Compare commits
4 Commits
4a1f5fb1f4
...
5c8ac2736f
Author | SHA1 | Date |
---|---|---|
|
5c8ac2736f | |
|
15212abd85 | |
|
3bc44c267d | |
|
01f3750efd |
|
@ -13,7 +13,6 @@
|
||||||
#include <FramelessHelper/Widgets/standardtitlebar.h>
|
#include <FramelessHelper/Widgets/standardtitlebar.h>
|
||||||
#include <FramelessHelper/Widgets/framelesswidgetshelper.h>
|
#include <FramelessHelper/Widgets/framelesswidgetshelper.h>
|
||||||
#include <FramelessHelper/Widgets/standardsystembutton.h>
|
#include <FramelessHelper/Widgets/standardsystembutton.h>
|
||||||
#include <FramelessHelper/Widgets/private/framelesswidgetshelper_p.h>
|
|
||||||
#include "../shared/settings.h"
|
#include "../shared/settings.h"
|
||||||
|
|
||||||
extern template void Settings::set<QRect>(const QString &, const QString &, const QRect &);
|
extern template void Settings::set<QRect>(const QString &, const QString &, const QRect &);
|
||||||
|
@ -138,11 +137,6 @@ void Dialog::setupUi()
|
||||||
helper->setSystemButton(titleBar->maximizeButton(), SystemButtonType::Maximize);
|
helper->setSystemButton(titleBar->maximizeButton(), SystemButtonType::Maximize);
|
||||||
helper->setSystemButton(titleBar->closeButton(), SystemButtonType::Close);
|
helper->setSystemButton(titleBar->closeButton(), SystemButtonType::Close);
|
||||||
#endif // Q_OS_MACOS
|
#endif // Q_OS_MACOS
|
||||||
// Special hack to disable the overriding of the mouse cursor, it's totally different
|
|
||||||
// with making the window un-resizable: we still want the window be able to resize
|
|
||||||
// programatically, but we also want the user not able to resize the window manually.
|
|
||||||
// So apparently we can't use QWidget::setFixedWidth/Height/Size() here.
|
|
||||||
FramelessWidgetsHelperPrivate::get(helper)->setProperty(kDontOverrideCursorVar, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog::waitReady()
|
void Dialog::waitReady()
|
||||||
|
|
|
@ -81,7 +81,7 @@ FramelessApplicationWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
interval: 500
|
interval: 100
|
||||||
running: true
|
running: true
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: timeLabel.text = Qt.formatTime(new Date(), "hh:mm:ss")
|
onTriggered: timeLabel.text = Qt.formatTime(new Date(), "hh:mm:ss")
|
||||||
|
|
|
@ -81,7 +81,7 @@ FramelessWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
interval: 500
|
interval: 100
|
||||||
running: true
|
running: true
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: timeLabel.text = Qt.formatTime(new Date(), "hh:mm:ss")
|
onTriggered: timeLabel.text = Qt.formatTime(new Date(), "hh:mm:ss")
|
||||||
|
|
|
@ -54,7 +54,7 @@ FRAMELESSHELPER_STRING_CONSTANT(DevicePixelRatio)
|
||||||
Widget::Widget(QWidget *parent) : FramelessWidget(parent)
|
Widget::Widget(QWidget *parent) : FramelessWidget(parent)
|
||||||
{
|
{
|
||||||
initialize();
|
initialize();
|
||||||
startTimer(500);
|
startTimer(100);
|
||||||
connect(FramelessManager::instance(), &FramelessManager::systemThemeChanged, this, &Widget::updateStyleSheet);
|
connect(FramelessManager::instance(), &FramelessManager::systemThemeChanged, this, &Widget::updateStyleSheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,130 @@
|
||||||
|
|
||||||
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
||||||
|
|
||||||
|
#ifndef WM_SIZEWAIT
|
||||||
|
# define WM_SIZEWAIT (0x0004)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_SETVISIBLE
|
||||||
|
# define WM_SETVISIBLE (0x0009)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_SYSTEMERROR
|
||||||
|
# define WM_SYSTEMERROR (0x0017)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_CTLCOLOR
|
||||||
|
# define WM_CTLCOLOR (0x0019)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_LOGOFF
|
||||||
|
# define WM_LOGOFF (0x0025)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_ALTTABACTIVE
|
||||||
|
# define WM_ALTTABACTIVE (0x0029)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_SHELLNOTIFY
|
||||||
|
# define WM_SHELLNOTIFY (0x0034)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_ISACTIVEICON
|
||||||
|
# define WM_ISACTIVEICON (0x0035)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_QUERYPARKICON
|
||||||
|
# define WM_QUERYPARKICON (0x0036)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_WINHELP
|
||||||
|
# define WM_WINHELP (0x0038)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_FULLSCREEN
|
||||||
|
# define WM_FULLSCREEN (0x003A)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_CLIENTSHUTDOWN
|
||||||
|
# define WM_CLIENTSHUTDOWN (0x003B)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_DDEMLEVENT
|
||||||
|
# define WM_DDEMLEVENT (0x003C)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_TESTING
|
||||||
|
# define WM_TESTING (0x0040)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_OTHERWINDOWCREATED
|
||||||
|
# define WM_OTHERWINDOWCREATED (0x0042)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_OTHERWINDOWDESTROYED
|
||||||
|
# define WM_OTHERWINDOWDESTROYED (0x0043)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_COPYGLOBALDATA
|
||||||
|
# define WM_COPYGLOBALDATA (0x0049)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_KEYF1
|
||||||
|
# define WM_KEYF1 (0x004D)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_ACCESS_WINDOW
|
||||||
|
# define WM_ACCESS_WINDOW (0x004F)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_FINALDESTROY
|
||||||
|
# define WM_FINALDESTROY (0x0070)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_MEASUREITEM_CLIENTDATA
|
||||||
|
# define WM_MEASUREITEM_CLIENTDATA (0x0071)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_SYNCTASK
|
||||||
|
# define WM_SYNCTASK (0x0089)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_KLUDGEMINRECT
|
||||||
|
# define WM_KLUDGEMINRECT (0x008B)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_LPKDRAWSWITCHWND
|
||||||
|
# define WM_LPKDRAWSWITCHWND (0x008C)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_UAHDESTROYWINDOW
|
||||||
|
# define WM_UAHDESTROYWINDOW (0x0090)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_UAHDRAWMENU
|
||||||
|
# define WM_UAHDRAWMENU (0x0091)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_UAHDRAWMENUITEM
|
||||||
|
# define WM_UAHDRAWMENUITEM (0x0092)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_UAHINITMENU
|
||||||
|
# define WM_UAHINITMENU (0x0093)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_UAHMEASUREMENUITEM
|
||||||
|
# define WM_UAHMEASUREMENUITEM (0x0094)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_UAHNCPAINTMENUPOPUP
|
||||||
|
# define WM_UAHNCPAINTMENUPOPUP (0x0095)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_UAHUPDATE
|
||||||
|
# define WM_UAHUPDATE (0x0096)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef WM_NCUAHDRAWCAPTION
|
#ifndef WM_NCUAHDRAWCAPTION
|
||||||
# define WM_NCUAHDRAWCAPTION (0x00AE)
|
# define WM_NCUAHDRAWCAPTION (0x00AE)
|
||||||
#endif
|
#endif
|
||||||
|
@ -94,6 +218,206 @@
|
||||||
# define WM_NCUAHDRAWFRAME (0x00AF)
|
# define WM_NCUAHDRAWFRAME (0x00AF)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_YOMICHAR
|
||||||
|
# define WM_YOMICHAR (0x0108)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_CONVERTREQUEST
|
||||||
|
# define WM_CONVERTREQUEST (0x010A)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_CONVERTRESULT
|
||||||
|
# define WM_CONVERTRESULT (0x010B)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_INTERIM
|
||||||
|
# define WM_INTERIM (0x010C)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_SYSTIMER
|
||||||
|
# define WM_SYSTIMER (0x0118)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_GESTUREINPUT
|
||||||
|
# define WM_GESTUREINPUT (0x011B)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_GESTURENOTIFIED
|
||||||
|
# define WM_GESTURENOTIFIED (0x011C)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_LBTRACKPOINT
|
||||||
|
# define WM_LBTRACKPOINT (0x0131)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_DROPOBJECT
|
||||||
|
# define WM_DROPOBJECT (0x022A)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_QUERYDROPOBJECT
|
||||||
|
# define WM_QUERYDROPOBJECT (0x022B)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_BEGINDRAG
|
||||||
|
# define WM_BEGINDRAG (0x022C)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_DRAGLOOP
|
||||||
|
# define WM_DRAGLOOP (0x022D)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_DRAGSELECT
|
||||||
|
# define WM_DRAGSELECT (0x022E)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_DRAGMOVE
|
||||||
|
# define WM_DRAGMOVE (0x022F)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_STOPINERTIA
|
||||||
|
# define WM_STOPINERTIA (0x023B)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_ENDINERTIA
|
||||||
|
# define WM_ENDINERTIA (0x023C)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_EDGYINERTIA
|
||||||
|
# define WM_EDGYINERTIA (0x023D)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_VISIBILITYCHANGED
|
||||||
|
# define WM_VISIBILITYCHANGED (0x0270)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_VIEWSTATECHANGED
|
||||||
|
# define WM_VIEWSTATECHANGED (0x0271)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_UNREGISTER_WINDOW_SERVICES
|
||||||
|
# define WM_UNREGISTER_WINDOW_SERVICES (0x0272)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_CONSOLIDATED
|
||||||
|
# define WM_CONSOLIDATED (0x0273)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_IME_REPORT
|
||||||
|
# define WM_IME_REPORT (0x0280)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_IME_SYSTEM
|
||||||
|
# define WM_IME_SYSTEM (0x0287)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_POINTERDEVICEADDED
|
||||||
|
# define WM_POINTERDEVICEADDED (0x02C8)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_POINTERDEVICEDELETED
|
||||||
|
# define WM_POINTERDEVICEDELETED (0x02C9)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_FLICK
|
||||||
|
# define WM_FLICK (0x02CB)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_FLICKINTERNAL
|
||||||
|
# define WM_FLICKINTERNAL (0x02CD)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_BRIGHTNESSCHANGED
|
||||||
|
# define WM_BRIGHTNESSCHANGED (0x02CE)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_SYSMENU
|
||||||
|
# define WM_SYSMENU (0x0313)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_HOOKMSG
|
||||||
|
# define WM_HOOKMSG (0x0314)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_EXITPROCESS
|
||||||
|
# define WM_EXITPROCESS (0x0315)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_WAKETHREAD
|
||||||
|
# define WM_WAKETHREAD (0x0316)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_UAHINIT
|
||||||
|
# define WM_UAHINIT (0x031B)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_DESKTOPNOTIFY
|
||||||
|
# define WM_DESKTOPNOTIFY (0x031C)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_DWMEXILEFRAME
|
||||||
|
# define WM_DWMEXILEFRAME (0x0322)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_MAGNIFICATION_STARTED
|
||||||
|
# define WM_MAGNIFICATION_STARTED (0x0324)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_MAGNIFICATION_ENDED
|
||||||
|
# define WM_MAGNIFICATION_ENDED (0x0325)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_DWMTHUMBNAILSIZECHANGED
|
||||||
|
# define WM_DWMTHUMBNAILSIZECHANGED (0x0327)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_MAGNIFICATION_OUTPUT
|
||||||
|
# define WM_MAGNIFICATION_OUTPUT (0x0328)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_BSDRDATA
|
||||||
|
# define WM_BSDRDATA (0x0329)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_DWMTRANSITIONSTATECHANGED
|
||||||
|
# define WM_DWMTRANSITIONSTATECHANGED (0x032A)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_KEYBOARDCORRECTIONCALLOUT
|
||||||
|
# define WM_KEYBOARDCORRECTIONCALLOUT (0x032C)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_KEYBOARDCORRECTIONACTION
|
||||||
|
# define WM_KEYBOARDCORRECTIONACTION (0x032D)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_UIACTION
|
||||||
|
# define WM_UIACTION (0x032E)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_ROUTED_UI_EVENT
|
||||||
|
# define WM_ROUTED_UI_EVENT (0x032F)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_MEASURECONTROL
|
||||||
|
# define WM_MEASURECONTROL (0x0330)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_GETACTIONTEXT
|
||||||
|
# define WM_GETACTIONTEXT (0x0331)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_FORWARDKEYDOWN
|
||||||
|
# define WM_FORWARDKEYDOWN (0x0333)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_FORWARDKEYUP
|
||||||
|
# define WM_FORWARDKEYUP (0x0334)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_NOTIFYWOW
|
||||||
|
# define WM_NOTIFYWOW (0x0340)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef WM_DWMCOMPOSITIONCHANGED
|
#ifndef WM_DWMCOMPOSITIONCHANGED
|
||||||
# define WM_DWMCOMPOSITIONCHANGED (0x031E)
|
# define WM_DWMCOMPOSITIONCHANGED (0x031E)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -44,10 +44,8 @@ public:
|
||||||
Q_NODISCARD static ChromePalettePrivate *get(ChromePalette *q);
|
Q_NODISCARD static ChromePalettePrivate *get(ChromePalette *q);
|
||||||
Q_NODISCARD static const ChromePalettePrivate *get(const ChromePalette *q);
|
Q_NODISCARD static const ChromePalettePrivate *get(const ChromePalette *q);
|
||||||
|
|
||||||
public Q_SLOTS:
|
Q_SLOT void refresh();
|
||||||
void refresh();
|
|
||||||
|
|
||||||
private:
|
|
||||||
ChromePalette *q_ptr = nullptr;
|
ChromePalette *q_ptr = nullptr;
|
||||||
// System-defined ones:
|
// System-defined ones:
|
||||||
QColor titleBarActiveBackgroundColor_sys = {};
|
QColor titleBarActiveBackgroundColor_sys = {};
|
||||||
|
|
|
@ -49,39 +49,27 @@ public:
|
||||||
static void initializeIconFont();
|
static void initializeIconFont();
|
||||||
Q_NODISCARD static QFont getIconFont();
|
Q_NODISCARD static QFont getIconFont();
|
||||||
|
|
||||||
Q_NODISCARD Global::SystemTheme systemTheme() const;
|
Q_SLOT void notifySystemThemeHasChangedOrNot();
|
||||||
Q_NODISCARD QColor systemAccentColor() const;
|
Q_SLOT void notifyWallpaperHasChangedOrNot();
|
||||||
Q_NODISCARD QString wallpaper() const;
|
|
||||||
Q_NODISCARD Global::WallpaperAspectStyle wallpaperAspectStyle() const;
|
|
||||||
|
|
||||||
static void addWindow(const SystemParameters *params);
|
|
||||||
static void removeWindow(const WId windowId);
|
|
||||||
|
|
||||||
Q_INVOKABLE void notifySystemThemeHasChangedOrNot();
|
|
||||||
Q_INVOKABLE void notifyWallpaperHasChangedOrNot();
|
|
||||||
|
|
||||||
Q_NODISCARD static bool usePureQtImplementation();
|
|
||||||
|
|
||||||
void setOverrideTheme(const Global::SystemTheme theme);
|
|
||||||
Q_NODISCARD bool isThemeOverrided() const;
|
Q_NODISCARD bool isThemeOverrided() const;
|
||||||
|
|
||||||
private:
|
|
||||||
void initialize();
|
void initialize();
|
||||||
|
|
||||||
void doNotifySystemThemeHasChangedOrNot();
|
void doNotifySystemThemeHasChangedOrNot();
|
||||||
void doNotifyWallpaperHasChangedOrNot();
|
void doNotifyWallpaperHasChangedOrNot();
|
||||||
|
|
||||||
private:
|
|
||||||
FramelessManager *q_ptr = nullptr;
|
FramelessManager *q_ptr = nullptr;
|
||||||
Global::SystemTheme m_systemTheme = Global::SystemTheme::Unknown;
|
Global::SystemTheme systemTheme = Global::SystemTheme::Unknown;
|
||||||
std::optional<Global::SystemTheme> m_overrideTheme = std::nullopt;
|
std::optional<Global::SystemTheme> overrideTheme = std::nullopt;
|
||||||
QColor m_accentColor = {};
|
QColor accentColor = {};
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
Global::DwmColorizationArea m_colorizationArea = Global::DwmColorizationArea::None;
|
Global::DwmColorizationArea colorizationArea = Global::DwmColorizationArea::None;
|
||||||
#endif
|
#endif
|
||||||
QString m_wallpaper = {};
|
QString wallpaper = {};
|
||||||
Global::WallpaperAspectStyle m_wallpaperAspectStyle = Global::WallpaperAspectStyle::Fill;
|
Global::WallpaperAspectStyle wallpaperAspectStyle = Global::WallpaperAspectStyle::Fill;
|
||||||
QTimer m_themeTimer{};
|
QTimer themeTimer{};
|
||||||
QTimer m_wallpaperTimer{};
|
QTimer wallpaperTimer{};
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
|
@ -50,22 +50,18 @@ public:
|
||||||
Q_NODISCARD QSize mapToWallpaper(const QSize &size) const;
|
Q_NODISCARD QSize mapToWallpaper(const QSize &size) const;
|
||||||
Q_NODISCARD QRect mapToWallpaper(const QRect &rect) const;
|
Q_NODISCARD QRect mapToWallpaper(const QRect &rect) const;
|
||||||
|
|
||||||
public Q_SLOTS:
|
Q_SLOT void maybeGenerateBlurredWallpaper(const bool force = false);
|
||||||
void maybeGenerateBlurredWallpaper(const bool force = false);
|
Q_SLOT void updateMaterialBrush();
|
||||||
void updateMaterialBrush();
|
Q_SLOT void forceRebuildWallpaper();
|
||||||
void paint(QPainter *painter, const QRect &rect, const bool active = true);
|
|
||||||
void forceRebuildWallpaper();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void initialize();
|
void initialize();
|
||||||
void prepareGraphicsResources();
|
void prepareGraphicsResources();
|
||||||
|
|
||||||
private:
|
|
||||||
MicaMaterial *q_ptr = nullptr;
|
MicaMaterial *q_ptr = nullptr;
|
||||||
QColor tintColor = {};
|
QColor tintColor = {};
|
||||||
qreal tintOpacity = 0.0;
|
qreal tintOpacity = qreal(0);
|
||||||
QColor fallbackColor = {};
|
QColor fallbackColor = {};
|
||||||
qreal noiseOpacity = 0.0;
|
qreal noiseOpacity = qreal(0);
|
||||||
bool fallbackEnabled = true;
|
bool fallbackEnabled = true;
|
||||||
QBrush micaBrush = {};
|
QBrush micaBrush = {};
|
||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
|
|
|
@ -74,7 +74,7 @@ public:
|
||||||
Q_NODISCARD std::optional<T> value(const QString &name) const
|
Q_NODISCARD std::optional<T> value(const QString &name) const
|
||||||
{
|
{
|
||||||
const QVariant var = value(name);
|
const QVariant var = value(name);
|
||||||
if (var.isValid()) {
|
if (var.isValid() && !var.isNull()) {
|
||||||
return qvariant_cast<T>(var);
|
return qvariant_cast<T>(var);
|
||||||
}
|
}
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
|
@ -44,22 +44,11 @@ public:
|
||||||
Q_NODISCARD static WindowBorderPainterPrivate *get(WindowBorderPainter *q);
|
Q_NODISCARD static WindowBorderPainterPrivate *get(WindowBorderPainter *q);
|
||||||
Q_NODISCARD static const WindowBorderPainterPrivate *get(const WindowBorderPainter *q);
|
Q_NODISCARD static const WindowBorderPainterPrivate *get(const WindowBorderPainter *q);
|
||||||
|
|
||||||
Q_NODISCARD static int getNativeBorderThickness();
|
|
||||||
Q_NODISCARD static QColor getNativeBorderColor(const bool active);
|
|
||||||
Q_NODISCARD static Global::WindowEdges getNativeBorderEdges();
|
|
||||||
|
|
||||||
public Q_SLOTS:
|
|
||||||
void paint(QPainter *painter, const QSize &size, const bool active) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void initialize();
|
|
||||||
|
|
||||||
private:
|
|
||||||
WindowBorderPainter *q_ptr = nullptr;
|
WindowBorderPainter *q_ptr = nullptr;
|
||||||
std::optional<int> m_thickness = std::nullopt;
|
std::optional<int> thickness = std::nullopt;
|
||||||
std::optional<Global::WindowEdges> m_edges = std::nullopt;
|
std::optional<Global::WindowEdges> edges = std::nullopt;
|
||||||
std::optional<QColor> m_activeColor = std::nullopt;
|
std::optional<QColor> activeColor = std::nullopt;
|
||||||
std::optional<QColor> m_inactiveColor = std::nullopt;
|
std::optional<QColor> inactiveColor = std::nullopt;
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
|
@ -61,7 +61,7 @@ public:
|
||||||
Q_NODISCARD QColor nativeInactiveColor() const;
|
Q_NODISCARD QColor nativeInactiveColor() const;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void paint(QPainter *painter, const QSize &size, const bool active) const;
|
void paint(QPainter *painter, const QSize &size, const bool active);
|
||||||
void setThickness(const int value);
|
void setThickness(const int value);
|
||||||
void setEdges(const Global::WindowEdges value);
|
void setEdges(const Global::WindowEdges value);
|
||||||
void setActiveColor(const QColor &value);
|
void setActiveColor(const QColor &value);
|
||||||
|
|
|
@ -75,7 +75,7 @@ public:
|
||||||
Q_NODISCARD QColor defaultSystemButtonBackgroundColor() const;
|
Q_NODISCARD QColor defaultSystemButtonBackgroundColor() const;
|
||||||
Q_NODISCARD QColor defaultSystemCloseButtonBackgroundColor() const;
|
Q_NODISCARD QColor defaultSystemCloseButtonBackgroundColor() const;
|
||||||
|
|
||||||
Q_NODISCARD Q_INVOKABLE QColor getSystemButtonBackgroundColor(
|
Q_NODISCARD Q_SLOT QColor getSystemButtonBackgroundColor(
|
||||||
const QuickGlobal::SystemButtonType button, const QuickGlobal::ButtonState state);
|
const QuickGlobal::SystemButtonType button, const QuickGlobal::ButtonState state);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -47,25 +47,9 @@ public:
|
||||||
Q_NODISCARD static FramelessQuickApplicationWindowPrivate *get(FramelessQuickApplicationWindow *pub);
|
Q_NODISCARD static FramelessQuickApplicationWindowPrivate *get(FramelessQuickApplicationWindow *pub);
|
||||||
Q_NODISCARD static const FramelessQuickApplicationWindowPrivate *get(const FramelessQuickApplicationWindow *pub);
|
Q_NODISCARD static const FramelessQuickApplicationWindowPrivate *get(const FramelessQuickApplicationWindow *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;
|
|
||||||
|
|
||||||
public Q_SLOTS:
|
|
||||||
void showMinimized2();
|
|
||||||
void toggleMaximized();
|
|
||||||
void toggleFullScreen();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void initialize();
|
|
||||||
|
|
||||||
private:
|
|
||||||
FramelessQuickApplicationWindow *q_ptr = nullptr;
|
FramelessQuickApplicationWindow *q_ptr = nullptr;
|
||||||
QuickWindowBorder *m_windowBorder = nullptr;
|
QuickWindowBorder *windowBorder = nullptr;
|
||||||
QQuickWindow::Visibility m_savedVisibility = QQuickWindow::Windowed;
|
QQuickWindow::Visibility savedVisibility = QQuickWindow::Windowed;
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
|
@ -51,33 +51,11 @@ public:
|
||||||
Q_NODISCARD static FramelessQuickHelperPrivate *get(FramelessQuickHelper *pub);
|
Q_NODISCARD static FramelessQuickHelperPrivate *get(FramelessQuickHelper *pub);
|
||||||
Q_NODISCARD static const FramelessQuickHelperPrivate *get(const FramelessQuickHelper *pub);
|
Q_NODISCARD static const FramelessQuickHelperPrivate *get(const FramelessQuickHelper *pub);
|
||||||
|
|
||||||
Q_NODISCARD bool isContentExtendedIntoTitleBar() const;
|
|
||||||
void extendsContentIntoTitleBar(const bool value);
|
|
||||||
|
|
||||||
Q_NODISCARD QQuickItem *getTitleBarItem() const;
|
|
||||||
void setTitleBarItem(QQuickItem *value);
|
|
||||||
|
|
||||||
void attach();
|
void attach();
|
||||||
void detach();
|
void detach();
|
||||||
void setSystemButton(QQuickItem *item, const QuickGlobal::SystemButtonType buttonType);
|
|
||||||
void setHitTestVisible(QQuickItem *item, const bool visible = true);
|
|
||||||
void setHitTestVisible(const QRect &rect, const bool visible = true);
|
|
||||||
void setHitTestVisible(QObject *object, const bool visible = true);
|
|
||||||
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);
|
|
||||||
|
|
||||||
void emitSignalForAllInstances(const char *signal);
|
void emitSignalForAllInstances(const char *signal);
|
||||||
|
|
||||||
Q_NODISCARD bool isBlurBehindWindowEnabled() const;
|
|
||||||
void setBlurBehindWindowEnabled(const bool value, const QColor &color);
|
|
||||||
|
|
||||||
void setProperty(const char *name, const QVariant &value);
|
void setProperty(const char *name, const QVariant &value);
|
||||||
Q_NODISCARD QVariant getProperty(const char *name, const QVariant &defaultValue = {});
|
Q_NODISCARD QVariant getProperty(const char *name, const QVariant &defaultValue = {});
|
||||||
|
|
||||||
|
@ -86,15 +64,11 @@ public:
|
||||||
|
|
||||||
Q_NODISCARD static FramelessQuickHelper *findOrCreateFramelessHelper(QObject *object);
|
Q_NODISCARD static FramelessQuickHelper *findOrCreateFramelessHelper(QObject *object);
|
||||||
|
|
||||||
Q_NODISCARD bool isReady() const;
|
|
||||||
void waitForReady();
|
|
||||||
|
|
||||||
void repaintAllChildren(const quint32 delay = 0) const;
|
void repaintAllChildren(const quint32 delay = 0) const;
|
||||||
|
|
||||||
Q_NODISCARD quint32 readyWaitTime() const;
|
Q_NODISCARD quint32 readyWaitTime() const;
|
||||||
void setReadyWaitTime(const quint32 time);
|
void setReadyWaitTime(const quint32 time);
|
||||||
|
|
||||||
private:
|
|
||||||
Q_NODISCARD QRect mapItemGeometryToScene(const QQuickItem * const item) const;
|
Q_NODISCARD QRect mapItemGeometryToScene(const QQuickItem * const item) const;
|
||||||
Q_NODISCARD bool isInSystemButtons(const QPoint &pos, QuickGlobal::SystemButtonType *button) const;
|
Q_NODISCARD bool isInSystemButtons(const QPoint &pos, QuickGlobal::SystemButtonType *button) const;
|
||||||
Q_NODISCARD bool isInTitleBarDraggableArea(const QPoint &pos) const;
|
Q_NODISCARD bool isInTitleBarDraggableArea(const QPoint &pos) const;
|
||||||
|
@ -104,14 +78,12 @@ private:
|
||||||
Q_NODISCARD FramelessQuickHelperData *getWindowDataMutable() const;
|
Q_NODISCARD FramelessQuickHelperData *getWindowDataMutable() const;
|
||||||
void rebindWindow();
|
void rebindWindow();
|
||||||
|
|
||||||
private:
|
|
||||||
FramelessQuickHelper *q_ptr = nullptr;
|
FramelessQuickHelper *q_ptr = nullptr;
|
||||||
QColor m_savedWindowBackgroundColor = {};
|
QColor savedWindowBackgroundColor = {};
|
||||||
bool m_blurBehindWindowEnabled = false;
|
bool blurBehindWindowEnabled = false;
|
||||||
std::optional<bool> m_extendIntoTitleBar = std::nullopt;
|
std::optional<bool> extendIntoTitleBar = std::nullopt;
|
||||||
bool m_destroying = false;
|
bool qpaReady = false;
|
||||||
bool m_qpaReady = false;
|
quint32 qpaWaitTime = 0;
|
||||||
quint32 m_qpaWaitTime = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
|
@ -47,25 +47,9 @@ public:
|
||||||
Q_NODISCARD static FramelessQuickWindowPrivate *get(FramelessQuickWindow *pub);
|
Q_NODISCARD static FramelessQuickWindowPrivate *get(FramelessQuickWindow *pub);
|
||||||
Q_NODISCARD static const FramelessQuickWindowPrivate *get(const 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;
|
|
||||||
|
|
||||||
public Q_SLOTS:
|
|
||||||
void showMinimized2();
|
|
||||||
void toggleMaximized();
|
|
||||||
void toggleFullScreen();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void initialize();
|
|
||||||
|
|
||||||
private:
|
|
||||||
FramelessQuickWindow *q_ptr = nullptr;
|
FramelessQuickWindow *q_ptr = nullptr;
|
||||||
QuickWindowBorder *m_windowBorder = nullptr;
|
QuickWindowBorder *windowBorder = nullptr;
|
||||||
QQuickWindow::Visibility m_savedVisibility = QQuickWindow::Windowed;
|
QQuickWindow::Visibility savedVisibility = QQuickWindow::Windowed;
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
|
@ -44,13 +44,6 @@ public:
|
||||||
Q_NODISCARD static QuickImageItemPrivate *get(QuickImageItem *q);
|
Q_NODISCARD static QuickImageItemPrivate *get(QuickImageItem *q);
|
||||||
Q_NODISCARD static const QuickImageItemPrivate *get(const QuickImageItem *q);
|
Q_NODISCARD static const QuickImageItemPrivate *get(const QuickImageItem *q);
|
||||||
|
|
||||||
void paint(QPainter *painter) const;
|
|
||||||
|
|
||||||
Q_NODISCARD QVariant source() const;
|
|
||||||
void setSource(const QVariant &value);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void initialize();
|
|
||||||
void fromUrl(const QUrl &value, QPainter *painter) const;
|
void fromUrl(const QUrl &value, QPainter *painter) const;
|
||||||
void fromString(const QString &value, QPainter *painter) const;
|
void fromString(const QString &value, QPainter *painter) const;
|
||||||
void fromImage(const QImage &value, QPainter *painter) const;
|
void fromImage(const QImage &value, QPainter *painter) const;
|
||||||
|
@ -58,9 +51,8 @@ private:
|
||||||
void fromIcon(const QIcon &value, QPainter *painter) const;
|
void fromIcon(const QIcon &value, QPainter *painter) const;
|
||||||
Q_NODISCARD QRectF paintArea() const;
|
Q_NODISCARD QRectF paintArea() const;
|
||||||
|
|
||||||
private:
|
|
||||||
QuickImageItem *q_ptr = nullptr;
|
QuickImageItem *q_ptr = nullptr;
|
||||||
QVariant m_source = {};
|
QVariant source = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
|
@ -44,19 +44,15 @@ public:
|
||||||
Q_NODISCARD static QuickMicaMaterialPrivate *get(QuickMicaMaterial *q);
|
Q_NODISCARD static QuickMicaMaterialPrivate *get(QuickMicaMaterial *q);
|
||||||
Q_NODISCARD static const QuickMicaMaterialPrivate *get(const QuickMicaMaterial *q);
|
Q_NODISCARD static const QuickMicaMaterialPrivate *get(const QuickMicaMaterial *q);
|
||||||
|
|
||||||
public Q_SLOTS:
|
Q_SLOT void rebindWindow();
|
||||||
void rebindWindow();
|
|
||||||
void repaint(QPainter *painter);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void initialize();
|
void initialize();
|
||||||
|
|
||||||
private:
|
|
||||||
QuickMicaMaterial *q_ptr = nullptr;
|
QuickMicaMaterial *q_ptr = nullptr;
|
||||||
QMetaObject::Connection m_rootWindowXChangedConnection = {};
|
QMetaObject::Connection rootWindowXChangedConnection = {};
|
||||||
QMetaObject::Connection m_rootWindowYChangedConnection = {};
|
QMetaObject::Connection rootWindowYChangedConnection = {};
|
||||||
QMetaObject::Connection m_rootWindowActiveChangedConnection = {};
|
QMetaObject::Connection rootWindowActiveChangedConnection = {};
|
||||||
MicaMaterial *m_micaMaterial = nullptr;
|
MicaMaterial *micaMaterial = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
|
@ -44,20 +44,15 @@ public:
|
||||||
Q_NODISCARD static QuickWindowBorderPrivate *get(QuickWindowBorder *q);
|
Q_NODISCARD static QuickWindowBorderPrivate *get(QuickWindowBorder *q);
|
||||||
Q_NODISCARD static const QuickWindowBorderPrivate *get(const QuickWindowBorder *q);
|
Q_NODISCARD static const QuickWindowBorderPrivate *get(const QuickWindowBorder *q);
|
||||||
|
|
||||||
void paint(QPainter *painter) const;
|
Q_SLOT void update();
|
||||||
|
|
||||||
public Q_SLOTS:
|
|
||||||
void update();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void initialize();
|
void initialize();
|
||||||
void rebindWindow();
|
void rebindWindow();
|
||||||
|
|
||||||
private:
|
|
||||||
QuickWindowBorder *q_ptr = nullptr;
|
QuickWindowBorder *q_ptr = nullptr;
|
||||||
WindowBorderPainter *m_borderPainter = nullptr;
|
WindowBorderPainter *borderPainter = nullptr;
|
||||||
QMetaObject::Connection m_activeChangeConnection = {};
|
QMetaObject::Connection activeChangeConnection = {};
|
||||||
QMetaObject::Connection m_visibilityChangeConnection = {};
|
QMetaObject::Connection visibilityChangeConnection = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
|
@ -84,6 +84,18 @@ static constexpr const int kEventDelayInterval = 1000;
|
||||||
}
|
}
|
||||||
#endif // FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
#endif // FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
||||||
|
|
||||||
|
[[nodiscard]] static inline bool usePureQtImplementation()
|
||||||
|
{
|
||||||
|
static const auto result = []() -> bool {
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
|
return FramelessConfig::instance()->isSet(Option::UseCrossPlatformQtImplementation);
|
||||||
|
#else
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
FramelessManagerPrivate::FramelessManagerPrivate(FramelessManager *q) : QObject(q)
|
FramelessManagerPrivate::FramelessManagerPrivate(FramelessManager *q) : QObject(q)
|
||||||
{
|
{
|
||||||
Q_ASSERT(q);
|
Q_ASSERT(q);
|
||||||
|
@ -152,85 +164,14 @@ QFont FramelessManagerPrivate::getIconFont()
|
||||||
#endif // FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
#endif // FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemTheme FramelessManagerPrivate::systemTheme() const
|
|
||||||
{
|
|
||||||
// The user's choice has top priority.
|
|
||||||
if (isThemeOverrided()) {
|
|
||||||
return m_overrideTheme.value();
|
|
||||||
}
|
|
||||||
return m_systemTheme;
|
|
||||||
}
|
|
||||||
|
|
||||||
QColor FramelessManagerPrivate::systemAccentColor() const
|
|
||||||
{
|
|
||||||
return m_accentColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString FramelessManagerPrivate::wallpaper() const
|
|
||||||
{
|
|
||||||
return m_wallpaper;
|
|
||||||
}
|
|
||||||
|
|
||||||
WallpaperAspectStyle FramelessManagerPrivate::wallpaperAspectStyle() const
|
|
||||||
{
|
|
||||||
return m_wallpaperAspectStyle;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessManagerPrivate::addWindow(FramelessParamsConst params)
|
|
||||||
{
|
|
||||||
Q_ASSERT(params);
|
|
||||||
if (!params) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const WId windowId = params->getWindowId();
|
|
||||||
if (g_framelessManagerData()->contains(windowId)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
g_framelessManagerData()->append(windowId);
|
|
||||||
static const bool pureQt = usePureQtImplementation();
|
|
||||||
if (pureQt) {
|
|
||||||
FramelessHelperQt::addWindow(params);
|
|
||||||
}
|
|
||||||
#ifdef Q_OS_WINDOWS
|
|
||||||
if (!pureQt) {
|
|
||||||
FramelessHelperWin::addWindow(params);
|
|
||||||
}
|
|
||||||
std::ignore = Utils::installWindowProcHook(windowId, params);
|
|
||||||
#endif
|
|
||||||
connect(params->getWindowHandle(), &QWindow::destroyed, FramelessManager::instance(), [windowId](){ removeWindow(windowId); });
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessManagerPrivate::removeWindow(const WId windowId)
|
|
||||||
{
|
|
||||||
Q_ASSERT(windowId);
|
|
||||||
if (!windowId) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!g_framelessManagerData()->contains(windowId)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
g_framelessManagerData()->removeAll(windowId);
|
|
||||||
static const bool pureQt = usePureQtImplementation();
|
|
||||||
if (pureQt) {
|
|
||||||
FramelessHelperQt::removeWindow(windowId);
|
|
||||||
}
|
|
||||||
#ifdef Q_OS_WINDOWS
|
|
||||||
if (!pureQt) {
|
|
||||||
FramelessHelperWin::removeWindow(windowId);
|
|
||||||
}
|
|
||||||
std::ignore = Utils::uninstallWindowProcHook(windowId);
|
|
||||||
std::ignore = Utils::removeMicaWindow(windowId);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessManagerPrivate::notifySystemThemeHasChangedOrNot()
|
void FramelessManagerPrivate::notifySystemThemeHasChangedOrNot()
|
||||||
{
|
{
|
||||||
m_themeTimer.start();
|
themeTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessManagerPrivate::notifyWallpaperHasChangedOrNot()
|
void FramelessManagerPrivate::notifyWallpaperHasChangedOrNot()
|
||||||
{
|
{
|
||||||
m_wallpaperTimer.start();
|
wallpaperTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessManagerPrivate::doNotifySystemThemeHasChangedOrNot()
|
void FramelessManagerPrivate::doNotifySystemThemeHasChangedOrNot()
|
||||||
|
@ -241,17 +182,17 @@ void FramelessManagerPrivate::doNotifySystemThemeHasChangedOrNot()
|
||||||
const DwmColorizationArea currentColorizationArea = Utils::getDwmColorizationArea();
|
const DwmColorizationArea currentColorizationArea = Utils::getDwmColorizationArea();
|
||||||
#endif
|
#endif
|
||||||
bool notify = false;
|
bool notify = false;
|
||||||
if (m_systemTheme != currentSystemTheme) {
|
if (systemTheme != currentSystemTheme) {
|
||||||
m_systemTheme = currentSystemTheme;
|
systemTheme = currentSystemTheme;
|
||||||
notify = true;
|
notify = true;
|
||||||
}
|
}
|
||||||
if (m_accentColor != currentAccentColor) {
|
if (accentColor != currentAccentColor) {
|
||||||
m_accentColor = currentAccentColor;
|
accentColor = currentAccentColor;
|
||||||
notify = true;
|
notify = true;
|
||||||
}
|
}
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
if (m_colorizationArea != currentColorizationArea) {
|
if (colorizationArea != currentColorizationArea) {
|
||||||
m_colorizationArea = currentColorizationArea;
|
colorizationArea = currentColorizationArea;
|
||||||
notify = true;
|
notify = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -259,10 +200,10 @@ void FramelessManagerPrivate::doNotifySystemThemeHasChangedOrNot()
|
||||||
if (notify && !isThemeOverrided()) {
|
if (notify && !isThemeOverrided()) {
|
||||||
Q_Q(FramelessManager);
|
Q_Q(FramelessManager);
|
||||||
Q_EMIT q->systemThemeChanged();
|
Q_EMIT q->systemThemeChanged();
|
||||||
DEBUG.nospace() << "System theme changed. Current theme: " << m_systemTheme
|
DEBUG.nospace() << "System theme changed. Current theme: " << systemTheme
|
||||||
<< ", accent color: " << m_accentColor.name(QColor::HexArgb).toUpper()
|
<< ", accent color: " << accentColor.name(QColor::HexArgb).toUpper()
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
<< ", colorization area: " << m_colorizationArea
|
<< ", colorization area: " << colorizationArea
|
||||||
#endif
|
#endif
|
||||||
<< '.';
|
<< '.';
|
||||||
}
|
}
|
||||||
|
@ -273,80 +214,53 @@ void FramelessManagerPrivate::doNotifyWallpaperHasChangedOrNot()
|
||||||
const QString currentWallpaper = Utils::getWallpaperFilePath();
|
const QString currentWallpaper = Utils::getWallpaperFilePath();
|
||||||
const WallpaperAspectStyle currentWallpaperAspectStyle = Utils::getWallpaperAspectStyle();
|
const WallpaperAspectStyle currentWallpaperAspectStyle = Utils::getWallpaperAspectStyle();
|
||||||
bool notify = false;
|
bool notify = false;
|
||||||
if (m_wallpaper != currentWallpaper) {
|
if (wallpaper != currentWallpaper) {
|
||||||
m_wallpaper = currentWallpaper;
|
wallpaper = currentWallpaper;
|
||||||
notify = true;
|
notify = true;
|
||||||
}
|
}
|
||||||
if (m_wallpaperAspectStyle != currentWallpaperAspectStyle) {
|
if (wallpaperAspectStyle != currentWallpaperAspectStyle) {
|
||||||
m_wallpaperAspectStyle = currentWallpaperAspectStyle;
|
wallpaperAspectStyle = currentWallpaperAspectStyle;
|
||||||
notify = true;
|
notify = true;
|
||||||
}
|
}
|
||||||
if (notify) {
|
if (notify) {
|
||||||
Q_Q(FramelessManager);
|
Q_Q(FramelessManager);
|
||||||
Q_EMIT q->wallpaperChanged();
|
Q_EMIT q->wallpaperChanged();
|
||||||
DEBUG.nospace() << "Wallpaper changed. Current wallpaper: " << m_wallpaper
|
DEBUG.nospace() << "Wallpaper changed. Current wallpaper: " << wallpaper
|
||||||
<< ", aspect style: " << m_wallpaperAspectStyle << '.';
|
<< ", aspect style: " << wallpaperAspectStyle << '.';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FramelessManagerPrivate::usePureQtImplementation()
|
|
||||||
{
|
|
||||||
static const auto result = []() -> bool {
|
|
||||||
#ifdef Q_OS_WINDOWS
|
|
||||||
return FramelessConfig::instance()->isSet(Option::UseCrossPlatformQtImplementation);
|
|
||||||
#else
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessManagerPrivate::setOverrideTheme(const SystemTheme theme)
|
|
||||||
{
|
|
||||||
if ((!m_overrideTheme.has_value() && (theme == SystemTheme::Unknown))
|
|
||||||
|| (m_overrideTheme.has_value() && (m_overrideTheme.value() == theme))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (theme == SystemTheme::Unknown) {
|
|
||||||
m_overrideTheme = std::nullopt;
|
|
||||||
} else {
|
|
||||||
m_overrideTheme = theme;
|
|
||||||
}
|
|
||||||
Q_Q(FramelessManager);
|
|
||||||
Q_EMIT q->systemThemeChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FramelessManagerPrivate::isThemeOverrided() const
|
bool FramelessManagerPrivate::isThemeOverrided() const
|
||||||
{
|
{
|
||||||
return (m_overrideTheme.value_or(SystemTheme::Unknown) != SystemTheme::Unknown);
|
return (overrideTheme.value_or(SystemTheme::Unknown) != SystemTheme::Unknown);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessManagerPrivate::initialize()
|
void FramelessManagerPrivate::initialize()
|
||||||
{
|
{
|
||||||
m_themeTimer.setInterval(kEventDelayInterval);
|
themeTimer.setInterval(kEventDelayInterval);
|
||||||
m_themeTimer.callOnTimeout(this, [this](){
|
themeTimer.callOnTimeout(this, [this](){
|
||||||
m_themeTimer.stop();
|
themeTimer.stop();
|
||||||
doNotifySystemThemeHasChangedOrNot();
|
doNotifySystemThemeHasChangedOrNot();
|
||||||
});
|
});
|
||||||
m_wallpaperTimer.setInterval(kEventDelayInterval);
|
wallpaperTimer.setInterval(kEventDelayInterval);
|
||||||
m_wallpaperTimer.callOnTimeout(this, [this](){
|
wallpaperTimer.callOnTimeout(this, [this](){
|
||||||
m_wallpaperTimer.stop();
|
wallpaperTimer.stop();
|
||||||
doNotifyWallpaperHasChangedOrNot();
|
doNotifyWallpaperHasChangedOrNot();
|
||||||
});
|
});
|
||||||
m_systemTheme = (Utils::shouldAppsUseDarkMode() ? SystemTheme::Dark : SystemTheme::Light);
|
systemTheme = (Utils::shouldAppsUseDarkMode() ? SystemTheme::Dark : SystemTheme::Light);
|
||||||
m_accentColor = Utils::getAccentColor();
|
accentColor = Utils::getAccentColor();
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
m_colorizationArea = Utils::getDwmColorizationArea();
|
colorizationArea = Utils::getDwmColorizationArea();
|
||||||
#endif
|
#endif
|
||||||
m_wallpaper = Utils::getWallpaperFilePath();
|
wallpaper = Utils::getWallpaperFilePath();
|
||||||
m_wallpaperAspectStyle = Utils::getWallpaperAspectStyle();
|
wallpaperAspectStyle = Utils::getWallpaperAspectStyle();
|
||||||
DEBUG.nospace() << "Current system theme: " << m_systemTheme
|
DEBUG.nospace() << "Current system theme: " << systemTheme
|
||||||
<< ", accent color: " << m_accentColor.name(QColor::HexArgb).toUpper()
|
<< ", accent color: " << accentColor.name(QColor::HexArgb).toUpper()
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
<< ", colorization area: " << m_colorizationArea
|
<< ", colorization area: " << colorizationArea
|
||||||
#endif
|
#endif
|
||||||
<< ", wallpaper: " << m_wallpaper
|
<< ", wallpaper: " << wallpaper
|
||||||
<< ", aspect style: " << m_wallpaperAspectStyle
|
<< ", aspect style: " << wallpaperAspectStyle
|
||||||
<< '.';
|
<< '.';
|
||||||
// We are doing some tricks in our Windows message handling code, so
|
// We are doing some tricks in our Windows message handling code, so
|
||||||
// we don't use Qt's theme notifier on Windows. But for other platforms
|
// we don't use Qt's theme notifier on Windows. But for other platforms
|
||||||
|
@ -389,43 +303,91 @@ FramelessManager *FramelessManager::instance()
|
||||||
SystemTheme FramelessManager::systemTheme() const
|
SystemTheme FramelessManager::systemTheme() const
|
||||||
{
|
{
|
||||||
Q_D(const FramelessManager);
|
Q_D(const FramelessManager);
|
||||||
return d->systemTheme();
|
// The user's choice has top priority.
|
||||||
|
if (d->isThemeOverrided()) {
|
||||||
|
return d->overrideTheme.value();
|
||||||
|
}
|
||||||
|
return d->systemTheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor FramelessManager::systemAccentColor() const
|
QColor FramelessManager::systemAccentColor() const
|
||||||
{
|
{
|
||||||
Q_D(const FramelessManager);
|
Q_D(const FramelessManager);
|
||||||
return d->systemAccentColor();
|
return d->accentColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FramelessManager::wallpaper() const
|
QString FramelessManager::wallpaper() const
|
||||||
{
|
{
|
||||||
Q_D(const FramelessManager);
|
Q_D(const FramelessManager);
|
||||||
return d->wallpaper();
|
return d->wallpaper;
|
||||||
}
|
}
|
||||||
|
|
||||||
WallpaperAspectStyle FramelessManager::wallpaperAspectStyle() const
|
WallpaperAspectStyle FramelessManager::wallpaperAspectStyle() const
|
||||||
{
|
{
|
||||||
Q_D(const FramelessManager);
|
Q_D(const FramelessManager);
|
||||||
return d->wallpaperAspectStyle();
|
return d->wallpaperAspectStyle;
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessManager::addWindow(FramelessParamsConst params)
|
|
||||||
{
|
|
||||||
Q_D(FramelessManager);
|
|
||||||
d->addWindow(params);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessManager::removeWindow(const WId windowId)
|
|
||||||
{
|
|
||||||
Q_D(FramelessManager);
|
|
||||||
d->removeWindow(windowId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessManager::setOverrideTheme(const SystemTheme theme)
|
void FramelessManager::setOverrideTheme(const SystemTheme theme)
|
||||||
{
|
{
|
||||||
Q_D(FramelessManager);
|
Q_D(FramelessManager);
|
||||||
d->setOverrideTheme(theme);
|
if ((!d->overrideTheme.has_value() && (theme == SystemTheme::Unknown))
|
||||||
|
|| (d->overrideTheme.has_value() && (d->overrideTheme.value() == theme))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (theme == SystemTheme::Unknown) {
|
||||||
|
d->overrideTheme = std::nullopt;
|
||||||
|
} else {
|
||||||
|
d->overrideTheme = theme;
|
||||||
|
}
|
||||||
|
Q_EMIT systemThemeChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FramelessManager::addWindow(FramelessParamsConst params)
|
||||||
|
{
|
||||||
|
Q_ASSERT(params);
|
||||||
|
if (!params) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const WId windowId = params->getWindowId();
|
||||||
|
if (g_framelessManagerData()->contains(windowId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
g_framelessManagerData()->append(windowId);
|
||||||
|
static const bool pureQt = usePureQtImplementation();
|
||||||
|
if (pureQt) {
|
||||||
|
FramelessHelperQt::addWindow(params);
|
||||||
|
}
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
|
if (!pureQt) {
|
||||||
|
FramelessHelperWin::addWindow(params);
|
||||||
|
}
|
||||||
|
std::ignore = Utils::installWindowProcHook(windowId, params);
|
||||||
|
#endif
|
||||||
|
connect(params->getWindowHandle(), &QWindow::destroyed, FramelessManager::instance(), [this, windowId](){ removeWindow(windowId); });
|
||||||
|
}
|
||||||
|
|
||||||
|
void FramelessManager::removeWindow(const WId windowId)
|
||||||
|
{
|
||||||
|
Q_ASSERT(windowId);
|
||||||
|
if (!windowId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!g_framelessManagerData()->contains(windowId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
g_framelessManagerData()->removeAll(windowId);
|
||||||
|
static const bool pureQt = usePureQtImplementation();
|
||||||
|
if (pureQt) {
|
||||||
|
FramelessHelperQt::removeWindow(windowId);
|
||||||
|
}
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
|
if (!pureQt) {
|
||||||
|
FramelessHelperWin::removeWindow(windowId);
|
||||||
|
}
|
||||||
|
std::ignore = Utils::uninstallWindowProcHook(windowId);
|
||||||
|
std::ignore = Utils::removeMicaWindow(windowId);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
|
@ -680,70 +680,6 @@ void MicaMaterialPrivate::updateMaterialBrush()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MicaMaterialPrivate::paint(QPainter *painter, const QRect &rect, const bool active)
|
|
||||||
{
|
|
||||||
Q_ASSERT(painter);
|
|
||||||
if (!painter) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
prepareGraphicsResources();
|
|
||||||
static constexpr const QPoint originPoint = {0, 0};
|
|
||||||
const QRect wallpaperRect = { originPoint, wallpaperSize };
|
|
||||||
const QRect mappedRect = mapToWallpaper(rect);
|
|
||||||
painter->save();
|
|
||||||
// Same as above. Speed is more important here.
|
|
||||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
|
||||||
painter->setRenderHint(QPainter::TextAntialiasing, false);
|
|
||||||
painter->setRenderHint(QPainter::SmoothPixmapTransform, false);
|
|
||||||
if (active) {
|
|
||||||
const QRect intersectedRect = wallpaperRect.intersected(mappedRect);
|
|
||||||
g_imageData()->mutex.lock();
|
|
||||||
painter->drawPixmap(originPoint, g_imageData()->blurredWallpaper, intersectedRect);
|
|
||||||
g_imageData()->mutex.unlock();
|
|
||||||
if (intersectedRect != mappedRect) {
|
|
||||||
static constexpr const auto xOffset = QPoint{ 1, 0 };
|
|
||||||
if (mappedRect.y() + mappedRect.height() <= wallpaperRect.height()) {
|
|
||||||
const QRect outerRect = { intersectedRect.topRight() + xOffset, QSize{ mappedRect.width() - intersectedRect.width(), intersectedRect.height() } };
|
|
||||||
const QPoint outerRectOriginPoint = originPoint + QPoint{ intersectedRect.width(), 0 } + xOffset;
|
|
||||||
const QRect mappedOuterRect = mapToWallpaper(outerRect);
|
|
||||||
const QMutexLocker locker(&g_imageData()->mutex);
|
|
||||||
painter->drawPixmap(outerRectOriginPoint, g_imageData()->blurredWallpaper, mappedOuterRect);
|
|
||||||
} else {
|
|
||||||
static constexpr const auto yOffset = QPoint{ 0, 1 };
|
|
||||||
const QRect outerRectBottom = { intersectedRect.bottomLeft() + yOffset, QSize{ intersectedRect.width(), mappedRect.height() - intersectedRect.height() } };
|
|
||||||
const QPoint outerRectBottomOriginPoint = originPoint + QPoint{ 0, intersectedRect.height() } + yOffset;
|
|
||||||
const QRect mappedOuterRectBottom = mapToWallpaper(outerRectBottom);
|
|
||||||
g_imageData()->mutex.lock();
|
|
||||||
painter->drawPixmap(outerRectBottomOriginPoint, g_imageData()->blurredWallpaper, mappedOuterRectBottom);
|
|
||||||
g_imageData()->mutex.unlock();
|
|
||||||
if (mappedRect.x() + mappedRect.width() > wallpaperRect.width()) {
|
|
||||||
const QRect outerRectRight = { intersectedRect.topRight() + xOffset, QSize{ mappedRect.width() - intersectedRect.width(), intersectedRect.height() } };
|
|
||||||
const QPoint outerRectRightOriginPoint = originPoint + QPoint{ intersectedRect.width(), 0 } + xOffset;
|
|
||||||
const QRect mappedOuterRectRight = mapToWallpaper(outerRectRight);
|
|
||||||
const QRect outerRectCorner = { intersectedRect.bottomRight() + xOffset + yOffset, QSize{ outerRectRight.width(), outerRectBottom.height() } };
|
|
||||||
const QPoint outerRectCornerOriginPoint = originPoint + QPoint{ intersectedRect.width(), intersectedRect.height() } + xOffset + yOffset;
|
|
||||||
const QRect mappedOuterRectCorner = mapToWallpaper(outerRectCorner);
|
|
||||||
const QMutexLocker locker(&g_imageData()->mutex);
|
|
||||||
painter->drawPixmap(outerRectRightOriginPoint, g_imageData()->blurredWallpaper, mappedOuterRectRight);
|
|
||||||
painter->drawPixmap(outerRectCornerOriginPoint, g_imageData()->blurredWallpaper, mappedOuterRectCorner);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
|
|
||||||
painter->setOpacity(qreal(1));
|
|
||||||
painter->fillRect(QRect{originPoint, mappedRect.size()}, [this, active]() -> QBrush {
|
|
||||||
if (!fallbackEnabled || active) {
|
|
||||||
return micaBrush;
|
|
||||||
}
|
|
||||||
if (fallbackColor.isValid()) {
|
|
||||||
return fallbackColor;
|
|
||||||
}
|
|
||||||
return systemFallbackColor();
|
|
||||||
}());
|
|
||||||
painter->restore();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MicaMaterialPrivate::forceRebuildWallpaper()
|
void MicaMaterialPrivate::forceRebuildWallpaper()
|
||||||
{
|
{
|
||||||
wallpaperSize = QGuiApplication::primaryScreen()->size();
|
wallpaperSize = QGuiApplication::primaryScreen()->size();
|
||||||
|
@ -962,8 +898,67 @@ void MicaMaterial::setFallbackEnabled(const bool value)
|
||||||
|
|
||||||
void MicaMaterial::paint(QPainter *painter, const QRect &rect, const bool active)
|
void MicaMaterial::paint(QPainter *painter, const QRect &rect, const bool active)
|
||||||
{
|
{
|
||||||
|
Q_ASSERT(painter);
|
||||||
|
if (!painter) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Q_D(MicaMaterial);
|
Q_D(MicaMaterial);
|
||||||
d->paint(painter, rect, active);
|
d->prepareGraphicsResources();
|
||||||
|
static constexpr const auto originPoint = QPoint{ 0, 0 };
|
||||||
|
const QRect wallpaperRect = { originPoint, d->wallpaperSize };
|
||||||
|
const QRect mappedRect = d->mapToWallpaper(rect);
|
||||||
|
painter->save();
|
||||||
|
// Same as above. Speed is more important here.
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||||
|
painter->setRenderHint(QPainter::TextAntialiasing, false);
|
||||||
|
painter->setRenderHint(QPainter::SmoothPixmapTransform, false);
|
||||||
|
if (active) {
|
||||||
|
const QRect intersectedRect = wallpaperRect.intersected(mappedRect);
|
||||||
|
g_imageData()->mutex.lock();
|
||||||
|
painter->drawPixmap(originPoint, g_imageData()->blurredWallpaper, intersectedRect);
|
||||||
|
g_imageData()->mutex.unlock();
|
||||||
|
if (intersectedRect != mappedRect) {
|
||||||
|
static constexpr const auto xOffset = QPoint{ 1, 0 };
|
||||||
|
if (mappedRect.y() + mappedRect.height() <= wallpaperRect.height()) {
|
||||||
|
const QRect outerRect = { intersectedRect.topRight() + xOffset, QSize{ mappedRect.width() - intersectedRect.width(), intersectedRect.height() } };
|
||||||
|
const QPoint outerRectOriginPoint = originPoint + QPoint{ intersectedRect.width(), 0 } + xOffset;
|
||||||
|
const QRect mappedOuterRect = d->mapToWallpaper(outerRect);
|
||||||
|
const QMutexLocker locker(&g_imageData()->mutex);
|
||||||
|
painter->drawPixmap(outerRectOriginPoint, g_imageData()->blurredWallpaper, mappedOuterRect);
|
||||||
|
} else {
|
||||||
|
static constexpr const auto yOffset = QPoint{ 0, 1 };
|
||||||
|
const QRect outerRectBottom = { intersectedRect.bottomLeft() + yOffset, QSize{ intersectedRect.width(), mappedRect.height() - intersectedRect.height() } };
|
||||||
|
const QPoint outerRectBottomOriginPoint = originPoint + QPoint{ 0, intersectedRect.height() } + yOffset;
|
||||||
|
const QRect mappedOuterRectBottom = d->mapToWallpaper(outerRectBottom);
|
||||||
|
g_imageData()->mutex.lock();
|
||||||
|
painter->drawPixmap(outerRectBottomOriginPoint, g_imageData()->blurredWallpaper, mappedOuterRectBottom);
|
||||||
|
g_imageData()->mutex.unlock();
|
||||||
|
if (mappedRect.x() + mappedRect.width() > wallpaperRect.width()) {
|
||||||
|
const QRect outerRectRight = { intersectedRect.topRight() + xOffset, QSize{ mappedRect.width() - intersectedRect.width(), intersectedRect.height() } };
|
||||||
|
const QPoint outerRectRightOriginPoint = originPoint + QPoint{ intersectedRect.width(), 0 } + xOffset;
|
||||||
|
const QRect mappedOuterRectRight = d->mapToWallpaper(outerRectRight);
|
||||||
|
const QRect outerRectCorner = { intersectedRect.bottomRight() + xOffset + yOffset, QSize{ outerRectRight.width(), outerRectBottom.height() } };
|
||||||
|
const QPoint outerRectCornerOriginPoint = originPoint + QPoint{ intersectedRect.width(), intersectedRect.height() } + xOffset + yOffset;
|
||||||
|
const QRect mappedOuterRectCorner = d->mapToWallpaper(outerRectCorner);
|
||||||
|
const QMutexLocker locker(&g_imageData()->mutex);
|
||||||
|
painter->drawPixmap(outerRectRightOriginPoint, g_imageData()->blurredWallpaper, mappedOuterRectRight);
|
||||||
|
painter->drawPixmap(outerRectCornerOriginPoint, g_imageData()->blurredWallpaper, mappedOuterRectCorner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
|
||||||
|
painter->setOpacity(qreal(1));
|
||||||
|
painter->fillRect(QRect{originPoint, mappedRect.size()}, [d, active]() -> QBrush {
|
||||||
|
if (!d->fallbackEnabled || active) {
|
||||||
|
return d->micaBrush;
|
||||||
|
}
|
||||||
|
if (d->fallbackColor.isValid()) {
|
||||||
|
return d->fallbackColor;
|
||||||
|
}
|
||||||
|
return d->systemFallbackColor();
|
||||||
|
}());
|
||||||
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
|
@ -242,7 +242,7 @@ struct Win32Message
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DEFINE_WIN32_MESSAGE(Message) Win32Message{ Message, #Message },
|
#define DEFINE_WIN32_MESSAGE(Message) Win32Message{ Message, #Message },
|
||||||
static constexpr const std::array<Win32Message, 252> g_win32MessageMap =
|
static constexpr const std::array<Win32Message, 333> g_win32MessageMap =
|
||||||
{
|
{
|
||||||
DEFINE_WIN32_MESSAGE(WM_NULL)
|
DEFINE_WIN32_MESSAGE(WM_NULL)
|
||||||
DEFINE_WIN32_MESSAGE(WM_CREATE)
|
DEFINE_WIN32_MESSAGE(WM_CREATE)
|
||||||
|
@ -376,7 +376,6 @@ static constexpr const std::array<Win32Message, 252> g_win32MessageMap =
|
||||||
DEFINE_WIN32_MESSAGE(WM_CTLCOLORDLG)
|
DEFINE_WIN32_MESSAGE(WM_CTLCOLORDLG)
|
||||||
DEFINE_WIN32_MESSAGE(WM_CTLCOLORSCROLLBAR)
|
DEFINE_WIN32_MESSAGE(WM_CTLCOLORSCROLLBAR)
|
||||||
DEFINE_WIN32_MESSAGE(WM_CTLCOLORSTATIC)
|
DEFINE_WIN32_MESSAGE(WM_CTLCOLORSTATIC)
|
||||||
DEFINE_WIN32_MESSAGE(MN_GETHMENU)
|
|
||||||
DEFINE_WIN32_MESSAGE(WM_MOUSEMOVE) // WM_MOUSEFIRST
|
DEFINE_WIN32_MESSAGE(WM_MOUSEMOVE) // WM_MOUSEFIRST
|
||||||
DEFINE_WIN32_MESSAGE(WM_LBUTTONDOWN)
|
DEFINE_WIN32_MESSAGE(WM_LBUTTONDOWN)
|
||||||
DEFINE_WIN32_MESSAGE(WM_LBUTTONUP)
|
DEFINE_WIN32_MESSAGE(WM_LBUTTONUP)
|
||||||
|
@ -433,7 +432,6 @@ static constexpr const std::array<Win32Message, 252> g_win32MessageMap =
|
||||||
DEFINE_WIN32_MESSAGE(WM_TOUCHHITTESTING)
|
DEFINE_WIN32_MESSAGE(WM_TOUCHHITTESTING)
|
||||||
DEFINE_WIN32_MESSAGE(WM_POINTERWHEEL)
|
DEFINE_WIN32_MESSAGE(WM_POINTERWHEEL)
|
||||||
DEFINE_WIN32_MESSAGE(WM_POINTERHWHEEL)
|
DEFINE_WIN32_MESSAGE(WM_POINTERHWHEEL)
|
||||||
DEFINE_WIN32_MESSAGE(DM_POINTERHITTEST)
|
|
||||||
DEFINE_WIN32_MESSAGE(WM_POINTERROUTEDTO)
|
DEFINE_WIN32_MESSAGE(WM_POINTERROUTEDTO)
|
||||||
DEFINE_WIN32_MESSAGE(WM_POINTERROUTEDAWAY)
|
DEFINE_WIN32_MESSAGE(WM_POINTERROUTEDAWAY)
|
||||||
DEFINE_WIN32_MESSAGE(WM_POINTERROUTEDRELEASED)
|
DEFINE_WIN32_MESSAGE(WM_POINTERROUTEDRELEASED)
|
||||||
|
@ -496,6 +494,90 @@ static constexpr const std::array<Win32Message, 252> g_win32MessageMap =
|
||||||
DEFINE_WIN32_MESSAGE(WM_PENWINLAST)
|
DEFINE_WIN32_MESSAGE(WM_PENWINLAST)
|
||||||
DEFINE_WIN32_MESSAGE(WM_APP)
|
DEFINE_WIN32_MESSAGE(WM_APP)
|
||||||
DEFINE_WIN32_MESSAGE(WM_USER)
|
DEFINE_WIN32_MESSAGE(WM_USER)
|
||||||
|
// Undocumented messages:
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_SIZEWAIT)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_SETVISIBLE)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_SYSTEMERROR)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_CTLCOLOR)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_LOGOFF)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_ALTTABACTIVE)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_SHELLNOTIFY)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_ISACTIVEICON)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_QUERYPARKICON)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_WINHELP)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_FULLSCREEN)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_CLIENTSHUTDOWN)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_DDEMLEVENT)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_TESTING)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_OTHERWINDOWCREATED)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_OTHERWINDOWDESTROYED)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_COPYGLOBALDATA)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_KEYF1)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_ACCESS_WINDOW)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_FINALDESTROY)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_MEASUREITEM_CLIENTDATA)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_SYNCTASK)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_KLUDGEMINRECT)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_LPKDRAWSWITCHWND)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_UAHDESTROYWINDOW)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_UAHDRAWMENU)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_UAHDRAWMENUITEM)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_UAHINITMENU)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_UAHMEASUREMENUITEM)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_UAHNCPAINTMENUPOPUP)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_UAHUPDATE)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_NCUAHDRAWCAPTION)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_NCUAHDRAWFRAME)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_YOMICHAR)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_CONVERTREQUEST)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_CONVERTRESULT)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_INTERIM)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_SYSTIMER)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_GESTUREINPUT)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_GESTURENOTIFIED)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_LBTRACKPOINT)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_DROPOBJECT)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_QUERYDROPOBJECT)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_BEGINDRAG)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_DRAGLOOP)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_DRAGSELECT)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_DRAGMOVE)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_STOPINERTIA)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_ENDINERTIA)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_EDGYINERTIA)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_VISIBILITYCHANGED)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_VIEWSTATECHANGED)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_UNREGISTER_WINDOW_SERVICES)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_CONSOLIDATED)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_IME_REPORT)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_IME_SYSTEM)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_POINTERDEVICEADDED)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_POINTERDEVICEDELETED)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_FLICK)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_FLICKINTERNAL)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_BRIGHTNESSCHANGED)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_SYSMENU)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_HOOKMSG)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_EXITPROCESS)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_WAKETHREAD)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_UAHINIT)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_DESKTOPNOTIFY)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_DWMEXILEFRAME)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_MAGNIFICATION_STARTED)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_MAGNIFICATION_ENDED)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_DWMTHUMBNAILSIZECHANGED)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_MAGNIFICATION_OUTPUT)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_BSDRDATA)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_DWMTRANSITIONSTATECHANGED)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_KEYBOARDCORRECTIONCALLOUT)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_KEYBOARDCORRECTIONACTION)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_UIACTION)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_ROUTED_UI_EVENT)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_MEASURECONTROL)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_GETACTIONTEXT)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_FORWARDKEYDOWN)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_FORWARDKEYUP)
|
||||||
|
DEFINE_WIN32_MESSAGE(WM_NOTIFYWOW)
|
||||||
};
|
};
|
||||||
#undef DEFINE_WIN32_MESSAGE
|
#undef DEFINE_WIN32_MESSAGE
|
||||||
|
|
||||||
|
@ -804,8 +886,7 @@ static constexpr const std::array<Win32Message, 252> g_win32MessageMap =
|
||||||
{
|
{
|
||||||
if (edges == Qt::Edges{}) {
|
if (edges == Qt::Edges{}) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} else if (edges == (Qt::LeftEdge)) {
|
||||||
if (edges == (Qt::LeftEdge)) {
|
|
||||||
return 0xF001; // SC_SIZELEFT
|
return 0xF001; // SC_SIZELEFT
|
||||||
} else if (edges == (Qt::RightEdge)) {
|
} else if (edges == (Qt::RightEdge)) {
|
||||||
return 0xF002; // SC_SIZERIGHT
|
return 0xF002; // SC_SIZERIGHT
|
||||||
|
@ -840,23 +921,16 @@ static constexpr const std::array<Win32Message, 252> g_win32MessageMap =
|
||||||
|
|
||||||
[[nodiscard]] static inline bool isNonClientMessage(const UINT message)
|
[[nodiscard]] static inline bool isNonClientMessage(const UINT message)
|
||||||
{
|
{
|
||||||
if ((message >= WM_NCCREATE) && (message <= WM_NCACTIVATE)) {
|
if (((message >= WM_NCCREATE) && (message <= WM_NCACTIVATE))
|
||||||
|
|| ((message >= WM_NCMOUSEMOVE) && (message <= WM_NCMBUTTONDBLCLK))
|
||||||
|
|| ((message >= WM_NCXBUTTONDOWN) && (message <= WM_NCXBUTTONDBLCLK))
|
||||||
|
|| ((message >= WM_NCPOINTERUPDATE) && (message <= WM_NCPOINTERUP))
|
||||||
|
|| ((message == WM_NCMOUSEHOVER) || (message == WM_NCMOUSELEAVE))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
if ((message >= WM_NCMOUSEMOVE) && (message <= WM_NCMBUTTONDBLCLK)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if ((message >= WM_NCXBUTTONDOWN) && (message <= WM_NCXBUTTONDBLCLK)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if ((message >= WM_NCPOINTERUPDATE) && (message <= WM_NCPOINTERUP)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if ((message == WM_NCMOUSEHOVER) || (message == WM_NCMOUSELEAVE)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] static inline bool isMouseMessage(const UINT message, bool *isNonClient = nullptr)
|
[[nodiscard]] static inline bool isMouseMessage(const UINT message, bool *isNonClient = nullptr)
|
||||||
{
|
{
|
||||||
|
@ -866,17 +940,17 @@ static constexpr const std::array<Win32Message, 252> g_win32MessageMap =
|
||||||
*isNonClient = false;
|
*isNonClient = false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
} else if (((message >= WM_NCMOUSEMOVE) && (message <= WM_NCMBUTTONDBLCLK))
|
||||||
if (((message >= WM_NCMOUSEMOVE) && (message <= WM_NCMBUTTONDBLCLK))
|
|
||||||
|| ((message >= WM_NCXBUTTONDOWN) && (message <= WM_NCXBUTTONDBLCLK))
|
|| ((message >= WM_NCXBUTTONDOWN) && (message <= WM_NCXBUTTONDBLCLK))
|
||||||
|| ((message == WM_NCMOUSEHOVER) || (message == WM_NCMOUSELEAVE))) {
|
|| ((message == WM_NCMOUSEHOVER) || (message == WM_NCMOUSELEAVE))) {
|
||||||
if (isNonClient) {
|
if (isNonClient) {
|
||||||
*isNonClient = true;
|
*isNonClient = true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] static inline bool usePureQtImplementation()
|
[[nodiscard]] static inline bool usePureQtImplementation()
|
||||||
{
|
{
|
||||||
|
@ -892,16 +966,32 @@ static constexpr const std::array<Win32Message, 252> g_win32MessageMap =
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (isWin32MessageDebuggingEnabled()) {
|
if (isWin32MessageDebuggingEnabled()) {
|
||||||
const auto it = std::find(g_win32MessageMap.cbegin(), g_win32MessageMap.cend(), Win32Message{ uMsg, nullptr });
|
const QString messageCodeHex = FRAMELESSHELPER_STRING_LITERAL("0x") + QString::number(uMsg, 16).toUpper().rightJustified(4, u'0');
|
||||||
if (it != g_win32MessageMap.cend()) {
|
|
||||||
QString text = {};
|
QString text = {};
|
||||||
QTextStream stream(&text);
|
QTextStream stream(&text);
|
||||||
stream << "Win32 message received: " << it->Str << " (0x"
|
stream << "Win32 message received: ";
|
||||||
<< QString::number(uMsg, 16).toUpper().rightJustified(4, u'0') << ')';
|
if (uMsg >= WM_APP) {
|
||||||
|
const UINT diff = (uMsg - WM_APP);
|
||||||
|
stream << "WM_APP + " << diff << " (" << messageCodeHex
|
||||||
|
<< ") [private message owned by current application]";
|
||||||
|
} else if (uMsg >= WM_USER) {
|
||||||
|
const UINT diff = (uMsg - WM_USER);
|
||||||
|
stream << "WM_USER + " << diff << " (" << messageCodeHex
|
||||||
|
<< ") [private message owned by all kinds of controls]";
|
||||||
|
} else {
|
||||||
|
const auto it = std::find(g_win32MessageMap.cbegin(), g_win32MessageMap.cend(), Win32Message{ uMsg, nullptr });
|
||||||
|
if (it == g_win32MessageMap.cend()) {
|
||||||
|
stream << "UNKNOWN";
|
||||||
|
} else {
|
||||||
|
stream << it->Str;
|
||||||
|
}
|
||||||
|
stream << " (" << messageCodeHex << ')';
|
||||||
|
auto screenPos = POINT{ 0, 0 };
|
||||||
|
auto clientPos = POINT{ 0, 0 };
|
||||||
bool isNonClientMouseMessage = false;
|
bool isNonClientMouseMessage = false;
|
||||||
if (isMouseMessage(uMsg, &isNonClientMouseMessage)) {
|
if (isMouseMessage(uMsg, &isNonClientMouseMessage)) {
|
||||||
if (isNonClientMouseMessage) {
|
if (isNonClientMouseMessage) {
|
||||||
const auto screenPos = [uMsg, lParam]() -> POINT {
|
screenPos = [uMsg, lParam]() -> POINT {
|
||||||
if (uMsg == WM_NCMOUSELEAVE) {
|
if (uMsg == WM_NCMOUSELEAVE) {
|
||||||
const DWORD dwScreenPos = ::GetMessagePos();
|
const DWORD dwScreenPos = ::GetMessagePos();
|
||||||
return POINT{ GET_X_LPARAM(dwScreenPos), GET_Y_LPARAM(dwScreenPos) };
|
return POINT{ GET_X_LPARAM(dwScreenPos), GET_Y_LPARAM(dwScreenPos) };
|
||||||
|
@ -909,35 +999,29 @@ static constexpr const std::array<Win32Message, 252> g_win32MessageMap =
|
||||||
return POINT{ GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
|
return POINT{ GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
POINT clientPos = screenPos;
|
clientPos = screenPos;
|
||||||
if (::ScreenToClient(hWnd, &clientPos) == FALSE) {
|
if (::ScreenToClient(hWnd, &clientPos) == FALSE) {
|
||||||
WARNING << Utils::getSystemErrorMessage(kScreenToClient);
|
WARNING << Utils::getSystemErrorMessage(kScreenToClient);
|
||||||
clientPos = {};
|
clientPos = {};
|
||||||
}
|
}
|
||||||
stream << ", screen coordinate: POINT(x: " << screenPos.x << ", y: "
|
|
||||||
<< screenPos.y << "), client coordinate: POINT(x: "
|
|
||||||
<< clientPos.x << ", y: " << clientPos.y << ')';
|
|
||||||
} else {
|
} else {
|
||||||
const auto clientPos = [hWnd, uMsg, lParam]() -> POINT {
|
|
||||||
if (uMsg == WM_MOUSELEAVE) {
|
if (uMsg == WM_MOUSELEAVE) {
|
||||||
const DWORD dwScreenPos = ::GetMessagePos();
|
const DWORD dwScreenPos = ::GetMessagePos();
|
||||||
const auto screenPos = POINT{ GET_X_LPARAM(dwScreenPos), GET_Y_LPARAM(dwScreenPos) };
|
screenPos = POINT{ GET_X_LPARAM(dwScreenPos), GET_Y_LPARAM(dwScreenPos) };
|
||||||
POINT clientPos = screenPos;
|
clientPos = screenPos;
|
||||||
if (::ScreenToClient(hWnd, &clientPos) == FALSE) {
|
if (::ScreenToClient(hWnd, &clientPos) == FALSE) {
|
||||||
WARNING << Utils::getSystemErrorMessage(kScreenToClient);
|
WARNING << Utils::getSystemErrorMessage(kScreenToClient);
|
||||||
return {};
|
clientPos = {};
|
||||||
} else {
|
|
||||||
return clientPos;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return POINT{ GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
|
clientPos = POINT{ GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
|
||||||
}
|
screenPos = clientPos;
|
||||||
}();
|
|
||||||
POINT screenPos = clientPos;
|
|
||||||
if (::ClientToScreen(hWnd, &screenPos) == FALSE) {
|
if (::ClientToScreen(hWnd, &screenPos) == FALSE) {
|
||||||
WARNING << Utils::getSystemErrorMessage(kClientToScreen);
|
WARNING << Utils::getSystemErrorMessage(kClientToScreen);
|
||||||
screenPos = {};
|
screenPos = {};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
stream << ", screen coordinate: POINT(x: " << screenPos.x << ", y: "
|
stream << ", screen coordinate: POINT(x: " << screenPos.x << ", y: "
|
||||||
<< screenPos.y << "), client coordinate: POINT(x: "
|
<< screenPos.y << "), client coordinate: POINT(x: "
|
||||||
<< clientPos.x << ", y: " << clientPos.y << ')';
|
<< clientPos.x << ", y: " << clientPos.y << ')';
|
||||||
|
@ -945,7 +1029,6 @@ static constexpr const std::array<Win32Message, 252> g_win32MessageMap =
|
||||||
}
|
}
|
||||||
DEBUG.noquote() << text;
|
DEBUG.noquote() << text;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
const auto windowId = reinterpret_cast<WId>(hWnd);
|
const auto windowId = reinterpret_cast<WId>(hWnd);
|
||||||
const auto it = g_win32UtilsData()->data.constFind(windowId);
|
const auto it = g_win32UtilsData()->data.constFind(windowId);
|
||||||
if (it == g_win32UtilsData()->data.constEnd()) {
|
if (it == g_win32UtilsData()->data.constEnd()) {
|
||||||
|
|
|
@ -59,7 +59,6 @@ WindowBorderPainterPrivate::WindowBorderPainterPrivate(WindowBorderPainter *q) :
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
q_ptr = q;
|
q_ptr = q;
|
||||||
initialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowBorderPainterPrivate::~WindowBorderPainterPrivate() = default;
|
WindowBorderPainterPrivate::~WindowBorderPainterPrivate() = default;
|
||||||
|
@ -82,19 +81,47 @@ const WindowBorderPainterPrivate *WindowBorderPainterPrivate::get(const WindowBo
|
||||||
return q->d_func();
|
return q->d_func();
|
||||||
}
|
}
|
||||||
|
|
||||||
int WindowBorderPainterPrivate::getNativeBorderThickness()
|
WindowBorderPainter::WindowBorderPainter(QObject *parent)
|
||||||
|
: QObject(parent), d_ptr(new WindowBorderPainterPrivate(this))
|
||||||
|
{
|
||||||
|
connect(FramelessManager::instance(), &FramelessManager::systemThemeChanged, this, &WindowBorderPainter::nativeBorderChanged);
|
||||||
|
connect(this, &WindowBorderPainter::nativeBorderChanged, this, &WindowBorderPainter::shouldRepaint);
|
||||||
|
}
|
||||||
|
|
||||||
|
WindowBorderPainter::~WindowBorderPainter() = default;
|
||||||
|
|
||||||
|
int WindowBorderPainter::thickness() const
|
||||||
|
{
|
||||||
|
Q_D(const WindowBorderPainter);
|
||||||
|
return d->thickness.value_or(nativeThickness());
|
||||||
|
}
|
||||||
|
|
||||||
|
WindowEdges WindowBorderPainter::edges() const
|
||||||
|
{
|
||||||
|
Q_D(const WindowBorderPainter);
|
||||||
|
return d->edges.value_or(nativeEdges());
|
||||||
|
}
|
||||||
|
|
||||||
|
QColor WindowBorderPainter::activeColor() const
|
||||||
|
{
|
||||||
|
Q_D(const WindowBorderPainter);
|
||||||
|
return d->activeColor.value_or(nativeActiveColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
QColor WindowBorderPainter::inactiveColor() const
|
||||||
|
{
|
||||||
|
Q_D(const WindowBorderPainter);
|
||||||
|
return d->inactiveColor.value_or(nativeInactiveColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
int WindowBorderPainter::nativeThickness() const
|
||||||
{
|
{
|
||||||
// Qt will scale it to the appropriate value for us automatically,
|
// Qt will scale it to the appropriate value for us automatically,
|
||||||
// based on the current system DPI and scale factor rounding policy.
|
// based on the current system DPI and scale factor rounding policy.
|
||||||
return kDefaultWindowFrameBorderThickness;
|
return kDefaultWindowFrameBorderThickness;
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor WindowBorderPainterPrivate::getNativeBorderColor(const bool active)
|
WindowEdges WindowBorderPainter::nativeEdges() const
|
||||||
{
|
|
||||||
return Utils::getFrameBorderColor(active);
|
|
||||||
}
|
|
||||||
|
|
||||||
WindowEdges WindowBorderPainterPrivate::getNativeBorderEdges()
|
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
if (Utils::isWindowFrameBorderVisible() && !WindowsVersionHelper::isWin11OrGreater()) {
|
if (Utils::isWindowFrameBorderVisible() && !WindowsVersionHelper::isWin11OrGreater()) {
|
||||||
|
@ -104,24 +131,35 @@ WindowEdges WindowBorderPainterPrivate::getNativeBorderEdges()
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowBorderPainterPrivate::paint(QPainter *painter, const QSize &size, const bool active) const
|
QColor WindowBorderPainter::nativeActiveColor() const
|
||||||
|
{
|
||||||
|
return Utils::getFrameBorderColor(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
QColor WindowBorderPainter::nativeInactiveColor() const
|
||||||
|
{
|
||||||
|
return Utils::getFrameBorderColor(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowBorderPainter::paint(QPainter *painter, const QSize &size, const bool active)
|
||||||
{
|
{
|
||||||
Q_ASSERT(painter);
|
Q_ASSERT(painter);
|
||||||
Q_ASSERT(!size.isEmpty());
|
Q_ASSERT(!size.isEmpty());
|
||||||
if (!painter || size.isEmpty()) {
|
if (!painter || size.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Q_D(WindowBorderPainter);
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||||
QList<QLineF> lines = {};
|
QList<QLineF> lines = {};
|
||||||
#else
|
#else
|
||||||
QVector<QLineF> lines = {};
|
QVector<QLineF> lines = {};
|
||||||
#endif
|
#endif
|
||||||
static constexpr const auto gap = qreal(0.5);
|
static constexpr const auto gap = qreal(0.5);
|
||||||
const QPointF leftTop = {gap, gap};
|
const auto leftTop = QPointF{ gap, gap };
|
||||||
const QPointF rightTop = {qreal(size.width()) - gap, gap};
|
const auto rightTop = QPointF{ qreal(size.width()) - gap, leftTop.y() };
|
||||||
const QPointF rightBottom = {qreal(size.width()) - gap, qreal(size.height()) - gap};
|
const auto rightBottom = QPointF{ rightTop.x(), qreal(size.height()) - gap };
|
||||||
const QPointF leftBottom = {gap, qreal(size.height()) - gap};
|
const auto leftBottom = QPointF{ leftTop.x(), rightBottom.y() };
|
||||||
const WindowEdges edges = m_edges.value_or(getNativeBorderEdges());
|
const WindowEdges edges = d->edges.value_or(nativeEdges());
|
||||||
if (edges & WindowEdge::Left) {
|
if (edges & WindowEdge::Left) {
|
||||||
lines.append({leftBottom, leftTop});
|
lines.append({leftBottom, leftTop});
|
||||||
}
|
}
|
||||||
|
@ -140,93 +178,24 @@ void WindowBorderPainterPrivate::paint(QPainter *painter, const QSize &size, con
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
|
painter->setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
|
||||||
QPen pen = {};
|
QPen pen = {};
|
||||||
pen.setColor([active, this]() -> QColor {
|
pen.setColor([this, d, active]() -> QColor {
|
||||||
QColor color = {};
|
QColor color = {};
|
||||||
if (active) {
|
if (active) {
|
||||||
color = m_activeColor.value_or(getNativeBorderColor(true));
|
color = d->activeColor.value_or(nativeActiveColor());
|
||||||
} else {
|
} else {
|
||||||
color = m_inactiveColor.value_or(getNativeBorderColor(false));
|
color = d->inactiveColor.value_or(nativeInactiveColor());
|
||||||
}
|
}
|
||||||
if (color.isValid()) {
|
if (color.isValid()) {
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
return (active ? kDefaultBlackColor : kDefaultDarkGrayColor);
|
return (active ? kDefaultBlackColor : kDefaultDarkGrayColor);
|
||||||
}());
|
}());
|
||||||
pen.setWidth(m_thickness.value_or(getNativeBorderThickness()));
|
pen.setWidth(d->thickness.value_or(nativeThickness()));
|
||||||
painter->setPen(pen);
|
painter->setPen(pen);
|
||||||
painter->drawLines(lines);
|
painter->drawLines(lines);
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowBorderPainterPrivate::initialize()
|
|
||||||
{
|
|
||||||
Q_Q(WindowBorderPainter);
|
|
||||||
connect(FramelessManager::instance(), &FramelessManager::systemThemeChanged,
|
|
||||||
q, &WindowBorderPainter::nativeBorderChanged);
|
|
||||||
connect(q, &WindowBorderPainter::nativeBorderChanged, q, &WindowBorderPainter::shouldRepaint);
|
|
||||||
}
|
|
||||||
|
|
||||||
WindowBorderPainter::WindowBorderPainter(QObject *parent)
|
|
||||||
: QObject(parent), d_ptr(new WindowBorderPainterPrivate(this))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
WindowBorderPainter::~WindowBorderPainter() = default;
|
|
||||||
|
|
||||||
int WindowBorderPainter::thickness() const
|
|
||||||
{
|
|
||||||
Q_D(const WindowBorderPainter);
|
|
||||||
return d->m_thickness.value_or(d->getNativeBorderThickness());
|
|
||||||
}
|
|
||||||
|
|
||||||
WindowEdges WindowBorderPainter::edges() const
|
|
||||||
{
|
|
||||||
Q_D(const WindowBorderPainter);
|
|
||||||
return d->m_edges.value_or(d->getNativeBorderEdges());
|
|
||||||
}
|
|
||||||
|
|
||||||
QColor WindowBorderPainter::activeColor() const
|
|
||||||
{
|
|
||||||
Q_D(const WindowBorderPainter);
|
|
||||||
return d->m_activeColor.value_or(d->getNativeBorderColor(true));
|
|
||||||
}
|
|
||||||
|
|
||||||
QColor WindowBorderPainter::inactiveColor() const
|
|
||||||
{
|
|
||||||
Q_D(const WindowBorderPainter);
|
|
||||||
return d->m_inactiveColor.value_or(d->getNativeBorderColor(false));
|
|
||||||
}
|
|
||||||
|
|
||||||
int WindowBorderPainter::nativeThickness() const
|
|
||||||
{
|
|
||||||
Q_D(const WindowBorderPainter);
|
|
||||||
return d->getNativeBorderThickness();
|
|
||||||
}
|
|
||||||
|
|
||||||
WindowEdges WindowBorderPainter::nativeEdges() const
|
|
||||||
{
|
|
||||||
Q_D(const WindowBorderPainter);
|
|
||||||
return d->getNativeBorderEdges();
|
|
||||||
}
|
|
||||||
|
|
||||||
QColor WindowBorderPainter::nativeActiveColor() const
|
|
||||||
{
|
|
||||||
Q_D(const WindowBorderPainter);
|
|
||||||
return d->getNativeBorderColor(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
QColor WindowBorderPainter::nativeInactiveColor() const
|
|
||||||
{
|
|
||||||
Q_D(const WindowBorderPainter);
|
|
||||||
return d->getNativeBorderColor(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowBorderPainter::paint(QPainter *painter, const QSize &size, const bool active) const
|
|
||||||
{
|
|
||||||
Q_D(const WindowBorderPainter);
|
|
||||||
d->paint(painter, size, active);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowBorderPainter::setThickness(const int value)
|
void WindowBorderPainter::setThickness(const int value)
|
||||||
{
|
{
|
||||||
Q_ASSERT(value >= 0);
|
Q_ASSERT(value >= 0);
|
||||||
|
@ -238,7 +207,7 @@ void WindowBorderPainter::setThickness(const int value)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Q_D(WindowBorderPainter);
|
Q_D(WindowBorderPainter);
|
||||||
d->m_thickness = value;
|
d->thickness = value;
|
||||||
Q_EMIT thicknessChanged();
|
Q_EMIT thicknessChanged();
|
||||||
Q_EMIT shouldRepaint();
|
Q_EMIT shouldRepaint();
|
||||||
}
|
}
|
||||||
|
@ -249,7 +218,7 @@ void WindowBorderPainter::setEdges(const Global::WindowEdges value)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Q_D(WindowBorderPainter);
|
Q_D(WindowBorderPainter);
|
||||||
d->m_edges = value;
|
d->edges = value;
|
||||||
Q_EMIT edgesChanged();
|
Q_EMIT edgesChanged();
|
||||||
Q_EMIT shouldRepaint();
|
Q_EMIT shouldRepaint();
|
||||||
}
|
}
|
||||||
|
@ -264,7 +233,7 @@ void WindowBorderPainter::setActiveColor(const QColor &value)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Q_D(WindowBorderPainter);
|
Q_D(WindowBorderPainter);
|
||||||
d->m_activeColor = value;
|
d->activeColor = value;
|
||||||
Q_EMIT activeColorChanged();
|
Q_EMIT activeColorChanged();
|
||||||
Q_EMIT shouldRepaint();
|
Q_EMIT shouldRepaint();
|
||||||
}
|
}
|
||||||
|
@ -279,7 +248,7 @@ void WindowBorderPainter::setInactiveColor(const QColor &value)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Q_D(WindowBorderPainter);
|
Q_D(WindowBorderPainter);
|
||||||
d->m_inactiveColor = value;
|
d->inactiveColor = value;
|
||||||
Q_EMIT inactiveColorChanged();
|
Q_EMIT inactiveColorChanged();
|
||||||
Q_EMIT shouldRepaint();
|
Q_EMIT shouldRepaint();
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,6 @@ FramelessQuickApplicationWindowPrivate::FramelessQuickApplicationWindowPrivate(F
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
q_ptr = q;
|
q_ptr = q;
|
||||||
initialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FramelessQuickApplicationWindowPrivate::~FramelessQuickApplicationWindowPrivate() = default;
|
FramelessQuickApplicationWindowPrivate::~FramelessQuickApplicationWindowPrivate() = default;
|
||||||
|
@ -82,156 +81,90 @@ const FramelessQuickApplicationWindowPrivate *FramelessQuickApplicationWindowPri
|
||||||
return pub->d_func();
|
return pub->d_func();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FramelessQuickApplicationWindowPrivate::isHidden() const
|
|
||||||
{
|
|
||||||
Q_Q(const FramelessQuickApplicationWindow);
|
|
||||||
return (q->visibility() == FramelessQuickApplicationWindow::Hidden);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FramelessQuickApplicationWindowPrivate::isNormal() const
|
|
||||||
{
|
|
||||||
Q_Q(const FramelessQuickApplicationWindow);
|
|
||||||
return (q->visibility() == FramelessQuickApplicationWindow::Windowed);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FramelessQuickApplicationWindowPrivate::isMinimized() const
|
|
||||||
{
|
|
||||||
Q_Q(const FramelessQuickApplicationWindow);
|
|
||||||
return (q->visibility() == FramelessQuickApplicationWindow::Minimized);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FramelessQuickApplicationWindowPrivate::isMaximized() const
|
|
||||||
{
|
|
||||||
Q_Q(const FramelessQuickApplicationWindow);
|
|
||||||
return (q->visibility() == FramelessQuickApplicationWindow::Maximized);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FramelessQuickApplicationWindowPrivate::isZoomed() const
|
|
||||||
{
|
|
||||||
Q_Q(const FramelessQuickApplicationWindow);
|
|
||||||
return (isMaximized() || (q->visibility() == FramelessQuickApplicationWindow::FullScreen));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FramelessQuickApplicationWindowPrivate::isFullScreen() const
|
|
||||||
{
|
|
||||||
Q_Q(const FramelessQuickApplicationWindow);
|
|
||||||
return (q->visibility() == FramelessQuickApplicationWindow::FullScreen);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickApplicationWindowPrivate::showMinimized2()
|
|
||||||
{
|
|
||||||
Q_Q(FramelessQuickApplicationWindow);
|
|
||||||
#ifdef Q_OS_WINDOWS
|
|
||||||
// Work-around a QtQuick bug: https://bugreports.qt.io/browse/QTBUG-69711
|
|
||||||
// Don't use "SW_SHOWMINIMIZED" because it will activate the current window
|
|
||||||
// instead of the next window in the Z order, which is not the default behavior
|
|
||||||
// of native Win32 applications.
|
|
||||||
ShowWindow(reinterpret_cast<HWND>(q->winId()), SW_MINIMIZE);
|
|
||||||
#else
|
|
||||||
q->showMinimized();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickApplicationWindowPrivate::toggleMaximized()
|
|
||||||
{
|
|
||||||
Q_Q(FramelessQuickApplicationWindow);
|
|
||||||
if (isMaximized()) {
|
|
||||||
q->showNormal();
|
|
||||||
} else {
|
|
||||||
q->showMaximized();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickApplicationWindowPrivate::toggleFullScreen()
|
|
||||||
{
|
|
||||||
Q_Q(FramelessQuickApplicationWindow);
|
|
||||||
if (isFullScreen()) {
|
|
||||||
q->setVisibility(m_savedVisibility);
|
|
||||||
} else {
|
|
||||||
m_savedVisibility = q->visibility();
|
|
||||||
q->showFullScreen();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickApplicationWindowPrivate::initialize()
|
|
||||||
{
|
|
||||||
Q_Q(FramelessQuickApplicationWindow);
|
|
||||||
QQuickItem * const rootItem = q->contentItem();
|
|
||||||
FramelessQuickHelper::get(rootItem)->extendsContentIntoTitleBar();
|
|
||||||
m_windowBorder = new QuickWindowBorder;
|
|
||||||
m_windowBorder->setParent(rootItem);
|
|
||||||
m_windowBorder->setParentItem(rootItem);
|
|
||||||
m_windowBorder->setZ(999); // Make sure it always stays on the top.
|
|
||||||
QQuickItemPrivate::get(m_windowBorder)->anchors()->setFill(rootItem);
|
|
||||||
connect(q, &FramelessQuickApplicationWindow::visibilityChanged, q, [q](){
|
|
||||||
Q_EMIT q->hiddenChanged();
|
|
||||||
Q_EMIT q->normalChanged();
|
|
||||||
Q_EMIT q->minimizedChanged();
|
|
||||||
Q_EMIT q->maximizedChanged();
|
|
||||||
Q_EMIT q->zoomedChanged();
|
|
||||||
Q_EMIT q->fullScreenChanged();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
FramelessQuickApplicationWindow::FramelessQuickApplicationWindow(QWindow *parent)
|
FramelessQuickApplicationWindow::FramelessQuickApplicationWindow(QWindow *parent)
|
||||||
: QQuickApplicationWindow(parent), d_ptr(new FramelessQuickApplicationWindowPrivate(this))
|
: QQuickApplicationWindow(parent), d_ptr(new FramelessQuickApplicationWindowPrivate(this))
|
||||||
{
|
{
|
||||||
|
QQuickItem * const rootItem = contentItem();
|
||||||
|
FramelessQuickHelper::get(rootItem)->extendsContentIntoTitleBar();
|
||||||
|
Q_D(FramelessQuickApplicationWindow);
|
||||||
|
d->windowBorder = new QuickWindowBorder;
|
||||||
|
d->windowBorder->setParent(rootItem);
|
||||||
|
d->windowBorder->setParentItem(rootItem);
|
||||||
|
d->windowBorder->setZ(999); // Make sure it always stays on the top.
|
||||||
|
QQuickItemPrivate::get(d->windowBorder)->anchors()->setFill(rootItem);
|
||||||
|
connect(this, &FramelessQuickApplicationWindow::visibilityChanged, this, [this](){
|
||||||
|
Q_EMIT hiddenChanged();
|
||||||
|
Q_EMIT normalChanged();
|
||||||
|
Q_EMIT minimizedChanged();
|
||||||
|
Q_EMIT maximizedChanged();
|
||||||
|
Q_EMIT zoomedChanged();
|
||||||
|
Q_EMIT fullScreenChanged();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
FramelessQuickApplicationWindow::~FramelessQuickApplicationWindow() = default;
|
FramelessQuickApplicationWindow::~FramelessQuickApplicationWindow() = default;
|
||||||
|
|
||||||
bool FramelessQuickApplicationWindow::isHidden() const
|
bool FramelessQuickApplicationWindow::isHidden() const
|
||||||
{
|
{
|
||||||
Q_D(const FramelessQuickApplicationWindow);
|
return (visibility() == FramelessQuickApplicationWindow::Hidden);
|
||||||
return d->isHidden();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FramelessQuickApplicationWindow::isNormal() const
|
bool FramelessQuickApplicationWindow::isNormal() const
|
||||||
{
|
{
|
||||||
Q_D(const FramelessQuickApplicationWindow);
|
return (visibility() == FramelessQuickApplicationWindow::Windowed);
|
||||||
return d->isNormal();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FramelessQuickApplicationWindow::isMinimized() const
|
bool FramelessQuickApplicationWindow::isMinimized() const
|
||||||
{
|
{
|
||||||
Q_D(const FramelessQuickApplicationWindow);
|
return (visibility() == FramelessQuickApplicationWindow::Minimized);
|
||||||
return d->isMinimized();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FramelessQuickApplicationWindow::isMaximized() const
|
bool FramelessQuickApplicationWindow::isMaximized() const
|
||||||
{
|
{
|
||||||
Q_D(const FramelessQuickApplicationWindow);
|
return (visibility() == FramelessQuickApplicationWindow::Maximized);
|
||||||
return d->isMaximized();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FramelessQuickApplicationWindow::isZoomed() const
|
bool FramelessQuickApplicationWindow::isZoomed() const
|
||||||
{
|
{
|
||||||
Q_D(const FramelessQuickApplicationWindow);
|
return (isMaximized() || (visibility() == FramelessQuickApplicationWindow::FullScreen));
|
||||||
return d->isZoomed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FramelessQuickApplicationWindow::isFullScreen() const
|
bool FramelessQuickApplicationWindow::isFullScreen() const
|
||||||
{
|
{
|
||||||
Q_D(const FramelessQuickApplicationWindow);
|
return (visibility() == FramelessQuickApplicationWindow::FullScreen);
|
||||||
return d->isFullScreen();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickApplicationWindow::showMinimized2()
|
void FramelessQuickApplicationWindow::showMinimized2()
|
||||||
{
|
{
|
||||||
Q_D(FramelessQuickApplicationWindow);
|
#ifdef Q_OS_WINDOWS
|
||||||
d->showMinimized2();
|
// Work-around a QtQuick bug: https://bugreports.qt.io/browse/QTBUG-69711
|
||||||
|
// Don't use "SW_SHOWMINIMIZED" because it will activate the current window
|
||||||
|
// instead of the next window in the Z order, which is not the default behavior
|
||||||
|
// of native Win32 applications.
|
||||||
|
::ShowWindow(reinterpret_cast<HWND>(winId()), SW_MINIMIZE);
|
||||||
|
#else
|
||||||
|
showMinimized();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickApplicationWindow::toggleMaximized()
|
void FramelessQuickApplicationWindow::toggleMaximized()
|
||||||
{
|
{
|
||||||
Q_D(FramelessQuickApplicationWindow);
|
if (isMaximized()) {
|
||||||
d->toggleMaximized();
|
showNormal();
|
||||||
|
} else {
|
||||||
|
showMaximized();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickApplicationWindow::toggleFullScreen()
|
void FramelessQuickApplicationWindow::toggleFullScreen()
|
||||||
{
|
{
|
||||||
Q_D(FramelessQuickApplicationWindow);
|
Q_D(FramelessQuickApplicationWindow);
|
||||||
d->toggleFullScreen();
|
if (isFullScreen()) {
|
||||||
|
setVisibility(d->savedVisibility);
|
||||||
|
} else {
|
||||||
|
d->savedVisibility = visibility();
|
||||||
|
showFullScreen();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickApplicationWindow::classBegin()
|
void FramelessQuickApplicationWindow::classBegin()
|
||||||
|
|
|
@ -98,12 +98,7 @@ FramelessQuickHelperPrivate::FramelessQuickHelperPrivate(FramelessQuickHelper *q
|
||||||
connect(q_ptr, &FramelessQuickHelper::windowChanged, q_ptr, &FramelessQuickHelper::windowChanged2);
|
connect(q_ptr, &FramelessQuickHelper::windowChanged, q_ptr, &FramelessQuickHelper::windowChanged2);
|
||||||
}
|
}
|
||||||
|
|
||||||
FramelessQuickHelperPrivate::~FramelessQuickHelperPrivate()
|
FramelessQuickHelperPrivate::~FramelessQuickHelperPrivate() = default;
|
||||||
{
|
|
||||||
m_destroying = true;
|
|
||||||
extendsContentIntoTitleBar(false);
|
|
||||||
m_extendIntoTitleBar = std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
FramelessQuickHelperPrivate *FramelessQuickHelperPrivate::get(FramelessQuickHelper *pub)
|
FramelessQuickHelperPrivate *FramelessQuickHelperPrivate::get(FramelessQuickHelper *pub)
|
||||||
{
|
{
|
||||||
|
@ -123,48 +118,6 @@ const FramelessQuickHelperPrivate *FramelessQuickHelperPrivate::get(const Framel
|
||||||
return pub->d_func();
|
return pub->d_func();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FramelessQuickHelperPrivate::isContentExtendedIntoTitleBar() const
|
|
||||||
{
|
|
||||||
const FramelessQuickHelperData *data = getWindowData();
|
|
||||||
return (data ? data->ready : false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickHelperPrivate::extendsContentIntoTitleBar(const bool value)
|
|
||||||
{
|
|
||||||
if (isContentExtendedIntoTitleBar() == value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (value) {
|
|
||||||
attach();
|
|
||||||
} else {
|
|
||||||
detach();
|
|
||||||
}
|
|
||||||
m_extendIntoTitleBar = value;
|
|
||||||
if (!m_destroying) {
|
|
||||||
emitSignalForAllInstances("extendsContentIntoTitleBarChanged");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QQuickItem *FramelessQuickHelperPrivate::getTitleBarItem() const
|
|
||||||
{
|
|
||||||
const FramelessQuickHelperData *data = getWindowData();
|
|
||||||
return (data ? data->titleBarItem : nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickHelperPrivate::setTitleBarItem(QQuickItem *value)
|
|
||||||
{
|
|
||||||
Q_ASSERT(value);
|
|
||||||
if (!value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
FramelessQuickHelperData *data = getWindowDataMutable();
|
|
||||||
if (!data || (data->titleBarItem == value)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
data->titleBarItem = value;
|
|
||||||
emitSignalForAllInstances("titleBarItemChanged");
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickHelperPrivate::attach()
|
void FramelessQuickHelperPrivate::attach()
|
||||||
{
|
{
|
||||||
Q_Q(FramelessQuickHelper);
|
Q_Q(FramelessQuickHelper);
|
||||||
|
@ -188,8 +141,8 @@ void FramelessQuickHelperPrivate::attach()
|
||||||
params.getWindowPosition = [window]() -> QPoint { return window->position(); };
|
params.getWindowPosition = [window]() -> QPoint { return window->position(); };
|
||||||
params.setWindowPosition = [window](const QPoint &pos) -> void { window->setX(pos.x()); window->setY(pos.y()); };
|
params.setWindowPosition = [window](const QPoint &pos) -> void { window->setX(pos.x()); window->setY(pos.y()); };
|
||||||
params.getWindowScreen = [window]() -> QScreen * { return window->screen(); };
|
params.getWindowScreen = [window]() -> QScreen * { return window->screen(); };
|
||||||
params.isWindowFixedSize = [this]() -> bool { return isWindowFixedSize(); };
|
params.isWindowFixedSize = [q]() -> bool { return q->isWindowFixedSize(); };
|
||||||
params.setWindowFixedSize = [this](const bool value) -> void { setWindowFixedSize(value); };
|
params.setWindowFixedSize = [q](const bool value) -> void { q->setWindowFixedSize(value); };
|
||||||
params.getWindowState = [window]() -> Qt::WindowState { return window->windowState(); };
|
params.getWindowState = [window]() -> Qt::WindowState { return window->windowState(); };
|
||||||
params.setWindowState = [window](const Qt::WindowState state) -> void { window->setWindowState(state); };
|
params.setWindowState = [window](const Qt::WindowState state) -> void { window->setWindowState(state); };
|
||||||
params.getWindowHandle = [window]() -> QWindow * { return window; };
|
params.getWindowHandle = [window]() -> QWindow * { return window; };
|
||||||
|
@ -208,7 +161,7 @@ void FramelessQuickHelperPrivate::attach()
|
||||||
FRAMELESSHELPER_ENUM_CORE_TO_QUICK(ButtonState, state));
|
FRAMELESSHELPER_ENUM_CORE_TO_QUICK(ButtonState, state));
|
||||||
};
|
};
|
||||||
params.shouldIgnoreMouseEvents = [this](const QPoint &pos) -> bool { return shouldIgnoreMouseEvents(pos); };
|
params.shouldIgnoreMouseEvents = [this](const QPoint &pos) -> bool { return shouldIgnoreMouseEvents(pos); };
|
||||||
params.showSystemMenu = [this](const QPoint &pos) -> void { showSystemMenu(pos); };
|
params.showSystemMenu = [q](const QPoint &pos) -> void { q->showSystemMenu(pos); };
|
||||||
params.setProperty = [this](const char *name, const QVariant &value) -> void { setProperty(name, value); };
|
params.setProperty = [this](const char *name, const QVariant &value) -> void { setProperty(name, value); };
|
||||||
params.getProperty = [this](const char *name, const QVariant &defaultValue) -> QVariant { return getProperty(name, defaultValue); };
|
params.getProperty = [this](const char *name, const QVariant &defaultValue) -> QVariant { return getProperty(name, defaultValue); };
|
||||||
params.setCursor = [window](const QCursor &cursor) -> void { window->setCursor(cursor); };
|
params.setCursor = [window](const QCursor &cursor) -> void { window->setCursor(cursor); };
|
||||||
|
@ -227,13 +180,13 @@ void FramelessQuickHelperPrivate::attach()
|
||||||
// we reach here, and all the modifications from the Qt side will be lost
|
// we reach here, and all the modifications from the Qt side will be lost
|
||||||
// due to QPA will reset the position and size of the window during it's
|
// due to QPA will reset the position and size of the window during it's
|
||||||
// initialization process.
|
// initialization process.
|
||||||
QTimer::singleShot(m_qpaWaitTime, this, [this](){
|
QTimer::singleShot(qpaWaitTime, this, [this, q](){
|
||||||
m_qpaReady = true;
|
qpaReady = true;
|
||||||
if (FramelessConfig::instance()->isSet(Option::CenterWindowBeforeShow)) {
|
if (FramelessConfig::instance()->isSet(Option::CenterWindowBeforeShow)) {
|
||||||
moveWindowToDesktopCenter();
|
q->moveWindowToDesktopCenter();
|
||||||
}
|
}
|
||||||
if (FramelessConfig::instance()->isSet(Option::EnableBlurBehindWindow)) {
|
if (FramelessConfig::instance()->isSet(Option::EnableBlurBehindWindow)) {
|
||||||
setBlurBehindWindowEnabled(true, {});
|
q->setBlurBehindWindowEnabled(true);
|
||||||
}
|
}
|
||||||
emitSignalForAllInstances("ready");
|
emitSignalForAllInstances("ready");
|
||||||
});
|
});
|
||||||
|
@ -255,206 +208,6 @@ void FramelessQuickHelperPrivate::detach()
|
||||||
FramelessManager::instance()->removeWindow(windowId);
|
FramelessManager::instance()->removeWindow(windowId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickHelperPrivate::setSystemButton(QQuickItem *item, const QuickGlobal::SystemButtonType buttonType)
|
|
||||||
{
|
|
||||||
Q_ASSERT(item);
|
|
||||||
Q_ASSERT(buttonType != QuickGlobal::SystemButtonType::Unknown);
|
|
||||||
if (!item || (buttonType == QuickGlobal::SystemButtonType::Unknown)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
FramelessQuickHelperData *data = getWindowDataMutable();
|
|
||||||
if (!data) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch (buttonType) {
|
|
||||||
case QuickGlobal::SystemButtonType::WindowIcon:
|
|
||||||
data->windowIconButton = item;
|
|
||||||
break;
|
|
||||||
case QuickGlobal::SystemButtonType::Help:
|
|
||||||
data->contextHelpButton = item;
|
|
||||||
break;
|
|
||||||
case QuickGlobal::SystemButtonType::Minimize:
|
|
||||||
data->minimizeButton = item;
|
|
||||||
break;
|
|
||||||
case QuickGlobal::SystemButtonType::Maximize:
|
|
||||||
case QuickGlobal::SystemButtonType::Restore:
|
|
||||||
data->maximizeButton = item;
|
|
||||||
break;
|
|
||||||
case QuickGlobal::SystemButtonType::Close:
|
|
||||||
data->closeButton = item;
|
|
||||||
break;
|
|
||||||
case QuickGlobal::SystemButtonType::Unknown:
|
|
||||||
Q_UNREACHABLE_RETURN(static_cast<void>(0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickHelperPrivate::setHitTestVisible(QQuickItem *item, const bool visible)
|
|
||||||
{
|
|
||||||
Q_ASSERT(item);
|
|
||||||
if (!item) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
FramelessQuickHelperData *data = getWindowDataMutable();
|
|
||||||
if (!data) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (visible) {
|
|
||||||
data->hitTestVisibleItems.append(item);
|
|
||||||
} else {
|
|
||||||
data->hitTestVisibleItems.removeAll(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickHelperPrivate::setHitTestVisible(const QRect &rect, const bool visible)
|
|
||||||
{
|
|
||||||
Q_ASSERT(rect.isValid());
|
|
||||||
if (!rect.isValid()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
FramelessQuickHelperData *data = getWindowDataMutable();
|
|
||||||
if (!data) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (visible) {
|
|
||||||
data->hitTestVisibleRects.append(rect);
|
|
||||||
} else {
|
|
||||||
data->hitTestVisibleRects.removeAll(rect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickHelperPrivate::setHitTestVisible(QObject *object, const bool visible)
|
|
||||||
{
|
|
||||||
Q_ASSERT(object);
|
|
||||||
if (!object) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const auto item = qobject_cast<QQuickItem *>(object);
|
|
||||||
Q_ASSERT(item);
|
|
||||||
if (!item) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setHitTestVisible(item, visible);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickHelperPrivate::showSystemMenu(const QPoint &pos)
|
|
||||||
{
|
|
||||||
Q_Q(FramelessQuickHelper);
|
|
||||||
const QQuickWindow * const window = q->window();
|
|
||||||
if (!window) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const WId windowId = window->winId();
|
|
||||||
const QPoint nativePos = Utils::toNativeGlobalPosition(window, pos);
|
|
||||||
#ifdef Q_OS_WINDOWS
|
|
||||||
std::ignore = Utils::showSystemMenu(windowId, nativePos, false, &getWindowData()->params);
|
|
||||||
#elif defined(Q_OS_LINUX)
|
|
||||||
Utils::openSystemMenu(windowId, nativePos);
|
|
||||||
#else
|
|
||||||
Q_UNUSED(windowId);
|
|
||||||
Q_UNUSED(nativePos);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickHelperPrivate::windowStartSystemMove2(const QPoint &pos)
|
|
||||||
{
|
|
||||||
Q_Q(FramelessQuickHelper);
|
|
||||||
QQuickWindow * const window = q->window();
|
|
||||||
if (!window) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
std::ignore = Utils::startSystemMove(window, pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickHelperPrivate::windowStartSystemResize2(const Qt::Edges edges, const QPoint &pos)
|
|
||||||
{
|
|
||||||
Q_Q(FramelessQuickHelper);
|
|
||||||
QQuickWindow * const window = q->window();
|
|
||||||
if (!window) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (edges == Qt::Edges{}) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
std::ignore = Utils::startSystemResize(window, edges, pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickHelperPrivate::moveWindowToDesktopCenter()
|
|
||||||
{
|
|
||||||
Q_Q(FramelessQuickHelper);
|
|
||||||
QQuickWindow * const window = q->window();
|
|
||||||
if (!window) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Utils::moveWindowToDesktopCenter(&getWindowData()->params, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickHelperPrivate::bringWindowToFront()
|
|
||||||
{
|
|
||||||
Q_Q(FramelessQuickHelper);
|
|
||||||
QQuickWindow * const window = q->window();
|
|
||||||
if (!window) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#ifdef Q_OS_WINDOWS
|
|
||||||
std::ignore = Utils::bringWindowToFront(window->winId());
|
|
||||||
#else
|
|
||||||
if (window->visibility() == QQuickWindow::Hidden) {
|
|
||||||
window->show();
|
|
||||||
}
|
|
||||||
if (window->visibility() == QQuickWindow::Minimized) {
|
|
||||||
# if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
|
||||||
window->setWindowStates(window->windowStates() & ~Qt::WindowMinimized);
|
|
||||||
# else
|
|
||||||
window->showNormal();
|
|
||||||
# endif
|
|
||||||
}
|
|
||||||
window->raise();
|
|
||||||
window->requestActivate();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FramelessQuickHelperPrivate::isWindowFixedSize() const
|
|
||||||
{
|
|
||||||
Q_Q(const FramelessQuickHelper);
|
|
||||||
const QQuickWindow * const window = q->window();
|
|
||||||
if (!window) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (window->flags() & Qt::MSWindowsFixedSizeDialogHint) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
const QSize minSize = window->minimumSize();
|
|
||||||
const QSize maxSize = window->maximumSize();
|
|
||||||
if (!minSize.isEmpty() && !maxSize.isEmpty() && (minSize == maxSize)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickHelperPrivate::setWindowFixedSize(const bool value)
|
|
||||||
{
|
|
||||||
Q_Q(FramelessQuickHelper);
|
|
||||||
QQuickWindow * const window = q->window();
|
|
||||||
if (!window) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isWindowFixedSize() == value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (value) {
|
|
||||||
const QSize size = window->size();
|
|
||||||
window->setMinimumSize(size);
|
|
||||||
window->setMaximumSize(size);
|
|
||||||
} else {
|
|
||||||
window->setMinimumSize(kDefaultWindowSize);
|
|
||||||
window->setMaximumSize(QSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX));
|
|
||||||
}
|
|
||||||
#ifdef Q_OS_WINDOWS
|
|
||||||
std::ignore = Utils::setAeroSnappingEnabled(window->winId(), !value);
|
|
||||||
#endif
|
|
||||||
emitSignalForAllInstances("windowFixedSizeChanged");
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickHelperPrivate::emitSignalForAllInstances(const char *signal)
|
void FramelessQuickHelperPrivate::emitSignalForAllInstances(const char *signal)
|
||||||
{
|
{
|
||||||
Q_ASSERT(signal);
|
Q_ASSERT(signal);
|
||||||
|
@ -479,50 +232,6 @@ void FramelessQuickHelperPrivate::emitSignalForAllInstances(const char *signal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FramelessQuickHelperPrivate::isBlurBehindWindowEnabled() const
|
|
||||||
{
|
|
||||||
return m_blurBehindWindowEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickHelperPrivate::setBlurBehindWindowEnabled(const bool value, const QColor &color)
|
|
||||||
{
|
|
||||||
Q_Q(FramelessQuickHelper);
|
|
||||||
QQuickWindow * const window = q->window();
|
|
||||||
if (!window) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (m_blurBehindWindowEnabled == value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (Utils::isBlurBehindWindowSupported()) {
|
|
||||||
QuickGlobal::BlurMode mode = QuickGlobal::BlurMode::Disable;
|
|
||||||
if (value) {
|
|
||||||
if (!m_savedWindowBackgroundColor.isValid()) {
|
|
||||||
m_savedWindowBackgroundColor = window->color();
|
|
||||||
}
|
|
||||||
window->setColor(kDefaultTransparentColor);
|
|
||||||
mode = QuickGlobal::BlurMode::Default;
|
|
||||||
} else {
|
|
||||||
if (m_savedWindowBackgroundColor.isValid()) {
|
|
||||||
window->setColor(m_savedWindowBackgroundColor);
|
|
||||||
m_savedWindowBackgroundColor = {};
|
|
||||||
}
|
|
||||||
mode = QuickGlobal::BlurMode::Disable;
|
|
||||||
}
|
|
||||||
if (Utils::setBlurBehindWindowEnabled(window->winId(),
|
|
||||||
FRAMELESSHELPER_ENUM_QUICK_TO_CORE(BlurMode, mode), color)) {
|
|
||||||
m_blurBehindWindowEnabled = value;
|
|
||||||
emitSignalForAllInstances("blurBehindWindowEnabledChanged");
|
|
||||||
} else {
|
|
||||||
WARNING << "Failed to enable/disable blur behind window.";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
m_blurBehindWindowEnabled = value;
|
|
||||||
findOrCreateMicaMaterial()->setVisible(m_blurBehindWindowEnabled);
|
|
||||||
emitSignalForAllInstances("blurBehindWindowEnabledChanged");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickHelperPrivate::setProperty(const char *name, const QVariant &value)
|
void FramelessQuickHelperPrivate::setProperty(const char *name, const QVariant &value)
|
||||||
{
|
{
|
||||||
Q_ASSERT(name);
|
Q_ASSERT(name);
|
||||||
|
@ -645,30 +354,6 @@ FramelessQuickHelper *FramelessQuickHelperPrivate::findOrCreateFramelessHelper(Q
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FramelessQuickHelperPrivate::isReady() const
|
|
||||||
{
|
|
||||||
return m_qpaReady;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickHelperPrivate::waitForReady()
|
|
||||||
{
|
|
||||||
if (m_qpaReady) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#if 1
|
|
||||||
QEventLoop loop;
|
|
||||||
Q_Q(FramelessQuickHelper);
|
|
||||||
const QMetaObject::Connection connection = connect(
|
|
||||||
q, &FramelessQuickHelper::ready, &loop, &QEventLoop::quit);
|
|
||||||
loop.exec();
|
|
||||||
disconnect(connection);
|
|
||||||
#else
|
|
||||||
while (!m_qpaReady) {
|
|
||||||
QCoreApplication::processEvents();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickHelperPrivate::repaintAllChildren(const quint32 delay) const
|
void FramelessQuickHelperPrivate::repaintAllChildren(const quint32 delay) const
|
||||||
{
|
{
|
||||||
Q_Q(const FramelessQuickHelper);
|
Q_Q(const FramelessQuickHelper);
|
||||||
|
@ -708,15 +393,15 @@ void FramelessQuickHelperPrivate::repaintAllChildren(const quint32 delay) const
|
||||||
|
|
||||||
quint32 FramelessQuickHelperPrivate::readyWaitTime() const
|
quint32 FramelessQuickHelperPrivate::readyWaitTime() const
|
||||||
{
|
{
|
||||||
return m_qpaWaitTime;
|
return qpaWaitTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickHelperPrivate::setReadyWaitTime(const quint32 time)
|
void FramelessQuickHelperPrivate::setReadyWaitTime(const quint32 time)
|
||||||
{
|
{
|
||||||
if (m_qpaWaitTime == time) {
|
if (qpaWaitTime == time) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_qpaWaitTime = time;
|
qpaWaitTime = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect FramelessQuickHelperPrivate::mapItemGeometryToScene(const QQuickItem * const item) const
|
QRect FramelessQuickHelperPrivate::mapItemGeometryToScene(const QQuickItem * const item) const
|
||||||
|
@ -918,8 +603,8 @@ void FramelessQuickHelperPrivate::rebindWindow()
|
||||||
q->setParent(window);
|
q->setParent(window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_extendIntoTitleBar.value_or(true)) {
|
if (extendIntoTitleBar.value_or(true)) {
|
||||||
extendsContentIntoTitleBar(true);
|
q->extendsContentIntoTitleBar(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -948,30 +633,6 @@ FramelessQuickHelper *FramelessQuickHelper::qmlAttachedProperties(QObject *paren
|
||||||
return get(parentObject);
|
return get(parentObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
QQuickItem *FramelessQuickHelper::titleBarItem() const
|
|
||||||
{
|
|
||||||
Q_D(const FramelessQuickHelper);
|
|
||||||
return d->getTitleBarItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FramelessQuickHelper::isWindowFixedSize() const
|
|
||||||
{
|
|
||||||
Q_D(const FramelessQuickHelper);
|
|
||||||
return d->isWindowFixedSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FramelessQuickHelper::isBlurBehindWindowEnabled() const
|
|
||||||
{
|
|
||||||
Q_D(const FramelessQuickHelper);
|
|
||||||
return d->isBlurBehindWindowEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FramelessQuickHelper::isContentExtendedIntoTitleBar() const
|
|
||||||
{
|
|
||||||
Q_D(const FramelessQuickHelper);
|
|
||||||
return d->isContentExtendedIntoTitleBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
QuickMicaMaterial *FramelessQuickHelper::micaMaterial() const
|
QuickMicaMaterial *FramelessQuickHelper::micaMaterial() const
|
||||||
{
|
{
|
||||||
Q_D(const FramelessQuickHelper);
|
Q_D(const FramelessQuickHelper);
|
||||||
|
@ -984,22 +645,88 @@ QuickWindowBorder *FramelessQuickHelper::windowBorder() const
|
||||||
return d->findOrCreateWindowBorder();
|
return d->findOrCreateWindowBorder();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FramelessQuickHelper::isReady() const
|
void FramelessQuickHelper::setHitTestVisible(QQuickItem *item, const bool visible)
|
||||||
{
|
{
|
||||||
Q_D(const FramelessQuickHelper);
|
setHitTestVisible_item(item, visible);
|
||||||
return d->isReady();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickHelper::waitForReady()
|
void FramelessQuickHelper::setHitTestVisible_item(QQuickItem *item, const bool visible)
|
||||||
{
|
{
|
||||||
|
Q_ASSERT(item);
|
||||||
|
if (!item) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Q_D(FramelessQuickHelper);
|
Q_D(FramelessQuickHelper);
|
||||||
d->waitForReady();
|
FramelessQuickHelperData *data = d->getWindowDataMutable();
|
||||||
|
if (!data) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (visible) {
|
||||||
|
data->hitTestVisibleItems.append(item);
|
||||||
|
} else {
|
||||||
|
data->hitTestVisibleItems.removeAll(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FramelessQuickHelper::setHitTestVisible_rect(const QRect &rect, const bool visible)
|
||||||
|
{
|
||||||
|
Q_ASSERT(rect.isValid());
|
||||||
|
if (!rect.isValid()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Q_D(FramelessQuickHelper);
|
||||||
|
FramelessQuickHelperData *data = d->getWindowDataMutable();
|
||||||
|
if (!data) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (visible) {
|
||||||
|
data->hitTestVisibleRects.append(rect);
|
||||||
|
} else {
|
||||||
|
data->hitTestVisibleRects.removeAll(rect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FramelessQuickHelper::setHitTestVisible_object(QObject *object, const bool visible)
|
||||||
|
{
|
||||||
|
Q_ASSERT(object);
|
||||||
|
if (!object) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto item = qobject_cast<QQuickItem *>(object);
|
||||||
|
Q_ASSERT(item);
|
||||||
|
if (!item) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setHitTestVisible_item(item, visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FramelessQuickHelper::isContentExtendedIntoTitleBar() const
|
||||||
|
{
|
||||||
|
Q_D(const FramelessQuickHelper);
|
||||||
|
const FramelessQuickHelperData *data = d->getWindowData();
|
||||||
|
return (data ? data->ready : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickHelper::extendsContentIntoTitleBar(const bool value)
|
void FramelessQuickHelper::extendsContentIntoTitleBar(const bool value)
|
||||||
{
|
{
|
||||||
|
if (isContentExtendedIntoTitleBar() == value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Q_D(FramelessQuickHelper);
|
Q_D(FramelessQuickHelper);
|
||||||
d->extendsContentIntoTitleBar(value);
|
if (value) {
|
||||||
|
d->attach();
|
||||||
|
} else {
|
||||||
|
d->detach();
|
||||||
|
}
|
||||||
|
d->extendIntoTitleBar = value;
|
||||||
|
d->emitSignalForAllInstances("extendsContentIntoTitleBarChanged");
|
||||||
|
}
|
||||||
|
|
||||||
|
QQuickItem *FramelessQuickHelper::titleBarItem() const
|
||||||
|
{
|
||||||
|
Q_D(const FramelessQuickHelper);
|
||||||
|
const FramelessQuickHelperData *data = d->getWindowData();
|
||||||
|
return (data ? data->titleBarItem : nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickHelper::setTitleBarItem(QQuickItem *value)
|
void FramelessQuickHelper::setTitleBarItem(QQuickItem *value)
|
||||||
|
@ -1009,7 +736,12 @@ void FramelessQuickHelper::setTitleBarItem(QQuickItem *value)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Q_D(FramelessQuickHelper);
|
Q_D(FramelessQuickHelper);
|
||||||
d->setTitleBarItem(value);
|
FramelessQuickHelperData *data = d->getWindowDataMutable();
|
||||||
|
if (!data || (data->titleBarItem == value)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data->titleBarItem = value;
|
||||||
|
d->emitSignalForAllInstances("titleBarItemChanged");
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickHelper::setSystemButton(QQuickItem *item, const QuickGlobal::SystemButtonType buttonType)
|
void FramelessQuickHelper::setSystemButton(QQuickItem *item, const QuickGlobal::SystemButtonType buttonType)
|
||||||
|
@ -1020,87 +752,212 @@ void FramelessQuickHelper::setSystemButton(QQuickItem *item, const QuickGlobal::
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Q_D(FramelessQuickHelper);
|
Q_D(FramelessQuickHelper);
|
||||||
d->setSystemButton(item, buttonType);
|
FramelessQuickHelperData *data = d->getWindowDataMutable();
|
||||||
}
|
if (!data) {
|
||||||
|
|
||||||
void FramelessQuickHelper::setHitTestVisible(QQuickItem *item, const bool visible)
|
|
||||||
{
|
|
||||||
setHitTestVisible_item(item, visible);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickHelper::setHitTestVisible_rect(const QRect &rect, const bool visible)
|
|
||||||
{
|
|
||||||
Q_ASSERT(rect.isValid());
|
|
||||||
if (!rect.isValid()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Q_D(FramelessQuickHelper);
|
switch (buttonType) {
|
||||||
d->setHitTestVisible(rect, visible);
|
case QuickGlobal::SystemButtonType::WindowIcon:
|
||||||
|
data->windowIconButton = item;
|
||||||
|
break;
|
||||||
|
case QuickGlobal::SystemButtonType::Help:
|
||||||
|
data->contextHelpButton = item;
|
||||||
|
break;
|
||||||
|
case QuickGlobal::SystemButtonType::Minimize:
|
||||||
|
data->minimizeButton = item;
|
||||||
|
break;
|
||||||
|
case QuickGlobal::SystemButtonType::Maximize:
|
||||||
|
case QuickGlobal::SystemButtonType::Restore:
|
||||||
|
data->maximizeButton = item;
|
||||||
|
break;
|
||||||
|
case QuickGlobal::SystemButtonType::Close:
|
||||||
|
data->closeButton = item;
|
||||||
|
break;
|
||||||
|
case QuickGlobal::SystemButtonType::Unknown:
|
||||||
|
Q_UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickHelper::setHitTestVisible_object(QObject *object, const bool visible)
|
|
||||||
{
|
|
||||||
Q_ASSERT(object);
|
|
||||||
if (!object) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Q_D(FramelessQuickHelper);
|
|
||||||
d->setHitTestVisible(object, visible);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickHelper::setHitTestVisible_item(QQuickItem *item, const bool visible)
|
|
||||||
{
|
|
||||||
Q_ASSERT(item);
|
|
||||||
if (!item) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Q_D(FramelessQuickHelper);
|
|
||||||
d->setHitTestVisible(item, visible);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickHelper::showSystemMenu(const QPoint &pos)
|
void FramelessQuickHelper::showSystemMenu(const QPoint &pos)
|
||||||
{
|
{
|
||||||
|
const QQuickWindow * const w = window();
|
||||||
|
if (!w) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const WId windowId = w->winId();
|
||||||
|
const QPoint nativePos = Utils::toNativeGlobalPosition(w, pos);
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
Q_D(FramelessQuickHelper);
|
Q_D(FramelessQuickHelper);
|
||||||
d->showSystemMenu(pos);
|
std::ignore = Utils::showSystemMenu(windowId, nativePos, false, &d->getWindowData()->params);
|
||||||
|
#elif defined(Q_OS_LINUX)
|
||||||
|
Utils::openSystemMenu(windowId, nativePos);
|
||||||
|
#else
|
||||||
|
Q_UNUSED(windowId);
|
||||||
|
Q_UNUSED(nativePos);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickHelper::windowStartSystemMove2(const QPoint &pos)
|
void FramelessQuickHelper::windowStartSystemMove2(const QPoint &pos)
|
||||||
{
|
{
|
||||||
Q_D(FramelessQuickHelper);
|
QQuickWindow * const w = window();
|
||||||
d->windowStartSystemMove2(pos);
|
if (!w) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::ignore = Utils::startSystemMove(w, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickHelper::windowStartSystemResize2(const Qt::Edges edges, const QPoint &pos)
|
void FramelessQuickHelper::windowStartSystemResize2(const Qt::Edges edges, const QPoint &pos)
|
||||||
{
|
{
|
||||||
|
QQuickWindow * const w = window();
|
||||||
|
if (!w) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (edges == Qt::Edges{}) {
|
if (edges == Qt::Edges{}) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Q_D(FramelessQuickHelper);
|
std::ignore = Utils::startSystemResize(w, edges, pos);
|
||||||
d->windowStartSystemResize2(edges, pos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickHelper::moveWindowToDesktopCenter()
|
void FramelessQuickHelper::moveWindowToDesktopCenter()
|
||||||
{
|
{
|
||||||
|
if (!window()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Q_D(FramelessQuickHelper);
|
Q_D(FramelessQuickHelper);
|
||||||
d->moveWindowToDesktopCenter();
|
Utils::moveWindowToDesktopCenter(&d->getWindowData()->params, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickHelper::bringWindowToFront()
|
void FramelessQuickHelper::bringWindowToFront()
|
||||||
{
|
{
|
||||||
Q_D(FramelessQuickHelper);
|
QQuickWindow * const w = window();
|
||||||
d->bringWindowToFront();
|
if (!w) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
|
std::ignore = Utils::bringWindowToFront(w->winId());
|
||||||
|
#else
|
||||||
|
if (w->visibility() == QQuickWindow::Hidden) {
|
||||||
|
w->show();
|
||||||
|
}
|
||||||
|
if (w->visibility() == QQuickWindow::Minimized) {
|
||||||
|
# if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||||
|
w->setWindowStates(w->windowStates() & ~Qt::WindowMinimized);
|
||||||
|
# else
|
||||||
|
w->showNormal();
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
w->raise();
|
||||||
|
w->requestActivate();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FramelessQuickHelper::isWindowFixedSize() const
|
||||||
|
{
|
||||||
|
const QQuickWindow * const w = window();
|
||||||
|
if (!w) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (w->flags() & Qt::MSWindowsFixedSizeDialogHint) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
const QSize minSize = w->minimumSize();
|
||||||
|
const QSize maxSize = w->maximumSize();
|
||||||
|
if (!minSize.isEmpty() && !maxSize.isEmpty() && (minSize == maxSize)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickHelper::setWindowFixedSize(const bool value)
|
void FramelessQuickHelper::setWindowFixedSize(const bool value)
|
||||||
{
|
{
|
||||||
|
QQuickWindow * const w = window();
|
||||||
|
if (!w) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (isWindowFixedSize() == value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (value) {
|
||||||
|
const QSize size = w->size();
|
||||||
|
w->setMinimumSize(size);
|
||||||
|
w->setMaximumSize(size);
|
||||||
|
} else {
|
||||||
|
w->setMinimumSize(kDefaultWindowSize);
|
||||||
|
w->setMaximumSize(QSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX));
|
||||||
|
}
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
|
std::ignore = Utils::setAeroSnappingEnabled(w->winId(), !value);
|
||||||
|
#endif
|
||||||
Q_D(FramelessQuickHelper);
|
Q_D(FramelessQuickHelper);
|
||||||
d->setWindowFixedSize(value);
|
d->emitSignalForAllInstances("windowFixedSizeChanged");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FramelessQuickHelper::isBlurBehindWindowEnabled() const
|
||||||
|
{
|
||||||
|
Q_D(const FramelessQuickHelper);
|
||||||
|
return d->blurBehindWindowEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickHelper::setBlurBehindWindowEnabled(const bool value)
|
void FramelessQuickHelper::setBlurBehindWindowEnabled(const bool value)
|
||||||
{
|
{
|
||||||
|
QQuickWindow * const w = window();
|
||||||
|
if (!w) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Q_D(FramelessQuickHelper);
|
Q_D(FramelessQuickHelper);
|
||||||
d->setBlurBehindWindowEnabled(value, {});
|
if (d->blurBehindWindowEnabled == value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Utils::isBlurBehindWindowSupported()) {
|
||||||
|
QuickGlobal::BlurMode mode = QuickGlobal::BlurMode::Disable;
|
||||||
|
if (value) {
|
||||||
|
if (!d->savedWindowBackgroundColor.isValid()) {
|
||||||
|
d->savedWindowBackgroundColor = w->color();
|
||||||
|
}
|
||||||
|
w->setColor(kDefaultTransparentColor);
|
||||||
|
mode = QuickGlobal::BlurMode::Default;
|
||||||
|
} else {
|
||||||
|
if (d->savedWindowBackgroundColor.isValid()) {
|
||||||
|
w->setColor(d->savedWindowBackgroundColor);
|
||||||
|
d->savedWindowBackgroundColor = {};
|
||||||
|
}
|
||||||
|
mode = QuickGlobal::BlurMode::Disable;
|
||||||
|
}
|
||||||
|
if (Utils::setBlurBehindWindowEnabled(w->winId(), FRAMELESSHELPER_ENUM_QUICK_TO_CORE(BlurMode, mode), {})) {
|
||||||
|
d->blurBehindWindowEnabled = value;
|
||||||
|
d->emitSignalForAllInstances("blurBehindWindowEnabledChanged");
|
||||||
|
} else {
|
||||||
|
WARNING << "Failed to enable/disable blur behind window.";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
d->blurBehindWindowEnabled = value;
|
||||||
|
micaMaterial()->setVisible(d->blurBehindWindowEnabled);
|
||||||
|
d->emitSignalForAllInstances("blurBehindWindowEnabledChanged");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FramelessQuickHelper::isReady() const
|
||||||
|
{
|
||||||
|
Q_D(const FramelessQuickHelper);
|
||||||
|
return d->qpaReady;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FramelessQuickHelper::waitForReady()
|
||||||
|
{
|
||||||
|
Q_D(FramelessQuickHelper);
|
||||||
|
if (d->qpaReady) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#if 1
|
||||||
|
QEventLoop loop{};
|
||||||
|
const QMetaObject::Connection connection = connect(this, &FramelessQuickHelper::ready, &loop, &QEventLoop::quit);
|
||||||
|
loop.exec();
|
||||||
|
disconnect(connection);
|
||||||
|
#else
|
||||||
|
while (!d->qpaReady) {
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickHelper::itemChange(const ItemChange change, const ItemChangeData &value)
|
void FramelessQuickHelper::itemChange(const ItemChange change, const ItemChangeData &value)
|
||||||
|
|
|
@ -59,7 +59,6 @@ FramelessQuickWindowPrivate::FramelessQuickWindowPrivate(FramelessQuickWindow *q
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
q_ptr = q;
|
q_ptr = q;
|
||||||
initialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FramelessQuickWindowPrivate::~FramelessQuickWindowPrivate() = default;
|
FramelessQuickWindowPrivate::~FramelessQuickWindowPrivate() = default;
|
||||||
|
@ -82,156 +81,90 @@ const FramelessQuickWindowPrivate *FramelessQuickWindowPrivate::get(const Framel
|
||||||
return pub->d_func();
|
return pub->d_func();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FramelessQuickWindowPrivate::isHidden() const
|
|
||||||
{
|
|
||||||
Q_Q(const FramelessQuickWindow);
|
|
||||||
return (q->visibility() == FramelessQuickWindow::Hidden);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FramelessQuickWindowPrivate::isNormal() const
|
|
||||||
{
|
|
||||||
Q_Q(const FramelessQuickWindow);
|
|
||||||
return (q->visibility() == FramelessQuickWindow::Windowed);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FramelessQuickWindowPrivate::isMinimized() const
|
|
||||||
{
|
|
||||||
Q_Q(const FramelessQuickWindow);
|
|
||||||
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);
|
|
||||||
return (isMaximized() || (q->visibility() == FramelessQuickWindow::FullScreen));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FramelessQuickWindowPrivate::isFullScreen() const
|
|
||||||
{
|
|
||||||
Q_Q(const FramelessQuickWindow);
|
|
||||||
return (q->visibility() == FramelessQuickWindow::FullScreen);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickWindowPrivate::showMinimized2()
|
|
||||||
{
|
|
||||||
Q_Q(FramelessQuickWindow);
|
|
||||||
#ifdef Q_OS_WINDOWS
|
|
||||||
// Work-around a QtQuick bug: https://bugreports.qt.io/browse/QTBUG-69711
|
|
||||||
// Don't use "SW_SHOWMINIMIZED" because it will activate the current window
|
|
||||||
// instead of the next window in the Z order, which is not the default behavior
|
|
||||||
// of native Win32 applications.
|
|
||||||
ShowWindow(reinterpret_cast<HWND>(q->winId()), SW_MINIMIZE);
|
|
||||||
#else
|
|
||||||
q->showMinimized();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickWindowPrivate::toggleMaximized()
|
|
||||||
{
|
|
||||||
Q_Q(FramelessQuickWindow);
|
|
||||||
if (isMaximized()) {
|
|
||||||
q->showNormal();
|
|
||||||
} else {
|
|
||||||
q->showMaximized();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickWindowPrivate::toggleFullScreen()
|
|
||||||
{
|
|
||||||
Q_Q(FramelessQuickWindow);
|
|
||||||
if (isFullScreen()) {
|
|
||||||
q->setVisibility(m_savedVisibility);
|
|
||||||
} else {
|
|
||||||
m_savedVisibility = q->visibility();
|
|
||||||
q->showFullScreen();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickWindowPrivate::initialize()
|
|
||||||
{
|
|
||||||
Q_Q(FramelessQuickWindow);
|
|
||||||
QQuickItem * const rootItem = q->contentItem();
|
|
||||||
FramelessQuickHelper::get(rootItem)->extendsContentIntoTitleBar();
|
|
||||||
m_windowBorder = new QuickWindowBorder;
|
|
||||||
m_windowBorder->setParent(rootItem);
|
|
||||||
m_windowBorder->setParentItem(rootItem);
|
|
||||||
m_windowBorder->setZ(999); // Make sure it always stays on the top.
|
|
||||||
QQuickItemPrivate::get(m_windowBorder)->anchors()->setFill(rootItem);
|
|
||||||
connect(q, &FramelessQuickWindow::visibilityChanged, q, [q](){
|
|
||||||
Q_EMIT q->hiddenChanged();
|
|
||||||
Q_EMIT q->normalChanged();
|
|
||||||
Q_EMIT q->minimizedChanged();
|
|
||||||
Q_EMIT q->maximizedChanged();
|
|
||||||
Q_EMIT q->zoomedChanged();
|
|
||||||
Q_EMIT q->fullScreenChanged();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
FramelessQuickWindow::FramelessQuickWindow(QWindow *parent)
|
FramelessQuickWindow::FramelessQuickWindow(QWindow *parent)
|
||||||
: QQuickWindowQmlImpl(parent), d_ptr(new FramelessQuickWindowPrivate(this))
|
: QQuickWindowQmlImpl(parent), d_ptr(new FramelessQuickWindowPrivate(this))
|
||||||
{
|
{
|
||||||
|
QQuickItem * const rootItem = contentItem();
|
||||||
|
FramelessQuickHelper::get(rootItem)->extendsContentIntoTitleBar();
|
||||||
|
Q_D(FramelessQuickWindow);
|
||||||
|
d->windowBorder = new QuickWindowBorder;
|
||||||
|
d->windowBorder->setParent(rootItem);
|
||||||
|
d->windowBorder->setParentItem(rootItem);
|
||||||
|
d->windowBorder->setZ(999); // Make sure it always stays on the top.
|
||||||
|
QQuickItemPrivate::get(d->windowBorder)->anchors()->setFill(rootItem);
|
||||||
|
connect(this, &FramelessQuickWindow::visibilityChanged, this, [this](){
|
||||||
|
Q_EMIT hiddenChanged();
|
||||||
|
Q_EMIT normalChanged();
|
||||||
|
Q_EMIT minimizedChanged();
|
||||||
|
Q_EMIT maximizedChanged();
|
||||||
|
Q_EMIT zoomedChanged();
|
||||||
|
Q_EMIT fullScreenChanged();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
FramelessQuickWindow::~FramelessQuickWindow() = default;
|
FramelessQuickWindow::~FramelessQuickWindow() = default;
|
||||||
|
|
||||||
bool FramelessQuickWindow::isHidden() const
|
bool FramelessQuickWindow::isHidden() const
|
||||||
{
|
{
|
||||||
Q_D(const FramelessQuickWindow);
|
return (visibility() == FramelessQuickWindow::Hidden);
|
||||||
return d->isHidden();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FramelessQuickWindow::isNormal() const
|
bool FramelessQuickWindow::isNormal() const
|
||||||
{
|
{
|
||||||
Q_D(const FramelessQuickWindow);
|
return (visibility() == FramelessQuickWindow::Windowed);
|
||||||
return d->isNormal();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FramelessQuickWindow::isMinimized() const
|
bool FramelessQuickWindow::isMinimized() const
|
||||||
{
|
{
|
||||||
Q_D(const FramelessQuickWindow);
|
return (visibility() == FramelessQuickWindow::Minimized);
|
||||||
return d->isMinimized();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FramelessQuickWindow::isMaximized() const
|
bool FramelessQuickWindow::isMaximized() const
|
||||||
{
|
{
|
||||||
Q_D(const FramelessQuickWindow);
|
return (visibility() == FramelessQuickWindow::Maximized);
|
||||||
return d->isMaximized();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FramelessQuickWindow::isZoomed() const
|
bool FramelessQuickWindow::isZoomed() const
|
||||||
{
|
{
|
||||||
Q_D(const FramelessQuickWindow);
|
return (isMaximized() || (visibility() == FramelessQuickWindow::FullScreen));
|
||||||
return d->isZoomed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FramelessQuickWindow::isFullScreen() const
|
bool FramelessQuickWindow::isFullScreen() const
|
||||||
{
|
{
|
||||||
Q_D(const FramelessQuickWindow);
|
return (visibility() == FramelessQuickWindow::FullScreen);
|
||||||
return d->isFullScreen();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickWindow::showMinimized2()
|
void FramelessQuickWindow::showMinimized2()
|
||||||
{
|
{
|
||||||
Q_D(FramelessQuickWindow);
|
#ifdef Q_OS_WINDOWS
|
||||||
d->showMinimized2();
|
// Work-around a QtQuick bug: https://bugreports.qt.io/browse/QTBUG-69711
|
||||||
|
// Don't use "SW_SHOWMINIMIZED" because it will activate the current window
|
||||||
|
// instead of the next window in the Z order, which is not the default behavior
|
||||||
|
// of native Win32 applications.
|
||||||
|
::ShowWindow(reinterpret_cast<HWND>(winId()), SW_MINIMIZE);
|
||||||
|
#else
|
||||||
|
showMinimized();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickWindow::toggleMaximized()
|
void FramelessQuickWindow::toggleMaximized()
|
||||||
{
|
{
|
||||||
Q_D(FramelessQuickWindow);
|
if (isMaximized()) {
|
||||||
d->toggleMaximized();
|
showNormal();
|
||||||
|
} else {
|
||||||
|
showMaximized();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickWindow::toggleFullScreen()
|
void FramelessQuickWindow::toggleFullScreen()
|
||||||
{
|
{
|
||||||
Q_D(FramelessQuickWindow);
|
Q_D(FramelessQuickWindow);
|
||||||
d->toggleFullScreen();
|
if (isFullScreen()) {
|
||||||
|
setVisibility(d->savedVisibility);
|
||||||
|
} else {
|
||||||
|
d->savedVisibility = visibility();
|
||||||
|
showFullScreen();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickWindow::classBegin()
|
void FramelessQuickWindow::classBegin()
|
||||||
|
|
|
@ -60,7 +60,6 @@ QuickImageItemPrivate::QuickImageItemPrivate(QuickImageItem *q) : QObject(q)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
q_ptr = q;
|
q_ptr = q;
|
||||||
initialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QuickImageItemPrivate::~QuickImageItemPrivate() = default;
|
QuickImageItemPrivate::~QuickImageItemPrivate() = default;
|
||||||
|
@ -83,71 +82,6 @@ const QuickImageItemPrivate *QuickImageItemPrivate::get(const QuickImageItem *q)
|
||||||
return q->d_func();
|
return q->d_func();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickImageItemPrivate::paint(QPainter *painter) const
|
|
||||||
{
|
|
||||||
Q_ASSERT(painter);
|
|
||||||
if (!painter) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!m_source.isValid() || m_source.isNull()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
painter->save();
|
|
||||||
painter->setRenderHints(QPainter::Antialiasing |
|
|
||||||
QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
|
|
||||||
switch (m_source.userType()) {
|
|
||||||
case QMetaType::QUrl:
|
|
||||||
fromUrl(m_source.toUrl(), painter);
|
|
||||||
break;
|
|
||||||
case QMetaType::QString:
|
|
||||||
fromString(m_source.toString(), painter);
|
|
||||||
break;
|
|
||||||
case QMetaType::QImage:
|
|
||||||
fromImage(qvariant_cast<QImage>(m_source), painter);
|
|
||||||
break;
|
|
||||||
case QMetaType::QPixmap:
|
|
||||||
fromPixmap(qvariant_cast<QPixmap>(m_source), painter);
|
|
||||||
break;
|
|
||||||
case QMetaType::QIcon:
|
|
||||||
fromIcon(qvariant_cast<QIcon>(m_source), painter);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
WARNING << "Unsupported type:" << m_source.typeName();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
painter->restore();
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant QuickImageItemPrivate::source() const
|
|
||||||
{
|
|
||||||
return m_source;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickImageItemPrivate::setSource(const QVariant &value)
|
|
||||||
{
|
|
||||||
Q_ASSERT(value.isValid());
|
|
||||||
Q_ASSERT(!value.isNull());
|
|
||||||
if (!value.isValid() || value.isNull()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (m_source == value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_source = value;
|
|
||||||
Q_Q(QuickImageItem);
|
|
||||||
q->update();
|
|
||||||
Q_EMIT q->sourceChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickImageItemPrivate::initialize()
|
|
||||||
{
|
|
||||||
Q_Q(QuickImageItem);
|
|
||||||
q->setAntialiasing(true);
|
|
||||||
q->setSmooth(true);
|
|
||||||
q->setMipmap(true);
|
|
||||||
q->setClip(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickImageItemPrivate::fromUrl(const QUrl &value, QPainter *painter) const
|
void QuickImageItemPrivate::fromUrl(const QUrl &value, QPainter *painter) const
|
||||||
{
|
{
|
||||||
Q_ASSERT(value.isValid());
|
Q_ASSERT(value.isValid());
|
||||||
|
@ -226,26 +160,70 @@ QRectF QuickImageItemPrivate::paintArea() const
|
||||||
QuickImageItem::QuickImageItem(QQuickItem *parent)
|
QuickImageItem::QuickImageItem(QQuickItem *parent)
|
||||||
: QQuickPaintedItem(parent), d_ptr(new QuickImageItemPrivate(this))
|
: QQuickPaintedItem(parent), d_ptr(new QuickImageItemPrivate(this))
|
||||||
{
|
{
|
||||||
|
setAntialiasing(true);
|
||||||
|
setSmooth(true);
|
||||||
|
setMipmap(true);
|
||||||
|
setClip(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
QuickImageItem::~QuickImageItem() = default;
|
QuickImageItem::~QuickImageItem() = default;
|
||||||
|
|
||||||
void QuickImageItem::paint(QPainter *painter)
|
void QuickImageItem::paint(QPainter *painter)
|
||||||
{
|
{
|
||||||
|
Q_ASSERT(painter);
|
||||||
|
if (!painter) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Q_D(QuickImageItem);
|
Q_D(QuickImageItem);
|
||||||
d->paint(painter);
|
if (!d->source.isValid() || d->source.isNull()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
painter->save();
|
||||||
|
painter->setRenderHints(QPainter::Antialiasing |
|
||||||
|
QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
|
||||||
|
switch (d->source.userType()) {
|
||||||
|
case QMetaType::QUrl:
|
||||||
|
d->fromUrl(d->source.toUrl(), painter);
|
||||||
|
break;
|
||||||
|
case QMetaType::QString:
|
||||||
|
d->fromString(d->source.toString(), painter);
|
||||||
|
break;
|
||||||
|
case QMetaType::QImage:
|
||||||
|
d->fromImage(qvariant_cast<QImage>(d->source), painter);
|
||||||
|
break;
|
||||||
|
case QMetaType::QPixmap:
|
||||||
|
d->fromPixmap(qvariant_cast<QPixmap>(d->source), painter);
|
||||||
|
break;
|
||||||
|
case QMetaType::QIcon:
|
||||||
|
d->fromIcon(qvariant_cast<QIcon>(d->source), painter);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
WARNING << "Unsupported type:" << d->source.typeName();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant QuickImageItem::source() const
|
QVariant QuickImageItem::source() const
|
||||||
{
|
{
|
||||||
Q_D(const QuickImageItem);
|
Q_D(const QuickImageItem);
|
||||||
return d->source();
|
return d->source;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickImageItem::setSource(const QVariant &value)
|
void QuickImageItem::setSource(const QVariant &value)
|
||||||
{
|
{
|
||||||
|
Q_ASSERT(value.isValid());
|
||||||
|
Q_ASSERT(!value.isNull());
|
||||||
|
if (!value.isValid() || value.isNull()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Q_D(QuickImageItem);
|
Q_D(QuickImageItem);
|
||||||
d->setSource(value);
|
if (d->source == value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
d->source = value;
|
||||||
|
update();
|
||||||
|
Q_EMIT sourceChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickImageItem::classBegin()
|
void QuickImageItem::classBegin()
|
||||||
|
|
|
@ -102,13 +102,13 @@ void QuickMicaMaterialPrivate::initialize()
|
||||||
// we don't need it anyway and it can improve the general performance as well.
|
// we don't need it anyway and it can improve the general performance as well.
|
||||||
q->setFillColor(QColor{});
|
q->setFillColor(QColor{});
|
||||||
|
|
||||||
m_micaMaterial = new MicaMaterial(this);
|
micaMaterial = new MicaMaterial(this);
|
||||||
connect(m_micaMaterial, &MicaMaterial::tintColorChanged, q, &QuickMicaMaterial::tintColorChanged);
|
connect(micaMaterial, &MicaMaterial::tintColorChanged, q, &QuickMicaMaterial::tintColorChanged);
|
||||||
connect(m_micaMaterial, &MicaMaterial::tintOpacityChanged, q, &QuickMicaMaterial::tintOpacityChanged);
|
connect(micaMaterial, &MicaMaterial::tintOpacityChanged, q, &QuickMicaMaterial::tintOpacityChanged);
|
||||||
connect(m_micaMaterial, &MicaMaterial::fallbackColorChanged, q, &QuickMicaMaterial::fallbackColorChanged);
|
connect(micaMaterial, &MicaMaterial::fallbackColorChanged, q, &QuickMicaMaterial::fallbackColorChanged);
|
||||||
connect(m_micaMaterial, &MicaMaterial::noiseOpacityChanged, q, &QuickMicaMaterial::noiseOpacityChanged);
|
connect(micaMaterial, &MicaMaterial::noiseOpacityChanged, q, &QuickMicaMaterial::noiseOpacityChanged);
|
||||||
connect(m_micaMaterial, &MicaMaterial::fallbackEnabledChanged, q, &QuickMicaMaterial::fallbackEnabledChanged);
|
connect(micaMaterial, &MicaMaterial::fallbackEnabledChanged, q, &QuickMicaMaterial::fallbackEnabledChanged);
|
||||||
connect(m_micaMaterial, &MicaMaterial::shouldRedraw, q, [q](){ q->update(); });
|
connect(micaMaterial, &MicaMaterial::shouldRedraw, q, [q](){ q->update(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickMicaMaterialPrivate::rebindWindow()
|
void QuickMicaMaterialPrivate::rebindWindow()
|
||||||
|
@ -125,39 +125,21 @@ void QuickMicaMaterialPrivate::rebindWindow()
|
||||||
QQuickItemPrivate::get(q)->anchors()->setFill(rootItem);
|
QQuickItemPrivate::get(q)->anchors()->setFill(rootItem);
|
||||||
#endif // FRAMELESSHELPER_QUICK_NO_PRIVATE
|
#endif // FRAMELESSHELPER_QUICK_NO_PRIVATE
|
||||||
q->setZ(-999); // Make sure we always stays on the bottom most place.
|
q->setZ(-999); // Make sure we always stays on the bottom most place.
|
||||||
if (m_rootWindowXChangedConnection) {
|
if (rootWindowXChangedConnection) {
|
||||||
disconnect(m_rootWindowXChangedConnection);
|
disconnect(rootWindowXChangedConnection);
|
||||||
m_rootWindowXChangedConnection = {};
|
rootWindowXChangedConnection = {};
|
||||||
}
|
}
|
||||||
if (m_rootWindowYChangedConnection) {
|
if (rootWindowYChangedConnection) {
|
||||||
disconnect(m_rootWindowYChangedConnection);
|
disconnect(rootWindowYChangedConnection);
|
||||||
m_rootWindowYChangedConnection = {};
|
rootWindowYChangedConnection = {};
|
||||||
}
|
}
|
||||||
if (m_rootWindowActiveChangedConnection) {
|
if (rootWindowActiveChangedConnection) {
|
||||||
disconnect(m_rootWindowActiveChangedConnection);
|
disconnect(rootWindowActiveChangedConnection);
|
||||||
m_rootWindowActiveChangedConnection = {};
|
rootWindowActiveChangedConnection = {};
|
||||||
}
|
}
|
||||||
m_rootWindowXChangedConnection = connect(window, &QQuickWindow::xChanged, q, [q](){ q->update(); });
|
rootWindowXChangedConnection = connect(window, &QQuickWindow::xChanged, q, [q](){ q->update(); });
|
||||||
m_rootWindowYChangedConnection = connect(window, &QQuickWindow::yChanged, q, [q](){ q->update(); });
|
rootWindowYChangedConnection = connect(window, &QQuickWindow::yChanged, q, [q](){ q->update(); });
|
||||||
m_rootWindowActiveChangedConnection = connect(window, &QQuickWindow::activeChanged, q, [q](){ q->update(); });
|
rootWindowActiveChangedConnection = connect(window, &QQuickWindow::activeChanged, q, [q](){ q->update(); });
|
||||||
}
|
|
||||||
|
|
||||||
void QuickMicaMaterialPrivate::repaint(QPainter *painter)
|
|
||||||
{
|
|
||||||
Q_ASSERT(painter);
|
|
||||||
Q_ASSERT(m_micaMaterial);
|
|
||||||
if (!painter || !m_micaMaterial) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Q_Q(QuickMicaMaterial);
|
|
||||||
const bool isActive = q->window() ? q->window()->isActive() : false;
|
|
||||||
const QPoint originPoint = q->mapToGlobal(QPointF{ 0, 0 }).toPoint();
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
|
||||||
const QSize size = q->size().toSize();
|
|
||||||
#else // (QT_VERSION < QT_VERSION_CHECK(5, 10, 0))
|
|
||||||
const QSize size = QSizeF{ q->width(), q->height() }.toSize();
|
|
||||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
|
||||||
m_micaMaterial->paint(painter, QRect{ originPoint, size }, isActive);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QuickMicaMaterial::QuickMicaMaterial(QQuickItem *parent)
|
QuickMicaMaterial::QuickMicaMaterial(QQuickItem *parent)
|
||||||
|
@ -174,67 +156,74 @@ void QuickMicaMaterial::paint(QPainter *painter)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Q_D(QuickMicaMaterial);
|
Q_D(QuickMicaMaterial);
|
||||||
d->repaint(painter);
|
const bool isActive = window() ? window()->isActive() : false;
|
||||||
|
const QPoint originPoint = mapToGlobal(QPointF{ 0, 0 }).toPoint();
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||||
|
const QSize s = size().toSize();
|
||||||
|
#else // (QT_VERSION < QT_VERSION_CHECK(5, 10, 0))
|
||||||
|
const QSize s = QSizeF{ width(), height() }.toSize();
|
||||||
|
#endif // (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||||
|
d->micaMaterial->paint(painter, QRect{ originPoint, s }, isActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor QuickMicaMaterial::tintColor() const
|
QColor QuickMicaMaterial::tintColor() const
|
||||||
{
|
{
|
||||||
Q_D(const QuickMicaMaterial);
|
Q_D(const QuickMicaMaterial);
|
||||||
return d->m_micaMaterial->tintColor();
|
return d->micaMaterial->tintColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickMicaMaterial::setTintColor(const QColor &value)
|
void QuickMicaMaterial::setTintColor(const QColor &value)
|
||||||
{
|
{
|
||||||
Q_D(QuickMicaMaterial);
|
Q_D(QuickMicaMaterial);
|
||||||
d->m_micaMaterial->setTintColor(value);
|
d->micaMaterial->setTintColor(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal QuickMicaMaterial::tintOpacity() const
|
qreal QuickMicaMaterial::tintOpacity() const
|
||||||
{
|
{
|
||||||
Q_D(const QuickMicaMaterial);
|
Q_D(const QuickMicaMaterial);
|
||||||
return d->m_micaMaterial->tintOpacity();
|
return d->micaMaterial->tintOpacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickMicaMaterial::setTintOpacity(const qreal value)
|
void QuickMicaMaterial::setTintOpacity(const qreal value)
|
||||||
{
|
{
|
||||||
Q_D(QuickMicaMaterial);
|
Q_D(QuickMicaMaterial);
|
||||||
d->m_micaMaterial->setTintOpacity(value);
|
d->micaMaterial->setTintOpacity(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor QuickMicaMaterial::fallbackColor() const
|
QColor QuickMicaMaterial::fallbackColor() const
|
||||||
{
|
{
|
||||||
Q_D(const QuickMicaMaterial);
|
Q_D(const QuickMicaMaterial);
|
||||||
return d->m_micaMaterial->fallbackColor();
|
return d->micaMaterial->fallbackColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickMicaMaterial::setFallbackColor(const QColor &value)
|
void QuickMicaMaterial::setFallbackColor(const QColor &value)
|
||||||
{
|
{
|
||||||
Q_D(QuickMicaMaterial);
|
Q_D(QuickMicaMaterial);
|
||||||
d->m_micaMaterial->setFallbackColor(value);
|
d->micaMaterial->setFallbackColor(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal QuickMicaMaterial::noiseOpacity() const
|
qreal QuickMicaMaterial::noiseOpacity() const
|
||||||
{
|
{
|
||||||
Q_D(const QuickMicaMaterial);
|
Q_D(const QuickMicaMaterial);
|
||||||
return d->m_micaMaterial->noiseOpacity();
|
return d->micaMaterial->noiseOpacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickMicaMaterial::setNoiseOpacity(const qreal value)
|
void QuickMicaMaterial::setNoiseOpacity(const qreal value)
|
||||||
{
|
{
|
||||||
Q_D(QuickMicaMaterial);
|
Q_D(QuickMicaMaterial);
|
||||||
d->m_micaMaterial->setNoiseOpacity(value);
|
d->micaMaterial->setNoiseOpacity(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QuickMicaMaterial::isFallbackEnabled() const
|
bool QuickMicaMaterial::isFallbackEnabled() const
|
||||||
{
|
{
|
||||||
Q_D(const QuickMicaMaterial);
|
Q_D(const QuickMicaMaterial);
|
||||||
return d->m_micaMaterial->isFallbackEnabled();
|
return d->micaMaterial->isFallbackEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickMicaMaterial::setFallbackEnabled(const bool value)
|
void QuickMicaMaterial::setFallbackEnabled(const bool value)
|
||||||
{
|
{
|
||||||
Q_D(QuickMicaMaterial);
|
Q_D(QuickMicaMaterial);
|
||||||
d->m_micaMaterial->setFallbackEnabled(value);
|
d->micaMaterial->setFallbackEnabled(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickMicaMaterial::itemChange(const ItemChange change, const ItemChangeData &value)
|
void QuickMicaMaterial::itemChange(const ItemChange change, const ItemChangeData &value)
|
||||||
|
@ -242,14 +231,14 @@ void QuickMicaMaterial::itemChange(const ItemChange change, const ItemChangeData
|
||||||
QQuickPaintedItem::itemChange(change, value);
|
QQuickPaintedItem::itemChange(change, value);
|
||||||
Q_D(QuickMicaMaterial);
|
Q_D(QuickMicaMaterial);
|
||||||
switch (change) {
|
switch (change) {
|
||||||
case ItemDevicePixelRatioHasChanged: {
|
case ItemDevicePixelRatioHasChanged:
|
||||||
update(); // Force re-paint immediately.
|
update(); // Force re-paint immediately.
|
||||||
} break;
|
break;
|
||||||
case ItemSceneChange: {
|
case ItemSceneChange:
|
||||||
if (value.window) {
|
if (value.window) {
|
||||||
d->rebindWindow();
|
d->rebindWindow();
|
||||||
}
|
}
|
||||||
} break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,21 +115,6 @@ const QuickWindowBorderPrivate *QuickWindowBorderPrivate::get(const QuickWindowB
|
||||||
return q->d_func();
|
return q->d_func();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickWindowBorderPrivate::paint(QPainter *painter) const
|
|
||||||
{
|
|
||||||
Q_ASSERT(painter);
|
|
||||||
if (!painter || !m_borderPainter) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Q_Q(const QuickWindowBorder);
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
|
||||||
const QSize size = q->size().toSize();
|
|
||||||
#else
|
|
||||||
const QSize size = QSizeF(q->width(), q->height()).toSize();
|
|
||||||
#endif
|
|
||||||
m_borderPainter->paint(painter, size, (q->window() && q->window()->isActive()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickWindowBorderPrivate::update()
|
void QuickWindowBorderPrivate::update()
|
||||||
{
|
{
|
||||||
Q_Q(QuickWindowBorder);
|
Q_Q(QuickWindowBorder);
|
||||||
|
@ -150,18 +135,18 @@ void QuickWindowBorderPrivate::initialize()
|
||||||
// some very thin lines that are too fragile.
|
// some very thin lines that are too fragile.
|
||||||
q->setAntialiasing(false);
|
q->setAntialiasing(false);
|
||||||
|
|
||||||
m_borderPainter = new WindowBorderPainter(this);
|
borderPainter = new WindowBorderPainter(this);
|
||||||
connect(m_borderPainter, &WindowBorderPainter::thicknessChanged,
|
connect(borderPainter, &WindowBorderPainter::thicknessChanged,
|
||||||
q, &QuickWindowBorder::thicknessChanged);
|
q, &QuickWindowBorder::thicknessChanged);
|
||||||
connect(m_borderPainter, &WindowBorderPainter::edgesChanged,
|
connect(borderPainter, &WindowBorderPainter::edgesChanged,
|
||||||
q, &QuickWindowBorder::edgesChanged);
|
q, &QuickWindowBorder::edgesChanged);
|
||||||
connect(m_borderPainter, &WindowBorderPainter::activeColorChanged,
|
connect(borderPainter, &WindowBorderPainter::activeColorChanged,
|
||||||
q, &QuickWindowBorder::activeColorChanged);
|
q, &QuickWindowBorder::activeColorChanged);
|
||||||
connect(m_borderPainter, &WindowBorderPainter::inactiveColorChanged,
|
connect(borderPainter, &WindowBorderPainter::inactiveColorChanged,
|
||||||
q, &QuickWindowBorder::inactiveColorChanged);
|
q, &QuickWindowBorder::inactiveColorChanged);
|
||||||
connect(m_borderPainter, &WindowBorderPainter::nativeBorderChanged,
|
connect(borderPainter, &WindowBorderPainter::nativeBorderChanged,
|
||||||
q, &QuickWindowBorder::nativeBorderChanged);
|
q, &QuickWindowBorder::nativeBorderChanged);
|
||||||
connect(m_borderPainter, &WindowBorderPainter::shouldRepaint, q, [q](){ q->update(); });
|
connect(borderPainter, &WindowBorderPainter::shouldRepaint, q, [q](){ q->update(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickWindowBorderPrivate::rebindWindow()
|
void QuickWindowBorderPrivate::rebindWindow()
|
||||||
|
@ -178,17 +163,17 @@ void QuickWindowBorderPrivate::rebindWindow()
|
||||||
QQuickItemPrivate::get(q)->anchors()->setFill(rootItem);
|
QQuickItemPrivate::get(q)->anchors()->setFill(rootItem);
|
||||||
#endif // FRAMELESSHELPER_QUICK_NO_PRIVATE
|
#endif // FRAMELESSHELPER_QUICK_NO_PRIVATE
|
||||||
q->setZ(999); // Make sure we always stays on the top most place.
|
q->setZ(999); // Make sure we always stays on the top most place.
|
||||||
if (m_activeChangeConnection) {
|
if (activeChangeConnection) {
|
||||||
disconnect(m_activeChangeConnection);
|
disconnect(activeChangeConnection);
|
||||||
m_activeChangeConnection = {};
|
activeChangeConnection = {};
|
||||||
}
|
}
|
||||||
if (m_visibilityChangeConnection) {
|
if (visibilityChangeConnection) {
|
||||||
disconnect(m_visibilityChangeConnection);
|
disconnect(visibilityChangeConnection);
|
||||||
m_visibilityChangeConnection = {};
|
visibilityChangeConnection = {};
|
||||||
}
|
}
|
||||||
m_activeChangeConnection = connect(window, &QQuickWindow::activeChanged,
|
activeChangeConnection = connect(window, &QQuickWindow::activeChanged,
|
||||||
this, &QuickWindowBorderPrivate::update);
|
this, &QuickWindowBorderPrivate::update);
|
||||||
m_visibilityChangeConnection = connect(window, &QQuickWindow::visibilityChanged,
|
visibilityChangeConnection = connect(window, &QQuickWindow::visibilityChanged,
|
||||||
this, &QuickWindowBorderPrivate::update);
|
this, &QuickWindowBorderPrivate::update);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,106 +186,115 @@ QuickWindowBorder::~QuickWindowBorder() = default;
|
||||||
|
|
||||||
void QuickWindowBorder::paint(QPainter *painter)
|
void QuickWindowBorder::paint(QPainter *painter)
|
||||||
{
|
{
|
||||||
|
Q_ASSERT(painter);
|
||||||
|
if (!painter) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Q_D(QuickWindowBorder);
|
Q_D(QuickWindowBorder);
|
||||||
d->paint(painter);
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||||
|
const QSize s = size().toSize();
|
||||||
|
#else
|
||||||
|
const QSize s = QSizeF{ width(), height() }.toSize();
|
||||||
|
#endif
|
||||||
|
d->borderPainter->paint(painter, s, (window() && window()->isActive()));
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal QuickWindowBorder::thickness() const
|
qreal QuickWindowBorder::thickness() const
|
||||||
{
|
{
|
||||||
Q_D(const QuickWindowBorder);
|
Q_D(const QuickWindowBorder);
|
||||||
return ((d->m_borderPainter == nullptr) ? 0 : d->m_borderPainter->thickness());
|
return ((d->borderPainter == nullptr) ? 0 : d->borderPainter->thickness());
|
||||||
}
|
}
|
||||||
|
|
||||||
QuickGlobal::WindowEdges QuickWindowBorder::edges() const
|
QuickGlobal::WindowEdges QuickWindowBorder::edges() const
|
||||||
{
|
{
|
||||||
Q_D(const QuickWindowBorder);
|
Q_D(const QuickWindowBorder);
|
||||||
return ((d->m_borderPainter == nullptr) ? QuickGlobal::WindowEdges()
|
return ((d->borderPainter == nullptr) ? QuickGlobal::WindowEdges()
|
||||||
: edgesToQuickEdges(d->m_borderPainter->edges()));
|
: edgesToQuickEdges(d->borderPainter->edges()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor QuickWindowBorder::activeColor() const
|
QColor QuickWindowBorder::activeColor() const
|
||||||
{
|
{
|
||||||
Q_D(const QuickWindowBorder);
|
Q_D(const QuickWindowBorder);
|
||||||
return ((d->m_borderPainter == nullptr) ? QColor() : d->m_borderPainter->activeColor());
|
return ((d->borderPainter == nullptr) ? QColor() : d->borderPainter->activeColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor QuickWindowBorder::inactiveColor() const
|
QColor QuickWindowBorder::inactiveColor() const
|
||||||
{
|
{
|
||||||
Q_D(const QuickWindowBorder);
|
Q_D(const QuickWindowBorder);
|
||||||
return ((d->m_borderPainter == nullptr) ? QColor() : d->m_borderPainter->inactiveColor());
|
return ((d->borderPainter == nullptr) ? QColor() : d->borderPainter->inactiveColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal QuickWindowBorder::nativeThickness() const
|
qreal QuickWindowBorder::nativeThickness() const
|
||||||
{
|
{
|
||||||
Q_D(const QuickWindowBorder);
|
Q_D(const QuickWindowBorder);
|
||||||
return ((d->m_borderPainter == nullptr) ? 0 : d->m_borderPainter->nativeThickness());
|
return ((d->borderPainter == nullptr) ? 0 : d->borderPainter->nativeThickness());
|
||||||
}
|
}
|
||||||
|
|
||||||
QuickGlobal::WindowEdges QuickWindowBorder::nativeEdges() const
|
QuickGlobal::WindowEdges QuickWindowBorder::nativeEdges() const
|
||||||
{
|
{
|
||||||
Q_D(const QuickWindowBorder);
|
Q_D(const QuickWindowBorder);
|
||||||
return ((d->m_borderPainter == nullptr) ? QuickGlobal::WindowEdges()
|
return ((d->borderPainter == nullptr) ? QuickGlobal::WindowEdges()
|
||||||
: edgesToQuickEdges(d->m_borderPainter->nativeEdges()));
|
: edgesToQuickEdges(d->borderPainter->nativeEdges()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor QuickWindowBorder::nativeActiveColor() const
|
QColor QuickWindowBorder::nativeActiveColor() const
|
||||||
{
|
{
|
||||||
Q_D(const QuickWindowBorder);
|
Q_D(const QuickWindowBorder);
|
||||||
return ((d->m_borderPainter == nullptr) ? QColor() : d->m_borderPainter->nativeActiveColor());
|
return ((d->borderPainter == nullptr) ? QColor() : d->borderPainter->nativeActiveColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor QuickWindowBorder::nativeInactiveColor() const
|
QColor QuickWindowBorder::nativeInactiveColor() const
|
||||||
{
|
{
|
||||||
Q_D(const QuickWindowBorder);
|
Q_D(const QuickWindowBorder);
|
||||||
return ((d->m_borderPainter == nullptr) ? QColor() : d->m_borderPainter->nativeInactiveColor());
|
return ((d->borderPainter == nullptr) ? QColor() : d->borderPainter->nativeInactiveColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickWindowBorder::setThickness(const qreal value)
|
void QuickWindowBorder::setThickness(const qreal value)
|
||||||
{
|
{
|
||||||
Q_D(QuickWindowBorder);
|
Q_D(QuickWindowBorder);
|
||||||
if (!d->m_borderPainter) {
|
if (!d->borderPainter) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (qFuzzyCompare(thickness(), value)) {
|
if (qFuzzyCompare(thickness(), value)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
d->m_borderPainter->setThickness(std::round(value));
|
d->borderPainter->setThickness(std::round(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickWindowBorder::setEdges(const QuickGlobal::WindowEdges value)
|
void QuickWindowBorder::setEdges(const QuickGlobal::WindowEdges value)
|
||||||
{
|
{
|
||||||
Q_D(QuickWindowBorder);
|
Q_D(QuickWindowBorder);
|
||||||
if (!d->m_borderPainter) {
|
if (!d->borderPainter) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (edges() == value) {
|
if (edges() == value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
d->m_borderPainter->setEdges(quickEdgesToEdges(value));
|
d->borderPainter->setEdges(quickEdgesToEdges(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickWindowBorder::setActiveColor(const QColor &value)
|
void QuickWindowBorder::setActiveColor(const QColor &value)
|
||||||
{
|
{
|
||||||
Q_D(QuickWindowBorder);
|
Q_D(QuickWindowBorder);
|
||||||
if (!d->m_borderPainter) {
|
if (!d->borderPainter) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (activeColor() == value) {
|
if (activeColor() == value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
d->m_borderPainter->setActiveColor(value);
|
d->borderPainter->setActiveColor(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickWindowBorder::setInactiveColor(const QColor &value)
|
void QuickWindowBorder::setInactiveColor(const QColor &value)
|
||||||
{
|
{
|
||||||
Q_D(QuickWindowBorder);
|
Q_D(QuickWindowBorder);
|
||||||
if (!d->m_borderPainter) {
|
if (!d->borderPainter) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (inactiveColor() == value) {
|
if (inactiveColor() == value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
d->m_borderPainter->setInactiveColor(value);
|
d->borderPainter->setInactiveColor(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickWindowBorder::itemChange(const ItemChange change, const ItemChangeData &value)
|
void QuickWindowBorder::itemChange(const ItemChange change, const ItemChangeData &value)
|
||||||
|
|
|
@ -384,6 +384,9 @@ FramelessWidgetsHelper *FramelessWidgetsHelperPrivate::findOrCreateFramelessHelp
|
||||||
if (!instance) {
|
if (!instance) {
|
||||||
instance = new FramelessWidgetsHelper(parent);
|
instance = new FramelessWidgetsHelper(parent);
|
||||||
instance->extendsContentIntoTitleBar();
|
instance->extendsContentIntoTitleBar();
|
||||||
|
if (parent->inherits("QDialog")) {
|
||||||
|
instance->setWindowFixedSize(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
@ -906,7 +909,7 @@ void FramelessWidgetsHelperPrivate::setSystemButton(QWidget *widget, const Syste
|
||||||
data->closeButton = widget;
|
data->closeButton = widget;
|
||||||
break;
|
break;
|
||||||
case SystemButtonType::Unknown:
|
case SystemButtonType::Unknown:
|
||||||
Q_UNREACHABLE_RETURN(void(0));
|
Q_UNREACHABLE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -374,6 +374,9 @@ bool StandardTitleBarPrivate::mouseEventHandler(QMouseEvent *event)
|
||||||
QRect StandardTitleBarPrivate::windowIconRect() const
|
QRect StandardTitleBarPrivate::windowIconRect() const
|
||||||
{
|
{
|
||||||
Q_Q(const StandardTitleBar);
|
Q_Q(const StandardTitleBar);
|
||||||
|
if (!windowIconVisible_real()) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
const QSize size = windowIconSize();
|
const QSize size = windowIconSize();
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
const auto x = [this, q, &size]() -> int {
|
const auto x = [this, q, &size]() -> int {
|
||||||
|
|
Loading…
Reference in New Issue