diff --git a/src/config.cc b/src/config.cc index 9f61ea25..a07c2ba7 100644 --- a/src/config.cc +++ b/src/config.cc @@ -138,6 +138,15 @@ Class load() throw( exError ) c.lastMainGroup = root.namedItem( "lastMainGroup" ).toElement().text(); c.lastPopupGroup = root.namedItem( "lastPopupGroup" ).toElement().text(); + QDomNode lastPopupWidth = root.namedItem( "lastPopupWidth" ); + QDomNode lastPopupHeight = root.namedItem( "lastPopupHeight" ); + + if ( !lastPopupWidth.isNull() && !lastPopupHeight.isNull() ) + { + c.lastPopupSize = QSize( lastPopupWidth.toElement().text().toULong(), + lastPopupHeight.toElement().text().toULong() ); + } + return c; } @@ -242,6 +251,17 @@ void save( Class const & c ) throw( exError ) opt = dd.createElement( "lastPopupGroup" ); opt.appendChild( dd.createTextNode( c.lastPopupGroup ) ); root.appendChild( opt ); + + if ( c.lastPopupSize.isValid() ) + { + opt = dd.createElement( "lastPopupWidth" ); + opt.appendChild( dd.createTextNode( QString::number( c.lastPopupSize.width() ) ) ); + root.appendChild( opt ); + + opt = dd.createElement( "lastPopupHeight" ); + opt.appendChild( dd.createTextNode( QString::number( c.lastPopupSize.height() ) ) ); + root.appendChild( opt ); + } } configFile.write( dd.toByteArray() ); diff --git a/src/config.hh b/src/config.hh index 14723411..8c0afdfd 100644 --- a/src/config.hh +++ b/src/config.hh @@ -6,6 +6,7 @@ #include #include +#include #include "ex.hh" /// GoldenDict's configuration @@ -47,6 +48,7 @@ struct Class QString lastMainGroup; // Last used group in main window QString lastPopupGroup; // Last used group in popup window + QSize lastPopupSize; }; DEF_EX( exError, "Error with the program's configuration", std::exception ) diff --git a/src/scanpopup.cc b/src/scanpopup.cc index 03a1e137..bf9cb422 100644 --- a/src/scanpopup.cc +++ b/src/scanpopup.cc @@ -37,6 +37,9 @@ ScanPopup::ScanPopup( QWidget * parent, setWindowFlags( Qt::Popup ); + if ( cfg.lastPopupSize.isValid() ) + resize( cfg.lastPopupSize ); + #ifdef Q_OS_WIN32 // On Windows, leaveEvent() doesn't seem to work with popups and we're trying // to emulate it. @@ -195,6 +198,13 @@ void ScanPopup::leaveEvent( QEvent * event ) hide(); } +void ScanPopup::resizeEvent( QResizeEvent * event ) +{ + cfg.lastPopupSize = event->size(); + + QDialog::resizeEvent( event ); +} + void ScanPopup::prefixMatchComplete( WordFinderResults r ) { // Check that the request wasn't already overridden by another one and diff --git a/src/scanpopup.hh b/src/scanpopup.hh index e4ec1855..99dd8fab 100644 --- a/src/scanpopup.hh +++ b/src/scanpopup.hh @@ -48,6 +48,7 @@ private: virtual void mouseMoveEvent( QMouseEvent * event ); virtual void leaveEvent( QEvent * event ); + virtual void resizeEvent( QResizeEvent * event ); void popupWordlist( vector< QString > const &, QToolButton * button );