Merge pull request #1196 from manongjohn/fix_missing_icons_multiple_screens

Fix missing icon on different resolutions
This commit is contained in:
manongjohn 2023-08-10 22:52:56 -04:00 committed by GitHub
commit 2538154b0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 6 deletions

View file

@ -447,7 +447,11 @@ int main(int argc, char *argv[]) {
#endif
// Set show icons in menus flag (use iconVisibleInMenu to disable selectively)
QApplication::instance()->setAttribute(Qt::AA_DontShowIconsInMenus, false);
bool dontShowIcon =
!Preferences::instance()->isShowAdvancedOptionsEnabled() ||
!Preferences::instance()->getBoolValue(showIconsInMenu);
QApplication::instance()->setAttribute(Qt::AA_DontShowIconsInMenus,
dontShowIcon);
TEnv::setApplicationFileName(argv[0]);

View file

@ -568,11 +568,19 @@ QIcon createQIcon(const QString &iconSVGName, bool useFullOpacity,
// there can be scaling artifacts with high dpi and load these in addition
if (baseImg.width() == (16 * devPixRatio) &&
baseImg.height() == (16 * devPixRatio)) {
QSize expandSize(20, 20);
QImage toolBaseImg(compositeImage(baseImg, expandSize));
QImage toolOverImg(compositeImage(overImg, expandSize));
QImage toolOnImg(compositeImage(onImg, expandSize));
addImagesToIcon(icon, toolBaseImg, toolOverImg, toolOnImg, useFullOpacity);
for (auto screen : QApplication::screens()) {
QSize expandSize(20, 20);
int otherDevPixRatio = screen->devicePixelRatio();
if (otherDevPixRatio != devPixRatio) {
expandSize.setWidth(16 * otherDevPixRatio);
expandSize.setHeight(16 * otherDevPixRatio);
}
QImage toolBaseImg(compositeImage(baseImg, expandSize));
QImage toolOverImg(compositeImage(overImg, expandSize));
QImage toolOnImg(compositeImage(onImg, expandSize));
addImagesToIcon(icon, toolBaseImg, toolOverImg, toolOnImg,
useFullOpacity);
}
}
return icon;