mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
Add extra flags input
This commit is contained in:
parent
0f2489a4c3
commit
05843feff3
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,4 +1,5 @@
|
|||||||
#include "UIWindow.h"
|
#include "UIWindow.h"
|
||||||
|
#include <iostream>
|
||||||
#include <qapplication.h>
|
#include <qapplication.h>
|
||||||
#include <qboxlayout.h>
|
#include <qboxlayout.h>
|
||||||
#include <qcombobox.h>
|
#include <qcombobox.h>
|
||||||
@ -7,6 +8,7 @@
|
|||||||
#include <qlineedit.h>
|
#include <qlineedit.h>
|
||||||
#include <qprocess.h>
|
#include <qprocess.h>
|
||||||
#include <qwidget.h>
|
#include <qwidget.h>
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
UIWindow::UIWindow(QWidget* parent, QApplication* qapp) {
|
UIWindow::UIWindow(QWidget* parent, QApplication* qapp) {
|
||||||
@ -35,9 +37,6 @@ void UIWindow::setupUIWindow(std::vector<std::string> wallpaperPaths) {
|
|||||||
|
|
||||||
int cols = 5;
|
int cols = 5;
|
||||||
|
|
||||||
// Wallpaper Process
|
|
||||||
// auto* wallpaperEngine = new QProcess(this);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < wallpaperPaths.size(); i++) {
|
for (size_t i = 0; i < wallpaperPaths.size(); i++) {
|
||||||
QPixmap pixmap(QString::fromStdString(wallpaperPaths[i] + "/preview.jpg"));
|
QPixmap pixmap(QString::fromStdString(wallpaperPaths[i] + "/preview.jpg"));
|
||||||
if (pixmap.isNull()) {
|
if (pixmap.isNull()) {
|
||||||
@ -57,6 +56,7 @@ void UIWindow::setupUIWindow(std::vector<std::string> wallpaperPaths) {
|
|||||||
button->setEnabled(false);
|
button->setEnabled(false);
|
||||||
|
|
||||||
this->selectedWallpapers[this->screenSelector->currentText().toStdString()] = clickedPath.toStdString();
|
this->selectedWallpapers[this->screenSelector->currentText().toStdString()] = clickedPath.toStdString();
|
||||||
|
this->extraFlags[this->screenSelector->currentText().toStdString()] = split(this->extraFlagsInput->text().toStdString(), ' ');
|
||||||
|
|
||||||
startNewWallpaperEngine();
|
startNewWallpaperEngine();
|
||||||
|
|
||||||
@ -85,9 +85,19 @@ void UIWindow::setupUIWindow(std::vector<std::string> wallpaperPaths) {
|
|||||||
this->screenSelector->addItem(screen->name());
|
this->screenSelector->addItem(screen->name());
|
||||||
}
|
}
|
||||||
this->screenSelector->setCurrentIndex(0);
|
this->screenSelector->setCurrentIndex(0);
|
||||||
auto* screenSelectorLayout = new QVBoxLayout(this);
|
this->screenSelector->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||||
QLabel label("Screen Selector:");
|
this->screenSelector->setFixedHeight(48);
|
||||||
screenSelectorLayout->addWidget(&label);
|
|
||||||
|
auto font = screenSelector->font();
|
||||||
|
font.setPointSize(18);
|
||||||
|
this->screenSelector->setFont(font);
|
||||||
|
|
||||||
|
this->screenSelector->setPalette(*pal);
|
||||||
|
|
||||||
|
auto* screenSelectorLayout = new QVBoxLayout();
|
||||||
|
auto* label = new QLabel("Screen Selector:");
|
||||||
|
label->setFont(font);
|
||||||
|
screenSelectorLayout->addWidget(label);
|
||||||
screenSelectorLayout->addWidget(screenSelector);
|
screenSelectorLayout->addWidget(screenSelector);
|
||||||
|
|
||||||
auto* screenSelectContainer = new QWidget();
|
auto* screenSelectContainer = new QWidget();
|
||||||
@ -118,11 +128,30 @@ void UIWindow::startNewWallpaperEngine() {
|
|||||||
for (auto wallpaper : this->selectedWallpapers) {
|
for (auto wallpaper : this->selectedWallpapers) {
|
||||||
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()) {
|
||||||
|
for (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));
|
||||||
|
|
||||||
|
for (QString s : args) {
|
||||||
|
std::cout << s.toStdString();
|
||||||
|
}
|
||||||
|
std::cout << "\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// start Wallpaper Process
|
// start Wallpaper Process
|
||||||
wallpaperEngine->start(QCoreApplication::applicationFilePath(), args);
|
wallpaperEngine->start(QCoreApplication::applicationFilePath(), args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> UIWindow::split(std::string str, char delimiter) {
|
||||||
|
// Using str in a string stream
|
||||||
|
std::stringstream ss(str);
|
||||||
|
std::vector<std::string> res;
|
||||||
|
std::string token;
|
||||||
|
while (getline(ss, token, delimiter)) {
|
||||||
|
res.push_back(token);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <bits/stdc++.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
class UIWindow : public QWidget {
|
class UIWindow : public QWidget {
|
||||||
@ -33,7 +34,9 @@ class UIWindow : public QWidget {
|
|||||||
QComboBox* screenSelector;
|
QComboBox* screenSelector;
|
||||||
QLineEdit* extraFlagsInput;
|
QLineEdit* extraFlagsInput;
|
||||||
std::map<std::string, std::string> selectedWallpapers;
|
std::map<std::string, std::string> selectedWallpapers;
|
||||||
|
std::map<std::string, std::vector<std::string>> extraFlags;
|
||||||
QProcess* wallpaperEngine;
|
QProcess* wallpaperEngine;
|
||||||
|
|
||||||
void startNewWallpaperEngine();
|
void startNewWallpaperEngine();
|
||||||
|
static std::vector<std::string> split(std::string str, char r);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user