Code refactoring - remove Q_OS_MACX (is not required, is covered by Q_OS_DARWIN)

(cherry picked from commit 00b9aae5266aaffb9a01a6f689e1829ae8218bdc)
This commit is contained in:
Yuriy Puchkov
2021-02-10 20:01:12 +02:00
parent 296bed0491
commit dd54d028a1
15 changed files with 28 additions and 33 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -18,7 +18,7 @@
#include "savetool.h"
#include "src/utils/screenshotsaver.h"
#include <QPainter>
#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 <QApplication>
#include <QWidget>
@@ -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 ==

View File

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

View File

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

View File

@@ -62,7 +62,7 @@ const QVector<QStringList>& 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;

View File

@@ -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(),

View File

@@ -4,8 +4,7 @@
#include <QApplication>
#include <QUrl>
#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 <QDBusConnection>
#include <QDBusInterface>
#include <QDBusMessage>
@@ -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<QVariant> args;

View File

@@ -134,7 +134,7 @@ static std::map<CaptureToolButton::ButtonType, int> 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::ButtonType>
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,

View File

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

View File

@@ -25,7 +25,7 @@
#include <QPushButton>
#include <QSlider>
#include <QVBoxLayout>
#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || defined(Q_OS_MACX))
#if (defined(Q_OS_MAC64) || defined(Q_OS_MACOS))
#include <QScreen>
#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) {