From cc669ac2cd2defa10ccf214a39f627299522e4c5 Mon Sep 17 00:00:00 2001 From: delia Date: Tue, 29 Apr 2025 01:06:13 +0200 Subject: [PATCH 1/6] Added SingleInstanceManager --- CMakeLists.txt | 7 +++++-- main.cpp | 23 ++++++++++++++--------- src/Qt/SingleInstanceManager.cpp | 32 ++++++++++++++++++++++++++++++++ src/Qt/SingleInstanceManager.h | 27 +++++++++++++++++++++++++++ src/Qt/UIWindow.cpp | 14 +++++++++++++- src/Qt/UIWindow.h | 5 ++++- 6 files changed, 95 insertions(+), 13 deletions(-) create mode 100644 src/Qt/SingleInstanceManager.cpp create mode 100644 src/Qt/SingleInstanceManager.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b42795..c9c1f5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ find_package(MPV REQUIRED) find_package(LZ4 REQUIRED) find_package(FFMPEG REQUIRED) find_package(PulseAudio REQUIRED) -find_package(Qt5 REQUIRED COMPONENTS Widgets) +find_package(Qt5 REQUIRED COMPONENTS Widgets Network) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) @@ -214,6 +214,8 @@ add_executable( src/Qt/UIWindow.h src/Qt/UIWindow.cpp + src/Qt/SingleInstanceManager.h + src/Qt/SingleInstanceManager.cpp src/External/Android/fft.cpp src/External/Android/fft.h @@ -474,7 +476,8 @@ target_link_libraries (linux-wallpaperengine PUBLIC ${PULSEAUDIO_LIBRARY} glfw libcef_lib libcef_dll_wrapper - Qt5::Widgets) + Qt5::Widgets + Qt5::Network) if (WAYLAND_SUPPORT_FOUND) diff --git a/main.cpp b/main.cpp index f1e33d6..2b691cc 100644 --- a/main.cpp +++ b/main.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -10,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -17,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -25,6 +28,7 @@ #include #include +#include "Qt/SingleInstanceManager.h" #include "Qt/UIWindow.h" #include "Steam/FileSystem/FileSystem.h" #include "WallpaperEngine/Application/CApplicationContext.h" @@ -34,6 +38,8 @@ WallpaperEngine::Application::CWallpaperApplication* appPointer; QCoreApplication* globalApp = nullptr; +SingleInstanceManager* g_instanceManager = nullptr; + class UIWindow; @@ -41,6 +47,7 @@ void signalhandler(int sig) { if (appPointer == nullptr) { if(globalApp != nullptr) { + if (g_instanceManager) g_instanceManager->cleanUpServer(); globalApp->quit(); } else return; } @@ -56,16 +63,14 @@ void initLogging () int main (int argc, char* argv[]) { initLogging (); - bool runGui = false; - for (int i = 1; i < argc; i++) { - if(std::strcmp(argv[i], "--gui") == 0) { - runGui = true; - break; + g_instanceManager = new SingleInstanceManager("linux-wallpaperengine"); + + if (argc <= 1) { + if (!g_instanceManager->tryListen()) { + std::cout << "App is already running!!!!\n"; + return 0; } - } - - if (runGui) { std::string path = Steam::FileSystem::workshopDirectory(431960); std::vector wallpaperPaths; @@ -81,7 +86,7 @@ int main (int argc, char* argv[]) { std::signal (SIGINT, signalhandler); std::signal (SIGTERM, signalhandler); - auto* uiWindow = new UIWindow(nullptr, &qapp); + auto* uiWindow = new UIWindow(nullptr, &qapp, g_instanceManager); uiWindow->setupUIWindow(wallpaperPaths); diff --git a/src/Qt/SingleInstanceManager.cpp b/src/Qt/SingleInstanceManager.cpp new file mode 100644 index 0000000..dd13821 --- /dev/null +++ b/src/Qt/SingleInstanceManager.cpp @@ -0,0 +1,32 @@ +#include "SingleInstanceManager.h" +#include +#include +#include +#include + +SingleInstanceManager::SingleInstanceManager(const QString& name, QObject* parent) : QObject(parent), m_serverName(name) { + this->server = new QLocalServer(this); +} + +SingleInstanceManager::~SingleInstanceManager() { + cleanUpServer(); +} + +void SingleInstanceManager::cleanUpServer() { + if(server->isListening()) { + server->close(); + } +} + +bool SingleInstanceManager::tryListen() { + if (!server->listen(m_serverName)) return false; + + connect(server, &QLocalServer::newConnection, this, [this]() { + auto client = server->nextPendingConnection(); + connect(client, &QLocalSocket::readyRead, client, [this, client]() { + emit messageReceived(client->readAll()); + client->disconnectFromServer(); + }); + }); + return true; +} diff --git a/src/Qt/SingleInstanceManager.h b/src/Qt/SingleInstanceManager.h new file mode 100644 index 0000000..0ae7471 --- /dev/null +++ b/src/Qt/SingleInstanceManager.h @@ -0,0 +1,27 @@ +#pragma once +#include +#include +#include +#include +#include +#include + +class SingleInstanceManager : public QObject { + Q_OBJECT + + public: + SingleInstanceManager(const QString& serverName, QObject* parent = nullptr); + ~SingleInstanceManager() override; + + void cleanUpServer(); + + bool tryListen(); + void sendMessage(const QByteArray& message); + + signals: + void messageReceived(const QByteArray& message); + + private: + QLocalServer* server; + QString m_serverName; +}; diff --git a/src/Qt/UIWindow.cpp b/src/Qt/UIWindow.cpp index 17b6327..0bd24c6 100644 --- a/src/Qt/UIWindow.cpp +++ b/src/Qt/UIWindow.cpp @@ -1,26 +1,31 @@ #include "UIWindow.h" +#include "Qt/SingleInstanceManager.h" #include #include #include #include #include #include +#include #include #include +#include #include #include #include #include +#include #include #include #define PICTURE_SIZE 256 -UIWindow::UIWindow(QWidget* parent, QApplication* qapp) { +UIWindow::UIWindow(QWidget* parent, QApplication* qapp, SingleInstanceManager* ig) { this->qapp = qapp; this->screenSelector = new QComboBox(this); this->extraFlagsInput = new QLineEdit(this); this->wallpaperEngine = new QProcess(this); + this->instanceGuard = ig; } void UIWindow::setupUIWindow(std::vector wallpaperPaths) { @@ -67,6 +72,7 @@ void UIWindow::setupUIWindow(std::vector wallpaperPaths) { QAbstractButton::connect(button, &QPushButton::clicked, [button, this]() { QString clickedPath = button->property("path").toString(); + std::cout << clickedPath.toStdString() << "\n"; button->setEnabled(false); this->selectedWallpapers[this->screenSelector->currentText().toStdString()] = clickedPath.toStdString(); @@ -88,6 +94,12 @@ void UIWindow::setupUIWindow(std::vector wallpaperPaths) { QObject::connect(this->qapp, &QCoreApplication::aboutToQuit, this, [this]() { wallpaperEngine->terminate(); wallpaperEngine->waitForFinished(3000); + + instanceGuard->cleanUpServer(); + }); + + QObject::connect(instanceGuard, &SingleInstanceManager::messageReceived, [this](const QByteArray& msg) { + qDebug() << msg; }); container->setLayout(layout); diff --git a/src/Qt/UIWindow.h b/src/Qt/UIWindow.h index 6134cc5..b42a018 100644 --- a/src/Qt/UIWindow.h +++ b/src/Qt/UIWindow.h @@ -1,8 +1,10 @@ #pragma once +#include "Qt/SingleInstanceManager.h" #include #include #include +#include #include #include #include @@ -28,11 +30,12 @@ class UIWindow : public QWidget { Q_OBJECT public: - UIWindow(QWidget* parent, QApplication* qapp); + UIWindow(QWidget* parent, QApplication* qapp, SingleInstanceManager* instanceGuard); void setupUIWindow(std::vector wallpaperPaths); private: QApplication* qapp; + SingleInstanceManager* instanceGuard; QComboBox* screenSelector; QLineEdit* extraFlagsInput; std::map selectedWallpapers; From 9f0b2f9a00d63e620e53fa20447036cde84c9493 Mon Sep 17 00:00:00 2001 From: delia Date: Tue, 29 Apr 2025 20:43:13 +0200 Subject: [PATCH 2/6] Add SystemTrayIcon --- main.cpp | 9 +++++---- src/Qt/SingleInstanceManager.cpp | 6 ++++++ src/Qt/UIWindow.cpp | 34 ++++++++++++++++++++++++++++++-- src/Qt/UIWindow.h | 8 ++++++++ 4 files changed, 51 insertions(+), 6 deletions(-) diff --git a/main.cpp b/main.cpp index 2b691cc..0c6dcd8 100644 --- a/main.cpp +++ b/main.cpp @@ -64,9 +64,13 @@ void initLogging () int main (int argc, char* argv[]) { initLogging (); - g_instanceManager = new SingleInstanceManager("linux-wallpaperengine"); if (argc <= 1) { + QApplication qapp(argc, argv); + globalApp = &qapp; + + g_instanceManager = new SingleInstanceManager("linux-wallpaperengine"); + if (!g_instanceManager->tryListen()) { std::cout << "App is already running!!!!\n"; return 0; @@ -79,9 +83,6 @@ int main (int argc, char* argv[]) { wallpaperPaths.push_back(entry.path()); } - QApplication qapp(argc, argv); - globalApp = &qapp; - // Signal for properly close the app std::signal (SIGINT, signalhandler); std::signal (SIGTERM, signalhandler); diff --git a/src/Qt/SingleInstanceManager.cpp b/src/Qt/SingleInstanceManager.cpp index dd13821..5f5adde 100644 --- a/src/Qt/SingleInstanceManager.cpp +++ b/src/Qt/SingleInstanceManager.cpp @@ -19,6 +19,12 @@ void SingleInstanceManager::cleanUpServer() { } bool SingleInstanceManager::tryListen() { + QLocalSocket socket; + socket.connectToServer(m_serverName); + if (!socket.waitForConnected(100)) { + QLocalServer::removeServer(m_serverName); + } else return false; + if (!server->listen(m_serverName)) return false; connect(server, &QLocalServer::newConnection, this, [this]() { diff --git a/src/Qt/UIWindow.cpp b/src/Qt/UIWindow.cpp index 1f7f1d7..849fe4a 100644 --- a/src/Qt/UIWindow.cpp +++ b/src/Qt/UIWindow.cpp @@ -1,6 +1,7 @@ #include "UIWindow.h" #include "Qt/SingleInstanceManager.h" #include +#include #include #include #include @@ -11,9 +12,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -75,7 +78,6 @@ void UIWindow::setupUIWindow(std::vector wallpaperPaths) { QAbstractButton::connect(button, &QPushButton::clicked, [button, this]() { QString clickedPath = button->property("path").toString(); - std::cout << clickedPath.toStdString() << "\n"; button->setEnabled(false); this->selectedWallpapers[this->screenSelector->currentText().toStdString()] = clickedPath.toStdString(); @@ -103,7 +105,9 @@ void UIWindow::setupUIWindow(std::vector wallpaperPaths) { }); QObject::connect(instanceGuard, &SingleInstanceManager::messageReceived, [this](const QByteArray& msg) { - qDebug() << msg; + if (msg == "show") { + if (this->isHidden()) show(); + } }); container->setLayout(buttonLayout); @@ -148,6 +152,26 @@ void UIWindow::setupUIWindow(std::vector wallpaperPaths) { // update Buttons updateSelectedButton(); + + // SYSTEM TRAY + auto* trayIcon = new QSystemTrayIcon(QIcon::fromTheme("folder")); + + auto* trayMenu = new QMenu(); + + auto* showAction = new QAction("Show"); + connect(showAction, &QAction::triggered, [this]() { + this->show(); + }); + + auto* closeAction = new QAction("close"); + connect(closeAction, &QAction::triggered, [this]() { + this->qapp->quit(); + }); + + trayMenu->addActions({showAction, closeAction}); + trayIcon->setContextMenu(trayMenu); + trayIcon->setToolTip("Linux-Wallpaperengine"); + trayIcon->show(); } void UIWindow::showEvent(QShowEvent* event) { @@ -156,6 +180,11 @@ void UIWindow::showEvent(QShowEvent* event) { }); } +void UIWindow::closeEvent(QCloseEvent* event) { + this->hide(); + event->ignore(); +} + void UIWindow::startNewWallpaperEngine() { if (wallpaperEngine->state() == QProcess::Running) { // Stop WallpaperProcess @@ -169,6 +198,7 @@ void UIWindow::startNewWallpaperEngine() { QStringList args; for (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()) { diff --git a/src/Qt/UIWindow.h b/src/Qt/UIWindow.h index dd99f02..c71f176 100644 --- a/src/Qt/UIWindow.h +++ b/src/Qt/UIWindow.h @@ -20,6 +20,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -34,11 +38,14 @@ class UIWindow : public QWidget { void setupUIWindow(std::vector wallpaperPaths); private: + // Components QApplication* qapp; SingleInstanceManager* instanceGuard; QComboBox* screenSelector; QLineEdit* extraFlagsInput; QGridLayout* buttonLayout; + + // Important Fields std::map selectedWallpapers; std::map> extraFlags; QProcess* wallpaperEngine; @@ -49,4 +56,5 @@ class UIWindow : public QWidget { protected: void showEvent(QShowEvent* event) override; + void closeEvent(QCloseEvent* event) override; }; From d351999e73363b7618fcc470540e5be7b6c16a2b Mon Sep 17 00:00:00 2001 From: delia Date: Wed, 30 Apr 2025 00:19:03 +0200 Subject: [PATCH 3/6] changed TrayMenu text from 'stop' to 'Quit' --- src/Qt/UIWindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Qt/UIWindow.cpp b/src/Qt/UIWindow.cpp index 849fe4a..ee61fdb 100644 --- a/src/Qt/UIWindow.cpp +++ b/src/Qt/UIWindow.cpp @@ -163,7 +163,7 @@ void UIWindow::setupUIWindow(std::vector wallpaperPaths) { this->show(); }); - auto* closeAction = new QAction("close"); + auto* closeAction = new QAction("Quit"); connect(closeAction, &QAction::triggered, [this]() { this->qapp->quit(); }); @@ -228,7 +228,7 @@ void UIWindow::updateSelectedButton() { if (button->property("path").toString().toStdString() == selected) { button->setStyleSheet("background-color: #4488ff; color white; border: 2px solid #0055cc"); } else { - button->setStyleSheet("background-color: #4A4D51; color white; border: 2px solid #2B2A33"); + button->setStyleSheet("background-color: #4A4D51; color white; border: 2px solid #3B3A43"); } } } From 0ff5c36a3c1f14bb66508b008a3c6811cca0a8c8 Mon Sep 17 00:00:00 2001 From: Deliasama <115506148+Deliasama@users.noreply.github.com> Date: Tue, 29 Apr 2025 23:17:39 +0000 Subject: [PATCH 4/6] Update README.md --- README.md | 158 ++++++++---------------------------------------------- 1 file changed, 22 insertions(+), 136 deletions(-) diff --git a/README.md b/README.md index a1559b9..6616e03 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,13 @@

