diff --git a/src/Qt/UIWindow.cpp b/src/Qt/UIWindow.cpp index 02fd3fe..82bf059 100644 --- a/src/Qt/UIWindow.cpp +++ b/src/Qt/UIWindow.cpp @@ -152,7 +152,6 @@ void UIWindow::setupUIWindow(std::vector wallpaperPaths) { QObject::connect(this->screenSelector, QOverload::of(&QComboBox::currentIndexChanged), [this](int index) { updateSelectedButton(); - sLog.out(this->selectedWallpapers[this->screenSelector->currentText().toStdString()]); this->wallpaperSettingsWidget->update(this->selectedWallpapers[this->screenSelector->currentText().toStdString()]); }); @@ -186,8 +185,9 @@ void UIWindow::setupUIWindow(std::vector wallpaperPaths) { // right side this->wallpaperSettingsWidget = new WallpaperSettingsWidget(splitWidget); - connect(this->wallpaperSettingsWidget, &WallpaperSettingsWidget::applySettings, this, [this](const std::string& flags) { - this->extraFlags[this->screenSelector->currentText().toStdString()] = split(flags, ' '); + connect(this->wallpaperSettingsWidget, &WallpaperSettingsWidget::applySettings, this, [this](const std::string& flags, const std::string& individualFlags) { + globalFlags = flags; + this->extraFlags[this->screenSelector->currentText().toStdString()] = split(individualFlags, ' '); startNewWallpaperEngine(); // updateStoredSelectedWallpapers(); }); @@ -240,18 +240,19 @@ void UIWindow::showEvent(QShowEvent* event) { void UIWindow::closeEvent(QCloseEvent* event) { this->hide(); + + updateStoredSelectedWallpapers(); + event->ignore(); } void UIWindow::startNewWallpaperEngine() { - sLog.out("Start new WallpaperEngine.."); for (const auto& n : this->extraFlags) { std::string str; for (const auto& s : n.second) { str.append(s); } - sLog.out(n.first + " | " + str); } if (wallpaperEngine->state() == QProcess::Running) { // Stop WallpaperProcess @@ -264,6 +265,10 @@ void UIWindow::startNewWallpaperEngine() { } // create args QStringList args; + + for (const auto& f : split(globalFlags, ' ')) { + args.push_back(QString::fromStdString(f)); + } for (const auto &wallpaper : this->selectedWallpapers) { if (wallpaper.first == "" || wallpaper.second == "") continue; diff --git a/src/Qt/UIWindow.h b/src/Qt/UIWindow.h index 29a4793..3013d1e 100644 --- a/src/Qt/UIWindow.h +++ b/src/Qt/UIWindow.h @@ -54,6 +54,7 @@ class UIWindow : public QWidget { // Important Fields std::map selectedWallpapers; std::map> extraFlags; + std::string globalFlags; QProcess* wallpaperEngine; std::string appDataPath; diff --git a/src/Qt/WallpaperSettingsWidget.cpp b/src/Qt/WallpaperSettingsWidget.cpp index fa6c3e4..b110a26 100644 --- a/src/Qt/WallpaperSettingsWidget.cpp +++ b/src/Qt/WallpaperSettingsWidget.cpp @@ -131,16 +131,16 @@ void WallpaperSettingsWidget::updateSettings(const std::string& wallpaperPath, c auto* clampingBox = new QComboBox(); // clampingBox->addItems({"clamp", "border", "repeat"}); - this->currentOptions.push_back({createStyledCheckBox(this->checkboxStyleSheet), "Mute Audio:", "mute_audio", "--silent", false, false}); - this->currentOptions.push_back({new QSlider(Qt::Horizontal), "Volume:", "volume", "--volume", true, 50}); - this->currentOptions.push_back({createStyledCheckBox(this->checkboxStyleSheet), "Disable Automute:", "disable_automute", "--noautomute", false, false}); - this->currentOptions.push_back({createStyledCheckBox(this->checkboxStyleSheet), "Disable Audio Reaction:", "disable_audio_reaction", "--no-audio-processing", false, false}); - this->currentOptions.push_back({new QLineEdit(), "FPS:", "fps", "--fps", true, 30}); - this->currentOptions.push_back({scalingBox, "Scaling:", "scaling", "--scaling", true, "default"}); - this->currentOptions.push_back({clampingBox, "Clamping:", "clamping", "--clamping", true, ""}); - this->currentOptions.push_back({createStyledCheckBox(this->checkboxStyleSheet), "Disable Mouse:", "diable_mouse", "--disable-mouse", false, false}); - this->currentOptions.push_back({createStyledCheckBox(this->checkboxStyleSheet), "Disable Parallax", "disable_parallax", "--disable-parallax", false, 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), "Mute Audio:", "mute_audio", "--silent", false, true, false}); + 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, true, 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, true, 30}); + this->currentOptions.push_back({scalingBox, "Scaling:", "scaling", "--scaling", true, false, "default"}); + this->currentOptions.push_back({clampingBox, "Clamping:", "clamping", "--clamping", true, 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, true}); + 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) { this->settingsLayout->addRow(opt.labelName, opt.widget); @@ -189,6 +189,7 @@ void WallpaperSettingsWidget::clearSettings() { void WallpaperSettingsWidget::apply() { if (currentWallpaperPath.empty()) return; + std::string individualFlag; std::string flags; for (const Option& opt : this->currentOptions) { @@ -207,16 +208,26 @@ void WallpaperSettingsWidget::apply() { } if (auto* lineEdit = dynamic_cast(opt.widget)) { std::string value = lineEdit->text().toStdString(); - flags.append(opt.flag + " "); - if (opt.flagHasValue) flags.append(value + " "); + if (opt.oneTimeFlag) { + flags.append(opt.flag + " "); + if (opt.flagHasValue) flags.append(value + " "); + } else { + individualFlag.append(opt.flag + " "); + if (opt.flagHasValue) individualFlag.append(value + " "); + } continue; } if (auto* comboBox = dynamic_cast(opt.widget)) { QString value = comboBox->currentText(); - flags.append(opt.flag + " "); - if (opt.flagHasValue) flags.append(value.toStdString() + " "); + if (opt.oneTimeFlag) { + flags.append(opt.flag + " "); + if (opt.flagHasValue) flags.append(value.toStdString() + " "); + } else { + individualFlag.append(opt.flag + " "); + if (opt.flagHasValue) individualFlag.append(value.toStdString() + " "); + } continue; } } - emit applySettings(flags); + emit applySettings(flags, individualFlag); } diff --git a/src/Qt/WallpaperSettingsWidget.h b/src/Qt/WallpaperSettingsWidget.h index f4715b0..d805834 100644 --- a/src/Qt/WallpaperSettingsWidget.h +++ b/src/Qt/WallpaperSettingsWidget.h @@ -25,6 +25,7 @@ struct Option { std::string optionName; std::string flag; bool flagHasValue; + bool oneTimeFlag; std::variant defaultValue; }; @@ -62,7 +63,7 @@ class WallpaperSettingsWidget : public QWidget { "}"; signals: - void applySettings(const std::string& flags); + void applySettings(const std::string& flags, const std::string& individualFlags); protected: };