Skip to content

Commit a57f641

Browse files
authored
Fix compiler warnings (flameshot-org#4023)
* Fix unused return value * Fix deprecated operator+ * Fix truncation from double to float * Fix unreferenced local variable * Use qWarning instead of AbstractLogger, because AbstractLogger creates a popup which could be annoying for missing translation messages.
1 parent 0d5b318 commit a57f641

File tree

5 files changed

+27
-14
lines changed

5 files changed

+27
-14
lines changed

src/config/shortcutswidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ void ShortcutsWidget::onShortcutCellClicked(int row, int col)
130130

131131
// set no shortcut is Backspace
132132
#if defined(Q_OS_MACOS)
133-
if (shortcutValue == QKeySequence(Qt::CTRL + Qt::Key_Backspace)) {
133+
if (shortcutValue == QKeySequence(Qt::CTRL | Qt::Key_Backspace)) {
134134
shortcutValue = QKeySequence("");
135135
}
136136
#else

src/main.cpp

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,34 @@ void configureApp(bool gui)
8888
#endif
8989
}
9090

91+
bool foundTranslation;
9192
// Configure translations
9293
for (const QString& path : PathInfo::translationsPaths()) {
93-
bool match = translator.load(QLocale(),
94-
QStringLiteral("Internationalization"),
95-
QStringLiteral("_"),
96-
path);
97-
if (match) {
94+
foundTranslation =
95+
translator.load(QLocale(),
96+
QStringLiteral("Internationalization"),
97+
QStringLiteral("_"),
98+
path);
99+
if (foundTranslation) {
98100
break;
99101
}
100102
}
103+
if (!foundTranslation) {
104+
QLocale l;
105+
qWarning() << QStringLiteral("No Flameshot translation found for %1")
106+
.arg(l.uiLanguages().join(", "));
107+
}
101108

102-
qtTranslator.load(QLocale::system(),
103-
"qt",
104-
"_",
105-
QLibraryInfo::path(QLibraryInfo::TranslationsPath));
109+
foundTranslation =
110+
qtTranslator.load(QLocale::system(),
111+
"qt",
112+
"_",
113+
QLibraryInfo::path(QLibraryInfo::TranslationsPath));
114+
if (!foundTranslation) {
115+
qWarning() << QStringLiteral("No Qt translation found for %1")
116+
.arg(QLocale::languageToString(
117+
QLocale::system().language()));
118+
}
106119

107120
auto app = QCoreApplication::instance();
108121
app->installTranslator(&translator);

src/utils/confighandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ bool ConfigHandler::setShortcut(const QString& actionName,
405405
qDebug() << actionName;
406406
static QVector<QKeySequence> reservedShortcuts = {
407407
#if defined(Q_OS_MACOS)
408-
Qt::CTRL + Qt::Key_Backspace,
408+
Qt::CTRL | Qt::Key_Backspace,
409409
Qt::Key_Escape,
410410
#else
411411
Qt::Key_Backspace,

src/utils/filenamehandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ FileNameHandler::FileNameHandler(QObject* parent)
1616
auto err = AbstractLogger::error(AbstractLogger::Stderr);
1717
try {
1818
std::locale::global(std::locale());
19-
} catch (std::exception& e) {
19+
} catch (std::exception&) {
2020
err << "Locales on your system are not properly configured. Falling "
2121
"back to defaults";
2222

src/widgets/colorpickerwidget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ void ColorPickerWidget::repaint(int i, QPainter& painter)
7373
int nSteps = lastRect.height() / nStep;
7474
// 0.02 - start rainbow color, 0.33 - end rainbow color from range:
7575
// 0.0 - 1.0
76-
float h = 0.02;
76+
float h = 0.02f;
7777
for (int radius = nSteps; radius > 0; radius -= nStep * 2) {
7878
// calculate color
7979
float fHStep = (0.33 - h) / (nSteps / nStep / 2);
80-
QColor color = QColor::fromHslF(h, 0.95, 0.5);
80+
QColor color = QColor::fromHslF(h, 0.95f, 0.5f);
8181

8282
// set color and draw circle
8383
painter.setPen(color);

0 commit comments

Comments
 (0)