From a57f6413f6b9343f18855fb382705f4841a537d7 Mon Sep 17 00:00:00 2001 From: El Thoro Date: Mon, 23 Jun 2025 01:49:16 +0200 Subject: [PATCH] Fix compiler warnings (#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. --- src/config/shortcutswidget.cpp | 2 +- src/main.cpp | 31 ++++++++++++++++++++++--------- src/utils/confighandler.cpp | 2 +- src/utils/filenamehandler.cpp | 2 +- src/widgets/colorpickerwidget.cpp | 4 ++-- 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/config/shortcutswidget.cpp b/src/config/shortcutswidget.cpp index 6e79945f..9f59d85c 100644 --- a/src/config/shortcutswidget.cpp +++ b/src/config/shortcutswidget.cpp @@ -130,7 +130,7 @@ void ShortcutsWidget::onShortcutCellClicked(int row, int col) // set no shortcut is Backspace #if defined(Q_OS_MACOS) - if (shortcutValue == QKeySequence(Qt::CTRL + Qt::Key_Backspace)) { + if (shortcutValue == QKeySequence(Qt::CTRL | Qt::Key_Backspace)) { shortcutValue = QKeySequence(""); } #else diff --git a/src/main.cpp b/src/main.cpp index 060eb0bf..0891807a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -88,21 +88,34 @@ void configureApp(bool gui) #endif } + bool foundTranslation; // Configure translations for (const QString& path : PathInfo::translationsPaths()) { - bool match = translator.load(QLocale(), - QStringLiteral("Internationalization"), - QStringLiteral("_"), - path); - if (match) { + foundTranslation = + translator.load(QLocale(), + QStringLiteral("Internationalization"), + QStringLiteral("_"), + path); + if (foundTranslation) { break; } } + if (!foundTranslation) { + QLocale l; + qWarning() << QStringLiteral("No Flameshot translation found for %1") + .arg(l.uiLanguages().join(", ")); + } - qtTranslator.load(QLocale::system(), - "qt", - "_", - QLibraryInfo::path(QLibraryInfo::TranslationsPath)); + foundTranslation = + qtTranslator.load(QLocale::system(), + "qt", + "_", + QLibraryInfo::path(QLibraryInfo::TranslationsPath)); + if (!foundTranslation) { + qWarning() << QStringLiteral("No Qt translation found for %1") + .arg(QLocale::languageToString( + QLocale::system().language())); + } auto app = QCoreApplication::instance(); app->installTranslator(&translator); diff --git a/src/utils/confighandler.cpp b/src/utils/confighandler.cpp index 6d3a12d2..d763c94a 100644 --- a/src/utils/confighandler.cpp +++ b/src/utils/confighandler.cpp @@ -405,7 +405,7 @@ bool ConfigHandler::setShortcut(const QString& actionName, qDebug() << actionName; static QVector reservedShortcuts = { #if defined(Q_OS_MACOS) - Qt::CTRL + Qt::Key_Backspace, + Qt::CTRL | Qt::Key_Backspace, Qt::Key_Escape, #else Qt::Key_Backspace, diff --git a/src/utils/filenamehandler.cpp b/src/utils/filenamehandler.cpp index 4e3aa392..dd68a559 100644 --- a/src/utils/filenamehandler.cpp +++ b/src/utils/filenamehandler.cpp @@ -16,7 +16,7 @@ FileNameHandler::FileNameHandler(QObject* parent) auto err = AbstractLogger::error(AbstractLogger::Stderr); try { std::locale::global(std::locale()); - } catch (std::exception& e) { + } catch (std::exception&) { err << "Locales on your system are not properly configured. Falling " "back to defaults"; diff --git a/src/widgets/colorpickerwidget.cpp b/src/widgets/colorpickerwidget.cpp index c8db7220..866a9757 100644 --- a/src/widgets/colorpickerwidget.cpp +++ b/src/widgets/colorpickerwidget.cpp @@ -73,11 +73,11 @@ void ColorPickerWidget::repaint(int i, QPainter& painter) int nSteps = lastRect.height() / nStep; // 0.02 - start rainbow color, 0.33 - end rainbow color from range: // 0.0 - 1.0 - float h = 0.02; + float h = 0.02f; for (int radius = nSteps; radius > 0; radius -= nStep * 2) { // calculate color float fHStep = (0.33 - h) / (nSteps / nStep / 2); - QColor color = QColor::fromHslF(h, 0.95, 0.5); + QColor color = QColor::fromHslF(h, 0.95f, 0.5f); // set color and draw circle painter.setPen(color);