Introduce new empty Windows 11 style
A new empty Windows 11 style plugin is introduced and QWindowsVistaStyle module is renamed to QModernWindowsStylePlugin containing styles for Windows Vista and Windows 11. The color palette is adjusted according to the Windows 11 guidelines. [ChangeLog][Windows] Introduction of Windows 11 specific style. [ChangeLog][Windows] Renaming of QWindowsVistaStylePlugin to QModernWindowsStylePlugin Change-Id: I5f67d7e8c9a3033ffe57ecbaebbf0e3fb10c60ab Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
parent
8ac49acca6
commit
65d58e6c41
@ -32,6 +32,7 @@
|
||||
#include <QtGui/qguiapplication.h>
|
||||
#include <QtGui/qpainter.h>
|
||||
#include <QtGui/qpixmapcache.h>
|
||||
#include <QtCore/qoperatingsystemversion.h>
|
||||
#include <qpa/qwindowsysteminterface.h>
|
||||
#include <QtGui/private/qabstractfileiconengine_p.h>
|
||||
#include <QtGui/private/qwindowsfontdatabase_p.h>
|
||||
@ -79,11 +80,11 @@ static inline QColor mixColors(const QColor &c1, const QColor &c2)
|
||||
(c1.blue() + c2.blue()) / 2};
|
||||
}
|
||||
|
||||
static inline QColor getSysColor(int index)
|
||||
{
|
||||
COLORREF cr = GetSysColor(index);
|
||||
return QColor(GetRValue(cr), GetGValue(cr), GetBValue(cr));
|
||||
}
|
||||
enum AccentColorLevel {
|
||||
AccentColorDarkest,
|
||||
AccentColorNormal,
|
||||
AccentColorLightest
|
||||
};
|
||||
|
||||
#if QT_CONFIG(cpp_winrt)
|
||||
static constexpr QColor getSysColor(winrt::Windows::UI::Color &&color)
|
||||
@ -92,6 +93,61 @@ static constexpr QColor getSysColor(winrt::Windows::UI::Color &&color)
|
||||
}
|
||||
#endif
|
||||
|
||||
[[maybe_unused]] [[nodiscard]] static inline QColor qt_accentColor(AccentColorLevel level)
|
||||
{
|
||||
#if QT_CONFIG(cpp_winrt)
|
||||
using namespace winrt::Windows::UI::ViewManagement;
|
||||
const auto settings = UISettings();
|
||||
const QColor accent = getSysColor(settings.GetColorValue(UIColorType::Accent));
|
||||
const QColor accentLight = getSysColor(settings.GetColorValue(UIColorType::AccentLight1));
|
||||
const QColor accentDarkest = getSysColor(settings.GetColorValue(UIColorType::AccentDark3));
|
||||
#else
|
||||
const QWinRegistryKey registry(HKEY_CURRENT_USER, LR"(Software\Microsoft\Windows\DWM)");
|
||||
if (!registry.isValid())
|
||||
return {};
|
||||
const QVariant value = registry.value(L"AccentColor");
|
||||
if (!value.isValid())
|
||||
return {};
|
||||
// The retrieved value is in the #AABBGGRR format, we need to
|
||||
// convert it to the #AARRGGBB format which Qt expects.
|
||||
const QColor abgr = QColor::fromRgba(qvariant_cast<DWORD>(value));
|
||||
if (!abgr.isValid())
|
||||
return {};
|
||||
const QColor accent = QColor::fromRgb(abgr.blue(), abgr.green(), abgr.red(), abgr.alpha());
|
||||
const QColor accentLight = accent.lighter(120);
|
||||
const QColor accentDarkest = accent.darker(120 * 120 * 120);
|
||||
#endif
|
||||
if (level == AccentColorDarkest)
|
||||
return accentDarkest;
|
||||
else if (level == AccentColorLightest)
|
||||
return accentLight;
|
||||
return accent;
|
||||
}
|
||||
|
||||
static inline QColor getSysColor(int index)
|
||||
{
|
||||
static const bool isWin11OrUpward = QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows11;
|
||||
static const bool highContrastMode = QWindowsTheme::queryHighContrast();
|
||||
|
||||
if (isWin11OrUpward && !highContrastMode) {
|
||||
switch (index) {
|
||||
case COLOR_WINDOW:
|
||||
return QColor(0xF3,0xF3,0xF3,0xFF);
|
||||
case COLOR_3DFACE:
|
||||
return QColor(0xFF,0xFF,0xFF,0xB3);
|
||||
case COLOR_WINDOWTEXT:
|
||||
case COLOR_BTNTEXT:
|
||||
return QColor(0x00,0x00,0x00,0xE4);
|
||||
case COLOR_HIGHLIGHT:
|
||||
return qt_accentColor(AccentColorNormal);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
COLORREF cr = GetSysColor(index);
|
||||
return QColor(GetRValue(cr), GetGValue(cr), GetBValue(cr));
|
||||
}
|
||||
|
||||
// QTBUG-48823/Windows 10: SHGetFileInfo() (as called by item views on file system
|
||||
// models has been observed to trigger a WM_PAINT on the mainwindow. Suppress the
|
||||
// behavior by running it in a thread.
|
||||
@ -221,63 +277,42 @@ static QColor placeHolderColor(QColor textColor)
|
||||
return textColor;
|
||||
}
|
||||
|
||||
[[maybe_unused]] [[nodiscard]] static inline QColor qt_accentColor()
|
||||
{
|
||||
const QWinRegistryKey registry(HKEY_CURRENT_USER, LR"(Software\Microsoft\Windows\DWM)");
|
||||
if (!registry.isValid())
|
||||
return {};
|
||||
const QVariant value = registry.value(L"AccentColor");
|
||||
if (!value.isValid())
|
||||
return {};
|
||||
// The retrieved value is in the #AABBGGRR format, we need to
|
||||
// convert it to the #AARRGGBB format which Qt expects.
|
||||
const QColor abgr = QColor::fromRgba(qvariant_cast<DWORD>(value));
|
||||
if (!abgr.isValid())
|
||||
return {};
|
||||
return QColor::fromRgb(abgr.blue(), abgr.green(), abgr.red(), abgr.alpha());
|
||||
}
|
||||
|
||||
/*
|
||||
This is used when the theme is light mode, and when the theme is dark but the
|
||||
application doesn't support dark mode. In the latter case, we need to check.
|
||||
|
||||
The colors for Windows 11 are taken from the official WinUI3 Figma style at
|
||||
https://www.figma.com/community/file/1159947337437047524
|
||||
*/
|
||||
static void populateLightSystemBasePalette(QPalette &result)
|
||||
{
|
||||
const QColor background = getSysColor(COLOR_BTNFACE);
|
||||
const QColor textColor = getSysColor(COLOR_WINDOWTEXT);
|
||||
|
||||
#if QT_CONFIG(cpp_winrt)
|
||||
// respect the Windows 11 accent color
|
||||
using namespace winrt::Windows::UI::ViewManagement;
|
||||
const auto settings = UISettings();
|
||||
|
||||
const QColor accent = getSysColor(settings.GetColorValue(UIColorType::Accent));
|
||||
const QColor accentDarkest = getSysColor(settings.GetColorValue(UIColorType::AccentDark3));
|
||||
#else
|
||||
const QColor accent = qt_accentColor();
|
||||
const QColor accentDarkest = accent.darker(120 * 120 * 120);
|
||||
#endif
|
||||
const QColor accent = qt_accentColor(AccentColorNormal);
|
||||
const QColor accentDarkest = qt_accentColor(AccentColorDarkest);
|
||||
|
||||
const QColor linkColor = accent;
|
||||
const QColor btnFace = background;
|
||||
const QColor btnHighlight = getSysColor(COLOR_BTNHIGHLIGHT);
|
||||
const QColor btnFace = getSysColor(COLOR_3DFACE);
|
||||
const QColor btnHighlight = getSysColor(COLOR_HIGHLIGHT);
|
||||
|
||||
result.setColor(QPalette::Highlight, getSysColor(COLOR_HIGHLIGHT));
|
||||
result.setColor(QPalette::WindowText, getSysColor(COLOR_WINDOWTEXT));
|
||||
result.setColor(QPalette::Button, btnFace);
|
||||
result.setColor(QPalette::Light, btnHighlight);
|
||||
result.setColor(QPalette::Dark, getSysColor(COLOR_BTNSHADOW));
|
||||
result.setColor(QPalette::Light, result.button().color().lighter(150));
|
||||
result.setColor(QPalette::Dark, result.button().color().darker(200));
|
||||
result.setColor(QPalette::Mid, result.button().color().darker(150));
|
||||
result.setColor(QPalette::Text, textColor);
|
||||
result.setColor(QPalette::PlaceholderText, placeHolderColor(textColor));
|
||||
result.setColor(QPalette::BrightText, btnHighlight);
|
||||
result.setColor(QPalette::Base, getSysColor(COLOR_WINDOW));
|
||||
result.setColor(QPalette::Window, btnFace);
|
||||
result.setColor(QPalette::Base, getSysColor(COLOR_3DFACE));
|
||||
result.setColor(QPalette::Window, getSysColor(COLOR_WINDOW));
|
||||
result.setColor(QPalette::ButtonText, getSysColor(COLOR_BTNTEXT));
|
||||
result.setColor(QPalette::Midlight, getSysColor(COLOR_3DLIGHT));
|
||||
result.setColor(QPalette::Shadow, getSysColor(COLOR_3DDKSHADOW));
|
||||
result.setColor(QPalette::Midlight, result.button().color().lighter(125));
|
||||
result.setColor(QPalette::Shadow, Qt::black);
|
||||
result.setColor(QPalette::HighlightedText, getSysColor(COLOR_HIGHLIGHTTEXT));
|
||||
result.setColor(QPalette::Accent, accent);
|
||||
result.setColor(QPalette::ToolTipBase, getSysColor(COLOR_WINDOW));
|
||||
result.setColor(QPalette::ToolTipText, getSysColor(COLOR_WINDOWTEXT));
|
||||
|
||||
result.setColor(QPalette::Link, linkColor);
|
||||
result.setColor(QPalette::LinkVisited, accentDarkest);
|
||||
@ -317,7 +352,7 @@ static void populateDarkSystemBasePalette(QPalette &result)
|
||||
#else
|
||||
const QColor foreground = Qt::white;
|
||||
const QColor background = QColor(0x1E, 0x1E, 0x1E);
|
||||
const QColor accent = qt_accentColor();
|
||||
const QColor accent = qt_accentColor(AccentColorNormal);
|
||||
const QColor accentDark = accent.darker(120);
|
||||
const QColor accentDarker = accentDark.darker(120);
|
||||
const QColor accentDarkest = accentDarker.darker(120);
|
||||
@ -357,9 +392,9 @@ static void populateDarkSystemBasePalette(QPalette &result)
|
||||
static inline QPalette toolTipPalette(const QPalette &systemPalette, bool light)
|
||||
{
|
||||
QPalette result(systemPalette);
|
||||
const QColor tipBgColor = light ? getSysColor(COLOR_INFOBK)
|
||||
const QColor tipBgColor = light ? getSysColor(COLOR_WINDOW)
|
||||
: systemPalette.button().color();
|
||||
const QColor tipTextColor = light ? getSysColor(COLOR_INFOTEXT)
|
||||
const QColor tipTextColor = light ? getSysColor(COLOR_WINDOWTEXT)
|
||||
: systemPalette.buttonText().color().darker(120);
|
||||
|
||||
result.setColor(QPalette::All, QPalette::Button, tipBgColor);
|
||||
@ -384,14 +419,18 @@ static inline QPalette toolTipPalette(const QPalette &systemPalette, bool light)
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
The colors for Windows 11 are taken from the official WinUI3 Figma style at
|
||||
https://www.figma.com/community/file/1159947337437047524
|
||||
*/
|
||||
static inline QPalette menuPalette(const QPalette &systemPalette, bool light)
|
||||
{
|
||||
if (!light)
|
||||
return systemPalette;
|
||||
|
||||
QPalette result(systemPalette);
|
||||
const QColor menuColor = getSysColor(COLOR_MENU);
|
||||
const QColor menuTextColor = getSysColor(COLOR_MENUTEXT);
|
||||
const QColor menuColor = getSysColor(COLOR_3DFACE);
|
||||
const QColor menuTextColor = getSysColor(COLOR_WINDOWTEXT);
|
||||
const QColor disabled = getSysColor(COLOR_GRAYTEXT);
|
||||
// we might need a special color group for the result.
|
||||
result.setColor(QPalette::Active, QPalette::Button, menuColor);
|
||||
@ -400,9 +439,10 @@ static inline QPalette menuPalette(const QPalette &systemPalette, bool light)
|
||||
result.setColor(QPalette::Active, QPalette::ButtonText, menuTextColor);
|
||||
result.setColor(QPalette::Disabled, QPalette::WindowText, disabled);
|
||||
result.setColor(QPalette::Disabled, QPalette::Text, disabled);
|
||||
const bool isFlat = booleanSystemParametersInfo(SPI_GETFLATMENU, false);
|
||||
const QColor highlightColor = getSysColor(isFlat ? COLOR_MENUHILIGHT : COLOR_HIGHLIGHT);
|
||||
result.setColor(QPalette::Disabled, QPalette::Highlight, highlightColor);
|
||||
const QColor highlightColor = getSysColor(COLOR_HIGHLIGHT);
|
||||
result.setColor(QPalette::Active, QPalette::Highlight, highlightColor);
|
||||
|
||||
result.setColor(QPalette::Active, QPalette::HighlightedText, menuTextColor);
|
||||
result.setColor(QPalette::Disabled, QPalette::HighlightedText, disabled);
|
||||
result.setColor(QPalette::Disabled, QPalette::Button,
|
||||
result.color(QPalette::Active, QPalette::Button));
|
||||
@ -423,6 +463,10 @@ static inline QPalette menuPalette(const QPalette &systemPalette, bool light)
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
The colors for Windows 11 are taken from the official WinUI3 Figma style at
|
||||
https://www.figma.com/community/file/1159947337437047524
|
||||
*/
|
||||
static inline QPalette *menuBarPalette(const QPalette &menuPalette, bool light)
|
||||
{
|
||||
QPalette *result = nullptr;
|
||||
@ -430,7 +474,7 @@ static inline QPalette *menuBarPalette(const QPalette &menuPalette, bool light)
|
||||
return result;
|
||||
|
||||
result = new QPalette(menuPalette);
|
||||
const QColor menubar(getSysColor(COLOR_MENUBAR));
|
||||
const QColor menubar = getSysColor(COLOR_WINDOW);
|
||||
result->setColor(QPalette::Active, QPalette::Button, menubar);
|
||||
result->setColor(QPalette::Disabled, QPalette::Button, menubar);
|
||||
result->setColor(QPalette::Inactive, QPalette::Button, menubar);
|
||||
@ -464,7 +508,10 @@ static inline QStringList iconThemeSearchPaths()
|
||||
|
||||
static inline QStringList styleNames()
|
||||
{
|
||||
return { QStringLiteral("WindowsVista"), QStringLiteral("Windows") };
|
||||
QStringList styles = { QStringLiteral("WindowsVista"), QStringLiteral("Windows") };
|
||||
if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows11)
|
||||
styles.prepend(QStringLiteral("Windows11"));
|
||||
return styles;
|
||||
}
|
||||
|
||||
static inline int uiEffects()
|
||||
@ -551,29 +598,20 @@ void QWindowsTheme::refreshPalettes()
|
||||
m_palettes[MenuPalette] = new QPalette(menuPalette(*m_palettes[SystemPalette], light));
|
||||
m_palettes[MenuBarPalette] = menuBarPalette(*m_palettes[MenuPalette], light);
|
||||
if (!light) {
|
||||
#if QT_CONFIG(cpp_winrt)
|
||||
using namespace winrt::Windows::UI::ViewManagement;
|
||||
const auto settings = UISettings();
|
||||
const QColor accent = getSysColor(settings.GetColorValue(UIColorType::Accent));
|
||||
const QColor accentLight = getSysColor(settings.GetColorValue(UIColorType::AccentLight1));
|
||||
const QColor accentDarkest = getSysColor(settings.GetColorValue(UIColorType::AccentDark3));
|
||||
#else
|
||||
const QColor accent = qt_accentColor();
|
||||
const QColor accentLight = accent.lighter(120);
|
||||
const QColor accentDarkest = accent.darker(120 * 120 * 120);
|
||||
#endif
|
||||
m_palettes[CheckBoxPalette] = new QPalette(*m_palettes[SystemPalette]);
|
||||
m_palettes[CheckBoxPalette]->setColor(QPalette::Active, QPalette::Base, accent);
|
||||
m_palettes[CheckBoxPalette]->setColor(QPalette::Active, QPalette::Button, accentLight);
|
||||
m_palettes[CheckBoxPalette]->setColor(QPalette::Inactive, QPalette::Base, accentDarkest);
|
||||
m_palettes[CheckBoxPalette]->setColor(QPalette::Active, QPalette::Base, qt_accentColor(AccentColorNormal));
|
||||
m_palettes[CheckBoxPalette]->setColor(QPalette::Active, QPalette::Button, qt_accentColor(AccentColorLightest));
|
||||
m_palettes[CheckBoxPalette]->setColor(QPalette::Inactive, QPalette::Base, qt_accentColor(AccentColorDarkest));
|
||||
m_palettes[RadioButtonPalette] = new QPalette(*m_palettes[CheckBoxPalette]);
|
||||
}
|
||||
}
|
||||
|
||||
QPalette QWindowsTheme::systemPalette(Qt::ColorScheme colorScheme)
|
||||
{
|
||||
QPalette result = standardPalette();
|
||||
static const bool isWin11OrUpward = QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows11;
|
||||
static const bool highContrastMode = QWindowsTheme::queryHighContrast();
|
||||
|
||||
QPalette result = standardPalette();
|
||||
switch (colorScheme) {
|
||||
case Qt::ColorScheme::Light:
|
||||
populateLightSystemBasePalette(result);
|
||||
@ -586,7 +624,7 @@ QPalette QWindowsTheme::systemPalette(Qt::ColorScheme colorScheme)
|
||||
break;
|
||||
}
|
||||
|
||||
if (result.window() != result.base()) {
|
||||
if (result.window() != result.base() && (!isWin11OrUpward || highContrastMode)) {
|
||||
result.setColor(QPalette::Inactive, QPalette::Highlight,
|
||||
result.color(QPalette::Inactive, QPalette::Window));
|
||||
result.setColor(QPalette::Inactive, QPalette::HighlightedText,
|
||||
|
@ -8,5 +8,5 @@ if(QT_FEATURE_style_mac)
|
||||
add_subdirectory(mac)
|
||||
endif()
|
||||
if(QT_FEATURE_style_windowsvista)
|
||||
add_subdirectory(windowsvista)
|
||||
add_subdirectory(modernwindows)
|
||||
endif()
|
||||
|
@ -5,12 +5,13 @@
|
||||
## QWindowsVistaStylePlugin Plugin:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_plugin(QWindowsVistaStylePlugin
|
||||
OUTPUT_NAME qwindowsvistastyle
|
||||
qt_internal_add_plugin(QModernWindowsStylePlugin
|
||||
OUTPUT_NAME qmodernwindowsstyle
|
||||
PLUGIN_TYPE styles
|
||||
SOURCES
|
||||
main.cpp
|
||||
qwindowsvistastyle.cpp qwindowsvistastyle_p.h
|
||||
qwindows11style.cpp qwindows11style_p.h
|
||||
qwindowsvistastyle_p_p.h
|
||||
qwindowsvistaanimation.cpp qwindowsvistaanimation_p.h
|
||||
qwindowsthemedata.cpp qwindowsthemedata_p.h
|
36
src/plugins/styles/modernwindows/main.cpp
Normal file
36
src/plugins/styles/modernwindows/main.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright (C) 2017 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#include <QtWidgets/private/qtwidgetsglobal_p.h>
|
||||
#include <QtWidgets/qstyleplugin.h>
|
||||
#include <QtCore/qoperatingsystemversion.h>
|
||||
#include "qwindowsvistastyle_p.h"
|
||||
#include "qwindows11style_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QModernWindowsStylePlugin : public QStylePlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE "modernwindowsstyles.json")
|
||||
public:
|
||||
QStyle *create(const QString &key) override;
|
||||
};
|
||||
|
||||
QStyle *QModernWindowsStylePlugin::create(const QString &key)
|
||||
{
|
||||
bool isWin11OrAbove = QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows11;
|
||||
if (isWin11OrAbove && key.compare(QLatin1String("windows11"), Qt::CaseInsensitive) == 0) {
|
||||
return new QWindows11Style();
|
||||
} else if (!isWin11OrAbove && key.compare(QLatin1String("windows11"), Qt::CaseInsensitive) == 0) {
|
||||
qWarning("QWindows11Style: Style is only supported on Windows11 and above");
|
||||
return new QWindowsVistaStyle();
|
||||
} else if (key.compare(QLatin1String("windowsvista"), Qt::CaseInsensitive) == 0) {
|
||||
return new QWindowsVistaStyle();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "main.moc"
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"Keys": [ "windowsvista", "windows11" ]
|
||||
}
|
69
src/plugins/styles/modernwindows/qwindows11style.cpp
Normal file
69
src/plugins/styles/modernwindows/qwindows11style.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
// Copyright (C) 2022 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#include "qwindows11style_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
const static int topLevelRoundingRadius = 8; //Radius for toplevel items like popups for round corners
|
||||
const static int secondLevelRoundingRadius = 4; //Radius for second level items like hovered menu item round corners
|
||||
|
||||
const static QColor subtleHighlightColor(0x00,0x00,0x00,0x09); //Subtle highlight based on alpha used for hovered elements
|
||||
const static QColor subtlePressedColor(0x00,0x00,0x00,0x06); //Subtle highlight based on alpha used for pressed elements
|
||||
const static QColor frameColorLight(0x00,0x00,0x00,0x0F); //Color of frame around flyouts and controls except for Checkbox and Radiobutton
|
||||
const static QColor frameColorStrong(0x00,0x00,0x00,0x9c); //Color of frame around Checkbox and Radiobuttons
|
||||
const static QColor controlStrongFill = QColor(0x00,0x00,0x00,0x72); //Color of controls with strong filling such as the right side of a slider
|
||||
const static QColor controlStrokeSecondary = QColor(0x00,0x00,0x00,0x29);
|
||||
const static QColor controlStrokePrimary = QColor(0x00,0x00,0x00,0x14);
|
||||
const static QColor controlFillTertiary = QColor(0xF9,0xF9,0xF9,0x00); //Color of filled sunken controls
|
||||
const static QColor controlFillSecondary= QColor(0xF9,0xF9,0xF9,0x80); //Color of filled hovered controls
|
||||
const static QColor menuPanelFill = QColor(0xFF,0xFF,0xFF,0xFF); //Color of menu panel
|
||||
const static QColor textOnAccentPrimary = QColor(0xFF,0xFF,0xFF,0xFF); //Color of text on controls filled in accent color
|
||||
const static QColor textOnAccentSecondary = QColor(0xFF,0xFF,0xFF,0x7F); //Color of text of sunken controls in accent color
|
||||
const static QColor controlTextSecondary = QColor(0x00,0x00,0x00,0x7F); //Color of text of sunken controls
|
||||
const static QColor controlStrokeOnAccentSecondary = QColor(0x00,0x00,0x00,0x66); //Color of frame around Buttons in accent color
|
||||
|
||||
/*!
|
||||
\class QWindows11Style
|
||||
\brief The QWindows11Style class provides a look and feel suitable for applications on Microsoft Windows 11.
|
||||
\since 6.6
|
||||
\ingroup appearance
|
||||
\inmodule QtWidgets
|
||||
\internal
|
||||
|
||||
\warning This style is only available on the Windows 11 platform and above.
|
||||
|
||||
\sa QWindows11Style QWindowsVistaStyle, QMacStyle, QFusionStyle
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a QWindows11Style object.
|
||||
*/
|
||||
QWindows11Style::QWindows11Style() : QWindowsVistaStyle(*new QWindows11StylePrivate)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
Constructs a QWindows11Style object.
|
||||
*/
|
||||
QWindows11Style::QWindows11Style(QWindows11StylePrivate &dd) : QWindowsVistaStyle(dd)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destructor.
|
||||
*/
|
||||
QWindows11Style::~QWindows11Style() = default;
|
||||
|
||||
void QWindows11Style::polish(QWidget* widget)
|
||||
{
|
||||
QWindowsVistaStyle::polish(widget);
|
||||
if (widget->inherits("QGraphicsView")) {
|
||||
QPalette pal = widget->palette();
|
||||
pal.setColor(QPalette::Base, pal.window().color());
|
||||
widget->setPalette(pal);
|
||||
}
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
50
src/plugins/styles/modernwindows/qwindows11style_p.h
Normal file
50
src/plugins/styles/modernwindows/qwindows11style_p.h
Normal file
@ -0,0 +1,50 @@
|
||||
// Copyright (C) 2022 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#ifndef QWINDOWS11STYLE_P_H
|
||||
#define QWINDOWS11STYLE_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtWidgets/private/qtwidgetsglobal_p.h>
|
||||
#include <qwindowsvistastyle_p_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QWindows11StylePrivate;
|
||||
class QWindows11Style;
|
||||
|
||||
class QWindows11Style : public QWindowsVistaStyle
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QWindows11Style();
|
||||
~QWindows11Style() override;
|
||||
|
||||
void polish(QWidget* widget) override;
|
||||
protected:
|
||||
QWindows11Style(QWindows11StylePrivate &dd);
|
||||
private:
|
||||
Q_DISABLE_COPY_MOVE(QWindows11Style)
|
||||
Q_DECLARE_PRIVATE(QWindows11Style)
|
||||
friend class QStyleFactory;
|
||||
|
||||
const QFont assetFont = QFont("Segoe Fluent Icons"); //Font to load icons from
|
||||
};
|
||||
|
||||
class QWindows11StylePrivate : public QWindowsVistaStylePrivate {
|
||||
Q_DECLARE_PUBLIC(QWindows11Style)
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QWINDOWS11STYLE_P_H
|
@ -1324,6 +1324,14 @@ QWindowsVistaStyle::QWindowsVistaStyle() : QWindowsStyle(*new QWindowsVistaStyle
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
Constructs a QWindowsStyle object.
|
||||
*/
|
||||
QWindowsVistaStyle::QWindowsVistaStyle(QWindowsVistaStylePrivate &dd) : QWindowsStyle(dd)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destructor.
|
||||
*/
|
@ -59,7 +59,8 @@ public:
|
||||
void unpolish(QWidget *widget) override;
|
||||
void polish(QPalette &pal) override;
|
||||
void polish(QApplication *app) override;
|
||||
|
||||
protected:
|
||||
QWindowsVistaStyle(QWindowsVistaStylePrivate &dd);
|
||||
private:
|
||||
Q_DISABLE_COPY_MOVE(QWindowsVistaStyle)
|
||||
Q_DECLARE_PRIVATE(QWindowsVistaStyle)
|
@ -1,28 +0,0 @@
|
||||
// Copyright (C) 2017 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#include <QtWidgets/private/qtwidgetsglobal_p.h>
|
||||
#include <QtWidgets/qstyleplugin.h>
|
||||
#include "qwindowsvistastyle_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QWindowsVistaStylePlugin : public QStylePlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE "windowsvistastyle.json")
|
||||
public:
|
||||
QStyle *create(const QString &key) override;
|
||||
};
|
||||
|
||||
QStyle *QWindowsVistaStylePlugin::create(const QString &key)
|
||||
{
|
||||
if (key.compare(QLatin1String("windowsvista"), Qt::CaseInsensitive) == 0)
|
||||
return new QWindowsVistaStyle();
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "main.moc"
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"Keys": [ "windowsvista" ]
|
||||
}
|
@ -37,6 +37,10 @@ qt_feature("style-windowsvista" PRIVATE
|
||||
LABEL "WindowsVista"
|
||||
CONDITION QT_FEATURE_style_windows AND QT_FEATURE_animation AND WIN32
|
||||
)
|
||||
qt_feature("style-windows11" PRIVATE
|
||||
LABEL "Windows11"
|
||||
CONDITION QT_FEATURE_style_windows AND QT_FEATURE_animation AND WIN32
|
||||
)
|
||||
qt_feature("style-android" PRIVATE
|
||||
LABEL "Android"
|
||||
AUTODETECT ANDROID
|
||||
|
Loading…
Reference in New Issue
Block a user