mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
Merge pull request #1 from Deliasama/SingleInstanceGuard
Single instance guard
This commit is contained in:
commit
a44dbd9125
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,6 +4,7 @@ cmake-build-debug*
|
||||
build/
|
||||
.vscode/
|
||||
third_party/
|
||||
cmake/
|
||||
compile_commands.json
|
||||
|
||||
*-protocol.o
|
||||
|
@ -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(Qt6 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
|
||||
@ -452,6 +454,8 @@ add_executable(
|
||||
${X11_SOURCES}
|
||||
|
||||
)
|
||||
qt_add_resources(RESOURCES resources.qrc)
|
||||
target_sources(linux-wallpaperengine PRIVATE ${RESOURCES})
|
||||
|
||||
COPY_FILES(linux-wallpaperengine "${CEF_BINARY_FILES}" "${CEF_BINARY_DIR}" "${TARGET_OUTPUT_DIRECTORY}")
|
||||
COPY_FILES(linux-wallpaperengine "${CEF_RESOURCE_FILES}" "${CEF_RESOURCE_DIR}" "${TARGET_OUTPUT_DIRECTORY}")
|
||||
@ -474,7 +478,8 @@ target_link_libraries (linux-wallpaperengine PUBLIC
|
||||
${PULSEAUDIO_LIBRARY}
|
||||
glfw
|
||||
libcef_lib libcef_dll_wrapper
|
||||
Qt5::Widgets)
|
||||
Qt6::Widgets
|
||||
Qt6::Network)
|
||||
|
||||
|
||||
if (WAYLAND_SUPPORT_FOUND)
|
||||
|
158
README.md
158
README.md
@ -1,19 +1,13 @@
|
||||
<p align="center">
|
||||
<a href="https://github.com/Almamu/linux-wallpaperengine/blob/main/LICENSE"><img src="https://img.shields.io/github/license/Almamu/linux-wallpaperengine" /></a>
|
||||
<a href="https://github.com/Almamu/linux-wallpaperengine/actions?query=branch%3Amain"><img src="https://img.shields.io/github/actions/workflow/status/Almamu/linux-wallpaperengine/cmake.yml?branch=main" /></a>
|
||||
<a href="https://github.com/Almamu/linux-wallpaperengine/pulse"><img src="https://img.shields.io/tokei/lines/github/Almamu/linux-wallpaperengine" /></a>
|
||||
<a href="https://www.codefactor.io/repository/github/almamu/linux-wallpaperengine"><img src="https://img.shields.io/codefactor/grade/github/Almamu/linux-wallpaperengine" /></a>
|
||||
<a href="https://github.com/Almamu/linux-wallpaperengine/graphs/commit-activity"><img src="https://img.shields.io/github/commit-activity/m/Almamu/linux-wallpaperengine" /></a>
|
||||
<a href="https://github.com/Almamu/linux-wallpaperengine/graphs/contributors"><img src="https://img.shields.io/github/contributors/Almamu/linux-wallpaperengine" /></a>
|
||||
<a href="https://github.com/Almamu/linux-wallpaperengine/issues"><img src="https://img.shields.io/github/issues-raw/Almamu/linux-wallpaperengine" /></a>
|
||||
<a href="https://github.com/Almamu/linux-wallpaperengine/issues?q=is%3Aissue+is%3Aopen+label%3A%22help%20wanted%22"><img src="https://img.shields.io/github/issues/Almamu/linux-wallpaperengine/help%20wanted?color=green" alt="help wanted"></a>
|
||||
</p>
|
||||
|
||||
# 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: <hr>Add Visualizer<hr>
|
||||
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 <val>` | Set audio volume |
|
||||
| `--noautomute` | Don't mute when other apps play audio |
|
||||
| `--no-audio-processing` | Disable audio reactive features |
|
||||
| `--fps <val>` | Limit frame rate |
|
||||
| `--scaling <mode>` | Wallpaper scaling: `stretch`, `fit`, `fill`, or `default` |
|
||||
| `--clamping <mode>` | 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.
|
||||
|
BIN
assets/wallpaper-icon.png
Normal file
BIN
assets/wallpaper-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
34
main.cpp
34
main.cpp
@ -1,5 +1,6 @@
|
||||
#include <csignal>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <QApplication>
|
||||
@ -10,6 +11,7 @@
|
||||
#include <QProcess>
|
||||
#include <QFileInfo>
|
||||
#include <QObject>
|
||||
#include <QLocalServer>
|
||||
#include <iterator>
|
||||
#include <qboxlayout.h>
|
||||
#include <qcoreapplication.h>
|
||||
@ -17,6 +19,7 @@
|
||||
#include <qgridlayout.h>
|
||||
#include <qlabel.h>
|
||||
#include <qnamespace.h>
|
||||
#include <qobject.h>
|
||||
#include <qprocess.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qscrollarea.h>
|
||||
@ -25,15 +28,19 @@
|
||||
#include <filesystem>
|
||||
#include <vector>
|
||||
|
||||
#include "Qt/SingleInstanceManager.h"
|
||||
#include "Qt/UIWindow.h"
|
||||
#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"
|
||||
|
||||
WallpaperEngine::Application::CWallpaperApplication* appPointer;
|
||||
QCoreApplication* globalApp = nullptr;
|
||||
SingleInstanceManager* g_instanceManager = nullptr;
|
||||
|
||||
|
||||
class UIWindow;
|
||||
|
||||
@ -41,6 +48,7 @@ void signalhandler(int sig)
|
||||
{
|
||||
if (appPointer == nullptr) {
|
||||
if(globalApp != nullptr) {
|
||||
if (g_instanceManager) g_instanceManager->cleanUpServer();
|
||||
globalApp->quit();
|
||||
} else return;
|
||||
}
|
||||
@ -56,17 +64,20 @@ 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;
|
||||
|
||||
if (argc <= 1) {
|
||||
QApplication qapp(argc, argv);
|
||||
globalApp = &qapp;
|
||||
|
||||
g_instanceManager = new SingleInstanceManager("linux-wallpaperengine");
|
||||
|
||||
if (!g_instanceManager->tryListen()) {
|
||||
sLog.out("App is already running!");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (runGui) {
|
||||
std::string path = Steam::FileSystem::workshopDirectory(431960);
|
||||
sLog.out("Found workshopDirectory: " + path);
|
||||
|
||||
std::vector<std::string> wallpaperPaths;
|
||||
|
||||
@ -74,14 +85,15 @@ int main (int argc, char* argv[]) {
|
||||
wallpaperPaths.push_back(entry.path());
|
||||
}
|
||||
|
||||
QApplication qapp(argc, argv);
|
||||
globalApp = &qapp;
|
||||
sLog.out("Found " + std::to_string(wallpaperPaths.size()) + " Installed Wallpapers!");
|
||||
|
||||
// Signal for properly close the app
|
||||
std::signal (SIGINT, signalhandler);
|
||||
std::signal (SIGTERM, signalhandler);
|
||||
|
||||
auto* uiWindow = new UIWindow(nullptr, &qapp);
|
||||
sLog.out("Starting App..");
|
||||
|
||||
auto* uiWindow = new UIWindow(nullptr, &qapp, g_instanceManager);
|
||||
|
||||
uiWindow->setupUIWindow(wallpaperPaths);
|
||||
|
||||
|
5
resources.qrc
Normal file
5
resources.qrc
Normal file
@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>assets/wallpaper-icon.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
39
src/Qt/SingleInstanceManager.cpp
Normal file
39
src/Qt/SingleInstanceManager.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
#include "SingleInstanceManager.h"
|
||||
#include <qchar.h>
|
||||
#include <qlocalserver.h>
|
||||
#include <qlocalsocket.h>
|
||||
#include <qobject.h>
|
||||
|
||||
SingleInstanceManager::SingleInstanceManager(const QString& name, QObject* parent) : QObject(parent), m_serverName(name) {
|
||||
this->server = new QLocalServer(this);
|
||||
}
|
||||
|
||||
SingleInstanceManager::~SingleInstanceManager() {
|
||||
cleanUpServer();
|
||||
delete this->server;
|
||||
}
|
||||
|
||||
void SingleInstanceManager::cleanUpServer() {
|
||||
if(server->isListening()) {
|
||||
server->close();
|
||||
}
|
||||
}
|
||||
|
||||
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]() {
|
||||
auto client = server->nextPendingConnection();
|
||||
connect(client, &QLocalSocket::readyRead, client, [this, client]() {
|
||||
emit messageReceived(client->readAll());
|
||||
client->disconnectFromServer();
|
||||
});
|
||||
});
|
||||
return true;
|
||||
}
|
27
src/Qt/SingleInstanceManager.h
Normal file
27
src/Qt/SingleInstanceManager.h
Normal file
@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
#include <QObject>
|
||||
#include <qlocalserver.h>
|
||||
#include <QLocalSocket>
|
||||
#include <qobject.h>
|
||||
#include <qobjectdefs.h>
|
||||
#include <QByteArray>
|
||||
|
||||
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;
|
||||
};
|
@ -1,30 +1,37 @@
|
||||
#include "UIWindow.h"
|
||||
#include "Qt/SingleInstanceManager.h"
|
||||
#include <QtConcurrent/qtconcurrentrun.h>
|
||||
#include <iostream>
|
||||
#include <cstddef>
|
||||
#include <qapplication.h>
|
||||
#include <qboxlayout.h>
|
||||
#include <qcombobox.h>
|
||||
#include <qcursor.h>
|
||||
#include <qevent.h>
|
||||
#include <qglobal.h>
|
||||
#include <qlabel.h>
|
||||
#include <qlayout.h>
|
||||
#include <qlineedit.h>
|
||||
#include <qlocalsocket.h>
|
||||
#include <qmenu.h>
|
||||
#include <qnamespace.h>
|
||||
#include <qprocess.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qsystemtrayicon.h>
|
||||
#include <qwidget.h>
|
||||
#include <qwindowdefs.h>
|
||||
#include <QByteArray>
|
||||
#include <string>
|
||||
#include <strings.h>
|
||||
#include <vector>
|
||||
|
||||
#define PICTURE_SIZE 128
|
||||
|
||||
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;
|
||||
this->buttonLayout = new QGridLayout(this);
|
||||
}
|
||||
|
||||
@ -93,6 +100,14 @@ void UIWindow::setupUIWindow(std::vector<std::string> 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) {
|
||||
if (msg == "show") {
|
||||
if (this->isHidden()) show();
|
||||
}
|
||||
});
|
||||
|
||||
container->setLayout(buttonLayout);
|
||||
@ -137,6 +152,28 @@ void UIWindow::setupUIWindow(std::vector<std::string> wallpaperPaths) {
|
||||
|
||||
// update Buttons
|
||||
updateSelectedButton();
|
||||
|
||||
// SYSTEM TRAY
|
||||
auto* trayIcon = new QSystemTrayIcon(QIcon(":/assets/wallpaper-icon.png"));
|
||||
|
||||
auto* trayMenu = new QMenu();
|
||||
|
||||
trayMenu->addAction("Reload wallpapers", [this] { startNewWallpaperEngine(); });
|
||||
trayMenu->addAction("Quit", [this] { qApp->quit(); });
|
||||
|
||||
trayIcon->setContextMenu(trayMenu);
|
||||
trayIcon->setToolTip("Linux-Wallpaperengine");
|
||||
trayIcon->show();
|
||||
|
||||
connect(trayIcon, &QSystemTrayIcon::activated, this, [this](QSystemTrayIcon::ActivationReason reason) {
|
||||
if (reason == QSystemTrayIcon::Trigger) {
|
||||
if (isVisible()) {
|
||||
hide();
|
||||
} else {
|
||||
show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void UIWindow::showEvent(QShowEvent* event) {
|
||||
@ -145,6 +182,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
|
||||
@ -157,11 +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));
|
||||
@ -187,13 +230,13 @@ 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> UIWindow::split(std::string str, char delimiter) {
|
||||
std::vector<std::string> UIWindow::split(const std::string &str, char delimiter) {
|
||||
// Using str in a string stream
|
||||
std::stringstream ss(str);
|
||||
std::vector<std::string> res;
|
||||
|
@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "Qt/SingleInstanceManager.h"
|
||||
#include <map>
|
||||
#include <qapplication.h>
|
||||
#include <qcombobox.h>
|
||||
#include <qglobal.h>
|
||||
#include <qgridlayout.h>
|
||||
#include <qlineedit.h>
|
||||
#include <qobjectdefs.h>
|
||||
@ -18,6 +20,10 @@
|
||||
#include <QLineEdit>
|
||||
#include <QLabel>
|
||||
#include <QMovie>
|
||||
#include <QCloseEvent>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -28,22 +34,27 @@ class UIWindow : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
UIWindow(QWidget* parent, QApplication* qapp);
|
||||
UIWindow(QWidget* parent, QApplication* qapp, SingleInstanceManager* instanceGuard);
|
||||
void setupUIWindow(std::vector<std::string> wallpaperPaths);
|
||||
|
||||
private:
|
||||
// Components
|
||||
QApplication* qapp;
|
||||
SingleInstanceManager* instanceGuard;
|
||||
QComboBox* screenSelector;
|
||||
QLineEdit* extraFlagsInput;
|
||||
QGridLayout* buttonLayout;
|
||||
|
||||
// Important Fields
|
||||
std::map<std::string, std::string> selectedWallpapers;
|
||||
std::map<std::string, std::vector<std::string>> extraFlags;
|
||||
QProcess* wallpaperEngine;
|
||||
|
||||
void startNewWallpaperEngine();
|
||||
void updateSelectedButton();
|
||||
static std::vector<std::string> split(std::string str, char r);
|
||||
static std::vector<std::string> split(const std::string &str, char r);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent* event) override;
|
||||
void closeEvent(QCloseEvent* event) override;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user