Update python bindings to 4.0.2 (#495)

* start adaption of PyQt5 bindings to Qt-ADS 4.0

* Update PyQt bindings

* Fix Python bindings build on Linux

---------

Co-authored-by: Mira Weller <mweller@seemoo.tu-darmstadt.de>
This commit is contained in:
Nicolas Elie 2023-03-21 06:04:19 +01:00 committed by GitHub
parent d28ca1e7a1
commit db16c5f1b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 283 additions and 107 deletions

View File

@ -1,12 +1,12 @@
# Specify the build system.
[build-system]
requires = ["sip >=6.0.2, <6.6", "PyQt-builder >=1.6, <2", "PyQt5>=5.15.4", "PyQt5-sip<13,>=12.8"]
requires = ["sip >=6.0.2, <6.3", "PyQt-builder >=1.6, <2", "PyQt5==5.15.4", "PyQt5-sip<13,>=12.8"]
build-backend = "sipbuild.api"
# Specify the PEP 566 metadata for the project.
[tool.sip.metadata]
name = "PyQtAds"
version = "3.8.2"
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"
@ -21,8 +21,11 @@ tag-prefix = "QtAds"
define-macros = ["ADS_SHARED_EXPORT"]
sip-file = "ads.sip"
include-dirs = ["src"]
qmake-QT = ["widgets"]
qmake-QT = ["widgets", "gui-private; platform_system == 'Linux'"]
headers = [
"src/AutoHideDockContainer.h",
"src/AutoHideSideBar.h",
"src/AutoHideTab.h",
"src/DockAreaTabBar.h",
"src/DockAreaTitleBar.h",
"src/DockAreaTitleBar_p.h",
@ -40,10 +43,15 @@ headers = [
"src/FloatingDockContainer.h",
"src/FloatingDragPreview.h",
"src/IconProvider.h",
"src/PushButton.h",
"src/ResizeHandle.h",
"src/ads_globals.h",
# "src/linux/FloatingWidgetTitleBar.h",
"src/linux/FloatingWidgetTitleBar.h; platform_system == 'Linux'",
]
sources = [
"src/AutoHideTab.cpp",
"src/AutoHideDockContainer.cpp",
"src/AutoHideSideBar.cpp",
"src/DockAreaTabBar.cpp",
"src/DockAreaTitleBar.cpp",
"src/DockAreaWidget.cpp",
@ -60,6 +68,8 @@ sources = [
"src/FloatingDockContainer.cpp",
"src/FloatingDragPreview.cpp",
"src/IconProvider.cpp",
"src/PushButton.cpp",
"src/ResizeHandle.cpp",
"src/ads_globals.cpp",
# "src/linux/FloatingWidgetTitleBar.cpp",
"src/linux/FloatingWidgetTitleBar.h; platform_system == 'Linux'",
]

View File

@ -0,0 +1,46 @@
%Import QtWidgets/QtWidgetsmod.sip
%If (Qt_5_0_0 -)
namespace ads
{
class CAutoHideDockContainer : QFrame
{
%TypeHeaderCode
#include <AutoHideDockContainer.h>
%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

41
sip/AutoHideSideBar.sip Normal file
View File

@ -0,0 +1,41 @@
%Import QtWidgets/QtWidgetsmod.sip
%If (Qt_5_0_0 -)
namespace ads
{
class CAutoHideSideBar : QScrollArea
{
%TypeHeaderCode
#include <AutoHideSideBar.h>
%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

36
sip/AutoHideTab.sip Normal file
View File

@ -0,0 +1,36 @@
%Import QtWidgets/QtWidgetsmod.sip
%If (Qt_5_0_0 -)
namespace ads
{
class CAutoHideTab : CPushButton
{
%TypeHeaderCode
#include <AutoHideTab.h>
%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

View File

@ -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:

View File

@ -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);

View File

@ -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();

View File

@ -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,124 +34,44 @@ protected:
ads::CDockAreaWidget* topLevelDockArea() const;
QList<ads::CDockWidget*> 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);
/**
* Removes dockwidget
*/
ads::CDockAreaWidget* DockAreaWidget /Transfer/ = 0,
int Index = -1);
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<ads::CDockAreaWidget*> openedDockAreas() const;
QList<ads::CDockWidget*> 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<ads::CAutoHideDockContainer*> 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

View File

@ -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);

View File

@ -156,7 +156,6 @@ public:
TabCloseButtonIsToolButton,
AllTabsHaveCloseButton,
RetainTabSizeWhenCloseButtonHidden,
OpaqueUndocking,
DragPreviewIsDynamic,
DragPreviewShowsContentPixmap,
DragPreviewHasWindowFrame,
@ -180,6 +179,17 @@ public:
NonOpaqueWithWindowFrame,
};
typedef QFlags<ads::CDockManager::eConfigFlag> ConfigFlags;
enum eAutoHideFlag
{
AutoHideFeatureEnabled,
DockAreaHasAutoHideButton,
AutoHideButtonTogglesArea,
AutoHideButtonCheckable,
AutoHideSideBarsIconOnly,
AutoHideShowOnMouseOver,
DefaultAutoHideConfig,
};
typedef QFlags<ads::CDockManager::eAutoHideFlag> AutoHideFlags;
CDockManager(QWidget* parent /TransferThis/ = 0);
virtual ~CDockManager();
@ -187,13 +197,24 @@ public:
static void setConfigFlags(const ads::CDockManager::ConfigFlags Flags);
static void setConfigFlag(ads::CDockManager::eConfigFlag Flag, bool On = true);
static bool testConfigFlag(eConfigFlag Flag);
static ads::CDockManager::AutoHideFlags autoHideConfigFlags();
static void setAutoHideConfigFlags(const ads::CDockManager::AutoHideFlags Flags);
static void setAutoHideConfigFlag(ads::CDockManager::eAutoHideFlag Flag, bool On = true);
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::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;
void removeDockWidget(ads::CDockWidget* Dockwidget) /TransferBack/;
@ -220,6 +241,8 @@ public:
ads::CDockWidget* focusedDockWidget() const;
QList<int> splitterSizes(ads::CDockAreaWidget *ContainedArea) const;
void setSplitterSizes(ads::CDockAreaWidget *ContainedArea, const QList<int>& sizes);
static void setFloatingContainersTitle(const QString& Title);
static QString floatingContainersTitle();
public slots:
void openPerspective(const QString& PerspectiveName);

View File

@ -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);

View File

@ -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)

View File

@ -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();

31
sip/PushButton.sip Normal file
View File

@ -0,0 +1,31 @@
%Import QtWidgets/QtWidgetsmod.sip
%If (Qt_5_0_0 -)
namespace ads
{
class CPushButton : QPushButton
{
%TypeHeaderCode
#include <PushButton.h>
%End
public:
enum Orientation {
Horizontal,
VerticalTopToBottom,
VerticalBottomToTop
};
virtual QSize sizeHint() const;
ads::CPushButton::Orientation buttonOrientation() const;
void setButtonOrientation(ads::CPushButton::Orientation orientation);
};
};
%End

36
sip/ResizeHandle.sip Normal file
View File

@ -0,0 +1,36 @@
%Import QtWidgets/QtWidgetsmod.sip
%If (Qt_5_0_0 -)
namespace ads
{
class CResizeHandle : QFrame
{
%TypeHeaderCode
#include <ResizeHandle.h>
%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

View File

@ -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

View File

@ -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);
};
};