Compare commits
No commits in common. "7fdea56785c003d7c27354a7205068cb7855492f" and "8ab8822448c8e8ef106e7c15f94d9069554a6ca9" have entirely different histories.
7fdea56785
...
8ab8822448
|
@ -81,7 +81,6 @@ namespace Utils
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 defaultScreenDpi();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 defaultScreenDpi();
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowAccelerated(const QWindow *window);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowAccelerated(const QWindow *window);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowTransparent(const QWindow *window);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowTransparent(const QWindow *window);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QColor calculateForegroundColor(const QColor &backgroundColor);
|
|
||||||
|
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowsVersionOrGreater(const Global::WindowsVersion version);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowsVersionOrGreater(const Global::WindowsVersion version);
|
||||||
|
|
|
@ -93,7 +93,16 @@ void ChromePalettePrivate::refresh()
|
||||||
titleBarInactiveBackgroundColor_sys = (dark ? kDefaultSystemDarkColor : kDefaultWhiteColor);
|
titleBarInactiveBackgroundColor_sys = (dark ? kDefaultSystemDarkColor : kDefaultWhiteColor);
|
||||||
titleBarActiveForegroundColor_sys = [this, dark, colorized]() -> QColor {
|
titleBarActiveForegroundColor_sys = [this, dark, colorized]() -> QColor {
|
||||||
if (dark || colorized) {
|
if (dark || colorized) {
|
||||||
return Utils::calculateForegroundColor(titleBarActiveBackgroundColor_sys);
|
// Calculate the most appropriate foreground color, based on the
|
||||||
|
// current background color.
|
||||||
|
const qreal grayF = (
|
||||||
|
(qreal(0.299) * titleBarActiveBackgroundColor_sys.redF()) +
|
||||||
|
(qreal(0.587) * titleBarActiveBackgroundColor_sys.greenF()) +
|
||||||
|
(qreal(0.114) * titleBarActiveBackgroundColor_sys.blueF()));
|
||||||
|
static constexpr const auto kFlag = qreal(0.5);
|
||||||
|
if ((grayF < kFlag) || qFuzzyCompare(grayF, kFlag)) {
|
||||||
|
return kDefaultWhiteColor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return kDefaultBlackColor;
|
return kDefaultBlackColor;
|
||||||
}();
|
}();
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "framelesshelpercore_global_p.h"
|
#include "framelesshelpercore_global_p.h"
|
||||||
#include "framelessmanager_p.h"
|
#include "framelessmanager_p.h"
|
||||||
#include "framelessmanager.h"
|
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
# include "winverhelper_p.h"
|
# include "winverhelper_p.h"
|
||||||
#endif // Q_OS_WINDOWS
|
#endif // Q_OS_WINDOWS
|
||||||
|
@ -279,28 +278,25 @@ QColor Utils::calculateSystemButtonBackgroundColor(const SystemButtonType button
|
||||||
if (state == ButtonState::Normal) {
|
if (state == ButtonState::Normal) {
|
||||||
return kDefaultTransparentColor;
|
return kDefaultTransparentColor;
|
||||||
}
|
}
|
||||||
const bool isDark = (FramelessManager::instance()->systemTheme() == SystemTheme::Dark);
|
|
||||||
const bool isClose = (button == SystemButtonType::Close);
|
const bool isClose = (button == SystemButtonType::Close);
|
||||||
const bool isTitleColor = isTitleBarColorized();
|
const bool isTitleColor = isTitleBarColorized();
|
||||||
const bool isHovered = (state == ButtonState::Hovered);
|
const bool isHovered = (state == ButtonState::Hovered);
|
||||||
auto result = [isDark, isClose, isTitleColor]() -> QColor {
|
const auto result = [isClose, isTitleColor]() -> QColor {
|
||||||
if (isClose) {
|
if (isClose) {
|
||||||
return kDefaultSystemCloseButtonBackgroundColor;
|
return kDefaultSystemCloseButtonBackgroundColor;
|
||||||
}
|
}
|
||||||
if (isTitleColor) {
|
if (isTitleColor) {
|
||||||
return calculateForegroundColor(getAccentColor());
|
return getAccentColor();
|
||||||
}
|
}
|
||||||
return (isDark ? kDefaultWhiteColor : kDefaultBlackColor);
|
return kDefaultSystemButtonBackgroundColor;
|
||||||
}();
|
}();
|
||||||
if (isClose) {
|
if (isClose) {
|
||||||
return (isHovered ? result.lighter(110) : result.lighter(140));
|
return (isHovered ? result.lighter(110) : result.lighter(140));
|
||||||
}
|
}
|
||||||
if (isHovered) {
|
if (!isTitleColor) {
|
||||||
result.setAlpha(12);
|
return (isHovered ? result.lighter(110) : result);
|
||||||
} else {
|
|
||||||
result.setAlpha(6);
|
|
||||||
}
|
}
|
||||||
return result;
|
return (isHovered ? result.lighter(150) : result.lighter(120));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Utils::shouldAppsUseDarkMode()
|
bool Utils::shouldAppsUseDarkMode()
|
||||||
|
@ -643,26 +639,4 @@ bool Utils::isWindowTransparent(const QWindow *window)
|
||||||
return window->format().hasAlpha();
|
return window->format().hasAlpha();
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor Utils::calculateForegroundColor(const QColor &backgroundColor)
|
|
||||||
{
|
|
||||||
Q_ASSERT(backgroundColor.isValid());
|
|
||||||
if (!backgroundColor.isValid()) {
|
|
||||||
return kDefaultBlackColor;
|
|
||||||
}
|
|
||||||
static constexpr const auto kFlag = qreal(0.5);
|
|
||||||
if (backgroundColor.alphaF() < kFlag) {
|
|
||||||
return kDefaultBlackColor;
|
|
||||||
}
|
|
||||||
// Calculate the most appropriate foreground color, based on the
|
|
||||||
// current background color.
|
|
||||||
const qreal grayF = (
|
|
||||||
(qreal(0.299) * backgroundColor.redF()) +
|
|
||||||
(qreal(0.587) * backgroundColor.greenF()) +
|
|
||||||
(qreal(0.114) * backgroundColor.blueF()));
|
|
||||||
if ((grayF < kFlag) || qFuzzyCompare(grayF, kFlag)) {
|
|
||||||
return kDefaultWhiteColor;
|
|
||||||
}
|
|
||||||
return kDefaultBlackColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
|
@ -240,9 +240,6 @@ void QuickStandardSystemButton::updateColor()
|
||||||
if (!hover && !active && m_inactiveForegroundColor.isValid()) {
|
if (!hover && !active && m_inactiveForegroundColor.isValid()) {
|
||||||
return m_inactiveForegroundColor;
|
return m_inactiveForegroundColor;
|
||||||
}
|
}
|
||||||
if ((m_buttonType == QuickGlobal::SystemButtonType::Close) && hover) {
|
|
||||||
return kDefaultWhiteColor;
|
|
||||||
}
|
|
||||||
if (m_activeForegroundColor.isValid()) {
|
if (m_activeForegroundColor.isValid()) {
|
||||||
return m_activeForegroundColor;
|
return m_activeForegroundColor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -305,13 +305,12 @@ void StandardSystemButton::paintEvent(QPaintEvent *event)
|
||||||
painter.save();
|
painter.save();
|
||||||
painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing
|
painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing
|
||||||
| QPainter::SmoothPixmapTransform);
|
| QPainter::SmoothPixmapTransform);
|
||||||
const bool isHovering = underMouse();
|
const auto backgroundColor = [this, d]() -> QColor {
|
||||||
const auto backgroundColor = [isHovering, d, this]() -> QColor {
|
|
||||||
// The pressed state has higher priority than the hovered state.
|
// The pressed state has higher priority than the hovered state.
|
||||||
if (isDown() && d->pressColor.isValid()) {
|
if (isDown() && d->pressColor.isValid()) {
|
||||||
return d->pressColor;
|
return d->pressColor;
|
||||||
}
|
}
|
||||||
if (isHovering && d->hoverColor.isValid()) {
|
if (underMouse() && d->hoverColor.isValid()) {
|
||||||
return d->hoverColor;
|
return d->hoverColor;
|
||||||
}
|
}
|
||||||
if (d->normalColor.isValid()) {
|
if (d->normalColor.isValid()) {
|
||||||
|
@ -324,13 +323,10 @@ void StandardSystemButton::paintEvent(QPaintEvent *event)
|
||||||
painter.fillRect(buttonRect, backgroundColor);
|
painter.fillRect(buttonRect, backgroundColor);
|
||||||
}
|
}
|
||||||
if (!d->glyph.isEmpty()) {
|
if (!d->glyph.isEmpty()) {
|
||||||
painter.setPen([isHovering, d]() -> QColor {
|
painter.setPen([this, d]() -> QColor {
|
||||||
if (!isHovering && !d->active && d->inactiveForegroundColor.isValid()) {
|
if (!underMouse() && !d->active && d->inactiveForegroundColor.isValid()) {
|
||||||
return d->inactiveForegroundColor;
|
return d->inactiveForegroundColor;
|
||||||
}
|
}
|
||||||
if ((d->buttonType == SystemButtonType::Close) && isHovering) {
|
|
||||||
return kDefaultWhiteColor;
|
|
||||||
}
|
|
||||||
if (d->activeForegroundColor.isValid()) {
|
if (d->activeForegroundColor.isValid()) {
|
||||||
return d->activeForegroundColor;
|
return d->activeForegroundColor;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue