Skip to content

Commit 8605162

Browse files
去除macos相关代码
1 parent 4076ced commit 8605162

24 files changed

+54
-332
lines changed

CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md") # TODO: Wher
5757
if(WIN32)
5858
# Include all dynamically linked runtime libraries such as MSVCRxxx.dll
5959
include(InstallRequiredSystemLibraries)
60-
61-
else()
62-
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-linux")
63-
set(CPACK_GENERATOR TGZ)
64-
set(CPACK_SOURCE_GENERATOR TGZ)
6560
endif()
6661

6762
include(CPack)

src/config/generalconf.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -585,10 +585,6 @@ void GeneralConf::initUseJpgForClipboard()
585585
tr("Use lossy JPG format for clipboard (lossless PNG default)"));
586586
m_scrollAreaLayout->addWidget(m_useJpgForClipboard);
587587

588-
#if defined(Q_OS_MACOS)
589-
// FIXME - temporary fix to disable option for MacOS
590-
m_useJpgForClipboard->hide();
591-
#endif
592588
connect(m_useJpgForClipboard,
593589
&QCheckBox::clicked,
594590
this,

src/config/shortcutswidget.cpp

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,8 @@ void ShortcutsWidget::populateInfoTable()
9393
const auto key_sequence = current_shortcut.at(2);
9494
m_table->setItem(i, 0, new QTableWidgetItem(description));
9595

96-
#if defined(Q_OS_MACOS)
97-
auto* item = new QTableWidgetItem(nativeOSHotKeyText(key_sequence));
98-
#else
9996
QTableWidgetItem* item = new QTableWidgetItem(key_sequence);
100-
#endif
97+
10198
item->setTextAlignment(Qt::AlignCenter);
10299
m_table->setItem(i, 1, item);
103100

@@ -134,15 +131,10 @@ void ShortcutsWidget::onShortcutCellClicked(int row, int col)
134131
QKeySequence shortcutValue = setShortcutDialog->shortcut();
135132

136133
// set no shortcut is Backspace
137-
#if defined(Q_OS_MACOS)
138-
if (shortcutValue == QKeySequence(Qt::CTRL + Qt::Key_Backspace)) {
139-
shortcutValue = QKeySequence("");
140-
}
141-
#else
134+
142135
if (shortcutValue == QKeySequence(Qt::Key_Backspace)) {
143136
shortcutValue = QKeySequence("");
144137
}
145-
#endif
146138
if (m_config.setShortcut(shortcutName, shortcutValue.toString())) {
147139
populateInfoTable();
148140
}
@@ -198,10 +190,8 @@ void ShortcutsWidget::loadShortcuts()
198190
<< QKeySequence(Qt::Key_Escape).toString());
199191

200192
// Global hotkeys
201-
#if defined(Q_OS_MACOS)
202-
appendShortcut("TAKE_SCREENSHOT", tr("Capture screen"));
203-
appendShortcut("SCREENSHOT_HISTORY", tr("Screenshot history"));
204-
#elif defined(Q_OS_WIN)
193+
194+
#if defined(Q_OS_WIN)
205195
m_shortcuts << (QStringList() << "" << QObject::tr("Screenshot history")
206196
<< "Shift+Print Screen");
207197
m_shortcuts << (QStringList()
@@ -227,14 +217,3 @@ void ShortcutsWidget::appendShortcut(const QString& shortcutName,
227217
<< shortcut.replace("Return", "Enter"));
228218
}
229219

230-
#if defined(Q_OS_MACOS)
231-
const QString& ShortcutsWidget::nativeOSHotKeyText(const QString& text)
232-
{
233-
m_res = text;
234-
m_res.replace("Ctrl+", "");
235-
m_res.replace("Alt+", "");
236-
m_res.replace("Meta+", "");
237-
m_res.replace("Shift+", "");
238-
return m_res;
239-
}
240-
#endif

src/config/shortcutswidget.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,13 @@ class ShortcutsWidget : public QWidget
2121

