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

feature: High-quality dictionary icons in toolbar #1750

Merged
merged 22 commits into from
Sep 9, 2024

Conversation

KonstantinDjairo
Copy link
Contributor

some of the code added to prevent crashes had a bad side effect, causing the icons to get a bad quality.
two line of codes in two different files were causing that downscaling, the first line was removed, the second had its value changed to a higher value, both conditions were tested and the result is pretty good:

2024-09-08_23-06

@@ -72,7 +72,7 @@ void DictionaryBar::setDictionaries( vector< sptr< Dictionary::Class > > const &
dictActions.append( action );
}

setDictionaryIconSize( 21 );
setDictionaryIconSize( 200 );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entire method of DictionaryBar::setDictionaryIconSize should be just deleted because the height of QToolBar is set automatically. Especially on Linux, it can be any value depends on what theme the user is using. The value 21 was set a decade ago for no reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i removed it as you said, but it seems that more files have references to that method, for instance of one these files is " scanpopup.cc"

Comment on lines 295 to 297
dictionaryIcon = QIcon( QPixmap::fromImage( result ) );

return !dictionaryIcon.isNull();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dictionaryIcon have to be set for dictionaries to have icons.

@shenlebantongying
Copy link
Collaborator

shenlebantongying commented Sep 9, 2024

Surprisingly, setDictionaryIconSize cannot be removed because Show Small Icons in Toolbars needs this.

Change initial value will cause problems to Show Small Icons in Toolbars.

Highly related: #1459

@shenlebantongying
Copy link
Collaborator

shenlebantongying commented Sep 9, 2024

#1459 need another day to do.

However, I pushed a change to enable a hidden feature that enables the user to set dictionaryBar icon size in qt style sheet.

MainWindow #dictionaryBar {
	icon-size: 64px;
}

Note that it will be bound by 64.

Edit: this doesn't work for actually implemented version.

@shenlebantongying shenlebantongying changed the title High-quality dictionary icons feature: High-quality dictionary icons in toolbar Sep 9, 2024
@KonstantinDjairo
Copy link
Contributor Author

#1459 need another day to do.

However, I pushed a change to enable a hidden feature that enables the user to set dictionaryBar icon size in qt style sheet.

MainWindow #dictionaryBar {
	icon-size: 64px;
}

Note that it will be bound by 64.

can that have an option in the preferences?

@shenlebantongying
Copy link
Collaborator

can that have an option in the preferences?

I don't know yet. Need to find free time to implement it first 😅

Can you please double-check my code? Then let's merge this first, and consider an option for larger icons later.

@KonstantinDjairo
Copy link
Contributor Author

can that have an option in the preferences?

I don't know yet. Need to find free time to implement it first 😅

Can you please double-check my code? Then let's merge this first, and consider an option for larger icons later.

alright, i'll test on my guix and check the results

@KonstantinDjairo
Copy link
Contributor Author

These are the results

2024-09-09_12-06
2024-09-09_12-04_1
2024-09-09_12-04

one thing that you can notice is that somehow the icons are too far from each other, it's not a square anymore...
another thing that can be noticed in the bigger screenshot is that even tho the quality is better than the one in the main branch, you can notice some pixel-ish effect in it, so i bet it's having a downscale , right?

@shenlebantongying
Copy link
Collaborator

I think the rectangle icon and pixels effect is caused by none-square initial toolbar icon size?

I pushed a fix, does it work?

@KonstantinDjairo
Copy link
Contributor Author

KonstantinDjairo commented Sep 9, 2024

I think the rectangle icon and pixels effect is caused by none-square initial toolbar icon size?

I pushed a fix, does it work?

there's a bit of blur
image

if you compare to my first image

image

maybe when choosing the icon size, you can compare the height and width numerically and pick the other that's higher, this way it will avoid downscale, but it can also cause upscaling, but i dont think it's a problem

Copy link

sonarcloud bot commented Sep 9, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

@shenlebantongying shenlebantongying merged commit aaaeb58 into xiaoyifang:staged Sep 9, 2024
7 of 8 checks passed
@shenlebantongying
Copy link
Collaborator

Ok, let's merge this :)

@KonstantinDjairo
Copy link
Contributor Author

Ok, let's merge this :)

still blurry but i think it'd require more than one PR to solve this

@KonstantinDjairo KonstantinDjairo deleted the icon_size branch September 9, 2024 18:56
@shenlebantongying
Copy link
Collaborator

Could the reason be high resolution screen?

For a 4x density monitor and the toolbar icon's logical size 21, then it would require 21*4=84?

@KonstantinDjairo
Copy link
Contributor Author

I think the rectangle icon and pixels effect is caused by none-square initial toolbar icon size?
I pushed a fix, does it work?

there's a bit of blur image

if you compare to my first image

image

maybe when choosing the icon size, you can compare the height and width numerically and pick the other that's higher, this way it will avoid downscale, but it can also cause upscaling, but i dont think it's a problem

for example, if you look at this comparison, both are in the same monitor.
and indeed your solution of selecting the "height" value was good, but somehow it made the icons a bit blurry

for some reason when i first removed the value of 21 as we did in the beginning, and set a high value in another variable:
11314d6
the result was the one in the picture, it's pretty sharp and there's no blur

somehow the barsize is downscaling the icons? i dont really know

@KonstantinDjairo
Copy link
Contributor Author

here's the comparison between the original icon (on the right) and the one produced by goldendict-ng.
the one on the left is blurry
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants