-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
11565 confirmation dialog for reset preferences and fixes #25400
Changes from all commits
d755e82
f35ac21
ef4f7bd
7093590
a57fe6f
97fcf55
de14305
3efe3c3
0e162bb
0354323
6505a2c
85e4df8
65dfd57
5644455
761d0b5
831cac7
2ba60a9
3d9a024
9550b82
9182f7c
9e4d37e
8072952
628dfa7
ebea4ba
0194b2d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,7 @@ bool AdvancedPreferencesModel::setData(const QModelIndex& index, const QVariant& | |
|
||
switch (role) { | ||
case ValueRole: | ||
changeVal(index.row(), value); | ||
changeVal(index.row(), Val::fromQVariant(value)); | ||
emit dataChanged(index, index, { ValueRole }); | ||
return true; | ||
default: | ||
|
@@ -96,28 +96,56 @@ void AdvancedPreferencesModel::load() | |
for (auto it = items.cbegin(); it != items.cend(); ++it) { | ||
if (it->second.canBeManuallyEdited) { | ||
m_items << it->second; | ||
|
||
muse::Settings::Key key = it->second.key; | ||
settings()->valueChanged(key).onReceive(this, [this, key](const Val& val) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe each subsequent call to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you elaborate? Each subsequent call is for a different setting (key) => different notification channel. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah sorry, you're definitely right! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No worries. Comments are always welcome. :) |
||
QModelIndex index = findIndex(key); | ||
if (!index.isValid() || m_items[index.row()].value == val) { | ||
return; | ||
} | ||
|
||
changeModelVal(m_items[index.row()], val); | ||
emit dataChanged(index, index, { ValueRole }); | ||
}); | ||
} | ||
} | ||
|
||
endResetModel(); | ||
} | ||
|
||
void AdvancedPreferencesModel::changeVal(int index, QVariant newVal) | ||
QModelIndex AdvancedPreferencesModel::findIndex(const muse::Settings::Key& key) | ||
{ | ||
for (int i = 0; i < m_items.size(); ++i) { | ||
if (m_items[i].key == key) { | ||
return index(i, 0); | ||
} | ||
} | ||
return QModelIndex(); | ||
} | ||
|
||
void AdvancedPreferencesModel::changeVal(int index, const Val& newVal) | ||
{ | ||
Settings::Item& item = m_items[index]; | ||
changeModelVal(item, newVal); | ||
settings()->setSharedValue(item.key, item.value); | ||
} | ||
|
||
void AdvancedPreferencesModel::changeModelVal(Settings::Item& item, const Val& newVal) | ||
{ | ||
if (item.value == newVal) { | ||
return; | ||
} | ||
Val::Type type = item.value.type(); | ||
item.value = Val::fromQVariant(newVal); | ||
item.value = newVal; | ||
item.value.setType(type); | ||
|
||
settings()->setSharedValue(item.key, item.value); | ||
} | ||
|
||
void AdvancedPreferencesModel::resetToDefault() | ||
{ | ||
beginResetModel(); | ||
|
||
for (int i = 0; i < m_items.size(); ++i) { | ||
changeVal(i, m_items[i].defaultValue.toQVariant()); | ||
changeVal(i, m_items[i].defaultValue); | ||
} | ||
|
||
endResetModel(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes were needed to properly update the Styles used for import controls on the Import page and fix these two bugs:
1. Open the Preferences dialog and navigate to the Import page.
2. Change Style used for import from Built-in style to Use style file.
3. Type a file if you want or skip this step.
4. Click Reset Preferences without closing the dialog.
Result: the Use style file radiobutton remains selected.
AND:
1. Open the Preferences dialog and navigate to the Import page.
2. Change Style used for import from Built-in style to Use style file.
3. Type something in the file textbox.
4. Delete the text in the file textbox.
Result: the Built-in style radiobutton becomes selected.