From 8bee9bf5c61cacb0ccb13bad5b43714bece5b1ce Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Wed, 22 Dec 2021 19:54:06 +0800 Subject: [PATCH] -fix: editor's tab close button size too small in high DPI settings --- NEWS.md | 4 +-- RedPandaIDE/icons.qrc | 1 + RedPandaIDE/mainwindow.cpp | 2 ++ RedPandaIDE/widgets/darkfusionstyle.cpp | 36 +++++++++++++++--------- RedPandaIDE/widgets/lightfusionstyle.cpp | 3 ++ 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/NEWS.md b/NEWS.md index 8c9c50be..8a7dd4d0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,9 +3,9 @@ Version 0.11.4 For Dev-C++ 7 Beta - fix: code completion doesn't work when input inside () or [] - fix: auto indent processing error when input '{' in the middle of if statement - fix: left and right gutter offset settings not correctly saved - - enhancement: use svg icons for editor gutter, and they can zoom with font now - fix: symbol completion for '<>' in the preprocessor line not work - - enhancement: use svg icons for class browser + - enhancement: new svg icons set + - enhancement: the size of icons in the main window zooms with font size Version 0.11.3 For Dev-C++ 7 Beta - fix: use pixel size for fonts, to fit different dpi in multiple displays diff --git a/RedPandaIDE/icons.qrc b/RedPandaIDE/icons.qrc index 107b69dc..06debcdc 100644 --- a/RedPandaIDE/icons.qrc +++ b/RedPandaIDE/icons.qrc @@ -204,5 +204,6 @@ images/newlook/06View-06Todo.svg images/newlook/05Run-14StepOverInstruction.svg images/newlook/05Run-15StepIntoInstruction.svg + images/dark-close.svg diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 2eafbe44..9d90af83 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -1115,6 +1115,8 @@ void MainWindow::updateActionIcons() ui->tabInfos->setIconSize(iconSize); ui->tabMessages->setIconSize(iconSize); + ui->EditorTabsLeft->setIconSize(iconSize); + ui->EditorTabsRight->setIconSize(iconSize); ui->actionNew->setIcon(QIcon(*(pIconsManager->getIcon(IconsManager::ACTION_FILE_NEW)))); ui->actionNew_Project->setIcon(QIcon(*(pIconsManager->getIcon(IconsManager::ACTION_PROJECT_NEW)))); diff --git a/RedPandaIDE/widgets/darkfusionstyle.cpp b/RedPandaIDE/widgets/darkfusionstyle.cpp index fee6a28c..269606e4 100644 --- a/RedPandaIDE/widgets/darkfusionstyle.cpp +++ b/RedPandaIDE/widgets/darkfusionstyle.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include "../settings.h" #define BEGIN_STYLE_PIXMAPCACHE(a) \ @@ -756,17 +757,16 @@ void DarkFusionStyle::drawPrimitive(PrimitiveElement elem, const QStyleOption *o case PE_FrameStatusBarItem: break; -// case PE_IndicatorTabClose: -// { -// Q_D(const QFusionStyle); -// if (d->tabBarcloseButtonIcon.isNull()) -// d->tabBarcloseButtonIcon = proxy()->standardIcon(SP_DialogCloseButton, option, widget); -// if ((option->state & State_Enabled) && (option->state & State_MouseOver)) -// proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget); -// QPixmap pixmap = d->tabBarcloseButtonIcon.pixmap(qt_getWindow(widget), QSize(16, 16), QIcon::Normal, QIcon::On); -// proxy()->drawItemPixmap(painter, option->rect, Qt::AlignCenter, pixmap); -// } -// break; + case PE_IndicatorTabClose: + { + QIcon closeIcon = proxy()->standardIcon(SP_DialogCloseButton, option, widget); + if ((option->state & State_Enabled) && (option->state & State_MouseOver)) + proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget); + int size = pointToPixel(pSettings->environment().interfaceFontSize()); + QPixmap pixmap = closeIcon.pixmap(QSize(size, size), QIcon::Normal, QIcon::On); + proxy()->drawItemPixmap(painter, option->rect, Qt::AlignCenter, pixmap); + } + break; case PE_PanelMenu: { painter->save(); const QBrush menuBackground = option->palette.base().color().darker(108); @@ -786,8 +786,15 @@ QIcon DarkFusionStyle::standardIcon(StandardPixmap standardIcon, const QStyleOpt switch (standardIcon) { case SP_TitleBarCloseButton: case SP_DockWidgetCloseButton: - case SP_DialogCloseButton: - return QIcon(":/themes/dark_close.png"); + case SP_DialogCloseButton: { + int size = pointToPixel(pSettings->environment().interfaceFontSize()); + QSvgRenderer renderer(QString(":/icons/images/dark-close.svg")); + QPixmap pixmap(size,size); + pixmap.fill(Qt::transparent); + QPainter painter(&pixmap); + renderer.render(&painter,pixmap.rect()); + return QIcon(pixmap); + } default: break; } @@ -805,6 +812,9 @@ int DarkFusionStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, switch ( metric ) { case QStyle::PM_SmallIconSize: return pointToPixel(pSettings->environment().interfaceFontSize()); + case QStyle::PM_TabCloseIndicatorHeight: + case QStyle::PM_TabCloseIndicatorWidth: + return 1.2*pointToPixel(pSettings->environment().interfaceFontSize()); default: return QProxyStyle::pixelMetric( metric, option, widget ); } diff --git a/RedPandaIDE/widgets/lightfusionstyle.cpp b/RedPandaIDE/widgets/lightfusionstyle.cpp index 9a807bb9..ca2cc1ad 100644 --- a/RedPandaIDE/widgets/lightfusionstyle.cpp +++ b/RedPandaIDE/widgets/lightfusionstyle.cpp @@ -11,6 +11,9 @@ int LightFusionStyle::pixelMetric(PixelMetric metric, const QStyleOption *option switch ( metric ) { case QStyle::PM_SmallIconSize: return pointToPixel(pSettings->environment().interfaceFontSize()); + case QStyle::PM_TabCloseIndicatorHeight: + case QStyle::PM_TabCloseIndicatorWidth: + return 1.2*pointToPixel(pSettings->environment().interfaceFontSize()); default: return QProxyStyle::pixelMetric( metric, option, widget ); }