diff --git a/src/cli/commandlineparser.cpp b/src/cli/commandlineparser.cpp index 8c5ef697..1dfb3866 100644 --- a/src/cli/commandlineparser.cpp +++ b/src/cli/commandlineparser.cpp @@ -209,8 +209,8 @@ bool CommandLineParser::parse(const QStringList& args) ok = processIfOptionIsHelp(args, it, actualNode); // process the other args for (; it != args.cend() && ok; ++it) { - const QString& value = *it; - if (value.startsWith(QLatin1String("-"))) { + const QString& val = *it; + if (val.startsWith(QLatin1String("-"))) { ok = processOptions(args, it, actualNode); } else { diff --git a/src/config/cacheutils.cpp b/src/config/cacheutils.cpp index b84ead9c..a5a60efe 100644 --- a/src/config/cacheutils.cpp +++ b/src/config/cacheutils.cpp @@ -46,4 +46,4 @@ QRect getLastRegion() } return lastRegion; -} \ No newline at end of file +} diff --git a/src/config/cacheutils.h b/src/config/cacheutils.h index ad82ca4a..96413a23 100644 --- a/src/config/cacheutils.h +++ b/src/config/cacheutils.h @@ -11,4 +11,4 @@ QString getCachePath(); QRect getLastRegion(); void setLastRegion(QRect const& newRegion); -#endif // FLAMESHOT_CACHEUTILS_H \ No newline at end of file +#endif // FLAMESHOT_CACHEUTILS_H diff --git a/src/config/clickablelabel.cpp b/src/config/clickablelabel.cpp index c8dca6d9..be827647 100644 --- a/src/config/clickablelabel.cpp +++ b/src/config/clickablelabel.cpp @@ -7,7 +7,7 @@ ClickableLabel::ClickableLabel(QWidget* parent) : QLabel(parent) {} -ClickableLabel::ClickableLabel(QString s, QWidget* parent) +ClickableLabel::ClickableLabel(const QString& s, QWidget* parent) : QLabel(parent) { setText(s); diff --git a/src/config/clickablelabel.h b/src/config/clickablelabel.h index 068de199..c5e6f332 100644 --- a/src/config/clickablelabel.h +++ b/src/config/clickablelabel.h @@ -10,7 +10,7 @@ class ClickableLabel : public QLabel Q_OBJECT public: explicit ClickableLabel(QWidget* parent = nullptr); - ClickableLabel(QString s, QWidget* parent = nullptr); + ClickableLabel(const QString& s, QWidget* parent = nullptr); signals: void clicked(); diff --git a/src/config/filenameeditor.cpp b/src/config/filenameeditor.cpp index 3f0f62d6..027b04ef 100644 --- a/src/config/filenameeditor.cpp +++ b/src/config/filenameeditor.cpp @@ -106,7 +106,7 @@ void FileNameEditor::resetName() m_nameEditor->setText(ConfigHandler().filenamePattern()); } -void FileNameEditor::addToNameEditor(QString s) +void FileNameEditor::addToNameEditor(const QString& s) { m_nameEditor->setText(m_nameEditor->text() + s); m_nameEditor->setFocus(); diff --git a/src/config/filenameeditor.h b/src/config/filenameeditor.h index 99b4be2f..04697ab4 100644 --- a/src/config/filenameeditor.h +++ b/src/config/filenameeditor.h @@ -32,7 +32,7 @@ private: void initWidgets(); public slots: - void addToNameEditor(QString s); + void addToNameEditor(const QString& s); void updateComponents(); private slots: diff --git a/src/config/generalconf.cpp b/src/config/generalconf.cpp index fa679691..6205c6b5 100644 --- a/src/config/generalconf.cpp +++ b/src/config/generalconf.cpp @@ -486,9 +486,9 @@ void GeneralConf::initSaveAfterCopy() m_screenshotPathFixedCheck = new QCheckBox(tr("Use fixed path for screenshots to save"), this); connect(m_screenshotPathFixedCheck, - SIGNAL(toggled(bool)), + &QCheckBox::toggled, this, - SLOT(togglePathFixed())); + &GeneralConf::togglePathFixed); vboxLayout->addLayout(pathLayout); vboxLayout->addWidget(m_screenshotPathFixedCheck); @@ -510,9 +510,9 @@ void GeneralConf::initSaveAfterCopy() m_setSaveAsFileExtension->setCurrentIndex(currentIndex); connect(m_setSaveAsFileExtension, - SIGNAL(currentTextChanged(QString)), + &QComboBox::currentTextChanged, this, - SLOT(setSaveAsFileExtension(QString))); + &GeneralConf::setSaveAsFileExtension); extensionLayout->addWidget(m_setSaveAsFileExtension); vboxLayout->addLayout(extensionLayout); @@ -539,9 +539,9 @@ void GeneralConf::initUploadHistoryMax() QStringLiteral("color: %1").arg(foreground)); connect(m_uploadHistoryMax, - SIGNAL(valueChanged(int)), + static_cast(&QSpinBox::valueChanged), this, - SLOT(uploadHistoryMaxChanged(int))); + &GeneralConf::uploadHistoryMaxChanged); vboxLayout->addWidget(m_uploadHistoryMax); } @@ -560,9 +560,9 @@ void GeneralConf::initUploadClientSecret() QStringLiteral("color: %1").arg(foreground)); m_uploadClientKey->setText(ConfigHandler().uploadClientSecret()); connect(m_uploadClientKey, - SIGNAL(editingFinished()), + &QLineEdit::editingFinished, this, - SLOT(uploadClientKeyEdited())); + &GeneralConf::uploadClientKeyEdited); vboxLayout->addWidget(m_uploadClientKey); } @@ -591,7 +591,10 @@ void GeneralConf::initUndoLimit() QString foreground = this->palette().windowText().color().name(); m_undoLimit->setStyleSheet(QStringLiteral("color: %1").arg(foreground)); - connect(m_undoLimit, SIGNAL(valueChanged(int)), this, SLOT(undoLimit(int))); + connect(m_undoLimit, + static_cast(&QSpinBox::valueChanged), + this, + &GeneralConf::undoLimit); vboxLayout->addWidget(m_undoLimit); } @@ -670,7 +673,7 @@ void GeneralConf::initUploadWithoutConfirmation() }); } -const QString GeneralConf::chooseFolder(const QString pathDefault) +const QString GeneralConf::chooseFolder(const QString& pathDefault) { QString path; if (pathDefault.isEmpty()) { @@ -685,13 +688,13 @@ const QString GeneralConf::chooseFolder(const QString pathDefault) if (path.isEmpty()) { return path; } - if (!path.isEmpty()) { - if (!QFileInfo(path).isWritable()) { - QMessageBox::about( - this, tr("Error"), tr("Unable to write to directory.")); - return QString(); - } + + if (!QFileInfo(path).isWritable()) { + QMessageBox::about( + this, tr("Error"), tr("Unable to write to directory.")); + return QString(); } + return path; } @@ -733,9 +736,9 @@ void GeneralConf::initShowSelectionGeometry() m_scrollAreaLayout->addLayout(tobox); connect(m_xywhTimeout, - SIGNAL(valueChanged(int)), + static_cast(&QSpinBox::valueChanged), this, - SLOT(setSelGeoHideTime(int))); + &GeneralConf::setSelGeoHideTime); auto* box = new QGroupBox(tr("Selection Geometry Display")); box->setFlat(true); @@ -763,10 +766,11 @@ void GeneralConf::initShowSelectionGeometry() m_selectGeometryLocation->setCurrentIndex( m_selectGeometryLocation->findData(pos)); - connect(m_selectGeometryLocation, - SIGNAL(currentIndexChanged(int)), - this, - SLOT(setGeometryLocation(int))); + connect( + m_selectGeometryLocation, + static_cast(&QComboBox::currentIndexChanged), + this, + &GeneralConf::setGeometryLocation); selGeoLayout->addWidget(m_selectGeometryLocation); vboxLayout->addLayout(selGeoLayout); @@ -789,7 +793,7 @@ void GeneralConf::togglePathFixed() ConfigHandler().setSavePathFixed(m_screenshotPathFixedCheck->isChecked()); } -void GeneralConf::setSaveAsFileExtension(QString extension) +void GeneralConf::setSaveAsFileExtension(const QString& extension) { ConfigHandler().setSaveAsFileExtension(extension); } diff --git a/src/config/generalconf.h b/src/config/generalconf.h index 29bbfffe..0444de7c 100644 --- a/src/config/generalconf.h +++ b/src/config/generalconf.h @@ -54,12 +54,12 @@ private slots: void togglePathFixed(); void uploadClientKeyEdited(); void useJpgForClipboardChanged(bool checked); - void setSaveAsFileExtension(QString extension); + void setSaveAsFileExtension(const QString& extension); void setGeometryLocation(int index); void setSelGeoHideTime(int v); private: - const QString chooseFolder(const QString currentPath = ""); + const QString chooseFolder(const QString& currentPath = ""); void initAllowMultipleGuiInstances(); void initAntialiasingPinZoom(); diff --git a/src/config/setshortcutwidget.cpp b/src/config/setshortcutwidget.cpp index c2002406..8c0de2d0 100644 --- a/src/config/setshortcutwidget.cpp +++ b/src/config/setshortcutwidget.cpp @@ -9,7 +9,8 @@ #include #include -SetShortcutDialog::SetShortcutDialog(QDialog* parent, QString shortcutName) +SetShortcutDialog::SetShortcutDialog(QDialog* parent, + const QString& shortcutName) : QDialog(parent) { setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); diff --git a/src/config/setshortcutwidget.h b/src/config/setshortcutwidget.h index 4d25df49..12324613 100644 --- a/src/config/setshortcutwidget.h +++ b/src/config/setshortcutwidget.h @@ -15,7 +15,7 @@ class SetShortcutDialog : public QDialog Q_OBJECT public: explicit SetShortcutDialog(QDialog* parent = nullptr, - QString shortcutName = ""); + const QString& shortcutName = ""); const QKeySequence& shortcut(); public: diff --git a/src/core/flameshot.cpp b/src/core/flameshot.cpp index ca7d5fb2..54b0ada4 100644 --- a/src/core/flameshot.cpp +++ b/src/core/flameshot.cpp @@ -279,8 +279,9 @@ Flameshot::Origin Flameshot::origin() bool Flameshot::resolveAnyConfigErrors() { bool resolved = true; - ConfigHandler config; - if (!config.checkUnrecognizedSettings() || !config.checkSemantics()) { + ConfigHandler confighandler; + if (!confighandler.checkUnrecognizedSettings() || + !confighandler.checkSemantics()) { auto* resolver = new ConfigResolver(); QObject::connect( resolver, &ConfigResolver::rejected, [resolver, &resolved]() { @@ -333,7 +334,7 @@ void Flameshot::requestCapture(const CaptureRequest& request) } } -void Flameshot::exportCapture(QPixmap capture, +void Flameshot::exportCapture(const QPixmap& capture, QRect& selection, const CaptureRequest& req) { diff --git a/src/core/flameshot.h b/src/core/flameshot.h index 01f13f8a..f625a801 100644 --- a/src/core/flameshot.h +++ b/src/core/flameshot.h @@ -56,7 +56,9 @@ signals: public slots: void requestCapture(const CaptureRequest& request); - void exportCapture(QPixmap p, QRect& selection, const CaptureRequest& req); + void exportCapture(const QPixmap& p, + QRect& selection, + const CaptureRequest& req); private: Flameshot(); diff --git a/src/core/flameshotdaemon.cpp b/src/core/flameshotdaemon.cpp index fdad6a20..b8fdf3cd 100644 --- a/src/core/flameshotdaemon.cpp +++ b/src/core/flameshotdaemon.cpp @@ -106,7 +106,7 @@ void FlameshotDaemon::start() } } -void FlameshotDaemon::createPin(QPixmap capture, QRect geometry) +void FlameshotDaemon::createPin(const QPixmap& capture, QRect geometry) { if (instance()) { instance()->attachPin(capture, geometry); @@ -122,7 +122,7 @@ void FlameshotDaemon::createPin(QPixmap capture, QRect geometry) call(m); } -void FlameshotDaemon::copyToClipboard(QPixmap capture) +void FlameshotDaemon::copyToClipboard(const QPixmap& capture) { if (instance()) { instance()->attachScreenshotToClipboard(capture); @@ -140,7 +140,8 @@ void FlameshotDaemon::copyToClipboard(QPixmap capture) call(m); } -void FlameshotDaemon::copyToClipboard(QString text, QString notification) +void FlameshotDaemon::copyToClipboard(const QString& text, + const QString& notification) { if (instance()) { instance()->attachTextToClipboard(text, notification); @@ -187,12 +188,14 @@ void FlameshotDaemon::getLatestAvailableVersion() { // This features is required for MacOS and Windows user and for Linux users // who installed Flameshot not from the repository. - m_networkCheckUpdates = new QNetworkAccessManager(this); QNetworkRequest requestCheckUpdates(QUrl(FLAMESHOT_APP_VERSION_URL)); - connect(m_networkCheckUpdates, - &QNetworkAccessManager::finished, - this, - &FlameshotDaemon::handleReplyCheckUpdates); + if (nullptr == m_networkCheckUpdates) { + m_networkCheckUpdates = new QNetworkAccessManager(this); + connect(m_networkCheckUpdates, + &QNetworkAccessManager::finished, + this, + &FlameshotDaemon::handleReplyCheckUpdates); + } m_networkCheckUpdates->get(requestCheckUpdates); // check for updates each 24 hours @@ -253,7 +256,7 @@ void FlameshotDaemon::quitIfIdle() // SERVICE METHODS -void FlameshotDaemon::attachPin(QPixmap pixmap, QRect geometry) +void FlameshotDaemon::attachPin(const QPixmap& pixmap, QRect geometry) { auto* pinWidget = new PinWidget(pixmap, geometry); m_widgets.append(pinWidget); @@ -266,7 +269,7 @@ void FlameshotDaemon::attachPin(QPixmap pixmap, QRect geometry) pinWidget->activateWindow(); } -void FlameshotDaemon::attachScreenshotToClipboard(QPixmap pixmap) +void FlameshotDaemon::attachScreenshotToClipboard(const QPixmap& pixmap) { m_hostingClipboard = true; QClipboard* clipboard = QApplication::clipboard(); @@ -301,7 +304,8 @@ void FlameshotDaemon::attachScreenshotToClipboard(const QByteArray& screenshot) attachScreenshotToClipboard(p); } -void FlameshotDaemon::attachTextToClipboard(QString text, QString notification) +void FlameshotDaemon::attachTextToClipboard(const QString& text, + const QString& notification) { // Must send notification before clipboard modification on linux if (!notification.isEmpty()) { @@ -391,7 +395,7 @@ void FlameshotDaemon::handleReplyCheckUpdates(QNetworkReply* reply) } #endif -QDBusMessage FlameshotDaemon::createMethodCall(QString method) +QDBusMessage FlameshotDaemon::createMethodCall(const QString& method) { QDBusMessage m = QDBusMessage::createMethodCall(QStringLiteral("org.flameshot.Flameshot"), diff --git a/src/core/flameshotdaemon.h b/src/core/flameshotdaemon.h index c729ce8a..e49c815e 100644 --- a/src/core/flameshotdaemon.h +++ b/src/core/flameshotdaemon.h @@ -23,9 +23,10 @@ class FlameshotDaemon : public QObject public: static void start(); static FlameshotDaemon* instance(); - static void createPin(QPixmap capture, QRect geometry); - static void copyToClipboard(QPixmap capture); - static void copyToClipboard(QString text, QString notification = ""); + static void createPin(const QPixmap& capture, QRect geometry); + static void copyToClipboard(const QPixmap& capture); + static void copyToClipboard(const QString& text, + const QString& notification = ""); static bool isThisInstanceHostingWidgets(); void sendTrayNotification( @@ -50,17 +51,19 @@ signals: private: FlameshotDaemon(); void quitIfIdle(); - void attachPin(QPixmap pixmap, QRect geometry); - void attachScreenshotToClipboard(QPixmap pixmap); + void attachPin(const QPixmap& pixmap, QRect geometry); + void attachScreenshotToClipboard(const QPixmap& pixmap); void attachPin(const QByteArray& data); void attachScreenshotToClipboard(const QByteArray& screenshot); - void attachTextToClipboard(QString text, QString notification); + void attachTextToClipboard(const QString& text, + const QString& notification); void initTrayIcon(); void enableTrayIcon(bool enable); - static QDBusMessage createMethodCall(QString method); +private: + static QDBusMessage createMethodCall(const QString& method); static void checkDBusConnection(const QDBusConnection& connection); static void call(const QDBusMessage& m); diff --git a/src/core/flameshotdbusadapter.cpp b/src/core/flameshotdbusadapter.cpp index 11632e9f..fc48b156 100644 --- a/src/core/flameshotdbusadapter.cpp +++ b/src/core/flameshotdbusadapter.cpp @@ -15,8 +15,8 @@ void FlameshotDBusAdapter::attachScreenshotToClipboard(const QByteArray& data) FlameshotDaemon::instance()->attachScreenshotToClipboard(data); } -void FlameshotDBusAdapter::attachTextToClipboard(QString text, - QString notification) +void FlameshotDBusAdapter::attachTextToClipboard(const QString& text, + const QString& notification) { FlameshotDaemon::instance()->attachTextToClipboard(text, notification); } diff --git a/src/core/flameshotdbusadapter.h b/src/core/flameshotdbusadapter.h index d9e96632..eb46d1d6 100644 --- a/src/core/flameshotdbusadapter.h +++ b/src/core/flameshotdbusadapter.h @@ -16,6 +16,7 @@ public: public slots: Q_NOREPLY void attachScreenshotToClipboard(const QByteArray& data); - Q_NOREPLY void attachTextToClipboard(QString text, QString notification); + Q_NOREPLY void attachTextToClipboard(const QString& text, + const QString& notification); Q_NOREPLY void attachPin(const QByteArray& data); }; diff --git a/src/tools/capturetool.h b/src/tools/capturetool.h index e9fc669f..a095d618 100644 --- a/src/tools/capturetool.h +++ b/src/tools/capturetool.h @@ -191,7 +191,7 @@ public slots: virtual void drawMoveWithAdjustment(const QPoint& p) { drawMove(p); } // Called when the tool is activated. virtual void drawStart(const CaptureContext& context) = 0; - // Called right after pressign the button which activates the tool. + // Called right after pressing the button which activates the tool. virtual void pressed(CaptureContext& context) = 0; // Called when the color is changed in the editor. virtual void onColorChanged(const QColor& c) = 0; diff --git a/src/tools/launcher/terminallauncher.cpp b/src/tools/launcher/terminallauncher.cpp index 4c0aa204..3b9b810a 100644 --- a/src/tools/launcher/terminallauncher.cpp +++ b/src/tools/launcher/terminallauncher.cpp @@ -44,6 +44,5 @@ TerminalApp TerminalLauncher::getPreferedTerminal() bool TerminalLauncher::launchDetached(const QString& command) { TerminalApp app = getPreferedTerminal(); - QString s = app.name + " " + app.arg + " " + command; return QProcess::startDetached(app.name, { app.arg, command }); } diff --git a/src/tools/text/texttool.cpp b/src/tools/text/texttool.cpp index 798688a3..30fbfd4e 100644 --- a/src/tools/text/texttool.cpp +++ b/src/tools/text/texttool.cpp @@ -203,10 +203,10 @@ void TextTool::process(QPainter& painter, const QPixmap& pixmap) QFont orig_font = painter.font(); QPen orig_pen = painter.pen(); QFontMetrics fm(m_font); - QSize size(fm.boundingRect(QRect(), 0, m_text).size()); - size.setWidth(size.width() + val * 2); - size.setHeight(size.height() + val * 2); - m_textArea.setSize(size); + QSize fontsize(fm.boundingRect(QRect(), 0, m_text).size()); + fontsize.setWidth(fontsize.width() + val * 2); + fontsize.setHeight(fontsize.height() + val * 2); + m_textArea.setSize(fontsize); // draw text painter.setFont(m_font); painter.setPen(m_color); diff --git a/src/utils/abstractlogger.cpp b/src/utils/abstractlogger.cpp index 3de73e28..986cd602 100644 --- a/src/utils/abstractlogger.cpp +++ b/src/utils/abstractlogger.cpp @@ -45,7 +45,7 @@ AbstractLogger AbstractLogger::error(int targets) return { Error, targets }; } -AbstractLogger& AbstractLogger::sendMessage(QString msg, Channel channel) +AbstractLogger& AbstractLogger::sendMessage(const QString& msg, Channel channel) { if (m_targets & Notification) { SystemNotification().sendMessage( @@ -77,7 +77,7 @@ AbstractLogger& AbstractLogger::sendMessage(QString msg, Channel channel) * @param msg * @return */ -AbstractLogger& AbstractLogger::operator<<(QString msg) +AbstractLogger& AbstractLogger::operator<<(const QString& msg) { sendMessage(msg, m_defaultChannel); return *this; @@ -92,7 +92,7 @@ AbstractLogger& AbstractLogger::addOutputString(QString& str) /** * @brief Attach a path to a notification so it can be dragged and dropped. */ -AbstractLogger& AbstractLogger::attachNotificationPath(QString path) +AbstractLogger& AbstractLogger::attachNotificationPath(const QString& path) { if (m_targets & Notification) { m_notificationPath = path; diff --git a/src/utils/abstractlogger.h b/src/utils/abstractlogger.h index 05ce8af5..6fc8ff7f 100644 --- a/src/utils/abstractlogger.h +++ b/src/utils/abstractlogger.h @@ -37,10 +37,10 @@ public: static AbstractLogger warning(int targets = Default); static AbstractLogger error(int targets = Default); - AbstractLogger& sendMessage(QString msg, Channel channel); - AbstractLogger& operator<<(QString msg); + AbstractLogger& sendMessage(const QString& msg, Channel channel); + AbstractLogger& operator<<(const QString& msg); AbstractLogger& addOutputString(QString& str); - AbstractLogger& attachNotificationPath(QString path); + AbstractLogger& attachNotificationPath(const QString& path); AbstractLogger& enableMessageHeader(bool enable); private: diff --git a/src/utils/confighandler.cpp b/src/utils/confighandler.cpp index b77b964e..effe4cb1 100644 --- a/src/utils/confighandler.cpp +++ b/src/utils/confighandler.cpp @@ -321,9 +321,9 @@ void ConfigHandler::setStartupLaunch(const bool start) void ConfigHandler::setAllTheButtons() { - QList buttons = + QList buttonlist = CaptureToolButton::getIterableButtonTypes(); - setValue(QStringLiteral("buttons"), QVariant::fromValue(buttons)); + setValue(QStringLiteral("buttons"), QVariant::fromValue(buttonlist)); } void ConfigHandler::setToolSize(CaptureTool::Type toolType, int size) @@ -388,16 +388,16 @@ bool ConfigHandler::setShortcut(const QString& actionName, return false; } - bool error = false; + bool errorFlag = false; m_settings.beginGroup(CONFIG_GROUP_SHORTCUTS); if (shortcut.isEmpty()) { setValue(actionName, ""); } else if (reservedShortcuts.contains(QKeySequence(shortcut))) { // do not allow to set reserved shortcuts - error = true; + errorFlag = true; } else { - error = false; + errorFlag = false; // Make no difference for Return and Enter keys QString newShortcut = KeySequence().value(shortcut).toString(); for (auto& otherAction : m_settings.allKeys()) { @@ -407,7 +407,7 @@ bool ConfigHandler::setShortcut(const QString& actionName, QString existingShortcut = KeySequence().value(m_settings.value(otherAction)).toString(); if (newShortcut == existingShortcut) { - error = true; + errorFlag = true; goto done; } } @@ -415,7 +415,7 @@ bool ConfigHandler::setShortcut(const QString& actionName, } done: m_settings.endGroup(); - return !error; + return !errorFlag; } QString ConfigHandler::shortcut(const QString& actionName) @@ -787,7 +787,7 @@ bool ConfigHandler::isShortcut(const QString& key) const key.startsWith(QStringLiteral(CONFIG_GROUP_SHORTCUTS "/")); } -QString ConfigHandler::baseName(QString key) const +QString ConfigHandler::baseName(const QString& key) const { return QFileInfo(key).baseName(); } diff --git a/src/utils/confighandler.h b/src/utils/confighandler.h index e8f47754..62f653e7 100644 --- a/src/utils/confighandler.h +++ b/src/utils/confighandler.h @@ -178,6 +178,6 @@ private: QSharedPointer valueHandler(const QString& key) const; void assertKeyRecognized(const QString& key) const; bool isShortcut(const QString& key) const; - QString baseName(QString key) const; + QString baseName(const QString& key) const; void cleanUnusedKeys(const QString& group, const QSet& keys) const; }; diff --git a/src/utils/filenamehandler.cpp b/src/utils/filenamehandler.cpp index ffee2569..4e3aa392 100644 --- a/src/utils/filenamehandler.cpp +++ b/src/utils/filenamehandler.cpp @@ -102,7 +102,7 @@ QString FileNameHandler::properScreenshotPath(QString path, } } -QString FileNameHandler::autoNumerateDuplicate(QString path) +QString FileNameHandler::autoNumerateDuplicate(const QString& path) { // add numeration in case of repeated filename in the directory // find unused name adding _n where n is a number diff --git a/src/utils/filenamehandler.h b/src/utils/filenamehandler.h index 921029ba..88c720ef 100644 --- a/src/utils/filenamehandler.h +++ b/src/utils/filenamehandler.h @@ -20,5 +20,5 @@ public: static const int MAX_CHARACTERS = 70; private: - QString autoNumerateDuplicate(QString path); + QString autoNumerateDuplicate(const QString& path); }; diff --git a/src/utils/history.cpp b/src/utils/history.cpp index e1f8d37e..f3ee09d0 100644 --- a/src/utils/history.cpp +++ b/src/utils/history.cpp @@ -12,9 +12,9 @@ History::History() #ifdef Q_OS_WIN m_historyPath = QDir::homePath() + "/AppData/Roaming/flameshot/history/"; #else - QString path = QProcessEnvironment::systemEnvironment().value( + QString cachepath = QProcessEnvironment::systemEnvironment().value( "XDG_CACHE_HOME", QDir::homePath() + "/.cache"); - m_historyPath = path + "/flameshot/history/"; + m_historyPath = cachepath + "/flameshot/history/"; #endif // Check if directory for history exists and create if doesn't diff --git a/src/utils/pathinfo.cpp b/src/utils/pathinfo.cpp index 6b2ad5e4..ea3faf67 100644 --- a/src/utils/pathinfo.cpp +++ b/src/utils/pathinfo.cpp @@ -26,7 +26,6 @@ QStringList PathInfo::translationsPaths() << QStringLiteral(APP_PREFIX) + "/share/flameshot/translations" << trPath << QStringLiteral("/usr/share/flameshot/translations") << QStringLiteral("/usr/local/share/flameshot/translations"); -#elif defined(Q_OS_WIN) - return QStringList() << trPath; #endif + return QStringList() << trPath; } diff --git a/src/utils/valuehandler.cpp b/src/utils/valuehandler.cpp index 281e71ff..099255d6 100644 --- a/src/utils/valuehandler.cpp +++ b/src/utils/valuehandler.cpp @@ -513,7 +513,7 @@ QString SaveFileExtension::expected() bool Region::check(const QVariant& val) { QVariant region = process(val); - return process(val).isValid(); + return region.isValid(); } #include // TODO remove after FIXME (see below) diff --git a/src/widgets/capture/buttonhandler.cpp b/src/widgets/capture/buttonhandler.cpp index afd10754..4a003714 100644 --- a/src/widgets/capture/buttonhandler.cpp +++ b/src/widgets/capture/buttonhandler.cpp @@ -353,7 +353,7 @@ void ButtonHandler::adjustHorizontalCenter(QPoint& center) } // setButtons redefines the buttons of the button handler -void ButtonHandler::setButtons(const QVector v) +void ButtonHandler::setButtons(const QVector& v) { if (v.isEmpty()) { return; diff --git a/src/widgets/capture/buttonhandler.h b/src/widgets/capture/buttonhandler.h index bd694653..ca59971e 100644 --- a/src/widgets/capture/buttonhandler.h +++ b/src/widgets/capture/buttonhandler.h @@ -26,7 +26,7 @@ public: bool buttonsAreInside() const; size_t size() const; - void setButtons(const QVector); + void setButtons(const QVector&); bool contains(const QPoint& p) const; void updateScreenRegions(const QVector& rects); void updateScreenRegions(const QRect& rect); diff --git a/src/widgets/capture/capturetoolobjects.cpp b/src/widgets/capture/capturetoolobjects.cpp index b0159f22..969492ec 100644 --- a/src/widgets/capture/capturetoolobjects.cpp +++ b/src/widgets/capture/capturetoolobjects.cpp @@ -61,7 +61,7 @@ void CaptureToolObjects::removeAt(int index) } } -int CaptureToolObjects::find(const QPoint& pos, const QSize& captureSize) +int CaptureToolObjects::find(const QPoint& pos, QSize captureSize) { if (m_captureToolObjects.empty()) { return -1; diff --git a/src/widgets/capture/capturetoolobjects.h b/src/widgets/capture/capturetoolobjects.h index 296479af..5c1f0447 100644 --- a/src/widgets/capture/capturetoolobjects.h +++ b/src/widgets/capture/capturetoolobjects.h @@ -18,7 +18,7 @@ public: void removeAt(int index); void clear(); int size(); - int find(const QPoint& pos, const QSize& captureSize); + int find(const QPoint& pos, QSize captureSize); QPointer at(int index); CaptureToolObjects& operator=(const CaptureToolObjects& other); diff --git a/src/widgets/capture/capturewidget.cpp b/src/widgets/capture/capturewidget.cpp index c12f03b0..3d535663 100644 --- a/src/widgets/capture/capturewidget.cpp +++ b/src/widgets/capture/capturewidget.cpp @@ -56,29 +56,27 @@ CaptureWidget::CaptureWidget(const CaptureRequest& req, bool fullScreen, QWidget* parent) : QWidget(parent) + , m_toolSizeByKeyboard(0) , m_mouseIsClicked(false) , m_captureDone(false) , m_previewEnabled(true) , m_adjustmentButtonPressed(false) , m_configError(false) , m_configErrorResolved(false) + , m_updateNotificationWidget(nullptr) + , m_lastMouseWheel(0) , m_activeButton(nullptr) , m_activeTool(nullptr) - , m_toolWidget(nullptr) - , m_colorPicker(nullptr) - , m_lastMouseWheel(0) -#if !defined(DISABLE_UPDATE_CHECKER) - , m_updateNotificationWidget(nullptr) -#endif , m_activeToolIsMoved(false) + , m_toolWidget(nullptr) , m_panel(nullptr) , m_sidePanel(nullptr) + , m_colorPicker(nullptr) , m_selection(nullptr) , m_magnifier(nullptr) + , m_xywhDisplay(false) , m_existingObjectIsChanged(false) , m_startMove(false) - , m_toolSizeByKeyboard(0) - , m_xywhDisplay(false) { m_undoStack.setUndoLimit(ConfigHandler().undoLimit()); @@ -95,7 +93,7 @@ CaptureWidget::CaptureWidget(const CaptureRequest& req, this, &CaptureWidget::childLeave); - connect(&m_xywhTimer, SIGNAL(timeout()), this, SLOT(xywhTick())); + connect(&m_xywhTimer, &QTimer::timeout, this, &CaptureWidget::xywhTick); setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_QuitOnClose, false); m_opacity = m_config.contrastOpacity(); @@ -328,8 +326,8 @@ void CaptureWidget::initButtons() ConfigHandler().shortcut(QVariant::fromValue(t).toString()); if (!shortcut.isNull()) { auto shortcuts = newShortcut(shortcut, this, nullptr); - for (auto* shortcut : shortcuts) { - connect(shortcut, &QShortcut::activated, this, [=]() { + for (auto* sc : shortcuts) { + connect(sc, &QShortcut::activated, this, [=]() { setState(b); }); } @@ -420,28 +418,26 @@ void CaptureWidget::showxywh(bool show) void CaptureWidget::initHelpMessage() { QList> keyMap; - if (keyMap.isEmpty()) { - keyMap << QPair(tr("Mouse"), tr("Select screenshot area")); - using CT = CaptureTool; - for (auto toolType : - { CT::TYPE_ACCEPT, CT::TYPE_SAVE, CT::TYPE_COPY }) { - if (!m_tools.contains(toolType)) { - continue; - } - auto* tool = m_tools[toolType]; - QString shortcut = ConfigHandler().shortcut( - QVariant::fromValue(toolType).toString()); - shortcut.replace("Return", "Enter"); - if (!shortcut.isEmpty()) { - keyMap << QPair(shortcut, tool->description()); - } + keyMap << QPair(tr("Mouse"), tr("Select screenshot area")); + using CT = CaptureTool; + for (auto toolType : { CT::TYPE_ACCEPT, CT::TYPE_SAVE, CT::TYPE_COPY }) { + if (!m_tools.contains(toolType)) { + continue; + } + auto* tool = m_tools[toolType]; + QString shortcut = + ConfigHandler().shortcut(QVariant::fromValue(toolType).toString()); + shortcut.replace("Return", "Enter"); + if (!shortcut.isEmpty()) { + keyMap << QPair(shortcut, tool->description()); } - keyMap << QPair(tr("Mouse Wheel"), tr("Change tool size")); - keyMap << QPair(tr("Right Click"), tr("Show color picker")); - keyMap << QPair(ConfigHandler().shortcut("TYPE_TOGGLE_PANEL"), - tr("Open side panel")); - keyMap << QPair(tr("Esc"), tr("Exit")); } + keyMap << QPair(tr("Mouse Wheel"), tr("Change tool size")); + keyMap << QPair(tr("Right Click"), tr("Show color picker")); + keyMap << QPair(ConfigHandler().shortcut("TYPE_TOGGLE_PANEL"), + tr("Open side panel")); + keyMap << QPair(tr("Esc"), tr("Exit")); + m_helpMessage = OverlayMessage::compileFromKeyMap(keyMap); } @@ -1499,15 +1495,13 @@ void CaptureWidget::removeToolObject(int index) --index; if (index >= 0 && index < m_captureToolObjects.size()) { // in case this tool is circle counter - int removedCircleCount = -1; - const CaptureTool::Type currentToolType = m_captureToolObjects.at(index)->type(); m_captureToolObjectsBackup = m_captureToolObjects; update( paddedUpdateRect(m_captureToolObjects.at(index)->boundingRect())); if (currentToolType == CaptureTool::TYPE_CIRCLECOUNT) { - removedCircleCount = m_captureToolObjects.at(index)->count(); + int removedCircleCount = m_captureToolObjects.at(index)->count(); --m_context.circleCount; // Decrement circle counter numbers starting from deleted circle for (int cnt = 0; cnt < m_captureToolObjects.size(); cnt++) { diff --git a/src/widgets/capture/selectionwidget.cpp b/src/widgets/capture/selectionwidget.cpp index 68c208e2..5e5fe355 100644 --- a/src/widgets/capture/selectionwidget.cpp +++ b/src/widgets/capture/selectionwidget.cpp @@ -384,8 +384,8 @@ void SelectionWidget::paintEvent(QPaintEvent*) p.drawRect(rect() + QMargins(0, 0, -1, -1)); p.setRenderHint(QPainter::Antialiasing); p.setBrush(m_color); - for (auto rect : handlerAreas()) { - p.drawEllipse(rect); + for (auto rectangle : handlerAreas()) { + p.drawEllipse(rectangle); } } @@ -549,14 +549,14 @@ void SelectionWidget::updateCursor() void SelectionWidget::setGeometryByKeyboard(const QRect& r) { static QTimer timer; - QRect rect = r.intersected(parentWidget()->rect()); - if (rect.width() <= 0) { - rect.setWidth(1); + QRect rectangle = r.intersected(parentWidget()->rect()); + if (rectangle.width() <= 0) { + rectangle.setWidth(1); } - if (rect.height() <= 0) { - rect.setHeight(1); + if (rectangle.height() <= 0) { + rectangle.setHeight(1); } - setGeometry(rect); + setGeometry(rectangle); connect(&timer, &QTimer::timeout, this, diff --git a/src/widgets/orientablepushbutton.cpp b/src/widgets/orientablepushbutton.cpp index c387e6df..091397d4 100644 --- a/src/widgets/orientablepushbutton.cpp +++ b/src/widgets/orientablepushbutton.cpp @@ -62,7 +62,7 @@ OrientablePushButton::Orientation OrientablePushButton::orientation() const } void OrientablePushButton::setOrientation( - const OrientablePushButton::Orientation& orientation) + OrientablePushButton::Orientation orientation) { m_orientation = orientation; } diff --git a/src/widgets/orientablepushbutton.h b/src/widgets/orientablepushbutton.h index 9f4cab11..0082ff4c 100644 --- a/src/widgets/orientablepushbutton.h +++ b/src/widgets/orientablepushbutton.h @@ -28,7 +28,7 @@ public: QSize sizeHint() const; OrientablePushButton::Orientation orientation() const; - void setOrientation(const OrientablePushButton::Orientation& orientation); + void setOrientation(OrientablePushButton::Orientation orientation); protected: void paintEvent(QPaintEvent* event); diff --git a/src/widgets/panel/utilitypanel.cpp b/src/widgets/panel/utilitypanel.cpp index 18401b4f..5fc1889e 100644 --- a/src/widgets/panel/utilitypanel.cpp +++ b/src/widgets/panel/utilitypanel.cpp @@ -137,9 +137,9 @@ void UtilityPanel::initInternalPanel() m_captureTools = new QListWidget(this); connect(m_captureTools, - SIGNAL(currentRowChanged(int)), + &QListWidget::currentRowChanged, this, - SLOT(onCurrentRowChanged(int))); + &UtilityPanel::onCurrentRowChanged); auto* layersButtons = new QHBoxLayout(); m_layersLayout->addLayout(layersButtons); @@ -171,9 +171,9 @@ void UtilityPanel::initInternalPanel() layersButtons->addStretch(); connect(m_buttonDelete, - SIGNAL(clicked(bool)), + &QPushButton::clicked, this, - SLOT(slotButtonDelete(bool))); + &UtilityPanel::slotButtonDelete); connect(m_buttonMoveUp, &QPushButton::clicked, diff --git a/src/widgets/trayicon.cpp b/src/widgets/trayicon.cpp index cb4de571..df58271c 100644 --- a/src/widgets/trayicon.cpp +++ b/src/widgets/trayicon.cpp @@ -139,7 +139,7 @@ void TrayIcon::initMenu() connect(FlameshotDaemon::instance(), &FlameshotDaemon::newVersionAvailable, this, - [this](QVersionNumber version) { + [this](const QVersionNumber& version) { QString newVersion = tr("New version %1 is available").arg(version.toString()); m_appUpdates->setText(newVersion);