mirror of
https://github.com/Lurkki14/tuxclocker.git
synced 2025-02-25 18:55:24 -06:00
implement automatic applying
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user