diff --git a/CMakeLists.txt b/CMakeLists.txt index ff8e9fd9..38c95264 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,15 @@ set(PROJECT_NAME_CAPITALIZED "Flameshot") include(FetchContent) +#Must be set before fetching external content +#QT_DEFAULT_MAJOR_VERSION used by "SingleApplication" +#QT_VERSION_MAJOR used by Flameshot and "QtColorWidgets" +set(QT_DEFAULT_MAJOR_VERSION 6 CACHE STRING "") +set(QT_VERSION_MAJOR 6 CACHE STRING "") + +#Needed due to linker error with QtColorWidget +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + FetchContent_Declare( qtColorWidgets GIT_REPOSITORY https://gitlab.com/mattbas/Qt-Color-Widgets.git @@ -120,7 +129,7 @@ if(USE_EXTERNAL_SINGLEAPPLICATION) # package dev-qt/qtsingleapplication provides no symlink to current version set(qtsingleapplication_libs libQt5Solutions_SingleApplication-2.6 Qt5Solutions_SingleApplication-2.6) find_library(QTSINGLEAPPLICATION_LIBRARY NAMES ${qtsingleapplication_libs}) - message(STATUS "Using external SingleApplication library") + message(STATUS "Using external QtSingleApplication library") else() FetchContent_Declare( singleApplication diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7b3e6358..86d69121 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,14 +1,17 @@ find_package( - Qt5 + Qt${QT_VERSION_MAJOR} CONFIG REQUIRED Core + Core5Compat Gui Widgets Network Svg DBus - LinguistTools) + LinguistTools + Core5Compat #To be removed once QTextCodec has been replaced with the equivalent in Qt 6 +) if (USE_WAYLAND_CLIPBOARD) find_package(KF5GuiAddons) @@ -136,9 +139,9 @@ set(FLAMESHOT_TS_FILES ) if (GENERATE_TS) - qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${FLAMESHOT_TS_FILES}) + qt6_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${FLAMESHOT_TS_FILES}) else () - qt5_add_translation(QM_FILES ${FLAMESHOT_TS_FILES}) + qt6_add_translation(QM_FILES ${FLAMESHOT_TS_FILES}) endif () target_sources( @@ -210,13 +213,13 @@ target_link_libraries( flameshot project_warnings project_options - Qt5::Svg - Qt5::DBus - Qt5::Network - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Svg + Qt${QT_VERSION_MAJOR}::DBus + Qt${QT_VERSION_MAJOR}::Network + Qt${QT_VERSION_MAJOR}::Widgets + Qt${QT_VERSION_MAJOR}::Core5Compat #To be removed once QTextCodec has been replaced with the equivalent in Qt 6 ${QTSINGLEAPPLICATION_LIBRARY} QtColorWidgets - ) if (USE_WAYLAND_CLIPBOARD) diff --git a/src/config/colorpickereditor.cpp b/src/config/colorpickereditor.cpp index 2af6c491..4121d33f 100644 --- a/src/config/colorpickereditor.cpp +++ b/src/config/colorpickereditor.cpp @@ -170,7 +170,11 @@ void ColorPickerEditor::updatePreset() void ColorPickerEditor::onAddPreset() { +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) if (QColor::isValidColor(m_colorInput->text())) { +#else + if (QColor::isValidColorName(m_colorInput->text())) { +#endif m_color = QColor(m_colorInput->text()); m_colorInput->setText(m_color.name(QColor::HexRgb)); } else { @@ -196,7 +200,11 @@ void ColorPickerEditor::onDeletePreset() void ColorPickerEditor::onUpdatePreset() { +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) if (QColor::isValidColor(m_colorEdit->text())) { +#else + if (QColor::isValidColorName(m_colorEdit->text())) { +#endif QColor c = QColor(m_colorEdit->text()); m_colorEdit->setText(c.name(QColor::HexRgb)); } else { @@ -206,4 +214,4 @@ void ColorPickerEditor::onUpdatePreset() updatePreset(); m_colorpicker->updateWidget(); -} \ No newline at end of file +} diff --git a/src/config/generalconf.cpp b/src/config/generalconf.cpp index fe1aad53..07afe049 100644 --- a/src/config/generalconf.cpp +++ b/src/config/generalconf.cpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include // TODO: Qt 6 - Replace QTextCodec with Qt 6 solution; temporary include Core5Compat #include GeneralConf::GeneralConf(QWidget* parent) @@ -188,6 +188,8 @@ void GeneralConf::importConfiguration() return; } QFile file(fileName); + // TODO: Qt 6 - Replace QTextCodec with Qt 6 solution + // Temporary: Include Core5Compat when compiling with Qt 6 QTextCodec* codec = QTextCodec::codecForLocale(); if (!file.open(QFile::ReadOnly)) { QMessageBox::about(this, tr("Error"), tr("Unable to read file.")); @@ -566,7 +568,7 @@ void GeneralConf::initSaveAfterCopy() m_setSaveAsFileExtension = new QComboBox(this); QStringList imageFormatList; - foreach (auto mimeType, QImageWriter::supportedImageFormats()) + for (const auto& mimeType : QImageWriter::supportedImageFormats()) imageFormatList.append(mimeType); m_setSaveAsFileExtension->addItems(imageFormatList); diff --git a/src/config/shortcutswidget.cpp b/src/config/shortcutswidget.cpp index 9dd71a9e..6e79945f 100644 --- a/src/config/shortcutswidget.cpp +++ b/src/config/shortcutswidget.cpp @@ -7,21 +7,18 @@ #include "src/core/qguiappcurrentscreen.h" #include "src/utils/globalvalues.h" #include "toolfactory.h" +#include #include #include #include #include +#include +#include #include #include #include #include -#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) -#include -#include -#include -#endif - ShortcutsWidget::ShortcutsWidget(QWidget* parent) : QWidget(parent) { @@ -29,12 +26,10 @@ ShortcutsWidget::ShortcutsWidget(QWidget* parent) setWindowIcon(QIcon(GlobalValues::iconPath())); setWindowTitle(tr("Hot Keys")); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) QRect position = frameGeometry(); QScreen* screen = QGuiAppCurrentScreen().currentScreen(); position.moveCenter(screen->availableGeometry().center()); move(position.topLeft()); -#endif m_layout = new QVBoxLayout(this); m_layout->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); diff --git a/src/config/uicoloreditor.cpp b/src/config/uicoloreditor.cpp index 28bd871d..7309b2bc 100644 --- a/src/config/uicoloreditor.cpp +++ b/src/config/uicoloreditor.cpp @@ -19,7 +19,7 @@ UIcolorEditor::UIcolorEditor(QWidget* parent) m_hLayout = new QHBoxLayout; m_vLayout = new QVBoxLayout; - const int space = QApplication::fontMetrics().lineSpacing(); + const int space = QFontMetrics(qApp->font()).lineSpacing(); m_hLayout->addItem(new QSpacerItem(space, space, QSizePolicy::Expanding)); m_vLayout->setAlignment(Qt::AlignVCenter); diff --git a/src/core/flameshot.cpp b/src/core/flameshot.cpp index fbadd41b..05827f7f 100644 --- a/src/core/flameshot.cpp +++ b/src/core/flameshot.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -53,6 +52,7 @@ Flameshot::Flameshot() // permissions on the first run. Otherwise it will be hidden under the // CaptureWidget QScreen* currentScreen = QGuiAppCurrentScreen().currentScreen(); + // TODO: Qt 6 - QApplication::desktop() not avialable currentScreen->grabWindow(QApplication::desktop()->winId(), 0, 0, 1, 1); // set global shortcuts for MacOS diff --git a/src/core/qguiappcurrentscreen.cpp b/src/core/qguiappcurrentscreen.cpp index 5d100b08..6bd06335 100644 --- a/src/core/qguiappcurrentscreen.cpp +++ b/src/core/qguiappcurrentscreen.cpp @@ -3,7 +3,6 @@ #include "qguiappcurrentscreen.h" #include -#include #include #include #include @@ -49,15 +48,6 @@ QScreen* QGuiAppCurrentScreen::currentScreen(const QPoint& pos) QScreen* QGuiAppCurrentScreen::screenAt(const QPoint& pos) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) m_currentScreen = qGuiApp->screenAt(pos); -#else - for (QScreen* const screen : QGuiApplication::screens()) { - m_currentScreen = screen; - if (screen->geometry().contains(pos)) { - break; - } - } -#endif return m_currentScreen; } diff --git a/src/main.cpp b/src/main.cpp index 69ca35db..c8fa179a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -153,9 +153,6 @@ int main(int argc, char* argv[]) wayland_hacks(); #endif - // required for the button serialization - // TODO: change to QVector in v1.0 - qRegisterMetaTypeStreamOperators>("QList"); QCoreApplication::setApplicationVersion(APP_VERSION); QCoreApplication::setApplicationName(QStringLiteral("flameshot")); QCoreApplication::setOrganizationName(QStringLiteral("flameshot")); diff --git a/src/tools/launcher/applauncherwidget.cpp b/src/tools/launcher/applauncherwidget.cpp index 630f6fe0..57550dd2 100644 --- a/src/tools/launcher/applauncherwidget.cpp +++ b/src/tools/launcher/applauncherwidget.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -128,11 +129,12 @@ void AppLauncherWidget::launch(const QModelIndex& index) QStringList prog_args = command.split(" "); #endif // no quotes because it is going in an array! + static const QRegularExpression regexp("(\\%.)"); if (command.contains("%")) { // but that means we need to substitute IN the array not the string! for (auto& i : prog_args) { if (i.contains("%")) - i.replace(QRegExp("(\\%.)"), m_tempFile); + i.replace(regexp, m_tempFile); } } else { // we really should append the file name if there @@ -174,7 +176,9 @@ void AppLauncherWidget::searchChanged(const QString& text) m_tabWidget->hide(); m_filterList->show(); m_filterList->clear(); - QRegExp regexp(text, Qt::CaseInsensitive, QRegExp::Wildcard); + const QRegularExpression regexp( + QRegularExpression::wildcardToRegularExpression(text), + QRegularExpression::CaseInsensitiveOption); QVector apps; for (auto const& i : catIconNames.toStdMap()) { diff --git a/src/tools/pin/pinwidget.cpp b/src/tools/pin/pinwidget.cpp index 74f18faa..84357397 100644 --- a/src/tools/pin/pinwidget.cpp +++ b/src/tools/pin/pinwidget.cpp @@ -135,7 +135,7 @@ bool PinWidget::scrollEvent(QWheelEvent* event) return true; } -void PinWidget::enterEvent(QEvent*) +void PinWidget::enterEvent(QEnterEvent*) { m_shadowEffect->setColor(m_hoverColor); } diff --git a/src/tools/pin/pinwidget.h b/src/tools/pin/pinwidget.h index 1e26baff..423028ff 100644 --- a/src/tools/pin/pinwidget.h +++ b/src/tools/pin/pinwidget.h @@ -24,7 +24,7 @@ protected: void mousePressEvent(QMouseEvent*) override; void mouseMoveEvent(QMouseEvent*) override; void keyPressEvent(QKeyEvent*) override; - void enterEvent(QEvent*) override; + void enterEvent(QEnterEvent*) override; void leaveEvent(QEvent*) override; bool event(QEvent* event) override; diff --git a/src/utils/abstractlogger.cpp b/src/utils/abstractlogger.cpp index 986cd602..9bf39aa2 100644 --- a/src/utils/abstractlogger.cpp +++ b/src/utils/abstractlogger.cpp @@ -52,7 +52,7 @@ AbstractLogger& AbstractLogger::sendMessage(const QString& msg, Channel channel) msg, messageHeader(channel, Notification), m_notificationPath); } if (!m_textStreams.isEmpty()) { - foreach (auto* stream, m_textStreams) { + for (auto* stream : m_textStreams) { *stream << messageHeader(channel, String) << msg << "\n"; } } diff --git a/src/utils/abstractlogger.h b/src/utils/abstractlogger.h index 6fc8ff7f..a5a153f9 100644 --- a/src/utils/abstractlogger.h +++ b/src/utils/abstractlogger.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include diff --git a/src/utils/confighandler.cpp b/src/utils/confighandler.cpp index bc43bbab..2f10afe6 100644 --- a/src/utils/confighandler.cpp +++ b/src/utils/confighandler.cpp @@ -359,7 +359,7 @@ QString ConfigHandler::filenamePatternDefault() void ConfigHandler::setDefaultSettings() { - foreach (const QString& key, m_settings.allKeys()) { + for (const auto& key : m_settings.allKeys()) { if (isShortcut(key)) { // Do not reset Shortcuts continue; @@ -486,25 +486,15 @@ void ConfigHandler::resetValue(const QString& key) QSet& ConfigHandler::recognizedGeneralOptions() { -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) auto keys = ::recognizedGeneralOptions.keys(); static QSet options = QSet(keys.begin(), keys.end()); -#else - static QSet options = - QSet::fromList(::recognizedGeneralOptions.keys()); -#endif return options; } QSet& ConfigHandler::recognizedShortcutNames() { -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) auto keys = recognizedShortcuts.keys(); static QSet names = QSet(keys.begin(), keys.end()); -#else - static QSet names = - QSet::fromList(recognizedShortcuts.keys()); -#endif return names; } diff --git a/src/utils/globalvalues.cpp b/src/utils/globalvalues.cpp index fe94354f..7f5d9bb2 100644 --- a/src/utils/globalvalues.cpp +++ b/src/utils/globalvalues.cpp @@ -7,7 +7,7 @@ int GlobalValues::buttonBaseSize() { - return QApplication::fontMetrics().lineSpacing() * 2.2; + return QFontMetrics(qApp->font()).lineSpacing() * 2.2; } QString GlobalValues::versionInfo() @@ -32,4 +32,4 @@ QString GlobalValues::iconPathPNG() #else return { ":img/app/flameshot.png" }; #endif -} \ No newline at end of file +} diff --git a/src/utils/history.cpp b/src/utils/history.cpp index f3ee09d0..877e6195 100644 --- a/src/utils/history.cpp +++ b/src/utils/history.cpp @@ -60,7 +60,7 @@ const QList& History::history() int cnt = 0; int max = ConfigHandler().uploadHistoryMax(); m_thumbs.clear(); - foreach (QString fileName, images) { + for (const auto& fileName : images) { if (++cnt <= max) { m_thumbs.append(fileName); } else { diff --git a/src/utils/screengrabber.cpp b/src/utils/screengrabber.cpp index 722ab665..ba8b86c9 100644 --- a/src/utils/screengrabber.cpp +++ b/src/utils/screengrabber.cpp @@ -8,7 +8,6 @@ #include "src/utils/filenamehandler.h" #include "src/utils/systemnotification.h" #include -#include #include #include #include @@ -141,10 +140,12 @@ void ScreenGrabber::freeDesktopPortal(bool& ok, QPixmap& res) QPixmap ScreenGrabber::grabEntireDesktop(bool& ok) { ok = true; + int wid = 0; + #if defined(Q_OS_MACOS) QScreen* currentScreen = QGuiAppCurrentScreen().currentScreen(); QPixmap screenPixmap( - currentScreen->grabWindow(QApplication::desktop()->winId(), + currentScreen->grabWindow(wid, currentScreen->geometry().x(), currentScreen->geometry().y(), currentScreen->geometry().width(), @@ -205,13 +206,8 @@ QPixmap ScreenGrabber::grabEntireDesktop(bool& ok) #if defined(Q_OS_LINUX) || defined(Q_OS_UNIX) || defined(Q_OS_WIN) QRect geometry = desktopGeometry(); QPixmap p(QApplication::primaryScreen()->grabWindow( - QApplication::desktop()->winId(), - geometry.x(), - geometry.y(), - geometry.width(), - geometry.height())); - auto screenNumber = QApplication::desktop()->screenNumber(); - QScreen* screen = QApplication::screens()[screenNumber]; + wid, geometry.x(), geometry.y(), geometry.width(), geometry.height())); + QScreen* screen = qApp->screenAt(QCursor::pos()); p.setDevicePixelRatio(screen->devicePixelRatio()); return p; #endif @@ -251,11 +247,8 @@ QPixmap ScreenGrabber::grabScreen(QScreen* screen, bool& ok) } } else { ok = true; - return screen->grabWindow(QApplication::desktop()->winId(), - geometry.x(), - geometry.y(), - geometry.width(), - geometry.height()); + return screen->grabWindow( + 0, geometry.x(), geometry.y(), geometry.width(), geometry.height()); } return p; } diff --git a/src/utils/screenshotsaver.cpp b/src/utils/screenshotsaver.cpp index 0fa26caa..6dcbc77e 100644 --- a/src/utils/screenshotsaver.cpp +++ b/src/utils/screenshotsaver.cpp @@ -82,7 +82,7 @@ QString ShowSaveFileDialog(const QString& title, const QString& directory) // Build string list of supported image formats QStringList mimeTypeList; - foreach (auto mimeType, QImageWriter::supportedMimeTypes()) { + for (const auto& mimeType : QImageWriter::supportedMimeTypes()) { // image/heif has several aliases and they cause glitch in save dialog // It is necessary to keep the image/heif (otherwise HEIF plug-in from // kimageformats will not work) but the aliases could be filtered out. diff --git a/src/utils/valuehandler.cpp b/src/utils/valuehandler.cpp index b6c62e68..19c18bb4 100644 --- a/src/utils/valuehandler.cpp +++ b/src/utils/valuehandler.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -96,8 +97,13 @@ Color::Color(QColor def) bool Color::check(const QVariant& val) { QString str = val.toString(); +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) + bool validColor = QColor::isValidColor(str); +#else + bool validColor = QColor::isValidColorName(str); +#endif // Disable #RGB, #RRRGGGBBB and #RRRRGGGGBBBB formats that QColor supports - return QColor::isValidColor(str) && + return validColor && (str[0] != '#' || (str.length() != 4 && str.length() != 10 && str.length() != 13)); } @@ -235,8 +241,7 @@ QVariant KeySequence::process(const QVariant& val) } if (str.length() > 0) { // Make the "main" key in sequence (last one) lower-case. - const QCharRef& lastChar = str[str.length() - 1]; - str.replace(str.length() - 1, 1, lastChar.toLower()); + str[str.length() - 1] = str[str.length() - 1].toLower(); } return str; } @@ -245,7 +250,7 @@ QVariant KeySequence::process(const QVariant& val) bool ExistingDir::check(const QVariant& val) { - if (!val.canConvert(QVariant::String) || val.toString().isEmpty()) { + if (!val.canConvert() || val.toString().isEmpty()) { return false; } QFileInfo info(val.toString()); @@ -396,11 +401,15 @@ bool UserColors::check(const QVariant& val) if (!val.isValid()) { return false; } - if (!val.canConvert(QVariant::StringList)) { + if (!val.canConvert()) { return false; } for (const QString& str : val.toStringList()) { +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) if (!QColor::isValidColor(str) && str != "picker") { +#else + if (!QColor::isValidColorName(str) && str != "picker") { +#endif return false; } } @@ -470,7 +479,7 @@ QVariant UserColors::representation(const QVariant& val) bool SaveFileExtension::check(const QVariant& val) { - if (!val.canConvert(QVariant::String) || val.toString().isEmpty()) { + if (!val.canConvert() || val.toString().isEmpty()) { return false; } @@ -481,7 +490,7 @@ bool SaveFileExtension::check(const QVariant& val) } QStringList imageFormatList; - foreach (auto imageFormat, QImageWriter::supportedImageFormats()) + for (const auto& imageFormat : QImageWriter::supportedImageFormats()) imageFormatList.append(imageFormat); if (!imageFormatList.contains(extension)) { @@ -533,32 +542,33 @@ QVariant Region::process(const QVariant& val) return ScreenGrabber().desktopGeometry(); } else if (str.startsWith("screen")) { bool ok; - int number = str.midRef(6).toInt(&ok); + int number = str.mid(6).toInt(&ok); if (!ok || number < 0) { return {}; } return ScreenGrabber().screenGeometry(qApp->screens()[number]); } - QRegExp regex("(-{,1}\\d+)" // number (any sign) - "[x,\\.\\s]" // separator ('x', ',', '.', or whitespace) - "(-{,1}\\d+)" // number (any sign) - "[\\+,\\.\\s]*" // separator ('+',',', '.', or whitespace) - "(-{,1}\\d+)" // number (non-negative) - "[\\+,\\.\\s]*" // separator ('+', ',', '.', or whitespace) - "(-{,1}\\d+)" // number (non-negative) + static const QRegularExpression regex( + "(-{,1}\\d+)" // number (any sign) + "[x,\\.\\s]" // separator ('x', ',', '.', or whitespace) + "(-{,1}\\d+)" // number (any sign) + "[\\+,\\.\\s]*" // separator ('+',',', '.', or whitespace) + "(-{,1}\\d+)" // number (non-negative) + "[\\+,\\.\\s]*" // separator ('+', ',', '.', or whitespace) + "(-{,1}\\d+)" // number (non-negative) ); - if (!regex.exactMatch(str)) { + if (!regex.match(str).hasMatch()) { return {}; } int w, h, x, y; bool w_ok, h_ok, x_ok, y_ok; - w = regex.cap(1).toInt(&w_ok); - h = regex.cap(2).toInt(&h_ok); - x = regex.cap(3).toInt(&x_ok); - y = regex.cap(4).toInt(&y_ok); + w = regex.match(str).captured(1).toInt(&w_ok); + h = regex.match(str).captured(2).toInt(&h_ok); + x = regex.match(str).captured(3).toInt(&x_ok); + y = regex.match(str).captured(4).toInt(&y_ok); if (!(w_ok && h_ok && x_ok && y_ok)) { return {}; diff --git a/src/widgets/capture/capturewidget.cpp b/src/widgets/capture/capturewidget.cpp index 23d3d1bb..2907ca99 100644 --- a/src/widgets/capture/capturewidget.cpp +++ b/src/widgets/capture/capturewidget.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -1221,10 +1220,6 @@ void CaptureWidget::showAppUpdateNotification(const QString& appLatestVersion, } #if defined(Q_OS_MACOS) int ax = (width() - m_updateNotificationWidget->width()) / 2; -#elif (defined(Q_OS_LINUX) && QT_VERSION < QT_VERSION_CHECK(5, 10, 0)) - QRect helpRect = QGuiApplication::primaryScreen()->geometry(); - int ax = helpRect.left() + - ((helpRect.width() - m_updateNotificationWidget->width()) / 2); #else QRect helpRect; QScreen* currentScreen = QGuiAppCurrentScreen().currentScreen(); @@ -1279,7 +1274,7 @@ void CaptureWidget::initSelection() if (!initialSelection.isNull()) { const qreal scale = m_context.screenshot.devicePixelRatio(); initialSelection.moveTopLeft(initialSelection.topLeft() - - mapToGlobal({})); + mapToGlobal(QPoint(0, 0))); initialSelection.setTop(initialSelection.top() / scale); initialSelection.setBottom(initialSelection.bottom() / scale); initialSelection.setLeft(initialSelection.left() / scale); diff --git a/src/widgets/capture/notifierbox.cpp b/src/widgets/capture/notifierbox.cpp index 9873d572..4c177fba 100644 --- a/src/widgets/capture/notifierbox.cpp +++ b/src/widgets/capture/notifierbox.cpp @@ -26,7 +26,7 @@ NotifierBox::NotifierBox(QWidget* parent) setFixedSize(QSize(size, size)); } -void NotifierBox::enterEvent(QEvent*) +void NotifierBox::enterEvent(QEnterEvent*) { hide(); } diff --git a/src/widgets/capture/notifierbox.h b/src/widgets/capture/notifierbox.h index d9ab367e..df163a9d 100644 --- a/src/widgets/capture/notifierbox.h +++ b/src/widgets/capture/notifierbox.h @@ -14,7 +14,7 @@ public: explicit NotifierBox(QWidget* parent = nullptr); protected: - virtual void enterEvent(QEvent*) override; + void enterEvent(QEnterEvent*) override; virtual void paintEvent(QPaintEvent*) override; signals: diff --git a/src/widgets/capture/overlaymessage.cpp b/src/widgets/capture/overlaymessage.cpp index 3cfa2957..48d8ca7d 100644 --- a/src/widgets/capture/overlaymessage.cpp +++ b/src/widgets/capture/overlaymessage.cpp @@ -31,7 +31,7 @@ OverlayMessage::OverlayMessage(QWidget* parent, const QRect& targetArea) setStyleSheet( QStringLiteral("QLabel { color: %1; }").arg(m_textColor.name())); - setMargin(QApplication::fontMetrics().height() / 2); + setMargin(QFontMetrics(qApp->font()).height() / 2); QWidget::hide(); } diff --git a/src/widgets/infowindow.cpp b/src/widgets/infowindow.cpp index f295f191..02630608 100644 --- a/src/widgets/infowindow.cpp +++ b/src/widgets/infowindow.cpp @@ -23,12 +23,10 @@ InfoWindow::InfoWindow(QWidget* parent) connect( ui->CopyInfoButton, &QPushButton::clicked, this, &InfoWindow::copyInfo); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) QRect position = frameGeometry(); QScreen* screen = QGuiAppCurrentScreen().currentScreen(); position.moveCenter(screen->availableGeometry().center()); move(position.topLeft()); -#endif show(); } diff --git a/src/widgets/loadspinner.cpp b/src/widgets/loadspinner.cpp index 59f82acb..b48f4110 100644 --- a/src/widgets/loadspinner.cpp +++ b/src/widgets/loadspinner.cpp @@ -15,7 +15,7 @@ LoadSpinner::LoadSpinner(QWidget* parent) , m_growing(true) { setAttribute(Qt::WA_TranslucentBackground); - const int size = QApplication::fontMetrics().height() * 8; + const int size = QFontMetrics(qApp->font()).height() * 8; setFixedSize(size, size); updateFrame(); // init timer diff --git a/src/widgets/panel/sidepanelwidget.cpp b/src/widgets/panel/sidepanelwidget.cpp index 2d156a48..240aa051 100644 --- a/src/widgets/panel/sidepanelwidget.cpp +++ b/src/widgets/panel/sidepanelwidget.cpp @@ -108,7 +108,11 @@ SidePanelWidget::SidePanelWidget(QPixmap* p, QWidget* parent) &SidePanelWidget::onToolSizeChanged); // color hex editor sigslots connect(m_colorHex, &QLineEdit::editingFinished, this, [=]() { +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) if (!QColor::isValidColor(m_colorHex->text())) { +#else + if (!QColor::isValidColorName(m_colorHex->text())) { +#endif m_colorHex->setText(m_color.name(QColor::HexRgb)); } else { emit colorChanged(m_colorHex->text()); diff --git a/src/widgets/uploadhistory.cpp b/src/widgets/uploadhistory.cpp index 76bdc375..b5fb29d8 100644 --- a/src/widgets/uploadhistory.cpp +++ b/src/widgets/uploadhistory.cpp @@ -6,7 +6,6 @@ #include "uploadlineitem.h" #include -#include #include #include @@ -37,7 +36,6 @@ UploadHistory::UploadHistory(QWidget* parent) setAttribute(Qt::WA_DeleteOnClose); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); - resize(QDesktopWidget().availableGeometry(this).size() * 0.5); } void UploadHistory::loadHistory() @@ -50,7 +48,7 @@ void UploadHistory::loadHistory() if (historyFiles.isEmpty()) { setEmptyMessage(); } else { - foreach (QString fileName, historyFiles) { + for (const auto& fileName : historyFiles) { addLine(history.path(), fileName); } }