mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
fixed multible flags bug
This commit is contained in:
parent
5b9862ef6a
commit
23667d0a4c
@ -152,7 +152,6 @@ void UIWindow::setupUIWindow(std::vector<std::string> wallpaperPaths) {
|
||||
|
||||
QObject::connect(this->screenSelector, QOverload<int>::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<std::string> 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
|
||||
@ -265,6 +266,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;
|
||||
args.push_back("--screen-root");
|
||||
|
@ -54,6 +54,7 @@ class UIWindow : public QWidget {
|
||||
// Important Fields
|
||||
std::map<std::string, std::string> selectedWallpapers;
|
||||
std::map<std::string, std::vector<std::string>> extraFlags;
|
||||
std::string globalFlags;
|
||||
QProcess* wallpaperEngine;
|
||||
|
||||
std::string appDataPath;
|
||||
|
@ -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<QLineEdit*>(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<QComboBox*>(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);
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ struct Option {
|
||||
std::string optionName;
|
||||
std::string flag;
|
||||
bool flagHasValue;
|
||||
bool oneTimeFlag;
|
||||
|
||||
std::variant<bool, int, float, QString> 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:
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user