From bea97cf0bb7825cdc485c845f870cf2915f32c2f Mon Sep 17 00:00:00 2001 From: delia Date: Wed, 16 Jul 2025 16:41:20 +0200 Subject: [PATCH] add restart wallpaper action in tray --- src/Qt/SingleInstanceManager.cpp | 1 + src/Qt/UIWindow.cpp | 22 +++++----------------- src/Qt/UIWindow.h | 2 +- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/Qt/SingleInstanceManager.cpp b/src/Qt/SingleInstanceManager.cpp index 5f5adde..06b8e00 100644 --- a/src/Qt/SingleInstanceManager.cpp +++ b/src/Qt/SingleInstanceManager.cpp @@ -10,6 +10,7 @@ SingleInstanceManager::SingleInstanceManager(const QString& name, QObject* paren SingleInstanceManager::~SingleInstanceManager() { cleanUpServer(); + delete this->server; } void SingleInstanceManager::cleanUpServer() { diff --git a/src/Qt/UIWindow.cpp b/src/Qt/UIWindow.cpp index 8e2cae4..1a389b7 100644 --- a/src/Qt/UIWindow.cpp +++ b/src/Qt/UIWindow.cpp @@ -1,9 +1,7 @@ #include "UIWindow.h" #include "Qt/SingleInstanceManager.h" -#include "WallpaperEngine/Logging/CLog.h" #include #include -#include #include #include #include @@ -159,20 +157,10 @@ void UIWindow::setupUIWindow(std::vector wallpaperPaths) { auto* trayIcon = new QSystemTrayIcon(QIcon(":/assets/wallpaper-icon.png")); auto* trayMenu = new QMenu(); - - /*auto* showAction = new QAction("Show"); - connect(showAction, &QAction::triggered, [this]() { - this->show(); - });*/ - trayMenu->addAction("Quit", [this]{ qApp->quit();}); + trayMenu->addAction("Reload wallpapers", [this] { startNewWallpaperEngine(); }); + trayMenu->addAction("Quit", [this] { qApp->quit(); }); - /*auto* closeAction = new QAction("Quit"); - connect(closeAction, &QAction::triggered, [this]() { - this->qapp->quit(); - });*/ - - // trayMenu->addActions({showAction, closeAction}); trayIcon->setContextMenu(trayMenu); trayIcon->setToolTip("Linux-Wallpaperengine"); trayIcon->show(); @@ -211,12 +199,12 @@ void UIWindow::startNewWallpaperEngine() { // create args QStringList args; - for (auto wallpaper : this->selectedWallpapers) { + for (const auto &wallpaper : this->selectedWallpapers) { if (wallpaper.first == "" || wallpaper.second == "") continue; args.push_back("--screen-root"); args.push_back(QString::fromStdString(wallpaper.first)); if (!extraFlags[wallpaper.first].empty()) { - for (std::string a : extraFlags[wallpaper.first]) args.push_back(QString::fromStdString(a)); + for (const std::string &a : extraFlags[wallpaper.first]) args.push_back(QString::fromStdString(a)); } args.push_back("--bg"); args.push_back(QString::fromStdString(wallpaper.second)); @@ -248,7 +236,7 @@ void UIWindow::updateSelectedButton() { } } -std::vector UIWindow::split(std::string str, char delimiter) { +std::vector UIWindow::split(const std::string &str, char delimiter) { // Using str in a string stream std::stringstream ss(str); std::vector res; diff --git a/src/Qt/UIWindow.h b/src/Qt/UIWindow.h index c71f176..7c4c9c0 100644 --- a/src/Qt/UIWindow.h +++ b/src/Qt/UIWindow.h @@ -52,7 +52,7 @@ class UIWindow : public QWidget { void startNewWallpaperEngine(); void updateSelectedButton(); - static std::vector split(std::string str, char r); + static std::vector split(const std::string &str, char r); protected: void showEvent(QShowEvent* event) override;