Skip to content

Commit 134238b

Browse files
authored
Fixing several Clazy warnings (flameshot-org#3960)
* Use multi-arg * Unused vaiables * Missing emit * Range loop reference * Don't use connect by name
1 parent 0b0172e commit 134238b

17 files changed

+39
-52
lines changed

src/cli/commandlineparser.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ QString optionsToString(const QList<CommandOption>& options,
5656
QStringLiteral(" ").repeated(size + 4).prepend("\n");
5757
for (int i = 0; i < options.length(); ++i) {
5858
result += QStringLiteral(" %1 %2\n")
59-
.arg(dashedOptionList.at(i).leftJustified(size, ' '))
60-
.arg(options.at(i).description().replace(
61-
QLatin1String("\n"), linePadding));
59+
.arg(dashedOptionList.at(i).leftJustified(size, ' '),
60+
options.at(i).description().replace(
61+
QLatin1String("\n"), linePadding));
6262
}
6363
if (!subcommands.isEmpty()) {
6464
result += QLatin1String("\n");
@@ -69,8 +69,8 @@ QString optionsToString(const QList<CommandOption>& options,
6969
}
7070
for (const auto& subcommand : subcommands) {
7171
result += QStringLiteral(" %1 %2\n")
72-
.arg(subcommand.name().leftJustified(size, ' '))
73-
.arg(subcommand.description());
72+
.arg(subcommand.name().leftJustified(size, ' '),
73+
subcommand.description());
7474
}
7575
return result;
7676
}
@@ -142,8 +142,7 @@ bool CommandLineParser::processOptions(const QStringList& args,
142142
}
143143
err << QStringLiteral("the option '%1' is not a valid option "
144144
"for the argument '%2'.")
145-
.arg(arg)
146-
.arg(argName);
145+
.arg(arg, argName);
147146
ok = false;
148147
return ok;
149148
}
@@ -329,9 +328,7 @@ void CommandLineParser::printHelp(QStringList args, const Node* node)
329328
node->subNodes.isEmpty() ? "" : "[" + QObject::tr("subcommands") + "]";
330329
helpText += (QObject::tr("Usage") + ": %1 [%2-" + QObject::tr("options") +
331330
QStringLiteral("] %3\n\n"))
332-
.arg(args.join(QStringLiteral(" ")))
333-
.arg(argName)
334-
.arg(argText);
331+
.arg(args.join(QStringLiteral(" ")), argName, argText);
335332

336333
// short section about default behavior
337334
helpText += QObject::tr("Per default runs Flameshot in the background and "

src/core/flameshot.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,6 @@ void Flameshot::exportCapture(const QPixmap& capture,
353353
QString path = req.path();
354354

355355
if (tasks & CR::PRINT_GEOMETRY) {
356-
QByteArray byteArray;
357-
QBuffer buffer(&byteArray);
358356
QTextStream(stdout)
359357
<< selection.width() << "x" << selection.height() << "+"
360358
<< selection.x() << "+" << selection.y() << "\n";

src/main.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,8 +589,7 @@ int main(int argc, char* argv[])
589589
QTextStream(stdout)
590590
<< QStringLiteral("The new pattern is '%1'\n"
591591
"Parsed pattern example: %2\n")
592-
.arg(newFilename)
593-
.arg(fh.parsedPattern());
592+
.arg(newFilename, fh.parsedPattern());
594593
}
595594
if (tray) {
596595
config.setDisabledTrayIcon(parser.value(trayOption) == "false");

src/tools/circlecount/circlecounttool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ QIcon CircleCountTool::icon(const QColor& background, bool inEditor) const
2424

2525
QString CircleCountTool::info()
2626
{
27-
m_tempString = QString("%1 - %2").arg(name()).arg(count());
27+
m_tempString = QString("%1 - %2").arg(name(), count());
2828
return m_tempString;
2929
}
3030

src/tools/launcher/applauncherwidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ AppLauncherWidget::AppLauncherWidget(const QPixmap& p, QWidget* parent)
6565
QStringList appsLocations =
6666
QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation);
6767

68-
for (auto appsLocation : appsLocations) {
68+
for (const auto& appsLocation : appsLocations) {
6969
QDir appsDir(appsLocation);
7070
m_parser.processDirectory(QDir(appsDir));
7171
}

src/tools/text/textconfig.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ TextConfig::TextConfig(QWidget* parent)
7878
m_leftAlignButton->setCheckable(true);
7979
m_leftAlignButton->setAutoExclusive(true);
8080
connect(m_leftAlignButton, &QPushButton::clicked, this, [this] {
81-
alignmentChanged(Qt::AlignLeft);
81+
emit alignmentChanged(Qt::AlignLeft);
8282
});
8383
m_leftAlignButton->setToolTip(tr("Left Align"));
8484

@@ -87,7 +87,7 @@ TextConfig::TextConfig(QWidget* parent)
8787
m_centerAlignButton->setCheckable(true);
8888
m_centerAlignButton->setAutoExclusive(true);
8989
connect(m_centerAlignButton, &QPushButton::clicked, this, [this] {
90-
alignmentChanged(Qt::AlignCenter);
90+
emit alignmentChanged(Qt::AlignCenter);
9191
});
9292
m_centerAlignButton->setToolTip(tr("Center Align"));
9393

@@ -96,7 +96,7 @@ TextConfig::TextConfig(QWidget* parent)
9696
m_rightAlignButton->setCheckable(true);
9797
m_rightAlignButton->setAutoExclusive(true);
9898
connect(m_rightAlignButton, &QPushButton::clicked, this, [this] {
99-
alignmentChanged(Qt::AlignRight);
99+
emit alignmentChanged(Qt::AlignRight);
100100
});
101101
m_rightAlignButton->setToolTip(tr("Right Align"));
102102

src/tools/text/texttool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ QString TextTool::name() const
7676
QString TextTool::info()
7777
{
7878
if (m_text.length() > 0) {
79-
m_tempString = QString("%1 - %2").arg(name()).arg(m_text.trimmed());
79+
m_tempString = QString("%1 - %2").arg(name(), m_text.trimmed());
8080
m_tempString = m_tempString.split("\n").at(0);
8181
if (m_tempString.length() > MAX_INFO_LENGTH) {
8282
m_tempString.truncate(MAX_INFO_LENGTH);

src/utils/confighandler.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -612,9 +612,7 @@ bool ConfigHandler::checkShortcutConflicts(AbstractLogger* log) const
612612
reportedInLog.append(*key2);
613613
*log << tr("Shortcut conflict: '%1' and '%2' "
614614
"have the same shortcut: %3\n")
615-
.arg(*key1)
616-
.arg(*key2)
617-
.arg(value1);
615+
.arg(*key1, *key2, value1);
618616
}
619617
}
620618
}
@@ -651,8 +649,7 @@ bool ConfigHandler::checkSemantics(AbstractLogger* log,
651649
}
652650
if (log != nullptr) {
653651
*log << tr("Bad value in '%1'. Expected: %2\n")
654-
.arg(key)
655-
.arg(valueHandler->expected());
652+
.arg(key, valueHandler->expected());
656653
}
657654
if (offenders != nullptr) {
658655
offenders->append(key);

src/utils/screengrabber.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ QPixmap ScreenGrabber::grabEntireDesktop(bool& ok)
219219

220220
QRect ScreenGrabber::screenGeometry(QScreen* screen)
221221
{
222-
QPixmap p;
223222
QRect geometry;
224223
if (m_info.waylandDetected()) {
225224
QPoint topLeft(0, 0);

src/utils/valuehandler.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ QVariant BoundedInt::fallback()
165165

166166
QString BoundedInt::expected()
167167
{
168-
return QStringLiteral("number between %1 and %2").arg(m_min).arg(m_max);
168+
return QStringLiteral("number between %1 and %2").arg(m_min, m_max);
169169
}
170170

171171
// LOWER BOUNDED INT
@@ -446,8 +446,7 @@ QString UserColors::expected()
446446
{
447447
return QStringLiteral(
448448
"list of colors(min %1 and max %2) separated by comma")
449-
.arg(m_min - 1)
450-
.arg(m_max - 1);
449+
.arg(m_min - 1, m_max - 1);
451450
}
452451

453452
QVariant UserColors::representation(const QVariant& val)

0 commit comments

Comments
 (0)