mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
add restart wallpaper action in tray
This commit is contained in:
parent
6a3d067c79
commit
bea97cf0bb
@ -10,6 +10,7 @@ SingleInstanceManager::SingleInstanceManager(const QString& name, QObject* paren
|
|||||||
|
|
||||||
SingleInstanceManager::~SingleInstanceManager() {
|
SingleInstanceManager::~SingleInstanceManager() {
|
||||||
cleanUpServer();
|
cleanUpServer();
|
||||||
|
delete this->server;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleInstanceManager::cleanUpServer() {
|
void SingleInstanceManager::cleanUpServer() {
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
#include "UIWindow.h"
|
#include "UIWindow.h"
|
||||||
#include "Qt/SingleInstanceManager.h"
|
#include "Qt/SingleInstanceManager.h"
|
||||||
#include "WallpaperEngine/Logging/CLog.h"
|
|
||||||
#include <QtConcurrent/qtconcurrentrun.h>
|
#include <QtConcurrent/qtconcurrentrun.h>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <iostream>
|
|
||||||
#include <qapplication.h>
|
#include <qapplication.h>
|
||||||
#include <qboxlayout.h>
|
#include <qboxlayout.h>
|
||||||
#include <qcombobox.h>
|
#include <qcombobox.h>
|
||||||
@ -160,19 +158,9 @@ void UIWindow::setupUIWindow(std::vector<std::string> wallpaperPaths) {
|
|||||||
|
|
||||||
auto* trayMenu = new QMenu();
|
auto* trayMenu = new QMenu();
|
||||||
|
|
||||||
/*auto* showAction = new QAction("Show");
|
trayMenu->addAction("Reload wallpapers", [this] { startNewWallpaperEngine(); });
|
||||||
connect(showAction, &QAction::triggered, [this]() {
|
trayMenu->addAction("Quit", [this] { qApp->quit(); });
|
||||||
this->show();
|
|
||||||
});*/
|
|
||||||
|
|
||||||
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->setContextMenu(trayMenu);
|
||||||
trayIcon->setToolTip("Linux-Wallpaperengine");
|
trayIcon->setToolTip("Linux-Wallpaperengine");
|
||||||
trayIcon->show();
|
trayIcon->show();
|
||||||
@ -211,12 +199,12 @@ void UIWindow::startNewWallpaperEngine() {
|
|||||||
// create args
|
// create args
|
||||||
QStringList args;
|
QStringList args;
|
||||||
|
|
||||||
for (auto wallpaper : this->selectedWallpapers) {
|
for (const auto &wallpaper : this->selectedWallpapers) {
|
||||||
if (wallpaper.first == "" || wallpaper.second == "") continue;
|
if (wallpaper.first == "" || wallpaper.second == "") continue;
|
||||||
args.push_back("--screen-root");
|
args.push_back("--screen-root");
|
||||||
args.push_back(QString::fromStdString(wallpaper.first));
|
args.push_back(QString::fromStdString(wallpaper.first));
|
||||||
if (!extraFlags[wallpaper.first].empty()) {
|
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("--bg");
|
||||||
args.push_back(QString::fromStdString(wallpaper.second));
|
args.push_back(QString::fromStdString(wallpaper.second));
|
||||||
@ -248,7 +236,7 @@ void UIWindow::updateSelectedButton() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
// Using str in a string stream
|
||||||
std::stringstream ss(str);
|
std::stringstream ss(str);
|
||||||
std::vector<std::string> res;
|
std::vector<std::string> res;
|
||||||
|
@ -52,7 +52,7 @@ class UIWindow : public QWidget {
|
|||||||
|
|
||||||
void startNewWallpaperEngine();
|
void startNewWallpaperEngine();
|
||||||
void updateSelectedButton();
|
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:
|
protected:
|
||||||
void showEvent(QShowEvent* event) override;
|
void showEvent(QShowEvent* event) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user