forked from github_mirror/framelesshelper
expose private headers, someone may need
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
c936a7da80
commit
286811c9df
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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 "framelesshelpercore_global.h"
|
||||
#include <QtCore/qobject.h>
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class FramelessWindowsManager;
|
||||
|
||||
class FRAMELESSHELPER_CORE_API FramelessWindowsManagerPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(FramelessWindowsManager)
|
||||
Q_DISABLE_COPY_MOVE(FramelessWindowsManagerPrivate)
|
||||
|
||||
public:
|
||||
explicit FramelessWindowsManagerPrivate(FramelessWindowsManager *q);
|
||||
~FramelessWindowsManagerPrivate() override;
|
||||
|
||||
Q_NODISCARD static FramelessWindowsManagerPrivate *get(FramelessWindowsManager *pub);
|
||||
Q_NODISCARD static const FramelessWindowsManagerPrivate *get(const FramelessWindowsManager *pub);
|
||||
|
||||
Q_NODISCARD static bool usePureQtImplementation();
|
||||
Q_NODISCARD Global::SystemTheme systemTheme() const;
|
||||
Q_NODISCARD QColor systemAccentColor() const;
|
||||
|
||||
static void addWindow(const Global::SystemParameters ¶ms);
|
||||
Q_INVOKABLE void notifySystemThemeHasChangedOrNot();
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
FramelessWindowsManager *q_ptr = nullptr;
|
||||
Global::SystemTheme m_systemTheme = Global::SystemTheme::Unknown;
|
||||
QColor m_accentColor = {};
|
||||
#ifdef Q_OS_WINDOWS
|
||||
Global::DwmColorizationArea m_colorizationArea = Global::DwmColorizationArea::None_;
|
||||
#endif
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
|
@ -1 +0,0 @@
|
|||
#include <framelessquickwindow.h>
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* 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"
|
||||
#include <QtCore/qobject.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QQuickItem;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
struct QuickHelperData;
|
||||
class FramelessQuickHelper;
|
||||
|
||||
class FRAMELESSHELPER_QUICK_API FramelessQuickHelperPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(FramelessQuickHelper)
|
||||
Q_DISABLE_COPY_MOVE(FramelessQuickHelperPrivate)
|
||||
|
||||
public:
|
||||
explicit FramelessQuickHelperPrivate(FramelessQuickHelper *q);
|
||||
~FramelessQuickHelperPrivate() override;
|
||||
|
||||
Q_NODISCARD static FramelessQuickHelperPrivate *get(FramelessQuickHelper *pub);
|
||||
Q_NODISCARD static const FramelessQuickHelperPrivate *get(const FramelessQuickHelper *pub);
|
||||
|
||||
Q_NODISCARD QQuickItem *getTitleBarItem() const;
|
||||
void setTitleBarItem(QQuickItem *value);
|
||||
|
||||
void attachToWindow();
|
||||
void setSystemButton(QQuickItem *item, const QuickGlobal::SystemButtonType buttonType);
|
||||
void setHitTestVisible(QQuickItem *item);
|
||||
void showSystemMenu(const QPoint &pos);
|
||||
void windowStartSystemMove2(const QPoint &pos);
|
||||
void windowStartSystemResize2(const Qt::Edges edges, const QPoint &pos);
|
||||
|
||||
void moveWindowToDesktopCenter();
|
||||
void bringWindowToFront();
|
||||
|
||||
Q_NODISCARD bool isWindowFixedSize() const;
|
||||
void setWindowFixedSize(const bool value);
|
||||
|
||||
private:
|
||||
Q_NODISCARD QRect mapItemGeometryToScene(const QQuickItem * const item) const;
|
||||
Q_NODISCARD bool isInSystemButtons(const QPoint &pos, QuickGlobal::SystemButtonType *button) const;
|
||||
Q_NODISCARD bool isInTitleBarDraggableArea(const QPoint &pos) const;
|
||||
Q_NODISCARD bool shouldIgnoreMouseEvents(const QPoint &pos) const;
|
||||
void setSystemButtonState(const QuickGlobal::SystemButtonType button, const QuickGlobal::ButtonState state);
|
||||
Q_NODISCARD QuickHelperData getWindowData() const;
|
||||
Q_NODISCARD QuickHelperData *getWindowDataMutable() const;
|
||||
|
||||
private:
|
||||
FramelessQuickHelper *q_ptr = nullptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
|
@ -28,7 +28,7 @@
|
|||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
#include <QtQuick/qquickwindow.h>
|
||||
|
||||
Q_MOC_INCLUDE("framelessquickwindow_p.h")
|
||||
Q_MOC_INCLUDE("framelessquickwindow_p_p.h")
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
|
@ -45,6 +45,7 @@ class FRAMELESSHELPER_QUICK_API FramelessQuickWindow : public QQuickWindow
|
|||
Q_PROPERTY(bool hidden READ isHidden NOTIFY hiddenChanged FINAL)
|
||||
Q_PROPERTY(bool normal READ isNormal NOTIFY normalChanged FINAL)
|
||||
Q_PROPERTY(bool minimized READ isMinimized NOTIFY minimizedChanged FINAL)
|
||||
Q_PROPERTY(bool maximized READ isMaximized NOTIFY maximizedChanged FINAL)
|
||||
Q_PROPERTY(bool zoomed READ isZoomed NOTIFY zoomedChanged FINAL)
|
||||
Q_PROPERTY(bool fullScreen READ isFullScreen NOTIFY fullScreenChanged FINAL)
|
||||
Q_PRIVATE_PROPERTY(FramelessQuickWindow::d_func(), QQuickAnchorLine topBorderBottom READ getTopBorderBottom CONSTANT FINAL)
|
||||
|
@ -56,6 +57,7 @@ public:
|
|||
Q_NODISCARD bool isHidden() const;
|
||||
Q_NODISCARD bool isNormal() const;
|
||||
Q_NODISCARD bool isMinimized() const;
|
||||
Q_NODISCARD bool isMaximized() const;
|
||||
Q_NODISCARD bool isZoomed() const;
|
||||
Q_NODISCARD bool isFullScreen() const;
|
||||
|
||||
|
@ -68,6 +70,7 @@ Q_SIGNALS:
|
|||
void hiddenChanged();
|
||||
void normalChanged();
|
||||
void minimizedChanged();
|
||||
void maximizedChanged();
|
||||
void zoomedChanged();
|
||||
void fullScreenChanged();
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* 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 <QtCore/qobject.h>
|
||||
#include <QtQuick/qquickwindow.h>
|
||||
#include <QtQuick/private/qquickanchors_p_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QQuickRectangle;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class FramelessQuickWindow;
|
||||
|
||||
class FRAMELESSHELPER_QUICK_API FramelessQuickWindowPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(FramelessQuickWindow)
|
||||
Q_DISABLE_COPY_MOVE(FramelessQuickWindowPrivate)
|
||||
|
||||
public:
|
||||
explicit FramelessQuickWindowPrivate(FramelessQuickWindow *q);
|
||||
~FramelessQuickWindowPrivate() override;
|
||||
|
||||
Q_NODISCARD static FramelessQuickWindowPrivate *get(FramelessQuickWindow *pub);
|
||||
Q_NODISCARD static const FramelessQuickWindowPrivate *get(const FramelessQuickWindow *pub);
|
||||
|
||||
Q_INVOKABLE Q_NODISCARD bool isHidden() const;
|
||||
Q_INVOKABLE Q_NODISCARD bool isNormal() const;
|
||||
Q_INVOKABLE Q_NODISCARD bool isMinimized() const;
|
||||
Q_INVOKABLE Q_NODISCARD bool isMaximized() const;
|
||||
Q_INVOKABLE Q_NODISCARD bool isZoomed() const;
|
||||
Q_INVOKABLE Q_NODISCARD bool isFullScreen() const;
|
||||
|
||||
Q_INVOKABLE Q_NODISCARD QColor getFrameBorderColor() const;
|
||||
Q_INVOKABLE Q_NODISCARD QQuickAnchorLine getTopBorderBottom() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void showMinimized2();
|
||||
void toggleMaximized();
|
||||
void toggleFullScreen();
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
Q_NODISCARD bool shouldDrawFrameBorder() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateTopBorderColor();
|
||||
void updateTopBorderHeight();
|
||||
|
||||
private:
|
||||
FramelessQuickWindow *q_ptr = nullptr;
|
||||
QScopedPointer<QQuickRectangle> m_topBorderRectangle;
|
||||
QScopedPointer<QQuickAnchors> m_topBorderAnchors;
|
||||
QQuickWindow::Visibility m_savedVisibility = QQuickWindow::Windowed;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
#endif
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* 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/qquicktooltip_p.h>
|
||||
#include <QtQuickTemplates2/private/qquickbutton_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QQuickImage;
|
||||
class QQuickRectangle;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class FRAMELESSHELPER_QUICK_API QuickStandardCloseButton : public QQuickButton
|
||||
{
|
||||
Q_OBJECT
|
||||
#ifdef QML_NAMED_ELEMENT
|
||||
QML_NAMED_ELEMENT(StandardCloseButton)
|
||||
#endif
|
||||
Q_DISABLE_COPY_MOVE(QuickStandardCloseButton)
|
||||
|
||||
public:
|
||||
explicit QuickStandardCloseButton(QQuickItem *parent = nullptr);
|
||||
~QuickStandardCloseButton() override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateForeground();
|
||||
void updateBackground();
|
||||
void updateToolTip();
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
QScopedPointer<QQuickItem> m_contentItem;
|
||||
QScopedPointer<QQuickImage> m_image;
|
||||
QScopedPointer<QQuickRectangle> m_backgroundItem;
|
||||
QPointer<QQuickToolTipAttached> m_tooltip = nullptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickStandardCloseButton))
|
||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* 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>
|
||||
#include <QtQuickTemplates2/private/qquicktooltip_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);
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateForeground();
|
||||
void updateBackground();
|
||||
void updateToolTip();
|
||||
|
||||
Q_SIGNALS:
|
||||
void maximizedChanged();
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
bool m_max = false;
|
||||
QScopedPointer<QQuickItem> m_contentItem;
|
||||
QScopedPointer<QQuickImage> m_image;
|
||||
QScopedPointer<QQuickRectangle> m_backgroundItem;
|
||||
QPointer<QQuickToolTipAttached> m_tooltip = nullptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickStandardMaximizeButton))
|
||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* 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>
|
||||
#include <QtQuickTemplates2/private/qquicktooltip_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;
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateForeground();
|
||||
void updateBackground();
|
||||
void updateToolTip();
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
QScopedPointer<QQuickItem> m_contentItem;
|
||||
QScopedPointer<QQuickImage> m_image;
|
||||
QScopedPointer<QQuickRectangle> m_backgroundItem;
|
||||
QPointer<QQuickToolTipAttached> m_tooltip = nullptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickStandardMinimizeButton))
|
||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* 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 <QtQuick/private/qquickrectangle_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QQuickLabel;
|
||||
class QQuickRow;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class QuickStandardMinimizeButton;
|
||||
class QuickStandardMaximizeButton;
|
||||
class QuickStandardCloseButton;
|
||||
|
||||
class FRAMELESSHELPER_QUICK_API QuickStandardTitleBar : public QQuickRectangle
|
||||
{
|
||||
Q_OBJECT
|
||||
#ifdef QML_NAMED_ELEMENT
|
||||
QML_NAMED_ELEMENT(StandardTitleBar)
|
||||
#endif
|
||||
Q_DISABLE_COPY_MOVE(QuickStandardTitleBar)
|
||||
Q_PROPERTY(Qt::Alignment titleLabelAlignment READ titleLabelAlignment WRITE setTitleLabelAlignment NOTIFY titleLabelAlignmentChanged 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)
|
||||
|
||||
public:
|
||||
explicit QuickStandardTitleBar(QQuickItem *parent = nullptr);
|
||||
~QuickStandardTitleBar() override;
|
||||
|
||||
Q_NODISCARD Qt::Alignment titleLabelAlignment() const;
|
||||
void setTitleLabelAlignment(const Qt::Alignment value);
|
||||
|
||||
Q_NODISCARD QuickStandardMinimizeButton *minimizeButton() const;
|
||||
Q_NODISCARD QuickStandardMaximizeButton *maximizeButton() const;
|
||||
Q_NODISCARD QuickStandardCloseButton *closeButton() const;
|
||||
|
||||
protected:
|
||||
void itemChange(const ItemChange change, const ItemChangeData &value) override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateMaximizeButton();
|
||||
void updateTitleLabelText();
|
||||
void updateTitleBarColor();
|
||||
void clickMinimizeButton();
|
||||
void clickMaximizeButton();
|
||||
void clickCloseButton();
|
||||
|
||||
Q_SIGNALS:
|
||||
void titleLabelAlignmentChanged();
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
void updateAll();
|
||||
|
||||
private:
|
||||
Qt::Alignment m_labelAlignment = {};
|
||||
QScopedPointer<QQuickLabel> m_label;
|
||||
QScopedPointer<QQuickRow> m_row;
|
||||
QScopedPointer<QuickStandardMinimizeButton> m_minBtn;
|
||||
QScopedPointer<QuickStandardMaximizeButton> m_maxBtn;
|
||||
QScopedPointer<QuickStandardCloseButton> m_closeBtn;
|
||||
QMetaObject::Connection m_windowStateChangeConnection = {};
|
||||
QMetaObject::Connection m_windowActiveChangeConnection = {};
|
||||
QMetaObject::Connection m_windowTitleChangeConnection = {};
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickStandardTitleBar))
|
||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* 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 "framelesshelperwidgets_global.h"
|
||||
#include <QtCore/qobject.h>
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class FramelessMainWindow;
|
||||
class WidgetsSharedHelper;
|
||||
|
||||
class FRAMELESSHELPER_WIDGETS_API FramelessMainWindowPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(FramelessMainWindow)
|
||||
Q_DISABLE_COPY_MOVE(FramelessMainWindowPrivate)
|
||||
|
||||
public:
|
||||
explicit FramelessMainWindowPrivate(FramelessMainWindow *q);
|
||||
~FramelessMainWindowPrivate() override;
|
||||
|
||||
Q_NODISCARD static FramelessMainWindowPrivate *get(FramelessMainWindow *pub);
|
||||
Q_NODISCARD static const FramelessMainWindowPrivate *get(const FramelessMainWindow *pub);
|
||||
|
||||
Q_NODISCARD bool isNormal() const;
|
||||
Q_NODISCARD bool isZoomed() const;
|
||||
|
||||
void toggleMaximized();
|
||||
void toggleFullScreen();
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
FramelessMainWindow *q_ptr = nullptr;
|
||||
Qt::WindowState m_savedWindowState = Qt::WindowNoState;
|
||||
QScopedPointer<WidgetsSharedHelper> m_helper;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* 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 "framelesshelperwidgets_global.h"
|
||||
#include <QtCore/qobject.h>
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class FramelessWidget;
|
||||
class WidgetsSharedHelper;
|
||||
|
||||
class FRAMELESSHELPER_WIDGETS_API FramelessWidgetPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(FramelessWidget)
|
||||
Q_DISABLE_COPY_MOVE(FramelessWidgetPrivate)
|
||||
|
||||
public:
|
||||
explicit FramelessWidgetPrivate(FramelessWidget *q);
|
||||
~FramelessWidgetPrivate() override;
|
||||
|
||||
Q_NODISCARD static FramelessWidgetPrivate *get(FramelessWidget *pub);
|
||||
Q_NODISCARD static const FramelessWidgetPrivate *get(const FramelessWidget *pub);
|
||||
|
||||
Q_NODISCARD bool isNormal() const;
|
||||
Q_NODISCARD bool isZoomed() const;
|
||||
|
||||
void toggleMaximized();
|
||||
void toggleFullScreen();
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
FramelessWidget *q_ptr = nullptr;
|
||||
Qt::WindowState m_savedWindowState = Qt::WindowNoState;
|
||||
QScopedPointer<WidgetsSharedHelper> m_helper;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* 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 "framelesshelperwidgets_global.h"
|
||||
#include <QtCore/qobject.h>
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
struct WidgetsHelperData;
|
||||
class FramelessWidgetsHelper;
|
||||
|
||||
class FRAMELESSHELPER_WIDGETS_API FramelessWidgetsHelperPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(FramelessWidgetsHelper)
|
||||
Q_DISABLE_COPY_MOVE(FramelessWidgetsHelperPrivate)
|
||||
|
||||
public:
|
||||
explicit FramelessWidgetsHelperPrivate(FramelessWidgetsHelper *q);
|
||||
~FramelessWidgetsHelperPrivate() override;
|
||||
|
||||
Q_NODISCARD static FramelessWidgetsHelperPrivate *get(FramelessWidgetsHelper *pub);
|
||||
Q_NODISCARD static const FramelessWidgetsHelperPrivate *get(const FramelessWidgetsHelper *pub);
|
||||
|
||||
Q_NODISCARD QWidget *getTitleBarWidget() const;
|
||||
void setTitleBarWidget(QWidget *widget);
|
||||
|
||||
void attachToWindow();
|
||||
void setSystemButton(QWidget *widget, const Global::SystemButtonType buttonType);
|
||||
void setHitTestVisible(QWidget *widget);
|
||||
void showSystemMenu(const QPoint &pos);
|
||||
void windowStartSystemMove2(const QPoint &pos);
|
||||
void windowStartSystemResize2(const Qt::Edges edges, const QPoint &pos);
|
||||
|
||||
void moveWindowToDesktopCenter();
|
||||
void bringWindowToFront();
|
||||
|
||||
Q_NODISCARD bool isWindowFixedSize() const;
|
||||
void setWindowFixedSize(const bool value);
|
||||
|
||||
private:
|
||||
Q_NODISCARD QRect mapWidgetGeometryToScene(const QWidget * const widget) const;
|
||||
Q_NODISCARD bool isInSystemButtons(const QPoint &pos, Global::SystemButtonType *button) const;
|
||||
Q_NODISCARD bool isInTitleBarDraggableArea(const QPoint &pos) const;
|
||||
Q_NODISCARD bool shouldIgnoreMouseEvents(const QPoint &pos) const;
|
||||
void setSystemButtonState(const Global::SystemButtonType button, const Global::ButtonState state);
|
||||
Q_NODISCARD QWidget *getWindow() const;
|
||||
Q_NODISCARD WidgetsHelperData getWindowData() const;
|
||||
Q_NODISCARD WidgetsHelperData *getWindowDataMutable() const;
|
||||
|
||||
private:
|
||||
FramelessWidgetsHelper *q_ptr = nullptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* 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 <QtCore/qobject.h>
|
||||
#include <QtGui/qpixmap.h>
|
||||
#include "framelesshelperwidgets_global.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QEnterEvent;
|
||||
class QPaintEvent;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class StandardSystemButton;
|
||||
|
||||
class FRAMELESSHELPER_WIDGETS_API StandardSystemButtonPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(StandardSystemButton)
|
||||
Q_DISABLE_COPY_MOVE(StandardSystemButtonPrivate)
|
||||
|
||||
public:
|
||||
explicit StandardSystemButtonPrivate(StandardSystemButton *q);
|
||||
~StandardSystemButtonPrivate() override;
|
||||
|
||||
Q_NODISCARD static StandardSystemButtonPrivate *get(StandardSystemButton *pub);
|
||||
Q_NODISCARD static const StandardSystemButtonPrivate *get(const StandardSystemButton *pub);
|
||||
|
||||
void refreshButtonTheme(const bool force);
|
||||
|
||||
Q_NODISCARD Global::SystemButtonType getButtonType() const;
|
||||
void setButtonType(const Global::SystemButtonType type);
|
||||
|
||||
void setIcon(const QIcon &value, const bool reverse);
|
||||
void setPixmap(const QPixmap &value, const bool reverse);
|
||||
void setImage(const QImage &value, const bool reverse);
|
||||
|
||||
Q_NODISCARD QSize getRecommendedButtonSize() const;
|
||||
|
||||
Q_NODISCARD bool isHovered() const;
|
||||
Q_NODISCARD bool isPressed() const;
|
||||
Q_NODISCARD QColor getHoverColor() const;
|
||||
Q_NODISCARD QColor getPressColor() const;
|
||||
|
||||
void setHovered(const bool value);
|
||||
void setPressed(const bool value);
|
||||
void setHoverColor(const QColor &value);
|
||||
void setPressColor(const QColor &value);
|
||||
|
||||
void enterEventHandler(QT_ENTER_EVENT_TYPE *event);
|
||||
void leaveEventHandler(QEvent *event);
|
||||
void paintEventHandler(QPaintEvent *event);
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
StandardSystemButton *q_ptr = nullptr;
|
||||
Global::SystemTheme m_buttonTheme = Global::SystemTheme::Unknown;
|
||||
Global::SystemButtonType m_buttonType = Global::SystemButtonType::Unknown;
|
||||
QPixmap m_icon = {};
|
||||
QPixmap m_reversedIcon = {};
|
||||
QColor m_hoverColor = {};
|
||||
QColor m_pressColor = {};
|
||||
bool m_hovered = false;
|
||||
bool m_pressed = false;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* 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 "framelesshelperwidgets_global.h"
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtCore/qpointer.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QLabel;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class StandardTitleBar;
|
||||
class StandardSystemButton;
|
||||
|
||||
class FRAMELESSHELPER_WIDGETS_API StandardTitleBarPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(StandardTitleBar)
|
||||
Q_DISABLE_COPY_MOVE(StandardTitleBarPrivate)
|
||||
|
||||
public:
|
||||
explicit StandardTitleBarPrivate(StandardTitleBar *q);
|
||||
~StandardTitleBarPrivate() override;
|
||||
|
||||
Q_NODISCARD static StandardTitleBarPrivate *get(StandardTitleBar *pub);
|
||||
Q_NODISCARD static const StandardTitleBarPrivate *get(const StandardTitleBar *pub);
|
||||
|
||||
public Q_SLOTS:
|
||||
void updateMaximizeButton();
|
||||
void updateTitleBarStyleSheet();
|
||||
|
||||
protected:
|
||||
Q_NODISCARD bool eventFilter(QObject *object, QEvent *event) override;
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
StandardTitleBar *q_ptr = nullptr;
|
||||
QScopedPointer<QLabel> m_windowTitleLabel;
|
||||
QScopedPointer<StandardSystemButton> m_minimizeButton;
|
||||
QScopedPointer<StandardSystemButton> m_maximizeButton;
|
||||
QScopedPointer<StandardSystemButton> m_closeButton;
|
||||
QPointer<QWidget> m_window = nullptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
|
@ -22,4 +22,42 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "../../include/FramelessHelper/Quick/framelessquickwindow.h"
|
||||
#pragma once
|
||||
|
||||
#include "framelesshelperwidgets_global.h"
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtCore/qpointer.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QPaintEvent;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class FRAMELESSHELPER_WIDGETS_API WidgetsSharedHelper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(WidgetsSharedHelper)
|
||||
|
||||
public:
|
||||
explicit WidgetsSharedHelper(QObject *parent = nullptr);
|
||||
~WidgetsSharedHelper() override;
|
||||
|
||||
void setup(QWidget *widget);
|
||||
|
||||
protected:
|
||||
Q_NODISCARD bool eventFilter(QObject *object, QEvent *event) override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateContentsMargins();
|
||||
|
||||
private:
|
||||
void changeEventHandler(QEvent *event);
|
||||
void paintEventHandler(QPaintEvent *event);
|
||||
Q_NODISCARD bool shouldDrawFrameBorder() const;
|
||||
|
||||
private:
|
||||
QPointer<QWidget> m_targetWidget = nullptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
|
@ -37,10 +37,10 @@ set(SOURCES
|
|||
${INCLUDE_PREFIX}/framelesshelper_qt.h
|
||||
${INCLUDE_PREFIX}/framelesswindowsmanager.h
|
||||
${INCLUDE_PREFIX}/utils.h
|
||||
${INCLUDE_PREFIX}/private/framelesswindowsmanager_p.h
|
||||
framelesshelpercore.qrc
|
||||
utils.cpp
|
||||
framelesshelper_qt.cpp
|
||||
framelesswindowsmanager_p.h
|
||||
framelesswindowsmanager.cpp
|
||||
)
|
||||
|
||||
|
@ -127,4 +127,5 @@ target_link_libraries(${SUB_PROJ_NAME} PRIVATE
|
|||
|
||||
target_include_directories(${SUB_PROJ_NAME} PUBLIC
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/${INCLUDE_PREFIX}"
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/${INCLUDE_PREFIX}/private"
|
||||
)
|
||||
|
|
|
@ -1,25 +1 @@
|
|||
/*
|
||||
* 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 "../../include/FramelessHelper/Core/framelesshelper_qt.h"
|
||||
|
|
|
@ -1,25 +1 @@
|
|||
/*
|
||||
* 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 "../../include/FramelessHelper/Core/framelesshelper_win.h"
|
||||
|
|
|
@ -1,25 +1 @@
|
|||
/*
|
||||
* 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 "../../include/FramelessHelper/Core/framelesshelper_windows.h"
|
||||
|
|
|
@ -1,25 +1 @@
|
|||
/*
|
||||
* 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 "../../include/FramelessHelper/Core/framelesshelpercore_global.h"
|
||||
|
|
|
@ -1,25 +1 @@
|
|||
/*
|
||||
* 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 "../../include/FramelessHelper/Core/framelesswindowsmanager.h"
|
||||
|
|
|
@ -1,66 +1 @@
|
|||
/*
|
||||
* 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 "framelesshelpercore_global.h"
|
||||
#include <QtCore/qobject.h>
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class FramelessWindowsManager;
|
||||
|
||||
class FRAMELESSHELPER_CORE_API FramelessWindowsManagerPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(FramelessWindowsManager)
|
||||
Q_DISABLE_COPY_MOVE(FramelessWindowsManagerPrivate)
|
||||
|
||||
public:
|
||||
explicit FramelessWindowsManagerPrivate(FramelessWindowsManager *q);
|
||||
~FramelessWindowsManagerPrivate() override;
|
||||
|
||||
Q_NODISCARD static FramelessWindowsManagerPrivate *get(FramelessWindowsManager *pub);
|
||||
Q_NODISCARD static const FramelessWindowsManagerPrivate *get(const FramelessWindowsManager *pub);
|
||||
|
||||
Q_NODISCARD static bool usePureQtImplementation();
|
||||
Q_NODISCARD Global::SystemTheme systemTheme() const;
|
||||
Q_NODISCARD QColor systemAccentColor() const;
|
||||
|
||||
static void addWindow(const Global::SystemParameters ¶ms);
|
||||
Q_INVOKABLE void notifySystemThemeHasChangedOrNot();
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
FramelessWindowsManager *q_ptr = nullptr;
|
||||
Global::SystemTheme m_systemTheme = Global::SystemTheme::Unknown;
|
||||
QColor m_accentColor = {};
|
||||
#ifdef Q_OS_WINDOWS
|
||||
Global::DwmColorizationArea m_colorizationArea = Global::DwmColorizationArea::None_;
|
||||
#endif
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
#include "../../include/FramelessHelper/Core/private/framelesswindowsmanager_p.h"
|
||||
|
|
|
@ -71,18 +71,22 @@ Qt::CursorShape Utils::calculateCursorShape(const QWindow *window, const QPoint
|
|||
if (window->visibility() != QWindow::Windowed) {
|
||||
return Qt::ArrowCursor;
|
||||
}
|
||||
if (((pos.x() < kDefaultResizeBorderThickness) && (pos.y() < kDefaultResizeBorderThickness))
|
||||
|| ((pos.x() >= (window->width() - kDefaultResizeBorderThickness)) && (pos.y() >= (window->height() - kDefaultResizeBorderThickness)))) {
|
||||
const int x = pos.x();
|
||||
const int y = pos.y();
|
||||
const int w = window->width();
|
||||
const int h = window->height();
|
||||
if (((x < kDefaultResizeBorderThickness) && (y < kDefaultResizeBorderThickness))
|
||||
|| ((x >= (w - kDefaultResizeBorderThickness)) && (y >= (h - kDefaultResizeBorderThickness)))) {
|
||||
return Qt::SizeFDiagCursor;
|
||||
}
|
||||
if (((pos.x() >= (window->width() - kDefaultResizeBorderThickness)) && (pos.y() < kDefaultResizeBorderThickness))
|
||||
|| ((pos.x() < kDefaultResizeBorderThickness) && (pos.y() >= (window->height() - kDefaultResizeBorderThickness)))) {
|
||||
if (((x >= (w - kDefaultResizeBorderThickness)) && (y < kDefaultResizeBorderThickness))
|
||||
|| ((x < kDefaultResizeBorderThickness) && (y >= (h - kDefaultResizeBorderThickness)))) {
|
||||
return Qt::SizeBDiagCursor;
|
||||
}
|
||||
if ((pos.x() < kDefaultResizeBorderThickness) || (pos.x() >= (window->width() - kDefaultResizeBorderThickness))) {
|
||||
if ((x < kDefaultResizeBorderThickness) || (x >= (w - kDefaultResizeBorderThickness))) {
|
||||
return Qt::SizeHorCursor;
|
||||
}
|
||||
if ((pos.y() < kDefaultResizeBorderThickness) || (pos.y() >= (window->height() - kDefaultResizeBorderThickness))) {
|
||||
if ((y < kDefaultResizeBorderThickness) || (y >= (h - kDefaultResizeBorderThickness))) {
|
||||
return Qt::SizeVerCursor;
|
||||
}
|
||||
return Qt::ArrowCursor;
|
||||
|
@ -104,16 +108,18 @@ Qt::Edges Utils::calculateWindowEdges(const QWindow *window, const QPoint &pos)
|
|||
return {};
|
||||
}
|
||||
Qt::Edges edges = {};
|
||||
if (pos.x() < kDefaultResizeBorderThickness) {
|
||||
const int x = pos.x();
|
||||
const int y = pos.y();
|
||||
if (x < kDefaultResizeBorderThickness) {
|
||||
edges |= Qt::LeftEdge;
|
||||
}
|
||||
if (pos.x() >= (window->width() - kDefaultResizeBorderThickness)) {
|
||||
if (x >= (window->width() - kDefaultResizeBorderThickness)) {
|
||||
edges |= Qt::RightEdge;
|
||||
}
|
||||
if (pos.y() < kDefaultResizeBorderThickness) {
|
||||
if (y < kDefaultResizeBorderThickness) {
|
||||
edges |= Qt::TopEdge;
|
||||
}
|
||||
if (pos.y() >= (window->height() - kDefaultResizeBorderThickness)) {
|
||||
if (y >= (window->height() - kDefaultResizeBorderThickness)) {
|
||||
edges |= Qt::BottomEdge;
|
||||
}
|
||||
return edges;
|
||||
|
|
|
@ -1,25 +1 @@
|
|||
/*
|
||||
* 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 "../../include/FramelessHelper/Core/utils.h"
|
||||
|
|
|
@ -33,19 +33,19 @@ set(SOURCES
|
|||
framelesshelperquick.qrc
|
||||
${INCLUDE_PREFIX}/framelesshelperquick_global.h
|
||||
${INCLUDE_PREFIX}/framelessquickmodule.h
|
||||
${INCLUDE_PREFIX}/framelessquickwindow.h
|
||||
${INCLUDE_PREFIX}/framelessquickhelper.h
|
||||
${INCLUDE_PREFIX}/framelessquickutils.h
|
||||
quickstandardminimizebutton_p.h
|
||||
${INCLUDE_PREFIX}/private/quickstandardminimizebutton_p.h
|
||||
${INCLUDE_PREFIX}/private/quickstandardmaximizebutton_p.h
|
||||
${INCLUDE_PREFIX}/private/quickstandardclosebutton_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_p.h
|
||||
quickstandardmaximizebutton.cpp
|
||||
quickstandardclosebutton_p.h
|
||||
quickstandardclosebutton.cpp
|
||||
quickstandardtitlebar_p.h
|
||||
quickstandardtitlebar.cpp
|
||||
framelessquickhelper_p.h
|
||||
framelessquickwindow_p.h
|
||||
framelessquickutils.cpp
|
||||
framelessquickmodule.cpp
|
||||
framelessquickwindow.cpp
|
||||
|
@ -114,4 +114,5 @@ target_link_libraries(${SUB_PROJ_NAME} PUBLIC
|
|||
|
||||
target_include_directories(${SUB_PROJ_NAME} PUBLIC
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/${INCLUDE_PREFIX}"
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/${INCLUDE_PREFIX}/private"
|
||||
)
|
||||
|
|
|
@ -1,25 +1 @@
|
|||
/*
|
||||
* 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 "../../include/FramelessHelper/Quick/framelesshelperquick_global.h"
|
||||
|
|
|
@ -325,11 +325,10 @@ void FramelessQuickHelperPrivate::bringWindowToFront()
|
|||
if (!window) {
|
||||
return;
|
||||
}
|
||||
const QQuickWindow::Visibility visibility = window->visibility();
|
||||
if (visibility == QQuickWindow::Hidden) {
|
||||
if (window->visibility() == QQuickWindow::Hidden) {
|
||||
window->show();
|
||||
}
|
||||
if (visibility == QQuickWindow::Minimized) {
|
||||
if (window->visibility() == QQuickWindow::Minimized) {
|
||||
window->showNormal(); // ### FIXME
|
||||
}
|
||||
window->raise();
|
||||
|
|
|
@ -1,25 +1 @@
|
|||
/*
|
||||
* 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 "../../include/FramelessHelper/Quick/framelessquickhelper.h"
|
||||
|
|
|
@ -1,81 +1 @@
|
|||
/*
|
||||
* 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"
|
||||
#include <QtCore/qobject.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QQuickItem;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
struct QuickHelperData;
|
||||
class FramelessQuickHelper;
|
||||
|
||||
class FRAMELESSHELPER_QUICK_API FramelessQuickHelperPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(FramelessQuickHelper)
|
||||
Q_DISABLE_COPY_MOVE(FramelessQuickHelperPrivate)
|
||||
|
||||
public:
|
||||
explicit FramelessQuickHelperPrivate(FramelessQuickHelper *q);
|
||||
~FramelessQuickHelperPrivate() override;
|
||||
|
||||
Q_NODISCARD static FramelessQuickHelperPrivate *get(FramelessQuickHelper *pub);
|
||||
Q_NODISCARD static const FramelessQuickHelperPrivate *get(const FramelessQuickHelper *pub);
|
||||
|
||||
Q_NODISCARD QQuickItem *getTitleBarItem() const;
|
||||
void setTitleBarItem(QQuickItem *value);
|
||||
|
||||
void attachToWindow();
|
||||
void setSystemButton(QQuickItem *item, const QuickGlobal::SystemButtonType buttonType);
|
||||
void setHitTestVisible(QQuickItem *item);
|
||||
void showSystemMenu(const QPoint &pos);
|
||||
void windowStartSystemMove2(const QPoint &pos);
|
||||
void windowStartSystemResize2(const Qt::Edges edges, const QPoint &pos);
|
||||
|
||||
void moveWindowToDesktopCenter();
|
||||
void bringWindowToFront();
|
||||
|
||||
Q_NODISCARD bool isWindowFixedSize() const;
|
||||
void setWindowFixedSize(const bool value);
|
||||
|
||||
private:
|
||||
Q_NODISCARD QRect mapItemGeometryToScene(const QQuickItem * const item) const;
|
||||
Q_NODISCARD bool isInSystemButtons(const QPoint &pos, QuickGlobal::SystemButtonType *button) const;
|
||||
Q_NODISCARD bool isInTitleBarDraggableArea(const QPoint &pos) const;
|
||||
Q_NODISCARD bool shouldIgnoreMouseEvents(const QPoint &pos) const;
|
||||
void setSystemButtonState(const QuickGlobal::SystemButtonType button, const QuickGlobal::ButtonState state);
|
||||
Q_NODISCARD QuickHelperData getWindowData() const;
|
||||
Q_NODISCARD QuickHelperData *getWindowDataMutable() const;
|
||||
|
||||
private:
|
||||
FramelessQuickHelper *q_ptr = nullptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
#include "../../include/FramelessHelper/Quick/private/framelessquickhelper_p.h"
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
# include "quickstandardmaximizebutton_p.h"
|
||||
# include "quickstandardclosebutton_p.h"
|
||||
# include "quickstandardtitlebar_p.h"
|
||||
# include "framelessquickwindow.h"
|
||||
# include "framelessquickwindow_p.h"
|
||||
#else // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
# include <QtQuick/qquickwindow.h>
|
||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
|
|
|
@ -1,25 +1 @@
|
|||
/*
|
||||
* 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 "../../include/FramelessHelper/Quick/framelessquickmodule.h"
|
||||
|
|
|
@ -1,25 +1 @@
|
|||
/*
|
||||
* 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 "../../include/FramelessHelper/Quick/framelessquickutils.h"
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "framelessquickwindow.h"
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
#include "framelessquickwindow_p.h"
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
#include "framelessquickwindow_p_p.h"
|
||||
#include "framelessquickhelper.h"
|
||||
#include <QtQuick/private/qquickitem_p.h>
|
||||
#include <QtQuick/private/qquickrectangle_p.h>
|
||||
|
@ -84,12 +84,16 @@ bool FramelessQuickWindowPrivate::isMinimized() const
|
|||
return (q->visibility() == FramelessQuickWindow::Minimized);
|
||||
}
|
||||
|
||||
bool FramelessQuickWindowPrivate::isMaximized() const
|
||||
{
|
||||
Q_Q(const FramelessQuickWindow);
|
||||
return (q->visibility() == FramelessQuickWindow::Maximized);
|
||||
}
|
||||
|
||||
bool FramelessQuickWindowPrivate::isZoomed() const
|
||||
{
|
||||
Q_Q(const FramelessQuickWindow);
|
||||
const FramelessQuickWindow::Visibility visibility = q->visibility();
|
||||
return ((visibility == FramelessQuickWindow::Maximized) ||
|
||||
(visibility == FramelessQuickWindow::FullScreen));
|
||||
return (isMaximized() || (q->visibility() == FramelessQuickWindow::FullScreen));
|
||||
}
|
||||
|
||||
bool FramelessQuickWindowPrivate::isFullScreen() const
|
||||
|
@ -130,7 +134,7 @@ void FramelessQuickWindowPrivate::showMinimized2()
|
|||
void FramelessQuickWindowPrivate::toggleMaximized()
|
||||
{
|
||||
Q_Q(FramelessQuickWindow);
|
||||
if (isZoomed()) {
|
||||
if (isMaximized()) {
|
||||
q->showNormal();
|
||||
} else {
|
||||
q->showMaximized();
|
||||
|
@ -171,6 +175,7 @@ void FramelessQuickWindowPrivate::initialize()
|
|||
Q_EMIT q->hiddenChanged();
|
||||
Q_EMIT q->normalChanged();
|
||||
Q_EMIT q->minimizedChanged();
|
||||
Q_EMIT q->maximizedChanged();
|
||||
Q_EMIT q->zoomedChanged();
|
||||
Q_EMIT q->fullScreenChanged();
|
||||
});
|
||||
|
@ -233,6 +238,12 @@ bool FramelessQuickWindow::isMinimized() const
|
|||
return d->isMinimized();
|
||||
}
|
||||
|
||||
bool FramelessQuickWindow::isMaximized() const
|
||||
{
|
||||
Q_D(const FramelessQuickWindow);
|
||||
return d->isMaximized();
|
||||
}
|
||||
|
||||
bool FramelessQuickWindow::isZoomed() const
|
||||
{
|
||||
Q_D(const FramelessQuickWindow);
|
||||
|
|
|
@ -1,84 +1 @@
|
|||
/*
|
||||
* 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 <QtCore/qobject.h>
|
||||
#include <QtQuick/qquickwindow.h>
|
||||
#include <QtQuick/private/qquickanchors_p_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QQuickRectangle;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class FramelessQuickWindow;
|
||||
|
||||
class FRAMELESSHELPER_QUICK_API FramelessQuickWindowPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(FramelessQuickWindow)
|
||||
Q_DISABLE_COPY_MOVE(FramelessQuickWindowPrivate)
|
||||
|
||||
public:
|
||||
explicit FramelessQuickWindowPrivate(FramelessQuickWindow *q);
|
||||
~FramelessQuickWindowPrivate() override;
|
||||
|
||||
Q_NODISCARD static FramelessQuickWindowPrivate *get(FramelessQuickWindow *pub);
|
||||
Q_NODISCARD static const FramelessQuickWindowPrivate *get(const FramelessQuickWindow *pub);
|
||||
|
||||
Q_INVOKABLE Q_NODISCARD bool isHidden() const;
|
||||
Q_INVOKABLE Q_NODISCARD bool isNormal() const;
|
||||
Q_INVOKABLE Q_NODISCARD bool isMinimized() const;
|
||||
Q_INVOKABLE Q_NODISCARD bool isZoomed() const;
|
||||
Q_INVOKABLE Q_NODISCARD bool isFullScreen() const;
|
||||
|
||||
Q_INVOKABLE Q_NODISCARD QColor getFrameBorderColor() const;
|
||||
Q_INVOKABLE Q_NODISCARD QQuickAnchorLine getTopBorderBottom() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void showMinimized2();
|
||||
void toggleMaximized();
|
||||
void toggleFullScreen();
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
Q_NODISCARD bool shouldDrawFrameBorder() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateTopBorderColor();
|
||||
void updateTopBorderHeight();
|
||||
|
||||
private:
|
||||
FramelessQuickWindow *q_ptr = nullptr;
|
||||
QScopedPointer<QQuickRectangle> m_topBorderRectangle;
|
||||
QScopedPointer<QQuickAnchors> m_topBorderAnchors;
|
||||
QQuickWindow::Visibility m_savedVisibility = QQuickWindow::Windowed;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
#endif
|
||||
#include "../../include/FramelessHelper/Quick/private/framelessquickwindow_p.h"
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
#include "../../include/FramelessHelper/Quick/private/framelessquickwindow_p_p.h"
|
|
@ -1,69 +1 @@
|
|||
/*
|
||||
* 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/qquicktooltip_p.h>
|
||||
#include <QtQuickTemplates2/private/qquickbutton_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QQuickImage;
|
||||
class QQuickRectangle;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class FRAMELESSHELPER_QUICK_API QuickStandardCloseButton : public QQuickButton
|
||||
{
|
||||
Q_OBJECT
|
||||
#ifdef QML_NAMED_ELEMENT
|
||||
QML_NAMED_ELEMENT(StandardCloseButton)
|
||||
#endif
|
||||
Q_DISABLE_COPY_MOVE(QuickStandardCloseButton)
|
||||
|
||||
public:
|
||||
explicit QuickStandardCloseButton(QQuickItem *parent = nullptr);
|
||||
~QuickStandardCloseButton() override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateForeground();
|
||||
void updateBackground();
|
||||
void updateToolTip();
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
QScopedPointer<QQuickItem> m_contentItem;
|
||||
QScopedPointer<QQuickImage> m_image;
|
||||
QScopedPointer<QQuickRectangle> m_backgroundItem;
|
||||
QPointer<QQuickToolTipAttached> m_tooltip = nullptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickStandardCloseButton))
|
||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
#include "../../include/FramelessHelper/Quick/private/quickstandardclosebutton_p.h"
|
||||
|
|
|
@ -1,77 +1 @@
|
|||
/*
|
||||
* 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>
|
||||
#include <QtQuickTemplates2/private/qquicktooltip_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);
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateForeground();
|
||||
void updateBackground();
|
||||
void updateToolTip();
|
||||
|
||||
Q_SIGNALS:
|
||||
void maximizedChanged();
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
bool m_max = false;
|
||||
QScopedPointer<QQuickItem> m_contentItem;
|
||||
QScopedPointer<QQuickImage> m_image;
|
||||
QScopedPointer<QQuickRectangle> m_backgroundItem;
|
||||
QPointer<QQuickToolTipAttached> m_tooltip = nullptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickStandardMaximizeButton))
|
||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
#include "../../include/FramelessHelper/Quick/private/quickstandardmaximizebutton_p.h"
|
||||
|
|
|
@ -1,69 +1 @@
|
|||
/*
|
||||
* 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>
|
||||
#include <QtQuickTemplates2/private/qquicktooltip_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;
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateForeground();
|
||||
void updateBackground();
|
||||
void updateToolTip();
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
QScopedPointer<QQuickItem> m_contentItem;
|
||||
QScopedPointer<QQuickImage> m_image;
|
||||
QScopedPointer<QQuickRectangle> m_backgroundItem;
|
||||
QPointer<QQuickToolTipAttached> m_tooltip = nullptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickStandardMinimizeButton))
|
||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
#include "../../include/FramelessHelper/Quick/private/quickstandardminimizebutton_p.h"
|
||||
|
|
|
@ -1,98 +1 @@
|
|||
/*
|
||||
* 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 <QtQuick/private/qquickrectangle_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QQuickLabel;
|
||||
class QQuickRow;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class QuickStandardMinimizeButton;
|
||||
class QuickStandardMaximizeButton;
|
||||
class QuickStandardCloseButton;
|
||||
|
||||
class FRAMELESSHELPER_QUICK_API QuickStandardTitleBar : public QQuickRectangle
|
||||
{
|
||||
Q_OBJECT
|
||||
#ifdef QML_NAMED_ELEMENT
|
||||
QML_NAMED_ELEMENT(StandardTitleBar)
|
||||
#endif
|
||||
Q_DISABLE_COPY_MOVE(QuickStandardTitleBar)
|
||||
Q_PROPERTY(Qt::Alignment titleLabelAlignment READ titleLabelAlignment WRITE setTitleLabelAlignment NOTIFY titleLabelAlignmentChanged 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)
|
||||
|
||||
public:
|
||||
explicit QuickStandardTitleBar(QQuickItem *parent = nullptr);
|
||||
~QuickStandardTitleBar() override;
|
||||
|
||||
Q_NODISCARD Qt::Alignment titleLabelAlignment() const;
|
||||
void setTitleLabelAlignment(const Qt::Alignment value);
|
||||
|
||||
Q_NODISCARD QuickStandardMinimizeButton *minimizeButton() const;
|
||||
Q_NODISCARD QuickStandardMaximizeButton *maximizeButton() const;
|
||||
Q_NODISCARD QuickStandardCloseButton *closeButton() const;
|
||||
|
||||
protected:
|
||||
void itemChange(const ItemChange change, const ItemChangeData &value) override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateMaximizeButton();
|
||||
void updateTitleLabelText();
|
||||
void updateTitleBarColor();
|
||||
void clickMinimizeButton();
|
||||
void clickMaximizeButton();
|
||||
void clickCloseButton();
|
||||
|
||||
Q_SIGNALS:
|
||||
void titleLabelAlignmentChanged();
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
void updateAll();
|
||||
|
||||
private:
|
||||
Qt::Alignment m_labelAlignment = {};
|
||||
QScopedPointer<QQuickLabel> m_label;
|
||||
QScopedPointer<QQuickRow> m_row;
|
||||
QScopedPointer<QuickStandardMinimizeButton> m_minBtn;
|
||||
QScopedPointer<QuickStandardMaximizeButton> m_maxBtn;
|
||||
QScopedPointer<QuickStandardCloseButton> m_closeBtn;
|
||||
QMetaObject::Connection m_windowStateChangeConnection = {};
|
||||
QMetaObject::Connection m_windowActiveChangeConnection = {};
|
||||
QMetaObject::Connection m_windowTitleChangeConnection = {};
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickStandardTitleBar))
|
||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
#include "../../include/FramelessHelper/Quick/private/quickstandardtitlebar_p.h"
|
||||
|
|
|
@ -33,17 +33,17 @@ set(SOURCES
|
|||
${INCLUDE_PREFIX}/standardsystembutton.h
|
||||
${INCLUDE_PREFIX}/framelesswidgetshelper.h
|
||||
${INCLUDE_PREFIX}/standardtitlebar.h
|
||||
framelesswidgetshelper_p.h
|
||||
standardsystembutton_p.h
|
||||
standardtitlebar_p.h
|
||||
framelesswidget_p.h
|
||||
framelessmainwindow_p.h
|
||||
${INCLUDE_PREFIX}/private/framelesswidgetshelper_p.h
|
||||
${INCLUDE_PREFIX}/private/standardsystembutton_p.h
|
||||
${INCLUDE_PREFIX}/private/standardtitlebar_p.h
|
||||
${INCLUDE_PREFIX}/private/framelesswidget_p.h
|
||||
${INCLUDE_PREFIX}/private/framelessmainwindow_p.h
|
||||
${INCLUDE_PREFIX}/private/widgetssharedhelper_p.h
|
||||
framelessmainwindow.cpp
|
||||
framelesswidgetshelper.cpp
|
||||
framelesswidget.cpp
|
||||
standardsystembutton.cpp
|
||||
standardtitlebar.cpp
|
||||
widgetssharedhelper_p.h
|
||||
widgetssharedhelper.cpp
|
||||
)
|
||||
|
||||
|
@ -98,4 +98,5 @@ target_link_libraries(${SUB_PROJ_NAME} PUBLIC
|
|||
|
||||
target_include_directories(${SUB_PROJ_NAME} PUBLIC
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/${INCLUDE_PREFIX}"
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/${INCLUDE_PREFIX}/private"
|
||||
)
|
||||
|
|
|
@ -1,25 +1 @@
|
|||
/*
|
||||
* 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 "../../include/FramelessHelper/Widgets/framelesshelperwidgets_global.h"
|
||||
|
|
|
@ -1,25 +1 @@
|
|||
/*
|
||||
* 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 "../../include/FramelessHelper/Widgets/framelessmainwindow.h"
|
||||
|
|
|
@ -1,63 +1 @@
|
|||
/*
|
||||
* 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 "framelesshelperwidgets_global.h"
|
||||
#include <QtCore/qobject.h>
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class FramelessMainWindow;
|
||||
class WidgetsSharedHelper;
|
||||
|
||||
class FRAMELESSHELPER_WIDGETS_API FramelessMainWindowPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(FramelessMainWindow)
|
||||
Q_DISABLE_COPY_MOVE(FramelessMainWindowPrivate)
|
||||
|
||||
public:
|
||||
explicit FramelessMainWindowPrivate(FramelessMainWindow *q);
|
||||
~FramelessMainWindowPrivate() override;
|
||||
|
||||
Q_NODISCARD static FramelessMainWindowPrivate *get(FramelessMainWindow *pub);
|
||||
Q_NODISCARD static const FramelessMainWindowPrivate *get(const FramelessMainWindow *pub);
|
||||
|
||||
Q_NODISCARD bool isNormal() const;
|
||||
Q_NODISCARD bool isZoomed() const;
|
||||
|
||||
void toggleMaximized();
|
||||
void toggleFullScreen();
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
FramelessMainWindow *q_ptr = nullptr;
|
||||
Qt::WindowState m_savedWindowState = Qt::WindowNoState;
|
||||
QScopedPointer<WidgetsSharedHelper> m_helper;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
#include "../../include/FramelessHelper/Widgets/private/framelessmainwindow_p.h"
|
||||
|
|
|
@ -1,25 +1 @@
|
|||
/*
|
||||
* 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 "../../include/FramelessHelper/Widgets/framelesswidget.h"
|
||||
|
|
|
@ -1,63 +1 @@
|
|||
/*
|
||||
* 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 "framelesshelperwidgets_global.h"
|
||||
#include <QtCore/qobject.h>
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class FramelessWidget;
|
||||
class WidgetsSharedHelper;
|
||||
|
||||
class FRAMELESSHELPER_WIDGETS_API FramelessWidgetPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(FramelessWidget)
|
||||
Q_DISABLE_COPY_MOVE(FramelessWidgetPrivate)
|
||||
|
||||
public:
|
||||
explicit FramelessWidgetPrivate(FramelessWidget *q);
|
||||
~FramelessWidgetPrivate() override;
|
||||
|
||||
Q_NODISCARD static FramelessWidgetPrivate *get(FramelessWidget *pub);
|
||||
Q_NODISCARD static const FramelessWidgetPrivate *get(const FramelessWidget *pub);
|
||||
|
||||
Q_NODISCARD bool isNormal() const;
|
||||
Q_NODISCARD bool isZoomed() const;
|
||||
|
||||
void toggleMaximized();
|
||||
void toggleFullScreen();
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
FramelessWidget *q_ptr = nullptr;
|
||||
Qt::WindowState m_savedWindowState = Qt::WindowNoState;
|
||||
QScopedPointer<WidgetsSharedHelper> m_helper;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
#include "../../include/FramelessHelper/Widgets/private/framelesswidget_p.h"
|
||||
|
|
|
@ -455,7 +455,7 @@ void FramelessWidgetsHelperPrivate::setSystemButtonState(const SystemButtonType
|
|||
const int pressedIndex = mo->indexOfSlot(QMetaObject::normalizedSignature("setPressed(bool)").constData());
|
||||
const int hoveredIndex = mo->indexOfSlot(QMetaObject::normalizedSignature("setHovered(bool)").constData());
|
||||
const int clickedIndex = mo->indexOfSignal(QMetaObject::normalizedSignature("clicked()").constData());
|
||||
if ((pressedIndex != -1) && (hoveredIndex != -1) && (clickedIndex != -1)) {
|
||||
if ((pressedIndex >= 0) && (hoveredIndex >= 0) && (clickedIndex >= 0)) {
|
||||
updateButtonState(widgetButton);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1 @@
|
|||
/*
|
||||
* 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 "../../include/FramelessHelper/Widgets/framelesswidgetshelper.h"
|
||||
|
|
|
@ -1,78 +1 @@
|
|||
/*
|
||||
* 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 "framelesshelperwidgets_global.h"
|
||||
#include <QtCore/qobject.h>
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
struct WidgetsHelperData;
|
||||
class FramelessWidgetsHelper;
|
||||
|
||||
class FRAMELESSHELPER_WIDGETS_API FramelessWidgetsHelperPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(FramelessWidgetsHelper)
|
||||
Q_DISABLE_COPY_MOVE(FramelessWidgetsHelperPrivate)
|
||||
|
||||
public:
|
||||
explicit FramelessWidgetsHelperPrivate(FramelessWidgetsHelper *q);
|
||||
~FramelessWidgetsHelperPrivate() override;
|
||||
|
||||
Q_NODISCARD static FramelessWidgetsHelperPrivate *get(FramelessWidgetsHelper *pub);
|
||||
Q_NODISCARD static const FramelessWidgetsHelperPrivate *get(const FramelessWidgetsHelper *pub);
|
||||
|
||||
Q_NODISCARD QWidget *getTitleBarWidget() const;
|
||||
void setTitleBarWidget(QWidget *widget);
|
||||
|
||||
void attachToWindow();
|
||||
void setSystemButton(QWidget *widget, const Global::SystemButtonType buttonType);
|
||||
void setHitTestVisible(QWidget *widget);
|
||||
void showSystemMenu(const QPoint &pos);
|
||||
void windowStartSystemMove2(const QPoint &pos);
|
||||
void windowStartSystemResize2(const Qt::Edges edges, const QPoint &pos);
|
||||
|
||||
void moveWindowToDesktopCenter();
|
||||
void bringWindowToFront();
|
||||
|
||||
Q_NODISCARD bool isWindowFixedSize() const;
|
||||
void setWindowFixedSize(const bool value);
|
||||
|
||||
private:
|
||||
Q_NODISCARD QRect mapWidgetGeometryToScene(const QWidget * const widget) const;
|
||||
Q_NODISCARD bool isInSystemButtons(const QPoint &pos, Global::SystemButtonType *button) const;
|
||||
Q_NODISCARD bool isInTitleBarDraggableArea(const QPoint &pos) const;
|
||||
Q_NODISCARD bool shouldIgnoreMouseEvents(const QPoint &pos) const;
|
||||
void setSystemButtonState(const Global::SystemButtonType button, const Global::ButtonState state);
|
||||
Q_NODISCARD QWidget *getWindow() const;
|
||||
Q_NODISCARD WidgetsHelperData getWindowData() const;
|
||||
Q_NODISCARD WidgetsHelperData *getWindowDataMutable() const;
|
||||
|
||||
private:
|
||||
FramelessWidgetsHelper *q_ptr = nullptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
#include "../../include/FramelessHelper/Widgets/private/framelesswidgetshelper_p.h"
|
||||
|
|
|
@ -302,6 +302,7 @@ void StandardSystemButtonPrivate::paintEventHandler(QPaintEvent *event)
|
|||
void StandardSystemButtonPrivate::initialize()
|
||||
{
|
||||
Q_Q(StandardSystemButton);
|
||||
q->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
q->setFixedSize(kDefaultSystemButtonSize);
|
||||
q->setIconSize(kDefaultSystemButtonIconSize);
|
||||
connect(q, &StandardSystemButton::pressed, this, [this](){ setPressed(true); });
|
||||
|
|
|
@ -1,25 +1 @@
|
|||
/*
|
||||
* 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 "../../include/FramelessHelper/Widgets/standardsystembutton.h"
|
||||
|
|
|
@ -1,93 +1 @@
|
|||
/*
|
||||
* 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 <QtCore/qobject.h>
|
||||
#include <QtGui/qpixmap.h>
|
||||
#include "framelesshelperwidgets_global.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QEnterEvent;
|
||||
class QPaintEvent;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class StandardSystemButton;
|
||||
|
||||
class FRAMELESSHELPER_WIDGETS_API StandardSystemButtonPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(StandardSystemButton)
|
||||
Q_DISABLE_COPY_MOVE(StandardSystemButtonPrivate)
|
||||
|
||||
public:
|
||||
explicit StandardSystemButtonPrivate(StandardSystemButton *q);
|
||||
~StandardSystemButtonPrivate() override;
|
||||
|
||||
Q_NODISCARD static StandardSystemButtonPrivate *get(StandardSystemButton *pub);
|
||||
Q_NODISCARD static const StandardSystemButtonPrivate *get(const StandardSystemButton *pub);
|
||||
|
||||
void refreshButtonTheme(const bool force);
|
||||
|
||||
Q_NODISCARD Global::SystemButtonType getButtonType() const;
|
||||
void setButtonType(const Global::SystemButtonType type);
|
||||
|
||||
void setIcon(const QIcon &value, const bool reverse);
|
||||
void setPixmap(const QPixmap &value, const bool reverse);
|
||||
void setImage(const QImage &value, const bool reverse);
|
||||
|
||||
Q_NODISCARD QSize getRecommendedButtonSize() const;
|
||||
|
||||
Q_NODISCARD bool isHovered() const;
|
||||
Q_NODISCARD bool isPressed() const;
|
||||
Q_NODISCARD QColor getHoverColor() const;
|
||||
Q_NODISCARD QColor getPressColor() const;
|
||||
|
||||
void setHovered(const bool value);
|
||||
void setPressed(const bool value);
|
||||
void setHoverColor(const QColor &value);
|
||||
void setPressColor(const QColor &value);
|
||||
|
||||
void enterEventHandler(QT_ENTER_EVENT_TYPE *event);
|
||||
void leaveEventHandler(QEvent *event);
|
||||
void paintEventHandler(QPaintEvent *event);
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
StandardSystemButton *q_ptr = nullptr;
|
||||
Global::SystemTheme m_buttonTheme = Global::SystemTheme::Unknown;
|
||||
Global::SystemButtonType m_buttonType = Global::SystemButtonType::Unknown;
|
||||
QPixmap m_icon = {};
|
||||
QPixmap m_reversedIcon = {};
|
||||
QColor m_hoverColor = {};
|
||||
QColor m_pressColor = {};
|
||||
bool m_hovered = false;
|
||||
bool m_pressed = false;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
#include "../../include/FramelessHelper/Widgets/private/standardsystembutton_p.h"
|
||||
|
|
|
@ -147,7 +147,7 @@ bool StandardTitleBarPrivate::eventFilter(QObject *object, QEvent *event)
|
|||
void StandardTitleBarPrivate::initialize()
|
||||
{
|
||||
Q_Q(StandardTitleBar);
|
||||
m_window = q->window();
|
||||
m_window = (q->nativeParentWidget() ? q->nativeParentWidget() : q->window());
|
||||
q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
q->setFixedHeight(kDefaultTitleBarHeight);
|
||||
m_windowTitleLabel.reset(new QLabel(q));
|
||||
|
@ -158,35 +158,38 @@ void StandardTitleBarPrivate::initialize()
|
|||
m_windowTitleLabel->setText(m_window->windowTitle());
|
||||
connect(m_window, &QWidget::windowTitleChanged, m_windowTitleLabel.data(), &QLabel::setText);
|
||||
m_minimizeButton.reset(new StandardSystemButton(SystemButtonType::Minimize, q));
|
||||
m_minimizeButton->setFixedSize(kDefaultSystemButtonSize);
|
||||
m_minimizeButton->setIconSize(kDefaultSystemButtonIconSize);
|
||||
m_minimizeButton->setToolTip(tr("Minimize"));
|
||||
connect(m_minimizeButton.data(), &StandardSystemButton::clicked, m_window, &QWidget::showMinimized);
|
||||
m_maximizeButton.reset(new StandardSystemButton(SystemButtonType::Maximize, q));
|
||||
m_maximizeButton->setFixedSize(kDefaultSystemButtonSize);
|
||||
m_maximizeButton->setIconSize(kDefaultSystemButtonIconSize);
|
||||
updateMaximizeButton();
|
||||
connect(m_maximizeButton.data(), &StandardSystemButton::clicked, this, [this](){
|
||||
if (m_window->isMaximized() || m_window->isFullScreen()) {
|
||||
if (m_window->isMaximized()) {
|
||||
m_window->showNormal();
|
||||
} else {
|
||||
m_window->showMaximized();
|
||||
}
|
||||
});
|
||||
m_closeButton.reset(new StandardSystemButton(SystemButtonType::Close, q));
|
||||
m_closeButton->setFixedSize(kDefaultSystemButtonSize);
|
||||
m_closeButton->setIconSize(kDefaultSystemButtonIconSize);
|
||||
m_closeButton->setToolTip(tr("Close"));
|
||||
connect(m_closeButton.data(), &StandardSystemButton::clicked, m_window, &QWidget::close);
|
||||
const auto systemButtonsInnerLayout = new QHBoxLayout;
|
||||
systemButtonsInnerLayout->setSpacing(0);
|
||||
systemButtonsInnerLayout->setContentsMargins(0, 0, 0, 0);
|
||||
systemButtonsInnerLayout->addWidget(m_minimizeButton.data());
|
||||
systemButtonsInnerLayout->addWidget(m_maximizeButton.data());
|
||||
systemButtonsInnerLayout->addWidget(m_closeButton.data());
|
||||
const auto systemButtonsOuterLayout = new QVBoxLayout;
|
||||
systemButtonsOuterLayout->setSpacing(0);
|
||||
systemButtonsOuterLayout->setContentsMargins(0, 0, 0, 0);
|
||||
systemButtonsOuterLayout->addLayout(systemButtonsInnerLayout);
|
||||
systemButtonsOuterLayout->addStretch();
|
||||
const auto titleBarLayout = new QHBoxLayout(q);
|
||||
titleBarLayout->setContentsMargins(0, 0, 0, 0);
|
||||
titleBarLayout->setSpacing(0);
|
||||
titleBarLayout->addSpacerItem(new QSpacerItem(kDefaultTitleBarContentsMargin, kDefaultTitleBarContentsMargin));
|
||||
titleBarLayout->addWidget(m_windowTitleLabel.data());
|
||||
titleBarLayout->addStretch();
|
||||
titleBarLayout->addWidget(m_minimizeButton.data());
|
||||
titleBarLayout->addWidget(m_maximizeButton.data());
|
||||
titleBarLayout->addWidget(m_closeButton.data());
|
||||
titleBarLayout->addLayout(systemButtonsOuterLayout);
|
||||
q->setLayout(titleBarLayout);
|
||||
updateTitleBarStyleSheet();
|
||||
connect(FramelessWindowsManager::instance(), &FramelessWindowsManager::systemThemeChanged,
|
||||
|
|
|
@ -1,25 +1 @@
|
|||
/*
|
||||
* 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 "../../include/FramelessHelper/Widgets/standardtitlebar.h"
|
||||
|
|
|
@ -1,72 +1 @@
|
|||
/*
|
||||
* 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 "framelesshelperwidgets_global.h"
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtCore/qpointer.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QLabel;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class StandardTitleBar;
|
||||
class StandardSystemButton;
|
||||
|
||||
class FRAMELESSHELPER_WIDGETS_API StandardTitleBarPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(StandardTitleBar)
|
||||
Q_DISABLE_COPY_MOVE(StandardTitleBarPrivate)
|
||||
|
||||
public:
|
||||
explicit StandardTitleBarPrivate(StandardTitleBar *q);
|
||||
~StandardTitleBarPrivate() override;
|
||||
|
||||
Q_NODISCARD static StandardTitleBarPrivate *get(StandardTitleBar *pub);
|
||||
Q_NODISCARD static const StandardTitleBarPrivate *get(const StandardTitleBar *pub);
|
||||
|
||||
public Q_SLOTS:
|
||||
void updateMaximizeButton();
|
||||
void updateTitleBarStyleSheet();
|
||||
|
||||
protected:
|
||||
Q_NODISCARD bool eventFilter(QObject *object, QEvent *event) override;
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
StandardTitleBar *q_ptr = nullptr;
|
||||
QScopedPointer<QLabel> m_windowTitleLabel;
|
||||
QScopedPointer<StandardSystemButton> m_minimizeButton;
|
||||
QScopedPointer<StandardSystemButton> m_maximizeButton;
|
||||
QScopedPointer<StandardSystemButton> m_closeButton;
|
||||
QPointer<QWidget> m_window = nullptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
#include "../../include/FramelessHelper/Widgets/private/standardtitlebar_p.h"
|
||||
|
|
|
@ -1,63 +1 @@
|
|||
/*
|
||||
* 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 "framelesshelperwidgets_global.h"
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtCore/qpointer.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QPaintEvent;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class FRAMELESSHELPER_WIDGETS_API WidgetsSharedHelper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(WidgetsSharedHelper)
|
||||
|
||||
public:
|
||||
explicit WidgetsSharedHelper(QObject *parent = nullptr);
|
||||
~WidgetsSharedHelper() override;
|
||||
|
||||
void setup(QWidget *widget);
|
||||
|
||||
protected:
|
||||
Q_NODISCARD bool eventFilter(QObject *object, QEvent *event) override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateContentsMargins();
|
||||
|
||||
private:
|
||||
void changeEventHandler(QEvent *event);
|
||||
void paintEventHandler(QPaintEvent *event);
|
||||
Q_NODISCARD bool shouldDrawFrameBorder() const;
|
||||
|
||||
private:
|
||||
QPointer<QWidget> m_targetWidget = nullptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
#include "../../include/FramelessHelper/Widgets/private/widgetssharedhelper_p.h"
|
||||
|
|
Loading…
Reference in New Issue