quick: simplify implementation

1. Merge the three system buttons into one class.
2. Fixed some color calculation errors of system button.
3. Removed some not used bundled resources.
4. Added function to retrieve runtime version of FramelessHelper.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2022-05-13 17:33:01 +08:00
parent 8042a78b8f
commit d13d74783f
24 changed files with 272 additions and 613 deletions

View File

@ -25,7 +25,7 @@
cmake_minimum_required(VERSION 3.20)
project(FramelessHelper
VERSION 2.1.0.0
VERSION 2.1.1.0
DESCRIPTION "Cross-platform window customization framework for Qt Widgets and Qt Quick."
HOMEPAGE_URL "https://github.com/wangwenx190/framelesshelper/"
LANGUAGES CXX

View File

@ -143,6 +143,8 @@ void MyWidget::myFunction2()
}
```
**IMPORTANT NOTE**: Some functionalities may only be available when `FramelessHelper` has finished the window customization process, such as changing window geometry/flags/state. In this case you can connect to the public `void ready()` signal of `FramelessHelper` to get the accurate time point and do your rest initialization process afterwards.
### Qt Quick
#### Code snippet
@ -223,6 +225,26 @@ If you find any of `FramelessHelper` functions have no effect after calling, the
There's also a QML type called `FramelessWindow`, it's only a simple wrapper of `FramelessHelper`, you can absolutely use plain `Window` instead.
**IMPORTANT NOTE**: Some functionalities may only be available when `FramelessHelper` has finished the window customization process, such as changing window geometry/flags/state. In this case you can connect to the public `void ready()` signal of `FramelessHelper` to get the accurate time point and do your rest initialization process afterwards.
```qml
Window {
FramelessHelper.onReady: {
// do something here ...
}
}
```
```qml
Window {
FramelessHelper {
onReady: {
// do something here ...
}
}
}
```
### More
Please refer to the demo projects to see more detailed usages: [examples](./examples/)

View File

@ -152,8 +152,31 @@ QT_END_NAMESPACE
# define FRAMELESSHELPER_PREPEND_NAMESPACE(X) ::FRAMELESSHELPER_NAMESPACE::X
#endif
#ifndef FRAMELESSHELPER_MAKE_VERSION
# define FRAMELESSHELPER_MAKE_VERSION(Major, Minor, Patch, Tweak) \
(((Major & 0xff) << 24) | ((Minor & 0xff) << 16) | ((Patch & 0xff) << 8) | (Tweak & 0xff))
#endif
#ifndef FRAMELESSHELPER_EXTRACT_VERSION
# define FRAMELESSHELPER_EXTRACT_VERSION(Version, Major, Minor, Patch, Tweak) \
{ \
Major = ((Version & 0xff) >> 24); \
Minor = ((Version & 0xff) >> 16); \
Patch = ((Version & 0xff) >> 8); \
Tweak = (Version & 0xff); \
}
#endif
FRAMELESSHELPER_BEGIN_NAMESPACE
[[maybe_unused]] static constexpr const int FRAMELESSHELPER_VERSION_MAJOR = 2;
[[maybe_unused]] static constexpr const int FRAMELESSHELPER_VERSION_MINOR = 1;
[[maybe_unused]] static constexpr const int FRAMELESSHELPER_VERSION_PATCH = 1;
[[maybe_unused]] static constexpr const int FRAMELESSHELPER_VERSION_TWEAK = 0;
[[maybe_unused]] static constexpr const int FRAMELESSHELPER_VERSION =
FRAMELESSHELPER_MAKE_VERSION(FRAMELESSHELPER_VERSION_MAJOR, FRAMELESSHELPER_VERSION_MINOR,
FRAMELESSHELPER_VERSION_PATCH, FRAMELESSHELPER_VERSION_TWEAK);
namespace Global
{
@ -471,6 +494,7 @@ static_assert(std::size(WindowsVersions) == (static_cast<int>(WindowsVersion::_1
namespace FramelessHelper::Core
{
FRAMELESSHELPER_CORE_API void initialize();
[[nodiscard]] FRAMELESSHELPER_CORE_API int version();
} // namespace FramelessHelper::Core
FRAMELESSHELPER_END_NAMESPACE

View File

@ -1,79 +0,0 @@
/*
* MIT License
*
* Copyright (C) 2022 by wangwenx190 (Yuhang Zhao)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#pragma once
#include "framelesshelperquick_global.h"
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#include <QtQuickTemplates2/private/qquickbutton_p.h>
QT_BEGIN_NAMESPACE
class QQuickImage;
class QQuickRectangle;
QT_END_NAMESPACE
FRAMELESSHELPER_BEGIN_NAMESPACE
class FRAMELESSHELPER_QUICK_API QuickStandardMaximizeButton : public QQuickButton
{
Q_OBJECT
#ifdef QML_NAMED_ELEMENT
QML_NAMED_ELEMENT(StandardMaximizeButton)
#endif
Q_DISABLE_COPY_MOVE(QuickStandardMaximizeButton)
Q_PROPERTY(bool maximized READ isMaximized WRITE setMaximized NOTIFY maximizedChanged FINAL)
public:
explicit QuickStandardMaximizeButton(QQuickItem *parent = nullptr);
~QuickStandardMaximizeButton() override;
Q_NODISCARD bool isMaximized() const;
void setMaximized(const bool max);
public Q_SLOTS:
void updateForeground();
void updateBackground();
void setInactive(const bool value);
Q_SIGNALS:
void maximizedChanged();
private:
void initialize();
void checkInactive();
private:
bool m_max = false;
QScopedPointer<QQuickItem> m_contentItem;
QScopedPointer<QQuickImage> m_image;
QScopedPointer<QQuickRectangle> m_backgroundItem;
bool m_forceLightTheme = false;
bool m_shouldCheck = false;
bool m_checkFlag = false;
};
FRAMELESSHELPER_END_NAMESPACE
QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickStandardMaximizeButton))
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))

View File

@ -1,71 +0,0 @@
/*
* MIT License
*
* Copyright (C) 2022 by wangwenx190 (Yuhang Zhao)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#pragma once
#include "framelesshelperquick_global.h"
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#include <QtQuickTemplates2/private/qquickbutton_p.h>
QT_BEGIN_NAMESPACE
class QQuickImage;
class QQuickRectangle;
QT_END_NAMESPACE
FRAMELESSHELPER_BEGIN_NAMESPACE
class FRAMELESSHELPER_QUICK_API QuickStandardMinimizeButton : public QQuickButton
{
Q_OBJECT
#ifdef QML_NAMED_ELEMENT
QML_NAMED_ELEMENT(StandardMinimizeButton)
#endif
Q_DISABLE_COPY_MOVE(QuickStandardMinimizeButton)
public:
explicit QuickStandardMinimizeButton(QQuickItem *parent = nullptr);
~QuickStandardMinimizeButton() override;
public Q_SLOTS:
void updateForeground();
void updateBackground();
void setInactive(const bool value);
private:
void initialize();
void checkInactive();
private:
QScopedPointer<QQuickItem> m_contentItem;
QScopedPointer<QQuickImage> m_image;
QScopedPointer<QQuickRectangle> m_backgroundItem;
bool m_forceLightTheme = false;
bool m_shouldCheck = false;
bool m_checkFlag = false;
};
FRAMELESSHELPER_END_NAMESPACE
QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickStandardMinimizeButton))
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))

View File

@ -35,37 +35,39 @@ QT_END_NAMESPACE
FRAMELESSHELPER_BEGIN_NAMESPACE
class FRAMELESSHELPER_QUICK_API QuickStandardCloseButton : public QQuickButton
class FRAMELESSHELPER_QUICK_API QuickStandardSystemButton : public QQuickButton
{
Q_OBJECT
#ifdef QML_NAMED_ELEMENT
QML_NAMED_ELEMENT(StandardCloseButton)
QML_NAMED_ELEMENT(StandardSystemButton)
#endif
Q_DISABLE_COPY_MOVE(QuickStandardCloseButton)
Q_DISABLE_COPY_MOVE(QuickStandardSystemButton)
public:
explicit QuickStandardCloseButton(QQuickItem *parent = nullptr);
~QuickStandardCloseButton() override;
explicit QuickStandardSystemButton(QQuickItem *parent = nullptr);
explicit QuickStandardSystemButton(const QuickGlobal::SystemButtonType type, QQuickItem *parent = nullptr);
~QuickStandardSystemButton() override;
public Q_SLOTS:
void updateForeground();
void updateBackground();
void setInactive(const bool value);
void setButtonType(const QuickGlobal::SystemButtonType type);
private:
void initialize();
void checkInactive();
private:
QScopedPointer<QQuickItem> m_contentItem;
QScopedPointer<QQuickImage> m_image;
QScopedPointer<QQuickImage> m_contentItem;
QScopedPointer<QQuickRectangle> m_backgroundItem;
bool m_forceLightTheme = false;
bool m_shouldCheck = false;
bool m_checkFlag = false;
QuickGlobal::SystemButtonType m_buttonType = QuickGlobal::SystemButtonType::Unknown;
};
FRAMELESSHELPER_END_NAMESPACE
QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickStandardCloseButton))
QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickStandardSystemButton))
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))

View File

@ -35,9 +35,7 @@ QT_END_NAMESPACE
FRAMELESSHELPER_BEGIN_NAMESPACE
class QuickStandardMinimizeButton;
class QuickStandardMaximizeButton;
class QuickStandardCloseButton;
class QuickStandardSystemButton;
class FRAMELESSHELPER_QUICK_API QuickStandardTitleBar : public QQuickRectangle
{
@ -48,9 +46,9 @@ class FRAMELESSHELPER_QUICK_API QuickStandardTitleBar : public QQuickRectangle
Q_DISABLE_COPY_MOVE(QuickStandardTitleBar)
Q_PROPERTY(Qt::Alignment titleLabelAlignment READ titleLabelAlignment WRITE setTitleLabelAlignment NOTIFY titleLabelAlignmentChanged FINAL)
Q_PROPERTY(QQuickLabel* titleLabel READ titleLabel CONSTANT FINAL)
Q_PROPERTY(QuickStandardMinimizeButton* minimizeButton READ minimizeButton CONSTANT FINAL)
Q_PROPERTY(QuickStandardMaximizeButton* maximizeButton READ maximizeButton CONSTANT FINAL)
Q_PROPERTY(QuickStandardCloseButton* closeButton READ closeButton CONSTANT FINAL)
Q_PROPERTY(QuickStandardSystemButton* minimizeButton READ minimizeButton CONSTANT FINAL)
Q_PROPERTY(QuickStandardSystemButton* maximizeButton READ maximizeButton CONSTANT FINAL)
Q_PROPERTY(QuickStandardSystemButton* closeButton READ closeButton CONSTANT FINAL)
Q_PROPERTY(bool extended READ isExtended WRITE setExtended NOTIFY extendedChanged FINAL)
public:
@ -61,9 +59,9 @@ public:
void setTitleLabelAlignment(const Qt::Alignment value);
Q_NODISCARD QQuickLabel *titleLabel() const;
Q_NODISCARD QuickStandardMinimizeButton *minimizeButton() const;
Q_NODISCARD QuickStandardMaximizeButton *maximizeButton() const;
Q_NODISCARD QuickStandardCloseButton *closeButton() const;
Q_NODISCARD QuickStandardSystemButton *minimizeButton() const;
Q_NODISCARD QuickStandardSystemButton *maximizeButton() const;
Q_NODISCARD QuickStandardSystemButton *closeButton() const;
Q_NODISCARD bool isExtended() const;
void setExtended(const bool value);
@ -93,9 +91,9 @@ private:
Qt::Alignment m_labelAlignment = {};
QScopedPointer<QQuickLabel> m_windowTitleLabel;
QScopedPointer<QQuickRow> m_systemButtonsRow;
QScopedPointer<QuickStandardMinimizeButton> m_minimizeButton;
QScopedPointer<QuickStandardMaximizeButton> m_maximizeButton;
QScopedPointer<QuickStandardCloseButton> m_closeButton;
QScopedPointer<QuickStandardSystemButton> m_minimizeButton;
QScopedPointer<QuickStandardSystemButton> m_maximizeButton;
QScopedPointer<QuickStandardSystemButton> m_closeButton;
QMetaObject::Connection m_windowStateChangeConnection = {};
QMetaObject::Connection m_windowActiveChangeConnection = {};
QMetaObject::Connection m_windowTitleChangeConnection = {};

View File

@ -26,7 +26,7 @@
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,0,0,0
PRODUCTVERSION 2,1,0,0
PRODUCTVERSION 2,1,1,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
@ -51,7 +51,7 @@ BEGIN
VALUE "OriginalFilename", "FramelessHelperCore.dll"
#endif
VALUE "ProductName", "FramelessHelper"
VALUE "ProductVersion", "2.1.0.0"
VALUE "ProductVersion", "2.1.1.0"
VALUE "InternalName", "FramelessHelperCore"
END
END

View File

@ -289,4 +289,9 @@ void FramelessHelper::Core::initialize()
qRegisterMetaType<SystemParameters>();
}
int FramelessHelper::Core::version()
{
return FRAMELESSHELPER_VERSION;
}
FRAMELESSHELPER_END_NAMESPACE

View File

@ -35,16 +35,12 @@ set(SOURCES
${INCLUDE_PREFIX}/framelessquickmodule.h
${INCLUDE_PREFIX}/framelessquickhelper.h
${INCLUDE_PREFIX}/framelessquickutils.h
${INCLUDE_PREFIX}/private/quickstandardminimizebutton_p.h
${INCLUDE_PREFIX}/private/quickstandardmaximizebutton_p.h
${INCLUDE_PREFIX}/private/quickstandardclosebutton_p.h
${INCLUDE_PREFIX}/private/quickstandardsystembutton_p.h
${INCLUDE_PREFIX}/private/quickstandardtitlebar_p.h
${INCLUDE_PREFIX}/private/framelessquickhelper_p.h
${INCLUDE_PREFIX}/private/framelessquickwindow_p.h
${INCLUDE_PREFIX}/private/framelessquickwindow_p_p.h
quickstandardminimizebutton.cpp
quickstandardmaximizebutton.cpp
quickstandardclosebutton.cpp
quickstandardsystembutton.cpp
quickstandardtitlebar.cpp
framelessquickutils.cpp
framelessquickmodule.cpp

View File

@ -1,7 +1,4 @@
<RCC>
<qresource prefix="/org/wangwenx190/FramelessHelper">
<file alias="qmldir">module/qmldir</file>
</qresource>
<qresource prefix="/org.wangwenx190.FramelessHelper">
<file alias="images/dark/chrome-close.svg">../core/images/dark/chrome-close.svg</file>
<file alias="images/dark/chrome-maximize.svg">../core/images/dark/chrome-maximize.svg</file>

View File

@ -26,7 +26,7 @@
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,0,0,0
PRODUCTVERSION 2,1,0,0
PRODUCTVERSION 2,1,1,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
@ -51,7 +51,7 @@ BEGIN
VALUE "OriginalFilename", "FramelessHelperQuick.dll"
#endif
VALUE "ProductName", "FramelessHelper"
VALUE "ProductVersion", "2.1.0.0"
VALUE "ProductVersion", "2.1.1.0"
VALUE "InternalName", "FramelessHelperQuick"
END
END

View File

@ -26,9 +26,7 @@
#include "framelessquickhelper.h"
#include "framelessquickutils.h"
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
# include "quickstandardminimizebutton_p.h"
# include "quickstandardmaximizebutton_p.h"
# include "quickstandardclosebutton_p.h"
# include "quickstandardsystembutton_p.h"
# include "quickstandardtitlebar_p.h"
# include "framelessquickwindow_p.h"
#else // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
@ -75,18 +73,12 @@ void FramelessHelper::Quick::registerTypes(QQmlEngine *engine)
qmlRegisterRevision<QQuickItem, 254>(QUICK_URI_FULL);
qmlRegisterType<FramelessQuickHelper>(QUICK_URI_EXPAND("FramelessHelper"));
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
qmlRegisterType<QuickStandardMinimizeButton>(QUICK_URI_EXPAND("StandardMinimizeButton"));
qmlRegisterType<QuickStandardMaximizeButton>(QUICK_URI_EXPAND("StandardMaximizeButton"));
qmlRegisterType<QuickStandardCloseButton>(QUICK_URI_EXPAND("StandardCloseButton"));
qmlRegisterType<QuickStandardSystemButton>(QUICK_URI_EXPAND("StandardSystemButton"));
qmlRegisterType<QuickStandardTitleBar>(QUICK_URI_EXPAND("StandardTitleBar"));
qmlRegisterType<FramelessQuickWindow>(QUICK_URI_EXPAND("FramelessWindow"));
#else // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
qmlRegisterTypeNotAvailable(QUICK_URI_EXPAND("StandardMinimizeButton"),
FRAMELESSHELPER_STRING_LITERAL("StandardMinimizeButton is not available until Qt6."));
qmlRegisterTypeNotAvailable(QUICK_URI_EXPAND("StandardMaximizeButton"),
FRAMELESSHELPER_STRING_LITERAL("StandardMaximizeButton is not available until Qt6."));
qmlRegisterTypeNotAvailable(QUICK_URI_EXPAND("StandardCloseButton"),
FRAMELESSHELPER_STRING_LITERAL("StandardCloseButton is not available until Qt6."));
qmlRegisterTypeNotAvailable(QUICK_URI_EXPAND("StandardSystemButton"),
FRAMELESSHELPER_STRING_LITERAL("StandardSystemButton is not available until Qt6."));
qmlRegisterTypeNotAvailable(QUICK_URI_EXPAND("StandardTitleBar"),
FRAMELESSHELPER_STRING_LITERAL("StandardTitleBar is not available until Qt6."));
qmlRegisterTypeNotAvailable(QUICK_URI_EXPAND("FramelessWindow"),

View File

@ -1,6 +0,0 @@
module org.wangwenx190.FramelessHelper
linktarget FramelessHelperQuick
plugin FramelessHelperQuick
classname FramelessHelperQuickPlugin
typeinfo FramelessHelperQuick.qmltypes
prefer :/org/wangwenx190/FramelessHelper/

View File

@ -1,123 +0,0 @@
/*
* MIT License
*
* Copyright (C) 2022 by wangwenx190 (Yuhang Zhao)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "quickstandardclosebutton_p.h"
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#include <framelessmanager.h>
#include <utils.h>
#include <QtQuick/private/qquickimage_p.h>
#include <QtQuick/private/qquickrectangle_p.h>
#include <QtQuick/private/qquickanchors_p.h>
#include <QtQuickTemplates2/private/qquicktooltip_p.h>
static inline void initResource()
{
Q_INIT_RESOURCE(framelesshelperquick);
}
FRAMELESSHELPER_BEGIN_NAMESPACE
using namespace Global;
FRAMELESSHELPER_STRING_CONSTANT2(DarkUrl, "qrc:///org.wangwenx190.FramelessHelper/images/dark/chrome-close.svg")
FRAMELESSHELPER_STRING_CONSTANT2(LightUrl, "qrc:///org.wangwenx190.FramelessHelper/images/light/chrome-close.svg")
QuickStandardCloseButton::QuickStandardCloseButton(QQuickItem *parent) : QQuickButton(parent)
{
initialize();
}
QuickStandardCloseButton::~QuickStandardCloseButton() = default;
void QuickStandardCloseButton::updateForeground()
{
const bool dark = ((Utils::shouldAppsUseDarkMode() || Utils::isTitleBarColorized()) && !m_forceLightTheme);
const auto url = QUrl((dark || isHovered() || isPressed()) ? kDarkUrl : kLightUrl);
initResource();
m_image->setSource(url);
}
void QuickStandardCloseButton::updateBackground()
{
static constexpr const auto button = SystemButtonType::Close;
const bool hover = isHovered();
const bool press = isPressed();
m_backgroundItem->setColor(Utils::calculateSystemButtonBackgroundColor(button, (press ? ButtonState::Pressed : ButtonState::Hovered)));
m_backgroundItem->setVisible(hover || press);
checkInactive();
qobject_cast<QQuickToolTipAttached *>(qmlAttachedPropertiesObject<QQuickToolTip>(this))->setVisible(hover);
}
void QuickStandardCloseButton::setInactive(const bool value)
{
const bool force = (value && Utils::isTitleBarColorized() && !Utils::shouldAppsUseDarkMode());
if (m_forceLightTheme == force) {
return;
}
m_forceLightTheme = force;
m_shouldCheck = m_forceLightTheme;
updateForeground();
}
void QuickStandardCloseButton::checkInactive()
{
if (!m_shouldCheck) {
return;
}
m_forceLightTheme = m_checkFlag;
m_checkFlag = !m_checkFlag;
updateForeground();
}
void QuickStandardCloseButton::initialize()
{
setImplicitWidth(kDefaultSystemButtonSize.width());
setImplicitHeight(kDefaultSystemButtonSize.height());
m_contentItem.reset(new QQuickItem(this));
m_contentItem->setImplicitWidth(kDefaultSystemButtonIconSize.width());
m_contentItem->setImplicitHeight(kDefaultSystemButtonIconSize.height());
m_image.reset(new QQuickImage(m_contentItem.data()));
const auto imageAnchors = new QQuickAnchors(m_image.data(), m_image.data());
imageAnchors->setCenterIn(m_contentItem.data());
connect(this, &QuickStandardCloseButton::hoveredChanged, this, &QuickStandardCloseButton::updateForeground);
connect(this, &QuickStandardCloseButton::pressedChanged, this, &QuickStandardCloseButton::updateForeground);
connect(FramelessManager::instance(), &FramelessManager::systemThemeChanged, this, &QuickStandardCloseButton::updateForeground);
m_backgroundItem.reset(new QQuickRectangle(this));
QQuickPen * const border = m_backgroundItem->border();
border->setWidth(0.0);
border->setColor(kDefaultTransparentColor);
connect(this, &QuickStandardCloseButton::hoveredChanged, this, &QuickStandardCloseButton::updateBackground);
connect(this, &QuickStandardCloseButton::pressedChanged, this, &QuickStandardCloseButton::updateBackground);
updateBackground();
updateForeground();
setContentItem(m_contentItem.data());
setBackground(m_backgroundItem.data());
}
FRAMELESSHELPER_END_NAMESPACE
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))

View File

@ -1,138 +0,0 @@
/*
* MIT License
*
* Copyright (C) 2022 by wangwenx190 (Yuhang Zhao)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "quickstandardmaximizebutton_p.h"
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#include <framelessmanager.h>
#include <utils.h>
#include <QtQuick/private/qquickimage_p.h>
#include <QtQuick/private/qquickrectangle_p.h>
#include <QtQuick/private/qquickanchors_p.h>
#include <QtQuickTemplates2/private/qquicktooltip_p.h>
static inline void initResource()
{
Q_INIT_RESOURCE(framelesshelperquick);
}
FRAMELESSHELPER_BEGIN_NAMESPACE
using namespace Global;
FRAMELESSHELPER_STRING_CONSTANT2(DarkMaxUrl, "qrc:///org.wangwenx190.FramelessHelper/images/dark/chrome-maximize.svg")
FRAMELESSHELPER_STRING_CONSTANT2(LightMaxUrl, "qrc:///org.wangwenx190.FramelessHelper/images/light/chrome-maximize.svg")
FRAMELESSHELPER_STRING_CONSTANT2(DarkRestoreUrl, "qrc:///org.wangwenx190.FramelessHelper/images/dark/chrome-restore.svg")
FRAMELESSHELPER_STRING_CONSTANT2(LightRestoreUrl, "qrc:///org.wangwenx190.FramelessHelper/images/light/chrome-restore.svg")
QuickStandardMaximizeButton::QuickStandardMaximizeButton(QQuickItem *parent) : QQuickButton(parent)
{
initialize();
}
QuickStandardMaximizeButton::~QuickStandardMaximizeButton() = default;
bool QuickStandardMaximizeButton::isMaximized() const
{
return m_max;
}
void QuickStandardMaximizeButton::setMaximized(const bool max)
{
if (m_max == max) {
return;
}
m_max = max;
Q_EMIT maximizedChanged();
}
void QuickStandardMaximizeButton::updateForeground()
{
const bool dark = ((Utils::shouldAppsUseDarkMode() || Utils::isTitleBarColorized()) && !m_forceLightTheme);
const auto url = QUrl(dark ? (m_max ? kDarkRestoreUrl : kDarkMaxUrl) : (m_max ? kLightRestoreUrl : kLightMaxUrl));
initResource();
m_image->setSource(url);
}
void QuickStandardMaximizeButton::updateBackground()
{
const SystemButtonType button = (m_max ? SystemButtonType::Restore : SystemButtonType::Maximize);
const bool hover = isHovered();
const bool press = isPressed();
m_backgroundItem->setColor(Utils::calculateSystemButtonBackgroundColor(button, (press ? ButtonState::Pressed : ButtonState::Hovered)));
m_backgroundItem->setVisible(hover || press);
checkInactive();
qobject_cast<QQuickToolTipAttached *>(qmlAttachedPropertiesObject<QQuickToolTip>(this))->setVisible(hover);
}
void QuickStandardMaximizeButton::setInactive(const bool value)
{
const bool force = (value && Utils::isTitleBarColorized() && !Utils::shouldAppsUseDarkMode());
if (m_forceLightTheme == force) {
return;
}
m_forceLightTheme = force;
m_shouldCheck = m_forceLightTheme;
updateForeground();
}
void QuickStandardMaximizeButton::checkInactive()
{
if (!m_shouldCheck) {
return;
}
m_forceLightTheme = m_checkFlag;
m_checkFlag = !m_checkFlag;
updateForeground();
}
void QuickStandardMaximizeButton::initialize()
{
setImplicitWidth(kDefaultSystemButtonSize.width());
setImplicitHeight(kDefaultSystemButtonSize.height());
m_contentItem.reset(new QQuickItem(this));
m_contentItem->setImplicitWidth(kDefaultSystemButtonIconSize.width());
m_contentItem->setImplicitHeight(kDefaultSystemButtonIconSize.height());
m_image.reset(new QQuickImage(m_contentItem.data()));
const auto imageAnchors = new QQuickAnchors(m_image.data(), m_image.data());
imageAnchors->setCenterIn(m_contentItem.data());
connect(FramelessManager::instance(), &FramelessManager::systemThemeChanged, this, &QuickStandardMaximizeButton::updateForeground);
connect(this, &QuickStandardMaximizeButton::maximizedChanged, this, &QuickStandardMaximizeButton::updateForeground);
m_backgroundItem.reset(new QQuickRectangle(this));
QQuickPen * const border = m_backgroundItem->border();
border->setWidth(0.0);
border->setColor(kDefaultTransparentColor);
connect(this, &QuickStandardMaximizeButton::hoveredChanged, this, &QuickStandardMaximizeButton::updateBackground);
connect(this, &QuickStandardMaximizeButton::pressedChanged, this, &QuickStandardMaximizeButton::updateBackground);
updateBackground();
updateForeground();
setContentItem(m_contentItem.data());
setBackground(m_backgroundItem.data());
}
FRAMELESSHELPER_END_NAMESPACE
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))

View File

@ -1 +0,0 @@
#include "../../include/FramelessHelper/Quick/private/quickstandardmaximizebutton_p.h"

View File

@ -1,121 +0,0 @@
/*
* MIT License
*
* Copyright (C) 2022 by wangwenx190 (Yuhang Zhao)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "quickstandardminimizebutton_p.h"
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#include <framelessmanager.h>
#include <utils.h>
#include <QtQuick/private/qquickimage_p.h>
#include <QtQuick/private/qquickrectangle_p.h>
#include <QtQuick/private/qquickanchors_p.h>
#include <QtQuickTemplates2/private/qquicktooltip_p.h>
static inline void initResource()
{
Q_INIT_RESOURCE(framelesshelperquick);
}
FRAMELESSHELPER_BEGIN_NAMESPACE
using namespace Global;
FRAMELESSHELPER_STRING_CONSTANT2(DarkUrl, "qrc:///org.wangwenx190.FramelessHelper/images/dark/chrome-minimize.svg")
FRAMELESSHELPER_STRING_CONSTANT2(LightUrl, "qrc:///org.wangwenx190.FramelessHelper/images/light/chrome-minimize.svg")
QuickStandardMinimizeButton::QuickStandardMinimizeButton(QQuickItem *parent) : QQuickButton(parent)
{
initialize();
}
QuickStandardMinimizeButton::~QuickStandardMinimizeButton() = default;
void QuickStandardMinimizeButton::updateForeground()
{
const bool dark = ((Utils::shouldAppsUseDarkMode() || Utils::isTitleBarColorized()) && !m_forceLightTheme);
const auto url = QUrl(dark ? kDarkUrl : kLightUrl);
initResource();
m_image->setSource(url);
}
void QuickStandardMinimizeButton::updateBackground()
{
static constexpr const auto button = SystemButtonType::Minimize;
const bool hover = isHovered();
const bool press = isPressed();
m_backgroundItem->setColor(Utils::calculateSystemButtonBackgroundColor(button, (press ? ButtonState::Pressed : ButtonState::Hovered)));
m_backgroundItem->setVisible(hover || press);
checkInactive();
qobject_cast<QQuickToolTipAttached *>(qmlAttachedPropertiesObject<QQuickToolTip>(this))->setVisible(hover);
}
void QuickStandardMinimizeButton::setInactive(const bool value)
{
const bool force = (value && Utils::isTitleBarColorized() && !Utils::shouldAppsUseDarkMode());
if (m_forceLightTheme == force) {
return;
}
m_forceLightTheme = force;
m_shouldCheck = m_forceLightTheme;
updateForeground();
}
void QuickStandardMinimizeButton::checkInactive()
{
if (!m_shouldCheck) {
return;
}
m_forceLightTheme = m_checkFlag;
m_checkFlag = !m_checkFlag;
updateForeground();
}
void QuickStandardMinimizeButton::initialize()
{
setImplicitWidth(kDefaultSystemButtonSize.width());
setImplicitHeight(kDefaultSystemButtonSize.height());
m_contentItem.reset(new QQuickItem(this));
m_contentItem->setImplicitWidth(kDefaultSystemButtonIconSize.width());
m_contentItem->setImplicitHeight(kDefaultSystemButtonIconSize.height());
m_image.reset(new QQuickImage(m_contentItem.data()));
const auto imageAnchors = new QQuickAnchors(m_image.data(), m_image.data());
imageAnchors->setCenterIn(m_contentItem.data());
connect(FramelessManager::instance(), &FramelessManager::systemThemeChanged, this, &QuickStandardMinimizeButton::updateForeground);
m_backgroundItem.reset(new QQuickRectangle(this));
QQuickPen * const border = m_backgroundItem->border();
border->setWidth(0.0);
border->setColor(kDefaultTransparentColor);
connect(this, &QuickStandardMinimizeButton::hoveredChanged, this, &QuickStandardMinimizeButton::updateBackground);
connect(this, &QuickStandardMinimizeButton::pressedChanged, this, &QuickStandardMinimizeButton::updateBackground);
updateBackground();
updateForeground();
setContentItem(m_contentItem.data());
setBackground(m_backgroundItem.data());
}
FRAMELESSHELPER_END_NAMESPACE
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))

View File

@ -1 +0,0 @@
#include "../../include/FramelessHelper/Quick/private/quickstandardminimizebutton_p.h"

View File

@ -0,0 +1,170 @@
/*
* MIT License
*
* Copyright (C) 2022 by wangwenx190 (Yuhang Zhao)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "quickstandardsystembutton_p.h"
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#include <framelessmanager.h>
#include <utils.h>
#include <QtQuick/private/qquickimage_p.h>
#include <QtQuick/private/qquickrectangle_p.h>
#include <QtQuickTemplates2/private/qquicktooltip_p.h>
static inline void initResource()
{
Q_INIT_RESOURCE(framelesshelperquick);
}
FRAMELESSHELPER_BEGIN_NAMESPACE
using namespace Global;
FRAMELESSHELPER_STRING_CONSTANT2(DarkMinimizeUrl, "qrc:///org.wangwenx190.FramelessHelper/images/dark/chrome-minimize.svg")
FRAMELESSHELPER_STRING_CONSTANT2(LightMinimizeUrl, "qrc:///org.wangwenx190.FramelessHelper/images/light/chrome-minimize.svg")
FRAMELESSHELPER_STRING_CONSTANT2(DarkMaximizeUrl, "qrc:///org.wangwenx190.FramelessHelper/images/dark/chrome-maximize.svg")
FRAMELESSHELPER_STRING_CONSTANT2(LightMaximizeUrl, "qrc:///org.wangwenx190.FramelessHelper/images/light/chrome-maximize.svg")
FRAMELESSHELPER_STRING_CONSTANT2(DarkRestoreUrl, "qrc:///org.wangwenx190.FramelessHelper/images/dark/chrome-restore.svg")
FRAMELESSHELPER_STRING_CONSTANT2(LightRestoreUrl, "qrc:///org.wangwenx190.FramelessHelper/images/light/chrome-restore.svg")
FRAMELESSHELPER_STRING_CONSTANT2(DarkCloseUrl, "qrc:///org.wangwenx190.FramelessHelper/images/dark/chrome-close.svg")
FRAMELESSHELPER_STRING_CONSTANT2(LightCloseUrl, "qrc:///org.wangwenx190.FramelessHelper/images/light/chrome-close.svg")
QuickStandardSystemButton::QuickStandardSystemButton(QQuickItem *parent) : QQuickButton(parent)
{
initialize();
}
QuickStandardSystemButton::QuickStandardSystemButton(const QuickGlobal::SystemButtonType type, QQuickItem *parent) : QuickStandardSystemButton(parent)
{
setButtonType(type);
}
QuickStandardSystemButton::~QuickStandardSystemButton() = default;
void QuickStandardSystemButton::setButtonType(const QuickGlobal::SystemButtonType type)
{
Q_ASSERT(type != QuickGlobal::SystemButtonType::Unknown);
if (type == QuickGlobal::SystemButtonType::Unknown) {
return;
}
if (m_buttonType == type) {
return;
}
m_buttonType = type;
updateForeground();
}
void QuickStandardSystemButton::updateForeground()
{
if (m_buttonType == QuickGlobal::SystemButtonType::Unknown) {
return;
}
const QUrl url = [this]() -> QUrl {
const bool dark = ((Utils::shouldAppsUseDarkMode() || Utils::isTitleBarColorized() || ((m_buttonType == QuickGlobal::SystemButtonType::Close) && isHovered())) && !m_forceLightTheme);
switch (m_buttonType) {
case QuickGlobal::SystemButtonType::Minimize:
return QUrl(dark ? kDarkMinimizeUrl : kLightMinimizeUrl);
case QuickGlobal::SystemButtonType::Maximize:
return QUrl(dark ? kDarkMaximizeUrl : kLightMaximizeUrl);
case QuickGlobal::SystemButtonType::Restore:
return QUrl(dark ? kDarkRestoreUrl : kLightRestoreUrl);
case QuickGlobal::SystemButtonType::Close:
return QUrl(dark ? kDarkCloseUrl : kLightCloseUrl);
case QuickGlobal::SystemButtonType::WindowIcon:
Q_FALLTHROUGH();
case QuickGlobal::SystemButtonType::Help:
Q_FALLTHROUGH();
case QuickGlobal::SystemButtonType::Unknown:
Q_ASSERT(false);
return {};
}
Q_UNREACHABLE();
return {};
}();
if (m_contentItem->source() == url) {
return;
}
initResource();
m_contentItem->setSource(url);
}
void QuickStandardSystemButton::updateBackground()
{
const bool hover = isHovered();
const bool press = isPressed();
m_backgroundItem->setColor(Utils::calculateSystemButtonBackgroundColor(
FRAMELESSHELPER_ENUM_QUICK_TO_CORE(SystemButtonType, m_buttonType),
(press ? ButtonState::Pressed : ButtonState::Hovered)));
m_backgroundItem->setVisible(hover || press);
checkInactive();
qobject_cast<QQuickToolTipAttached *>(qmlAttachedPropertiesObject<QQuickToolTip>(this))->setVisible(hover);
}
void QuickStandardSystemButton::setInactive(const bool value)
{
const bool force = (value && Utils::isTitleBarColorized() && !Utils::shouldAppsUseDarkMode());
if (m_forceLightTheme == force) {
return;
}
m_forceLightTheme = force;
m_shouldCheck = m_forceLightTheme;
updateForeground();
}
void QuickStandardSystemButton::checkInactive()
{
if (!m_shouldCheck) {
return;
}
m_forceLightTheme = m_checkFlag;
m_checkFlag = !m_checkFlag;
updateForeground();
}
void QuickStandardSystemButton::initialize()
{
setImplicitWidth(kDefaultSystemButtonSize.width());
setImplicitHeight(kDefaultSystemButtonSize.height());
m_contentItem.reset(new QQuickImage(this));
m_contentItem->setFillMode(QQuickImage::Pad);
m_contentItem->setWidth(kDefaultSystemButtonIconSize.width());
m_contentItem->setHeight(kDefaultSystemButtonIconSize.height());
connect(FramelessManager::instance(), &FramelessManager::systemThemeChanged, this, &QuickStandardSystemButton::updateForeground);
m_backgroundItem.reset(new QQuickRectangle(this));
QQuickPen * const border = m_backgroundItem->border();
border->setWidth(0.0);
border->setColor(kDefaultTransparentColor);
connect(this, &QuickStandardSystemButton::hoveredChanged, this, &QuickStandardSystemButton::updateBackground);
connect(this, &QuickStandardSystemButton::hoveredChanged, this, &QuickStandardSystemButton::updateForeground);
connect(this, &QuickStandardSystemButton::pressedChanged, this, &QuickStandardSystemButton::updateBackground);
updateBackground();
updateForeground();
setContentItem(m_contentItem.data());
setBackground(m_backgroundItem.data());
}
FRAMELESSHELPER_END_NAMESPACE
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))

View File

@ -1 +1 @@
#include "../../include/FramelessHelper/Quick/private/quickstandardclosebutton_p.h"
#include "../../include/FramelessHelper/Quick/private/quickstandardsystembutton_p.h"

View File

@ -24,9 +24,7 @@
#include "quickstandardtitlebar_p.h"
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#include "quickstandardminimizebutton_p.h"
#include "quickstandardmaximizebutton_p.h"
#include "quickstandardclosebutton_p.h"
#include "quickstandardsystembutton_p.h"
#include <framelessmanager.h>
#include <utils.h>
#include <QtQuick/private/qquickitem_p.h>
@ -93,17 +91,17 @@ QQuickLabel *QuickStandardTitleBar::titleLabel() const
return m_windowTitleLabel.data();
}
QuickStandardMinimizeButton *QuickStandardTitleBar::minimizeButton() const
QuickStandardSystemButton *QuickStandardTitleBar::minimizeButton() const
{
return m_minimizeButton.data();
}
QuickStandardMaximizeButton *QuickStandardTitleBar::maximizeButton() const
QuickStandardSystemButton *QuickStandardTitleBar::maximizeButton() const
{
return m_maximizeButton.data();
}
QuickStandardCloseButton *QuickStandardTitleBar::closeButton() const
QuickStandardSystemButton *QuickStandardTitleBar::closeButton() const
{
return m_closeButton.data();
}
@ -129,15 +127,9 @@ void QuickStandardTitleBar::updateMaximizeButton()
if (!w) {
return;
}
m_maximizeButton->setMaximized(w->visibility() == QQuickWindow::Maximized);
qobject_cast<QQuickToolTipAttached *>(qmlAttachedPropertiesObject<QQuickToolTip>(m_maximizeButton.data()))->setText([this]() -> QString {
if (const QQuickWindow * const w = window()) {
if (w->visibility() == QQuickWindow::Maximized) {
return tr("Restore");
}
}
return tr("Maximize");
}());
const bool max = (w->visibility() == QQuickWindow::Maximized);
m_maximizeButton->setButtonType(max ? QuickGlobal::SystemButtonType::Restore : QuickGlobal::SystemButtonType::Maximize);
qobject_cast<QQuickToolTipAttached *>(qmlAttachedPropertiesObject<QQuickToolTip>(m_maximizeButton.data()))->setText(max ? tr("Restore") : tr("Maximize"));
}
void QuickStandardTitleBar::updateTitleLabelText()
@ -256,12 +248,12 @@ void QuickStandardTitleBar::initialize()
const QQuickItemPrivate * const thisPriv = QQuickItemPrivate::get(this);
rowAnchors->setTop(thisPriv->top());
rowAnchors->setRight(thisPriv->right());
m_minimizeButton.reset(new QuickStandardMinimizeButton(m_systemButtonsRow.data()));
connect(m_minimizeButton.data(), &QuickStandardMinimizeButton::clicked, this, &QuickStandardTitleBar::clickMinimizeButton);
m_maximizeButton.reset(new QuickStandardMaximizeButton(m_systemButtonsRow.data()));
connect(m_maximizeButton.data(), &QuickStandardMaximizeButton::clicked, this, &QuickStandardTitleBar::clickMaximizeButton);
m_closeButton.reset(new QuickStandardCloseButton(m_systemButtonsRow.data()));
connect(m_closeButton.data(), &QuickStandardCloseButton::clicked, this, &QuickStandardTitleBar::clickCloseButton);
m_minimizeButton.reset(new QuickStandardSystemButton(QuickGlobal::SystemButtonType::Minimize, m_systemButtonsRow.data()));
connect(m_minimizeButton.data(), &QuickStandardSystemButton::clicked, this, &QuickStandardTitleBar::clickMinimizeButton);
m_maximizeButton.reset(new QuickStandardSystemButton(m_systemButtonsRow.data()));
connect(m_maximizeButton.data(), &QuickStandardSystemButton::clicked, this, &QuickStandardTitleBar::clickMaximizeButton);
m_closeButton.reset(new QuickStandardSystemButton(QuickGlobal::SystemButtonType::Close, m_systemButtonsRow.data()));
connect(m_closeButton.data(), &QuickStandardSystemButton::clicked, this, &QuickStandardTitleBar::clickCloseButton);
connect(FramelessManager::instance(), &FramelessManager::systemThemeChanged, this, &QuickStandardTitleBar::updateTitleBarColor);

View File

@ -26,7 +26,7 @@
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,0,0,0
PRODUCTVERSION 2,1,0,0
PRODUCTVERSION 2,1,1,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
@ -51,7 +51,7 @@ BEGIN
VALUE "OriginalFilename", "FramelessHelperWidgets.dll"
#endif
VALUE "ProductName", "FramelessHelper"
VALUE "ProductVersion", "2.1.0.0"
VALUE "ProductVersion", "2.1.1.0"
VALUE "InternalName", "FramelessHelperWidgets"
END
END

View File

@ -98,6 +98,8 @@ void StandardSystemButtonPrivate::refreshButtonTheme(const bool force)
// https://doc.qt.io/qt-6/qpixmap.html#reading-and-writing-image-files
setImage(qvariant_cast<QImage>(Utils::getSystemButtonIconResource(m_buttonType, m_buttonTheme, ResourceType::Image)), false);
setImage(qvariant_cast<QImage>(Utils::getSystemButtonIconResource(m_buttonType, reversedTheme, ResourceType::Image)), true);
setHoverColor(Utils::calculateSystemButtonBackgroundColor(m_buttonType, ButtonState::Hovered));
setPressColor(Utils::calculateSystemButtonBackgroundColor(m_buttonType, ButtonState::Pressed));
}
SystemButtonType StandardSystemButtonPrivate::getButtonType() const
@ -115,8 +117,6 @@ void StandardSystemButtonPrivate::setButtonType(const SystemButtonType type)
return;
}
m_buttonType = type;
setHoverColor(Utils::calculateSystemButtonBackgroundColor(type, ButtonState::Hovered));
setPressColor(Utils::calculateSystemButtonBackgroundColor(type, ButtonState::Pressed));
refreshButtonTheme(true);
}
@ -315,7 +315,8 @@ void StandardSystemButtonPrivate::paintEventHandler(QPaintEvent *event)
if (m_reversedIcon.isNull()) {
return m_icon;
}
if (m_hovered && m_forceLightTheme) {
if (m_hovered && (((m_buttonType == SystemButtonType::Close)
&& (m_buttonTheme == SystemTheme::Light)) || m_forceLightTheme)) {
return m_reversedIcon;
}
return m_icon;