Save&restore the geometry of Dictionaries dialog

The geometries of many GoldenDict's dialogs and windows are already
stored in config. Dictionaries dialog can make use of extra horizontal
space when there are many groups, extra vertical space - when there are
many dictionaries. A user can now resize this dialog to her liking once.
This commit is contained in:
Igor Kushnir 2021-06-22 18:30:13 +03:00
parent e1c9a0d6de
commit fdf0464628
3 changed files with 12 additions and 0 deletions

View file

@ -1100,6 +1100,11 @@ Class load() THROW_SPEC( exError )
if ( !inspectorGeometry.isNull() )
c.inspectorGeometry = QByteArray::fromBase64( inspectorGeometry.toElement().text().toLatin1() );
QDomNode dictionariesDialogGeometry = root.namedItem( "dictionariesDialogGeometry" );
if ( !dictionariesDialogGeometry.isNull() )
c.dictionariesDialogGeometry = QByteArray::fromBase64( dictionariesDialogGeometry.toElement().text().toLatin1() );
QDomNode timeForNewReleaseCheck = root.namedItem( "timeForNewReleaseCheck" );
if ( !timeForNewReleaseCheck.isNull() )
@ -2094,6 +2099,10 @@ void save( Class const & c ) THROW_SPEC( exError )
opt.appendChild( dd.createTextNode( QString::fromLatin1( c.inspectorGeometry.toBase64() ) ) );
root.appendChild( opt );
opt = dd.createElement( "dictionariesDialogGeometry" );
opt.appendChild( dd.createTextNode( QString::fromLatin1( c.dictionariesDialogGeometry.toBase64() ) ) );
root.appendChild( opt );
opt = dd.createElement( "timeForNewReleaseCheck" );
opt.appendChild( dd.createTextNode( c.timeForNewReleaseCheck.toString( Qt::ISODate ) ) );
root.appendChild( opt );

View file

@ -677,6 +677,7 @@ struct Class
QByteArray popupWindowGeometry; // Geometry saved by QMainWindow
QByteArray dictInfoGeometry; // Geometry of "Dictionary info" window
QByteArray inspectorGeometry; // Geometry of WebKit inspector window
QByteArray dictionariesDialogGeometry; // Geometry of Dictionaries dialog
QByteArray helpWindowGeometry; // Geometry of help window
QByteArray helpSplitterState; // Geometry of help splitter

View file

@ -2035,7 +2035,9 @@ void MainWindow::editDictionaries( unsigned editDictionaryGroup )
if ( editDictionaryGroup != Instances::Group::NoGroupId )
dicts.editGroup( editDictionaryGroup );
dicts.restoreGeometry( cfg.dictionariesDialogGeometry );
dicts.exec();
cfg.dictionariesDialogGeometry = newCfg.dictionariesDialogGeometry = dicts.saveGeometry();
if ( dicts.areDictionariesChanged() || dicts.areGroupsChanged() )
{