1 #include "MainWindow.h"
17 setWindowTitle(title);
42 QString MainWindow::settingsFileName(QString objectTitle) {
43 if (QApplication::applicationName() ==
"") {
45 "application name before using the Isis::MainWindow class. Window "
46 "state and geometry can not be saved and restored",
_FILEINFO_);
49 if (objectTitle ==
"") {
51 tr(
"You must provide a valid objectTitle to MainWindow::settingsFileName"),
55 QDir programSettings =
56 QDir(FileName(
"$HOME/.Isis/" + QApplication::applicationName() +
"/").path());
57 QString windowSettings = programSettings.filePath(objectTitle +
".config");
59 return windowSettings;
80 QSettings settings(settingsFileName(), QSettings::NativeFormat);
81 restoreGeometry(settings.value(
"geometry").toByteArray());
82 restoreState(settings.value(
"windowState").toByteArray());
87 if (!settings.value(
"pos").toPoint().isNull())
88 move(settings.value(
"pos").toPoint());
90 resize(settings.value(
"size", defaultSize).toSize());
94 QString MainWindow::settingsFileName()
const {
95 if (QApplication::applicationName() ==
"") {
97 "application name before using the Isis::MainWindow class. Window "
98 "state and geometry can not be saved and restored",
_FILEINFO_);
101 if (objectName() ==
"") {
103 tr(
"You must set the objectName of the widget titled [%1] before "
104 "using the instance. Window state and geometry can not be saved and "
108 QDir programSettings =
109 QDir(FileName(
"$HOME/.Isis/" + QApplication::applicationName() +
"/").path());
110 QString windowSettings = programSettings.filePath(objectName() +
".config");
112 return windowSettings;
123 QSettings settings(settingsFileName(), QSettings::NativeFormat);
125 settings.setValue(
"geometry", saveGeometry());
126 settings.setValue(
"windowState", saveState());
127 settings.setValue(
"size", size());
128 settings.setValue(
"pos", pos());