diff --git a/config.cc b/config.cc index ba4124b8..faa5aeee 100644 --- a/config.cc +++ b/config.cc @@ -731,6 +731,22 @@ Class load() throw( exError ) if ( !mainWindowGeometry.isNull() ) c.mainWindowGeometry = QByteArray::fromBase64( mainWindowGeometry.toElement().text().toLatin1() ); + QDomNode maximizedMainWindowGeometry = root.namedItem( "maximizedMainWindowGeometry" ); + + if ( !maximizedMainWindowGeometry.isNull() ) + { + int x = 0, y = 0, width = 0, height = 0; + if( !maximizedMainWindowGeometry.namedItem( "x" ).isNull() ) + x = maximizedMainWindowGeometry.namedItem( "x" ).toElement().text().toInt(); + if( !maximizedMainWindowGeometry.namedItem( "y" ).isNull() ) + y = maximizedMainWindowGeometry.namedItem( "y" ).toElement().text().toInt(); + if( !maximizedMainWindowGeometry.namedItem( "width" ).isNull() ) + width = maximizedMainWindowGeometry.namedItem( "width" ).toElement().text().toInt(); + if( !maximizedMainWindowGeometry.namedItem( "height" ).isNull() ) + height = maximizedMainWindowGeometry.namedItem( "height" ).toElement().text().toInt(); + c.maximizedMainWindowGeometry = QRect( x, y, width, height ); + } + QDomNode dictInfoGeometry = root.namedItem( "dictInfoGeometry" ); if ( !dictInfoGeometry.isNull() ) @@ -1385,6 +1401,27 @@ void save( Class const & c ) throw( exError ) opt.appendChild( dd.createTextNode( QString::fromLatin1( c.mainWindowGeometry.toBase64() ) ) ); root.appendChild( opt ); + { + QDomElement maximizedMainWindowGeometry = dd.createElement( "maximizedMainWindowGeometry" ); + root.appendChild( maximizedMainWindowGeometry ); + + opt = dd.createElement( "x" ); + opt.appendChild( dd.createTextNode( QString::number( c.maximizedMainWindowGeometry.x() ) ) ); + maximizedMainWindowGeometry.appendChild( opt ); + + opt = dd.createElement( "y" ); + opt.appendChild( dd.createTextNode( QString::number( c.maximizedMainWindowGeometry.y() ) ) ); + maximizedMainWindowGeometry.appendChild( opt ); + + opt = dd.createElement( "width" ); + opt.appendChild( dd.createTextNode( QString::number( c.maximizedMainWindowGeometry.width() ) ) ); + maximizedMainWindowGeometry.appendChild( opt ); + + opt = dd.createElement( "height" ); + opt.appendChild( dd.createTextNode( QString::number( c.maximizedMainWindowGeometry.height() ) ) ); + maximizedMainWindowGeometry.appendChild( opt ); + } + opt = dd.createElement( "dictInfoGeometry" ); opt.appendChild( dd.createTextNode( QString::fromLatin1( c.dictInfoGeometry.toBase64() ) ) ); root.appendChild( opt ); diff --git a/config.hh b/config.hh index 69c29a26..8e369ca3 100644 --- a/config.hh +++ b/config.hh @@ -10,6 +10,7 @@ #include #include #include +#include #include "ex.hh" /// GoldenDict's configuration @@ -422,6 +423,8 @@ struct Class /// Bigger headwords won't be indexed. For now, only in DSL. unsigned int maxHeadwordSize; + QRect maximizedMainWindowGeometry; + QString editDictionaryCommandLine; // Command line to call external editor for dictionary Class(): lastMainGroupId( 0 ), lastPopupGroupId( 0 ), diff --git a/mainwindow.cc b/mainwindow.cc index ff1693ea..0a9956ac 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -604,11 +604,24 @@ MainWindow::MainWindow( Config::Class & cfg_ ): ui.historyList->installEventFilter( this ); - if ( cfg.mainWindowGeometry.size() ) - restoreGeometry( cfg.mainWindowGeometry ); - - if ( cfg.mainWindowState.size() ) - restoreState( cfg.mainWindowState, 1 ); + QRect baseGeometry; + if( cfg.maximizedMainWindowGeometry.width() > 0 ) + { + if ( cfg.mainWindowGeometry.size() ) + restoreGeometry( cfg.mainWindowGeometry ); + baseGeometry = geometry(); + setGeometry( cfg.maximizedMainWindowGeometry ); + if ( cfg.mainWindowState.size() ) + restoreState( cfg.mainWindowState, 1 ); + setWindowState( windowState() | Qt::WindowMaximized ); + } + else + { + if ( cfg.mainWindowGeometry.size() ) + restoreGeometry( cfg.mainWindowGeometry ); + if ( cfg.mainWindowState.size() ) + restoreState( cfg.mainWindowState, 1 ); + } updateSearchPaneAndBar( cfg.preferences.searchInDock ); ui.searchPane->setVisible( cfg.preferences.searchInDock ); @@ -673,6 +686,12 @@ MainWindow::MainWindow( Config::Class & cfg_ ): { show(); focusTranslateLine(); + if( baseGeometry.width() > 0 ) + { + hide(); + setGeometry( baseGeometry ); + showMaximized(); + } } connect( &newReleaseCheckTimer, SIGNAL( timeout() ), @@ -794,6 +813,11 @@ void MainWindow::mousePressEvent( QMouseEvent *event) MainWindow::~MainWindow() { + if( isMaximized() ) + cfg.maximizedMainWindowGeometry = geometry(); + else + cfg.maximizedMainWindowGeometry = QRect(); + commitData(); // Close all tabs -- they should be destroyed before network managers