fixed multible flags bug

This commit is contained in:
delia 2025-09-09 17:38:07 +02:00
parent 5b9862ef6a
commit 23667d0a4c
4 changed files with 39 additions and 21 deletions

View File

@ -152,7 +152,6 @@ void UIWindow::setupUIWindow(std::vector<std::string> wallpaperPaths) {
QObject::connect(this->screenSelector, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) { QObject::connect(this->screenSelector, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) {
updateSelectedButton(); updateSelectedButton();
sLog.out(this->selectedWallpapers[this->screenSelector->currentText().toStdString()]);
this->wallpaperSettingsWidget->update(this->selectedWallpapers[this->screenSelector->currentText().toStdString()]); this->wallpaperSettingsWidget->update(this->selectedWallpapers[this->screenSelector->currentText().toStdString()]);
}); });
@ -186,8 +185,9 @@ void UIWindow::setupUIWindow(std::vector<std::string> wallpaperPaths) {
// right side // right side
this->wallpaperSettingsWidget = new WallpaperSettingsWidget(splitWidget); this->wallpaperSettingsWidget = new WallpaperSettingsWidget(splitWidget);
connect(this->wallpaperSettingsWidget, &WallpaperSettingsWidget::applySettings, this, [this](const std::string& flags) { connect(this->wallpaperSettingsWidget, &WallpaperSettingsWidget::applySettings, this, [this](const std::string& flags, const std::string& individualFlags) {
this->extraFlags[this->screenSelector->currentText().toStdString()] = split(flags, ' '); globalFlags = flags;
this->extraFlags[this->screenSelector->currentText().toStdString()] = split(individualFlags, ' ');
startNewWallpaperEngine(); startNewWallpaperEngine();
// updateStoredSelectedWallpapers(); // updateStoredSelectedWallpapers();
}); });
@ -240,18 +240,19 @@ void UIWindow::showEvent(QShowEvent* event) {
void UIWindow::closeEvent(QCloseEvent* event) { void UIWindow::closeEvent(QCloseEvent* event) {
this->hide(); this->hide();
updateStoredSelectedWallpapers();
event->ignore(); event->ignore();
} }
void UIWindow::startNewWallpaperEngine() { void UIWindow::startNewWallpaperEngine() {
sLog.out("Start new WallpaperEngine..");
for (const auto& n : this->extraFlags) { for (const auto& n : this->extraFlags) {
std::string str; std::string str;
for (const auto& s : n.second) { for (const auto& s : n.second) {
str.append(s); str.append(s);
} }
sLog.out(n.first + " | " + str);
} }
if (wallpaperEngine->state() == QProcess::Running) { if (wallpaperEngine->state() == QProcess::Running) {
// Stop WallpaperProcess // Stop WallpaperProcess
@ -264,6 +265,10 @@ void UIWindow::startNewWallpaperEngine() {
} }
// create args // create args
QStringList args; QStringList args;
for (const auto& f : split(globalFlags, ' ')) {
args.push_back(QString::fromStdString(f));
}
for (const auto &wallpaper : this->selectedWallpapers) { for (const auto &wallpaper : this->selectedWallpapers) {
if (wallpaper.first == "" || wallpaper.second == "") continue; if (wallpaper.first == "" || wallpaper.second == "") continue;

View File

@ -54,6 +54,7 @@ class UIWindow : public QWidget {
// Important Fields // Important Fields
std::map<std::string, std::string> selectedWallpapers; std::map<std::string, std::string> selectedWallpapers;
std::map<std::string, std::vector<std::string>> extraFlags; std::map<std::string, std::vector<std::string>> extraFlags;
std::string globalFlags;
QProcess* wallpaperEngine; QProcess* wallpaperEngine;
std::string appDataPath; std::string appDataPath;

View File

@ -131,16 +131,16 @@ void WallpaperSettingsWidget::updateSettings(const std::string& wallpaperPath, c
auto* clampingBox = new QComboBox(); auto* clampingBox = new QComboBox();
// clampingBox->addItems({"clamp", "border", "repeat"}); // clampingBox->addItems({"clamp", "border", "repeat"});
this->currentOptions.push_back({createStyledCheckBox(this->checkboxStyleSheet), "Mute Audio:", "mute_audio", "--silent", false, false}); this->currentOptions.push_back({createStyledCheckBox(this->checkboxStyleSheet), "Mute Audio:", "mute_audio", "--silent", false, true, false});
this->currentOptions.push_back({new QSlider(Qt::Horizontal), "Volume:", "volume", "--volume", true, 50}); this->currentOptions.push_back({new QSlider(Qt::Horizontal), "Volume:", "volume", "--volume", true, true, 50});
this->currentOptions.push_back({createStyledCheckBox(this->checkboxStyleSheet), "Disable Automute:", "disable_automute", "--noautomute", false, false}); this->currentOptions.push_back({createStyledCheckBox(this->checkboxStyleSheet), "Disable Automute:", "disable_automute", "--noautomute", false, true, false});
this->currentOptions.push_back({createStyledCheckBox(this->checkboxStyleSheet), "Disable Audio Reaction:", "disable_audio_reaction", "--no-audio-processing", false, false}); this->currentOptions.push_back({createStyledCheckBox(this->checkboxStyleSheet), "Disable Audio Reaction:", "disable_audio_reaction", "--no-audio-processing", false, true, false});
this->currentOptions.push_back({new QLineEdit(), "FPS:", "fps", "--fps", true, 30}); this->currentOptions.push_back({new QLineEdit(), "FPS:", "fps", "--fps", true, true, 30});
this->currentOptions.push_back({scalingBox, "Scaling:", "scaling", "--scaling", true, "default"}); this->currentOptions.push_back({scalingBox, "Scaling:", "scaling", "--scaling", true, false, "default"});
this->currentOptions.push_back({clampingBox, "Clamping:", "clamping", "--clamping", true, ""}); this->currentOptions.push_back({clampingBox, "Clamping:", "clamping", "--clamping", true, false, ""});
this->currentOptions.push_back({createStyledCheckBox(this->checkboxStyleSheet), "Disable Mouse:", "diable_mouse", "--disable-mouse", false, false}); this->currentOptions.push_back({createStyledCheckBox(this->checkboxStyleSheet), "Disable Mouse:", "diable_mouse", "--disable-mouse", false, true, false});
this->currentOptions.push_back({createStyledCheckBox(this->checkboxStyleSheet), "Disable Parallax", "disable_parallax", "--disable-parallax", false, true}); this->currentOptions.push_back({createStyledCheckBox(this->checkboxStyleSheet), "Disable Parallax", "disable_parallax", "--disable-parallax", false, true, true});
this->currentOptions.push_back({createStyledCheckBox(this->checkboxStyleSheet), "Disable Fullscreen Pause:", "disable_fullscreen_pause", "--no-fullscreen-pause", true, false}); this->currentOptions.push_back({createStyledCheckBox(this->checkboxStyleSheet), "Disable Fullscreen Pause:", "disable_fullscreen_pause", "--no-fullscreen-pause", true, true, false});
for (const Option& opt : this->currentOptions) { for (const Option& opt : this->currentOptions) {
this->settingsLayout->addRow(opt.labelName, opt.widget); this->settingsLayout->addRow(opt.labelName, opt.widget);
@ -189,6 +189,7 @@ void WallpaperSettingsWidget::clearSettings() {
void WallpaperSettingsWidget::apply() { void WallpaperSettingsWidget::apply() {
if (currentWallpaperPath.empty()) return; if (currentWallpaperPath.empty()) return;
std::string individualFlag;
std::string flags; std::string flags;
for (const Option& opt : this->currentOptions) { for (const Option& opt : this->currentOptions) {
@ -207,16 +208,26 @@ void WallpaperSettingsWidget::apply() {
} }
if (auto* lineEdit = dynamic_cast<QLineEdit*>(opt.widget)) { if (auto* lineEdit = dynamic_cast<QLineEdit*>(opt.widget)) {
std::string value = lineEdit->text().toStdString(); std::string value = lineEdit->text().toStdString();
flags.append(opt.flag + " "); if (opt.oneTimeFlag) {
if (opt.flagHasValue) flags.append(value + " "); flags.append(opt.flag + " ");
if (opt.flagHasValue) flags.append(value + " ");
} else {
individualFlag.append(opt.flag + " ");
if (opt.flagHasValue) individualFlag.append(value + " ");
}
continue; continue;
} }
if (auto* comboBox = dynamic_cast<QComboBox*>(opt.widget)) { if (auto* comboBox = dynamic_cast<QComboBox*>(opt.widget)) {
QString value = comboBox->currentText(); QString value = comboBox->currentText();
flags.append(opt.flag + " "); if (opt.oneTimeFlag) {
if (opt.flagHasValue) flags.append(value.toStdString() + " "); flags.append(opt.flag + " ");
if (opt.flagHasValue) flags.append(value.toStdString() + " ");
} else {
individualFlag.append(opt.flag + " ");
if (opt.flagHasValue) individualFlag.append(value.toStdString() + " ");
}
continue; continue;
} }
} }
emit applySettings(flags); emit applySettings(flags, individualFlag);
} }

View File

@ -25,6 +25,7 @@ struct Option {
std::string optionName; std::string optionName;
std::string flag; std::string flag;
bool flagHasValue; bool flagHasValue;
bool oneTimeFlag;
std::variant<bool, int, float, QString> defaultValue; std::variant<bool, int, float, QString> defaultValue;
}; };
@ -62,7 +63,7 @@ class WallpaperSettingsWidget : public QWidget {
"}"; "}";
signals: signals:
void applySettings(const std::string& flags); void applySettings(const std::string& flags, const std::string& individualFlags);
protected: protected:
}; };