2222
private:
2323
void initInfoTable();
24-
#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
25-
defined(Q_OS_MACX))
26-
const QString& nativeOSHotKeyText(const QString& text);
27-
#endif
2824

2925
private slots:
3026
void populateInfoTable();
3127
void onShortcutCellClicked(int, int);
3228

3329
private:
34-
#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
35-
defined(Q_OS_MACX))
36-
QString m_res;
37-
#endif
30+
3831
ConfigHandler m_config;
3932
QTableWidget* m_table;
4033
QVBoxLayout* m_layout;

src/core/flameshot.cpp

Lines changed: 3 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33

44
#include "flameshot.h"
55
#include "flameshotdaemon.h"
6-
#if defined(Q_OS_MACOS)
7-
#include "external/QHotkey/QHotkey"
8-
#endif
96

107
#include "abstractlogger.h"
118
#include "screenshotsaver.h"
@@ -31,42 +28,15 @@
3128
#include <QTimer>
3229
#include <QVersionNumber>
3330

34-
#if defined(Q_OS_MACOS)
35-
#include <QScreen>
36-
#endif
3731

3832
Flameshot::Flameshot()
3933
: m_captureWindow(nullptr)
4034
, m_haveExternalWidget(false)
41-
#if defined(Q_OS_MACOS)
42-
, m_HotkeyScreenshotCapture(nullptr)
43-
, m_HotkeyScreenshotHistory(nullptr)
44-
#endif
4535
{
4636
QString StyleSheet = CaptureButton::globalStyleSheet();
4737
qApp->setStyleSheet(StyleSheet);
4838

49-
#if defined(Q_OS_MACOS)
50-
// Try to take a test screenshot, MacOS will request a "Screen Recording"
51-
// permissions on the first run. Otherwise it will be hidden under the
52-
// CaptureWidget
53-
QScreen* currentScreen = QGuiAppCurrentScreen().currentScreen();
54-
currentScreen->grabWindow(QApplication::desktop()->winId(), 0, 0, 1, 1);
55-
56-
// set global shortcuts for MacOS
57-
m_HotkeyScreenshotCapture = new QHotkey(
58-
QKeySequence(ConfigHandler().shortcut("TAKE_SCREENSHOT")), true, this);
59-
QObject::connect(m_HotkeyScreenshotCapture,
60-
&QHotkey::activated,
61-
qApp,
62-
[this]() { gui(); });
63-
m_HotkeyScreenshotHistory = new QHotkey(
64-
QKeySequence(ConfigHandler().shortcut("SCREENSHOT_HISTORY")), true, this);
65-
QObject::connect(m_HotkeyScreenshotHistory,
66-
&QHotkey::activated,
67-
qApp,
68-
[this]() { history(); });
69-
#endif
39+
7040
}
7141

7242
Flameshot* Flameshot::instance()
@@ -187,10 +157,7 @@ void Flameshot::launcher()
187157
m_launcherWindow = new CaptureLauncher();
188158
}
189159
m_launcherWindow->show();
190-
#if defined(Q_OS_MACOS)
191-
m_launcherWindow->activateWindow();
192-
m_launcherWindow->raise();
193-
#endif
160+
194161
}
195162

196163
void Flameshot::config()
@@ -209,10 +176,7 @@ void Flameshot::info()
209176
{
210177
if (m_infoWindow == nullptr) {
211178
m_infoWindow = new InfoWindow();
212-
#if defined(Q_OS_MACOS)
213-
m_infoWindow->activateWindow();
214-
m_infoWindow->raise();
215-
#endif
179+
216180
}
217181
}
218182

@@ -228,10 +192,6 @@ void Flameshot::history()
228192
}
229193
historyWidget->show();
230194

231-
#if defined(Q_OS_MACOS)
232-
historyWidget->activateWindow();
233-
historyWidget->raise();
234-
#endif
235195
}
236196

237197
QVersionNumber Flameshot::getVersion()
@@ -240,16 +200,6 @@ QVersionNumber Flameshot::getVersion()
240200
QStringLiteral(APP_VERSION).replace("v", ""));
241201
}
242202

