From d2814e2dd8f2a22590a16940f67731de04b1633f Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Thu, 1 Jul 2021 15:28:43 +0100 Subject: [PATCH 1/3] Save and restore position and size of main window between invocations. Fixes #89 --- sdrgui/mainwindow.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sdrgui/mainwindow.cpp b/sdrgui/mainwindow.cpp index e84ecfd90..60f57d1cc 100644 --- a/sdrgui/mainwindow.cpp +++ b/sdrgui/mainwindow.cpp @@ -269,6 +269,11 @@ MainWindow::MainWindow(qtwebapp::LoggerWithFile *logger, const MainParser& parse delete splash; + // Restore window size and position + QSettings s; + restoreGeometry(s.value("mainWindowGeometry").toByteArray()); + restoreState(s.value("mainWindowState").toByteArray()); + qDebug() << "MainWindow::MainWindow: end"; } @@ -850,6 +855,11 @@ void MainWindow::closeEvent(QCloseEvent *closeEvent) { qDebug("MainWindow::closeEvent"); + // Save window size and position + QSettings s; + s.setValue("mainWindowGeometry", saveGeometry()); + s.setValue("mainWindowState", saveState()); + savePresetSettings(m_mainCore->m_settings.getWorkingPreset(), 0); saveFeatureSetPresetSettings(m_mainCore->m_settings.getWorkingFeatureSetPreset(), 0); m_mainCore->m_settings.save(); From b949a19808a84b02f91d93d736fe5b7f374d1cf3 Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Thu, 1 Jul 2021 16:07:25 +0100 Subject: [PATCH 2/3] Save settings in base64 for linux compatibility --- sdrgui/mainwindow.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sdrgui/mainwindow.cpp b/sdrgui/mainwindow.cpp index 60f57d1cc..61b8b59ed 100644 --- a/sdrgui/mainwindow.cpp +++ b/sdrgui/mainwindow.cpp @@ -271,8 +271,8 @@ MainWindow::MainWindow(qtwebapp::LoggerWithFile *logger, const MainParser& parse // Restore window size and position QSettings s; - restoreGeometry(s.value("mainWindowGeometry").toByteArray()); - restoreState(s.value("mainWindowState").toByteArray()); + restoreGeometry(qUncompress(QByteArray::fromBase64(s.value("mainWindowGeometry").toByteArray()))); + restoreState(qUncompress(QByteArray::fromBase64(s.value("mainWindowState").toByteArray()))); qDebug() << "MainWindow::MainWindow: end"; } @@ -856,9 +856,10 @@ void MainWindow::closeEvent(QCloseEvent *closeEvent) qDebug("MainWindow::closeEvent"); // Save window size and position + // Need to use base64, as it seems binary values aren't saved on Linux QSettings s; - s.setValue("mainWindowGeometry", saveGeometry()); - s.setValue("mainWindowState", saveState()); + s.setValue("mainWindowGeometry", qCompress(saveGeometry()).toBase64()); + s.setValue("mainWindowState", qCompress(saveState()).toBase64()); savePresetSettings(m_mainCore->m_settings.getWorkingPreset(), 0); saveFeatureSetPresetSettings(m_mainCore->m_settings.getWorkingFeatureSetPreset(), 0); From 6a6b2b3ecae9d1d3889152a9f77b9860f17ae60d Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Thu, 1 Jul 2021 16:16:24 +0100 Subject: [PATCH 3/3] Remove incorrect comment. --- sdrgui/mainwindow.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/sdrgui/mainwindow.cpp b/sdrgui/mainwindow.cpp index 61b8b59ed..6e5c3d283 100644 --- a/sdrgui/mainwindow.cpp +++ b/sdrgui/mainwindow.cpp @@ -856,7 +856,6 @@ void MainWindow::closeEvent(QCloseEvent *closeEvent) qDebug("MainWindow::closeEvent"); // Save window size and position - // Need to use base64, as it seems binary values aren't saved on Linux QSettings s; s.setValue("mainWindowGeometry", qCompress(saveGeometry()).toBase64()); s.setValue("mainWindowState", qCompress(saveState()).toBase64());