- - - - - - - help wanted

# 1. Disclaimer -**This is an educational project**. Although the project started as a learning exercise on the Irrlicht Engine, it has kind of turned into an OpenGL one instead due to limitations and issues with Irrlicht (most likely caused by my limited experience with graphics programming). As it turns out, working directly with OpenGL is not as hard as I thought. For more information on the project's license, check [LICENSE](LICENSE). +**This is an educational project**. The project started as a fork from [Almamu/linux-wallpaperengine](https://github.com/Almamu/linux-wallpaperengine) so please check out the original! +For more information on the project's license, check [LICENSE](LICENSE). # 2. What is this project all about? -This project aims to reproduce the background functionality of Wallpaper Engine on Linux systems. Simple as that. +This project aims to reproduce the background functionality of Wallpaper Engine on Linux systems. Simple as that. This fork in particular adds a GUI for selecting your wallpapers! # 3. What is Wallpaper Engine? Wallpaper Engine is a software designed by [Kristjan Skutta](https://store.steampowered.com/search/?developer=Kristjan%20Skutta&snr=1_5_9__400) that provides live wallpaper functionality to Windows Systems, allowing its users to animate their own backgrounds and share their own creations. You can find more about it on their [Steam page](https://store.steampowered.com/app/431960/Wallpaper_Engine/). @@ -96,146 +90,38 @@ make **REMEMBER: The assets folder has to be in the same folder as the executable** -## 5.5. Running a background -There are two ways to run a background: Run it with the gui, or run it in cli with the workshop's ID - -### 5.5.1. Running with GUI -To open the GUI/Wallpaper-launcher you just need to run the following command: +## 5.5. Running linux-wallpaperengine +Now you can run the program using the following command: ``` -./linux-wallpaperengine --gui +./linux-wallpaperengine ``` -In the simple Qt based UI you can select one of your installed Wallpapers and the screen where the wallpaper should run on. - -### 5.5.2. Running a background from Steam -Just like with the assets, the software can automatically detect where the subscribed backgrounds are stored. To get started, search in the workshop for whatever background you want to use and click the "+Subscribe" button. This should download the background in the steam directory. - -To actually use the background you'll need to know the workshop's ID. This can be obtained right-clicking anywhere in the background's page -> "Copy Page URL". You can paste this URL anywhere, it will look something like this: - -``` -https://steamcommunity.com/sharedfiles/filedetails/?id=1845706469&searchtext=portal+3 -``` - -Where 1845706469 is the wallpaper's ID. You can use this ID to run wallpaperengine: -``` -./linux-wallpaperengine 1845706469 -``` - -### 5.5.3. Running a background in a different folder -For the situations where the software cannot detect where the backgrounds are stored, you can specify a full path to it, like so: -``` -./linux-wallpaperengine /home/almamu/Development/backgrounds/1845706469/ -``` - -### 5.5.4. Running in a window (Default) -By default the app will load the backgrounds in a window so you can preview them: -``` -./linux-wallpaperengine /home/almamu/Development/backgrounds/1845706469/ -``` - -Where `/home/almamu/Development/backgrounds/1845706469/` is the background's path. - -### 5.5.5. Running as a screen's background -The app supports running as background in X11 and Wayland. Use the --screen-root switch and the screen name, like so: - -``` -./linux-wallpaperengine --screen-root HDMI-1 --screen-root DVI-D-1 1845706469 -``` +## 5.6 Selecting a wallpaper +In the graphical user interface (GUI), start by selecting the desired screen. Then simply click on a wallpaper to display it. #### Wayland Has only been tested under wlroots but should work on any flavour as long as wlr-layer-shell-unstable is supported. #### X11 -Only screens configured with the XRandr extension are supported. To specify the screen names (as reported from xrandr tool) just use the ```--screen-root``` switch. You can specify multiple screens at the same time, for example: +Only screens configured with the XRandr extension are supported. **IMPORTANT: Right now this doesn't work if there is anything drawing to the background (like a compositor, gnome, kde, nautilus, etc)** +### 5.6.1 Using custom-flags +To further customize your wallpaper (e.g., adjusting the volume), you can enter one or more of the following flags in the text field at the bottom of the GUI **before** selecting a wallpaper: -### 5.5.6. Limiting FPS -To reduce the performance hit to your system you can reduce (or increase) the FPS limit with the switch ```--fps```, especially useful for laptops: -``` -./linux-wallpaperengine --fps 30 -``` - -## 5.6. Audio -### 5.6.1. Disable audio -It's possible to disable the audio of the background with the silent argument -``` -./linux-wallpaperengine --silent -``` - -## 5.7. Taking a screenshot -It is possible to take a screenshot of the screen's content at the moment a background is loaded up and rendered. Useful for tools like pywal to further customize your environment: -``` -./linux-wallpaperengine --screenshot /path/to/screenshot/name.png -``` - -PNG, BMP and JPEG are supported. - -## 5.8. Properties -Some backgrounds have a list of properties that the user can customize. These properties modify how parts of the background behave or look like. Support for these is present. -First, list all the available properties in a background, you can do that with the --list-properties switch: -``` -./linux-wallpaperengine --list-properties 2370927443 -``` - -The output includes all the relevant information for each of the different properties: -``` -barcount - slider - Description: Bar Count - Value: 64 - Minimum value: 16 - Maximum value: 64 - Step: 1 - -bloom - boolean - Description: Bloom - Value: 0 -frequency - combolist - Description: Frequency - Value: 2 - Posible values: - 16 -> 1 - 32 -> 2 - 64 -> 3 - -owl - boolean - Description: Owl - Value: 0 -rain - boolean - Description: Rain - Value: 1 -schemecolor - color - Description: ui_browse_properties_scheme_color - R: 0.14902 G: 0.23137 B: 0.4 A: 1 -visualizer - boolean - Description:
Add Visualizer
- Value: 1 -visualizercolor - color - Description: Bar Color - R: 0.12549 G: 0.215686 B: 0.352941 A: 1 -visualizeropacity - slider - Description: Bar Opacity - Value: 1 - Minimum value: 0 - Maximum value: 1 - Step: 0.1 - -visualizerwidth - slider - Description: Bar Spacing - Value: 0.25 - Minimum value: 0 - Maximum value: 0.5 - Step: 0.01 -``` - -Any of these values can be modified with the --set-property switch. Say you want to enable the bloom in this background, you would do so like this: -``` -./linux-wallpaperengine --set-property bloom=1 2370927443 -``` - -If you keep --list-properties in the commandline you can see how the values change to confirm that it applied properly. +| Option | Description | +|--------|-------------| +| `--silent` | Mute background audio | +| `--volume ` | Set audio volume | +| `--noautomute` | Don't mute when other apps play audio | +| `--no-audio-processing` | Disable audio reactive features | +| `--fps ` | Limit frame rate | +| `--scaling ` | Wallpaper scaling: `stretch`, `fit`, `fill`, or `default` | +| `--clamping ` | Set texture clamping: `clamp`, `border`, `repeat` | +| `--disable-mouse` | Disable mouse interaction | +| `--no-fullscreen-pause` | Prevent pausing while fullscreen apps are running | ## 6. Example background This was the first background to even be compatible with the software. And it's not 100% compatible yet. Both textures and shaders are properly loaded, but there are still particles missing. From 4891a7fcc67d34c83177f109967f5bf314c3b306 Mon Sep 17 00:00:00 2001 From: delia Date: Sat, 12 Jul 2025 01:59:31 +0200 Subject: [PATCH 5/6] add few logs at startup --- main.cpp | 8 +++++++- src/Qt/UIWindow.cpp | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 0c6dcd8..4075df3 100644 --- a/main.cpp +++ b/main.cpp @@ -33,6 +33,7 @@ #include "Steam/FileSystem/FileSystem.h" #include "WallpaperEngine/Application/CApplicationContext.h" #include "WallpaperEngine/Application/CWallpaperApplication.h" +#include "WallpaperEngine/Logging/CLog.h" #include "WallpaperEngine/WebBrowser/CWebBrowserContext.h" #include "common.h" @@ -72,10 +73,11 @@ int main (int argc, char* argv[]) { g_instanceManager = new SingleInstanceManager("linux-wallpaperengine"); if (!g_instanceManager->tryListen()) { - std::cout << "App is already running!!!!\n"; + sLog.out("App is already running!"); return 0; } std::string path = Steam::FileSystem::workshopDirectory(431960); + sLog.out("Found workshopDirectory: " + path); std::vector wallpaperPaths; @@ -83,10 +85,14 @@ int main (int argc, char* argv[]) { wallpaperPaths.push_back(entry.path()); } + sLog.out("Found " + std::to_string(wallpaperPaths.size()) + " Installed Wallpapers!"); + // Signal for properly close the app std::signal (SIGINT, signalhandler); std::signal (SIGTERM, signalhandler); + sLog.out("Starting App.."); + auto* uiWindow = new UIWindow(nullptr, &qapp, g_instanceManager); uiWindow->setupUIWindow(wallpaperPaths); diff --git a/src/Qt/UIWindow.cpp b/src/Qt/UIWindow.cpp index ee61fdb..8633a1a 100644 --- a/src/Qt/UIWindow.cpp +++ b/src/Qt/UIWindow.cpp @@ -1,5 +1,6 @@ #include "UIWindow.h" #include "Qt/SingleInstanceManager.h" +#include "WallpaperEngine/Logging/CLog.h" #include #include #include From bea97cf0bb7825cdc485c845f870cf2915f32c2f Mon Sep 17 00:00:00 2001 From: delia Date: Wed, 16 Jul 2025 16:41:20 +0200 Subject: [PATCH 6/6] 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;