I just killed a few hours in the future by making alot of merge conflicts

This commit is contained in:
ArsenArsen 2017-05-22 19:34:29 +02:00
parent c15594cd57
commit 4150551d78
10 changed files with 15 additions and 36 deletions

View File

@ -6,8 +6,7 @@
#include <QGraphicsTextItem> #include <QGraphicsTextItem>
#include <QTimer> #include <QTimer>
ColorPickerScene::ColorPickerScene(QPixmap *pixmap, QWidget *parentWidget) ColorPickerScene::ColorPickerScene(QPixmap *pixmap, QWidget *parentWidget) : QGraphicsScene(), QGraphicsView(this, parentWidget) {
: QGraphicsScene(), QGraphicsView(this, parentWidget) {
setFrameShape(QFrame::NoFrame); // Time taken to solve: A george99g and 38 minutes. setFrameShape(QFrame::NoFrame); // Time taken to solve: A george99g and 38 minutes.
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

View File

@ -108,8 +108,7 @@ void CropScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
initPos = p; initPos = p;
rect->setRect(p.x(), p.y(), 1, 1); rect->setRect(p.x(), p.y(), 1, 1);
} else { } else {
rect->setRect(QRect(qMin(initPos.x(), p.x()), qMin(initPos.y(), p.y()), qAbs(initPos.x() - p.x()), rect->setRect(QRect(qMin(initPos.x(), p.x()), qMin(initPos.y(), p.y()), qAbs(initPos.x() - p.x()), qAbs(initPos.y() - p.y())));
qAbs(initPos.y() - p.y())));
} }
} }
QPolygonF poly; QPolygonF poly;

View File

@ -15,8 +15,7 @@ void TextItem::mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *scene) {
textItem->setPen(scene->pen()); textItem->setPen(scene->pen());
textItem->setBrush(scene->brush()); textItem->setBrush(scene->brush());
} else { } else {
auto ee auto ee = 180 + qRadiansToDegrees(qAtan2((textItem->pos().y() - e->scenePos().y()), (textItem->pos().x() - e->scenePos().x())));
= 180 + qRadiansToDegrees(qAtan2((textItem->pos().y() - e->scenePos().y()), (textItem->pos().x() - e->scenePos().x())));
textItem->setRotation(ee); textItem->setRotation(ee);
} }
} }

View File

