diff --git a/pyproject.toml b/pyproject.toml index 083ac2e..76a6461 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "sipbuild.api" # Specify the PEP 566 metadata for the project. [tool.sip.metadata] name = "PyQtAds" -version = "4.0.0" +version = "4.0.2" summary = "Python bindings for Qt Advanced Docking System" home-page = "https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/" license = "LGPL v2.1" @@ -23,9 +23,9 @@ sip-file = "ads.sip" include-dirs = ["src"] qmake-QT = ["widgets"] headers = [ - "src/AutoHideDockContainer.h", - "src/AutoHideSideBar.h", - "src/AutoHideTab.h", + "src/AutoHideDockContainer.h", + "src/AutoHideSideBar.h", + "src/AutoHideTab.h", "src/DockAreaTabBar.h", "src/DockAreaTitleBar.h", "src/DockAreaTitleBar_p.h", @@ -43,15 +43,15 @@ headers = [ "src/FloatingDockContainer.h", "src/FloatingDragPreview.h", "src/IconProvider.h", - "src/PushButton.h", - "src/ResizeHandle.h", + "src/PushButton.h", + "src/ResizeHandle.h", "src/ads_globals.h", # "src/linux/FloatingWidgetTitleBar.h", ] sources = [ - "src/AutoHideDockContainer.cpp", - "src/AutoHideSideBar.cpp", - "src/AutoHideTab.cpp", + "src/AutoHideTab.cpp", + "src/AutoHideDockContainer.cpp", + "src/AutoHideSideBar.cpp", "src/DockAreaTabBar.cpp", "src/DockAreaTitleBar.cpp", "src/DockAreaWidget.cpp", diff --git a/sip/AutoHideDockContainer.sip b/sip/AutoHideDockContainer.sip new file mode 100644 index 0000000..7d5a18b --- /dev/null +++ b/sip/AutoHideDockContainer.sip @@ -0,0 +1,46 @@ +%Import QtWidgets/QtWidgetsmod.sip + +%If (Qt_5_0_0 -) + +namespace ads +{ + +class CAutoHideDockContainer : QFrame +{ + + %TypeHeaderCode + #include + %End + +protected: + virtual bool eventFilter(QObject* watched, QEvent* event); + virtual void resizeEvent(QResizeEvent* event); + virtual void leaveEvent(QEvent *event); + virtual bool event(QEvent* event); + void updateSize(); + void saveState(QXmlStreamWriter& Stream); + +public: + CAutoHideDockContainer(ads::CDockWidget* DockWidget /Transfer/, ads::SideBarLocation area, + ads::CDockContainerWidget* parent /TransferThis/); + virtual ~CAutoHideDockContainer(); + ads::CAutoHideSideBar* sideBar() const; + ads::CAutoHideTab* autoHideTab() const; + ads::CDockWidget* dockWidget() const; + void addDockWidget(ads::CDockWidget* DockWidget /Transfer/); + ads::SideBarLocation sideBarLocation() const; + void setSideBarLocation(ads::SideBarLocation SideBarLocation); + ads::CDockAreaWidget* dockAreaWidget() const; + ads::CDockContainerWidget* dockContainer() const; + void moveContentsToParent(); + void cleanupAndDelete(); + void toggleView(bool Enable); + void collapseView(bool Enable); + void toggleCollapseState(); + void setSize(int Size); + +}; + +}; + +%End \ No newline at end of file diff --git a/sip/AutoHideSideBar.sip b/sip/AutoHideSideBar.sip new file mode 100644 index 0000000..492464b --- /dev/null +++ b/sip/AutoHideSideBar.sip @@ -0,0 +1,41 @@ +%Import QtWidgets/QtWidgetsmod.sip + +%If (Qt_5_0_0 -) + +namespace ads +{ + + +class CAutoHideSideBar : QScrollArea +{ + + %TypeHeaderCode + #include + %End + +protected: + virtual bool eventFilter(QObject *watched, QEvent *event); + void saveState(QXmlStreamWriter& Stream) const; + void insertTab(int Index, ads::CAutoHideTab* SideTab /Transfer/); + +public: + CAutoHideSideBar(ads::CDockContainerWidget* parent /TransferThis/, SideBarLocation area); + virtual ~CAutoHideSideBar(); + void removeTab(ads::CAutoHideTab* SideTab) /TransferBack/; + ads::CAutoHideDockContainer* insertDockWidget(int Index, ads::CDockWidget* DockWidget /Transfer/); + void removeAutoHideWidget(ads::CAutoHideDockContainer* AutoHideWidget) /TransferBack/; + void addAutoHideWidget(ads::CAutoHideDockContainer* AutoHideWidget); + Qt::Orientation orientation() const; + ads::CAutoHideTab* tabAt(int index) const; + int tabCount() const; + ads::SideBarLocation sideBarLocation() const; + virtual QSize minimumSizeHint() const; + virtual QSize sizeHint() const; + int spacing() const; + void setSpacing(int Spacing); + CDockContainerWidget* dockContainer() const; +}; + +}; + +%End \ No newline at end of file diff --git a/sip/AutoHideTab.sip b/sip/AutoHideTab.sip new file mode 100644 index 0000000..42e607c --- /dev/null +++ b/sip/AutoHideTab.sip @@ -0,0 +1,36 @@ +%Import QtWidgets/QtWidgetsmod.sip + +%If (Qt_5_0_0 -) + +namespace ads +{ + +class CAutoHideTab : CPushButton +{ + + %TypeHeaderCode + #include + %End + +protected: + void setSideBar(ads::CAutoHideSideBar *SideTabBar); + void removeFromSideBar(); + virtual bool event(QEvent* event); + +public: + CAutoHideTab(QWidget* parent /TransferThis/ = 0); + virtual ~CAutoHideTab(); + void updateStyle(); + ads::SideBarLocation sideBarLocation() const; + void setOrientation(Qt::Orientation Orientation); + Qt::Orientation orientation() const; + bool isActiveTab() const; + ads::CDockWidget* dockWidget() const; + void setDockWidget(ads::CDockWidget* DockWidget); + bool iconOnly() const; + ads::CAutoHideSideBar* sideBar() const; +}; + +}; + +%End diff --git a/sip/DockAreaTitleBar.sip b/sip/DockAreaTitleBar.sip index f4dd32d..8d3fad7 100644 --- a/sip/DockAreaTitleBar.sip +++ b/sip/DockAreaTitleBar.sip @@ -27,10 +27,12 @@ public: virtual ~CDockAreaTitleBar(); ads::CDockAreaTabBar* tabBar() const; QAbstractButton* button(ads::TitleBarButton which) const; + ads::CElidingLabel* autoHideTitleLabel() const; void updateDockWidgetActionsButtons(); virtual void setVisible(bool Visible); void insertWidget(int index, QWidget *widget /Transfer/ ); int indexOf(QWidget *widget) const; + QString titleBarButtonToolTip(ads::TitleBarButton Button) const; signals: diff --git a/sip/DockAreaWidget.sip b/sip/DockAreaWidget.sip index 8196047..ae74263 100644 --- a/sip/DockAreaWidget.sip +++ b/sip/DockAreaWidget.sip @@ -23,6 +23,7 @@ protected: void updateTitleBarVisibility(); void internalSetCurrentDockWidget(ads::CDockWidget* DockWidget /Transfer/); void markTitleBarMenuOutdated(); + void updateTitleBarButtonVisibility(bool IsTopLevel) const; protected slots: void toggleView(bool Open); @@ -52,6 +53,8 @@ public: ads::CDockWidget* currentDockWidget() const; void setCurrentDockWidget(ads::CDockWidget* DockWidget); void saveState(QXmlStreamWriter& Stream) const; + static bool restoreState(ads::CDockingStateReader& Stream, ads::CDockAreaWidget*& CreatedWidget, + bool Testing, ads::CDockContainerWidget* ParentContainer); ads::CDockWidget::DockWidgetFeatures features(ads::eBitwiseOperator Mode = ads::BitwiseAnd) const; QAbstractButton* titleBarButton(ads::TitleBarButton which) const; virtual void setVisible(bool Visible); @@ -65,6 +68,8 @@ public: void setDockAreaFlag(eDockAreaFlag Flag, bool On); bool isCentralWidgetArea() const; + bool containsCentralWidget() const; + bool isTopLevelArea() const; public slots: void setCurrentIndex(int index); diff --git a/sip/DockComponentsFactory.sip b/sip/DockComponentsFactory.sip index e227608..b00eb62 100644 --- a/sip/DockComponentsFactory.sip +++ b/sip/DockComponentsFactory.sip @@ -13,6 +13,7 @@ class CDockComponentsFactory public: virtual ~CDockComponentsFactory(); virtual CDockWidgetTab* createDockWidgetTab(CDockWidget* DockWidget /Transfer/ ) const; + virtual CAutoHideTab* createDockWidgetSideTab(CDockWidget* DockWidget /Transfer/) const; virtual CDockAreaTabBar* createDockAreaTabBar(CDockAreaWidget* DockArea /Transfer/ ) const; virtual CDockAreaTitleBar* createDockAreaTitleBar(CDockAreaWidget* DockArea /Transfer/ ) const; static const CDockComponentsFactory* factory(); diff --git a/sip/DockContainerWidget.sip b/sip/DockContainerWidget.sip index d56ec2a..922db75 100644 --- a/sip/DockContainerWidget.sip +++ b/sip/DockContainerWidget.sip @@ -21,6 +21,7 @@ class CDockContainerWidget : QFrame protected: virtual bool event(QEvent *e); QSplitter* rootSplitter() const; + ads::CAutoHideDockContainer* createAndSetupAutoHideContainer(ads::SideBarLocation area, ads::CDockWidget* DockWidget /Transfer/); void createRootSplitter(); void dropFloatingWidget(ads::CFloatingDockContainer* FloatingWidget, const QPoint& TargetPos); void dropWidget(QWidget* Widget, DockWidgetArea DropArea, CDockAreaWidget* TargetAreaWidget); @@ -33,125 +34,44 @@ protected: ads::CDockAreaWidget* topLevelDockArea() const; QList dockWidgets() const; void updateSplitterHandles(QSplitter* splitter); + void registerAutoHideWidget(ads::CAutoHideDockContainer* AutoHideWidget /Transfer/); + void removeAutoHideWidget(ads::CAutoHideDockContainer* AutoHideWidget /TransferBack/); + void handleAutoHideWidgetEvent(QEvent* e, QWidget* w); public: - /** - * Default Constructor - */ CDockContainerWidget(ads::CDockManager* DockManager /TransferThis/, QWidget* parent /TransferThis/ = 0); - - /** - * Virtual Destructor - */ virtual ~CDockContainerWidget(); - - /** - * Adds dockwidget into the given area. - * If DockAreaWidget is not null, then the area parameter indicates the area - * into the DockAreaWidget. If DockAreaWidget is null, the Dockwidget will - * be dropped into the container. - * \return Returns the dock area widget that contains the new DockWidget - */ ads::CDockAreaWidget* addDockWidget(ads::DockWidgetArea area, ads::CDockWidget* Dockwidget /Transfer/, - ads::CDockAreaWidget* DockAreaWidget /Transfer/ = 0, + ads::CDockAreaWidget* DockAreaWidget /Transfer/ = 0, int Index = -1); - - /** - * Removes dockwidget - */ void removeDockWidget(ads::CDockWidget* Dockwidget) /TransferBack/; - - /** - * Returns the current zOrderIndex - */ virtual unsigned int zOrderIndex() const; - - /** - * This function returns true if this container widgets z order index is - * higher than the index of the container widget given in Other parameter - */ bool isInFrontOf(ads::CDockContainerWidget* Other) const; - - /** - * Returns the dock area at teh given global position or 0 if there is no - * dock area at this position - */ ads::CDockAreaWidget* dockAreaAt(const QPoint& GlobalPos) const; - - /** - * Returns the dock area at the given Index or 0 if the index is out of - * range - */ ads::CDockAreaWidget* dockArea(int Index) const; - - /** - * Returns the list of dock areas that are not closed - * If all dock widgets in a dock area are closed, the dock area will be closed - */ QList openedDockAreas() const; + QList openedDockWidgets() const; bool hasTopLevelDockWidget() const; - - /** - * Returns the number of dock areas in this container - */ int dockAreaCount() const; - - /** - * Returns the number of visible dock areas - */ int visibleDockAreaCount() const; - - /** - * This function returns true, if this container is in a floating widget - */ bool isFloating() const; - - /** - * Dumps the layout for debugging purposes - */ void dumpLayout(); - - /** - * This functions returns the dock widget features of all dock widget in - * this container. - * A bitwise and is used to combine the flags of all dock widgets. That - * means, if only dock widget does not support a certain flag, the whole - * dock are does not support the flag. - */ ads::CDockWidget::DockWidgetFeatures features() const; - - /** - * If this dock container is in a floating widget, this function returns - * the floating widget. - * Else, it returns a nullptr. - */ ads::CFloatingDockContainer* floatingWidget() const; - - /** - * Call this function to close all dock areas except the KeepOpenArea - */ void closeOtherAreas(ads::CDockAreaWidget* KeepOpenArea); + ads::CAutoHideSideBar* sideTabBar(SideBarLocation area) const; + QList autoHideWidgets() const; + QRect contentRect() const; + QRect contentRectGlobal() const; + ads::CDockManager* dockManager() const; signals: - /** - * This signal is emitted if one or multiple dock areas has been added to - * the internal list of dock areas. - * If multiple dock areas are inserted, this signal is emitted only once - */ void dockAreasAdded(); - - /** - * This signal is emitted if one or multiple dock areas has been removed - */ + void autoHideWidgetCreated(ads::CAutoHideDockContainer* AutoHideWidget); void dockAreasRemoved(); - - /** - * This signal is emitted if a dock area is opened or closed via - * toggleView() function - */ void dockAreaViewToggled(ads::CDockAreaWidget* DockArea, bool Open); -}; // class DockContainerWidget }; - // namespace ads + +}; %End diff --git a/sip/DockFocusController.sip b/sip/DockFocusController.sip index a701096..a5cf1d1 100644 --- a/sip/DockFocusController.sip +++ b/sip/DockFocusController.sip @@ -22,6 +22,7 @@ public: void notifyFloatingWidgetDrop(ads::CFloatingDockContainer* FloatingWidget); ads::CDockWidget* focusedDockWidget() const; void setDockWidgetTabFocused(ads::CDockWidgetTab* Tab); + void clearDockWidgetFocus(ads::CDockWidget* dockWidget); public slots: void setDockWidgetFocused(ads::CDockWidget* focusedNow); diff --git a/sip/DockManager.sip b/sip/DockManager.sip index a63a8ed..5abc9b5 100644 --- a/sip/DockManager.sip +++ b/sip/DockManager.sip @@ -156,7 +156,6 @@ public: TabCloseButtonIsToolButton, AllTabsHaveCloseButton, RetainTabSizeWhenCloseButtonHidden, - OpaqueUndocking, DragPreviewIsDynamic, DragPreviewShowsContentPixmap, DragPreviewHasWindowFrame, @@ -204,15 +203,17 @@ public: static bool testAutoHideConfigFlag(eAutoHideFlag Flag); static ads::CIconProvider& iconProvider(); ads::CDockAreaWidget* addDockWidget(ads::DockWidgetArea area, ads::CDockWidget* Dockwidget /Transfer/, - ads::CDockAreaWidget* DockAreaWidget /Transfer/ = 0, + ads::CDockAreaWidget* DockAreaWidget /Transfer/ = 0, int Index = -1); ads::CDockAreaWidget* addDockWidgetToContainer(ads::DockWidgetArea area, ads::CDockWidget* Dockwidget /Transfer/, - ads::CDockContainerWidget* DockContainerWidget /Transfer/ = 0); - + ads::CDockContainerWidget* DockContainerWidget /Transfer/ = 0); + ads::CAutoHideDockContainer* addAutoHideDockWidget(ads::SideBarLocation Location, ads::CDockWidget* Dockwidget /Transfer/); + ads::CAutoHideDockContainer* addAutoHideDockWidgetToContainer(SideBarLocation Location, + ads::CDockWidget* Dockwidget /Transfer/, ads::CDockContainerWidget* DockContainerWidget); ads::CDockAreaWidget* addDockWidgetTab(ads::DockWidgetArea area, ads::CDockWidget* Dockwidget /Transfer/); ads::CDockAreaWidget* addDockWidgetTabToArea(ads::CDockWidget* Dockwidget /Transfer/, - ads::CDockAreaWidget* DockAreaWidget /Transfer/, + ads::CDockAreaWidget* DockAreaWidget /Transfer/, int Index = -1); ads::CFloatingDockContainer* addDockWidgetFloating(ads::CDockWidget* DockWidget /Transfer/); ads::CDockWidget* findDockWidget(const QString& ObjectName) const; @@ -240,6 +241,8 @@ public: ads::CDockWidget* focusedDockWidget() const; QList splitterSizes(ads::CDockAreaWidget *ContainedArea) const; void setSplitterSizes(ads::CDockAreaWidget *ContainedArea, const QList& sizes); + static void setFloatingContainersTitle(const QString& Title); + static QString floatingContainersTitle(); public slots: void openPerspective(const QString& PerspectiveName); diff --git a/sip/DockWidget.sip b/sip/DockWidget.sip index 581fa7b..d428912 100644 --- a/sip/DockWidget.sip +++ b/sip/DockWidget.sip @@ -35,6 +35,7 @@ public: DockWidgetForceCloseWithArea, NoTab, DeleteContentOnClose, + DockWidgetPinnable, DefaultDockWidgetFeatures, AllDockWidgetFeatures, DockWidgetAlwaysCloseAndDelete, @@ -81,7 +82,12 @@ public: ads::CDockWidget::DockWidgetFeatures features() const; ads::CDockManager* dockManager() const; ads::CDockContainerWidget* dockContainer() const; + ads::CFloatingDockContainer* floatingDockContainer() const; ads::CDockAreaWidget* dockAreaWidget() const; + ads::CAutoHideTab* sideTabWidget() const; + void setSideTabWidget(ads::CAutoHideTab* SideTab /Transfer/) const; + bool isAutoHide() const; + ads::CAutoHideDockContainer* autoHideDockContainer() const; bool isFloating() const; bool isInFloatingContainer() const; bool isClosed() const; @@ -118,6 +124,8 @@ public slots: void closeDockWidget(); void showFullScreen(); void showNormal(); + void setAutoHide(bool Enable, ads::SideBarLocation Location = ads::SideBarNone); + void toggleAutoHide(ads::SideBarLocation Location = ads::SideBarNone); signals: void viewToggled(bool Open); diff --git a/sip/FloatingDockContainer.sip b/sip/FloatingDockContainer.sip index 0a6d51f..b36f4ce 100644 --- a/sip/FloatingDockContainer.sip +++ b/sip/FloatingDockContainer.sip @@ -64,6 +64,7 @@ protected: %If (WS_X11) virtual void moveEvent(QMoveEvent *event); virtual void resizeEvent(QResizeEvent *event); + virtual bool event(QEvent *e); %End %If (WS_WIN) diff --git a/sip/FloatingDragPreview.sip b/sip/FloatingDragPreview.sip index 9a76e0b..0dfc502 100644 --- a/sip/FloatingDragPreview.sip +++ b/sip/FloatingDragPreview.sip @@ -27,10 +27,9 @@ public: public: // implements IFloatingWidget virtual void startFloating(const QPoint& DragStartMousePos, const QSize& Size, ads::eDragState DragState, QWidget* MouseEventHandler); - virtual void moveFloating(); - virtual void finishDragging(); + void cleanupAutoHideContainerWidget(); signals: void draggingCanceled(); diff --git a/sip/PushButton.sip b/sip/PushButton.sip new file mode 100644 index 0000000..5613f92 --- /dev/null +++ b/sip/PushButton.sip @@ -0,0 +1,31 @@ +%Import QtWidgets/QtWidgetsmod.sip + +%If (Qt_5_0_0 -) + +namespace ads +{ + + +class CPushButton : QPushButton +{ + %TypeHeaderCode + #include + %End + +public: + enum Orientation { + Horizontal, + VerticalTopToBottom, + VerticalBottomToTop + }; + virtual QSize sizeHint() const; + + ads::CPushButton::Orientation buttonOrientation() const; + void setButtonOrientation(ads::CPushButton::Orientation orientation); + +}; + +}; + +%End + diff --git a/sip/ResizeHandle.sip b/sip/ResizeHandle.sip new file mode 100644 index 0000000..0cfdea1 --- /dev/null +++ b/sip/ResizeHandle.sip @@ -0,0 +1,36 @@ +%Import QtWidgets/QtWidgetsmod.sip + +%If (Qt_5_0_0 -) + +namespace ads +{ + +class CResizeHandle : QFrame +{ + + %TypeHeaderCode + #include + %End + +protected: + void mouseMoveEvent(QMouseEvent *); + void mousePressEvent(QMouseEvent *); + void mouseReleaseEvent(QMouseEvent *); + +public: + CResizeHandle(Qt::Edge HandlePosition, QWidget* parent /TransferThis/); + virtual ~CResizeHandle(); + void setHandlePosition(Qt::Edge HandlePosition); + Qt::Edge handlePostion() const; + Qt::Orientation orientation() const; + QSize sizeHint() const; + bool isResizing() const; + void setMinResizeSize(int MinSize); + void setMaxResizeSize(int MaxSize); + void setOpaqueResize(bool opaque = true); + bool opaqueResize() const; +}; + +}; + +%End diff --git a/sip/ads.sip b/sip/ads.sip index 2c29232..70a252a 100644 --- a/sip/ads.sip +++ b/sip/ads.sip @@ -3,6 +3,9 @@ %DefaultSupertype sip.simplewrapper %Include ads_globals.sip +%Include AutoHideDockContainer.sip +%Include AutoHideSideBar.sip +%Include AutoHideTab.sip %Include DockWidget.sip %Include DockAreaTabBar.sip %Include DockAreaTitleBar_p.sip @@ -20,6 +23,8 @@ %Include FloatingDockContainer.sip %Include FloatingDragPreview.sip %Include IconProvider.sip +%Include PushButton.sip +%Include ResizeHandle.sip %If (WS_X11) %Include linux/FloatingWidgetTitleBar.sip %End diff --git a/sip/ads_globals.sip b/sip/ads_globals.sip index 91df1c7..62eb674 100644 --- a/sip/ads_globals.sip +++ b/sip/ads_globals.sip @@ -50,7 +50,6 @@ namespace ads TopDockWidgetArea, BottomDockWidgetArea, CenterDockWidgetArea, - InvalidDockWidgetArea, OuterDockAreas, AllDockAreas @@ -62,7 +61,8 @@ namespace ads { TitleBarButtonTabsMenu, TitleBarButtonUndock, - TitleBarButtonClose + TitleBarButtonClose, + TitleBarButtonAutoHide }; enum eDragState @@ -76,10 +76,10 @@ namespace ads enum eIcon { TabCloseIcon, + AutoHideIcon, DockAreaMenuIcon, DockAreaUndockIcon, DockAreaCloseIcon, - IconCount, }; @@ -89,6 +89,15 @@ namespace ads BitwiseOr }; + enum SideBarLocation + { + SideBarTop, + SideBarLeft, + SideBarRight, + SideBarBottom, + SideBarNone + }; + namespace internal { void replaceSplitterWidget(QSplitter* Splitter, QWidget* From, QWidget* To); @@ -131,6 +140,7 @@ namespace ads }; void repolishStyle(QWidget* w, ads::internal::eRepolishChildOptions Options = ads::internal::RepolishIgnoreChildren); + QRect globalGeometry(QWidget* w); }; };