fix: dictionaries order , dictionary icon size

This commit is contained in:
xiaoyifang 2022-03-14 23:18:53 +08:00
parent 5071b480c9
commit 3a50805cea
3 changed files with 24 additions and 20 deletions

View file

@ -37,6 +37,8 @@ void ArticleWebView::triggerPageAction( QWebEnginePage::WebAction action, bool c
} }
QWebEngineView * ArticleWebView::createWindow( QWebEnginePage::WebWindowType type ) QWebEngineView * ArticleWebView::createWindow( QWebEnginePage::WebWindowType type )
{
if(type==QWebEnginePage::WebWindowType::WebDialog)
{ {
QMainWindow * dlg = new QMainWindow( this ); QMainWindow * dlg = new QMainWindow( this );
QWebEngineView * view = new QWebEngineView( dlg ); QWebEngineView * view = new QWebEngineView( dlg );
@ -46,16 +48,14 @@ QWebEngineView * ArticleWebView::createWindow( QWebEnginePage::WebWindowType typ
return view; return view;
} }
return QWebEngineView::createWindow(type);
}
bool ArticleWebView::event( QEvent * event ) bool ArticleWebView::event( QEvent * event )
{ {
if (event->type() == QEvent::ChildAdded) { if( event->type() == QEvent::ChildAdded )
{
QChildEvent * child_ev = static_cast< QChildEvent * >( event ); QChildEvent * child_ev = static_cast< QChildEvent * >( event );
// // there is also QObject child that should be ignored here;
// // use only QOpenGLWidget child
// QOpenGLWidget *w = static_cast<QOpenGLWidget*>(child_ev->child());
child_ev->child()->installEventFilter( this ); child_ev->child()->installEventFilter( this );
} }

View file

@ -261,7 +261,7 @@ QVariant DictListModel::data( QModelIndex const & index, int role ) const
case Qt::DecorationRole: case Qt::DecorationRole:
// make all icons of the same size to avoid visual size/alignment problems // 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:; default:;
} }

View file

@ -23,6 +23,7 @@ Group::Group( Config::Group const & cfgGroup,
iconData = iconFromData( cfgGroup.iconData ); iconData = iconFromData( cfgGroup.iconData );
QMap<string, sptr< Dictionary::Class > > groupDicts; QMap<string, sptr< Dictionary::Class > > groupDicts;
QVector<string> dictOrderList;
for( unsigned x = 0; x < (unsigned)cfgGroup.dictionaries.size(); ++x ) for( unsigned x = 0; x < (unsigned)cfgGroup.dictionaries.size(); ++x )
{ {
@ -30,6 +31,7 @@ Group::Group( Config::Group const & cfgGroup,
if(allDictionaries.contains(id)){ if(allDictionaries.contains(id)){
groupDicts.insert(id, allDictionaries[ id ] ); groupDicts.insert(id, allDictionaries[ id ] );
dictOrderList.push_back(id);
} }
} }
@ -39,12 +41,14 @@ Group::Group( Config::Group const & cfgGroup,
set< string > inactiveSet; set< string > inactiveSet;
for( int i = 0; i < inactiveGroup.dictionaries.size(); i++ ) 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]);
} }
} }