From 8f96d8d5edc98fc1b7cacd02f3219e1a2f0fcab7 Mon Sep 17 00:00:00 2001 From: Javier Date: Sun, 14 Jun 2015 18:57:00 +0200 Subject: add saving of mainwindow state/geometry --- mainwindow.cc | 29 ++++++++++++++++++++++++----- mainwindow.h | 3 +++ scribiu.pro | 2 +- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/mainwindow.cc b/mainwindow.cc index 48a7de0..0610993 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -61,6 +62,13 @@ MainWindow::MainWindow(QWidget *parent) : this, SLOT(handleMediaTotalTimeChanged(qint64))); connect(_media, SIGNAL(tick(qint64)), this, SLOT(handleMediaTick(qint64))); + + QSettings settings; + settings.beginGroup("mainwindow"); + restoreGeometry(settings.value("geometry").toByteArray()); + restoreState(settings.value("state").toByteArray()); + ui->splitter->restoreState(settings.value("splitter").toByteArray()); + settings.endGroup(); } MainWindow::~MainWindow() @@ -324,6 +332,22 @@ void MainWindow::handleExport() } } +void MainWindow::handleAbout() +{ + QMessageBox::about(this, tr("About Scribiu"), tr("Read notebooks and audio notes from your Livescribe Echo pen")); +} + +void MainWindow::closeEvent(QCloseEvent *event) +{ + QSettings settings; + Q_UNUSED(event); + settings.beginGroup("mainwindow"); + settings.setValue("geometry", saveGeometry()); + settings.setValue("state", saveState()); + settings.setValue("splitter", ui->splitter->saveState()); + settings.endGroup(); +} + QString MainWindow::formatDuration(qint64 time) { int secs = time / 1000; @@ -339,8 +363,3 @@ QString MainWindow::formatDuration(qint64 time) return QString("%2:%3").arg(mins).arg(secs, 2, 10, fill); } } - -void MainWindow::handleAbout() -{ - QMessageBox::about(this, tr("About Scribiu"), tr("Read notebooks and audio notes from your Livescribe Echo pen")); -} diff --git a/mainwindow.h b/mainwindow.h index 3f6aafc..e176122 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -62,6 +62,9 @@ private slots: void handleExport(); void handleAbout(); +protected: + void closeEvent(QCloseEvent *event); + private: QString formatDuration(qint64 time); diff --git a/scribiu.pro b/scribiu.pro index f8247c2..a9b12d0 100644 --- a/scribiu.pro +++ b/scribiu.pro @@ -48,7 +48,7 @@ isEmpty(PREFIX) { target.path = $$PREFIX/bin -udev.path = /etc/udev/rules.d +udev.path = /lib/udev/rules.d udev.files = 60-livescribe.rules icon_scalable.path = $$PREFIX/share/icons/hicolor/scalable/apps -- cgit v1.2.3