Cppcheck and clazy warning fixes (#2821)

* Cppcheck and clazy warning fixes

* Clang-format

* Revert QRect call by value

* Revert QPoint call by value

* Revert complained renamings

---------

Co-authored-by: Haris Gušić <harisgusic.dev@gmail.com>
This commit is contained in:
El Thoro
2023-01-29 16:01:02 +01:00
committed by GitHub
parent 05c3b8746a
commit f7e41f4d70
39 changed files with 150 additions and 142 deletions

View File

@@ -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 {

View File

@@ -46,4 +46,4 @@ QRect getLastRegion()
}
return lastRegion;
}
}

View File

@@ -11,4 +11,4 @@ QString getCachePath();
QRect getLastRegion();
void setLastRegion(QRect const& newRegion);
#endif // FLAMESHOT_CACHEUTILS_H
#endif // FLAMESHOT_CACHEUTILS_H

View File

@@ -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);

View File

@@ -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();

View File

@@ -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();

View File

@@ -32,7 +32,7 @@ private:
void initWidgets();
public slots:
void addToNameEditor(QString s);
void addToNameEditor(const QString& s);
void updateComponents();
private slots:

View File

@@ -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<void (QSpinBox::*)(int)>(&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<void (QSpinBox::*)(int)>(&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<void (QSpinBox::*)(int)>(&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<void (QComboBox::*)(int)>(&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);
}

View File

@@ -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();

View File

@@ -9,7 +9,8 @@
#include <QLayout>
#include <QPixmap>
SetShortcutDialog::SetShortcutDialog(QDialog* parent, QString shortcutName)
SetShortcutDialog::SetShortcutDialog(QDialog* parent,
const QString& shortcutName)
: QDialog(parent)
{
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);

View File

@@ -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:

View File

@@ -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)
{

View File

@@ -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();

View File

@@ -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"),

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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);
};

View File

@@ -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;

View File

@@ -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 });
}

View File

@@ -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);

View File

@@ -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;

View File

@@ -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:

View File

@@ -321,9 +321,9 @@ void ConfigHandler::setStartupLaunch(const bool start)
void ConfigHandler::setAllTheButtons()
{
QList<CaptureTool::Type> buttons =
QList<CaptureTool::Type> 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();
}

View File

@@ -178,6 +178,6 @@ private:
QSharedPointer<ValueHandler> 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<QString>& keys) const;
};

View File

@@ -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

View File

@@ -20,5 +20,5 @@ public:
static const int MAX_CHARACTERS = 70;
private:
QString autoNumerateDuplicate(QString path);
QString autoNumerateDuplicate(const QString& path);
};

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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 <QApplication> // TODO remove after FIXME (see below)

View File

@@ -353,7 +353,7 @@ void ButtonHandler::adjustHorizontalCenter(QPoint& center)
}
// setButtons redefines the buttons of the button handler
void ButtonHandler::setButtons(const QVector<CaptureToolButton*> v)
void ButtonHandler::setButtons(const QVector<CaptureToolButton*>& v)
{
if (v.isEmpty()) {
return;

View File

@@ -26,7 +26,7 @@ public:
bool buttonsAreInside() const;
size_t size() const;
void setButtons(const QVector<CaptureToolButton*>);
void setButtons(const QVector<CaptureToolButton*>&);
bool contains(const QPoint& p) const;
void updateScreenRegions(const QVector<QRect>& rects);
void updateScreenRegions(const QRect& rect);

View File

@@ -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;

View File

@@ -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<CaptureTool> at(int index);
CaptureToolObjects& operator=(const CaptureToolObjects& other);

View File

@@ -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<QPair<QString, QString>> 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++) {

View File

@@ -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,

View File

@@ -62,7 +62,7 @@ OrientablePushButton::Orientation OrientablePushButton::orientation() const
}
void OrientablePushButton::setOrientation(
const OrientablePushButton::Orientation& orientation)
OrientablePushButton::Orientation orientation)
{
m_orientation = orientation;
}

View File

@@ -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);

View File

@@ -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,

View File

@@ -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);