diff options
Diffstat (limited to 'src/UiGuiSettings.cpp')
-rw-r--r-- | src/UiGuiSettings.cpp | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/src/UiGuiSettings.cpp b/src/UiGuiSettings.cpp index b231577..baea1d9 100644 --- a/src/UiGuiSettings.cpp +++ b/src/UiGuiSettings.cpp @@ -23,6 +23,7 @@ #include <tqdatetime.h> #include <tqdir.h> #include <tqpoint.h> +#include <tqregexp.h> #include <tqsettings.h> #include <tqsize.h> #include <tqwidget.h> @@ -175,13 +176,35 @@ bool UiGuiSettings::setValueByName(const TQString &settingName, TQVariant value) */ void UiGuiSettings::loadSettings() { - // Read the version string saved in the settings file. + // Read the version string m_settings["VersionInSettingsFile"] = m_qsettings->readEntry("version", TQString::null); - // Read windows last size and position from the settings file. + // Read window's maximized status m_settings["WindowIsMaximized"] = m_qsettings->readBoolEntry("maximized", false); - m_settings["WindowPosition"] = m_qsettings->readEntry("position", "@Point(50, 50)"); - m_settings["WindowSize"] = m_qsettings->readEntry("size", "@Size(800, 600)"); + + // Read window's position + TQString positionString = m_qsettings->readEntry("position", "@Point(50 50)"); + TQRegExp posrx("@Point\\((-?\\d+)[ \\t]+(-?\\d+)\\)"); + TQPoint position(50, 50); + if (posrx.exactMatch(positionString.stripWhiteSpace())) + { + TQStringList posList = posrx.capturedTexts(); + position.setX(posList[1].toInt()); + position.setY(posList[2].toInt()); + } + m_settings["WindowPosition"] = position; + + // Read window's size + TQString sizeString = m_qsettings->readEntry("size", "@Size(800 600)"); + TQRegExp sizerx("@Size\\((-?\\d+)[ \\t]+(-?\\d+)\\)"); + TQSize size(800, 600); + if (sizerx.exactMatch(sizeString.stripWhiteSpace())) + { + TQStringList sizeList = sizerx.capturedTexts(); + size.setWidth(sizeList[1].toInt()); + size.setHeight(sizeList[2].toInt()); + } + m_settings["WindowSize"] = size; // Read last selected encoding for the opened source code file. m_settings["FileEncoding"] = m_qsettings->readEntry("encoding", "UTF-8"); @@ -241,13 +264,21 @@ void UiGuiSettings::loadSettings() */ void UiGuiSettings::saveSettings() { - // Write the version string saved in the settings file. + // Write the version string m_qsettings->writeEntry("version", m_settings["VersionInSettingsFile"].toString()); - // Write windows last size and position from the settings file. + // Write window's maximized status m_qsettings->writeEntry("maximized", m_settings["WindowIsMaximized"].toBool()); - m_qsettings->writeEntry("position", m_settings["WindowPosition"].toString()); - m_qsettings->writeEntry("size", m_settings["WindowSize"].toString()); + + // Write window's position + TQPoint position = m_settings["WindowPosition"].toPoint(); + TQString positionString = TQString("@Point(%1 %2)").arg(position.x()).arg(position.y()); + m_qsettings->writeEntry("position", positionString); + + // Write window's size + TQSize size = m_settings["WindowSize"].toSize(); + TQString sizeString = TQString("@Size(%1 %2)").arg(size.width()).arg(size.height()); + m_qsettings->writeEntry("size", sizeString); // Write last selected encoding for the opened source code file. m_qsettings->writeEntry("encoding", m_settings["FileEncoding"].toString()); |