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.
This commit is contained in:
El Thoro
2025-06-23 01:49:16 +02:00
committed by GitHub
parent 0d5b318e12
commit a57f6413f6
5 changed files with 27 additions and 14 deletions

View File

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

View File

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

View File

@@ -405,7 +405,7 @@ bool ConfigHandler::setShortcut(const QString& actionName,
qDebug() << actionName;
static QVector<QKeySequence> reservedShortcuts = {
#if defined(Q_OS_MACOS)
Qt::CTRL + Qt::Key_Backspace,
Qt::CTRL | Qt::Key_Backspace,
Qt::Key_Escape,
#else
Qt::Key_Backspace,

View File

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

View File

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