-fix: editor's tab close button size too small in high DPI settings

This commit is contained in:
Roy Qu 2021-12-22 19:54:06 +08:00
parent 5e076419c2
commit 8bee9bf5c6
5 changed files with 31 additions and 15 deletions

View File

@ -3,9 +3,9 @@ Version 0.11.4 For Dev-C++ 7 Beta
- fix: code completion doesn't work when input inside () or [] - fix: code completion doesn't work when input inside () or []
- fix: auto indent processing error when input '{' in the middle of if statement - fix: auto indent processing error when input '{' in the middle of if statement
- fix: left and right gutter offset settings not correctly saved - 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 - 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 Version 0.11.3 For Dev-C++ 7 Beta
- fix: use pixel size for fonts, to fit different dpi in multiple displays - fix: use pixel size for fonts, to fit different dpi in multiple displays

View File

@ -204,5 +204,6 @@
<file>images/newlook/06View-06Todo.svg</file> <file>images/newlook/06View-06Todo.svg</file>
<file>images/newlook/05Run-14StepOverInstruction.svg</file> <file>images/newlook/05Run-14StepOverInstruction.svg</file>
<file>images/newlook/05Run-15StepIntoInstruction.svg</file> <file>images/newlook/05Run-15StepIntoInstruction.svg</file>
<file>images/dark-close.svg</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -1115,6 +1115,8 @@ void MainWindow::updateActionIcons()
ui->tabInfos->setIconSize(iconSize); ui->tabInfos->setIconSize(iconSize);
ui->tabMessages->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->setIcon(QIcon(*(pIconsManager->getIcon(IconsManager::ACTION_FILE_NEW))));
ui->actionNew_Project->setIcon(QIcon(*(pIconsManager->getIcon(IconsManager::ACTION_PROJECT_NEW)))); ui->actionNew_Project->setIcon(QIcon(*(pIconsManager->getIcon(IconsManager::ACTION_PROJECT_NEW))));

View File

@ -8,6 +8,7 @@
#include <QCoreApplication> #include <QCoreApplication>
#include <QPixmapCache> #include <QPixmapCache>
#include <QApplication> #include <QApplication>
#include <QSvgRenderer>
#include "../settings.h" #include "../settings.h"
#define BEGIN_STYLE_PIXMAPCACHE(a) \ #define BEGIN_STYLE_PIXMAPCACHE(a) \
@ -756,17 +757,16 @@ void DarkFusionStyle::drawPrimitive(PrimitiveElement elem, const QStyleOption *o
case PE_FrameStatusBarItem: case PE_FrameStatusBarItem:
break; break;
// case PE_IndicatorTabClose: case PE_IndicatorTabClose:
// { {
// Q_D(const QFusionStyle); QIcon closeIcon = proxy()->standardIcon(SP_DialogCloseButton, option, widget);
// if (d->tabBarcloseButtonIcon.isNull()) if ((option->state & State_Enabled) && (option->state & State_MouseOver))
// d->tabBarcloseButtonIcon = proxy()->standardIcon(SP_DialogCloseButton, option, widget); proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget);
// if ((option->state & State_Enabled) && (option->state & State_MouseOver)) int size = pointToPixel(pSettings->environment().interfaceFontSize());
// proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget); QPixmap pixmap = closeIcon.pixmap(QSize(size, size), QIcon::Normal, QIcon::On);
// QPixmap pixmap = d->tabBarcloseButtonIcon.pixmap(qt_getWindow(widget), QSize(16, 16), QIcon::Normal, QIcon::On); proxy()->drawItemPixmap(painter, option->rect, Qt::AlignCenter, pixmap);
// proxy()->drawItemPixmap(painter, option->rect, Qt::AlignCenter, pixmap); }
// } break;
// break;
case PE_PanelMenu: { case PE_PanelMenu: {
painter->save(); painter->save();
const QBrush menuBackground = option->palette.base().color().darker(108); const QBrush menuBackground = option->palette.base().color().darker(108);
@ -786,8 +786,15 @@ QIcon DarkFusionStyle::standardIcon(StandardPixmap standardIcon, const QStyleOpt
switch (standardIcon) { switch (standardIcon) {
case SP_TitleBarCloseButton: case SP_TitleBarCloseButton:
case SP_DockWidgetCloseButton: case SP_DockWidgetCloseButton:
case SP_DialogCloseButton: case SP_DialogCloseButton: {
return QIcon(":/themes/dark_close.png"); 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: default:
break; break;
} }
@ -805,6 +812,9 @@ int DarkFusionStyle::pixelMetric(PixelMetric metric, const QStyleOption *option,
switch ( metric ) { switch ( metric ) {
case QStyle::PM_SmallIconSize: case QStyle::PM_SmallIconSize:
return pointToPixel(pSettings->environment().interfaceFontSize()); return pointToPixel(pSettings->environment().interfaceFontSize());
case QStyle::PM_TabCloseIndicatorHeight:
case QStyle::PM_TabCloseIndicatorWidth:
return 1.2*pointToPixel(pSettings->environment().interfaceFontSize());
default: default:
return QProxyStyle::pixelMetric( metric, option, widget ); return QProxyStyle::pixelMetric( metric, option, widget );
} }

View File

@ -11,6 +11,9 @@ int LightFusionStyle::pixelMetric(PixelMetric metric, const QStyleOption *option
switch ( metric ) { switch ( metric ) {
case QStyle::PM_SmallIconSize: case QStyle::PM_SmallIconSize:
return pointToPixel(pSettings->environment().interfaceFontSize()); return pointToPixel(pSettings->environment().interfaceFontSize());
case QStyle::PM_TabCloseIndicatorHeight:
case QStyle::PM_TabCloseIndicatorWidth:
return 1.2*pointToPixel(pSettings->environment().interfaceFontSize());
default: default:
return QProxyStyle::pixelMetric( metric, option, widget ); return QProxyStyle::pixelMetric( metric, option, widget );
} }