clean code:

remove qt version check
save geometry
This commit is contained in:
xiaoyifang 2021-11-27 22:04:43 +08:00 committed by yifang
parent 5eac08c97a
commit 303179b410
4 changed files with 7 additions and 11 deletions

View file

@ -6,14 +6,12 @@
#include <QtNetwork> #include <QtNetwork>
#if QT_VERSION >= 0x050300 // Qt 5.3+
#include <QSet> #include <QSet>
#include <QMap> #include <QMap>
#include <QPair> #include <QPair>
#include <QWebEngineUrlSchemeHandler> #include <QWebEngineUrlSchemeHandler>
#include <QWebEngineUrlRequestJob> #include <QWebEngineUrlRequestJob>
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#endif
#include "dictionary.hh" #include "dictionary.hh"
#include "article_maker.hh" #include "article_maker.hh"

View file

@ -185,7 +185,8 @@ QString ArticleView::runJavaScriptSync(QWebEnginePage* frame, const QString& var
QObject::connect(this, SIGNAL(notifyJavascriptFinished()), &loop, SLOT(quit())); QObject::connect(this, SIGNAL(notifyJavascriptFinished()), &loop, SLOT(quit()));
frame->runJavaScript(variable, [&](const QVariant &v) frame->runJavaScript(variable, [&](const QVariant &v)
{ {
result = v.toString(); if(v.isValid())
result = v.toString();
emitJavascriptFinished(); emitJavascriptFinished();
}); });
@ -345,10 +346,8 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm,
expandOptionalParts = cfg.preferences.alwaysExpandOptionalParts; expandOptionalParts = cfg.preferences.alwaysExpandOptionalParts;
#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
ui.definition->grabGesture( Gestures::GDPinchGestureType ); ui.definition->grabGesture( Gestures::GDPinchGestureType );
ui.definition->grabGesture( Gestures::GDSwipeGestureType ); ui.definition->grabGesture( Gestures::GDSwipeGestureType );
#endif
// Variable name for store current selection range // Variable name for store current selection range
rangeVarName = QString( "sr_%1" ).arg( QString::number( (quint64)this, 16 ) ); rangeVarName = QString( "sr_%1" ).arg( QString::number( (quint64)this, 16 ) );

View file

@ -746,9 +746,9 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
} }
if( cfg.maximizedMainWindowGeometry.width() > 0 ) if( cfg.maximizedMainWindowGeometry.width() > 0 )
{ {
// setGeometry( cfg.maximizedMainWindowGeometry ); setGeometry( cfg.maximizedMainWindowGeometry );
// if ( cfg.mainWindowGeometry.size() ) if ( cfg.mainWindowGeometry.size() )
// restoreGeometry( cfg.mainWindowGeometry ); restoreGeometry( cfg.mainWindowGeometry );
if ( cfg.mainWindowState.size() ) if ( cfg.mainWindowState.size() )
restoreState( cfg.mainWindowState, 1 ); restoreState( cfg.mainWindowState, 1 );
setWindowState( windowState() | Qt::WindowMaximized ); setWindowState( windowState() | Qt::WindowMaximized );
@ -2456,8 +2456,7 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
{ {
if( !isMaximized() && !isMinimized() && !isFullScreen() ) if( !isMaximized() && !isMinimized() && !isFullScreen() )
{ {
//todo ,need further effort setGeometry( cfg.normalMainWindowGeometry );
// setGeometry( cfg.normalMainWindowGeometry );
} }
ev->accept(); ev->accept();
return true; return true;

View file

@ -16,7 +16,7 @@ namespace Utils
/** /**
* remove right end space * remove right end space
*/ */
QString rstrip(const QString& str) { inline QString rstrip(const QString& str) {
int n = str.size() - 1; int n = str.size() - 1;
for (; n >= 0; --n) { for (; n >= 0; --n) {
if (!str.at(n).isSpace()) { if (!str.at(n).isSpace()) {