Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opt: large icon and word zoom #2038

Merged
merged 28 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions src/ui/mainwindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,14 @@ MainWindow::MainWindow( Config::Class & cfg_ ):

// translate box
groupListInToolbar = new GroupComboBox( navToolbar );
groupListInToolbar->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::MinimumExpanding );
groupListInToolbar->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred );
groupListInToolbar->setSizeAdjustPolicy( QComboBox::AdjustToContents );
groupListInToolbar->setStyleSheet( "QComboBox { padding: 0px; margin: 0px; }" );
translateBoxLayout->addWidget( groupListInToolbar );

translateBox = new TranslateBox( navToolbar );
translateBox->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding );
translateBox->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred );
translateBox->setStyleSheet( "QComboBox { padding: 0px; margin: 0px; }" );
translateBoxLayout->addWidget( translateBox );
translateBoxToolBarAction = navToolbar->addWidget( translateBoxWidget );

Expand Down Expand Up @@ -3140,6 +3142,10 @@ int MainWindow::getIconSize()

void MainWindow::iconSizeActionTriggered( QAction * /*action*/ )
{
//reset word zoom
cfg.preferences.wordsZoomLevel = 0;
wordsZoomBase->setEnabled( false );

bool useLargeIcons = useLargeIconsInToolbarsAction.isChecked();
int extent = getIconSize();
if ( useLargeIcons ) {
Expand All @@ -3159,9 +3165,11 @@ void MainWindow::iconSizeActionTriggered( QAction * /*action*/ )

scanPopup->setDictionaryIconSize();

//ajust the font size as well
//adjust the font size as well
auto font = translateLine->font();
font.setPixelSize( extent );
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 );
Expand Down Expand Up @@ -3654,7 +3662,8 @@ void MainWindow::applyWordsZoomLevel()
if ( ps < 1 ) {
ps = 1;
}
font.setPixelSize( ps );

font.setPixelSize( ps * 0.8 );
ui.wordList->setFont( font );
translateLine->setFont( font );
translateBox->completerWidget()->setFont( font );
Expand Down
55 changes: 14 additions & 41 deletions src/ui/scanpopup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -348,56 +348,27 @@ void ScanPopup::applyZoomFactor() const

void ScanPopup::applyWordsZoomLevel()
{
QFont font( wordListDefaultFont );
int ps = font.pointSize();
QFont font = ui.translateBox->translateLine()->font();

if ( cfg.preferences.wordsZoomLevel != 0 ) {
ps += cfg.preferences.wordsZoomLevel;
if ( ps < 1 ) {
ps = 1;
}
font.setPointSize( ps );
}

if ( ui.translateBox->completerWidget()->font().pointSize() != ps ) {
ui.translateBox->completerWidget()->setFont( font );
}

font = translateLineDefaultFont;
ps = font.pointSize();

if ( cfg.preferences.wordsZoomLevel != 0 ) {
ps += cfg.preferences.wordsZoomLevel;
if ( ps < 1 ) {
ps = 1;
}
font.setPointSize( ps );
}

if ( ui.translateBox->translateLine()->font().pointSize() != ps ) {
ui.translateBox->translateLine()->setFont( font );
}

font = groupListDefaultFont;
ps = font.pointSize();
int ps = dictionaryBar.iconSize().height();

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

if ( ui.groupList->font().pointSize() != ps ) {
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 );
}
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.outerFrame->layout()->activate();
}
Expand Down Expand Up @@ -1151,6 +1122,8 @@ void ScanPopup::setDictionaryIconSize()
else if ( cfg.usingToolbarsIconSize == Config::ToolbarsIconSize::Large ) {
dictionaryBar.setDictionaryIconSize( DictionaryBar::IconSize::Large );
}

applyWordsZoomLevel();
}


Expand Down
4 changes: 2 additions & 2 deletions src/ui/scanpopup.ui
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<item>
<widget class="GroupComboBox" name="groupList">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
Expand All @@ -83,7 +83,7 @@
<item>
<widget class="TranslateBox" name="translateBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
Expand Down
Loading