mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
Allow styling of translate line and word list dependent on the current group by introducing a currentGroup Qt property.
To use, create ~/.goldendict/qt-style.css like this: MainWindow #searchPane #translateLine[currentGroup="En"], MainWindow #searchPane #wordList[currentGroup="En"] { background: white; color: black; font-size: 20px; }
This commit is contained in:
parent
e1c9748d88
commit
1dafa5cb16
|
@ -1183,14 +1183,7 @@ void ArticleView::openSearch()
|
|||
ui.searchText->setProperty( "noResults", false );
|
||||
|
||||
// Reload stylesheet
|
||||
for( QWidget * w = parentWidget(); w; w = w->parentWidget() )
|
||||
{
|
||||
if ( w->styleSheet().size() )
|
||||
{
|
||||
w->setStyleSheet( w->styleSheet() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
reloadStyleSheet();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1275,6 +1268,12 @@ void ArticleView::performFindOperation( bool restart, bool backwards )
|
|||
ui.searchText->setProperty( "noResults", setMark );
|
||||
|
||||
// Reload stylesheet
|
||||
reloadStyleSheet();
|
||||
}
|
||||
}
|
||||
|
||||
void ArticleView::reloadStyleSheet()
|
||||
{
|
||||
for( QWidget * w = parentWidget(); w; w = w->parentWidget() )
|
||||
{
|
||||
if ( w->styleSheet().size() )
|
||||
|
@ -1283,9 +1282,9 @@ void ArticleView::performFindOperation( bool restart, bool backwards )
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool ArticleView::closeSearch()
|
||||
{
|
||||
if ( searchIsOpened )
|
||||
|
|
|
@ -240,6 +240,8 @@ private:
|
|||
|
||||
void performFindOperation( bool restart, bool backwards );
|
||||
|
||||
void reloadStyleSheet();
|
||||
|
||||
/// Returns the comma-separated list of dictionary ids which should be muted
|
||||
/// for the given group. If there are none, returns empty string.
|
||||
QString getMutedForGroup( unsigned group );
|
||||
|
|
|
@ -664,6 +664,7 @@ void MainWindow::updateGroupList()
|
|||
|
||||
groupList.fill( groupInstances );
|
||||
groupList.setCurrentGroup( cfg.lastMainGroupId );
|
||||
updateCurrentGroupProperty();
|
||||
|
||||
updateDictionaryBar();
|
||||
|
||||
|
@ -1063,6 +1064,29 @@ void MainWindow::currentGroupChanged( QString const & )
|
|||
// Update word search results
|
||||
|
||||
translateInputChanged( ui.translateLine->text() );
|
||||
|
||||
updateCurrentGroupProperty();
|
||||
}
|
||||
|
||||
void MainWindow::updateCurrentGroupProperty()
|
||||
{
|
||||
// We maintain currentGroup property so styles could use that to change
|
||||
// fonts based on group names
|
||||
Instances::Group * grp =
|
||||
groupInstances.findGroup( groupList.getCurrentGroup() );
|
||||
|
||||
if ( grp && ui.translateLine->property( "currentGroup" ).toString() !=
|
||||
grp->name )
|
||||
{
|
||||
ui.translateLine->setProperty( "currentGroup", grp->name );
|
||||
ui.wordList->setProperty( "currentGroup", grp->name );
|
||||
QString ss = styleSheet();
|
||||
|
||||
// Only update stylesheet if it mentions currentGroup, as updating the
|
||||
// stylesheet is a slow operation
|
||||
if ( ss.contains("currentGroup") )
|
||||
setStyleSheet( ss );
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::translateInputChanged( QString const & newValue )
|
||||
|
|
|
@ -136,6 +136,9 @@ private:
|
|||
|
||||
void mousePressEvent ( QMouseEvent * event );
|
||||
|
||||
void updateCurrentGroupProperty();
|
||||
|
||||
|
||||
private slots:
|
||||
|
||||
void hotKeyActivated( int );
|
||||
|
|
Loading…
Reference in a new issue