Skip to content

Commit

Permalink
opt: do not change font size of combobox and wordlist etc . (#2047)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyifang authored Dec 29, 2024
1 parent 25c2982 commit 68522ad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 32 deletions.
33 changes: 12 additions & 21 deletions src/ui/mainwindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3166,13 +3166,13 @@ void MainWindow::iconSizeActionTriggered( QAction * /*action*/ )
scanPopup->setDictionaryIconSize();

//adjust the font size as well
auto font = translateLine->font();
auto font = translateBox->translateLine()->font();
font.setWeight( QFont::Normal );
//arbitrary value to make it look good
font.setPixelSize( extent * 0.8 );
translateLine->setFont( font );
translateBox->completerWidget()->setFont( font );
groupList->setFont( font );
// translateBox->completerWidget()->setFont( font );
//only set the font in toolbar
translateBox->translateLine()->setFont( font );
}

void MainWindow::toggleMenuBarTriggered( bool announce )
Expand Down Expand Up @@ -3633,14 +3633,14 @@ void MainWindow::scaleArticlesByCurrentZoomFactor()

void MainWindow::doWordsZoomIn()
{
++cfg.preferences.wordsZoomLevel;
cfg.preferences.wordsZoomLevel = cfg.preferences.wordsZoomLevel + 2;

applyWordsZoomLevel();
}

void MainWindow::doWordsZoomOut()
{
--cfg.preferences.wordsZoomLevel;
cfg.preferences.wordsZoomLevel = cfg.preferences.wordsZoomLevel - 2;

applyWordsZoomLevel();
}
Expand All @@ -3654,28 +3654,19 @@ void MainWindow::doWordsZoomBase()

void MainWindow::applyWordsZoomLevel()
{
QFont font = translateLine->font();
QFont font = translateBox->translateLine()->font();

int ps = getIconSize();

ps += cfg.preferences.wordsZoomLevel;
if ( ps < 1 ) {
ps = 1;
if ( ps < 12 ) {
ps = 12;
}

font.setPixelSize( ps * 0.8 );
ui.wordList->setFont( font );
translateLine->setFont( font );
translateBox->completerWidget()->setFont( font );

disconnect( groupList, &GroupComboBox::currentIndexChanged, this, &MainWindow::currentGroupChanged );
int n = groupList->currentIndex();
groupList->clear();
groupList->setFont( font );
groupList->fill( groupInstances );
groupList->setCurrentIndex( n );
connect( groupList, &GroupComboBox::currentIndexChanged, this, &MainWindow::currentGroupChanged );

font.setWeight( QFont::Normal );
translateBox->translateLine()->setFont( font );
// translateBox->completerWidget()->setFont( font );
wordsZoomBase->setEnabled( cfg.preferences.wordsZoomLevel != 0 );

if ( !cfg.preferences.searchInDock ) {
Expand Down
14 changes: 3 additions & 11 deletions src/ui/scanpopup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -354,21 +354,13 @@ void ScanPopup::applyWordsZoomLevel()

if ( cfg.preferences.wordsZoomLevel != 0 ) {
ps += cfg.preferences.wordsZoomLevel;
if ( ps < 1 ) {
ps = 1;
if ( ps < 12 ) {
ps = 12;
}
font.setPixelSize( ps * 0.8 );
}
ui.translateBox->completerWidget()->setFont( font );
ui.translateBox->translateLine()->setFont( font );

disconnect( ui.groupList, &GroupComboBox::currentIndexChanged, this, &ScanPopup::currentGroupChanged );
int n = ui.groupList->currentIndex();
ui.groupList->clear();
ui.groupList->setFont( font );
ui.groupList->fill( groups );
ui.groupList->setCurrentIndex( n );
connect( ui.groupList, &GroupComboBox::currentIndexChanged, this, &ScanPopup::currentGroupChanged );
// ui.translateBox->translateLine()->setFont( font );

ui.outerFrame->layout()->activate();
}
Expand Down

0 comments on commit 68522ad

Please sign in to comment.