From eaf76fbcb6fae8c6000c945a052060682a7d716b Mon Sep 17 00:00:00 2001 From: xiaoyifang Date: Tue, 19 Apr 2022 22:21:56 +0800 Subject: [PATCH] clean code:remove useless code the maximumwindowssize was only set value in the ~MainWindows() which means it can not be saved into the config file. --- config.cc | 76 --------------------------------------------------- config.hh | 5 ---- mainwindow.cc | 30 -------------------- mainwindow.hh | 20 -------------- 4 files changed, 131 deletions(-) diff --git a/config.cc b/config.cc index 6c287d2e..3daa51e3 100644 --- a/config.cc +++ b/config.cc @@ -1073,40 +1073,6 @@ Class load() if ( !helpSplitterState.isNull() ) c.helpSplitterState = QByteArray::fromBase64( helpSplitterState.toElement().text().toLatin1() ); -#ifdef Q_OS_WIN - 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 normalMainWindowGeometry = root.namedItem( "normalMainWindowGeometry" ); - - if ( !normalMainWindowGeometry.isNull() ) - { - int x = 0, y = 0, width = 0, height = 0; - if( !normalMainWindowGeometry.namedItem( "x" ).isNull() ) - x = normalMainWindowGeometry.namedItem( "x" ).toElement().text().toInt(); - if( !normalMainWindowGeometry.namedItem( "y" ).isNull() ) - y = normalMainWindowGeometry.namedItem( "y" ).toElement().text().toInt(); - if( !normalMainWindowGeometry.namedItem( "width" ).isNull() ) - width = normalMainWindowGeometry.namedItem( "width" ).toElement().text().toInt(); - if( !normalMainWindowGeometry.namedItem( "height" ).isNull() ) - height = normalMainWindowGeometry.namedItem( "height" ).toElement().text().toInt(); - c.normalMainWindowGeometry = QRect( x, y, width, height ); - } -#endif - QDomNode dictInfoGeometry = root.namedItem( "dictInfoGeometry" ); if ( !dictInfoGeometry.isNull() ) @@ -2058,48 +2024,6 @@ void save( Class const & c ) opt.appendChild( dd.createTextNode( QString::fromLatin1( c.helpSplitterState.toBase64() ) ) ); root.appendChild( opt ); -#ifdef Q_OS_WIN - { - 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 ); - - QDomElement normalMainWindowGeometry = dd.createElement( "normalMainWindowGeometry" ); - root.appendChild( normalMainWindowGeometry ); - - opt = dd.createElement( "x" ); - opt.appendChild( dd.createTextNode( QString::number( c.normalMainWindowGeometry.x() ) ) ); - normalMainWindowGeometry.appendChild( opt ); - - opt = dd.createElement( "y" ); - opt.appendChild( dd.createTextNode( QString::number( c.normalMainWindowGeometry.y() ) ) ); - normalMainWindowGeometry.appendChild( opt ); - - opt = dd.createElement( "width" ); - opt.appendChild( dd.createTextNode( QString::number( c.normalMainWindowGeometry.width() ) ) ); - normalMainWindowGeometry.appendChild( opt ); - - opt = dd.createElement( "height" ); - opt.appendChild( dd.createTextNode( QString::number( c.normalMainWindowGeometry.height() ) ) ); - normalMainWindowGeometry.appendChild( opt ); - } -#endif - 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 117478f9..e50336bb 100644 --- a/config.hh +++ b/config.hh @@ -709,11 +709,6 @@ struct Class HeadwordsDialog headwordsDialog; -#ifdef Q_OS_WIN - QRect maximizedMainWindowGeometry; - QRect normalMainWindowGeometry; -#endif - QString editDictionaryCommandLine; // Command line to call external editor for dictionary Class(): lastMainGroupId( 0 ), lastPopupGroupId( 0 ), diff --git a/mainwindow.cc b/mainwindow.cc index f710e24c..f7b060a1 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -744,23 +744,6 @@ MainWindow::MainWindow( Config::Class & cfg_ ): connect( &ftsIndexing, SIGNAL( newIndexingName( QString ) ), this, SLOT( showFTSIndexingName( QString ) ) ); -#ifdef Q_OS_WIN - if( cfg.normalMainWindowGeometry.width() <= 0 ) - { - QRect r = QGuiApplication::primaryScreen ()->geometry (); - cfg.normalMainWindowGeometry.setRect( r.width() / 4, r.height() / 4, r.width() / 2, r.height() / 2 ); - } - if( cfg.maximizedMainWindowGeometry.width() > 0 ) - { - setGeometry( cfg.maximizedMainWindowGeometry ); - if ( cfg.mainWindowGeometry.size() ) - restoreGeometry( cfg.mainWindowGeometry ); - if ( cfg.mainWindowState.size() ) - restoreState( cfg.mainWindowState, 1 ); - setWindowState( windowState() | Qt::WindowMaximized ); - } - else -#endif #ifndef Q_OS_MAC { if ( cfg.mainWindowGeometry.size() ) @@ -997,19 +980,6 @@ void MainWindow::mousePressEvent( QMouseEvent *event) MainWindow::~MainWindow() { -#ifdef Q_OS_WIN - if( isMaximized() ) - { - cfg.maximizedMainWindowGeometry = geometry(); - } - else - { - cfg.maximizedMainWindowGeometry = QRect(); - if( !isMinimized() ) - cfg.normalMainWindowGeometry = geometry(); - } -#endif - closeHeadwordsDialog(); ftsIndexing.stopIndexing(); diff --git a/mainwindow.hh b/mainwindow.hh index 2c7c075b..3867c1b0 100644 --- a/mainwindow.hh +++ b/mainwindow.hh @@ -41,26 +41,6 @@ using std::string; using std::vector; -class ExpandableToolBar : public QToolBar -{ - Q_OBJECT - -public: - explicit ExpandableToolBar(QString const & title, QWidget * parent = 0) - : QToolBar(title, parent) {} - virtual QSize sizeHint() const - { - if ( !isFloating() && parentWidget() ) - { - return QSize( parentWidget()->width(), QToolBar::sizeHint().height() ); - } - else - { - return QToolBar::sizeHint(); - } - } -}; - class MainWindow: public QMainWindow, public DataCommitter { Q_OBJECT