-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: 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

View File

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

View File

@ -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))));

View File

@ -8,6 +8,7 @@
#include <QCoreApplication>
#include <QPixmapCache>
#include <QApplication>
#include <QSvgRenderer>
#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 );
}

View File

@ -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 );
}