mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
+ Save the popup size across program restarts.
This commit is contained in:
parent
abc6d30d7c
commit
79901d0414
|
@ -138,6 +138,15 @@ Class load() throw( exError )
|
||||||
c.lastMainGroup = root.namedItem( "lastMainGroup" ).toElement().text();
|
c.lastMainGroup = root.namedItem( "lastMainGroup" ).toElement().text();
|
||||||
c.lastPopupGroup = root.namedItem( "lastPopupGroup" ).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;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,6 +251,17 @@ void save( Class const & c ) throw( exError )
|
||||||
opt = dd.createElement( "lastPopupGroup" );
|
opt = dd.createElement( "lastPopupGroup" );
|
||||||
opt.appendChild( dd.createTextNode( c.lastPopupGroup ) );
|
opt.appendChild( dd.createTextNode( c.lastPopupGroup ) );
|
||||||
root.appendChild( opt );
|
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() );
|
configFile.write( dd.toByteArray() );
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QSize>
|
||||||
#include "ex.hh"
|
#include "ex.hh"
|
||||||
|
|
||||||
/// GoldenDict's configuration
|
/// GoldenDict's configuration
|
||||||
|
@ -47,6 +48,7 @@ struct Class
|
||||||
|
|
||||||
QString lastMainGroup; // Last used group in main window
|
QString lastMainGroup; // Last used group in main window
|
||||||
QString lastPopupGroup; // Last used group in popup window
|
QString lastPopupGroup; // Last used group in popup window
|
||||||
|
QSize lastPopupSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
DEF_EX( exError, "Error with the program's configuration", std::exception )
|
DEF_EX( exError, "Error with the program's configuration", std::exception )
|
||||||
|
|
|
@ -37,6 +37,9 @@ ScanPopup::ScanPopup( QWidget * parent,
|
||||||
|
|
||||||
setWindowFlags( Qt::Popup );
|
setWindowFlags( Qt::Popup );
|
||||||
|
|
||||||
|
if ( cfg.lastPopupSize.isValid() )
|
||||||
|
resize( cfg.lastPopupSize );
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
// On Windows, leaveEvent() doesn't seem to work with popups and we're trying
|
// On Windows, leaveEvent() doesn't seem to work with popups and we're trying
|
||||||
// to emulate it.
|
// to emulate it.
|
||||||
|
@ -195,6 +198,13 @@ void ScanPopup::leaveEvent( QEvent * event )
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScanPopup::resizeEvent( QResizeEvent * event )
|
||||||
|
{
|
||||||
|
cfg.lastPopupSize = event->size();
|
||||||
|
|
||||||
|
QDialog::resizeEvent( event );
|
||||||
|
}
|
||||||
|
|
||||||
void ScanPopup::prefixMatchComplete( WordFinderResults r )
|
void ScanPopup::prefixMatchComplete( WordFinderResults r )
|
||||||
{
|
{
|
||||||
// Check that the request wasn't already overridden by another one and
|
// Check that the request wasn't already overridden by another one and
|
||||||
|
|
|
@ -48,6 +48,7 @@ private:
|
||||||
|
|
||||||
virtual void mouseMoveEvent( QMouseEvent * event );
|
virtual void mouseMoveEvent( QMouseEvent * event );
|
||||||
virtual void leaveEvent( QEvent * event );
|
virtual void leaveEvent( QEvent * event );
|
||||||
|
virtual void resizeEvent( QResizeEvent * event );
|
||||||
|
|
||||||
void popupWordlist( vector< QString > const &, QToolButton * button );
|
void popupWordlist( vector< QString > const &, QToolButton * button );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue