From dd54d028a1dd5016bbc73a2891ebcfbbb5f54195 Mon Sep 17 00:00:00 2001 From: Yuriy Puchkov Date: Wed, 10 Feb 2021 20:01:12 +0200 Subject: [PATCH] Code refactoring - remove Q_OS_MACX (is not required, is covered by Q_OS_DARWIN) (cherry picked from commit 00b9aae5266aaffb9a01a6f689e1829ae8218bdc) --- src/config/shortcutswidget.cpp | 6 +++--- src/core/qguiappcurrentscreen.cpp | 2 +- src/main.cpp | 6 ++---- src/tools/abstractpathtool.cpp | 4 ++-- src/tools/abstracttwopointtool.cpp | 4 ++-- src/tools/pin/pintool.cpp | 4 ++-- src/tools/save/savetool.cpp | 4 ++-- src/tools/text/texttool.cpp | 4 ++-- src/tools/toolfactory.cpp | 2 +- src/utils/configshortcuts.cpp | 4 ++-- src/utils/screengrabber.cpp | 2 +- src/utils/systemnotification.cpp | 9 +++------ src/widgets/capture/capturetoolbutton.cpp | 4 ++-- src/widgets/capturelauncher.cpp | 2 +- src/widgets/panel/sidepanelwidget.cpp | 4 ++-- 15 files changed, 28 insertions(+), 33 deletions(-) diff --git a/src/config/shortcutswidget.cpp b/src/config/shortcutswidget.cpp index bc6b6057..21d5fa3b 100644 --- a/src/config/shortcutswidget.cpp +++ b/src/config/shortcutswidget.cpp @@ -90,7 +90,7 @@ void ShortcutsWidget::initInfoTable() const auto default_key_sequence = current_shortcut.at(2); m_table->setItem(i, 0, new QTableWidgetItem(description)); -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) QTableWidgetItem* item = new QTableWidgetItem(nativeOSHotKeyText(m_shortcuts.at(i).at(2))); #else @@ -145,7 +145,7 @@ void ShortcutsWidget::slotShortcutCellClicked(int row, int col) } if (m_config.setShortcut(shortcutName, shortcutValue.toString())) { -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) QTableWidgetItem* item = new QTableWidgetItem( nativeOSHotKeyText(shortcutValue.toString())); #else @@ -161,7 +161,7 @@ void ShortcutsWidget::slotShortcutCellClicked(int row, int col) } } -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) const QString& ShortcutsWidget::nativeOSHotKeyText(const QString& text) { m_res = text; diff --git a/src/core/qguiappcurrentscreen.cpp b/src/core/qguiappcurrentscreen.cpp index 1cb592f9..fface54b 100644 --- a/src/core/qguiappcurrentscreen.cpp +++ b/src/core/qguiappcurrentscreen.cpp @@ -22,7 +22,7 @@ QScreen* QGuiAppCurrentScreen::currentScreen() QScreen* QGuiAppCurrentScreen::currentScreen(const QPoint& pos) { m_currentScreen = screenAt(pos); -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) // On the MacOS if mouse position is at the edge of bottom or right sides // qGuiApp->screenAt will return nullptr, so we need to try to find current // screen by moving 1 pixel inside to the current desktop area diff --git a/src/main.cpp b/src/main.cpp index fee7690e..2b6c2234 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -108,8 +108,7 @@ int main(int argc, char* argv[]) app.setOrganizationName(QStringLiteral("flameshot")); auto c = Controller::getInstance(); -#if not(defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX) || \ - defined(Q_OS_WIN)) +#if not(defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_WIN)) new FlameshotDBusAdapter(c); QDBusConnection dbus = QDBusConnection::sessionBus(); if (!dbus.isConnected()) { @@ -125,8 +124,7 @@ int main(int argc, char* argv[]) return app.exec(); } -#if not(defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX) || \ - defined(Q_OS_WIN)) +#if not(defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_WIN)) /*--------------| * CLI parsing | * ------------*/ diff --git a/src/tools/abstractpathtool.cpp b/src/tools/abstractpathtool.cpp index 65557805..fbbd7e4c 100644 --- a/src/tools/abstractpathtool.cpp +++ b/src/tools/abstractpathtool.cpp @@ -46,7 +46,7 @@ bool AbstractPathTool::showMousePreview() const void AbstractPathTool::undo(QPixmap& pixmap) { QPainter p(&pixmap); -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) // Not sure how will it work on 4k and fullHd on Linux or Windows with a // capture of different displays with different DPI, so let it be MacOS // specific only. @@ -85,7 +85,7 @@ void AbstractPathTool::updateBackup(const QPixmap& pixmap) QRect AbstractPathTool::backupRect(const QPixmap& pixmap) const { const QRect& limits = pixmap.rect(); -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) // Not sure how will it work on 4k and fullHd on Linux or Windows with a // capture of different displays with different DPI, so let it be MacOS // specific only. diff --git a/src/tools/abstracttwopointtool.cpp b/src/tools/abstracttwopointtool.cpp index fe8c7975..f4653164 100644 --- a/src/tools/abstracttwopointtool.cpp +++ b/src/tools/abstracttwopointtool.cpp @@ -73,7 +73,7 @@ bool AbstractTwoPointTool::showMousePreview() const void AbstractTwoPointTool::undo(QPixmap& pixmap) { QPainter p(&pixmap); -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) // Not sure how will it work on 4k and fullHd on Linux or Windows with a // capture of different displays with different DPI, so let it be MacOS // specific only. @@ -121,7 +121,7 @@ QRect AbstractTwoPointTool::backupRect(const QPixmap& pixmap) const { const QRect& limits = pixmap.rect(); QRect r = QRect(m_points.first, m_points.second).normalized(); -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) // Not sure how will it work on 4k and fullHd on Linux or Windows with a // capture of different displays with different DPI, so let it be MacOS // specific only. diff --git a/src/tools/pin/pintool.cpp b/src/tools/pin/pintool.cpp index 9708738d..934667cd 100644 --- a/src/tools/pin/pintool.cpp +++ b/src/tools/pin/pintool.cpp @@ -52,7 +52,7 @@ QString PinTool::description() const QWidget* PinTool::widget() { qreal devicePixelRatio = 1; -#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(); if (currentScreen) { devicePixelRatio = currentScreen->devicePixelRatio(); @@ -62,7 +62,7 @@ QWidget* PinTool::widget() const int m = w->margin() * devicePixelRatio; QRect adjusted_pos = m_geometry + QMargins(m, m, m, m); w->setGeometry(adjusted_pos); -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) if (currentScreen) { QPoint topLeft = currentScreen->geometry().topLeft(); adjusted_pos.setX((adjusted_pos.x() - topLeft.x()) / devicePixelRatio + diff --git a/src/tools/save/savetool.cpp b/src/tools/save/savetool.cpp index 6230076b..272c39ea 100644 --- a/src/tools/save/savetool.cpp +++ b/src/tools/save/savetool.cpp @@ -18,7 +18,7 @@ #include "savetool.h" #include "src/utils/screenshotsaver.h" #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" #include #include @@ -60,7 +60,7 @@ CaptureTool* SaveTool::copy(QObject* parent) void SaveTool::pressed(const CaptureContext& context) { -#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 == diff --git a/src/tools/text/texttool.cpp b/src/tools/text/texttool.cpp index 05603398..c475316e 100644 --- a/src/tools/text/texttool.cpp +++ b/src/tools/text/texttool.cpp @@ -130,7 +130,7 @@ CaptureTool* TextTool::copy(QObject* parent) void TextTool::undo(QPixmap& pixmap) { QPainter p(&pixmap); -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) // Not sure how will it work on 4k and fullHd on Linux or Windows with a // capture of different displays with different DPI, so let it be MacOS // specific only. @@ -165,7 +165,7 @@ QRect TextTool::backupRect(const QPixmap& pixmap) const { const QRect& limits = pixmap.rect(); QRect r = m_backupArea.normalized(); -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) const qreal pixelRatio = pixmap.devicePixelRatio(); const int val = 5 * pixelRatio; if (1 != pixelRatio) { diff --git a/src/tools/toolfactory.cpp b/src/tools/toolfactory.cpp index 2754353a..3d4d3ebe 100644 --- a/src/tools/toolfactory.cpp +++ b/src/tools/toolfactory.cpp @@ -92,7 +92,7 @@ CaptureTool* ToolFactory::CreateTool(CaptureToolButton::ButtonType t, case CaptureToolButton::TYPE_REDO: tool = new RedoTool(parent); break; -#if not(defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if not(defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) case CaptureToolButton::TYPE_OPEN_APP: tool = new AppLauncher(parent); break; diff --git a/src/utils/configshortcuts.cpp b/src/utils/configshortcuts.cpp index b6ec4504..07fae504 100644 --- a/src/utils/configshortcuts.cpp +++ b/src/utils/configshortcuts.cpp @@ -62,7 +62,7 @@ const QVector& ConfigShortcuts::captureShortcutsDefault( m_shortcuts << (QStringList() << "" << QObject::tr("Quit capture") << QKeySequence(Qt::Key_Escape).toString()); -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) m_shortcuts << (QStringList() << "" << QObject::tr("Screenshot history") << "⇧⌘⌥H"); m_shortcuts << (QStringList() @@ -131,7 +131,7 @@ const QKeySequence& ConfigShortcuts::captureShortcutDefault( case CaptureToolButton::ButtonType::TYPE_IMAGEUPLOADER: m_ks = QKeySequence(Qt::Key_Return); break; -#if not(defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if not(defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) case CaptureToolButton::ButtonType::TYPE_OPEN_APP: m_ks = QKeySequence(Qt::CTRL + Qt::Key_O); break; diff --git a/src/utils/screengrabber.cpp b/src/utils/screengrabber.cpp index 1d19bb54..3aac0dc2 100644 --- a/src/utils/screengrabber.cpp +++ b/src/utils/screengrabber.cpp @@ -39,7 +39,7 @@ ScreenGrabber::ScreenGrabber(QObject* parent) QPixmap ScreenGrabber::grabEntireDesktop(bool& ok) { ok = true; -#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(); QPixmap screenPixmap( currentScreen->grabWindow(QApplication::desktop()->winId(), diff --git a/src/utils/systemnotification.cpp b/src/utils/systemnotification.cpp index 79fad371..bd417097 100644 --- a/src/utils/systemnotification.cpp +++ b/src/utils/systemnotification.cpp @@ -4,8 +4,7 @@ #include #include -#if not(defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX) || \ - defined(Q_OS_WIN)) +#if not(defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_WIN)) #include #include #include @@ -15,8 +14,7 @@ SystemNotification::SystemNotification(QObject* parent) : QObject(parent) , m_interface(nullptr) { -#if not(defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX) || \ - defined(Q_OS_WIN)) +#if not(defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_WIN)) m_interface = new QDBusInterface(QStringLiteral("org.freedesktop.Notifications"), QStringLiteral("/org/freedesktop/Notifications"), @@ -41,8 +39,7 @@ void SystemNotification::sendMessage(const QString& text, return; } -#if defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX) || \ - defined(Q_OS_WIN) +#if defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_WIN) Controller::getInstance()->sendTrayNotification(text, title, timeout); #else QList args; diff --git a/src/widgets/capture/capturetoolbutton.cpp b/src/widgets/capture/capturetoolbutton.cpp index 7f81d76f..6159e781 100644 --- a/src/widgets/capture/capturetoolbutton.cpp +++ b/src/widgets/capture/capturetoolbutton.cpp @@ -134,7 +134,7 @@ static std::map buttonTypeOrder { CaptureToolButton::TYPE_COPY, 14 }, { CaptureToolButton::TYPE_SAVE, 15 }, { CaptureToolButton::TYPE_IMAGEUPLOADER, 16 }, -#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, 17 }, { CaptureToolButton::TYPE_EXIT, 18 }, { CaptureToolButton::TYPE_PIN, 19 }, #else @@ -168,7 +168,7 @@ QVector 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, diff --git a/src/widgets/capturelauncher.cpp b/src/widgets/capturelauncher.cpp index 6fd1be02..19e9c6ad 100644 --- a/src/widgets/capturelauncher.cpp +++ b/src/widgets/capturelauncher.cpp @@ -60,7 +60,7 @@ CaptureLauncher::CaptureLauncher(QDialog* parent) m_captureType->insertItem( 1, tr("Rectangular Region"), CaptureRequest::GRAPHICAL_MODE); -#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX)) +#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS)) // Following to MacOS philosophy (one application cannot be displayed on // more than one display) m_captureType->insertItem( diff --git a/src/widgets/panel/sidepanelwidget.cpp b/src/widgets/panel/sidepanelwidget.cpp index 527795d6..d78c9cf8 100644 --- a/src/widgets/panel/sidepanelwidget.cpp +++ b/src/widgets/panel/sidepanelwidget.cpp @@ -25,7 +25,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 #endif @@ -165,7 +165,7 @@ QColor SidePanelWidget::grabPixmapColor(const QPoint& p) { QColor c; if (m_pixmap) { -#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(); QPoint point = p; if (currentScreen) {