Improve macOS platform integration.
- Allow switching between themes without restart (except classic) - Rework icon loading and recolouring logic to react to theme changes - Automatically react to light/dark theme change - Remove explicit selection of monochrome tray icon variant (selected automatically now) - Update theme background colours for Big Sur - Update application icon to match Big Sur HIG The tray icon doesn't respond perfectly to theme changes yet on Big Sur, since we need different icons for dark and light theme and cannot simply let the OS recolour the icon for us (we do that, too, but only as an additional fallback). At the moment, there is no signal to listen to that would allow this. This patch adds a few generic methods to OSUtils for detecting and communicating theme changes, which are only stubs for Windows and Linux at the moment and need to be implemented in future commits. Fixes #4933 Fixes #5349
This commit is contained in:
@@ -52,6 +52,10 @@
|
||||
#include <QtMath>
|
||||
#include <qdrawutil.h>
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
#include <QOperatingSystemVersion>
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "gui/Icons.h"
|
||||
@@ -288,10 +292,16 @@ namespace Phantom
|
||||
#ifdef Q_OS_MACOS
|
||||
QColor tabBarBase(const QPalette& pal)
|
||||
{
|
||||
return hack_isLightPalette(pal) ? QRgb(0xD1D1D1) : QRgb(0x252525);
|
||||
if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::MacOSBigSur) {
|
||||
return hack_isLightPalette(pal) ? QRgb(0xD4D4D4) : QRgb(0x2A2A2A);
|
||||
}
|
||||
return hack_isLightPalette(pal) ? QRgb(0xDD1D1D1) : QRgb(0x252525);
|
||||
}
|
||||
QColor tabBarBaseInactive(const QPalette& pal)
|
||||
{
|
||||
if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::MacOSBigSur) {
|
||||
return hack_isLightPalette(pal) ? QRgb(0xF5F5F5) : QRgb(0x2D2D2D);
|
||||
}
|
||||
return hack_isLightPalette(pal) ? QRgb(0xF4F4F4) : QRgb(0x282828);
|
||||
}
|
||||
#endif
|
||||
@@ -4571,27 +4581,6 @@ QStyle::SubControl BaseStyle::hitTestComplexControl(ComplexControl cc,
|
||||
return QCommonStyle::hitTestComplexControl(cc, opt, pt, w);
|
||||
}
|
||||
|
||||
QPixmap BaseStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap& pixmap, const QStyleOption* opt) const
|
||||
{
|
||||
// Default icon highlight is way too subtle
|
||||
if (iconMode == QIcon::Selected) {
|
||||
QImage img = pixmap.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied);
|
||||
QPainter painter(&img);
|
||||
|
||||
painter.setCompositionMode(QPainter::CompositionMode_SourceAtop);
|
||||
|
||||
QColor color =
|
||||
Phantom::DeriveColors::adjustLightness(opt->palette.color(QPalette::Normal, QPalette::Highlight), .25);
|
||||
color.setAlphaF(0.25);
|
||||
painter.fillRect(0, 0, img.width(), img.height(), color);
|
||||
|
||||
painter.end();
|
||||
|
||||
return QPixmap::fromImage(img);
|
||||
}
|
||||
return QCommonStyle::generatedIconPixmap(iconMode, pixmap, opt);
|
||||
}
|
||||
|
||||
int BaseStyle::styleHint(StyleHint hint,
|
||||
const QStyleOption* option,
|
||||
const QWidget* widget,
|
||||
|
||||
Reference in New Issue
Block a user