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

@ -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<QChildEvent *>(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<QOpenGLWidget*>(child_ev->child());
child_ev->child()->installEventFilter(this);
}
return QWebEngineView::event(event);
return QWebEngineView::event( event );
}
void ArticleWebView::linkClickedInHtml(QUrl const& ){

View file

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

View file

@ -23,6 +23,7 @@ Group::Group( Config::Group const & cfgGroup,
iconData = iconFromData( cfgGroup.iconData );
QMap<string, sptr< Dictionary::Class > > groupDicts;
QVector<string> 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]);
}
}