From 7afe3c0ca066498c5e9cd30d47bde066b330cae0 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 4 Jan 2018 16:15:44 -0500 Subject: Get a lot more of the NativeWindowObject QML-ified. --- .../src-desktop/src-cpp/NativeWindowObject.cpp | 92 ++++++++++++++++++++++ .../src-desktop/src-cpp/NativeWindowObject.h | 32 +++++++- 2 files changed, 122 insertions(+), 2 deletions(-) diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.cpp index 796dd5bc..a1b8dbbb 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.cpp @@ -117,6 +117,10 @@ QRect NativeWindowObject::geometry(){ } // QML ACCESS FUNCTIONS (shortcuts for particular properties in a format QML can use) +QImage NativeWindowObject::winImage(){ + return this->property(NativeWindowObject::WinImage).value(); +} + QString NativeWindowObject::name(){ return this->property(NativeWindowObject::Name).toString(); } @@ -133,10 +137,94 @@ QIcon NativeWindowObject::icon(){ return this->property(NativeWindowObject::Name).value(); } +//QML Button states +bool NativeWindowObject::showCloseButton(){ + QList types = this->property(NativeWindowObject::WinTypes).value >(); + QList badtypes; + badtypes << NativeWindowObject::T_DESKTOP << NativeWindowObject::T_TOOLBAR << NativeWindowObject::T_MENU \ + << NativeWindowObject::T_SPLASH << NativeWindowObject::T_DROPDOWN_MENU << NativeWindowObject::T_POPUP_MENU \ + << NativeWindowObject::T_NOTIFICATION << NativeWindowObject::T_COMBO << NativeWindowObject::T_DND; + for(int i=0; i types = this->property(NativeWindowObject::WinTypes).value >(); + QList badtypes; + badtypes << NativeWindowObject::T_DESKTOP << NativeWindowObject::T_TOOLBAR << NativeWindowObject::T_MENU \ + << NativeWindowObject::T_SPLASH << NativeWindowObject::T_DROPDOWN_MENU << NativeWindowObject::T_POPUP_MENU \ + << NativeWindowObject::T_NOTIFICATION << NativeWindowObject::T_COMBO << NativeWindowObject::T_DND; + for(int i=0; i types = this->property(NativeWindowObject::WinTypes).value >(); + QList badtypes; + badtypes << NativeWindowObject::T_DESKTOP << NativeWindowObject::T_TOOLBAR << NativeWindowObject::T_MENU \ + << NativeWindowObject::T_SPLASH << NativeWindowObject::T_DROPDOWN_MENU << NativeWindowObject::T_POPUP_MENU \ + << NativeWindowObject::T_NOTIFICATION << NativeWindowObject::T_COMBO << NativeWindowObject::T_DND << NativeWindowObject::T_DIALOG; + for(int i=0; i types = this->property(NativeWindowObject::WinTypes).value >(); + QList badtypes; + badtypes << NativeWindowObject::T_DESKTOP << NativeWindowObject::T_TOOLBAR << NativeWindowObject::T_MENU \ + << NativeWindowObject::T_SPLASH << NativeWindowObject::T_DROPDOWN_MENU << NativeWindowObject::T_POPUP_MENU \ + << NativeWindowObject::T_NOTIFICATION << NativeWindowObject::T_COMBO << NativeWindowObject::T_DND; + for(int i=0; i types = this->property(NativeWindowObject::WinTypes).value >(); + QList badtypes; + badtypes << NativeWindowObject::T_DESKTOP << NativeWindowObject::T_TOOLBAR << NativeWindowObject::T_MENU \ + << NativeWindowObject::T_SPLASH << NativeWindowObject::T_DROPDOWN_MENU << NativeWindowObject::T_POPUP_MENU \ + << NativeWindowObject::T_NOTIFICATION << NativeWindowObject::T_COMBO << NativeWindowObject::T_DND; + for(int i=0; i types = this->property(NativeWindowObject::WinTypes).value >(); + QList badtypes; + badtypes << NativeWindowObject::T_DESKTOP << NativeWindowObject::T_TOOLBAR << NativeWindowObject::T_MENU \ + << NativeWindowObject::T_SPLASH << NativeWindowObject::T_DROPDOWN_MENU << NativeWindowObject::T_POPUP_MENU \ + << NativeWindowObject::T_NOTIFICATION << NativeWindowObject::T_COMBO << NativeWindowObject::T_DND; + for(int i=0; iproperty(NativeWindowObject::Workspace).toInt()<0 || this->property(NativeWindowObject::States).value >().contains(NativeWindowObject::S_STICKY) ); } +//QML Geometry reporting +QRect NativeWindowObject::frameGeometry(){ + return geometry(); +} + +QRect NativeWindowObject::imageGeometry(){ + QRect geom( this->property(NativeWindowObject::GlobalPos).toPoint(), this->property(NativeWindowObject::Size).toSize() ); + return geom; +} + // ==== PUBLIC SLOTS === void NativeWindowObject::toggleVisibility(){ setProperty(NativeWindowObject::Visible, !property(NativeWindowObject::Visible).toBool() ); @@ -169,6 +257,10 @@ void NativeWindowObject::emitSinglePropChanged(NativeWindowObject::Property prop case NativeWindowObject::Workspace: case NativeWindowObject::States: emit stickyChanged(); break; + case NativeWindowObject::WinImage: + emit winImageChanged(); break; + case NativeWindowObject::WinTypes: + emit winTypeChanged(); break; default: break; //do nothing otherwise } diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.h index fa1bf4de..8a8504aa 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.h +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/NativeWindowObject.h @@ -17,11 +17,22 @@ class NativeWindowObject : public QObject{ Q_OBJECT // QML-ACCESSIBLE PROPERTIES + Q_PROPERTY( QImage winImage READ winImage NOTIFY winImageChanged) Q_PROPERTY( QString name READ name NOTIFY nameChanged) Q_PROPERTY( QString title READ title NOTIFY titleChanged) Q_PROPERTY( QString shortTitle READ shortTitle NOTIFY shortTitleChanged) Q_PROPERTY( QIcon icon READ icon NOTIFY iconChanged) Q_PROPERTY( bool sticky READ isSticky NOTIFY stickyChanged) + //Button/Titlebar visibility + Q_PROPERTY( bool showCloseButton READ showCloseButton NOTIFY winTypeChanged) + Q_PROPERTY( bool showMinButton READ showMinButton NOTIFY winTypeChanged) + Q_PROPERTY( bool showMaxButton READ showMaxButton NOTIFY winTypeChanged) + Q_PROPERTY( bool showTitlebar READ showTitlebar NOTIFY winTypeChanged) + Q_PROPERTY( bool showGenericButton READ showGenericButton NOTIFY winTypeChanged) + Q_PROPERTY( bool showWindowFrame READ showWindowFrame NOTIFY winTypeChanged) + //Geometry information + Q_PROPERTY( QRect frameGeometry READ frameGeometry NOTIFY geomChanged) + Q_PROPERTY( QRect imageGeometry READ imageGeometry NOTIFY geomChanged) public: enum State{ S_MODAL, S_STICKY, S_MAX_VERT, S_MAX_HORZ, S_SHADED, S_SKIP_TASKBAR, S_SKIP_PAGER, S_HIDDEN, S_FULLSCREEN, S_ABOVE, S_BELOW, S_ATTENTION }; @@ -45,7 +56,8 @@ public: FrameExtents=13, /*QList : [Left, Right, Top, Bottom] in pixels */ RelatedWindows=14, /* QList - better to use the "isRelatedTo(WId)" function instead of reading this directly*/ Active=15, /*bool*/ - Visible=16 /*bool*/ + Visible=16, /*bool*/ + WinImage=17 /*QImage*/ }; static QList allProperties(){ @@ -77,15 +89,28 @@ public: void requestProperty(NativeWindowObject::Property, QVariant, bool force = false); void requestProperties(QList, QList, bool force = false); - QRect geometry(); //this returns the "full" geometry of the window (window + frame) + Q_INVOKABLE QRect geometry(); //this returns the "full" geometry of the window (window + frame) // QML ACCESS FUNCTIONS (shortcuts for particular properties in a format QML can use) + Q_INVOKABLE QImage winImage(); Q_INVOKABLE QString name(); Q_INVOKABLE QString title(); Q_INVOKABLE QString shortTitle(); Q_INVOKABLE QIcon icon(); + //QML Button states + Q_INVOKABLE bool showCloseButton(); + Q_INVOKABLE bool showMaxButton(); + Q_INVOKABLE bool showMinButton(); + Q_INVOKABLE bool showTitlebar(); + Q_INVOKABLE bool showGenericButton(); + Q_INVOKABLE bool showWindowFrame(); + //QML Window States Q_INVOKABLE bool isSticky(); + //QML Geometry reporting + Q_INVOKABLE QRect frameGeometry(); + Q_INVOKABLE QRect imageGeometry(); + public slots: Q_INVOKABLE void toggleVisibility(); Q_INVOKABLE void requestClose(); //ask the app to close the window (may/not depending on activity) @@ -120,11 +145,14 @@ signals: //void RequestUnEmbed(WId, QWidget*); // QML update signals + void winImageChanged(); void nameChanged(); void titleChanged(); void shortTitleChanged(); void iconChanged(); void stickyChanged(); + void winTypeChanged(); + void geomChanged(); }; // Declare the enumerations as Qt MetaTypes -- cgit