diff --git a/src/colorpicker/colorpickerscene.cpp b/src/colorpicker/colorpickerscene.cpp index a8eb148..275e06f 100644 --- a/src/colorpicker/colorpickerscene.cpp +++ b/src/colorpicker/colorpickerscene.cpp @@ -1,11 +1,11 @@ #include "colorpickerscene.hpp" #include #include -#include #include #include #include #include +#include #include #include @@ -24,7 +24,7 @@ void ColorPickerScene::keyPressEvent(QKeyEvent *event) { color = image.pixelColor(cursorPos().toPoint()); if (event->key() == Qt::Key_Return) { QApplication::clipboard()->setText(color.name()); - logger::info(tr("Copied hex code to clipboard.")); + logger::info(tr("Copied hex code to clipboard.")); } if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Escape) close(); } diff --git a/src/cropeditor/cropscene.cpp b/src/cropeditor/cropscene.cpp index 8dd7f99..e309179 100644 --- a/src/cropeditor/cropscene.cpp +++ b/src/cropeditor/cropscene.cpp @@ -203,9 +203,9 @@ void CropScene::mouseMoved(QGraphicsSceneMouseEvent *e, QPointF cursorPos, QPoin if (e->buttons() & Qt::LeftButton) newRect.setBottomLeft(cursorPos); } } - if (!close) + if (!close) { views()[0]->setCursor(Qt::BlankCursor); - else { + } else { rect->setRect(newRect); prevButtons = e->buttons(); updatePoly(); @@ -220,29 +220,31 @@ void CropScene::mouseMoved(QGraphicsSceneMouseEvent *e, QPointF cursorPos, QPoin return; } if (buttons == Qt::LeftButton) { - if (drawingSelection) { - drawingSelection->mouseDragEvent(e, this); - } else { - QPointF p = cursorPos; - if (rect == nullptr) { - drawingRect = true; - rect = new SelectionRectangle(p.x(), p.y(), 1, 1); - initPos = p; - QPen pen(Qt::NoBrush, 1); - pen.setColor(highlight()); - rect->setPen(pen); - rect->setZValue(1); - addItem(rect); + if (!proxyMenu->sceneBoundingRect().contains(cursorPos)) { + if (drawingSelection) { + drawingSelection->mouseDragEvent(e, this); } else { - if (prevButtons == Qt::NoButton) { + QPointF p = cursorPos; + if (rect == nullptr) { + drawingRect = true; + rect = new SelectionRectangle(p.x(), p.y(), 1, 1); initPos = p; - rect->setRect(p.x(), p.y(), 1, 1); + QPen pen(Qt::NoBrush, 1); + pen.setColor(highlight()); + rect->setPen(pen); + rect->setZValue(1); + addItem(rect); } else { - rect->setRect(QRect(qMin(initPos.x(), p.x()), qMin(initPos.y(), p.y()), qAbs(initPos.x() - p.x()), - qAbs(initPos.y() - p.y()))); + if (prevButtons == Qt::NoButton) { + initPos = p; + rect->setRect(p.x(), p.y(), 1, 1); + } else { + rect->setRect(QRect(qMin(initPos.x(), p.x()), qMin(initPos.y(), p.y()), + qAbs(initPos.x() - p.x()), qAbs(initPos.y() - p.y()))); + } } + updatePoly(); } - updatePoly(); } } prevButtons = buttons; @@ -259,7 +261,10 @@ void CropScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) { done(true); prevButtons = Qt::NoButton; - if (e->modifiers() & Qt::ControlModifier) e->accept(); + if (e->modifiers() & Qt::ControlModifier) + e->accept(); + else + QGraphicsScene::mouseReleaseEvent(e); } void CropScene::mousePressEvent(QGraphicsSceneMouseEvent *e) { @@ -268,14 +273,17 @@ void CropScene::mousePressEvent(QGraphicsSceneMouseEvent *e) { if (item && item != proxyMenu) removeItem(item); } - if (e->modifiers() & Qt::ControlModifier) e->accept(); + if (e->modifiers() & Qt::ControlModifier) + e->accept(); + else + QGraphicsScene::mousePressEvent(e); } void CropScene::addDrawingAction(QMenuBar *menu, QString name, QString icon, std::function item) { QAction *action = menu->addAction(""); action->setToolTip(name); action->setIcon(QIcon(icon)); - connect(action, &QAction::triggered, [this, menu, action, item, name](bool) { setDrawingSelection(name, item); }); + connect(action, &QAction::triggered, [this, item, name](bool) { setDrawingSelection(name, item); }); } void CropScene::keyReleaseEvent(QKeyEvent *event) { diff --git a/src/cropeditor/cropview.hpp b/src/cropeditor/cropview.hpp index 6e48e73..23a0754 100644 --- a/src/cropeditor/cropview.hpp +++ b/src/cropeditor/cropview.hpp @@ -1,8 +1,8 @@ #ifndef CROPVIEW_HPP #define CROPVIEW_HPP -#include #include +#include #include class CropView : public ScreenOverlayView { @@ -10,6 +10,7 @@ class CropView : public ScreenOverlayView { public: CropView(QGraphicsScene *scene); ~CropView(); + protected: void showEvent(QShowEvent *e) override; }; diff --git a/src/cropeditor/drawing/textitem.cpp b/src/cropeditor/drawing/textitem.cpp index ae5a757..bcf00c0 100644 --- a/src/cropeditor/drawing/textitem.cpp +++ b/src/cropeditor/drawing/textitem.cpp @@ -17,8 +17,9 @@ void TextItem::mouseDragEvent(QGraphicsSceneMouseEvent *, CropScene *scene) { textItem->setPen(scene->pen().color()); textItem->setBrush(scene->pen().color()); } else { - auto ee = 180 + qRadiansToDegrees(qAtan2((textItem->pos().y() - scene->cursorPos().y()), - (textItem->pos().x() - scene->cursorPos().x()))); + auto ee = 180 + + qRadiansToDegrees(qAtan2((textItem->pos().y() - scene->cursorPos().y()), + (textItem->pos().x() - scene->cursorPos().x()))); textItem->setRotation(ee); } } diff --git a/src/formats.hpp b/src/formats.hpp index c4c5646..a5acd7c 100644 --- a/src/formats.hpp +++ b/src/formats.hpp @@ -13,5 +13,5 @@ namespace formats { QString recordingFormatName(Recording format); Recording recordingFormatFromName(QString format); QString recordingFormatMIME(Recording format); -} +} // namespace formats #endif // FORMATS_HPP diff --git a/src/hotkeying.hpp b/src/hotkeying.hpp index 4ff102c..a901599 100644 --- a/src/hotkeying.hpp +++ b/src/hotkeying.hpp @@ -10,6 +10,6 @@ namespace hotkeying { bool valid(QString seq); void load(QString seqName, std::function func, QString def = QString()); QString sequence(QString seqName); -} +} // namespace hotkeying #endif // HOTKEYING_HPP diff --git a/src/io/ioutils.hpp b/src/io/ioutils.hpp index c133d63..36a9f80 100644 --- a/src/io/ioutils.hpp +++ b/src/io/ioutils.hpp @@ -27,6 +27,6 @@ namespace ioutils { QHttpMultiPart *body, std::function callback); QString methodString(QNetworkAccessManager::Operation operation); -} +} // namespace ioutils #endif // IOUTILS_HPP diff --git a/src/logger.hpp b/src/logger.hpp index a8141d4..3e240ca 100644 --- a/src/logger.hpp +++ b/src/logger.hpp @@ -9,6 +9,6 @@ namespace logger { void error(QString info); // Oh no - it errored, but is recoverable, and still important enough to notify void fatal(QString info); // Unrecoverable error, procedure aborts and notifies the user void abort(QString info); // tell the user that it gonna ded -} +} // namespace logger #endif /* LOGGER_HPP */ diff --git a/src/logs/historydialog.cpp b/src/logs/historydialog.cpp index 9fe4832..383661e 100644 --- a/src/logs/historydialog.cpp +++ b/src/logs/historydialog.cpp @@ -16,8 +16,8 @@ HistoryDialog::HistoryDialog(QWidget *parent) : QDialog(parent), ui(new Ui::Hist QList requests = requestlogging::getRequests(); for (LoggedRequest req : requests) { - ui->treeWidget->addTopLevelItem(new QTreeWidgetItem( - { req.getType(), req.getUrl(), QString::number(req.getResponseCode()), req.getTime() + " UTC" })); + ui->treeWidget->addTopLevelItem( + new QTreeWidgetItem({ req.getType(), req.getUrl(), QString::number(req.getResponseCode()), req.getTime() + " UTC" })); } } diff --git a/src/logs/requestlogging.hpp b/src/logs/requestlogging.hpp index 48922f2..73ca70b 100644 --- a/src/logs/requestlogging.hpp +++ b/src/logs/requestlogging.hpp @@ -41,6 +41,6 @@ namespace requestlogging { QList getRequests(); void addEntry(RequestContext context); -} +} // namespace requestlogging #endif // REQUESTLOGGING_HPP diff --git a/src/main.cpp b/src/main.cpp index 42d7340..2969d74 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,4 @@ #include "mainwindow.hpp" -#include #include #include #include @@ -7,6 +6,7 @@ #include #include #include +#include extern "C" { #include #include diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4e32ca7..ea2184d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -9,12 +9,12 @@ #include #include #include +#include #include #include #include #include #include -#include MainWindow *MainWindow::instance; diff --git a/src/notifications.hpp b/src/notifications.hpp index 5e31597..75306be 100644 --- a/src/notifications.hpp +++ b/src/notifications.hpp @@ -7,6 +7,6 @@ namespace notifications { void notify(QString title, QString body, QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information); void notifyNolog(QString title, QString body, QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information); -} +} // namespace notifications #endif // NOTIFICATIONS_HPP diff --git a/src/platformspecifics/mac/macbackend.cpp b/src/platformspecifics/mac/macbackend.cpp index 61ad6cd..6665d6b 100644 --- a/src/platformspecifics/mac/macbackend.cpp +++ b/src/platformspecifics/mac/macbackend.cpp @@ -1,7 +1,7 @@ #include "macbackend.hpp" -#include #include +#include std::tuple PlatformBackend::getCursor() { #warning "TODO: Mac backend" @@ -21,13 +21,13 @@ bool PlatformBackend::filenameValid(QString name) { QString PlatformBackend::getCurrentUser() { auto pwent = getpwent(); - if(!pwent) { + if (!pwent) { if (qEnvironmentVariableIsSet("USER")) return QString::fromLocal8Bit(qgetenv("USER")); - else return QString(); + else + return QString(); } QString ret = QString::fromLocal8Bit(pwent->pw_name); endpwent(); return ret; } - diff --git a/src/platformspecifics/x11/x11backend.cpp b/src/platformspecifics/x11/x11backend.cpp index ea0e2c4..8670967 100644 --- a/src/platformspecifics/x11/x11backend.cpp +++ b/src/platformspecifics/x11/x11backend.cpp @@ -2,8 +2,8 @@ #include #include -#include #include +#include #include #include #include @@ -61,10 +61,11 @@ bool PlatformBackend::filenameValid(QString name) { QString PlatformBackend::getCurrentUser() { auto pwent = getpwent(); - if(!pwent) { + if (!pwent) { if (qEnvironmentVariableIsSet("USER")) return QString::fromLocal8Bit(qgetenv("USER")); - else return QString(); + else + return QString(); } QString ret = QString::fromLocal8Bit(pwent->pw_name); endpwent(); diff --git a/src/recording/recordingformats.cpp b/src/recording/recordingformats.cpp index 0fb64c1..ae8c217 100644 --- a/src/recording/recordingformats.cpp +++ b/src/recording/recordingformats.cpp @@ -2,12 +2,12 @@ #include #include -#include #include #include #include #include #include +#include #include #include #include diff --git a/src/recording/recordingpreview.cpp b/src/recording/recordingpreview.cpp index a8ecd47..3e31c41 100644 --- a/src/recording/recordingpreview.cpp +++ b/src/recording/recordingpreview.cpp @@ -57,6 +57,5 @@ void RecordingPreview::setPixmap(QPixmap map) { } void RecordingPreview::setTime(QString time, int frame) { if (isVisible()) - hintLabel->setText( - tr("Time: %1\nFrame: %2\nStop key: %3").arg(time).arg(frame).arg(hotkeying::sequence("recordingstop"))); + hintLabel->setText(tr("Time: %1\nFrame: %2\nStop key: %3").arg(time).arg(frame).arg(hotkeying::sequence("recordingstop"))); } diff --git a/src/screenoverlay/screenoverlay.cpp b/src/screenoverlay/screenoverlay.cpp index b74ecb3..3c324da 100644 --- a/src/screenoverlay/screenoverlay.cpp +++ b/src/screenoverlay/screenoverlay.cpp @@ -95,8 +95,9 @@ void ScreenOverlay::setMagVisibility(bool visible) { magnifierBox->setVisible(visible); magnifierHint->setVisible(visible); magnifierHintBox->setVisible(visible); - for (auto *view : views()) + for (auto *view : views()) { view->setCursor(visible ? Qt::BlankCursor : Qt::ArrowCursor); + } } void ScreenOverlay::showMag() { diff --git a/src/screenoverlay/screenoverlaysettings.cpp b/src/screenoverlay/screenoverlaysettings.cpp index b94b70f..09c8021 100644 --- a/src/screenoverlay/screenoverlaysettings.cpp +++ b/src/screenoverlay/screenoverlaysettings.cpp @@ -1,8 +1,8 @@ #include "screenoverlaysettings.hpp" #include "ui_screenoverlaysettings.h" -#include #include +#include ScreenOverlaySettings::ScreenOverlaySettings(ScreenOverlay *overlay, QWidget *parent) : QDialog(parent), ui(new Ui::ScreenOverlaySettings), overlay(overlay) { diff --git a/src/screenoverlay/screenoverlaysettings.hpp b/src/screenoverlay/screenoverlaysettings.hpp index 008bb84..061f5eb 100644 --- a/src/screenoverlay/screenoverlaysettings.hpp +++ b/src/screenoverlay/screenoverlaysettings.hpp @@ -1,15 +1,14 @@ #ifndef SCREENOVERLAYSETTINGS_H #define SCREENOVERLAYSETTINGS_H -#include #include "screenoverlay.hpp" +#include namespace Ui { -class ScreenOverlaySettings; + class ScreenOverlaySettings; } -class ScreenOverlaySettings : public QDialog -{ +class ScreenOverlaySettings : public QDialog { Q_OBJECT public: diff --git a/src/screenshotter.hpp b/src/screenshotter.hpp index 3932e25..f0f7d0d 100644 --- a/src/screenshotter.hpp +++ b/src/screenshotter.hpp @@ -10,6 +10,6 @@ namespace screenshotter { void activeDelayed(); void active(); -} +} // namespace screenshotter #endif // SCREENSHOTTER_HPP diff --git a/src/settings.cpp b/src/settings.cpp index 5c55461..64f1853 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1,7 +1,7 @@ #include "settings.hpp" -#include #include +#include QSettings &settings::settings() { static QSettings settings(dir().absoluteFilePath("settings.ini"), QSettings::IniFormat); diff --git a/src/settings.hpp b/src/settings.hpp index e22ff91..22661de 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -7,6 +7,6 @@ namespace settings { QSettings &settings(); QDir dir(); -} +} // namespace settings #endif // SETTINGS_HPP diff --git a/src/settingsdialog.hpp b/src/settingsdialog.hpp index d1b57ac..e90cd62 100644 --- a/src/settingsdialog.hpp +++ b/src/settingsdialog.hpp @@ -38,6 +38,7 @@ private slots: void on_fpsMax_valueChanged(int arg1); void on_fullscreenCapture_textChanged(QString newVal); void on_focusedCapture_textChanged(QString newVal); + private: Ui::SettingsDialog *ui; }; diff --git a/src/uploaders/default/imgplusuploader.cpp b/src/uploaders/default/imgplusuploader.cpp index 5cbdb6a..32a0a17 100644 --- a/src/uploaders/default/imgplusuploader.cpp +++ b/src/uploaders/default/imgplusuploader.cpp @@ -31,9 +31,8 @@ void ImgplusUploader::doUpload(QByteArray byteArray, QString format) { keyPart.setBody(settings::settings().value("imgplus/apikey").toString().toUtf8()); multipart->append(keyPart); - ioutils::postMultipartData(QUrl("http://imgpl.us/api/upload"), - { QPair("Accept", "application/json") }, multipart, - [](QByteArray link, QNetworkReply *) { + ioutils::postMultipartData(QUrl("http://imgpl.us/api/upload"), { QPair("Accept", "application/json") }, + multipart, [](QByteArray link, QNetworkReply *) { QApplication::clipboard()->setText(QString::fromUtf8(link)); if (!link.startsWith("http")) qCritical() << QObject::tr("Failed to upload! Copied the response to clipboard"); diff --git a/src/uploaders/uploadersingleton.cpp b/src/uploaders/uploadersingleton.cpp index 431ac9c..c9d0f7c 100644 --- a/src/uploaders/uploadersingleton.cpp +++ b/src/uploaders/uploadersingleton.cpp @@ -3,12 +3,12 @@ #include "default/clipboarduploader.hpp" #include "default/imguruploader.hpp" #include -#include #include #include #include #include #include +#include #include #include #include diff --git a/src/utils.cpp b/src/utils.cpp index 7ee95ed..65ae96b 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -136,7 +136,7 @@ void utils::externalScreenshot(std::function callback) { QObject::connect(process, QOverload::of(&QProcess::finished), [callback, process, tempPath](int code, QProcess::ExitStatus) { if (code != 0) { - logger::fatal(QObject::tr("Failed to take external screenshot: \n") + process->readAllStandardError()); + logger::fatal(QObject::tr("Failed to take external screenshot: \n") + process->readAllStandardError()); } else { QPixmap pixmap; if (!tempPath.isEmpty()) @@ -167,7 +167,7 @@ void utils::externalScreenshotActive(std::function callback) { QObject::connect(process, QOverload::of(&QProcess::finished), [callback, process, tempPath](int code, QProcess::ExitStatus) { if (code != 0) { - logger::fatal(QObject::tr("Failed to take external screenshot: \n") + process->readAllStandardError()); + logger::fatal(QObject::tr("Failed to take external screenshot: \n") + process->readAllStandardError()); } else { QPixmap pixmap; if (!tempPath.isEmpty()) diff --git a/src/utils.hpp b/src/utils.hpp index 263b9b5..f4c42a1 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -20,6 +20,6 @@ namespace utils { void externalScreenshot(std::function callback); void externalScreenshotActive(std::function callback); QString randomString(int length); -} +} // namespace utils #endif // UTILS_HPP