implement automatic applying

This commit is contained in:
Jussi Kuokkanen
2023-09-16 16:02:52 +03:00
parent cf47eca15f
commit bc8fafe5f9
3 changed files with 9 additions and 1 deletions

View File

@@ -74,6 +74,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
Globals::g_settingsData = Settings::readSettings(); Globals::g_settingsData = Settings::readSettings();
Utils::setModelAssignableSettings(*model, Globals::g_settingsData.assignableSettings); Utils::setModelAssignableSettings(*model, Globals::g_settingsData.assignableSettings);
if (Globals::g_settingsData.autoApplyProfile)
model->applyChanges();
Utils::writeAssignableDefaults(*model); Utils::writeAssignableDefaults(*model);
} }

View File

@@ -62,8 +62,12 @@ DeviceBrowser::DeviceBrowser(DeviceModel &model, QWidget *parent)
connect(m_settings, &Settings::settingsSaved, [=](auto data) { connect(m_settings, &Settings::settingsSaved, [=](auto data) {
Globals::g_mainStack->setCurrentWidget(this); Globals::g_mainStack->setCurrentWidget(this);
// No-op when data.assignableSettings is empty
Utils::setModelAssignableSettings( Utils::setModelAssignableSettings(
*Globals::g_deviceModel, data.assignableSettings); *Globals::g_deviceModel, data.assignableSettings);
if (data.autoApplyProfile && data.currentProfile.has_value())
m_deviceModel.applyChanges();
}); });
} }
Globals::g_mainStack->setCurrentWidget(m_settings); Globals::g_mainStack->setCurrentWidget(m_settings);

View File

@@ -101,7 +101,7 @@ void Settings::setUIState(SettingsData data) {
SettingsData Settings::fromUIState() { SettingsData Settings::fromUIState() {
std::optional<QString> currentProfile = std::nullopt; std::optional<QString> currentProfile = std::nullopt;
if (m_profileView->currentItem()) { if (m_profileView->currentItem() && m_useProfile->isChecked()) {
auto data = m_profileView->currentItem()->data(Qt::DisplayRole); auto data = m_profileView->currentItem()->data(Qt::DisplayRole);
if (data.isValid()) if (data.isValid())
currentProfile = data.toString(); currentProfile = data.toString();