* screengrabber: pass non-empty parent_window to xdg-desktop-portal
xdg-desktop-portal-gnome on GNOME 46 rejects requests where the
parent_window argument is an empty string with the error
"Failed to associate portal window with parent window ''",
which made daemon-mode (tray icon, DBus captureScreen) capture
fail for all GNOME Wayland users.
Allocate an offscreen QWidget (Qt::WA_DontShowOnScreen) so a
winId is generated, and pass "x11:<hex>" on X11 sessions or
"wayland:" on Wayland. Both are accepted by xdg-desktop-portal
as valid no-real-parent handles, while remaining non-empty as
the portal spec requires.
Tested on: Ubuntu 24.04, GNOME 46 Wayland, NVIDIA proprietary
590.48.01, Qt 6.4.2, xdg-desktop-portal-gnome 46.2.
Fixes daemon-mode capture on GNOME 46 Wayland.
* clang format
---------
Co-authored-by: Jeremy Borgman <borgman.jeremy@pm.me>
macOS showFullScreen() triggers a native fullscreen space transition
animation when capturing. Replace with show() using FramelessWindowHint,
WindowStaysOnTopHint, and Qt::Tool flags to avoid the animation.
Add a 'useNativeFullscreen' config option (default: off) so users who
prefer the native fullscreen behavior can re-enable it from
Settings > General.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
On macOS with LSUIElement=true, Flameshot runs as an agent app (no dock
icon). This adds a dock icon that appears while any user-facing window
(Settings, About, Launcher, Upload History) is visible and disappears
when the last one is closed or hidden.
Uses QWindow::visibilityChanged signal with a per-window dynamic property
to track visibility state and a reference counter for the activation
policy toggle.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: borgmanJeremy <46930769+borgmanJeremy@users.noreply.github.com>
The clipboard copy from tray menu and capture GUI was broken on macOS:
1. FlameshotDaemon::copyToClipboard() created a KDSingleApplication
instance and called isPrimaryInstance(), which always returned false
(the daemon already holds the socket). This caused a 3-second IPC
timeout before falling back. Fix: use instance() to check if the
daemon singleton exists in-process, matching non-macOS behavior.
2. saveToClipboardMime() used setData("image/...") which puts a lazy
reference on the macOS pasteboard. If the app exits before paste,
data is lost ("Cannot keep promise"). Fix: use setImageData() for
native pasteboard persistence, plus setData() for exact format.
3. saveJpegToClipboardMacOS() used osascript with a temp file and
incorrectly labeled JPEG data as PNG UTI. Removed entirely — the
fixed saveToClipboardMime() now handles both JPEG and PNG.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The widget's layout is set in the member initializer list (line 25)
via m_layout(new QVBoxLayout(this)). Passing 'this' to the QHBoxLayout
constructor at line 84 tries to set a second layout on the same widget,
which Qt rejects with a warning on every capture:
QLayout: Attempting to add QLayout "" to SidePanelWidget "",
which already has a layout
The parent argument is unnecessary since the layout is added to
m_layout via addLayout() at line 94.
Co-authored-by: Benigno Batista Júnior <benigno@opus-software.com.br>
* 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
* Option to build a portable binary, which is using flameshot.ini in application folder.
* Align Qt version
* Fix appveyor
* Fix appveyor
* Fix appveyor
When compiled with USE_WAYLAND_CLIPBOARD, the clipboard now works
correctly on both Wayland and X11 sessions.
Previously, builds with USE_WAYLAND_CLIPBOARD=ON would always use
KSystemClipboard, which doesn't work properly when running under X11
(e.g., via XWayland or QT_QPA_PLATFORM=xcb).
This change adds a runtime check for the platform name:
- 'wayland' -> uses KSystemClipboard (KF6 GuiAddons)
- otherwise -> uses QApplication::clipboard() (standard Qt)
This allows distros to ship a single binary that works on both
display servers without requiring separate builds.
Co-authored-by: Benigno Batista Júnior <benigno@opus-software.com.br>
* Rework capture system to only enter fullscreen widget on one monitor
* Sort monitor previews by screen position instead of Qt index (#4522)
The monitor selection dialog displayed monitors in Qt's default
screen order (by connector name, e.g. DP-1 before DP-2), which
can differ from the physical arrangement configured in the display
settings. This sorts the preview widgets by their X geometry
position so they match the user's actual left-to-right layout.
---------
Co-authored-by: Brian J. Cohen <brianjcohen@gmail.com>
On Wayland, the backing store may not be ready when paintEvent is called,
causing QPainter to fail with 'Paint device returned engine == 0'.
This adds isActive() checks to prevent crashes when the painter
cannot be initialized.
Fixes crashes on KDE Plasma Wayland with Qt 6.
* Fix copy failure on GNOME
My suspicion is that GNOME and specifically Mutter requires specific trusted context for the QtClipboard (from 'kf.guiaddons: Could not init WaylandClipboard, falling back to QtClipboard.') clipboard operation. This means that a visible window must provide the clipboard data. Since the daemon has no visible window, this is a workaround that makes the 'flameshot gui' window handle the copying with a slight delay using QTimer to ensure that GNOME has requested the clipboard data and saved it.
This seems like a better solution #4355 as no helper windows are needed, since we already have the 'flameshot gui' window and can use it. I've limited it to GNOME only as I cannot easily test in other environments.
Fixes#4116, #4298
* Keep capture window alive until GNOME fetches clipboard data
* Move the GNOME clipboard workaround in screenshotsaver.cpp
* Log GNOME clipboard timeout and restore success notification
* Apply linter fixes
(or equivelent directories on windows/mac-os)
By default logging to file is enabled for all log messages.
Filtering log messages written to disk by level severity and choosing a
different path to save the log files is configurable via the config menu.
There is also a shortcut on the about menu popup to open the configured
logging directory. This shortcut is disabled if logging to file is
disabled
The log file implements a simple roller that saves only the two most
recent sets of logs generated by flameshot. This should stop log
messages from eating users' disk.
We use cmake to check the version of QT6. If greater than or equal to
6.7, we set the default log directory to the standard App State
directory. If not, we use the app local data directory
Issue #4353
Add a check when looking up the `org.freedesktop.Notifications` service
to see if the it actually exists before trying to fetch it
Add a check on QDBus service lookup in screengrabber freedesktop
* Fix multiple memory leaks in Region::process() function
- Add proper cleanup for allocated QApplication object
- Add proper cleanup for allocated char** argv array
- Add proper cleanup for allocated int* argc pointer
- Ensure all return paths properly clean up allocated memory
- Prevents memory leaks when Region::process() is called
Fixes multiple memory leaks identified in codebase analysis.
* Apply clang-format to fix code style compliance
- Remove trailing whitespace
- Normalize line endings
- Ensure compliance with project's clang-format rules
Fixes CI test-clang-format workflow failure.
* Refactor cleanup logic in Region::process
Introduced a cleanup lambda to handle memory deallocation in Region::process, replacing repeated code with a single reusable function for better maintainability and readability.
* Format cleanup lambda for readability
Reformatted the cleanup lambda in Region::process for improved readability by expanding it to multiple lines.
* Refactor Region::process to use smart pointers
Replaces manual memory management with std::unique_ptr for temporary QApplication and argument variables. Removes redundant cleanup logic for improved safety and readability.
* chore: fix typo in comment in GlobalShortcutFilter
* chore: fix typos in comments and function names
- Fix 'temporal workwrround' to 'temporary workaround' in GlobalShortcutFilter
- Fix 'habdler' to 'handler' in ButtonHandler comment
- Fix 'the the' to 'to the' in ButtonHandler comment
- Fix 'minimun' to 'minimum' in ButtonHandler function name
---------
Co-authored-by: Aman Chaturvedi <aman.chaturvedi@kpit.com>