mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-24 23:31:32 +08:00
Merge branch 'master' of https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System
This commit is contained in:
commit
42dc529ce1
@ -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
|
||||
|
75
examples/centralwidget/centralWidget.py
Normal file
75
examples/centralwidget/centralWidget.py
Normal file
@ -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_()
|
@ -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);
|
||||
|
@ -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__':
|
||||
|
4
setup.py
4
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)
|
||||
|
||||
|
@ -28,6 +28,13 @@ protected slots:
|
||||
void toggleView(bool Open);
|
||||
|
||||
public:
|
||||
enum eDockAreaFlag
|
||||
{
|
||||
HideSingleWidgetTitleBar,
|
||||
DefaultFlags
|
||||
};
|
||||
typedef QFlags<ads::CDockAreaWidget::eDockAreaFlag> 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);
|
||||
|
@ -32,6 +32,7 @@ protected:
|
||||
ads::CDockWidget* topLevelDockWidget() const;
|
||||
ads::CDockAreaWidget* topLevelDockArea() const;
|
||||
QList<ads::CDockWidget*> dockWidgets() const;
|
||||
void updateSplitterHandles(QSplitter* splitter);
|
||||
|
||||
public:
|
||||
/**
|
||||
|
@ -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;
|
||||
|
@ -18,6 +18,7 @@ public:
|
||||
bool hasVisibleContent() const;
|
||||
QWidget* firstWidget() const;
|
||||
QWidget* lastWidget() const;
|
||||
bool isResizingWithContainer() const;
|
||||
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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<ads::CDockWidget*> dockWidgets() const;
|
||||
|
||||
%If (WS_X11)
|
||||
void onMaximizeRequest();
|
||||
void showNormal(bool fixGeometry);
|
||||
void showMaximized();
|
||||
bool isMaximized() const;
|
||||
void show();
|
||||
bool hasNativeTitleBar();
|
||||
%End
|
||||
};
|
||||
|
||||
};
|
||||
|
@ -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();
|
||||
};
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user