From d65a1f7869e83eba5c01617253c46ac7f63e3514 Mon Sep 17 00:00:00 2001 From: Abs62 Date: Tue, 27 Mar 2018 21:01:33 +0300 Subject: [PATCH] Save popup window configuration without it destroying --- mainwindow.cc | 15 ++++++--------- mainwindow.hh | 2 +- scanpopup.cc | 15 ++++++++++----- scanpopup.hh | 2 ++ 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/mainwindow.cc b/mainwindow.cc index fd9d4c02..2a721f1c 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -1022,10 +1022,10 @@ void MainWindow::addGlobalActionsToDialog( QDialog * dialog ) void MainWindow::commitData( QSessionManager & ) { - commitData( true ); + commitData(); } -void MainWindow::commitData( bool init_popup ) +void MainWindow::commitData() { try { @@ -1033,9 +1033,10 @@ void MainWindow::commitData( bool init_popup ) cfg.mainWindowState = saveState( 1 ); cfg.mainWindowGeometry = saveGeometry(); - // Close the popup, so it would save its geometry to config + // Save popup window state and geometry - scanPopup.reset(); + if( scanPopup.get() ) + scanPopup->saveConfigData(); // Save any changes in last chosen groups etc try @@ -1052,10 +1053,6 @@ void MainWindow::commitData( bool init_popup ) // Save favorites ui.favoritesPaneWidget->saveData(); - - // Reinit popup window if necessary (when called from session manager) - if( init_popup ) - makeScanPopup(); } catch( std::exception & e ) { @@ -1187,7 +1184,7 @@ void MainWindow::closeEvent( QCloseEvent * ev ) void MainWindow::quitApp() { - commitData( false ); + commitData(); qApp->quit(); } diff --git a/mainwindow.hh b/mainwindow.hh index d5fbdea0..2cd15bfd 100644 --- a/mainwindow.hh +++ b/mainwindow.hh @@ -92,7 +92,7 @@ private: void addGlobalAction( QAction * action, const char * slot ); void addGlobalActionsToDialog( QDialog * dialog ); - void commitData( bool init_popup ); + void commitData(); QSystemTrayIcon * trayIcon; diff --git a/scanpopup.cc b/scanpopup.cc index dbd33c49..b602d120 100644 --- a/scanpopup.cc +++ b/scanpopup.cc @@ -310,11 +310,7 @@ ScanPopup::ScanPopup( QWidget * parent, ScanPopup::~ScanPopup() { - // Save state, geometry and pin status - cfg.popupWindowState = saveState( 1 ); - cfg.popupWindowGeometry = saveGeometry(); - cfg.pinPopupWindow = ui.pinButton->isChecked(); - cfg.popupWindowAlwaysOnTop = ui.onTopButton->isChecked(); + saveConfigData(); disableScanning(); @@ -324,6 +320,15 @@ ScanPopup::~ScanPopup() #endif } +void ScanPopup::saveConfigData() +{ + // Save state, geometry and pin status + cfg.popupWindowState = saveState( 1 ); + cfg.popupWindowGeometry = saveGeometry(); + cfg.pinPopupWindow = ui.pinButton->isChecked(); + cfg.popupWindowAlwaysOnTop = ui.onTopButton->isChecked(); +} + void ScanPopup::enableScanning() { if ( !isScanningEnabled ) diff --git a/scanpopup.hh b/scanpopup.hh index 7352bf85..db0af231 100644 --- a/scanpopup.hh +++ b/scanpopup.hh @@ -52,6 +52,8 @@ public: void setDictionaryIconSize(); + void saveConfigData(); + signals: /// Forwarded from the dictionary bar, so that main window could act on this.