diff --git a/demo/demo.py b/demo/demo.py index ff268f6..5895ca4 100644 --- a/demo/demo.py +++ b/demo/demo.py @@ -203,8 +203,8 @@ class MainWindow(MainWindowUI, MainWindowBase): QtAds.CDockComponentsFactory.setFactory(CCustomComponentsFactory()) top_dock_area = self.dock_manager.addDockWidget(QtAds.TopDockWidgetArea, file_system_widget) # Uncomment the next line if you would like to test the - # setHideSingleWidgetTitleBar() functionality - # top_dock_area.setHideSingleWidgetTitleBar(True) + # HideSingleWidgetTitleBar functionality + # top_dock_area.setDockAreaFlag(QtAds.CDockAreaWidget.HideSingleWidgetTitleBar, True) QtAds.CDockComponentsFactory.resetDefaultFactory() # We create a calendar widget and clear all flags to prevent the dock area diff --git a/examples/centralwidget/centralWidget.py b/examples/centralwidget/centralWidget.py new file mode 100644 index 0000000..1587141 --- /dev/null +++ b/examples/centralwidget/centralWidget.py @@ -0,0 +1,75 @@ +import os +import sys + +from PyQt5 import uic +from PyQt5.QtCore import Qt, QTimer, QDir +from PyQt5.QtGui import QCloseEvent +from PyQt5.QtWidgets import (QApplication, QLabel, QCalendarWidget, QFrame, QTreeView, + QTableWidget, QFileSystemModel) + +from PyQtAds import QtAds + +UI_FILE = os.path.join(os.path.dirname(__file__), 'mainwindow.ui') +MainWindowUI, MainWindowBase = uic.loadUiType(UI_FILE) + + +class MainWindow(MainWindowUI, MainWindowBase): + + def __init__(self, parent=None): + super().__init__(parent) + + self.setupUi(self) + + QtAds.CDockManager.setConfigFlag(QtAds.CDockManager.OpaqueSplitterResize, True) + QtAds.CDockManager.setConfigFlag(QtAds.CDockManager.XmlCompressionEnabled, False) + self.dock_manager = QtAds.CDockManager(self) + + # Set central widget + calendar = QCalendarWidget() + central_dock_widget = QtAds.CDockWidget("CentralWidget") + central_dock_widget.setWidget(calendar) + central_dock_area = self.dock_manager.setCentralWidget(central_dock_widget) + central_dock_area.setAllowedAreas(QtAds.DockWidgetArea.OuterDockAreas) + + # create other dock widgets + file_tree = QTreeView() + file_tree.setFrameShape(QFrame.NoFrame) + file_model = QFileSystemModel(file_tree) + file_model.setRootPath(QDir.currentPath()) + file_tree.setModel(file_model) + data_dock_widget = QtAds.CDockWidget("File system") + data_dock_widget.setWidget(file_tree) + data_dock_widget.resize(150, 250) + data_dock_widget.setMinimumSize(100, 250) + file_area = self.dock_manager.addDockWidget(QtAds.DockWidgetArea.LeftDockWidgetArea, data_dock_widget, central_dock_area) + self.menuView.addAction(data_dock_widget.toggleViewAction()) + + table = QTableWidget() + table.setColumnCount(3) + table.setRowCount(10) + table_dock_widget = QtAds.CDockWidget("Table") + table_dock_widget.setWidget(table) + table_dock_widget.setMinimumSizeHintMode(QtAds.CDockWidget.MinimumSizeHintFromDockWidget) + table_dock_widget.resize(250, 150) + table_dock_widget.setMinimumSize(200, 150) + self.dock_manager.addDockWidget(QtAds.DockWidgetArea.BottomDockWidgetArea, table_dock_widget, file_area) + self.menuView.addAction(table_dock_widget.toggleViewAction()) + + properties_table = QTableWidget() + properties_table.setColumnCount(3) + properties_table.setRowCount(10) + properties_dock_widget = QtAds.CDockWidget("Properties") + properties_dock_widget.setWidget(properties_table) + properties_dock_widget.setMinimumSizeHintMode(QtAds.CDockWidget.MinimumSizeHintFromDockWidget) + properties_dock_widget.resize(250, 150) + properties_dock_widget.setMinimumSize(200,150) + self.dock_manager.addDockWidget(QtAds.DockWidgetArea.RightDockWidgetArea, properties_dock_widget, central_dock_area) + self.menuView.addAction(properties_dock_widget.toggleViewAction()) + + +if __name__ == '__main__': + app = QApplication(sys.argv) + + w = MainWindow() + w.show() + app.exec_() diff --git a/examples/centralwidget/mainwindow.cpp b/examples/centralwidget/mainwindow.cpp index f4c7858..943857b 100644 --- a/examples/centralwidget/mainwindow.cpp +++ b/examples/centralwidget/mainwindow.cpp @@ -65,8 +65,8 @@ CMainWindow::CMainWindow(QWidget *parent) ui->menuView->addAction(TableDockWidget->toggleViewAction()); QTableWidget* propertiesTable = new QTableWidget(); - table->setColumnCount(3); - table->setRowCount(10); + propertiesTable->setColumnCount(3); + propertiesTable->setRowCount(10); CDockWidget* PropertiesDockWidget = new CDockWidget("Properties"); PropertiesDockWidget->setWidget(propertiesTable); PropertiesDockWidget->setMinimumSizeHintMode(CDockWidget::MinimumSizeHintFromDockWidget); diff --git a/examples/simple/simple.py b/examples/simple/simple.py index fe24fc6..b21767d 100644 --- a/examples/simple/simple.py +++ b/examples/simple/simple.py @@ -21,7 +21,7 @@ class MainWindow(MainWindowUI, MainWindowBase): # Create the dock manager. Because the parent parameter is a QMainWindow # the dock manager registers itself as the central widget. - self.dock_manager1 = QtAds.CDockManager(self) + self.dock_manager = QtAds.CDockManager(self) # Create example content label - this can be any application specific # widget @@ -35,41 +35,13 @@ class MainWindow(MainWindowUI, MainWindowBase): dock_widget = QtAds.CDockWidget("Label 1") dock_widget.setWidget(l) - l = QLabel() - l.setWordWrap(True) - l.setAlignment(Qt.AlignTop | Qt.AlignLeft); - l.setText("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. ") - - # Create a dock widget with the title Label 1 and set the created label - # as the dock widget content - dock_widget2 = QtAds.CDockWidget("Label 2") - dock_widget2.setWidget(l) # Add the toggleViewAction of the dock widget to the menu to give # the user the possibility to show the dock widget if it has been closed self.menuView.addAction(dock_widget.toggleViewAction()) # Add the dock widget to the top dock widget area - self.dock_manager1.addDockWidget(QtAds.TopDockWidgetArea, dock_widget) - - def remove_first_manager(): - self.dock_manager1.removeDockWidget(dock_widget) - del self.dock_manager1 - QTimer.singleShot(3000, remove_first_manager) - - def add_second_manager(): - self.dock_manager2 = QtAds.CDockManager(self) - self.dock_manager2.addDockWidget(QtAds.TopDockWidgetArea, dock_widget) - QTimer.singleShot(5000, add_second_manager) - - def closeEvent(self, event: QCloseEvent): - super().closeEvent(event) - - if hasattr(self, 'dock_manager1'): - self.dock_manager1.deleteLater() - - if hasattr(self, 'dock_manager2'): - self.dock_manager2.deleteLater() + self.dock_manager.addDockWidget(QtAds.TopDockWidgetArea, dock_widget) if __name__ == '__main__': diff --git a/setup.py b/setup.py index 1986df7..31546a9 100644 --- a/setup.py +++ b/setup.py @@ -227,7 +227,9 @@ class build_ext(sipdistutils.build_ext): extension.extra_link_args += ['-F' + self.qtconfig.QT_INSTALL_LIBS, '-mmacosx-version-min=10.9'] elif sys.platform == 'linux': - extension.extra_compile_args += ['-std=c++11'] + extension.extra_compile_args += ['-D', 'QT_X11EXTRAS_LIB', '-std=c++11'] + extension.include_dirs += [os.path.join(self.qt_include_dir, 'QtX11Extras')] + extension.libraries += ['Qt5X11Extras' + self.qt_libinfix] return super().swig_sources(sources, extension) diff --git a/sip/DockAreaWidget.sip b/sip/DockAreaWidget.sip index f7f1e4a..8196047 100644 --- a/sip/DockAreaWidget.sip +++ b/sip/DockAreaWidget.sip @@ -28,6 +28,13 @@ protected slots: void toggleView(bool Open); public: + enum eDockAreaFlag + { + HideSingleWidgetTitleBar, + DefaultFlags + }; + typedef QFlags DockAreaFlags; + CDockAreaWidget(ads::CDockManager* DockManager /TransferThis/, ads::CDockContainerWidget* parent /TransferThis/); virtual ~CDockAreaWidget(); ads::CDockManager* dockManager() const; @@ -51,8 +58,13 @@ public: void setAllowedAreas(DockWidgetAreas areas); DockWidgetAreas allowedAreas() const; - void setHideSingleWidgetTitleBar(bool hide); CDockAreaTitleBar* titleBar() const; + + DockAreaFlags dockAreaFlags() const; + void setDockAreaFlags(DockAreaFlags Flags); + void setDockAreaFlag(eDockAreaFlag Flag, bool On); + + bool isCentralWidgetArea() const; public slots: void setCurrentIndex(int index); diff --git a/sip/DockContainerWidget.sip b/sip/DockContainerWidget.sip index ae90e3c..be8e6d7 100644 --- a/sip/DockContainerWidget.sip +++ b/sip/DockContainerWidget.sip @@ -32,6 +32,7 @@ protected: ads::CDockWidget* topLevelDockWidget() const; ads::CDockAreaWidget* topLevelDockArea() const; QList dockWidgets() const; + void updateSplitterHandles(QSplitter* splitter); public: /** diff --git a/sip/DockManager.sip b/sip/DockManager.sip index d5d2f7a..0f35a5c 100644 --- a/sip/DockManager.sip +++ b/sip/DockManager.sip @@ -170,6 +170,8 @@ public: HideSingleCentralWidgetTitleBar, FocusHighlighting, EqualSplitOnInsertion, + FloatingContainerForceNativeTitleBar, + FloatingContainerForceQWidgetTitleBar, DefaultDockAreaButtons, DefaultBaseConfig, DefaultOpaqueConfig, @@ -206,6 +208,8 @@ public: QStringList perspectiveNames() const; void savePerspectives(QSettings& Settings) const; void loadPerspectives(QSettings& Settings); + CDockWidget* centralWidget() const; + CDockAreaWidget* setCentralWidget(CDockWidget* widget /Transfer/); QAction* addToggleViewActionToMenu(QAction* ToggleViewAction /Transfer/, const QString& Group = QString(), const QIcon& GroupIcon = QIcon()); QMenu* viewMenu() const; diff --git a/sip/DockSplitter.sip b/sip/DockSplitter.sip index d6a5f31..2b567e2 100644 --- a/sip/DockSplitter.sip +++ b/sip/DockSplitter.sip @@ -18,6 +18,7 @@ public: bool hasVisibleContent() const; QWidget* firstWidget() const; QWidget* lastWidget() const; + bool isResizingWithContainer() const; }; diff --git a/sip/DockWidget.sip b/sip/DockWidget.sip index c61853b..5a8a097 100644 --- a/sip/DockWidget.sip +++ b/sip/DockWidget.sip @@ -84,6 +84,7 @@ public: QAction* toggleViewAction() const; void setToggleViewActionMode(ads::CDockWidget::eToggleViewActionMode Mode); void setMinimumSizeHintMode(ads::CDockWidget::eMinimumSizeHintMode Mode); + bool isCentralWidget() const; void setIcon(const QIcon& Icon); QIcon icon() const; QToolBar* toolBar() const; diff --git a/sip/FloatingDockContainer.sip b/sip/FloatingDockContainer.sip index 4e80db5..0a6d51f 100644 --- a/sip/FloatingDockContainer.sip +++ b/sip/FloatingDockContainer.sip @@ -52,11 +52,20 @@ protected: protected: virtual void changeEvent(QEvent *event); - virtual void moveEvent(QMoveEvent *event); - virtual bool event(QEvent *e); virtual void closeEvent(QCloseEvent *event); virtual void hideEvent(QHideEvent *event); virtual void showEvent(QShowEvent *event); + + %If (WS_MACX) + virtual bool event(QEvent *e); + virtual void moveEvent(QMoveEvent *event); + %End + + %If (WS_X11) + virtual void moveEvent(QMoveEvent *event); + virtual void resizeEvent(QResizeEvent *event); + %End + %If (WS_WIN) virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result); %End @@ -72,6 +81,15 @@ public: bool hasTopLevelDockWidget() const; ads::CDockWidget* topLevelDockWidget() const; QList dockWidgets() const; + + %If (WS_X11) + void onMaximizeRequest(); + void showNormal(bool fixGeometry); + void showMaximized(); + bool isMaximized() const; + void show(); + bool hasNativeTitleBar(); + %End }; }; diff --git a/sip/linux/FloatingWidgetTitleBar.sip b/sip/linux/FloatingWidgetTitleBar.sip index fe37bd3..44a2d38 100644 --- a/sip/linux/FloatingWidgetTitleBar.sip +++ b/sip/linux/FloatingWidgetTitleBar.sip @@ -15,15 +15,24 @@ protected: virtual void mousePressEvent(QMouseEvent *ev); virtual void mouseReleaseEvent(QMouseEvent *ev); virtual void mouseMoveEvent(QMouseEvent *ev); + virtual void mouseDoubleClickEvent(QMouseEvent *event); + + void setMaximizeIcon(const QIcon& Icon); + QIcon maximizeIcon() const; + void setNormalIcon(const QIcon& Icon); + QIcon normalIcon() const; public: explicit CFloatingWidgetTitleBar(CFloatingDockContainer *parent /TransferThis/ = 0); virtual ~CFloatingWidgetTitleBar(); void enableCloseButton(bool Enable); void setTitle(const QString &Text); + void updateStyle(); + void setMaximizedIcon(bool maximized); signals: void closeRequested(); + void maximizeRequested(); }; };