emmit applySettings at WallpaperSettingsWidget::update()

This commit is contained in:
delia 2025-08-28 16:59:58 +02:00
parent f078765987
commit 8ddc02649b
5 changed files with 31 additions and 6 deletions

View File

@ -50,7 +50,7 @@ UIWindow::UIWindow(QWidget* parent, QApplication* qapp, SingleInstanceManager* i
}
void UIWindow::setupUIWindow(std::vector<std::string> wallpaperPaths) {
this->setWindowTitle("Wallpapers :3");
this->setWindowTitle("Linux-WallpaperEngine");
this->setStyleSheet(R"(
QWidget {
@ -76,8 +76,9 @@ void UIWindow::setupUIWindow(std::vector<std::string> wallpaperPaths) {
button->setEnabled(false);
this->selectedWallpapers[this->screenSelector->currentText().toStdString()] = clickedPath.toStdString();
startNewWallpaperEngine();
// startNewWallpaperEngine();
// Doesn't need to start a new WallpaperEngine here since update wallpaperSettings does emit applySettings()
updateSelectedButton();
this->wallpaperSettingsWidget->update(this->selectedWallpapers[this->screenSelector->currentText().toStdString()]);
});
@ -218,6 +219,7 @@ void UIWindow::startNewWallpaperEngine() {
wallpaperEngine->waitForFinished();
}
}
// delete this->wallpaperEngine;
// create args
QStringList args;

View File

@ -1,7 +1,10 @@
#pragma once
#include "Qt/SingleInstanceManager.h"
#include <cstddef>
#include <cstdlib>
#include <map>
#include <new>
#include <qapplication.h>
#include <qboxlayout.h>
#include <qcombobox.h>

View File

@ -61,5 +61,4 @@ void WallpaperButton::resizeEvent(QResizeEvent* event) {
QToolButton::resizeEvent(event);
int size = std::min(event->size().width(), event->size().height()) * 0.8f;
setIconSize(QSize(size, size));
}

View File

@ -1,5 +1,6 @@
#include "WallpaperSettingsWidget.h"
#include <fstream>
#include <memory>
#include <nlohmann/json_fwd.hpp>
#include <qchar.h>
#include <qcheckbox.h>
@ -19,6 +20,8 @@
#include <QComboBox>
#include <variant>
#include <iostream>
#include "WallpaperEngine/Assets/CCombinedContainer.h"
#include "WallpaperEngine/Logging/CLog.h"
WallpaperSettingsWidget::WallpaperSettingsWidget(QWidget* parent)
: QWidget(parent) {
@ -91,7 +94,10 @@ void WallpaperSettingsWidget::update(const std::string& selected) {
// edit Title
preview.title->setText(QString::fromStdString(title));
file.close();
updateSettings(selected, wallpaperJSON);
apply();
}
QCheckBox* createStyledCheckBox(const QString& style) {
@ -104,7 +110,18 @@ void WallpaperSettingsWidget::updateSettings(const std::string& wallpaperPath, c
clearSettings();
// TODO: add individual settings depending on wallpaper
/*
auto general = wallpaper.find("general");
if (general != wallpaper.end()) {
if (general->find("properties") != general->end()) {
const auto properties = general->at("properties");
if (properties != nullptr) {
sLog.out(properties);
}
}
}
*/
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});
@ -146,8 +163,12 @@ void WallpaperSettingsWidget::clearSettings() {
if (item->widget()) {
delete item->widget();
}
if (item->layout()) {
delete item->layout();
}
delete item;
}
this->currentOptions.clear();
}

View File

@ -58,7 +58,7 @@ class WallpaperSettingsWidget : public QWidget {
" border: 1px solid gray;"
"}"
"QCheckBox::indicator:checked {"
" background-color: #4CAF50;"
" background-color:#4488FF;"
"}";
signals: