From 303179b410e242f79cb699d536db393bca79993b Mon Sep 17 00:00:00 2001 From: xiaoyifang Date: Sat, 27 Nov 2021 22:04:43 +0800 Subject: [PATCH] clean code: remove qt version check save geometry --- article_netmgr.hh | 2 -- articleview.cc | 5 ++--- mainwindow.cc | 9 ++++----- utils.hh | 2 +- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/article_netmgr.hh b/article_netmgr.hh index af45ff0b..61cdfc47 100644 --- a/article_netmgr.hh +++ b/article_netmgr.hh @@ -6,14 +6,12 @@ #include -#if QT_VERSION >= 0x050300 // Qt 5.3+ #include #include #include #include #include #include -#endif #include "dictionary.hh" #include "article_maker.hh" diff --git a/articleview.cc b/articleview.cc index 7ca09006..647e0ea4 100644 --- a/articleview.cc +++ b/articleview.cc @@ -185,7 +185,8 @@ QString ArticleView::runJavaScriptSync(QWebEnginePage* frame, const QString& var QObject::connect(this, SIGNAL(notifyJavascriptFinished()), &loop, SLOT(quit())); frame->runJavaScript(variable, [&](const QVariant &v) { - result = v.toString(); + if(v.isValid()) + result = v.toString(); emitJavascriptFinished(); }); @@ -345,10 +346,8 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm, expandOptionalParts = cfg.preferences.alwaysExpandOptionalParts; -#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) ui.definition->grabGesture( Gestures::GDPinchGestureType ); ui.definition->grabGesture( Gestures::GDSwipeGestureType ); -#endif // Variable name for store current selection range rangeVarName = QString( "sr_%1" ).arg( QString::number( (quint64)this, 16 ) ); diff --git a/mainwindow.cc b/mainwindow.cc index 036cf6c6..82fadfcf 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -746,9 +746,9 @@ MainWindow::MainWindow( Config::Class & cfg_ ): } if( cfg.maximizedMainWindowGeometry.width() > 0 ) { -// setGeometry( cfg.maximizedMainWindowGeometry ); -// if ( cfg.mainWindowGeometry.size() ) -// restoreGeometry( cfg.mainWindowGeometry ); + setGeometry( cfg.maximizedMainWindowGeometry ); + if ( cfg.mainWindowGeometry.size() ) + restoreGeometry( cfg.mainWindowGeometry ); if ( cfg.mainWindowState.size() ) restoreState( cfg.mainWindowState, 1 ); setWindowState( windowState() | Qt::WindowMaximized ); @@ -2456,8 +2456,7 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev ) { if( !isMaximized() && !isMinimized() && !isFullScreen() ) { - //todo ,need further effort - // setGeometry( cfg.normalMainWindowGeometry ); + setGeometry( cfg.normalMainWindowGeometry ); } ev->accept(); return true; diff --git a/utils.hh b/utils.hh index 99b29d1a..c8b57596 100644 --- a/utils.hh +++ b/utils.hh @@ -16,7 +16,7 @@ namespace Utils /** * remove right end space */ - QString rstrip(const QString& str) { +inline QString rstrip(const QString& str) { int n = str.size() - 1; for (; n >= 0; --n) { if (!str.at(n).isSpace()) {