From a5cd4cd1bc41cbec260c84e84809b93635f7599a Mon Sep 17 00:00:00 2001 From: Yuriy Puchkov Date: Wed, 17 Feb 2021 14:50:34 +0200 Subject: [PATCH] Code refactoring - remove Q_OS_MACX (is not required, is covered by Q_OS_DARWIN) (cherry picked from commit 00b9aae5266aaffb9a01a6f689e1829ae8218bdc) --- src/core/controller.cpp | 24 ++++++++++++------------ src/utils/confighandler.cpp | 6 +++--- src/utils/screenshotsaver.cpp | 4 ++-- src/widgets/capture/capturewidget.cpp | 12 ++++++------ 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/core/controller.cpp b/src/core/controller.cpp index d4ad1976..8943260b 100644 --- a/src/core/controller.cpp +++ b/src/core/controller.cpp @@ -49,7 +49,7 @@ #include "src/core/globalshortcutfilter.h" #endif -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) #include #include #endif @@ -64,7 +64,7 @@ Controller::Controller() , m_trayIconMenu(nullptr) , m_networkCheckUpdates(nullptr) , m_showCheckAppUpdateStatus(false) -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) , m_HotkeyScreenshotCapture(nullptr) , m_HotkeyScreenshotHistory(nullptr) #endif @@ -93,7 +93,7 @@ Controller::Controller() QString StyleSheet = CaptureButton::globalStyleSheet(); qApp->setStyleSheet(StyleSheet); -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) // Try to take a test screenshot, MacOS will request a "Screen Recording" // permissions on the first run. Otherwise it will be hidden under the // CaptureWidget @@ -270,7 +270,7 @@ void Controller::requestCapture(const CaptureRequest& request) void Controller::startVisualCapture(const uint id, const QString& forcedSavePath) { -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) // This is required on MacOS because of Mission Control. If you'll switch to // another Desktop you cannot take a new screenshot from the tray, you have // to switch back to the Flameshot Desktop manually. It is not obvious and a @@ -315,7 +315,7 @@ void Controller::startVisualCapture(const uint id, #ifdef Q_OS_WIN m_captureWindow->show(); -#elif (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#elif (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) // In "Emulate fullscreen mode" m_captureWindow->showFullScreen(); m_captureWindow->activateWindow(); @@ -359,7 +359,7 @@ void Controller::openConfigWindow() if (!m_configWindow) { m_configWindow = new ConfigWindow(); m_configWindow->show(); -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) m_configWindow->activateWindow(); m_configWindow->raise(); #endif @@ -371,7 +371,7 @@ void Controller::openInfoWindow() { if (!m_infoWindow) { m_infoWindow = new InfoWindow(); -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) m_infoWindow->activateWindow(); m_infoWindow->raise(); #endif @@ -384,7 +384,7 @@ void Controller::openLauncherWindow() m_launcherWindow = new CaptureLauncher(); } m_launcherWindow->show(); -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) m_launcherWindow->activateWindow(); m_launcherWindow->raise(); #endif @@ -403,7 +403,7 @@ void Controller::enableTrayIcon() ConfigHandler().setDisabledTrayIcon(false); QAction* captureAction = new QAction(tr("&Take Screenshot"), this); connect(captureAction, &QAction::triggered, this, [this]() { -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) auto currentMacOsVersion = QOperatingSystemVersion::current(); if (currentMacOsVersion >= currentMacOsVersion.MacOSBigSur) { startVisualCapture(); @@ -458,7 +458,7 @@ void Controller::enableTrayIcon() Q_ASSERT(m_trayIcon); } m_trayIcon->setToolTip(QStringLiteral("Flameshot")); -#if defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX) +#if defined(Q_OS_MAC64) || defined(Q_OS_MACOS) // Because of the following issues on MacOS "Catalina": // https://bugreports.qt.io/browse/QTBUG-86393 // https://developer.apple.com/forums/thread/126072 @@ -473,7 +473,7 @@ void Controller::enableTrayIcon() QIcon::fromTheme("flameshot-tray", QIcon(":img/app/flameshot.png")); m_trayIcon->setIcon(trayIcon); -#if defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX) +#if defined(Q_OS_MAC64) || defined(Q_OS_MACOS) if (currentMacOsVersion < currentMacOsVersion.MacOSBigSur) { // Because of the following issues on MacOS "Catalina": // https://bugreports.qt.io/browse/QTBUG-86393 @@ -558,7 +558,7 @@ void Controller::showRecentScreenshots() } m_history->loadHistory(); m_history->show(); -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) m_history->activateWindow(); m_history->raise(); #endif diff --git a/src/utils/confighandler.cpp b/src/utils/confighandler.cpp index 1fc68f4b..2a3a93fa 100644 --- a/src/utils/confighandler.cpp +++ b/src/utils/confighandler.cpp @@ -62,7 +62,7 @@ QVector ConfigHandler::getButtons() << CaptureToolButton::TYPE_COPY << CaptureToolButton::TYPE_SAVE << CaptureToolButton::TYPE_EXIT << CaptureToolButton::TYPE_IMAGEUPLOADER -#if not(defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if not(defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) << CaptureToolButton::TYPE_OPEN_APP #endif << CaptureToolButton::TYPE_PIN << CaptureToolButton::TYPE_TEXT @@ -324,7 +324,7 @@ void ConfigHandler::setCheckForUpdates(const bool checkForUpdates) bool ConfigHandler::startupLaunchValue() { -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) bool res = false; #else bool res = true; @@ -363,7 +363,7 @@ void ConfigHandler::setStartupLaunch(const bool start) if (start == m_settings.value(QStringLiteral("startupLaunch")).toBool()) { return; } -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) /* TODO - there should be more correct way via API, but didn't find it without extra dependencies, there should be something like that: https://stackoverflow.com/questions/3358410/programmatically-run-at-startup-on-mac-os-x diff --git a/src/utils/screenshotsaver.cpp b/src/utils/screenshotsaver.cpp index c568f68a..c3750d17 100644 --- a/src/utils/screenshotsaver.cpp +++ b/src/utils/screenshotsaver.cpp @@ -27,7 +27,7 @@ #include #include #include -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) #include "src/widgets/capture/capturewidget.h" #endif @@ -120,7 +120,7 @@ bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap& capture) while (!ok) { ConfigHandler config; QString savePath = FileNameHandler().absoluteSavePath(); -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) for (QWidget* widget : qApp->topLevelWidgets()) { QString className(widget->metaObject()->className()); if (0 == className.compare( diff --git a/src/widgets/capture/capturewidget.cpp b/src/widgets/capture/capturewidget.cpp index 98d0be33..19f387a5 100644 --- a/src/widgets/capture/capturewidget.cpp +++ b/src/widgets/capture/capturewidget.cpp @@ -120,7 +120,7 @@ CaptureWidget::CaptureWidget(const uint id, } move(topLeft); resize(pixmap().size()); -#elif (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#elif (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) // Emulate fullscreen mode // setWindowFlags(Qt::WindowStaysOnTopHint | // Qt::BypassWindowManagerHint | @@ -147,7 +147,7 @@ CaptureWidget::CaptureWidget(const uint id, topLeftOffset - topLeft; #endif -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) // MacOS works just with one active display, so we need to append // just one current display and keep multiple displays logic for // other OS @@ -334,7 +334,7 @@ void CaptureWidget::paintEvent(QPaintEvent*) painter.setClipRect(rect()); if (m_showInitialMsg) { -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) QRect helpRect; QScreen* currentScreen = QGuiAppCurrentScreen().currentScreen(); if (currentScreen) { @@ -763,7 +763,7 @@ void CaptureWidget::initPanel() m_panel = new UtilityPanel(this); m_panel->hide(); makeChild(m_panel); -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) QScreen* currentScreen = QGuiAppCurrentScreen().currentScreen(); panelRect.moveTo(mapFromGlobal(panelRect.topLeft())); m_panel->setFixedWidth(m_colorPicker->width() * 1.5); @@ -810,7 +810,7 @@ void CaptureWidget::showAppUpdateNotification(const QString& appLatestVersion, m_updateNotificationWidget = new UpdateNotificationWidget(this, appLatestVersion, appLatestUrl); } -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || 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(); @@ -1233,7 +1233,7 @@ void CaptureWidget::copyScreenshot() void CaptureWidget::saveScreenshot() { -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) showNormal(); #endif m_captureDone = true;