From 199ff2586a8a85a1055025d6f9ea853a0d87036b Mon Sep 17 00:00:00 2001 From: El Thoro Date: Sat, 14 Mar 2026 15:59:28 +0100 Subject: [PATCH 1/2] Windows: Global "take screenshot" shortcut (#4556) * Enable QHotkey on Windows to define global shortcut for taking screenshot * Check if Windows forces PrntScr for its snipping tool; provide the option to change corresponding registry key by Flameshot * Option to register Flameshot as MS-SCREENCLIP application * clang-format * Default shortcut * Minor: Move MsScreenclip initialization to separate function * Minor: Move MsScreenclip initialization to separate function --- CMakeLists.txt | 6 +- README.md | 6 +- src/CMakeLists.txt | 5 + src/config/setshortcutwidget.cpp | 35 ++++- src/config/setshortcutwidget.h | 10 +- src/config/shortcutswidget.cpp | 212 +++++++++++++++++++++++++++++- src/config/shortcutswidget.h | 16 ++- src/core/flameshot.cpp | 15 ++- src/core/flameshot.h | 6 +- src/core/flameshotdaemon.cpp | 3 - src/core/globalshortcutfilter.cpp | 6 +- src/core/globalshortcutfilter.h | 3 - src/utils/confighandler.cpp | 7 + src/utils/confighandler.h | 5 + src/utils/screenshotsaver.cpp | 4 +- 15 files changed, 303 insertions(+), 36 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2678f1e56d..fa396e5259 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,10 @@ set(QT_DEFAULT_MAJOR_VERSION 6 CACHE STRING "") set(QT_VERSION_MAJOR 6 CACHE STRING "") #BUILD_SHARED_LIBS used by QHotkey and QtColorWidgets option(BUILD_SHARED_LIBS OFF) +#QHOTKEY_INSTALL used by QHotkey; must be disabled on Windows +if(WIN32) +set(QHOTKEY_INSTALL OFF CACHE BOOL "qHotkey install") +endif() #Needed due to linker error with QtColorWidget set(CMAKE_POSITION_INDEPENDENT_CODE ON) @@ -134,7 +138,7 @@ endif() # ToDo: Check if this is used anywhere option(BUILD_STATIC_LIBS ON) -if(APPLE) +if(WIN32 OR APPLE) FetchContent_Declare( qHotKey GIT_REPOSITORY https://github.com/flameshot-org/QHotkey diff --git a/README.md b/README.md index aaa4719490..6bc86b406a 100644 --- a/README.md +++ b/README.md @@ -237,9 +237,9 @@ These shortcuts are available in GUI mode: ### Global -Flameshot uses Print screen (Windows) and cmd-shift-x (macOS) as default global hotkeys. - -On Linux, Flameshot doesn't yet support Prt Sc out of the box, but with a bit of configuration you can set this up: +- Windows: Prt Sc (fixed, cannot be changed) and Win + Shift + X (can be changed in the settings) +- macOS: cmd + Shift + X (can be changed in the settings) +- Linux: Flameshot doesn't yet support Prt Sc out of the box, but you can set this up with a bit of configuration: #### On KDE Plasma desktop diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d37bff000c..8f47eca059 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -296,6 +296,11 @@ if (WIN32) if (NOT USE_OPENSSL) message(WARNING "OpenSSL is required to upload screenshots") endif () + + target_link_libraries( + flameshot + qhotkey + ) endif () # Choose default color palette (small or large) diff --git a/src/config/setshortcutwidget.cpp b/src/config/setshortcutwidget.cpp index af9318fd75..5a047f1dda 100644 --- a/src/config/setshortcutwidget.cpp +++ b/src/config/setshortcutwidget.cpp @@ -8,6 +8,7 @@ #include #include #include +#include SetShortcutDialog::SetShortcutDialog(QDialog* parent, const QString& shortcutName) @@ -34,7 +35,7 @@ SetShortcutDialog::SetShortcutDialog(QDialog* parent, m_layout->addWidget(infoIcon); QString msg = ""; -#if defined(Q_OS_MAC) +#if defined(Q_OS_MACOS) msg = tr( "Press Esc to cancel or ⌘+Backspace to disable the keyboard shortcut."); #else @@ -58,6 +59,15 @@ SetShortcutDialog::SetShortcutDialog(QDialog* parent, infoBottom->setMargin(10); infoBottom->setAlignment(Qt::AlignCenter); m_layout->addWidget(infoBottom); + + // 0ms Delay: Event loop waits until after show(); widget fully initialized + QTimer::singleShot(0, this, &SetShortcutDialog::startCapture); +} + +void SetShortcutDialog::startCapture() +{ + grabKeyboard(); // Call AFTER show()! + setFocus(); } const QKeySequence& SetShortcutDialog::shortcut() @@ -67,16 +77,19 @@ const QKeySequence& SetShortcutDialog::shortcut() void SetShortcutDialog::keyPressEvent(QKeyEvent* ke) { - if (ke->modifiers() & Qt::ShiftModifier) { + Qt::KeyboardModifiers mods = ke->modifiers(); + + if (mods & Qt::ShiftModifier) { m_modifier += "Shift+"; } - if (ke->modifiers() & Qt::ControlModifier) { + if (mods & Qt::ControlModifier) { m_modifier += "Ctrl+"; } - if (ke->modifiers() & Qt::AltModifier) { + if (mods & Qt::AltModifier) { m_modifier += "Alt+"; } - if (ke->modifiers() & Qt::MetaModifier) { + // ke->key() == Qt::Key_Meta required on Windows to grab Win key + if (ke->modifiers() & Qt::MetaModifier || ke->key() == Qt::Key_Meta) { m_modifier += "Meta+"; } @@ -91,3 +104,15 @@ void SetShortcutDialog::keyReleaseEvent(QKeyEvent* event) } accept(); } + +void SetShortcutDialog::accept() +{ + releaseKeyboard(); + QDialog::accept(); +} + +void SetShortcutDialog::reject() +{ + releaseKeyboard(); + QDialog::reject(); +} diff --git a/src/config/setshortcutwidget.h b/src/config/setshortcutwidget.h index 1232461393..e0056251f1 100644 --- a/src/config/setshortcutwidget.h +++ b/src/config/setshortcutwidget.h @@ -19,12 +19,16 @@ class SetShortcutDialog : public QDialog const QKeySequence& shortcut(); public: - void keyPressEvent(QKeyEvent*); - void keyReleaseEvent(QKeyEvent* event); + void keyPressEvent(QKeyEvent*) override; + void keyReleaseEvent(QKeyEvent* event) override; -signals: +private slots: + void accept() override; + void reject() override; private: + void startCapture(); + QVBoxLayout* m_layout; QString m_modifier; QKeySequence m_ks; diff --git a/src/config/shortcutswidget.cpp b/src/config/shortcutswidget.cpp index 5117e94576..c6b1ef97e4 100644 --- a/src/config/shortcutswidget.cpp +++ b/src/config/shortcutswidget.cpp @@ -7,11 +7,14 @@ #include "src/core/qguiappcurrentscreen.h" #include "src/utils/globalvalues.h" #include "toolfactory.h" +#include #include +#include #include #include #include #include +#include #include #include #include @@ -34,11 +37,20 @@ ShortcutsWidget::ShortcutsWidget(QWidget* parent) m_layout = new QVBoxLayout(this); m_layout->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); +#if defined(Q_OS_WIN) + checkPrintScreenForcesSnipping(); +#endif + initInfoTable(); connect(ConfigHandler::getInstance(), &ConfigHandler::fileChanged, this, &ShortcutsWidget::populateInfoTable); + +#if defined(Q_OS_WIN) + initMsScreenclipCheckbox(); +#endif + show(); } @@ -202,13 +214,15 @@ void ShortcutsWidget::loadShortcuts() appendShortcut("SCREENSHOT_HISTORY", tr("Screenshot history")); #endif #elif defined(Q_OS_WIN) - + if (this->isPrintScreenKeyForSnippingDisabled()) { + m_shortcuts << (QStringList() << "" << QObject::tr("Capture screen") + << "Print Screen"); + } + appendShortcut("TAKE_SCREENSHOT", tr("Capture screen")); #ifdef ENABLE_IMGUR m_shortcuts << (QStringList() << "" << QObject::tr("Screenshot history") << "Shift+Print Screen"); #endif - m_shortcuts << (QStringList() - << "" << QObject::tr("Capture screen") << "Print Screen"); #else // TODO - Linux doesn't support global shortcuts for (XServer and Wayland), // possibly it will be solved in the QHotKey library later. So it is @@ -241,3 +255,195 @@ const QString& ShortcutsWidget::nativeOSHotKeyText(const QString& text) return m_res; } #endif + +#if defined(Q_OS_WIN) +void ShortcutsWidget::checkPrintScreenForcesSnipping() +{ + if (!isPrintScreenKeyForSnippingDisabled() && + !ConfigHandler().ignorePrntScrForcesSnipping()) { + QMessageBox msgBox; + msgBox.setWindowTitle("Flameshot"); + msgBox.setIcon(QMessageBox::Question); + msgBox.setText(tr("It seems, that Windows forces to open its screenshot" + " tool when the 'Print Screen' key is pressed. Would " + "you like to disable this so that Flameshot can use " + "the 'Print Screen' key?") + + "\n\n" + + tr("Flameshot must be restarted for changes to take " + "effect.")); + QPushButton* yesBtn = msgBox.addButton(QMessageBox::Yes); + QPushButton* noBtn = msgBox.addButton(QMessageBox::No); + QPushButton* noDontAskAgainBtn = + new QPushButton(tr("No, don't ask again")); + msgBox.addButton(noDontAskAgainBtn, QMessageBox::RejectRole); + msgBox.setDefaultButton(yesBtn); + msgBox.exec(); + + if (msgBox.clickedButton() == yesBtn) { + if (!disablePrintScreenKeyForSnipping()) { + QMessageBox::warning( + this, "Flameshot", tr("The registry could not be changed!")); + } + } else if (msgBox.clickedButton() == noDontAskAgainBtn) { + ConfigHandler().setIgnorePrntScrForcesSnipping(true); + } + } +} + +bool ShortcutsWidget::isPrintScreenKeyForSnippingDisabled() +{ + QSettings PrintKeyForSnipping("HKEY_CURRENT_USER\\Control Panel\\Keyboard", + QSettings::NativeFormat); + return PrintKeyForSnipping.value("PrintScreenKeyForSnippingEnabled", 1) + .toInt() == 0; +} + +bool ShortcutsWidget::disablePrintScreenKeyForSnipping() +{ + QSettings PrintKeyForSnipping("HKEY_CURRENT_USER\\Control Panel\\Keyboard", + QSettings::NativeFormat); + PrintKeyForSnipping.setValue("PrintScreenKeyForSnippingEnabled", 0); + PrintKeyForSnipping.sync(); + if (QSettings::AccessError == PrintKeyForSnipping.status()) { + return false; + } + return this->isPrintScreenKeyForSnippingDisabled(); +} + +void ShortcutsWidget::initMsScreenclipCheckbox() +{ + m_registerMsScreenclip = + new QCheckBox(tr("Register Flameshot as MS-SCREENCLIP application " + "(administrator privileges required)"), + this); + m_registerMsScreenclip->setToolTip( + tr("After registering, you can select Flameshot as the default " + "screenshot application in Windows Settings.")); + m_registerMsScreenclip->setChecked(isMsScreenclipRegistered()); + m_layout->addWidget(m_registerMsScreenclip); + + connect( + m_registerMsScreenclip, &QCheckBox::clicked, this, [this](bool checked) { + if (checked) { + if (!registerMsScreenclip()) { + QMessageBox::warning( + this, + "Flameshot", + tr("The registry could not be changed!") + "\n" + + tr("You may start Flameshot as administrator ONCE and " + "try again!")); + m_registerMsScreenclip->setChecked(false); + } + } else { + if (!unregisterMsScreenclip()) { + QMessageBox::warning( + this, + "Flameshot", + tr("The registry could not be changed!") + "\n" + + tr("You may start Flameshot as administrator ONCE and " + "try again!")); + m_registerMsScreenclip->setChecked(true); + } + } + }); +} + +bool ShortcutsWidget::isMsScreenclipRegistered() +{ + QSettings URLAssociations( + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Flameshot\\Capabilities\\URLAssociations", + QSettings::NativeFormat); + QString value = URLAssociations.value("ms-screenclip", "").toString(); + if (value.toLower() != "flameshot") + return false; + + QSettings RegisteredApplications( + "HKEY_LOCAL_MACHINE\\SOFTWARE\\RegisteredApplications", + QSettings::NativeFormat); + value = RegisteredApplications.value("Flameshot", "").toString(); + if (value.toLower() != + QString("SOFTWARE\\Flameshot\\Capabilities").toLower()) + return false; + + QSettings FlameshotShellCmd( + "HKEY_CURRENT_USER\\Software\\Classes\\Flameshot\\Shell\\Open\\command", + QSettings::NativeFormat); + value = FlameshotShellCmd.value(".").toString(); + if (value.toLower() != QString("\"" + + QDir::toNativeSeparators( + QCoreApplication::applicationFilePath()) + + "\" gui") + .toLower()) + return false; + + return true; // All registry entries found +} + +bool ShortcutsWidget::registerMsScreenclip() +{ + QSettings URLAssociations( + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Flameshot\\Capabilities\\URLAssociations", + QSettings::NativeFormat); + URLAssociations.setValue("ms-screenclip", "Flameshot"); + URLAssociations.sync(); + if (QSettings::AccessError == URLAssociations.status()) { + return false; + } + + QSettings RegisteredApplications( + "HKEY_LOCAL_MACHINE\\SOFTWARE\\RegisteredApplications", + QSettings::NativeFormat); + RegisteredApplications.setValue("Flameshot", + "SOFTWARE\\Flameshot\\Capabilities"); + RegisteredApplications.sync(); + if (QSettings::AccessError == RegisteredApplications.status()) { + return false; + } + + QSettings FlameshotShellCmd( + "HKEY_CURRENT_USER\\Software\\Classes\\Flameshot\\Shell\\Open\\command", + QSettings::NativeFormat); + FlameshotShellCmd.setValue( + ".", + "\"" + QDir::toNativeSeparators(QCoreApplication::applicationFilePath()) + + "\" gui"); + FlameshotShellCmd.sync(); + if (QSettings::AccessError == FlameshotShellCmd.status()) { + return false; + } + + return isMsScreenclipRegistered(); +} + +bool ShortcutsWidget::unregisterMsScreenclip() +{ + QSettings FlameshotShellCmd("HKEY_CURRENT_USER\\Software\\Classes", + QSettings::NativeFormat); + FlameshotShellCmd.remove("Flameshot"); + FlameshotShellCmd.sync(); + if (QSettings::AccessError == FlameshotShellCmd.status()) { + return false; + } + + QSettings RegisteredApplications( + "HKEY_LOCAL_MACHINE\\SOFTWARE\\RegisteredApplications", + QSettings::NativeFormat); + RegisteredApplications.remove("Flameshot"); + RegisteredApplications.sync(); + if (QSettings::AccessError == RegisteredApplications.status()) { + return false; + } + + QSettings URLAssociations( + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Flameshot\\Capabilities\\URLAssociations", + QSettings::NativeFormat); + URLAssociations.remove("ms-screenclip"); + URLAssociations.sync(); + if (QSettings::AccessError == URLAssociations.status()) { + return false; + } + + return !isMsScreenclipRegistered(); +} + +#endif diff --git a/src/config/shortcutswidget.h b/src/config/shortcutswidget.h index 63c1fa98b6..0a70a882ad 100644 --- a/src/config/shortcutswidget.h +++ b/src/config/shortcutswidget.h @@ -10,6 +10,7 @@ #include class SetShortcutDialog; +class QCheckBox; class QTableWidget; class QVBoxLayout; @@ -21,7 +22,7 @@ class ShortcutsWidget : public QWidget private: void initInfoTable(); -#if (defined(Q_OS_MAC) || defined(Q_OS_MACOS)) +#if (defined(Q_OS_MACOS)) const QString& nativeOSHotKeyText(const QString& text); #endif @@ -30,7 +31,7 @@ private slots: void onShortcutCellClicked(int, int); private: -#if (defined(Q_OS_MAC) || defined(Q_OS_MACOS)) +#if (defined(Q_OS_MACOS)) QString m_res; #endif ConfigHandler m_config; @@ -41,6 +42,17 @@ private slots: void loadShortcuts(); void appendShortcut(const QString& shortcutName, const QString& description); +#if defined(Q_OS_WIN) + void checkPrintScreenForcesSnipping(); + bool isPrintScreenKeyForSnippingDisabled(); + bool disablePrintScreenKeyForSnipping(); + + void initMsScreenclipCheckbox(); + bool isMsScreenclipRegistered(); + bool registerMsScreenclip(); + bool unregisterMsScreenclip(); + QCheckBox* m_registerMsScreenclip; +#endif }; #endif // HOTKEYSCONFIG_H diff --git a/src/core/flameshot.cpp b/src/core/flameshot.cpp index 8d1dfcae81..293beddaf8 100644 --- a/src/core/flameshot.cpp +++ b/src/core/flameshot.cpp @@ -3,7 +3,7 @@ #include "flameshot.h" #include "flameshotdaemon.h" -#if defined(Q_OS_MACOS) +#if defined(Q_OS_MACOS) || defined(Q_OS_WIN) #include "qhotkey.h" #endif @@ -43,8 +43,10 @@ Flameshot::Flameshot() : m_haveExternalWidget(false) , m_captureWindow(nullptr) -#if defined(Q_OS_MACOS) +#if (defined(Q_OS_MACOS) || defined(Q_OS_WIN)) , m_HotkeyScreenshotCapture(nullptr) +#endif +#if (defined(Q_OS_MACOS) && ENABLE_IMGUR) , m_HotkeyScreenshotHistory(nullptr) #endif { @@ -57,15 +59,17 @@ Flameshot::Flameshot() // CaptureWidget QScreen* currentScreen = QGuiAppCurrentScreen().currentScreen(); currentScreen->grabWindow(0, 0, 0, 1, 1); - - // set global shortcuts for MacOS +#endif +#if (defined(Q_OS_MACOS) || defined(Q_OS_WIN)) + // Set global shortcuts for MacOS or Windows m_HotkeyScreenshotCapture = new QHotkey( QKeySequence(ConfigHandler().shortcut("TAKE_SCREENSHOT")), true, this); QObject::connect(m_HotkeyScreenshotCapture, &QHotkey::activated, qApp, [this]() { gui(); }); -#ifdef ENABLE_IMGUR +#endif +#if (defined(Q_OS_MACOS) && ENABLE_IMGUR) m_HotkeyScreenshotHistory = new QHotkey( QKeySequence(ConfigHandler().shortcut("SCREENSHOT_HISTORY")), true, this); QObject::connect(m_HotkeyScreenshotHistory, @@ -73,7 +77,6 @@ Flameshot::Flameshot() qApp, [this]() { history(); }); #endif -#endif } Flameshot* Flameshot::instance() diff --git a/src/core/flameshot.h b/src/core/flameshot.h index a9a80ab650..b9b77159c3 100644 --- a/src/core/flameshot.h +++ b/src/core/flameshot.h @@ -15,7 +15,7 @@ class CaptureLauncher; #ifdef ENABLE_IMGUR class UploadHistory; #endif -#if (defined(Q_OS_MAC) || defined(Q_OS_MACOS)) +#if (defined(Q_OS_MACOS) || defined(Q_OS_WIN)) class QHotkey; #endif @@ -90,8 +90,10 @@ public slots: QPointer m_launcherWindow; QPointer m_configWindow; -#if (defined(Q_OS_MAC) || defined(Q_OS_MACOS)) +#if (defined(Q_OS_MACOS) || defined(Q_OS_WIN)) QHotkey* m_HotkeyScreenshotCapture; +#endif +#if (defined(Q_OS_MACOS) && ENABLE_IMGUR) QHotkey* m_HotkeyScreenshotHistory; #endif }; diff --git a/src/core/flameshotdaemon.cpp b/src/core/flameshotdaemon.cpp index a01b394e19..da1fa7af54 100644 --- a/src/core/flameshotdaemon.cpp +++ b/src/core/flameshotdaemon.cpp @@ -394,9 +394,6 @@ void FlameshotDaemon::initTrayIcon() GlobalShortcutFilter* nativeFilter = new GlobalShortcutFilter(this); qApp->installNativeEventFilter(nativeFilter); - connect(nativeFilter, &GlobalShortcutFilter::printPressed, this, [this]() { - Flameshot::instance()->gui(); - }); #endif } diff --git a/src/core/globalshortcutfilter.cpp b/src/core/globalshortcutfilter.cpp index 949fde9893..6aba7dd150 100644 --- a/src/core/globalshortcutfilter.cpp +++ b/src/core/globalshortcutfilter.cpp @@ -35,15 +35,15 @@ bool GlobalShortcutFilter::nativeEventFilter(const QByteArray& eventType, // Show screenshots history if (VK_SNAPSHOT == keycode && MOD_SHIFT == modifiers) { Flameshot::instance()->history(); + return true; } #endif // Capture screen if (VK_SNAPSHOT == keycode && 0 == modifiers) { Flameshot::instance()->requestCapture( CaptureRequest(CaptureRequest::GRAPHICAL_MODE)); + return true; } - - return true; } - return false; + return false; // Forward event to Qt } diff --git a/src/core/globalshortcutfilter.h b/src/core/globalshortcutfilter.h index e6dbc9dedb..0282ed64c2 100644 --- a/src/core/globalshortcutfilter.h +++ b/src/core/globalshortcutfilter.h @@ -18,9 +18,6 @@ class GlobalShortcutFilter void* message, qintptr* result); -signals: - void printPressed(); - private: quint32 getNativeModifier(Qt::KeyboardModifiers modifiers); quint32 nativeKeycode(Qt::Key key); diff --git a/src/utils/confighandler.cpp b/src/utils/confighandler.cpp index 3569735f6e..6fa87095d8 100644 --- a/src/utils/confighandler.cpp +++ b/src/utils/confighandler.cpp @@ -136,6 +136,10 @@ static QMap> OPTION("jpegQuality" , BoundedInt ( 0,100,75 )), OPTION("reverseArrow" ,Bool ( false )), OPTION("insecurePixelate" ,Bool ( false )), +#if defined(Q_OS_WIN) + // Not visible on settings dialog + OPTION("ignorePrntScrForcesSnipping" ,Bool ( false )), +#endif }; static QMap> recognizedShortcuts = { @@ -180,6 +184,9 @@ static QMap> recognizedShortcuts = { SHORTCUT("TYPE_MOVE_UP" , "Up" ), SHORTCUT("TYPE_MOVE_DOWN" , "Down" ), SHORTCUT("TYPE_COMMIT_CURRENT_TOOL" , "Ctrl+Return" ), +#if defined(Q_OS_WIN) + SHORTCUT("TAKE_SCREENSHOT" , "Meta+Shift+x" ), +#endif #if defined(Q_OS_MACOS) SHORTCUT("TYPE_DELETE_CURRENT_TOOL" , "Backspace" ), SHORTCUT("TAKE_SCREENSHOT" , "Ctrl+Shift+X" ), diff --git a/src/utils/confighandler.h b/src/utils/confighandler.h index 5387642af3..a66e30c422 100644 --- a/src/utils/confighandler.h +++ b/src/utils/confighandler.h @@ -139,6 +139,11 @@ class ConfigHandler : public QObject CONFIG_GETTER_SETTER(showSelectionGeometryHideTime, showSelectionGeometryHideTime, int) +#if defined(Q_OS_WIN) + CONFIG_GETTER_SETTER(ignorePrntScrForcesSnipping, + setIgnorePrntScrForcesSnipping, + bool) +#endif // SPECIAL CASES bool startupLaunch(); diff --git a/src/utils/screenshotsaver.cpp b/src/utils/screenshotsaver.cpp index 14715228dd..1b1cbf8262 100644 --- a/src/utils/screenshotsaver.cpp +++ b/src/utils/screenshotsaver.cpp @@ -207,7 +207,7 @@ void saveToClipboard(const QPixmap& capture) AbstractLogger() << QObject::tr("Capture saved to clipboard."); } if (ConfigHandler().useJpgForClipboard()) { -#ifdef Q_OS_MAC +#ifdef Q_OS_MACOS saveJpegToClipboardMacOS(capture); #else saveToClipboardMime(capture, "jpeg"); @@ -374,4 +374,4 @@ bool saveToFilesystemGUI(const QPixmap& capture) } return okay; -} \ No newline at end of file +} From 3eb366e038838931bc98f66794e23339f467ed47 Mon Sep 17 00:00:00 2001 From: Eric Blanquer Date: Sat, 14 Mar 2026 20:34:36 +0100 Subject: [PATCH 2/2] Hide monitor selection in launcher when only one screen is connected and make launcher UI more compact (#4569) --- src/widgets/capturelauncher.cpp | 10 ++++++++++ src/widgets/capturelauncher.ui | 12 ++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/widgets/capturelauncher.cpp b/src/widgets/capturelauncher.cpp index 91794caa2a..5fdc5c6283 100644 --- a/src/widgets/capturelauncher.cpp +++ b/src/widgets/capturelauncher.cpp @@ -62,6 +62,11 @@ CaptureLauncher::CaptureLauncher(QDialog* parent) #ifdef Q_OS_MACOS ui->monitorLabel->setVisible(false); ui->monitorSelection->setVisible(false); +#else + if (screens.size() <= 1) { + ui->monitorLabel->setVisible(false); + ui->monitorSelection->setVisible(false); + } #endif ui->delayTime->setSpecialValueText(tr("No Delay")); @@ -119,6 +124,11 @@ CaptureLauncher::CaptureLauncher(QDialog* parent) ui->screenshotWidth->setText(QString::number(lastRegion.width())); ui->screenshotHeight->setText(QString::number(lastRegion.height())); + ui->screenshotWidth->setMaximumWidth(70); + ui->screenshotHeight->setMaximumWidth(70); + ui->screenshotX->setMaximumWidth(70); + ui->screenshotY->setMaximumWidth(70); + adjustSize(); show(); // Call show() first, otherwise the correct geometry cannot be fetched // for centering the window on the screen diff --git a/src/widgets/capturelauncher.ui b/src/widgets/capturelauncher.ui index 1995d56806..cc97bc8049 100644 --- a/src/widgets/capturelauncher.ui +++ b/src/widgets/capturelauncher.ui @@ -6,16 +6,21 @@ 0 0 - 452 - 250 + 0 + 0 Capture Launcher + 4 + 4 + 4 + 4 + 4 @@ -45,6 +50,9 @@ + + QComboBox::SizeAdjustPolicy::AdjustToContents +