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.
This commit is contained in:
xiaoyifang 2022-04-19 22:21:56 +08:00
parent c7f7fde5e4
commit eaf76fbcb6
4 changed files with 0 additions and 131 deletions

View file

@ -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 );

View file

@ -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 ),

View file

@ -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();

View file

@ -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