243-
void Flameshot::setOrigin(Origin origin)
244-
{
245-
m_origin = origin;
246-
}
247-
248-
Flameshot::Origin Flameshot::origin()
249-
{
250-
return m_origin;
251-
}
252-
253203
/**
254204
* @brief Prompt the user to resolve config errors if necessary.
255205
* @return Whether errors were resolved.
@@ -265,9 +215,6 @@ bool Flameshot::resolveAnyConfigErrors()
265215
resolver, &ConfigResolver::rejected, [resolver, &resolved]() {
266216
resolved = false;
267217
resolver->deleteLater();
268-
if (origin() == CLI) {
269-
exit(1);
270-
}
271218
});
272219
QObject::connect(
273220
resolver, &ConfigResolver::accepted, [resolver, &resolved]() {

src/core/flameshot.h

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ class ConfigWindow;
1313
class InfoWindow;
1414
class CaptureLauncher;
1515
class UploadHistory;
16-
#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
17-
defined(Q_OS_MACX))
18-
class QHotkey;
19-
#endif
2016

2117
class Flameshot : public QObject
2218
{
@@ -32,8 +28,9 @@ class Flameshot : public QObject
3228
static Flameshot* instance();
3329

3430
public slots:
35-
CaptureWidget* gui(
36-
const CaptureRequest& req = CaptureRequest::GRAPHICAL_MODE);
31+
// 截图接口
32+
CaptureWidget* gui(const CaptureRequest& req = CaptureRequest::GRAPHICAL_MODE);
33+
3734
void screen(CaptureRequest req, int const screenNumber = -1);
3835
void full(const CaptureRequest& req);
3936
void launcher();
@@ -45,8 +42,6 @@ public slots:
4542
QVersionNumber getVersion();
4643

4744
public:
48-
static void setOrigin(Origin origin);
49-
static Origin origin();
5045
void setExternalWidget(bool b);
5146
bool haveExternalWidget();
5247

@@ -73,9 +68,4 @@ public slots:
7368
QPointer<CaptureLauncher> m_launcherWindow;
7469
QPointer<ConfigWindow> m_configWindow;
7570

76-
#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
77-
defined(Q_OS_MACX))
78-
QHotkey* m_HotkeyScreenshotCapture;
79-
QHotkey* m_HotkeyScreenshotHistory;
80-
#endif
8171
};

src/core/qguiappcurrentscreen.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,7 @@ QScreen* QGuiAppCurrentScreen::currentScreen()
2121
QScreen* QGuiAppCurrentScreen::currentScreen(const QPoint& pos)
2222
{
2323
m_currentScreen = screenAt(pos);
24-
#if defined(Q_OS_MACOS)
25-
// On the MacOS if mouse position is at the edge of bottom or right sides
26-
// qGuiApp->screenAt will return nullptr, so we need to try to find current
27-
// screen by moving 1 pixel inside to the current desktop area
28-
if (!m_currentScreen && pos.x() > 0) {
29-
QPoint posCorrected(pos.x() - 1, pos.y());
30-
m_currentScreen = screenAt(posCorrected);
31-
}
32-
if (!m_currentScreen && pos.y() > 0) {
33-
QPoint posCorrected(pos.x(), pos.y() - 1);
34-
m_currentScreen = screenAt(posCorrected);
35-
}
36-
if (!m_currentScreen && pos.x() > 0 && pos.y() > 0) {
37-
QPoint posCorrected(pos.x() - 1, pos.y() - 1);
38-
m_currentScreen = screenAt(posCorrected);
39-
}
40-
#endif
24+
4125
if (!m_currentScreen) {
4226
qCritical("Unable to get current screen, starting to use primary "
4327
"screen. It may be a cause of logical error and working with "

src/tools/accept/accepttool.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
#include <QApplication>
77
#include <QPainter>
88
#include <QStyle>
9-
#if defined(Q_OS_MACOS)
10-
#include "src/widgets/capture/capturewidget.h"
11-
#include <QWidget>
12-
#endif
139

1410
AcceptTool::AcceptTool(QObject* parent)
1511
: AbstractActionTool(parent)

src/tools/pin/pinwidget.cpp

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,7 @@ PinWidget::PinWidget(const QPixmap& pixmap,
5858
new QShortcut(Qt::Key_Escape, this, SLOT(close()));
5959

6060
qreal devicePixelRatio = 1;
61-
#if defined(Q_OS_MACOS)
62-
QScreen* currentScreen = QGuiAppCurrentScreen().currentScreen();
63-
if (currentScreen != nullptr) {
64-
devicePixelRatio = currentScreen->devicePixelRatio();
65-
}
66-
#endif
61+
6762
const int margin =
6863
static_cast<int>(static_cast<double>(MARGIN) * devicePixelRatio);
6964
QRect adjusted_pos = geometry + QMargins(margin, margin, margin, margin);
@@ -72,20 +67,7 @@ PinWidget::PinWidget(const QPixmap& pixmap,
7267
setWindowFlags(Qt::X11BypassWindowManagerHint);
7368
#endif
7469

75-
#if defined(Q_OS_MACOS)
76-
if (currentScreen != nullptr) {
77-
QPoint topLeft = currentScreen->geometry().topLeft();
78-
adjusted_pos.setX((adjusted_pos.x() - topLeft.x()) / devicePixelRatio +
79-
topLeft.x());
80-
81-
adjusted_pos.setY((adjusted_pos.y() - topLeft.y()) / devicePixelRatio +
82-
topLeft.y());
83-
adjusted_pos.setWidth(adjusted_pos.size().width() / devicePixelRatio);
84-
adjusted_pos.setHeight(adjusted_pos.size().height() / devicePixelRatio);
85-
resize(0, 0);
86-
move(adjusted_pos.x(), adjusted_pos.y());
87-
}
88-
#endif
70+
8971
grabGesture(Qt::PinchGesture);
9072

9173
this->setContextMenuPolicy(Qt::CustomContextMenu);
@@ -105,10 +87,9 @@ bool PinWidget::scrollEvent(QWheelEvent* event)
10587
{
10688
const auto phase = event->phase();
10789
if (phase == Qt::ScrollPhase::ScrollUpdate
108-
#if defined(Q_OS_LINUX) || defined(Q_OS_WINDOWS)
10990
// Linux is getting only NoScrollPhase events.
11091
|| phase == Qt::ScrollPhase::NoScrollPhase
111-
#endif
92+
11293
) {
11394
const auto angle = event->angleDelta();
11495
if (angle.y() == 0) {
@@ -119,12 +100,9 @@ bool PinWidget::scrollEvent(QWheelEvent* event)
119100
: m_currentStepScaleFactor - STEP;
120101
m_expanding = m_currentStepScaleFactor >= 1.0;
121102
}
122-
#if defined(Q_OS_MACOS)
123-
// ScrollEnd is currently supported only on Mac OSX
124-
if (phase == Qt::ScrollPhase::ScrollEnd) {
125-
#else
103+
126104
else {
127-
#endif
105+
128106
m_scaleFactor *= m_currentStepScaleFactor;
129107
m_currentStepScaleFactor = 1.0;
130108
m_expanding = false;

src/tools/toolfactory.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ CaptureTool* ToolFactory::CreateTool(CaptureTool::Type t, QObject* parent)
5050
if_TYPE_return_TOOL(TYPE_SAVE, SaveTool);
5151
if_TYPE_return_TOOL(TYPE_EXIT, ExitTool);
5252
if_TYPE_return_TOOL(TYPE_IMAGEUPLOADER, ImgUploaderTool);
53-
#if !defined(Q_OS_MACOS)
54-
if_TYPE_return_TOOL(TYPE_OPEN_APP, AppLauncher);
55-
#endif
53+
5654
if_TYPE_return_TOOL(TYPE_PIXELATE, PixelateTool);
5755
if_TYPE_return_TOOL(TYPE_REDO, RedoTool);
5856
if_TYPE_return_TOOL(TYPE_PIN, PinTool);

0 commit comments

Comments
 (0)