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>
#if QT_VERSION >= 0x050300 // Qt 5.3+
#include <QSet>
#include <QMap>
#include <QPair>
#include <QWebEngineUrlSchemeHandler>
#include <QWebEngineUrlRequestJob>
#include <QNetworkAccessManager>
#endif
#include "dictionary.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()));
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 ) );

View file

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

View file

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