fix: restore maximize geometry (#1013)

* fix: restore maximize geometry

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
xiaoyifang 2023-07-27 17:09:06 +08:00 committed by GitHub
parent 1f362142ab
commit cd560f85fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 0 deletions

View file

@ -1107,6 +1107,11 @@ Class load()
if ( !mainWindowGeometry.isNull() )
c.mainWindowGeometry = QByteArray::fromBase64( mainWindowGeometry.toElement().text().toLatin1() );
QDomNode mainWindowMaximized = root.namedItem( "mainWindowMaximized" );
if ( !mainWindowMaximized.isNull() )
c.mainWindowMaximized = ( mainWindowMaximized.toElement().text() == "1" );
QDomNode dictInfoGeometry = root.namedItem( "dictInfoGeometry" );
if ( !dictInfoGeometry.isNull() )
@ -2095,6 +2100,10 @@ void save( Class const & c )
opt.appendChild( dd.createTextNode( QString::fromLatin1( c.mainWindowGeometry.toBase64() ) ) );
root.appendChild( opt );
opt = dd.createElement( "mainWindowMaximized" );
opt.appendChild( dd.createTextNode( c.mainWindowMaximized ? "1" : "0" ) );
root.appendChild( opt );
opt = dd.createElement( "dictInfoGeometry" );
opt.appendChild( dd.createTextNode( QString::fromLatin1( c.dictInfoGeometry.toBase64() ) ) );
root.appendChild( opt );

View file

@ -866,6 +866,7 @@ struct Class
QByteArray mainWindowState; // Binary state saved by QMainWindow
QByteArray mainWindowGeometry; // Geometry saved by QMainWindow
bool mainWindowMaximized = false;
MutedDictionaries mutedDictionaries; // Disabled via dictionary bar
MutedDictionaries popupMutedDictionaries; // Disabled via dictionary bar in popup

View file

@ -746,6 +746,10 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
if ( cfg.mainWindowGeometry.size() )
restoreGeometry( cfg.mainWindowGeometry );
if ( cfg.mainWindowMaximized ) {
showMaximized();
}
#if defined( Q_OS_LINUX )
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) )
defaultInterfaceStyle = QApplication::style()->name();
@ -1214,6 +1218,7 @@ void MainWindow::commitData()
// Save MainWindow state and geometry
cfg.mainWindowState = saveState();
cfg.mainWindowGeometry = saveGeometry();
cfg.mainWindowMaximized = isMaximized();
// Save popup window state and geometry
if ( scanPopup )