diff --git a/src/Frame_p.h b/src/Frame_p.h
index b5f83f03..84060219 100644
--- a/src/Frame_p.h
+++ b/src/Frame_p.h
@@ -58,6 +58,8 @@ class FloatingWindow;
class DOCKS_EXPORT Frame : public QWidgetAdapter
{
Q_OBJECT
+
+ Q_PROPERTY(KDDockWidgets::TitleBar* titleBar READ titleBar CONSTANT)
public:
typedef QList List;
typedef int Options;
diff --git a/src/qtquick.qrc b/src/qtquick.qrc
index ea3bb215..4fb907fd 100644
--- a/src/qtquick.qrc
+++ b/src/qtquick.qrc
@@ -3,5 +3,7 @@
quick/qml/Frame.qml
quick/qml/MainWindow.qml
quick/qml/Separator.qml
+ quick/qml/TitleBarBase.qml
+ quick/qml/TitleBar.qml
diff --git a/src/quick/FrameQuick.cpp b/src/quick/FrameQuick.cpp
index 90f759ef..9f69e325 100644
--- a/src/quick/FrameQuick.cpp
+++ b/src/quick/FrameQuick.cpp
@@ -39,8 +39,8 @@ FrameQuick::FrameQuick(QWidgetAdapter *parent, Options options)
auto component = new QQmlComponent(Config::self().qmlEngine(),
QUrl(QStringLiteral("qrc:/kddockwidgets/quick/qml/Frame.qml")));
-
- auto separatorItem = static_cast(component->create());
- separatorItem->setParentItem(this);
- separatorItem->setParent(this);
+ auto item = static_cast(component->create());
+ item->setProperty("frameCpp", QVariant::fromValue(this));
+ item->setParentItem(this);
+ item->setParent(this);
}
diff --git a/src/quick/QmlTypes.cpp b/src/quick/QmlTypes.cpp
index 7e3af9fe..4724cfc0 100644
--- a/src/quick/QmlTypes.cpp
+++ b/src/quick/QmlTypes.cpp
@@ -21,6 +21,7 @@
#include "QmlTypes.h"
#include "DropAreaWithCentralFrame_p.h"
#include "quick/MainWindowQuick_p.h"
+#include "TitleBar_p.h"
#include
#include
@@ -30,4 +31,6 @@ void KDDockWidgets::registerQmlTypes()
qDebug() << "Registering types";
qmlRegisterType("com.kdab.dockwidgets", 1, 0, "DropAreaWithCentralFrame");
qmlRegisterType("com.kdab.dockwidgets", 1, 0, "MainWindowQuick");
+
+ qmlRegisterUncreatableType("com.kdab.dockwidgets", 1, 0, "TitleBar", QStringLiteral("Enum access only"));
}
diff --git a/src/quick/TitleBarQuick.cpp b/src/quick/TitleBarQuick.cpp
index 3bb57a93..7b9f0087 100644
--- a/src/quick/TitleBarQuick.cpp
+++ b/src/quick/TitleBarQuick.cpp
@@ -43,23 +43,3 @@ TitleBarQuick::TitleBarQuick(FloatingWindow *parent)
TitleBarQuick::~TitleBarQuick()
{
}
-
-bool TitleBarQuick::isCloseButtonVisible() const
-{
- return false;
-}
-
-bool TitleBarQuick::isCloseButtonEnabled() const
-{
- return false;
-}
-
-bool TitleBarQuick::isFloatButtonVisible() const
-{
- return false;
-}
-
-bool TitleBarQuick::isFloatButtonEnabled() const
-{
- return false;
-}
diff --git a/src/quick/TitleBarQuick_p.h b/src/quick/TitleBarQuick_p.h
index 3992b1f6..13129624 100644
--- a/src/quick/TitleBarQuick_p.h
+++ b/src/quick/TitleBarQuick_p.h
@@ -47,12 +47,6 @@ protected:
void mouseDoubleClickEvent(QMouseEvent *) override;
void updateFloatButton() override;
void updateCloseButton() override;*/
-
- // The following are needed for the unit-tests
- bool isCloseButtonVisible() const override;
- bool isCloseButtonEnabled() const override;
- bool isFloatButtonVisible() const override;
- bool isFloatButtonEnabled() const override;
//
};
diff --git a/src/quick/qml/Frame.qml b/src/quick/qml/Frame.qml
index 37eaa413..5df559f1 100644
--- a/src/quick/qml/Frame.qml
+++ b/src/quick/qml/Frame.qml
@@ -2,6 +2,18 @@ import QtQuick 2.9
Rectangle {
id: root
+ property QtObject frameCpp
+
color: "cyan"
anchors.fill: parent
+
+ TitleBar {
+ height: 30
+ titleBarCpp: frameCpp ? frameCpp.titleBar : null
+ anchors {
+ top: parent.top
+ left: parent.left
+ right: parent.right
+ }
+ }
}
diff --git a/src/quick/qml/TitleBar.qml b/src/quick/qml/TitleBar.qml
new file mode 100644
index 00000000..52fd5cd8
--- /dev/null
+++ b/src/quick/qml/TitleBar.qml
@@ -0,0 +1,55 @@
+import QtQuick 2.9
+
+TitleBarBase {
+ id: root
+
+ Text {
+ id: title
+ text: root.title
+ anchors {
+ left: parent.left
+ leftMargin: 5
+ }
+ }
+
+ Rectangle {
+ id: floatButton
+ color: "red"
+ anchors {
+ top: parent.top
+ bottom: parent.bottom
+ right: closeButton.left
+ topMargin: 5
+ bottomMargin: 5
+ rightMargin: 5
+ }
+ width: height
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ console.log("Float clicked")
+ }
+ }
+ }
+
+ Rectangle {
+ id: closeButton
+ color: "red"
+ anchors {
+ top: parent.top
+ bottom: parent.bottom
+ right: parent.right
+ topMargin: 5
+ bottomMargin: 5
+ leftMargin: 5
+ }
+ width: height
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ console.log("Close clicked")
+ }
+ }
+ }
+}
diff --git a/src/quick/qml/TitleBarBase.qml b/src/quick/qml/TitleBarBase.qml
new file mode 100644
index 00000000..c5ff63e2
--- /dev/null
+++ b/src/quick/qml/TitleBarBase.qml
@@ -0,0 +1,11 @@
+import QtQuick 2.9
+
+Rectangle {
+ id: root
+
+ property QtObject titleBarCpp
+ readonly property string title: titleBarCpp ? titleBarCpp.title : ""
+
+ visible: titleBarCpp && titleBarCpp.visible
+ implicitHeight: 30
+}