@ -8,9 +8,7 @@ namespace ioutils {
QNetworkAccessManager networkManager; QNetworkAccessManager networkManager;
} }
void ioutils::getJson(QUrl target, void ioutils::getJson(QUrl target, QList<QPair<QString, QString>> headers, std::function<void(QJsonDocument, QByteArray, QNetworkReply *)> callback) {
QList<QPair<QString, QString>> headers,
std::function<void(QJsonDocument, QByteArray, QNetworkReply *)> callback) {
QNetworkRequest req(target); QNetworkRequest req(target);
for (auto header : headers) { for (auto header : headers) {
req.setRawHeader(header.first.toUtf8(), header.second.toUtf8()); req.setRawHeader(header.first.toUtf8(), header.second.toUtf8());
@ -23,10 +21,7 @@ void ioutils::getJson(QUrl target,
}); });
} }
void ioutils::postJson(QUrl target, void ioutils::postJson(QUrl target, QList<QPair<QString, QString>> headers, QByteArray body, std::function<void(QJsonDocument, QByteArray, QNetworkReply *)> callback) {
QList<QPair<QString, QString>> headers,
QByteArray body,
std::function<void(QJsonDocument, QByteArray, QNetworkReply *)> callback) {
QNetworkRequest req(target); QNetworkRequest req(target);
for (auto header : headers) { for (auto header : headers) {
req.setRawHeader(header.first.toUtf8(), header.second.toUtf8()); req.setRawHeader(header.first.toUtf8(), header.second.toUtf8());
@ -51,10 +46,7 @@ void ioutils::getData(QUrl target, QList<QPair<QString, QString>> headers, std::
}); });
} }
void ioutils::postData(QUrl target, void ioutils::postData(QUrl target, QList<QPair<QString, QString>> headers, QByteArray body, std::function<void(QByteArray, QNetworkReply *)> callback) {
QList<QPair<QString, QString>> headers,
QByteArray body,
std::function<void(QByteArray, QNetworkReply *)> callback) {
QNetworkRequest req(target); QNetworkRequest req(target);
for (auto header : headers) { for (auto header : headers) {
req.setRawHeader(header.first.toUtf8(), header.second.toUtf8()); req.setRawHeader(header.first.toUtf8(), header.second.toUtf8());

View File

@ -10,10 +10,7 @@
namespace ioutils { namespace ioutils {
extern QNetworkAccessManager networkManager; extern QNetworkAccessManager networkManager;
void getJson(QUrl target, QList<QPair<QString, QString>> headers, std::function<void(QJsonDocument, QByteArray, QNetworkReply *)> callback); void getJson(QUrl target, QList<QPair<QString, QString>> headers, std::function<void(QJsonDocument, QByteArray, QNetworkReply *)> callback);
void postJson(QUrl target, void postJson(QUrl target, QList<QPair<QString, QString>> headers, QByteArray body, std::function<void(QJsonDocument, QByteArray, QNetworkReply *)> callback);
QList<QPair<QString, QString>> headers,
QByteArray body,
std::function<void(QJsonDocument, QByteArray, QNetworkReply *)> callback);
void getData(QUrl target, QList<QPair<QString, QString>> headers, std::function<void(QByteArray, QNetworkReply *)> callback); void getData(QUrl target, QList<QPair<QString, QString>> headers, std::function<void(QByteArray, QNetworkReply *)> callback);
void postData(QUrl target, QList<QPair<QString, QString>> headers, QByteArray body, std::function<void(QByteArray, QNetworkReply *)> callback); void postData(QUrl target, QList<QPair<QString, QString>> headers, QByteArray body, std::function<void(QByteArray, QNetworkReply *)> callback);
} }

View File

@ -169,8 +169,7 @@ void MainWindow::on_hotkeys_doubleClicked(const QModelIndex &) {
QListWidgetItem *i = ui->hotkeys->selectedItems().at(0); QListWidgetItem *i = ui->hotkeys->selectedItems().at(0);
QString str = i->data(Qt::UserRole + 1).toString(); QString str = i->data(Qt::UserRole + 1).toString();
bool ok; bool ok;
QString seq = QInputDialog::getText(ui->centralWidget, "Hotkey Input", "Insert hotkey:", QLineEdit::Normal, QString seq = QInputDialog::getText(ui->centralWidget, "Hotkey Input", "Insert hotkey:", QLineEdit::Normal, hotkeying::sequence(str), &ok);
hotkeying::sequence(str), &ok);
if (ok && hotkeying::valid(seq)) hotkeying::hotkey(str, QKeySequence(seq), *fncs.value(str)); if (ok && hotkeying::valid(seq)) hotkeying::hotkey(str, QKeySequence(seq), *fncs.value(str));
} }
} }

View File

@ -11,8 +11,7 @@ std::tuple<QPoint, QPixmap> PlatformBackend::getCursor() {
if (cursorInfo.flags == CURSOR_SHOWING) { if (cursorInfo.flags == CURSOR_SHOWING) {
ICONINFO info; // It took me 5 hours to get to here ICONINFO info; // It took me 5 hours to get to here
if (GetIconInfo(cursorInfo.hCursor, &info)) { if (GetIconInfo(cursorInfo.hCursor, &info)) {
return std::tuple<QPoint, QPixmap>(QPoint(info.xHotspot, info.yHotspot), return std::tuple<QPoint, QPixmap>(QPoint(info.xHotspot, info.yHotspot), QtWin::fromHBITMAP(info.hbmColor, QtWin::HBitmapAlpha));
QtWin::fromHBITMAP(info.hbmColor, QtWin::HBitmapAlpha));
} else } else
return std::tuple<QPoint, QPixmap>(QPoint(0, 0), QPixmap()); return std::tuple<QPoint, QPixmap>(QPoint(0, 0), QPixmap());
} else } else

View File

@ -78,8 +78,7 @@ CustomUploader::CustomUploader(QString absFilePath) {
error(absFilePath, "imageformat not string"); error(absFilePath, "imageformat not string");
} }
QString imageFormat = imageValue.toString(); QString imageFormat = imageValue.toString();
if (imageFormat == "base64" || QRegExp("base64\\([^+]+\\+[^+]+)").exactMatch(imageFormat) if (imageFormat == "base64" || QRegExp("base64\\([^+]+\\+[^+]+)").exactMatch(imageFormat) || QRegExp("[^+]+\\+[^+]+").exactMatch(imageFormat)) {
|| QRegExp("[^+]+\\+[^+]+").exactMatch(imageFormat)) {
this->iFormat = imageFormat; this->iFormat = imageFormat;
} else } else
error(absFilePath, "imageformat invalid"); error(absFilePath, "imageformat invalid");
@ -231,8 +230,7 @@ void parseResult(QJsonDocument result, QByteArray data, QString returnPathspec,
} else } else
notifications::notify("KShare Custom Uploader " + name, "Upload done, but result empty!"); notifications::notify("KShare Custom Uploader " + name, "Upload done, but result empty!");
} else { } else {
notifications::notify("KShare Custom Uploader " + name, notifications::notify("KShare Custom Uploader " + name, "Upload done, but result is not JSON Object! Result in clipboard.");
"Upload done, but result is not JSON Object! Result in clipboard.");
QApplication::clipboard()->setText(data); QApplication::clipboard()->setText(data);
} }
} }

