mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
Merge pull request #356 from xiaoyifang/goldendict-master
upstream:save/restore scanpopup position
This commit is contained in:
commit
27766d4e22
25
scanpopup.cc
25
scanpopup.cc
|
@ -170,6 +170,7 @@ ScanPopup::ScanPopup( QWidget * parent,
|
|||
connect( &dictionaryBar, &DictionaryBar::showDictionaryInfo, this, &ScanPopup::showDictionaryInfo );
|
||||
connect( &dictionaryBar, &DictionaryBar::openDictionaryFolder, this, &ScanPopup::openDictionaryFolder );
|
||||
|
||||
pinnedGeometry = cfg.popupWindowGeometry;
|
||||
if( cfg.popupWindowGeometry.size() )
|
||||
restoreGeometry( cfg.popupWindowGeometry );
|
||||
|
||||
|
@ -546,6 +547,11 @@ void ScanPopup::engagePopup( bool forcePopup, bool giveFocus )
|
|||
|
||||
move( x, y );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( pinnedGeometry.size() > 0 )
|
||||
restoreGeometry( pinnedGeometry );
|
||||
}
|
||||
|
||||
show();
|
||||
|
||||
|
@ -933,6 +939,22 @@ void ScanPopup::showEvent( QShowEvent * ev )
|
|||
}
|
||||
}
|
||||
|
||||
void ScanPopup::closeEvent( QCloseEvent * ev )
|
||||
{
|
||||
if( isVisible() && ui.pinButton->isChecked() )
|
||||
pinnedGeometry = saveGeometry();
|
||||
|
||||
QMainWindow::closeEvent( ev );
|
||||
}
|
||||
|
||||
void ScanPopup::moveEvent( QMoveEvent * ev )
|
||||
{
|
||||
if( isVisible() && ui.pinButton->isChecked() )
|
||||
pinnedGeometry = saveGeometry();
|
||||
|
||||
QMainWindow::moveEvent( ev );
|
||||
}
|
||||
|
||||
void ScanPopup::prefixMatchFinished()
|
||||
{
|
||||
// Check that there's a window there at all
|
||||
|
@ -988,6 +1010,9 @@ void ScanPopup::pinButtonClicked( bool checked )
|
|||
cfg.pinPopupWindow = checked;
|
||||
|
||||
show();
|
||||
|
||||
if( checked )
|
||||
pinnedGeometry = saveGeometry();
|
||||
}
|
||||
|
||||
void ScanPopup::focusTranslateLine()
|
||||
|
|
|
@ -150,6 +150,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
|
||||
|
@ -180,6 +181,8 @@ private:
|
|||
virtual void enterEvent( QEvent * event );
|
||||
#endif
|
||||
virtual void showEvent( QShowEvent * );
|
||||
virtual void closeEvent( QCloseEvent * );
|
||||
virtual void moveEvent( QMoveEvent * );
|
||||
|
||||
/// Returns inputWord, chopped with appended ... if it's too long/
|
||||
QString elideInputWord();
|
||||
|
|
Loading…
Reference in a new issue