From 3a50805cea1963aded85bcc9d26d80b8f7fb40eb Mon Sep 17 00:00:00 2001 From: xiaoyifang Date: Mon, 14 Mar 2022 23:18:53 +0800 Subject: [PATCH] fix: dictionaries order , dictionary icon size --- articlewebview.cc | 32 ++++++++++++++++---------------- groups_widgets.cc | 2 +- instances.cc | 10 +++++++--- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/articlewebview.cc b/articlewebview.cc index e8bd821d..7fbad610 100644 --- a/articlewebview.cc +++ b/articlewebview.cc @@ -38,28 +38,28 @@ void ArticleWebView::triggerPageAction( QWebEnginePage::WebAction action, bool c QWebEngineView * ArticleWebView::createWindow( QWebEnginePage::WebWindowType type ) { - QMainWindow * dlg = new QMainWindow( this ); - QWebEngineView * view = new QWebEngineView( dlg ); - dlg->setCentralWidget(view); - dlg->resize(400,400); - dlg->show(); + if(type==QWebEnginePage::WebWindowType::WebDialog) + { + QMainWindow * dlg = new QMainWindow( this ); + QWebEngineView * view = new QWebEngineView( dlg ); + dlg->setCentralWidget(view); + dlg->resize(400,400); + dlg->show(); - return view; + return view; + } + return QWebEngineView::createWindow(type); } bool ArticleWebView::event( QEvent * event ) { - if (event->type() == QEvent::ChildAdded) { - QChildEvent *child_ev = static_cast(event); + if( event->type() == QEvent::ChildAdded ) + { + QChildEvent * child_ev = static_cast< QChildEvent * >( event ); + child_ev->child()->installEventFilter( this ); + } -// // there is also QObject child that should be ignored here; -// // use only QOpenGLWidget child -// QOpenGLWidget *w = static_cast(child_ev->child()); - - child_ev->child()->installEventFilter(this); - } - - return QWebEngineView::event(event); + return QWebEngineView::event( event ); } void ArticleWebView::linkClickedInHtml(QUrl const& ){ diff --git a/groups_widgets.cc b/groups_widgets.cc index 21aef2a7..f1142d0b 100644 --- a/groups_widgets.cc +++ b/groups_widgets.cc @@ -261,7 +261,7 @@ QVariant DictListModel::data( QModelIndex const & index, int role ) const case Qt::DecorationRole: // make all icons of the same size to avoid visual size/alignment problems - return item->getIcon().pixmap( 32 ).scaledToHeight( 21, Qt::SmoothTransformation ); + return item->getIcon(); default:; } diff --git a/instances.cc b/instances.cc index 30a12407..c39cfe52 100644 --- a/instances.cc +++ b/instances.cc @@ -23,6 +23,7 @@ Group::Group( Config::Group const & cfgGroup, iconData = iconFromData( cfgGroup.iconData ); QMap > groupDicts; + QVector dictOrderList; for( unsigned x = 0; x < (unsigned)cfgGroup.dictionaries.size(); ++x ) { @@ -30,6 +31,7 @@ Group::Group( Config::Group const & cfgGroup, if(allDictionaries.contains(id)){ groupDicts.insert(id, allDictionaries[ id ] ); + dictOrderList.push_back(id); } } @@ -39,12 +41,14 @@ Group::Group( Config::Group const & cfgGroup, set< string > inactiveSet; for( int i = 0; i < inactiveGroup.dictionaries.size(); i++ ) { - groupDicts.remove(inactiveGroup.dictionaries[ i ].id.toStdString()); + string id=inactiveGroup.dictionaries[ i ].id.toStdString(); + groupDicts.remove(id); + dictOrderList.removeOne(id); } } - for(const auto & dict : groupDicts) + for(const auto & dictId : dictOrderList) { - dictionaries.push_back(dict); + dictionaries.push_back(groupDicts[dictId]); } }