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() {
|
||||
cleanUpServer();
|
||||
delete this->server;
|
||||
}
|
||||
|
||||
void SingleInstanceManager::cleanUpServer() {
|
||||
|
@ -1,9 +1,7 @@
|
||||
#include "UIWindow.h"
|
||||
#include "Qt/SingleInstanceManager.h"
|
||||
#include "WallpaperEngine/Logging/CLog.h"
|
||||
#include <QtConcurrent/qtconcurrentrun.h>
|
||||
#include <cstddef>
|
||||
#include <iostream>
|
||||
#include <qapplication.h>
|
||||
#include <qboxlayout.h>
|
||||
#include <qcombobox.h>
|
||||
@ -160,19 +158,9 @@ void UIWindow::setupUIWindow(std::vector<std::string> wallpaperPaths) {
|
||||
|
||||
auto* trayMenu = new QMenu();
|
||||
|
||||
/*auto* showAction = new QAction("Show");
|
||||
connect(showAction, &QAction::triggered, [this]() {
|
||||
this->show();
|
||||
});*/
|
||||
trayMenu->addAction("Reload wallpapers", [this] { startNewWallpaperEngine(); });
|
||||
trayMenu->addAction("Quit", [this] { qApp->quit(); });
|
||||
|
||||
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<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;
|
||||
|
@ -52,7 +52,7 @@ class UIWindow : public QWidget {
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user