From a81e09bcd3dfe9f7e44db60f9feb02284155aa6b Mon Sep 17 00:00:00 2001 From: Sine Striker <trueful@163.com> Date: ćšć, 14 12æ 2023 14:46:43 +0800 Subject: [PATCH] minor tweaks --- src/core/contexts/abstractwindowcontext.cpp | 53 ++++++++++++++++++++++++----------------------------- 1 files changed, 24 insertions(+), 29 deletions(-) diff --git a/src/core/contexts/abstractwindowcontext.cpp b/src/core/contexts/abstractwindowcontext.cpp index d3e8c0f..3b2340f 100644 --- a/src/core/contexts/abstractwindowcontext.cpp +++ b/src/core/contexts/abstractwindowcontext.cpp @@ -7,13 +7,6 @@ namespace QWK { - QWK_USED static constexpr const struct { - const quint32 activeLight = MAKE_RGBA_COLOR(210, 233, 189, 226); - const quint32 activeDark = MAKE_RGBA_COLOR(177, 205, 190, 240); - const quint32 inactiveLight = MAKE_RGBA_COLOR(193, 195, 211, 203); - const quint32 inactiveDark = MAKE_RGBA_COLOR(240, 240, 250, 255); - } kSampleColorSet; - AbstractWindowContext::AbstractWindowContext() = default; AbstractWindowContext::~AbstractWindowContext() = default; @@ -98,10 +91,6 @@ return true; } - void AbstractWindowContext::showSystemMenu(const QPoint &pos) { - virtual_hook(ShowSystemMenuHook, &const_cast<QPoint &>(pos)); - } - QRegion AbstractWindowContext::hitTestShape() const { if (hitTestVisibleShapeDirty) { hitTestVisibleShape = {}; @@ -178,30 +167,32 @@ return {}; } + QWK_USED static constexpr const struct { + const quint32 activeLight = MAKE_RGBA_COLOR(210, 233, 189, 226); + const quint32 activeDark = MAKE_RGBA_COLOR(177, 205, 190, 240); + const quint32 inactiveLight = MAKE_RGBA_COLOR(193, 195, 211, 203); + const quint32 inactiveDark = MAKE_RGBA_COLOR(240, 240, 250, 255); + } kSampleColorSet; + void AbstractWindowContext::virtual_hook(int id, void *data) { switch (id) { - case NeedsDrawBordersHook: { - auto &result = *static_cast<bool *>(data); - result = false; - return; + case CentralizeHook: { + // TODO: Qt + break; } - case BorderThicknessHook: { - auto args = static_cast<void **>(data); - const bool requireNative = *static_cast<const bool *>(args[0]); - quint32 &thickness = *static_cast<quint32 *>(args[1]); - std::ignore = requireNative; - thickness = 1; - return; + case ShowSystemMenuHook: { + // TODO: Qt + break; } - case BorderColorsHook: { - auto arr = *reinterpret_cast<QList<QColor> *>(data); - arr.clear(); - arr.push_back(kSampleColorSet.activeLight); - arr.push_back(kSampleColorSet.activeDark); - arr.push_back(kSampleColorSet.inactiveLight); - arr.push_back(kSampleColorSet.inactiveDark); + case DefaultColorsHook: { + auto &map = *static_cast<QMap<QString, QColor> *>(data); + map.clear(); + map.insert(QStringLiteral("activeLight"), kSampleColorSet.activeLight); + map.insert(QStringLiteral("activeDark"), kSampleColorSet.activeDark); + map.insert(QStringLiteral("inactiveLight"), kSampleColorSet.inactiveLight); + map.insert(QStringLiteral("inactiveDark"), kSampleColorSet.inactiveDark); return; } @@ -210,4 +201,8 @@ } } + void AbstractWindowContext::showSystemMenu(const QPoint &pos) { + virtual_hook(ShowSystemMenuHook, &const_cast<QPoint &>(pos)); + } + } \ No newline at end of file -- Gitblit v1.9.1