From 12aea5986764722ad0e24dd944eaf40b4db3c891 Mon Sep 17 00:00:00 2001 From: "Srivats P." Date: Thu, 14 Apr 2011 22:38:39 +0530 Subject: [PATCH] At exit Ostinato main window geometry and layout is saved and restored next time you open Ostinato --- client/mainwindow.cpp | 19 +++++++++++++++++++ client/settings.h | 7 +++++++ 2 files changed, 26 insertions(+) diff --git a/client/mainwindow.cpp b/client/mainwindow.cpp index 623624f..03a16ab 100644 --- a/client/mainwindow.cpp +++ b/client/mainwindow.cpp @@ -27,6 +27,7 @@ along with this program. If not, see #include "portstatswindow.h" #include "portswindow.h" #include "preferences.h" +#include "settings.h" #include "ui_about.h" #include @@ -62,7 +63,13 @@ MainWindow::MainWindow(QWidget *parent) portsWindow = new PortsWindow(pgl, this); statsWindow = new PortStatsWindow(pgl, this); portsDock = new QDockWidget(tr("Ports and Streams"), this); + portsDock->setObjectName("portsDock"); + portsDock->setFeatures( + portsDock->features() & ~QDockWidget::DockWidgetClosable); statsDock = new QDockWidget(tr("Statistics"), this); + statsDock->setObjectName("statsDock"); + statsDock->setFeatures( + statsDock->features() & ~QDockWidget::DockWidgetClosable); setupUi(this); @@ -73,6 +80,14 @@ MainWindow::MainWindow(QWidget *parent) portsDock->setWidget(portsWindow); addDockWidget(Qt::TopDockWidgetArea, portsDock); + QRect geom = appSettings->value(kApplicationWindowGeometryKey).toRect(); + if (!geom.isNull()) + setGeometry(geom); + QByteArray layout = appSettings->value(kApplicationWindowLayout) + .toByteArray(); + if (layout.size()) + restoreState(layout, 0); + connect(actionFileExit, SIGNAL(triggered()), this, SLOT(close())); connect(actionAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt())); #if 0 @@ -89,6 +104,10 @@ MainWindow::~MainWindow() localServer_->terminate(); localServer_->waitForFinished(); delete localServer_; + + QByteArray layout = saveState(0); + appSettings->setValue(kApplicationWindowLayout, layout); + appSettings->setValue(kApplicationWindowGeometryKey, geometry()); } void MainWindow::on_actionPreferences_triggered() diff --git a/client/settings.h b/client/settings.h index 2f0666c..d76bb47 100644 --- a/client/settings.h +++ b/client/settings.h @@ -74,6 +74,13 @@ const QString kAwkPathDefaultValue("/usr/bin/awk"); const QString kAwkPathDefaultValue("/usr/bin/awk"); #endif + +// +// LastUse Section Keys +// +const QString kApplicationWindowGeometryKey("LastUse/ApplicationWindowGeometry"); +const QString kApplicationWindowLayout("LastUse/ApplicationWindowLayout"); + #endif