Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/Linux-pack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
- {
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -311,6 +312,16 @@ Now every time you press <kbd>Prt Sc</kbd>, it will start the Flameshot GUI inst

Now every time you press <kbd>Prt Sc</kbd> 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.
Expand Down
3 changes: 3 additions & 0 deletions flameshot.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
;
Expand Down
18 changes: 9 additions & 9 deletions src/config/configwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -68,15 +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();
m_shortcutsTab = new QWidget();
Expand Down
19 changes: 19 additions & 0 deletions src/config/generalconf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ GeneralConf::GeneralConf(QWidget* parent)
#endif
initShowTrayIcon();
initShowDesktopNotification();
initShowAbortNotification();
#if !defined(DISABLE_UPDATE_CHECKER)
initCheckForUpdates();
#endif
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions src/config/generalconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -78,6 +79,7 @@ private slots:
void initSaveAfterCopy();
void initScrollArea();
void initShowDesktopNotification();
void initShowAbortNotification();
void initShowHelp();
void initShowMagnifier();
void initShowQuitPrompt();
Expand All @@ -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;
Expand Down
31 changes: 27 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -63,7 +81,12 @@ int requestCaptureAndWait(const CaptureRequest& req)
#endif
});
QObject::connect(flameshot, &Flameshot::captureFailed, []() {
AbstractLogger::info() << "Screenshot aborted.";
AbstractLogger::Target logTarget = static_cast<AbstractLogger::Target>(
ConfigHandler().showAbortNotification()
? AbstractLogger::Target::Default
: AbstractLogger::Target::Default &
~AbstractLogger::Target::Notification);
AbstractLogger::info(logTarget) << "Screenshot aborted.";
qApp->exit(1);
});
return qApp->exec();
Expand Down
1 change: 1 addition & 0 deletions src/utils/confighandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ static QMap<class QString, QSharedPointer<ValueHandler>>
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 )),
Expand Down
1 change: 1 addition & 0 deletions src/utils/confighandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
38 changes: 36 additions & 2 deletions src/utils/screengrabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions src/utils/screengrabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/utils/systemnotification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Loading