Save popup window configuration without it destroying

This commit is contained in:
Abs62 2018-03-27 21:01:33 +03:00
parent 2ff7e4e6d0
commit d65a1f7869
4 changed files with 19 additions and 15 deletions

View file

@ -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();
}

View file

@ -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;

View file

@ -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 )

View file

@ -52,6 +52,8 @@ public:
void setDictionaryIconSize();
void saveConfigData();
signals:
/// Forwarded from the dictionary bar, so that main window could act on this.