diff --git a/CMakeLists.txt b/CMakeLists.txt
index 14f014e3..8d91daed 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.13)
# cmake_policy(SET CMP0076 OLD)
-set(FLAMESHOT_VERSION 0.8.5.6)
+set(FLAMESHOT_VERSION 0.8.5)
# Flameshot-org
set(GIT_API_URL "https://api.github.com/repos/flameshot-org/flameshot/releases/latest")
diff --git a/README.md b/README.md
index 60afe623..d181a2d6 100644
--- a/README.md
+++ b/README.md
@@ -49,6 +49,7 @@
- [Features](#features)
- [Usage](#usage)
- [CLI configuration](#cli-configuration)
+ - [Config file](#config-file)
- [Keyboard Shortcuts](#keyboard-shortcuts)
- [Local](#local)
- [Global](#global)
@@ -161,6 +162,10 @@ You can use the graphical menu to configure Flameshot, but alternatively you can
flameshot config -h
```
+### Config file
+You can also edit some of the settings (like overriding the default colors) in the configuration file located at `~/.config/flameshot/flameshot.ini`.
+
+
## Keyboard shortcuts
### Local
diff --git a/data/dbus/org.flameshot.Flameshot.xml b/data/dbus/org.flameshot.Flameshot.xml
index 3a3beedc..2a922026 100644
--- a/data/dbus/org.flameshot.Flameshot.xml
+++ b/data/dbus/org.flameshot.Flameshot.xml
@@ -115,5 +115,17 @@
+
+
+
+
+
+
diff --git a/src/core/capturerequest.cpp b/src/core/capturerequest.cpp
index dfefac83..c8a560a1 100644
--- a/src/core/capturerequest.cpp
+++ b/src/core/capturerequest.cpp
@@ -85,9 +85,9 @@ void CaptureRequest::exportCapture(const QPixmap& p)
{
if ((m_tasks & ExportTask::FILESYSTEM_SAVE_TASK) != ExportTask::NO_TASK) {
if (m_path.isEmpty()) {
- ScreenshotSaver().saveToFilesystemGUI(p);
+ ScreenshotSaver(m_id).saveToFilesystemGUI(p);
} else {
- ScreenshotSaver().saveToFilesystem(p, m_path, "");
+ ScreenshotSaver(m_id).saveToFilesystem(p, m_path, "");
}
}
diff --git a/src/core/controller.cpp b/src/core/controller.cpp
index 8ff11829..7980c313 100644
--- a/src/core/controller.cpp
+++ b/src/core/controller.cpp
@@ -16,8 +16,8 @@
// along with Flameshot. If not, see .
#include "controller.h"
-#include "src/config/configwindow.h"
#include "external/QHotkey/QHotkey"
+#include "src/config/configwindow.h"
#include "src/utils/confighandler.h"
#include "src/utils/history.h"
#include "src/utils/screengrabber.h"
@@ -45,7 +45,7 @@
#include "src/core/globalshortcutfilter.h"
#endif
-#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
+#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
defined(Q_OS_MACX))
#include
#include
@@ -55,12 +55,15 @@
// launches the capture widget
Controller::Controller()
- : m_captureWindow(nullptr), m_history(nullptr), m_trayIconMenu(nullptr), m_networkCheckUpdates(nullptr),
- m_showCheckAppUpdateStatus(false)
-#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
+ : m_captureWindow(nullptr)
+ , m_history(nullptr)
+ , m_trayIconMenu(nullptr)
+ , m_networkCheckUpdates(nullptr)
+ , m_showCheckAppUpdateStatus(false)
+#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
defined(Q_OS_MACX))
-, m_HotkeyScreenshotCapture(nullptr)
-, m_HotkeyScreenshotHistory(nullptr)
+ , m_HotkeyScreenshotCapture(nullptr)
+ , m_HotkeyScreenshotHistory(nullptr)
#endif
{
m_appLatestVersion = QStringLiteral(APP_VERSION).replace("v", "");
@@ -87,7 +90,7 @@ Controller::Controller()
QString StyleSheet = CaptureButton::globalStyleSheet();
qApp->setStyleSheet(StyleSheet);
-#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
+#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
defined(Q_OS_MACX))
// Try to take a test screenshot, MacOS will request a "Screen Recording"
// permissions on the first run. Otherwise it will be hidden under the
@@ -112,24 +115,28 @@ Controller::Controller()
getLatestAvailableVersion();
}
-Controller::~Controller() {
+Controller::~Controller()
+{
delete m_history;
delete m_trayIconMenu;
}
-Controller *Controller::getInstance() {
+Controller* Controller::getInstance()
+{
static Controller c;
return &c;
}
-void Controller::enableExports() {
+void Controller::enableExports()
+{
connect(
- this, &Controller::captureTaken, this, &Controller::handleCaptureTaken);
+ this, &Controller::captureTaken, this, &Controller::handleCaptureTaken);
connect(
- this, &Controller::captureFailed, this, &Controller::handleCaptureFailed);
+ this, &Controller::captureFailed, this, &Controller::handleCaptureFailed);
}
-void Controller::getLatestAvailableVersion() {
+void Controller::getLatestAvailableVersion()
+{
// This features is required for MacOS and Windows user and for Linux users
// who installed Flameshot not from the repository.
m_networkCheckUpdates = new QNetworkAccessManager(this);
@@ -146,17 +153,18 @@ void Controller::getLatestAvailableVersion() {
});
}
-void Controller::handleReplyCheckUpdates(QNetworkReply *reply) {
+void Controller::handleReplyCheckUpdates(QNetworkReply* reply)
+{
if (reply->error() == QNetworkReply::NoError) {
QJsonDocument response = QJsonDocument::fromJson(reply->readAll());
QJsonObject json = response.object();
m_appLatestVersion = json["tag_name"].toString().replace("v", "");
if (QStringLiteral(APP_VERSION)
- .replace("v", "")
- .compare(m_appLatestVersion) < 0) {
+ .replace("v", "")
+ .compare(m_appLatestVersion) < 0) {
m_appLatestUrl = json["html_url"].toString();
QString newVersion =
- tr("New version %1 is available").arg(m_appLatestVersion);
+ tr("New version %1 is available").arg(m_appLatestVersion);
m_appUpdates->setText(newVersion);
if (m_showCheckAppUpdateStatus) {
sendTrayNotification(newVersion, "Flameshot");
@@ -171,14 +179,15 @@ void Controller::handleReplyCheckUpdates(QNetworkReply *reply) {
<< reply->errorString();
if (m_showCheckAppUpdateStatus) {
sendTrayNotification(
- tr("Failed to get information about the latest version."),
- "Flameshot");
+ tr("Failed to get information about the latest version."),
+ "Flameshot");
}
}
m_showCheckAppUpdateStatus = false;
}
-void Controller::appUpdates() {
+void Controller::appUpdates()
+{
if (m_appLatestUrl.isEmpty()) {
m_showCheckAppUpdateStatus = true;
getLatestAvailableVersion();
@@ -187,7 +196,8 @@ void Controller::appUpdates() {
}
}
-void Controller::requestCapture(const CaptureRequest &request) {
+void Controller::requestCapture(const CaptureRequest& request)
+{
uint id = request.id();
m_requestMap.insert(id, request);
@@ -197,17 +207,17 @@ void Controller::requestCapture(const CaptureRequest &request) {
this->startFullscreenCapture(id);
});
break;
- // TODO: Figure out the code path that gets here so the deprated warning
- // can be fixed
+ // TODO: Figure out the code path that gets here so the deprated
+ // warning can be fixed
case CaptureRequest::SCREEN_MODE: {
- int &&number = request.data().toInt();
+ int&& number = request.data().toInt();
doLater(request.delay(), this, [this, id, number]() {
this->startScreenGrab(id, number);
});
break;
}
case CaptureRequest::GRAPHICAL_MODE: {
- QString &&path = request.path();
+ QString&& path = request.path();
doLater(request.delay(), this, [this, id, path]() {
this->startVisualCapture(id, path);
});
@@ -221,9 +231,10 @@ void Controller::requestCapture(const CaptureRequest &request) {
// creation of a new capture in GUI mode
void Controller::startVisualCapture(const uint id,
- const QString &forcedSavePath) {
+ const QString& forcedSavePath)
+{
if (!m_captureWindow) {
- QWidget *modalWidget = nullptr;
+ QWidget* modalWidget = nullptr;
do {
modalWidget = qApp->activeModalWidget();
if (modalWidget) {
@@ -246,7 +257,7 @@ void Controller::startVisualCapture(const uint id,
#ifdef Q_OS_WIN
m_captureWindow->show();
-#elif (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
+#elif (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
defined(Q_OS_MACX))
// In "Emulate fullscreen mode"
m_captureWindow->showFullScreen();
@@ -254,11 +265,11 @@ void Controller::startVisualCapture(const uint id,
m_captureWindow->raise();
#else
m_captureWindow->showFullScreen();
- //m_captureWindow->show(); //Debug
+ // m_captureWindow->show(); //Debug
#endif
if (!m_appLatestUrl.isEmpty() &&
ConfigHandler().ignoreUpdateToVersion().compare(
- m_appLatestVersion) < 0) {
+ m_appLatestVersion) < 0) {
m_captureWindow->showAppUpdateNotification(m_appLatestVersion,
m_appLatestUrl);
}
@@ -267,7 +278,8 @@ void Controller::startVisualCapture(const uint id,
}
}
-void Controller::startScreenGrab(const uint id, const int screenNumber) {
+void Controller::startScreenGrab(const uint id, const int screenNumber)
+{
bool ok = true;
int n = screenNumber;
@@ -285,11 +297,12 @@ void Controller::startScreenGrab(const uint id, const int screenNumber) {
}
// creation of the configuration window
-void Controller::openConfigWindow() {
+void Controller::openConfigWindow()
+{
if (!m_configWindow) {
m_configWindow = new ConfigWindow();
m_configWindow->show();
-#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
+#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
defined(Q_OS_MACX))
m_configWindow->activateWindow();
m_configWindow->raise();
@@ -298,10 +311,11 @@ void Controller::openConfigWindow() {
}
// creation of the window of information
-void Controller::openInfoWindow() {
+void Controller::openInfoWindow()
+{
if (!m_infoWindow) {
m_infoWindow = new InfoWindow();
-#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
+#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
defined(Q_OS_MACX))
m_infoWindow->activateWindow();
m_infoWindow->raise();
@@ -309,51 +323,53 @@ void Controller::openInfoWindow() {
}
}
-void Controller::openLauncherWindow() {
+void Controller::openLauncherWindow()
+{
if (!m_launcherWindow) {
m_launcherWindow = new CaptureLauncher();
}
m_launcherWindow->show();
-#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
+#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
defined(Q_OS_MACX))
m_launcherWindow->activateWindow();
m_launcherWindow->raise();
#endif
}
-void Controller::enableTrayIcon() {
+void Controller::enableTrayIcon()
+{
if (m_trayIcon) {
return;
}
m_trayIconMenu = new QMenu();
ConfigHandler().setDisabledTrayIcon(false);
- QAction *captureAction = new QAction(tr("&Take Screenshot"), this);
+ QAction* captureAction = new QAction(tr("&Take Screenshot"), this);
connect(captureAction, &QAction::triggered, this, [this]() {
// Wait 400 ms to hide the QMenu
doLater(400, this, [this]() { this->startVisualCapture(); });
});
- QAction *launcherAction = new QAction(tr("&Open Launcher"), this);
+ QAction* launcherAction = new QAction(tr("&Open Launcher"), this);
connect(launcherAction,
&QAction::triggered,
this,
&Controller::openLauncherWindow);
- QAction *configAction = new QAction(tr("&Configuration"), this);
+ QAction* configAction = new QAction(tr("&Configuration"), this);
connect(
- configAction, &QAction::triggered, this, &Controller::openConfigWindow);
- QAction *infoAction = new QAction(tr("&About"), this);
+ configAction, &QAction::triggered, this, &Controller::openConfigWindow);
+ QAction* infoAction = new QAction(tr("&About"), this);
connect(infoAction, &QAction::triggered, this, &Controller::openInfoWindow);
m_appUpdates = new QAction(tr("Check for updates"), this);
connect(m_appUpdates, &QAction::triggered, this, &Controller::appUpdates);
- QAction *quitAction = new QAction(tr("&Quit"), this);
+ QAction* quitAction = new QAction(tr("&Quit"), this);
connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit);
// recent screenshots
- QAction *recentAction = new QAction(tr("&Latest Uploads"), this);
+ QAction* recentAction = new QAction(tr("&Latest Uploads"), this);
connect(
- recentAction, SIGNAL(triggered()), this, SLOT(showRecentScreenshots()));
+ recentAction, SIGNAL(triggered()), this, SLOT(showRecentScreenshots()));
// generate menu
m_trayIconMenu->addAction(captureAction);
@@ -370,7 +386,7 @@ void Controller::enableTrayIcon() {
m_trayIcon = new QSystemTrayIcon();
m_trayIcon->setToolTip(QStringLiteral("Flameshot"));
-#if defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
+#if defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
defined(Q_OS_MACX)
// Because of the following issues on MacOS "Catalina":
// https://bugreports.qt.io/browse/QTBUG-86393
@@ -383,10 +399,10 @@ void Controller::enableTrayIcon() {
m_trayIcon->setContextMenu(m_trayIconMenu);
#endif
QIcon trayicon =
- QIcon::fromTheme("flameshot-tray", QIcon(":img/app/flameshot.png"));
+ QIcon::fromTheme("flameshot-tray", QIcon(":img/app/flameshot.png"));
m_trayIcon->setIcon(trayicon);
-#if defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
+#if defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
defined(Q_OS_MACX)
if (currentMacOsVersion < currentMacOsVersion.MacOSBigSur) {
// Because of the following issues on MacOS "Catalina":
@@ -420,7 +436,8 @@ void Controller::enableTrayIcon() {
m_trayIcon->show();
}
-void Controller::disableTrayIcon() {
+void Controller::disableTrayIcon()
+{
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
if (m_trayIcon) {
m_trayIcon->deleteLater();
@@ -429,22 +446,25 @@ void Controller::disableTrayIcon() {
#endif
}
-void Controller::sendTrayNotification(const QString &text,
- const QString &title,
- const int timeout) {
+void Controller::sendTrayNotification(const QString& text,
+ const QString& title,
+ const int timeout)
+{
if (m_trayIcon) {
m_trayIcon->showMessage(
- title, text, QIcon(":img/app/flameshot.svg"), timeout);
+ title, text, QIcon(":img/app/flameshot.svg"), timeout);
}
}
-void Controller::updateConfigComponents() {
+void Controller::updateConfigComponents()
+{
if (m_configWindow) {
m_configWindow->updateChildren();
}
}
-void Controller::updateRecentScreenshots() {
+void Controller::updateRecentScreenshots()
+{
if (nullptr != m_history) {
if (m_history->isVisible()) {
m_history->loadHistory();
@@ -452,20 +472,27 @@ void Controller::updateRecentScreenshots() {
}
}
-void Controller::showRecentScreenshots() {
+void Controller::showRecentScreenshots()
+{
if (nullptr == m_history) {
m_history = new HistoryWidget();
}
m_history->loadHistory();
m_history->show();
-#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
+#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
defined(Q_OS_MACX))
m_history->activateWindow();
m_history->raise();
#endif
}
-void Controller::startFullscreenCapture(const uint id) {
+void Controller::sendCaptureSaved(uint id, const QString& savePath)
+{
+ emit captureSaved(id, savePath);
+}
+
+void Controller::startFullscreenCapture(const uint id)
+{
bool ok = true;
QPixmap p(ScreenGrabber().grabEntireDesktop(ok));
if (ok) {
@@ -476,7 +503,8 @@ void Controller::startFullscreenCapture(const uint id) {
}
}
-void Controller::handleCaptureTaken(uint id, QPixmap p, QRect selection) {
+void Controller::handleCaptureTaken(uint id, QPixmap p, QRect selection)
+{
auto it = m_requestMap.find(id);
if (it != m_requestMap.end()) {
it.value().exportCapture(p);
@@ -484,12 +512,14 @@ void Controller::handleCaptureTaken(uint id, QPixmap p, QRect selection) {
}
}
-void Controller::handleCaptureFailed(uint id) {
+void Controller::handleCaptureFailed(uint id)
+{
m_requestMap.remove(id);
}
-void Controller::doLater(int msec, QObject *receiver, lambda func) {
- QTimer *timer = new QTimer(receiver);
+void Controller::doLater(int msec, QObject* receiver, lambda func)
+{
+ QTimer* timer = new QTimer(receiver);
QObject::connect(timer, &QTimer::timeout, receiver, [timer, func]() {
func();
timer->deleteLater();
diff --git a/src/core/controller.h b/src/core/controller.h
index 8c7a4a84..73c4f217 100644
--- a/src/core/controller.h
+++ b/src/core/controller.h
@@ -57,6 +57,7 @@ public:
signals:
void captureTaken(uint id, QPixmap p, QRect selection);
void captureFailed(uint id);
+ void captureSaved(uint id, QString savePath);
public slots:
void requestCapture(const CaptureRequest& request);
@@ -76,6 +77,8 @@ public slots:
void showRecentScreenshots();
+ void sendCaptureSaved(uint id, const QString& savePath);
+
private slots:
void startFullscreenCapture(const uint id = 0);
void startVisualCapture(const uint id = 0,
diff --git a/src/core/flameshotdbusadapter.cpp b/src/core/flameshotdbusadapter.cpp
index 5bfb4f85..260ae9c1 100644
--- a/src/core/flameshotdbusadapter.cpp
+++ b/src/core/flameshotdbusadapter.cpp
@@ -34,6 +34,10 @@ FlameshotDBusAdapter::FlameshotDBusAdapter(QObject* parent)
&Controller::captureTaken,
this,
&FlameshotDBusAdapter::handleCaptureTaken);
+ connect(controller,
+ &Controller::captureSaved,
+ this,
+ &FlameshotDBusAdapter::captureSaved);
}
FlameshotDBusAdapter::~FlameshotDBusAdapter() {}
diff --git a/src/core/flameshotdbusadapter.h b/src/core/flameshotdbusadapter.h
index 46d522d6..ecd32944 100644
--- a/src/core/flameshotdbusadapter.h
+++ b/src/core/flameshotdbusadapter.h
@@ -32,6 +32,7 @@ public:
signals:
void captureTaken(uint id, QByteArray rawImage, QRect selection);
void captureFailed(uint id);
+ void captureSaved(uint id, QString savePath);
public slots:
Q_NOREPLY void graphicCapture(QString path, int delay, uint id);
diff --git a/src/utils/screenshotsaver.cpp b/src/utils/screenshotsaver.cpp
index a19dbdd2..95f8d3d3 100644
--- a/src/utils/screenshotsaver.cpp
+++ b/src/utils/screenshotsaver.cpp
@@ -16,6 +16,7 @@
// along with Flameshot. If not, see .
#include "screenshotsaver.h"
+#include "src/core/controller.h"
#include "src/utils/confighandler.h"
#include "src/utils/filenamehandler.h"
#include "src/utils/systemnotification.h"
@@ -25,7 +26,13 @@
#include
#include
-ScreenshotSaver::ScreenshotSaver() {}
+ScreenshotSaver::ScreenshotSaver()
+ : m_id(0)
+{}
+
+ScreenshotSaver::ScreenshotSaver(const unsigned id)
+ : m_id(id)
+{}
// TODO: If data is saved to the clipboard before the notification is sent via
// dbus, the application freezes.
@@ -63,6 +70,8 @@ bool ScreenshotSaver::saveToFilesystem(const QPixmap& capture,
ConfigHandler().setSavePath(path);
saveMessage =
messagePrefix + QObject::tr("Capture saved as ") + completePath;
+ Controller::getInstance()->sendCaptureSaved(
+ m_id, QFileInfo(completePath).canonicalFilePath());
} else {
saveMessage = messagePrefix + QObject::tr("Error trying to save as ") +
completePath;
@@ -112,6 +121,8 @@ bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap& capture)
savePath;
}
SystemNotification().sendMessage(msg, savePath);
+ Controller::getInstance()->sendCaptureSaved(
+ m_id, QFileInfo(savePath).canonicalFilePath());
} else {
QString msg = QObject::tr("Error trying to save as ") + savePath;
QMessageBox saveErrBox(
diff --git a/src/utils/screenshotsaver.h b/src/utils/screenshotsaver.h
index b528cbd7..7b40b787 100644
--- a/src/utils/screenshotsaver.h
+++ b/src/utils/screenshotsaver.h
@@ -24,10 +24,14 @@ class ScreenshotSaver
{
public:
ScreenshotSaver();
+ ScreenshotSaver(const unsigned id);
void saveToClipboard(const QPixmap& capture);
bool saveToFilesystem(const QPixmap& capture,
const QString& path,
const QString& messagePrefix);
bool saveToFilesystemGUI(const QPixmap& capture);
+
+private:
+ unsigned m_id;
};
diff --git a/src/widgets/capture/capturewidget.cpp b/src/widgets/capture/capturewidget.cpp
index 5961543f..95358896 100644
--- a/src/widgets/capture/capturewidget.cpp
+++ b/src/widgets/capture/capturewidget.cpp
@@ -1200,9 +1200,10 @@ void CaptureWidget::saveScreenshot()
}
hide();
if (m_context.savePath.isEmpty()) {
- ScreenshotSaver().saveToFilesystemGUI(pixmap());
+ ScreenshotSaver(m_id).saveToFilesystemGUI(pixmap());
} else {
- ScreenshotSaver().saveToFilesystem(pixmap(), m_context.savePath, "");
+ ScreenshotSaver(m_id).saveToFilesystem(
+ pixmap(), m_context.savePath, "");
}
close();
}
diff --git a/src/widgets/panel/utilitypanel.cpp b/src/widgets/panel/utilitypanel.cpp
index 43efe1e6..1068f906 100644
--- a/src/widgets/panel/utilitypanel.cpp
+++ b/src/widgets/panel/utilitypanel.cpp
@@ -23,8 +23,9 @@
#include
#include
-UtilityPanel::UtilityPanel(QWidget *parent)
- : QWidget(parent) {
+UtilityPanel::UtilityPanel(QWidget* parent)
+ : QWidget(parent)
+{
initInternalPanel();
setAttribute(Qt::WA_TransparentForMouseEvents);
setCursor(Qt::ArrowCursor);
@@ -42,17 +43,19 @@ UtilityPanel::UtilityPanel(QWidget *parent)
m_internalPanel,
&QWidget::hide);
-#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(Q_OS_MAC64) || \
+#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(Q_OS_MAC64) || \
defined(Q_OS_MACOS) || defined(Q_OS_MACX))
move(0, 0);
#endif
}
-QWidget *UtilityPanel::toolWidget() const {
+QWidget* UtilityPanel::toolWidget() const
+{
return m_toolWidget;
}
-void UtilityPanel::addToolWidget(QWidget *w) {
+void UtilityPanel::addToolWidget(QWidget* w)
+{
if (m_toolWidget) {
m_toolWidget->deleteLater();
}
@@ -64,30 +67,34 @@ void UtilityPanel::addToolWidget(QWidget *w) {
}
}
-void UtilityPanel::clearToolWidget() {
+void UtilityPanel::clearToolWidget()
+{
if (m_toolWidget) {
m_toolWidget->deleteLater();
}
}
-void UtilityPanel::pushWidget(QWidget *w) {
+void UtilityPanel::pushWidget(QWidget* w)
+{
m_layout->insertWidget(m_layout->count() - 1, w);
}
-void UtilityPanel::show() {
+void UtilityPanel::show()
+{
setAttribute(Qt::WA_TransparentForMouseEvents, false);
m_showAnimation->setStartValue(QRect(-width(), 0, 0, height()));
m_showAnimation->setEndValue(QRect(0, 0, width(), height()));
m_internalPanel->show();
m_showAnimation->start();
-#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(Q_OS_MAC64) || \
+#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(Q_OS_MAC64) || \
defined(Q_OS_MACOS) || defined(Q_OS_MACX))
move(0, 0);
#endif
QWidget::show();
}
-void UtilityPanel::hide() {
+void UtilityPanel::hide()
+{
setAttribute(Qt::WA_TransparentForMouseEvents);
m_hideAnimation->setStartValue(QRect(0, 0, width(), height()));
m_hideAnimation->setEndValue(QRect(-width(), 0, 0, height()));
@@ -96,7 +103,8 @@ void UtilityPanel::hide() {
QWidget::hide();
}
-void UtilityPanel::toggle() {
+void UtilityPanel::toggle()
+{
if (m_internalPanel->isHidden()) {
show();
} else {
@@ -104,10 +112,11 @@ void UtilityPanel::toggle() {
}
}
-void UtilityPanel::initInternalPanel() {
+void UtilityPanel::initInternalPanel()
+{
m_internalPanel = new QScrollArea(this);
m_internalPanel->setAttribute(Qt::WA_NoMousePropagation);
- QWidget *widget = new QWidget();
+ QWidget* widget = new QWidget();
m_internalPanel->setWidget(widget);
m_internalPanel->setWidgetResizable(true);
@@ -118,7 +127,7 @@ void UtilityPanel::initInternalPanel() {
m_layout->addLayout(m_bottomLayout);
widget->setLayout(m_layout);
- QPushButton *closeButton = new QPushButton(this);
+ QPushButton* closeButton = new QPushButton(this);
closeButton->setText(tr("Close"));
connect(closeButton, &QPushButton::clicked, this, &UtilityPanel::toggle);
m_bottomLayout->addWidget(closeButton);
@@ -126,6 +135,6 @@ void UtilityPanel::initInternalPanel() {
QColor bgColor = palette().window().color();
bgColor.setAlphaF(0.0);
m_internalPanel->setStyleSheet(
- QStringLiteral("QScrollArea {background-color: %1}").arg(bgColor.name()));
+ QStringLiteral("QScrollArea {background-color: %1}").arg(bgColor.name()));
m_internalPanel->hide();
}