1 #include "MainWindow.h" 18 setWindowTitle(title);
39 QMainWindow::closeEvent(event);
43 QString MainWindow::settingsFileName(QString objectTitle) {
44 if (QCoreApplication::applicationName() ==
"") {
46 "application name before using the Isis::MainWindow class. Window " 47 "state and geometry can not be saved and restored",
_FILEINFO_);
50 if (objectTitle ==
"") {
52 tr(
"You must provide a valid objectTitle to MainWindow::settingsFileName"),
56 QDir programSettings =
57 QDir(FileName(
"$HOME/.Isis/" + QCoreApplication::applicationName() +
"/").path());
58 QString windowSettings = programSettings.filePath(objectTitle +
".config");
60 return windowSettings;
82 QSettings settings(settingsFileName(), QSettings::NativeFormat);
83 restoreGeometry(settings.value(
"geometry").toByteArray());
84 restoreState(settings.value(
"windowState").toByteArray());
89 if (!settings.value(
"pos").toPoint().isNull())
90 move(settings.value(
"pos").toPoint());
92 resize(settings.value(
"size", defaultSize).toSize());
96 QString MainWindow::settingsFileName()
const {
97 if (QCoreApplication::applicationName() ==
"") {
99 "application name before using the Isis::MainWindow class. Window " 100 "state and geometry can not be saved and restored",
_FILEINFO_);
103 if (objectName() ==
"") {
105 tr(
"You must set the objectName of the widget titled [%1] before " 106 "using the instance. Window state and geometry can not be saved and " 110 QDir programSettings =
111 QDir(FileName(
"$HOME/.Isis/" + QCoreApplication::applicationName() +
"/").path());
112 QString windowSettings = programSettings.filePath(objectName() +
".config");
114 return windowSettings;
126 QSettings settings(settingsFileName(), QSettings::NativeFormat);
128 settings.setValue(
"geometry", saveGeometry());
129 settings.setValue(
"windowState", saveState());
130 settings.setValue(
"size", size());
131 settings.setValue(
"pos", pos());
virtual void readSettings(QSize defaultSize=QSize())
This method ensure that the settings get written even if the Main window was only hidden...
This error is for when a programmer made an API call that was illegal.
MainWindow(QString title, QWidget *parent=0, Qt::WindowFlags flags=0)
Mainwindow constructor.
virtual void closeEvent(QCloseEvent *event)
This method is overridden so that we can be sure to write the current settings of the Main window...
#define _FILEINFO_
Macro for the filename and line number.
Namespace for ISIS/Bullet specific routines.
virtual void writeSettings() const
This method is called when the Main window is closed or hidden to write the size and location setting...
virtual ~MainWindow()
Free allocated memory by from this instance.