diff options
author | Michele Calgaro <[email protected]> | 2023-04-08 14:41:17 +0900 |
---|---|---|
committer | Michele Calgaro <[email protected]> | 2023-04-08 14:41:17 +0900 |
commit | b4d35ab97d008c3b24a109640d90dba73215631b (patch) | |
tree | 78ef92df7a05944abbbc564df9d2789e42d1220a /src/UiGuiSettings.cpp | |
parent | 191e11f6dc9f8ac42f39a8866a8f4dfb4f75433c (diff) | |
download | universal-indent-gui-tqt-b4d35ab97d008c3b24a109640d90dba73215631b.tar.gz universal-indent-gui-tqt-b4d35ab97d008c3b24a109640d90dba73215631b.zip |
Settings for syntax highlighting, showing whitespaces and loading last open file are now saved and restored across executions
Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'src/UiGuiSettings.cpp')
-rw-r--r-- | src/UiGuiSettings.cpp | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/src/UiGuiSettings.cpp b/src/UiGuiSettings.cpp index baea1d9..e4ab510 100644 --- a/src/UiGuiSettings.cpp +++ b/src/UiGuiSettings.cpp @@ -53,6 +53,11 @@ UiGuiSettings::UiGuiSettings() : TQObject() m_qsettings->beginGroup("universalindentgui/UniversalIndentGUI"); m_indenterDirectoryStr = SettingsPaths::getGlobalFilesPath() + "/indenters"; + + m_actionSettings["actionEnableSyntaxHighlighting"] = "SyntaxHighlightingEnabled"; + m_actionSettings["actionLoadLastOpenedFileOnStartup"] = "LoadLastOpenedFileOnStartup"; + m_actionSettings["actionWhiteSpaceIsVisible"] = "WhiteSpaceIsVisible"; + readAvailableTranslations(); loadSettings(); } @@ -229,8 +234,8 @@ void UiGuiSettings::loadSettings() m_settings["SelectedIndenter"] = selectedIndenter; // Read if syntax highlighting is enabled. - m_settings["SyntaxHighlightningEnabled"] = m_qsettings->readBoolEntry( - "SyntaxHighlightningEnabled", true); + m_settings["SyntaxHighlightingEnabled"] = m_qsettings->readBoolEntry( + "SyntaxHighlightingEnabled", true); // Read if white space characters should be displayed. m_settings["WhiteSpaceIsVisible"] = m_qsettings->readBoolEntry("whiteSpaceIsVisible", false); @@ -297,8 +302,8 @@ void UiGuiSettings::saveSettings() m_qsettings->writeEntry("selectedIndenter", m_settings["SelectedIndenter"].toInt()); // Write if syntax highlighting is enabled. - m_qsettings->writeEntry("SyntaxHighlightningEnabled", - m_settings["SyntaxHighlightningEnabled"].toBool()); + m_qsettings->writeEntry("SyntaxHighlightingEnabled", + m_settings["SyntaxHighlightingEnabled"].toBool()); // Write if white space characters should be displayed. m_qsettings->writeEntry("whiteSpaceIsVisible", m_settings["WhiteSpaceIsVisible"].toBool()); @@ -318,8 +323,44 @@ void UiGuiSettings::saveSettings() //m_qsettings->writeEntry("MainWindowState", m_settings["MainWindowState"].toByteArray()); } +/* + \brief Extern widgets can connect to this slot to change settings. + + According to the objects property "connectedSettingName" the corresponding + setting is known and set. + */ +void UiGuiSettings::handleValueChangeFromExtern(bool value) +{ + if (sender()) + { + // Get the corresponding setting name from the sender objects property + TQString senderName = TQString(sender()->name()); + if (m_actionSettings.contains(senderName)) + { + TQString settingName = m_actionSettings[senderName]; + + // Set the value of the setting to the objects value. + setValueByName(settingName, value); + tqWarning("MIKE set="+settingName); + } + } +} + void UiGuiSettings::emitSignalForSetting(TQString settingName) { + // Emit the signal for the changed value. + if (settingName == "LoadLastOpenedFileOnStartup") + { + emit loadLastOpenedFileOnStartup(m_settings[settingName].toBool()); + } + else if (settingName == "SyntaxHighlightingEnabled") + { + emit syntaxHighlightingEnabled(m_settings[settingName].toBool()); + } + else if (settingName == "WhiteSpaceIsVisible") + { + emit whiteSpaceIsVisible(m_settings[settingName].toBool()); + } } /* |