ScanPopup: Save/restore position of the pinned popup window after closing/reopening it

This commit is contained in:
Abs62 2023-02-14 17:51:03 +03:00
parent e1e70e6a6c
commit 74aa95220d
2 changed files with 16 additions and 0 deletions

View file

@ -181,6 +181,7 @@ ScanPopup::ScanPopup( QWidget * parent,
connect( &dictionaryBar, SIGNAL( openDictionaryFolder( QString const & ) ),
this, SIGNAL( openDictionaryFolder( QString const & ) ) );
pinnedGeometry = cfg.popupWindowGeometry;
if ( cfg.popupWindowGeometry.size() )
restoreGeometry( cfg.popupWindowGeometry );
@ -663,6 +664,11 @@ void ScanPopup::engagePopup( bool forcePopup, bool giveFocus )
move( x, y );
}
else
{
if( pinnedGeometry.size() > 0 )
restoreGeometry( pinnedGeometry );
}
show();
@ -1060,6 +1066,14 @@ void ScanPopup::showEvent( QShowEvent * ev )
}
}
void ScanPopup::closeEvent( QCloseEvent * ev )
{
if( isVisible() && ui.pinButton->isChecked() )
pinnedGeometry = saveGeometry();
QMainWindow::closeEvent( ev );
}
void ScanPopup::prefixMatchFinished()
{
// Check that there's a window there at all

View file

@ -151,6 +151,7 @@ private:
bool mouseIntercepted;
QPoint startPos; // For window moving
QByteArray pinnedGeometry;
QTimer hideTimer; // When mouse leaves the window, a grace period is
// given for it to return back. If it doesn't before
@ -178,6 +179,7 @@ private:
virtual void leaveEvent( QEvent * event );
virtual void enterEvent( QEvent * event );
virtual void showEvent( QShowEvent * );
virtual void closeEvent( QCloseEvent * );
/// Returns inputWord, chopped with appended ... if it's too long/
QString elideInputWord();