From de11a36967403d7d1a5658e7441120a0be0f1392 Mon Sep 17 00:00:00 2001 From: Anwarul Islam Date: Sun, 11 May 2025 03:08:09 +0600 Subject: [PATCH 1/8] refactor: move general configuration tab to ConfigWindow first (#3655) --- src/config/configwindow.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/config/configwindow.cpp b/src/config/configwindow.cpp index 0bae50f681..91b7ded407 100644 --- a/src/config/configwindow.cpp +++ b/src/config/configwindow.cpp @@ -49,6 +49,15 @@ ConfigWindow::ConfigWindow(QWidget* parent) QString modifier = isDark ? PathInfo::whiteIconPath() : PathInfo::blackIconPath(); + // general + m_generalConfig = new GeneralConf(); + m_generalConfigTab = new QWidget(); + auto* generalConfigLayout = new QVBoxLayout(m_generalConfigTab); + m_generalConfigTab->setLayout(generalConfigLayout); + generalConfigLayout->addWidget(m_generalConfig); + m_tabWidget->addTab( + m_generalConfigTab, QIcon(modifier + "config.svg"), tr("General")); + // visuals m_visuals = new VisualsEditor(); m_visualsTab = new QWidget(); @@ -68,14 +77,6 @@ ConfigWindow::ConfigWindow(QWidget* parent) QIcon(modifier + "name_edition.svg"), tr("Filename Editor")); - // general - m_generalConfig = new GeneralConf(); - m_generalConfigTab = new QWidget(); - auto* generalConfigLayout = new QVBoxLayout(m_generalConfigTab); - m_generalConfigTab->setLayout(generalConfigLayout); - generalConfigLayout->addWidget(m_generalConfig); - m_tabWidget->addTab( - m_generalConfigTab, QIcon(modifier + "config.svg"), tr("General")); // shortcuts m_shortcuts = new ShortcutsWidget(); From a293034a506645f2c61ca651c03f8fd99e112f97 Mon Sep 17 00:00:00 2001 From: j4k0xb <55899582+j4k0xb@users.noreply.github.com> Date: Sat, 10 May 2025 23:08:23 +0200 Subject: [PATCH 2/8] Add option to disable abort notification (#3610) --- flameshot.example.ini | 3 +++ src/config/generalconf.cpp | 19 +++++++++++++++++++ src/config/generalconf.h | 3 +++ src/main.cpp | 7 ++++++- src/utils/confighandler.cpp | 1 + src/utils/confighandler.h | 1 + 6 files changed, 33 insertions(+), 1 deletion(-) diff --git a/flameshot.example.ini b/flameshot.example.ini index 189f41f033..22cb4f276a 100644 --- a/flameshot.example.ini +++ b/flameshot.example.ini @@ -42,6 +42,9 @@ ;; Show desktop notifications (bool) ;showDesktopNotification=true ; +;; Show abort notifications (bool) +;showAbortNotification=true +; ;; Filename pattern using C++ strftime formatting ;filenamePattern=%F_%H-%M ; diff --git a/src/config/generalconf.cpp b/src/config/generalconf.cpp index 2e92f71379..9554d6b74f 100644 --- a/src/config/generalconf.cpp +++ b/src/config/generalconf.cpp @@ -38,6 +38,7 @@ GeneralConf::GeneralConf(QWidget* parent) #endif initShowTrayIcon(); initShowDesktopNotification(); + initShowAbortNotification(); #if !defined(DISABLE_UPDATE_CHECKER) initCheckForUpdates(); #endif @@ -77,6 +78,7 @@ void GeneralConf::_updateComponents(bool allowEmptySavePath) m_helpMessage->setChecked(config.showHelp()); m_sidePanelButton->setChecked(config.showSidePanelButton()); m_sysNotifications->setChecked(config.showDesktopNotification()); + m_abortNotifications->setChecked(config.showAbortNotification()); m_autostart->setChecked(config.startupLaunch()); m_copyURLAfterUpload->setChecked(config.copyURLAfterUpload()); m_saveAfterCopy->setChecked(config.saveAfterCopy()); @@ -140,6 +142,11 @@ void GeneralConf::showDesktopNotificationChanged(bool checked) ConfigHandler().setShowDesktopNotification(checked); } +void GeneralConf::showAbortNotificationChanged(bool checked) +{ + ConfigHandler().setShowAbortNotification(checked); +} + #if !defined(DISABLE_UPDATE_CHECKER) void GeneralConf::checkForUpdatesChanged(bool checked) { @@ -292,6 +299,18 @@ void GeneralConf::initShowDesktopNotification() &GeneralConf::showDesktopNotificationChanged); } +void GeneralConf::initShowAbortNotification() +{ + m_abortNotifications = new QCheckBox(tr("Show abort notifications"), this); + m_abortNotifications->setToolTip(tr("Enable abort notifications")); + m_scrollAreaLayout->addWidget(m_abortNotifications); + + connect(m_abortNotifications, + &QCheckBox::clicked, + this, + &GeneralConf::showAbortNotificationChanged); +} + void GeneralConf::initShowTrayIcon() { #if defined(Q_OS_LINUX) || defined(Q_OS_UNIX) diff --git a/src/config/generalconf.h b/src/config/generalconf.h index 6b6b2f34e0..3f76a76c05 100644 --- a/src/config/generalconf.h +++ b/src/config/generalconf.h @@ -37,6 +37,7 @@ private slots: void saveLastRegion(bool checked); void showSidePanelButtonChanged(bool checked); void showDesktopNotificationChanged(bool checked); + void showAbortNotificationChanged(bool checked); #if !defined(DISABLE_UPDATE_CHECKER) void checkForUpdatesChanged(bool checked); #endif @@ -78,6 +79,7 @@ private slots: void initSaveAfterCopy(); void initScrollArea(); void initShowDesktopNotification(); + void initShowAbortNotification(); void initShowHelp(); void initShowMagnifier(); void initShowQuitPrompt(); @@ -101,6 +103,7 @@ private slots: QVBoxLayout* m_scrollAreaLayout; QScrollArea* m_scrollArea; QCheckBox* m_sysNotifications; + QCheckBox* m_abortNotifications; QCheckBox* m_showTray; QCheckBox* m_helpMessage; QCheckBox* m_sidePanelButton; diff --git a/src/main.cpp b/src/main.cpp index 80ffb31dc7..5e8766fa09 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -63,7 +63,12 @@ int requestCaptureAndWait(const CaptureRequest& req) #endif }); QObject::connect(flameshot, &Flameshot::captureFailed, []() { - AbstractLogger::info() << "Screenshot aborted."; + AbstractLogger::Target logTarget = static_cast( + ConfigHandler().showAbortNotification() + ? AbstractLogger::Target::Default + : AbstractLogger::Target::Default & + ~AbstractLogger::Target::Notification); + AbstractLogger::info(logTarget) << "Screenshot aborted."; qApp->exit(1); }); return qApp->exec(); diff --git a/src/utils/confighandler.cpp b/src/utils/confighandler.cpp index 3fbfef6783..6307fcd9cb 100644 --- a/src/utils/confighandler.cpp +++ b/src/utils/confighandler.cpp @@ -77,6 +77,7 @@ static QMap> OPTION("showHelp" ,Bool ( true )), OPTION("showSidePanelButton" ,Bool ( true )), OPTION("showDesktopNotification" ,Bool ( true )), + OPTION("showAbortNotification" ,Bool ( true )), OPTION("disabledTrayIcon" ,Bool ( false )), OPTION("disabledGrimWarning" ,Bool ( false )), OPTION("historyConfirmationToDelete" ,Bool ( true )), diff --git a/src/utils/confighandler.h b/src/utils/confighandler.h index af33e221d0..76bfd71062 100644 --- a/src/utils/confighandler.h +++ b/src/utils/confighandler.h @@ -86,6 +86,7 @@ class ConfigHandler : public QObject CONFIG_GETTER_SETTER(showDesktopNotification, setShowDesktopNotification, bool) + CONFIG_GETTER_SETTER(showAbortNotification, setShowAbortNotification, bool) CONFIG_GETTER_SETTER(filenamePattern, setFilenamePattern, QString) CONFIG_GETTER_SETTER(disabledTrayIcon, setDisabledTrayIcon, bool) CONFIG_GETTER_SETTER(disabledGrimWarning, disabledGrimWarning, bool) From 7b25e467f073dbeca3f3f82454f869a821fbf3a6 Mon Sep 17 00:00:00 2001 From: insuna Date: Sat, 10 May 2025 23:42:42 +0200 Subject: [PATCH 3/8] Don't initialize Notifications dbus if disabled (#3598) --- src/utils/systemnotification.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/utils/systemnotification.cpp b/src/utils/systemnotification.cpp index 903bf4cdac..d4bf8e4e1e 100644 --- a/src/utils/systemnotification.cpp +++ b/src/utils/systemnotification.cpp @@ -24,6 +24,9 @@ SystemNotification::SystemNotification(QObject* parent) , m_interface(nullptr) { #if !(defined(Q_OS_MACOS) || defined(Q_OS_WIN)) + if (!ConfigHandler().showDesktopNotification()) { + return; + } m_interface = new QDBusInterface(QStringLiteral("org.freedesktop.Notifications"), QStringLiteral("/org/freedesktop/Notifications"), From f7923936f216c956b33acf18840ddfdb8fa23103 Mon Sep 17 00:00:00 2001 From: borgmanJeremy <46930769+borgmanJeremy@users.noreply.github.com> Date: Sat, 10 May 2025 17:21:08 -0500 Subject: [PATCH 4/8] fix clang-format for another PR (#3931) --- src/config/configwindow.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/config/configwindow.cpp b/src/config/configwindow.cpp index 91b7ded407..fecde7b9c1 100644 --- a/src/config/configwindow.cpp +++ b/src/config/configwindow.cpp @@ -77,7 +77,6 @@ ConfigWindow::ConfigWindow(QWidget* parent) QIcon(modifier + "name_edition.svg"), tr("Filename Editor")); - // shortcuts m_shortcuts = new ShortcutsWidget(); m_shortcutsTab = new QWidget(); From 6499b510c84b6411e8f5178b8f62b6d3c3c0b557 Mon Sep 17 00:00:00 2001 From: borgmanJeremy <46930769+borgmanJeremy@users.noreply.github.com> Date: Sat, 10 May 2025 17:44:32 -0500 Subject: [PATCH 5/8] Upgrade fedora CI to 41 and 42 (#3932) --- .github/workflows/Linux-pack.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/Linux-pack.yml b/.github/workflows/Linux-pack.yml index 63bd6c17b0..c645dc2152 100644 --- a/.github/workflows/Linux-pack.yml +++ b/.github/workflows/Linux-pack.yml @@ -163,15 +163,15 @@ jobs: matrix: dist: - { - name: fedora-40, + name: fedora-41, os: fedora, - symbol: 40, + symbol: 41, arch: x86_64 } - { - name: fedora-41, + name: fedora-42, os: fedora, - symbol: 41, + symbol: 42, arch: x86_64 } - { From b801ada623f4c2c3eb90124835f9bafb234668b6 Mon Sep 17 00:00:00 2001 From: SFBB Date: Sun, 11 May 2025 08:00:48 +0800 Subject: [PATCH 6/8] Fix issue #564, that in wayland fractional scaling situtation, screenshot preview size is wrong. (#3869) * fix screenshot's size not match with the screen when applying fractional scaling in KDE plasma desktop in wayland. * Fix: Really fix wayland dpr is not correct and that causes our screenshot preview is wrongly scaled issue. This fix supports that we will use dpr in xcb platform because it is correct in that case. * Chore: Use more concise variable names. Add comments to explain context. * Chore: Fix a typo(physcal -> physical). Change code style to meet the .clang-format requirement. --- src/utils/screengrabber.cpp | 38 +++++++++++++++++++++++++++++++++++-- src/utils/screengrabber.h | 1 + 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/utils/screengrabber.cpp b/src/utils/screengrabber.cpp index a9b7c59b2e..baf2d630b4 100644 --- a/src/utils/screengrabber.cpp +++ b/src/utils/screengrabber.cpp @@ -80,13 +80,36 @@ void ScreenGrabber::freeDesktopPortal(bool& ok, QPixmap& res) this); QEventLoop loop; - const auto gotSignal = [&res, &loop](uint status, const QVariantMap& map) { + const auto gotSignal = [&res, &loop, this](uint status, + const QVariantMap& map) { if (status == 0) { // Parse this as URI to handle unicode properly QUrl uri = map.value("uri").toString(); QString uriString = uri.toLocalFile(); res = QPixmap(uriString); - res.setDevicePixelRatio(qApp->devicePixelRatio()); + + // we calculate an approximated physical desktop geometry based on + // dpr(provided by qt), we calculate the logical desktop geometry + // later, this is the accurate size, more info: + // https://bugreports.qt.io/browse/QTBUG-135612 + QRect approxPhysGeo = desktopGeometry(); + QRect logicalGeo = logicalDesktopGeometry(); + if (res.size() == + approxPhysGeo.size()) // which means the res is physical size + // and the dpr is correct. + { + res.setDevicePixelRatio(qApp->devicePixelRatio()); + } else if (res.size() == + logicalGeo.size()) // which means the res is logical size + // and we need to do nothing. + { + // No action needed + } else // which means the res is physical size and the dpr is not + // correct. + { + res.setDevicePixelRatio(res.height() * 1.0f / + logicalGeo.height()); + } QFile imgFile(uriString); imgFile.remove(); } @@ -248,3 +271,14 @@ QRect ScreenGrabber::desktopGeometry() } return geometry; } + +QRect ScreenGrabber::logicalDesktopGeometry() +{ + QRect geometry; + for (QScreen* const screen : QGuiApplication::screens()) { + QRect scrRect = screen->geometry(); + scrRect.moveTo(scrRect.x(), scrRect.y()); + geometry = geometry.united(scrRect); + } + return geometry; +} diff --git a/src/utils/screengrabber.h b/src/utils/screengrabber.h index 39be6d5ac2..c1e6eebdd9 100644 --- a/src/utils/screengrabber.h +++ b/src/utils/screengrabber.h @@ -18,6 +18,7 @@ class ScreenGrabber : public QObject void freeDesktopPortal(bool& ok, QPixmap& res); void generalGrimScreenshot(bool& ok, QPixmap& res); QRect desktopGeometry(); + QRect logicalDesktopGeometry(); private: DesktopInfo m_info; From 7346d5bfe724437069769a482a7867b584fc137c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Mu=C5=82a?= Date: Sun, 11 May 2025 03:02:16 +0200 Subject: [PATCH 7/8] Add Fluxbox configuration snippet (#3796) --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index baf450ed47..a9a800f39a 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ - [On KDE Plasma desktop](#on-kde-plasma-desktop) - [On Ubuntu](#on-ubuntu-tested-on-1804-2004-2204) - [On XFCE 4](#on-xfce-4) + - [On Fluxbox](#on-fluxbox) - [Considerations](#considerations) - [Installation](#installation) - [Prebuilt Packages](#prebuilt-packages) @@ -311,6 +312,16 @@ Now every time you press Prt Sc, it will start the Flameshot GUI inst Now every time you press Prt Sc it will start Flameshot GUI instead of the default application. +#### On Fluxbox + +1. Edit your `~/.fluxbox/keys` file +2. Add a new entry. `Print` is the key name, `flameshot gui` is the shell command; for more options see [the fluxbox wiki](https://sillyslux.github.io/fluxbox-wiki/en/wiki/Keyboard-Shortcuts/). + + ```text + Print :Exec flameshot gui + ```` +3. Refresh Fluxbox configuration with **Reconfigure** option from the menu. + ## Considerations - Experimental Gnome Wayland and Plasma Wayland support. From 90fd5fcb2e97527c3d10bd05087628870da0b3e7 Mon Sep 17 00:00:00 2001 From: Daniel Fox Date: Sat, 10 May 2025 18:07:12 -0700 Subject: [PATCH 8/8] Remove QT+GNOME+Wayland 'xcb' hack on fixed Qt versions (#3683) * Bypass the Qt GNOME/Wayland workaround on fixed Qt versions We implement code on GNOME desktops to force the QT_QPA_PLATFORM to be 'xcb'; this works around a clipboard-related bug on GNOME+Wayland+Qt. This bug was fixed (or worked around) in Qt 5.15.2, so we implement a version check; if the runtime Qt version is < 5.15.2, still force the workaround; otherwise, we don't need the workaround so we skip it. * Reformat with clang-format --- src/main.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 5e8766fa09..e7c1675fee 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -37,10 +37,28 @@ // source: https://github.com/ksnip/ksnip/issues/416 void wayland_hacks() { - // Workaround to https://github.com/ksnip/ksnip/issues/416 + int suffixIndex; DesktopInfo info; - if (info.windowManager() == DesktopInfo::GNOME) { - qputenv("QT_QPA_PLATFORM", "xcb"); + + const char* qt_version = qVersion(); + + QVersionNumber targetVersion(5, 15, 2); + QString string(qt_version); + QVersionNumber currentVersion = + QVersionNumber::fromString(string, &suffixIndex); + + if (currentVersion < targetVersion) { + if (info.windowManager() == DesktopInfo::GNOME) { + qWarning() + << "Qt versions lower than" << targetVersion.toString() + << "on GNOME using Wayland have a bug when accessing the " + "clipboard." + << "Your version is" << currentVersion.toString() + << "so we're forcing QT_QPA_PLATFORM to 'xcb'." + << "To use native Wayland, please upgrade your Qt version to" + << targetVersion.toString() << "or higher"; + qputenv("QT_QPA_PLATFORM", "xcb"); + } } } #endif