mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
ScanPopup: Save/restore position of the pinned popup window after closing/reopening it
This commit is contained in:
parent
e1e70e6a6c
commit
74aa95220d
14
scanpopup.cc
14
scanpopup.cc
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue