Skip to content

Commit ec4a4d1

Browse files
renatofilhoiamsergio
authored andcommitted
Python: Create bindings for InitialOption
Added bindings for missing enums Added InitialOption as value type Task-Id: #198
1 parent 5ef330f commit ec4a4d1

File tree

6 files changed

+16
-9
lines changed

6 files changed

+16
-9
lines changed

python/PyKDDockWidgets/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ set(PyKDDockWidgets_SRC
1616
${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgets/kddockwidgets_dockwidgetbase_wrapper.h
1717
${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgets/kddockwidgets_dockwidget_wrapper.cpp
1818
${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgets/kddockwidgets_dockwidget_wrapper.h
19+
${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgets/kddockwidgets_initialoption_wrapper.cpp
20+
${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgets/kddockwidgets_initialoption_wrapper.h
1921
${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgets/kddockwidgets_mainwindowbase_wrapper.cpp
2022
${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgets/kddockwidgets_mainwindowbase_wrapper.h
2123
${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgets/kddockwidgets_mainwindow_wrapper.cpp

python/PyKDDockWidgets/typesystem_kddockwidgets.xml

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
otherwise shiboken will ignore the function and will fail to create a wrapper -->
1717
<primitive-type name="DropAreaWithCentralFrame"/>
1818
<primitive-type name="SideBar"/>
19-
<primitive-type name="InitialOption"/>
2019

2120
<!-- Some plublic enum and flags -->
2221
<enum-type name="Location"/>
@@ -28,20 +27,25 @@
2827
<enum-type name="DropIndicatorType"/>
2928
<enum-type name="SideBarLocation"/>
3029
<enum-type name="TitleBarButtonType"/>
30+
<enum-type name="SuggestedGeometryHint" flags="SuggestedGeometryHints" />
31+
<enum-type name="CursorPosition" flags="CursorPositions" />
32+
<enum-type name="AddingOption" />
3133

3234
<!-- our classes
3335
For class we can use two types:
3436
object-type: class that does not have a copy-contructor and can not be passed as value to functions;
3537
value-type: class that can be passed as value for functions
3638
Here we only use 'object-type' since all our classes are derived from QWidget
3739
-->
40+
<value-type name="InitialOption"/>
3841
<object-type name="MainWindowBase" />
3942
<object-type name="MainWindow" />
4043
<object-type name="DockWidgetBase" >
4144
<!-- this class contains a internal enum, so it should be declared
4245
inside of the object-type -->
4346
<enum-type name="Option" flags="Options" />
4447
<enum-type name="IconPlace" flags="IconPlaces" />
48+
<enum-type name="LayoutSaverOption" flags="LayoutSaverOptions" />
4549
</object-type>
4650

4751
<object-type name="DockWidget" />

python/examples/MyMainWindow.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ def createDockWidgets(self):
106106
self.m_dockwidgets.append(self.newDockWidget())
107107

108108
# MainWindow::addDockWidget() attaches a dock widget to the main window:
109-
self.addDockWidget(self.m_dockwidgets[0], KDDockWidgets.Location_OnTop)
109+
initialOpts = KDDockWidgets.InitialOption(KDDockWidgets.InitialVisibilityOption.StartHidden, QtCore.QSize(500, 500))
110+
self.addDockWidget(self.m_dockwidgets[0], KDDockWidgets.Location_OnBottom, None, initialOpts)
110111

111112
# Here, for finer granularity we specify right of dockwidgets[0]:
112113
self.addDockWidget(self.m_dockwidgets[1], KDDockWidgets.Location_OnRight, self.m_dockwidgets[0])

src/DockWidget.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ class DOCKS_EXPORT DockWidget : public DockWidgetBase
4949
* when visible, or stays without a parent when hidden. This allows to support docking
5050
* to different main windows.
5151
*/
52-
explicit DockWidget(const QString &uniqueName, Options options = DockWidgetBase::Options(),
53-
LayoutSaverOptions layoutSaverOptions = LayoutSaverOptions());
52+
explicit DockWidget(const QString &uniqueName, Options options = KDDockWidgets::DockWidgetBase::Options(),
53+
LayoutSaverOptions layoutSaverOptions = KDDockWidgets::DockWidgetBase::LayoutSaverOptions());
5454

5555
///@brief destructor
5656
~DockWidget() override;

src/DockWidgetBase.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ class DOCKS_EXPORT DockWidgetBase : public QWidget
109109
* when visible, or stays without a parent when hidden.
110110
*/
111111
explicit DockWidgetBase(const QString &uniqueName,
112-
Options options = DockWidgetBase::Options(),
113-
LayoutSaverOptions layoutSaverOptions = LayoutSaverOptions());
112+
Options options = KDDockWidgets::DockWidgetBase::Options(),
113+
LayoutSaverOptions layoutSaverOptions = KDDockWidgets::DockWidgetBase::LayoutSaverOptions());
114114

115115
///@brief destructor
116116
~DockWidgetBase() override;

src/KDDockWidgets.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ struct InitialOption
150150
* Next time you call DockWidget::show() it will be shown at that place. This avoids
151151
* flickering, as no show()/hide() workarounds are needed.
152152
*/
153-
const InitialVisibilityOption visibility = InitialVisibilityOption::StartVisible;
153+
InitialVisibilityOption visibility = InitialVisibilityOption::StartVisible;
154154

155155
/**
156156
* @brief Allows to control the size a dock widget should get when docked.
@@ -161,7 +161,7 @@ struct InitialOption
161161
* dock widget to the left then only the preferred width will be taken into account, as the
162162
* height will simply fill the whole layout.
163163
*/
164-
const QSize preferredSize;
164+
QSize preferredSize;
165165

166166
private:
167167
friend class Layouting::Item;
@@ -174,7 +174,7 @@ struct InitialOption
174174
{
175175
}
176176

177-
const DefaultSizeMode sizeMode = DefaultSizeMode::Fair;
177+
DefaultSizeMode sizeMode = DefaultSizeMode::Fair;
178178
};
179179

180180
enum RestoreOption

0 commit comments

Comments
 (0)