diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-08-17 08:27:13 -0400 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2019-08-17 08:27:13 -0400 |
| commit | 7cc5f220520ab19940462fb6d2f660d8b7e2d600 (patch) | |
| tree | 0f66ecd267b063dbf6b519c0de2a34d06d30250c /src/settings.cpp | |
| parent | d9cb15f1d117b91f0d75c1b7702696f7da93d3d2 (diff) | |
put tutorials in the settings
finished moving endorsement to settings
Diffstat (limited to 'src/settings.cpp')
| -rw-r--r-- | src/settings.cpp | 55 |
1 files changed, 50 insertions, 5 deletions
diff --git a/src/settings.cpp b/src/settings.cpp index 882984f3..af32a082 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -39,6 +39,34 @@ std::optional<T> getOptional( } +EndorsementState endorsementStateFromString(const QString& s) +{ + if (s == "Endorsed") { + return EndorsementState::Accepted; + } else if (s == "Abstained") { + return EndorsementState::Refused; + } else { + return EndorsementState::NoDecision; + } +} + +QString toString(EndorsementState s) +{ + switch (s) + { + case EndorsementState::Accepted: + return "Endorsed"; + + case EndorsementState::Refused: + return "Abstained"; + + case EndorsementState::NoDecision: // fall-through + default: + return {}; + } +} + + QString widgetNameWithTopLevel(const QWidget* widget) { QStringList components; @@ -697,13 +725,17 @@ bool Settings::endorsementIntegration() const EndorsementState Settings::endorsementState() const { const auto v = getOptional<QString>(m_Settings, "endorse_state"); + return endorsementStateFromString(v.value_or("")); +} - if (!v) { - return EndorsementState::NoDecision; - } else if (*v == "Abstained") { - return EndorsementState::Refused; +void Settings::setEndorsementState(EndorsementState s) +{ + const auto v = toString(s); + + if (v.isEmpty()) { + m_Settings.remove("endorse_state"); } else { - return EndorsementState::Accepted; + m_Settings.setValue("endorse_state", v); } } @@ -935,6 +967,19 @@ void Settings::setExecutables(const std::vector<std::map<QString, QVariant>>& v) m_Settings.endArray(); } +bool Settings::isTutorialCompleted(const QString& windowName) const +{ + const auto v = getOptional<bool>( + m_Settings, "CompletedWindowTutorials/" + windowName); + + return v.value_or(false); +} + +void Settings::setTutorialCompleted(const QString& windowName, bool b) +{ + m_Settings.setValue("CompletedWindowTutorials/" + windowName, true); +} + std::optional<int> Settings::getIndex(QComboBox* cb) const { return getOptional<int>(m_Settings, indexSettingName(cb)); |