View File

@ -16,13 +16,11 @@ void ImgurUploader::doUpload(QPixmap *pixmap) {
return; return;
} }
ioutils::postJson(QUrl("https://api.imgur.com/3/image"), ioutils::postJson(QUrl("https://api.imgur.com/3/image"),
QList<QPair<QString, QString>>() QList<QPair<QString, QString>>() << QPair<QString, QString>("Content-Type", "application/x-www-form-urlencoded")
<< QPair<QString, QString>("Content-Type", "application/x-www-form-urlencoded") << QPair<QString, QString>("Authorization", "Client-ID 8a98f183fc895da"),
<< QPair<QString, QString>("Authorization", "Client-ID 8a98f183fc895da"),
byteArray, [](QJsonDocument res, QByteArray, QNetworkReply *) { byteArray, [](QJsonDocument res, QByteArray, QNetworkReply *) {
QString result = res.object()["data"].toObject()["link"].toString(); QString result = res.object()["data"].toObject()["link"].toString();
screenshotutil::toClipboard(result); screenshotutil::toClipboard(result);
notifications::notify("KShare imgur Uploader ", notifications::notify("KShare imgur Uploader ", result.isEmpty() ? "Failed upload!" : "Uploaded to imgur!");
result.isEmpty() ? "Failed upload!" : "Uploaded to imgur!");
}); });
} }

View File

@ -8,8 +8,7 @@
#include <formatter.hpp> #include <formatter.hpp>
#include <settings.hpp> #include <settings.hpp>
UploaderSingleton::UploaderSingleton() UploaderSingleton::UploaderSingleton() : QObject(), saveDir(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)) {
: QObject(), saveDir(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)) {
if (QStandardPaths::writableLocation(QStandardPaths::PicturesLocation).isEmpty()) { if (QStandardPaths::writableLocation(QStandardPaths::PicturesLocation).isEmpty()) {
qFatal("Cannot determine location for pictures"); qFatal("Cannot determine location for pictures");
} }