First Commit

This commit is contained in:
2025-11-18 14:18:26 -07:00
parent 33eb6e3707
commit 27277ec342
6106 changed files with 3571167 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Sergio Martins <sergio.martins@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
add_subdirectory(dockwidgets)
add_subdirectory(mdi)
add_subdirectory(customtitlebar)
add_subdirectory(customtabbar)
add_subdirectory(customseparator)
add_subdirectory(customplayground)
add_subdirectory(fixed_central_widget)
add_subdirectory(mdi_with_docking)

View File

@@ -0,0 +1,35 @@
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2019 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Sergio Martins <sergio.martins@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
cmake_minimum_required(VERSION 3.15)
project(qtquick_customplayground)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIRS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT TARGET kddockwidgets)
# For the purpose of our example, we're looking for Qt5 or Qt6 KDDW.
# For your own purposes, just chose the one you need.
find_package(KDDockWidgets QUIET)
if(NOT KDDockWidgets_FOUND)
find_package(KDDockWidgets-qt6 REQUIRED)
endif()
endif()
set(RESOURCES_EXAMPLE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/resources_qtquick_example.qrc
${CMAKE_CURRENT_SOURCE_DIR}/../../dockwidgets/resources_example.qrc
)
add_executable(qtquick_customplayground main.cpp ${RESOURCES_EXAMPLE_SRC})
target_link_libraries(qtquick_customplayground PRIVATE KDAB::kddockwidgets)

View File

@@ -0,0 +1,47 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
import QtQuick.Controls 2.15
Item {
anchors.fill: parent
property alias background: background.source
property alias logo: logo.source
Image {
id: background
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
Image {
id: logo
fillMode: Image.PreserveAspectFit
anchors {
fill: parent
margins: 50
}
}
}
TextField {
placeholderText: "TextField just to test focus"
anchors {
bottom: parent.bottom
left: parent.left
right: parent.right
margins: 5
}
}
}

View File

@@ -0,0 +1,18 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Guest {
anchors.fill: parent
background: "qrc:/assets/triangles.png"
logo: "qrc:/assets/KDAB_bubble_white.png"
}

View File

@@ -0,0 +1,17 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Guest {
anchors.fill: parent
logo: "qrc:/assets/KDAB_bubble_blue.png"
}

View File

@@ -0,0 +1,18 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Guest {
anchors.fill: parent
background: "qrc:/assets/base.png"
logo: "qrc:/assets/KDAB_bubble_fulcolor.png"
}

View File

@@ -0,0 +1,18 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Guest {
anchors.fill: parent
background: "qrc:/assets/triangles.png"
logo: "qrc:/assets/KDAB_bubble_white.png"
}

View File

@@ -0,0 +1,22 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.6
// Will be moved to a plugin in the future, if there's enough demand
import "qrc:/kddockwidgets/qtquick/views/qml/" as KDDW
KDDW.DockWidget {
id: root
color: "black"
border.color: (dockWidgetCpp && dockWidgetCpp.isFocused) ? "orange" : "black"
border.width: (dockWidgetCpp && dockWidgetCpp.isFocused) ? 2 : 1
}

View File

@@ -0,0 +1,41 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.6
Rectangle {
id: root
anchors.fill: parent
color: "orange"
readonly property QtObject kddwSeparator: parent
MouseArea {
cursorShape: kddwSeparator ? (kddwSeparator.isVertical ? Qt.SizeVerCursor : Qt.SizeHorCursor)
: Qt.SizeHorCursor
anchors.fill: parent
onPressed: {
kddwSeparator.onMousePressed();
}
onReleased: {
kddwSeparator.onMouseReleased();
}
onPositionChanged: (mouse) => {
kddwSeparator.onMouseMoved(Qt.point(mouse.x, mouse.y));
}
onDoubleClicked: {
kddwSeparator.onMouseDoubleClicked();
}
}
}

View File

@@ -0,0 +1,83 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.6
// Will be moved to a plugin in the future, if there's enough demand
import "qrc:/kddockwidgets/qtquick/views/qml/" as KDDW
KDDW.TitleBarBase {
id: root
color: "black"
border.color: "orange"
border.width: 2
heightWhenVisible: 50
Text {
color: isFocused ? "cyan" : "orange"
font.bold: isFocused
text: root.title
anchors {
left: parent.left
leftMargin: 10
verticalCenter: root.verticalCenter
}
}
Row {
id: buttonRow
spacing: 10
height: root.height - 20
anchors {
right: root.right
rightMargin: 10
verticalCenter: root.verticalCenter
}
Rectangle {
id: floatButton
visible: root.floatButtonVisible
radius: 5
color: isFocused ? "red" : "white"
height: parent.height
width: height
MouseArea {
anchors.fill: parent
onClicked: {
root.floatButtonClicked();
}
}
}
Rectangle {
id: closeButton
enabled: root.closeButtonEnabled
radius: 5
color: isFocused ? "cyan" : "green"
height: parent.height
width: height
Text {
anchors.centerIn: parent
text: "X"
}
MouseArea {
anchors.fill: parent
onClicked: {
root.closeButtonClicked();
}
}
}
}
}

View File

@@ -0,0 +1,98 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#include <kddockwidgets/Config.h>
#include <kddockwidgets/core/DockRegistry.h>
#include <kddockwidgets/qtquick/views/DockWidget.h>
#include <kddockwidgets/qtquick/Platform.h>
#include <kddockwidgets/qtquick/ViewFactory.h>
#include <kddockwidgets/qtquick/views/MainWindow.h>
#include <QQuickView>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
/// A playground for playing with styling
class CustomViewFactory : public KDDockWidgets::QtQuick::ViewFactory
{
public:
~CustomViewFactory() override;
QUrl dockwidgetFilename() const override
{
return QUrl("qrc:/MyDockWidget.qml");
}
QUrl titleBarFilename() const override
{
return KDDockWidgets::QtQuick::ViewFactory::titleBarFilename();
}
QUrl separatorFilename() const override
{
return KDDockWidgets::QtQuick::ViewFactory::separatorFilename();
}
QUrl groupFilename() const override
{
return KDDockWidgets::QtQuick::ViewFactory::groupFilename();
}
QUrl floatingWindowFilename() const override
{
return KDDockWidgets::QtQuick::ViewFactory::floatingWindowFilename();
}
};
CustomViewFactory::~CustomViewFactory() = default;
int main(int argc, char *argv[])
{
#ifdef Q_OS_WIN
QGuiApplication::setAttribute(Qt::AA_UseOpenGLES);
#endif
QGuiApplication app(argc, argv);
KDDockWidgets::initFrontend(KDDockWidgets::FrontendType::QtQuick);
auto &config = KDDockWidgets::Config::self();
auto flags = config.flags() | KDDockWidgets::Config::Flag_TitleBarIsFocusable;
config.setFlags(flags);
config.setViewFactory(new CustomViewFactory());
QQmlApplicationEngine appEngine;
KDDockWidgets::QtQuick::Platform::instance()->setQmlEngine(&appEngine);
appEngine.load((QUrl("qrc:/main.qml")));
auto dw1 = new KDDockWidgets::QtQuick::DockWidget("Dock #1");
dw1->setGuestItem(QStringLiteral("qrc:/Guest1.qml"));
dw1->resize(QSize(800, 800));
dw1->open();
auto dw2 = new KDDockWidgets::QtQuick::DockWidget("Dock #2");
dw2->setGuestItem(QStringLiteral("qrc:/Guest2.qml"));
dw2->resize(QSize(800, 800));
dw2->open();
auto dw3 = new KDDockWidgets::QtQuick::DockWidget("Dock #3");
dw3->setGuestItem(QStringLiteral("qrc:/Guest3.qml"));
dw1->addDockWidgetToContainingWindow(dw3, KDDockWidgets::Location_OnRight);
// Access the main area we created in QML with DockingArea {}
auto mainArea = KDDockWidgets::DockRegistry::self()->mainDockingAreas().constFirst();
mainArea->addDockWidget(dw2, KDDockWidgets::Location_OnTop);
return app.exec();
}

View File

@@ -0,0 +1,42 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.6
import QtQuick.Controls 2.12
import com.kdab.dockwidgets 2.0 as KDDW
ApplicationWindow {
visible: true
width: 1000
height: 800
KDDW.DockingArea {
id: dockWidgetArea
anchors.fill: parent
uniqueName: "MyMainLayout"
KDDW.DockWidget {
id: dock4
uniqueName: "dock4"
source: "qrc:/Guest4.qml"
onIsFocusedChanged: {
console.log("Dock4 focus changed to: " + isFocused);
}
}
Component.onCompleted: {
// The other 3 dock widgets are created via C++ in main.cpp
// For illustration purposes, here's a .qml version. Maybe its the preferred form even.
addDockWidget(dock4, KDDW.KDDockWidgets.Location_OnBottom);
}
}
}

View File

@@ -0,0 +1,13 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>Guest1.qml</file>
<file>Guest2.qml</file>
<file>Guest3.qml</file>
<file>Guest4.qml</file>
<file>Guest.qml</file>
<file>MyTitleBar.qml</file>
<file>MySeparator.qml</file>
<file>MyDockWidget.qml</file>
</qresource>
</RCC>

View File

@@ -0,0 +1,35 @@
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Sergio Martins <sergio.martins@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
cmake_minimum_required(VERSION 3.15)
project(qtquick_customseparator)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIRS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT TARGET kddockwidgets)
# For the purpose of our example, we're looking for Qt5 or Qt6 KDDW.
# For your own purposes, just chose the one you need.
find_package(KDDockWidgets QUIET)
if(NOT KDDockWidgets_FOUND)
find_package(KDDockWidgets-qt6 REQUIRED)
endif()
endif()
set(RESOURCES_EXAMPLE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/resources_qtquick_example.qrc
${CMAKE_CURRENT_SOURCE_DIR}/../../dockwidgets/resources_example.qrc
)
add_executable(qtquick_customseparator main.cpp ${RESOURCES_EXAMPLE_SRC})
target_link_libraries(qtquick_customseparator PRIVATE KDAB::kddockwidgets)

View File

@@ -0,0 +1,36 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Item {
anchors.fill: parent
property alias background: background.source
property alias logo: logo.source
Image {
id: background
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
Image {
id: logo
fillMode: Image.PreserveAspectFit
anchors {
fill: parent
margins: 50
}
}
}
}

View File

@@ -0,0 +1,18 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Guest {
anchors.fill: parent
background: "qrc:/assets/triangles.png"
logo: "qrc:/assets/KDAB_bubble_white.png"
}

View File

@@ -0,0 +1,17 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Guest {
anchors.fill: parent
logo: "qrc:/assets/KDAB_bubble_blue.png"
}

View File

@@ -0,0 +1,18 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Guest {
anchors.fill: parent
background: "qrc:/assets/base.png"
logo: "qrc:/assets/KDAB_bubble_fulcolor.png"
}

View File

@@ -0,0 +1,18 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Guest {
anchors.fill: parent
background: "qrc:/assets/triangles.png"
logo: "qrc:/assets/KDAB_bubble_white.png"
}

View File

@@ -0,0 +1,65 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.6
Rectangle {
id: root
anchors.fill: parent
color: "orange"
// Might be needed as MouseArea overlaps with the dock widgets, since it's bigger than
// its parent.
z: 2
readonly property QtObject kddwSeparator: parent
MouseArea {
cursorShape: kddwSeparator ? (kddwSeparator.isVertical ? Qt.SizeVerCursor : Qt.SizeHorCursor)
: Qt.SizeHorCursor
// Make the MouseArea bigger than its parent, so it can detect mouse easier
// Since we're using only 2px of thickness.
readonly property int hoverThreshold: 2
anchors {
left: parent.left
right: parent.right
top: parent.top
bottom: parent.bottom
leftMargin: (kddwSeparator && !kddwSeparator.isVertical) ? -hoverThreshold : 0
rightMargin: (kddwSeparator && !kddwSeparator.isVertical) ? -hoverThreshold : 0
topMargin: (kddwSeparator && kddwSeparator.isVertical) ? -hoverThreshold : 0
bottomMargin: (kddwSeparator && kddwSeparator.isVertical) ? -hoverThreshold : 0
}
// uncomment for debugging your mouse area
// Rectangle {
// color: "red"
// anchors.fill: parent
// }
onPressed: {
kddwSeparator.onMousePressed();
}
onReleased: {
kddwSeparator.onMouseReleased();
}
onPositionChanged: (mouse) => {
kddwSeparator.onMouseMoved(Qt.point(mouse.x, mouse.y));
}
onDoubleClicked: {
kddwSeparator.onMouseDoubleClicked();
}
}
}

View File

@@ -0,0 +1,54 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.6
// Will be moved to a plugin in the future, if there's enough demand
import "qrc:/kddockwidgets/qtquick/views/qml/" as KDDW
KDDW.TitleBarBase {
id: root
color: "black"
border.color: "orange"
border.width: 2
heightWhenVisible: 50
Text {
color: isFocused ? "cyan" : "orange"
font.bold: isFocused
text: root.title
anchors {
left: parent.left
leftMargin: 10
verticalCenter: root.verticalCenter
}
}
Rectangle {
id: closeButton
enabled: root.closeButtonEnabled
radius: 5
color: isFocused ? "cyan" : "green"
height: root.height - 20
width: height
anchors {
right: root.right
rightMargin: 10
verticalCenter: root.verticalCenter
}
MouseArea {
anchors.fill: parent
onClicked: {
root.closeButtonClicked();
}
}
}
}

View File

@@ -0,0 +1,20 @@
# qtquick_customseparator
In this example we illustrate how to provide a custom resize separator.<br>
Here we list the main things to remember:
- In your `CustomViewFactory` override `separatorFilename()`
- Tell KDDW about your view factory `config.setViewFactory(new CustomViewFactory());`.
- Optionally, call `config.setSeparatorThickness(2);` to control the thickness.
This is not done via styling, as the layouting engine needs to know the value.
The default is 5 pixels.
- Implement your `MySeparator.qml` and put it into your QRC.
Base it from our example, as we take care of some boilerplate.
- If you set the thickness too small it might not detect mouse hover,
but we improve that by increasing the `MouseArea`'s size by manipulating
its margins

View File

@@ -0,0 +1,75 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#include <kddockwidgets/Config.h>
#include <kddockwidgets/core/DockRegistry.h>
#include <kddockwidgets/qtquick/views/DockWidget.h>
#include <kddockwidgets/qtquick/Platform.h>
#include <kddockwidgets/qtquick/ViewFactory.h>
#include <kddockwidgets/qtquick/views/MainWindow.h>
#include <QQuickView>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
class CustomViewFactory : public KDDockWidgets::QtQuick::ViewFactory
{
public:
~CustomViewFactory() override;
QUrl separatorFilename() const override
{
return QUrl("qrc:/MySeparator.qml");
}
};
CustomViewFactory::~CustomViewFactory() = default;
int main(int argc, char *argv[])
{
#ifdef Q_OS_WIN
QGuiApplication::setAttribute(Qt::AA_UseOpenGLES);
#endif
QGuiApplication app(argc, argv);
KDDockWidgets::initFrontend(KDDockWidgets::FrontendType::QtQuick);
auto &config = KDDockWidgets::Config::self();
config.setSeparatorThickness(2);
config.setViewFactory(new CustomViewFactory());
QQmlApplicationEngine appEngine;
KDDockWidgets::QtQuick::Platform::instance()->setQmlEngine(&appEngine);
appEngine.load((QUrl("qrc:/main.qml")));
auto dw1 = new KDDockWidgets::QtQuick::DockWidget("Dock #1");
dw1->setGuestItem(QStringLiteral("qrc:/Guest1.qml"));
dw1->resize(QSize(800, 800));
dw1->open();
auto dw2 = new KDDockWidgets::QtQuick::DockWidget("Dock #2");
dw2->setGuestItem(QStringLiteral("qrc:/Guest2.qml"));
dw2->resize(QSize(800, 800));
dw2->open();
auto dw3 = new KDDockWidgets::QtQuick::DockWidget("Dock #3");
dw3->setGuestItem(QStringLiteral("qrc:/Guest3.qml"));
dw1->addDockWidgetToContainingWindow(dw3, KDDockWidgets::Location_OnRight);
// Access the main area we created in QML with DockingArea {}
auto mainArea = KDDockWidgets::DockRegistry::self()->mainDockingAreas().constFirst();
mainArea->addDockWidget(dw2, KDDockWidgets::Location_OnTop);
return app.exec();
}

View File

@@ -0,0 +1,42 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.6
import QtQuick.Controls 2.12
import com.kdab.dockwidgets 2.0 as KDDW
ApplicationWindow {
visible: true
width: 1000
height: 800
KDDW.DockingArea {
id: dockWidgetArea
anchors.fill: parent
uniqueName: "MyMainLayout"
KDDW.DockWidget {
id: dock4
uniqueName: "dock4"
source: "qrc:/Guest4.qml"
onIsFocusedChanged: {
console.log("Dock4 focus changed to: " + isFocused);
}
}
Component.onCompleted: {
// The other 3 dock widgets are created via C++ in main.cpp
// For illustration purposes, here's a .qml version. Maybe its the preferred form even.
addDockWidget(dock4, KDDW.KDDockWidgets.Location_OnBottom);
}
}
}

View File

@@ -0,0 +1,12 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>Guest1.qml</file>
<file>Guest2.qml</file>
<file>Guest3.qml</file>
<file>Guest4.qml</file>
<file>Guest.qml</file>
<file>MyTitleBar.qml</file>
<file>MySeparator.qml</file>
</qresource>
</RCC>

View File

@@ -0,0 +1,35 @@
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2019 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Sergio Martins <sergio.martins@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
cmake_minimum_required(VERSION 3.15)
project(qtquick_customtabbar)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIRS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT TARGET kddockwidgets)
# For the purpose of our example, we're looking for Qt5 or Qt6 KDDW.
# For your own purposes, just chose the one you need.
find_package(KDDockWidgets QUIET)
if(NOT KDDockWidgets_FOUND)
find_package(KDDockWidgets-qt6 REQUIRED)
endif()
endif()
set(RESOURCES_EXAMPLE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/resources_qtquick_example.qrc
${CMAKE_CURRENT_SOURCE_DIR}/../../dockwidgets/resources_example.qrc
)
add_executable(qtquick_customtabbar main.cpp ${RESOURCES_EXAMPLE_SRC})
target_link_libraries(qtquick_customtabbar PRIVATE KDAB::kddockwidgets)

View File

@@ -0,0 +1,36 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Item {
anchors.fill: parent
property alias background: background.source
property alias logo: logo.source
Image {
id: background
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
Image {
id: logo
fillMode: Image.PreserveAspectFit
anchors {
fill: parent
margins: 50
}
}
}
}

View File

@@ -0,0 +1,18 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Guest {
anchors.fill: parent
background: "qrc:/assets/triangles.png"
logo: "qrc:/assets/KDAB_bubble_white.png"
}

View File

@@ -0,0 +1,17 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Guest {
anchors.fill: parent
logo: "qrc:/assets/KDAB_bubble_blue.png"
}

View File

@@ -0,0 +1,18 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Guest {
anchors.fill: parent
background: "qrc:/assets/base.png"
logo: "qrc:/assets/KDAB_bubble_fulcolor.png"
}

View File

@@ -0,0 +1,172 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.6
// Will be moved to a plugin in the future, if there's enough demand
import "qrc:/kddockwidgets/qtquick/views/qml/" as KDDW
/// Example of a QML Tab Bar that doesn't use QtQuick.Controls, just for demo purposes.
/// Se the comments named "#HERE#" for important things you shouldn't forget.
KDDW.TabBarBase {
id: root
implicitHeight: 30
currentTabIndex: 0
/// Optionally, we add a background.
Rectangle {
id: tabBarBackground
color: "#85baa1"
anchors.fill: parent
z: tabBarRow.z + 100
Rectangle {
id: addButton
width: 50
color: addButtonMouseArea.containsMouse ? (addButtonMouseArea.pressed ? "#d6ce93" : "#ffecd1" ) : "#ffecd1"
anchors {
right: parent.right
top: parent.top
bottom: parent.bottom
topMargin: 5
rightMargin: 5
}
Text {
text: "+"
font.pixelSize: 24
anchors.centerIn: parent
}
MouseArea {
id: addButtonMouseArea
anchors.fill: parent
hoverEnabled: true
onPressed: {
/// Do not use random uuids if you're planing to use layout save/restore!
/// Using them here for convenience of the exercise
var uniqueName = _kddwHelpers.generateUuid();
var code = `import com.kdab.dockwidgets 2.0 as KDDW;
import QtQuick 2.6;
KDDW.DockWidget {
uniqueName: "${uniqueName}";
title: "dynamic";
Rectangle {
color: "#85baa1";
anchors.fill: parent;
}
}`;
var newDW = Qt.createQmlObject(code, root);
tabBarCpp.addDockWidgetAsTab(newDW);
}
}
}
}
/// #HERE#. This function required in all derived tab bars. It's called by C++;
/// Returns the tab bar (QQuickItem*) at the specified index.
function getTabAtIndex(index) {
return tabBarRow.children[index];
}
/// #HERE#. This function required in all derived tab bars. It's called by C++;
/// Returns an int, with the index of the tab that's at the specified position.
function getTabIndexAtPosition(globalPoint) {
for (var i = 0; i < tabBarRow.children.length; ++i) {
var tab = tabBarRow.children[i];
var localPt = tab.mapFromGlobal(globalPoint.x, globalPoint.y);
if (tab.contains(localPt)) {
return i;
}
}
return -1;
}
Row {
id: tabBarRow
/// #HERE#: If you're going to add any custom MouseAreas please use set a higher Z than the builtin one
z: root.mouseAreaZ.z + 1
anchors.fill: parent
spacing: 2
/// Needed only if you want to style hovered tabs differently
property int hoveredIndex: -1;
/// ##HERE## The list of tabs is stored in a C++ model. This repeater populates our tab bar
Repeater {
model: root.groupCpp ? root.groupCpp.tabBar.dockWidgetModel : 0
Rectangle {
id: tab
height: parent.height
width: 150
readonly property bool isCurrent: index == root.groupCpp.currentIndex;
color: (tabBarRow.hoveredIndex == index) ? "#d6ce93" : (isCurrent ? "#d6ce93" : "#ffecd1")
border.color: "black"
// ##HERE## Illustrating how to have a different style in case the tab is current
border.width: isCurrent ? 2 : 1
radius: 2
// ##HERE## The index of the tab. This is required in all custom tab bar implementations
// It is be used by "getTabAtIndex()" and "getTabIndexAtPosition()" functions
readonly property int tabIndex: index
Text {
anchors.centerIn: parent
text: title
}
// Optionally, and for illustration purposes, we add a close button
Rectangle {
id: closeButton
color: "transparent"
radius: 3
border.width: closeButtonMouseArea.containsMouse ? 1 : 0
border.color: "black"
height: 17
width: height
anchors {
right: parent.right
rightMargin: 4
verticalCenter: parent.verticalCenter
}
Image {
source: "qrc:/img/close.png"
anchors.centerIn: parent
MouseArea {
id: closeButtonMouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: {
tabBarCpp.closeAtIndex(index);
}
}
}
}
}
}
Connections {
target: tabBarCpp
function onHoveredTabIndexChanged(index) {
tabBarRow.hoveredIndex = index;
}
}
}
}

View File

@@ -0,0 +1,74 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#include <kddockwidgets/Config.h>
#include <kddockwidgets/core/DockRegistry.h>
#include <kddockwidgets/qtquick/views/DockWidget.h>
#include <kddockwidgets/qtquick/Platform.h>
#include <kddockwidgets/qtquick/ViewFactory.h>
#include <kddockwidgets/core/MainWindow.h>
#include <kddockwidgets/core/views/MainWindowViewInterface.h>
#include <QQuickView>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
class CustomViewFactory : public KDDockWidgets::QtQuick::ViewFactory
{
public:
~CustomViewFactory() override;
QUrl tabbarFilename() const override
{
return QUrl("qrc:/MyTabBar.qml");
}
};
CustomViewFactory::~CustomViewFactory() = default;
int main(int argc, char *argv[])
{
#ifdef Q_OS_WIN
QGuiApplication::setAttribute(Qt::AA_UseOpenGLES);
#endif
QGuiApplication app(argc, argv);
KDDockWidgets::initFrontend(KDDockWidgets::FrontendType::QtQuick);
auto &config = KDDockWidgets::Config::self();
auto flags = config.flags();
config.setFlags(flags);
config.setViewFactory(new CustomViewFactory());
QQmlApplicationEngine appEngine;
KDDockWidgets::QtQuick::Platform::instance()->setQmlEngine(&appEngine);
appEngine.load((QUrl("qrc:/main.qml")));
auto dw1 = new KDDockWidgets::QtQuick::DockWidget("Dock #1");
dw1->setGuestItem(QStringLiteral("qrc:/Guest1.qml"));
auto dw2 = new KDDockWidgets::QtQuick::DockWidget("Dock #2");
dw2->setGuestItem(QStringLiteral("qrc:/Guest2.qml"));
auto dw3 = new KDDockWidgets::QtQuick::DockWidget("Dock #3");
dw3->setGuestItem(QStringLiteral("qrc:/Guest3.qml"));
// Access the main area we created in QML with DockingArea {}
auto mainArea = KDDockWidgets::DockRegistry::self()->mainDockingAreas().constFirst();
mainArea->addDockWidget(dw1, KDDockWidgets::Location_OnTop);
dw1->addDockWidgetAsTab(dw2);
dw1->addDockWidgetAsTab(dw3);
return app.exec();
}

View File

@@ -0,0 +1,75 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.6
import QtQuick.Controls 2.12
import com.kdab.dockwidgets 2.0 as KDDW
/// The top 3 tabbed dock widgets were created in C++, while the bottom 2 (dock4 and dock5) were created in QML
ApplicationWindow {
visible: true
width: 1000
height: 800
menuBar: MenuBar {
Menu {
title: qsTr("&Misc")
Action {
// For demonstration purposes, show how to change title:
text: qsTr("Change title of #4")
onTriggered: {
dock4.title = "new title";
}
}
}
}
KDDW.DockWidget {
id: dock4
uniqueName: "dock4"
Rectangle {
color: "#85baa1"
anchors.fill: parent
Text {
font.pixelSize: 25
text: "Four"
anchors.centerIn: parent
}
}
}
KDDW.DockWidget {
id: dock5
uniqueName: "dock5"
Rectangle {
color: "#85baa1"
anchors.fill: parent
Text {
font.pixelSize: 25
text: "Five"
anchors.centerIn: parent
}
}
}
KDDW.DockingArea {
id: dockWidgetArea
anchors.fill: parent
uniqueName: "MyMainLayout"
Component.onCompleted: {
addDockWidget(dock4, KDDW.KDDockWidgets.Location_OnBottom);
dock4.addDockWidgetAsTab(dock5);
}
}
}

View File

@@ -0,0 +1,10 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>Guest1.qml</file>
<file>Guest2.qml</file>
<file>Guest3.qml</file>
<file>Guest.qml</file>
<file>MyTabBar.qml</file>
</qresource>
</RCC>

View File

@@ -0,0 +1,35 @@
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2019 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Sergio Martins <sergio.martins@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
cmake_minimum_required(VERSION 3.15)
project(qtquick_customtitlebar)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIRS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT TARGET kddockwidgets)
# For the purpose of our example, we're looking for Qt5 or Qt6 KDDW.
# For your own purposes, just chose the one you need.
find_package(KDDockWidgets QUIET)
if(NOT KDDockWidgets_FOUND)
find_package(KDDockWidgets-qt6 REQUIRED)
endif()
endif()
set(RESOURCES_EXAMPLE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/resources_qtquick_example.qrc
${CMAKE_CURRENT_SOURCE_DIR}/../../dockwidgets/resources_example.qrc
)
add_executable(qtquick_customtitlebar main.cpp ${RESOURCES_EXAMPLE_SRC})
target_link_libraries(qtquick_customtitlebar PRIVATE KDAB::kddockwidgets)

View File

@@ -0,0 +1,47 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
import QtQuick.Controls 2.15
Item {
anchors.fill: parent
property alias background: background.source
property alias logo: logo.source
Image {
id: background
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
Image {
id: logo
fillMode: Image.PreserveAspectFit
anchors {
fill: parent
margins: 50
}
}
}
TextField {
placeholderText: "TextField just to test focus"
anchors {
bottom: parent.bottom
left: parent.left
right: parent.right
margins: 5
}
}
}

View File

@@ -0,0 +1,18 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Guest {
anchors.fill: parent
background: "qrc:/assets/triangles.png"
logo: "qrc:/assets/KDAB_bubble_white.png"
}

View File

@@ -0,0 +1,17 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Guest {
anchors.fill: parent
logo: "qrc:/assets/KDAB_bubble_blue.png"
}

View File

@@ -0,0 +1,18 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Guest {
anchors.fill: parent
background: "qrc:/assets/base.png"
logo: "qrc:/assets/KDAB_bubble_fulcolor.png"
}

View File

@@ -0,0 +1,18 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Guest {
anchors.fill: parent
background: "qrc:/assets/triangles.png"
logo: "qrc:/assets/KDAB_bubble_white.png"
}

View File

@@ -0,0 +1,41 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.6
Rectangle {
id: root
anchors.fill: parent
color: "orange"
readonly property QtObject kddwSeparator: parent
MouseArea {
cursorShape: kddwSeparator ? (kddwSeparator.isVertical ? Qt.SizeVerCursor : Qt.SizeHorCursor)
: Qt.SizeHorCursor
anchors.fill: parent
onPressed: {
kddwSeparator.onMousePressed();
}
onReleased: {
kddwSeparator.onMouseReleased();
}
onPositionChanged: (mouse) => {
kddwSeparator.onMouseMoved(Qt.point(mouse.x, mouse.y));
}
onDoubleClicked: {
kddwSeparator.onMouseDoubleClicked();
}
}
}

View File

@@ -0,0 +1,83 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.6
// Will be moved to a plugin in the future, if there's enough demand
import "qrc:/kddockwidgets/qtquick/views/qml/" as KDDW
KDDW.TitleBarBase {
id: root
color: "black"
border.color: "orange"
border.width: 2
heightWhenVisible: 50
Text {
color: isFocused ? "cyan" : "orange"
font.bold: isFocused
text: root.title
anchors {
left: parent.left
leftMargin: 10
verticalCenter: root.verticalCenter
}
}
Row {
id: buttonRow
spacing: 10
height: root.height - 20
anchors {
right: root.right
rightMargin: 10
verticalCenter: root.verticalCenter
}
Rectangle {
id: floatButton
visible: root.floatButtonVisible
radius: 5
color: isFocused ? "red" : "white"
height: parent.height
width: height
MouseArea {
anchors.fill: parent
onClicked: {
root.floatButtonClicked();
}
}
}
Rectangle {
id: closeButton
enabled: root.closeButtonEnabled
radius: 5
color: isFocused ? "cyan" : "green"
height: parent.height
width: height
Text {
anchors.centerIn: parent
text: "X"
}
MouseArea {
anchors.fill: parent
onClicked: {
root.closeButtonClicked();
}
}
}
}
}

View File

@@ -0,0 +1,83 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#include <kddockwidgets/Config.h>
#include <kddockwidgets/core/DockRegistry.h>
#include <kddockwidgets/qtquick/views/DockWidget.h>
#include <kddockwidgets/qtquick/Platform.h>
#include <kddockwidgets/qtquick/ViewFactory.h>
#include <kddockwidgets/qtquick/views/MainWindow.h>
#include <QQuickView>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
class CustomViewFactory : public KDDockWidgets::QtQuick::ViewFactory
{
public:
~CustomViewFactory() override;
QUrl titleBarFilename() const override
{
return QUrl("qrc:/MyTitleBar.qml");
}
// Optional, just for illustration purposes
QUrl separatorFilename() const override
{
return QUrl("qrc:/MySeparator.qml");
}
};
CustomViewFactory::~CustomViewFactory() = default;
int main(int argc, char *argv[])
{
#ifdef Q_OS_WIN
QGuiApplication::setAttribute(Qt::AA_UseOpenGLES);
#endif
QGuiApplication app(argc, argv);
KDDockWidgets::initFrontend(KDDockWidgets::FrontendType::QtQuick);
auto &config = KDDockWidgets::Config::self();
auto flags = config.flags() | KDDockWidgets::Config::Flag_TitleBarIsFocusable;
config.setFlags(flags);
config.setViewFactory(new CustomViewFactory());
QQmlApplicationEngine appEngine;
KDDockWidgets::QtQuick::Platform::instance()->setQmlEngine(&appEngine);
appEngine.load((QUrl("qrc:/main.qml")));
auto dw1 = new KDDockWidgets::QtQuick::DockWidget("Dock #1");
dw1->setGuestItem(QStringLiteral("qrc:/Guest1.qml"));
dw1->resize(QSize(800, 800));
dw1->open();
auto dw2 = new KDDockWidgets::QtQuick::DockWidget("Dock #2");
dw2->setGuestItem(QStringLiteral("qrc:/Guest2.qml"));
dw2->resize(QSize(800, 800));
dw2->open();
auto dw3 = new KDDockWidgets::QtQuick::DockWidget("Dock #3");
dw3->setGuestItem(QStringLiteral("qrc:/Guest3.qml"));
dw1->addDockWidgetToContainingWindow(dw3, KDDockWidgets::Location_OnRight);
// Access the main area we created in QML with DockingArea {}
auto mainArea = KDDockWidgets::DockRegistry::self()->mainDockingAreas().constFirst();
mainArea->addDockWidget(dw2, KDDockWidgets::Location_OnTop);
return app.exec();
}

View File

@@ -0,0 +1,42 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.6
import QtQuick.Controls 2.12
import com.kdab.dockwidgets 2.0 as KDDW
ApplicationWindow {
visible: true
width: 1000
height: 800
KDDW.DockingArea {
id: dockWidgetArea
anchors.fill: parent
uniqueName: "MyMainLayout"
KDDW.DockWidget {
id: dock4
uniqueName: "dock4"
source: "qrc:/Guest4.qml"
onIsFocusedChanged: {
console.log("Dock4 focus changed to: " + isFocused);
}
}
Component.onCompleted: {
// The other 3 dock widgets are created via C++ in main.cpp
// For illustration purposes, here's a .qml version. Maybe its the preferred form even.
addDockWidget(dock4, KDDW.KDDockWidgets.Location_OnBottom);
}
}
}

View File

@@ -0,0 +1,12 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>Guest1.qml</file>
<file>Guest2.qml</file>
<file>Guest3.qml</file>
<file>Guest4.qml</file>
<file>Guest.qml</file>
<file>MyTitleBar.qml</file>
<file>MySeparator.qml</file>
</qresource>
</RCC>

View File

@@ -0,0 +1,18 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Rectangle {
id: root
color: "#0C2D48"
anchors.fill: parent
}

View File

@@ -0,0 +1,35 @@
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2019 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Sergio Martins <sergio.martins@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
cmake_minimum_required(VERSION 3.15)
project(qtquick_dockwidgets)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIRS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT TARGET kddockwidgets)
# For the purpose of our example, we're looking for Qt5 or Qt6 KDDW.
# For your own purposes, just chose the one you need.
find_package(KDDockWidgets QUIET)
if(NOT KDDockWidgets_FOUND)
find_package(KDDockWidgets-qt6 REQUIRED)
endif()
endif()
set(RESOURCES_EXAMPLE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/resources_qtquick_example.qrc
${CMAKE_CURRENT_SOURCE_DIR}/../../dockwidgets/resources_example.qrc
)
add_executable(qtquick_dockwidgets main.cpp ${RESOURCES_EXAMPLE_SRC})
target_link_libraries(qtquick_dockwidgets PRIVATE KDAB::kddockwidgets)

View File

@@ -0,0 +1,36 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Item {
anchors.fill: parent
property alias background: background.source
property alias logo: logo.source
Image {
id: background
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
Image {
id: logo
fillMode: Image.PreserveAspectFit
anchors {
fill: parent
margins: 50
}
}
}
}

View File

@@ -0,0 +1,19 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
import com.kdab.dockwidgets 2.0 as KDDW
Guest {
anchors.fill: parent
background: "qrc:/assets/triangles.png"
logo: "qrc:/assets/KDAB_bubble_white.png"
}

View File

@@ -0,0 +1,17 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Guest {
anchors.fill: parent
logo: "qrc:/assets/KDAB_bubble_blue.png"
}

View File

@@ -0,0 +1,18 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Guest {
anchors.fill: parent
background: "qrc:/assets/base.png"
logo: "qrc:/assets/KDAB_bubble_fulcolor.png"
}

View File

@@ -0,0 +1,168 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#include <kddockwidgets/Config.h>
#include <kddockwidgets/core/DockRegistry.h>
#include <kddockwidgets/qtquick/ViewFactory.h>
#include <kddockwidgets/qtquick/Platform.h>
#include <kddockwidgets/qtquick/views/DockWidget.h>
#include <kddockwidgets/qtquick/views/MainWindow.h>
#include <QQmlApplicationEngine>
#include <QGuiApplication>
#include <QCommandLineParser>
#include <QQmlContext>
int main(int argc, char *argv[])
{
#ifdef Q_OS_WIN
QGuiApplication::setAttribute(Qt::AA_UseOpenGLES);
#endif
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
QGuiApplication app(argc, argv);
KDDockWidgets::initFrontend(KDDockWidgets::FrontendType::QtQuick);
QCommandLineParser parser;
parser.setApplicationDescription("KDDockWidgets example application");
parser.addHelpOption();
QCommandLineOption noTitleBars(
"t", QCoreApplication::translate("main", "Hide titlebars when tabs are visible"));
parser.addOption(noTitleBars);
QCommandLineOption alwaysTabs(
"z", QCoreApplication::translate("main", "Show tabs even if there's only one"));
parser.addOption(alwaysTabs);
QCommandLineOption maximizeButtonOption(
"b",
QCoreApplication::translate(
"main",
"Floating dockWidgets have maximize/restore buttons instead of float/dock button"));
parser.addOption(maximizeButtonOption);
QCommandLineOption minimizeButtonOption(
"k",
QCoreApplication::translate("main",
"Floating dockWidgets have a minimize button. Implies not "
"being an utility window (~Qt::Tool)"));
parser.addOption(minimizeButtonOption);
#ifdef Q_OS_WIN
QCommandLineOption nativeTitleBar(
"native-title-bar",
QCoreApplication::translate("main", "(internal) FloatingWindows a native title bar"));
parser.addOption(nativeTitleBar);
#endif
#if defined(DOCKS_DEVELOPER_MODE)
QCommandLineOption noQtTool(
"no-qttool", QCoreApplication::translate("main", "(internal) Don't use Qt::Tool"));
QCommandLineOption noParentForFloating(
"no-parent-for-floating",
QCoreApplication::translate("main", "(internal) FloatingWindows won't have a parent"));
QCommandLineOption noDropIndicators(
"no-drop-indicators",
QCoreApplication::translate("main", "(internal) Don't use any drop indicators"));
parser.addOption(noQtTool);
parser.addOption(noParentForFloating);
parser.addOption(noDropIndicators);
#if defined(Q_OS_WIN)
QCommandLineOption noAeroSnap(
"no-aero-snap", QCoreApplication::translate("main", "(internal) Disable AeroSnap"));
parser.addOption(noAeroSnap);
#endif
#endif
parser.process(app);
auto flags = KDDockWidgets::Config::self().flags();
#if defined(DOCKS_DEVELOPER_MODE)
auto internalFlags = KDDockWidgets::Config::self().internalFlags();
if (parser.isSet(noQtTool))
internalFlags |= KDDockWidgets::Config::InternalFlag_DontUseQtToolWindowsForFloatingWindows;
if (parser.isSet(noParentForFloating))
internalFlags |= KDDockWidgets::Config::InternalFlag_DontUseParentForFloatingWindows;
if (parser.isSet(noDropIndicators))
KDDockWidgets::Core::ViewFactory::s_dropIndicatorType = KDDockWidgets::DropIndicatorType::None;
#if defined(Q_OS_WIN)
if (parser.isSet(noAeroSnap))
internalFlags |= KDDockWidgets::Config::InternalFlag_NoAeroSnap;
#endif
// These are debug-only/development flags, which you can ignore.
KDDockWidgets::Config::self().setInternalFlags(internalFlags);
#endif
#if defined(Q_OS_WIN)
// On Linux the title bar doesn't send us NonClient mouse events
if (parser.isSet(nativeTitleBar))
flags |= KDDockWidgets::Config::Flag_NativeTitleBar;
#endif
if (parser.isSet(noTitleBars))
flags |= KDDockWidgets::Config::Flag_HideTitleBarWhenTabsVisible;
if (parser.isSet(alwaysTabs))
flags |= KDDockWidgets::Config::Flag_AlwaysShowTabs;
if (parser.isSet(maximizeButtonOption))
flags |= KDDockWidgets::Config::Flag_TitleBarHasMaximizeButton;
if (parser.isSet(minimizeButtonOption))
flags |= KDDockWidgets::Config::Flag_TitleBarHasMinimizeButton;
// Set any required flags. The defaults are usually fine.
KDDockWidgets::Config::self().setFlags(flags);
// Create your engine which loads main.qml. A simple QQuickView would work too.
QQmlApplicationEngine appEngine;
appEngine.rootContext()->setContextProperty("_exampleShowsMaximize", parser.isSet(maximizeButtonOption));
KDDockWidgets::QtQuick::Platform::instance()->setQmlEngine(&appEngine);
appEngine.load((QUrl("qrc:/main.qml")));
// Below we illustrate usage of our C++ API. Alternative you can use declarative API.
// See main.qml for examples of dockwidgets created directly in QML
auto dw1 = new KDDockWidgets::QtQuick::DockWidget("Dock #1");
dw1->setGuestItem(QStringLiteral("qrc:/Guest1.qml"));
dw1->resize(QSize(800, 800));
dw1->open();
auto dw2 = new KDDockWidgets::QtQuick::DockWidget("Dock #2");
dw2->setGuestItem(QStringLiteral("qrc:/Guest2.qml"));
dw2->resize(QSize(800, 800));
dw2->open();
auto dw3 = new KDDockWidgets::QtQuick::DockWidget("Dock #3");
dw3->setGuestItem(QStringLiteral("qrc:/Guest3.qml"));
dw1->addDockWidgetToContainingWindow(dw3, KDDockWidgets::Location_OnRight);
// Access the main area we created in QML with DockingArea {}
auto mainArea = KDDockWidgets::DockRegistry::self()->mainDockingAreas().constFirst();
mainArea->addDockWidget(dw2, KDDockWidgets::Location_OnTop);
return app.exec();
}

View File

@@ -0,0 +1,209 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.6
import QtQuick.Controls 2.12
import com.kdab.dockwidgets 2.0 as KDDW
ApplicationWindow {
visible: true
width: 1000
height: 800
menuBar: MenuBar {
Menu {
title: qsTr("&File")
Action {
text: qsTr("Save layout")
onTriggered: {
layoutSaver.saveToFile("mySavedLayout.json");
}
}
Action {
text: qsTr("Restore layout")
onTriggered: {
layoutSaver.restoreFromFile("mySavedLayout.json");
}
}
Action {
text: qsTr("Toggle widget #4")
onTriggered: {
toggleDockWidget(dock4);
}
}
Action {
text: qsTr("Toggle widget #5")
onTriggered: {
toggleDockWidget(dock5);
}
}
Action {
text: qsTr("Toggle widget #6")
onTriggered: {
toggleDockWidget(dock6);
}
}
Action {
text: qsTr("Create widget with min-size")
onTriggered: {
/// Do not use random uuids if you're planing to use layout save/restore!
/// Using them here for convenience of the exercise
var uniqueName = _kddwHelpers.generateUuid();
var code = `import com.kdab.dockwidgets 2.0 as KDDW;
import QtQuick 2.6;
KDDW.DockWidget {
uniqueName: "${uniqueName}";
title: "min-size=" + guest.kddockwidgets_min_size
Rectangle {
id: guest
property var kddockwidgets_min_size: Qt.size(800, 200)
// property var kddockwidgets_max_size: Qt.size(800, 400) Not yet supported
color: "#85baa1";
anchors.fill: parent;
}
}`;
var newDW = Qt.createQmlObject(code, root);
newDW.open();
}
}
Action {
text: qsTr("Close All")
onTriggered: {
_kddwDockRegistry.clear();
}
}
Action {
// Shows how to use direct deletion
text: qsTr("Delete widget #5")
onTriggered: {
dock5.deleteDockWidget();
}
}
MenuSeparator { }
Action { text: qsTr("&Quit")
onTriggered: {
Qt.quit();
}
}
}
}
KDDW.DockingArea {
id: root
anchors.fill: parent
// Each main layout needs a unique id
uniqueName: "MainLayout-1"
Repeater {
model: 3
KDDW.DockWidget {
uniqueName: "fromRepeater-" + index
source: ":/Another.qml"
}
}
KDDW.DockWidget {
id: dock4
uniqueName: "dock4" // Each dock widget needs a unique id
source: ":/Another.qml"
onIsOpenChanged: {
// Just an example of detecting when a dockwidget is closed
console.log("Dock4 is open ? " + isOpen)
}
}
KDDW.DockWidget {
id: dock5
uniqueName: "dock5"
Rectangle {
id: guest
color: "#2E8BC0"
anchors.fill: parent
}
}
KDDW.DockWidget {
id: dock6
uniqueName: "dock6"
Rectangle {
color: "#2E8BC0"
anchors.fill: parent
}
}
KDDW.DockWidget {
id: dock7
uniqueName: "dock7"
Rectangle {
color: "#145DA0"
anchors.fill: parent
Button {
// This button is just to show some API where we maximize from docked state
text: "Toggle Maximized"
visible: _exampleShowsMaximize
anchors {
right: parent.right
bottom: parent.bottom
margins: 5
}
onClicked: {
dock7.actualTitleBar.onFloatClicked();
dock7.actualTitleBar.toggleMaximized();
}
}
}
}
Component.onCompleted: {
// Add dock4 to the Bottom location
addDockWidget(dock4, KDDW.KDDockWidgets.Location_OnBottom);
// Add dock5 to the left of dock4
addDockWidget(dock5, KDDW.KDDockWidgets.Location_OnRight, dock4);
// Adds dock6 but specifies a preferred initial size and it starts hidden
// When toggled it will be shown on the desired dock location.
// See MainWindowInstantiator_p.h for the API
addDockWidget(dock6, KDDW.KDDockWidgets.Location_OnLeft, null,
Qt.size(500, 100), KDDW.KDDockWidgets.StartHidden);
// dock7 will be tabbed with dock7:
dock5.addDockWidgetAsTab(dock7);
}
}
KDDW.LayoutSaver {
id: layoutSaver
}
function toggleDockWidget(dw) {
if (dw.isOpen) {
dw.close();
} else {
dw.show();
}
}
}

View File

@@ -0,0 +1,10 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>Guest1.qml</file>
<file>Guest2.qml</file>
<file>Guest3.qml</file>
<file>Guest.qml</file>
<file>Another.qml</file>
</qresource>
</RCC>

View File

@@ -0,0 +1,35 @@
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2019 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Sergio Martins <sergio.martins@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
cmake_minimum_required(VERSION 3.15)
project(qtquick_dockwidgets)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIRS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT TARGET kddockwidgets)
# For the purpose of our example, we're looking for Qt5 or Qt6 KDDW.
# For your own purposes, just chose the one you need.
find_package(KDDockWidgets QUIET)
if(NOT KDDockWidgets_FOUND)
find_package(KDDockWidgets-qt6 REQUIRED)
endif()
endif()
set(RESOURCES_EXAMPLE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/resources_qtquick_example.qrc
${CMAKE_CURRENT_SOURCE_DIR}/../../dockwidgets/resources_example.qrc
)
add_executable(qtquick_fixed_central_widget main.cpp ${RESOURCES_EXAMPLE_SRC})
target_link_libraries(qtquick_fixed_central_widget PRIVATE KDAB::kddockwidgets)

View File

@@ -0,0 +1,27 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Item {
anchors.fill: parent
Image {
id: logo
source: "qrc:/assets/KDAB_bubble_blue.png"
fillMode: Image.PreserveAspectFit
anchors {
fill: parent
margins: 150
}
}
}

View File

@@ -0,0 +1,18 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Rectangle {
id: root
color: "#0C2D48"
anchors.fill: parent
}

View File

@@ -0,0 +1,51 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#include <kddockwidgets/Config.h>
#include <kddockwidgets/core/DockRegistry.h>
#include <kddockwidgets/qtquick/ViewFactory.h>
#include <kddockwidgets/qtquick/Platform.h>
#include <kddockwidgets/qtquick/views/DockWidget.h>
#include <kddockwidgets/qtquick/views/MainWindow.h>
#include <QQmlApplicationEngine>
#include <QGuiApplication>
#include <QCommandLineParser>
#include <QQmlContext>
int main(int argc, char *argv[])
{
#ifdef Q_OS_WIN
QGuiApplication::setAttribute(Qt::AA_UseOpenGLES);
#endif
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
QGuiApplication app(argc, argv);
KDDockWidgets::initFrontend(KDDockWidgets::FrontendType::QtQuick);
QCommandLineParser parser;
parser.setApplicationDescription("KDDockWidgets QtQuick example with fixed central area");
parser.addHelpOption();
// Create your engine which loads main.qml. A simple QQuickView would work too.
QQmlApplicationEngine appEngine;
KDDockWidgets::QtQuick::Platform::instance()->setQmlEngine(&appEngine);
appEngine.load((QUrl("qrc:/main.qml")));
// Access the main area we created in QML with DockingArea {}
// auto mainArea = KDDockWidgets::DockRegistry::self()->mainDockingAreas().constFirst();
return app.exec();
}

View File

@@ -0,0 +1,85 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.6
import QtQuick.Controls 2.12
import com.kdab.dockwidgets 2.0 as KDDW
ApplicationWindow {
visible: true
width: 1600
height: 800
Rectangle {
id: someTopArea
color: "#CFD4C5"
height: 50
anchors {
left: parent.left
right: parent.right
}
}
KDDW.DockingArea {
id: root
anchors {
left: parent.left
right: parent.right
bottom: parent.bottom
top: someTopArea.bottom
}
persistentCentralItemFileName: ":/CentralWidget.qml"
options: KDDW.KDDockWidgets.MainWindowOption_HasCentralWidget
// Each main layout needs a unique id
uniqueName: "MainLayout-1"
KDDW.DockWidget {
id: dock4
uniqueName: "dock4" // Each dock widget needs a unique id
source: ":/SomeDockWidget.qml"
}
KDDW.DockWidget {
id: dock5
uniqueName: "dock5"
Rectangle {
id: guest
color: "#2E8BC0"
anchors.fill: parent
}
}
KDDW.DockWidget {
id: dock6
uniqueName: "dock6"
Rectangle {
color: "#2E8BC0"
anchors.fill: parent
}
}
Component.onCompleted: {
addDockWidget(dock5, KDDW.KDDockWidgets.Location_OnRight, null, Qt.size(500, 0));
addDockWidget(dock4, KDDW.KDDockWidgets.Location_OnLeft, null, Qt.size(300, 0));
dock5.addDockWidgetAsTab(dock6);
}
}
function toggleDockWidget(dw) {
if (dw.dockWidget.isOpen()) {
dw.dockWidget.close();
} else {
dw.dockWidget.show();
}
}
}

View File

@@ -0,0 +1,7 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>CentralWidget.qml</file>
<file>SomeDockWidget.qml</file>
</qresource>
</RCC>

View File

@@ -0,0 +1,18 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Rectangle {
id: root
color: "#0C2D48"
anchors.fill: parent
}

View File

@@ -0,0 +1,35 @@
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2019 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Sergio Martins <sergio.martins@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
cmake_minimum_required(VERSION 3.15)
project(qtquick_mdi)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIRS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT TARGET kddockwidgets)
# For the purpose of our example, we're looking for Qt5 or Qt6 KDDW.
# For your own purposes, just chose the one you need.
find_package(KDDockWidgets QUIET)
if(NOT KDDockWidgets_FOUND)
find_package(KDDockWidgets-qt6 REQUIRED)
endif()
endif()
set(RESOURCES_EXAMPLE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/resources_qtquick_mdi_example.qrc
${CMAKE_CURRENT_SOURCE_DIR}/../../dockwidgets/resources_example.qrc
)
add_executable(qtquick_mdi main.cpp ${RESOURCES_EXAMPLE_SRC})
target_link_libraries(qtquick_mdi PRIVATE KDAB::kddockwidgets)

View File

@@ -0,0 +1,37 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Rectangle {
color: "white"
anchors.fill: parent
property alias background: background.source
property alias logo: logo.source
Image {
id: background
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
Image {
id: logo
fillMode: Image.PreserveAspectFit
anchors {
fill: parent
margins: 50
}
}
}
}

View File

@@ -0,0 +1,43 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
import QtQuick.Controls 2.12
import com.kdab.dockwidgets 2.0 as KDDW
Guest {
anchors.fill: parent
background: "qrc:/assets/triangles.png"
logo: "qrc:/assets/KDAB_bubble_white.png"
KDDW.DockWidget {
id: another
uniqueName: "another1"
source: ":/Another.qml"
}
Button {
text: "Toggle Another"
anchors {
bottom: parent.bottom
left: parent.left
margins: 5
}
onClicked: {
if (another.isOpen) {
another.close();
} else {
another.show();
}
}
}
}

View File

@@ -0,0 +1,17 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Guest {
anchors.fill: parent
logo: "qrc:/assets/KDAB_bubble_blue.png"
}

View File

@@ -0,0 +1,18 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Guest {
anchors.fill: parent
background: "qrc:/assets/base.png"
logo: "qrc:/assets/KDAB_bubble_fulcolor.png"
}

View File

@@ -0,0 +1,62 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#include <kddockwidgets/Config.h>
#include <kddockwidgets/qtquick/views/DockWidget.h>
#include <kddockwidgets/qtquick/views/MainWindowMDI.h>
#include <kddockwidgets/qtquick/Platform.h>
#include <kddockwidgets/core/DockRegistry.h>
#include "kddockwidgets/core/MainWindow.h"
#include <QQmlApplicationEngine>
#include <QGuiApplication>
#include <QCommandLineParser>
int main(int argc, char *argv[])
{
#ifdef Q_OS_WIN
QGuiApplication::setAttribute(Qt::AA_UseOpenGLES);
#endif
QGuiApplication app(argc, argv);
KDDockWidgets::initFrontend(KDDockWidgets::FrontendType::QtQuick);
QCommandLineParser parser;
parser.setApplicationDescription("KDDockWidgets example application");
parser.addHelpOption();
QQmlApplicationEngine appEngine;
KDDockWidgets::QtQuick::Platform::instance()->setQmlEngine(&appEngine);
appEngine.load((QUrl("qrc:/main.qml")));
auto dw1 = new KDDockWidgets::QtQuick::DockWidget("Dock #1");
dw1->setGuestItem(QStringLiteral("qrc:/Guest1.qml"));
dw1->resize(QSize(400, 400));
auto dw2 = new KDDockWidgets::QtQuick::DockWidget("Dock #2");
dw2->setGuestItem(QStringLiteral("qrc:/Guest2.qml"));
dw2->resize(QSize(400, 400));
auto dw3 = new KDDockWidgets::QtQuick::DockWidget("Dock #3");
dw3->setGuestItem(QStringLiteral("qrc:/Guest3.qml"));
// See main.qml for how to add dock widgets from QML.
// Here's a low level C++ example just for educational purposes:
auto mainAreaView = KDDockWidgets::DockRegistry::self()->mainDockingAreas().constFirst();
auto mainAreaMDI = static_cast<KDDockWidgets::QtQuick::MainWindowMDI *>(mainAreaView);
mainAreaMDI->addDockWidget(dw1, QPoint(10, 10));
mainAreaMDI->addDockWidget(dw2, QPoint(50, 50));
mainAreaMDI->addDockWidget(dw3, QPoint(90, 90));
return app.exec();
}

View File

@@ -0,0 +1,39 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.6
import QtQuick.Controls 2.12
import com.kdab.dockwidgets 2.0 as KDDW
ApplicationWindow {
visible: true
width: 1000
height: 1200
KDDW.MDIDockingArea {
id: dockingArea
anchors.fill: parent
uniqueName: "MyMainLayout"
}
KDDW.DockWidget {
id: someDock
uniqueName: "someDock"
Rectangle {
color: "#413C58"
anchors.fill: parent
}
}
Component.onCompleted: {
dockingArea.addDockWidget(someDock, Qt.point(200, 200));
}
}

View File

@@ -0,0 +1,10 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>Guest1.qml</file>
<file>Guest2.qml</file>
<file>Guest3.qml</file>
<file>Guest.qml</file>
<file>Another.qml</file>
</qresource>
</RCC>

View File

@@ -0,0 +1,18 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Rectangle {
id: root
color: "green"
anchors.fill: parent
}

View File

@@ -0,0 +1,35 @@
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2019 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Sergio Martins <sergio.martins@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
cmake_minimum_required(VERSION 3.15)
project(qtquick_dockwidgets)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIRS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT TARGET kddockwidgets)
# For the purpose of our example, we're looking for Qt5 or Qt6 KDDW.
# For your own purposes, just chose the one you need.
find_package(KDDockWidgets QUIET)
if(NOT KDDockWidgets_FOUND)
find_package(KDDockWidgets-qt6 REQUIRED)
endif()
endif()
set(RESOURCES_EXAMPLE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/resources_qtquick_example.qrc
${CMAKE_CURRENT_SOURCE_DIR}/../../dockwidgets/resources_example.qrc
)
add_executable(qtquick_mdi_with_docking main.cpp ${RESOURCES_EXAMPLE_SRC})
target_link_libraries(qtquick_mdi_with_docking PRIVATE KDAB::kddockwidgets)

View File

@@ -0,0 +1,36 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Item {
anchors.fill: parent
property alias background: background.source
property alias logo: logo.source
Image {
id: background
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
Image {
id: logo
fillMode: Image.PreserveAspectFit
anchors {
fill: parent
margins: 50
}
}
}
}

View File

@@ -0,0 +1,19 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
import com.kdab.dockwidgets 2.0 as KDDW
Guest {
anchors.fill: parent
background: "qrc:/assets/triangles.png"
logo: "qrc:/assets/KDAB_bubble_white.png"
}

View File

@@ -0,0 +1,17 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Guest {
anchors.fill: parent
logo: "qrc:/assets/KDAB_bubble_blue.png"
}

View File

@@ -0,0 +1,18 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Guest {
anchors.fill: parent
background: "qrc:/assets/base.png"
logo: "qrc:/assets/KDAB_bubble_fulcolor.png"
}

View File

@@ -0,0 +1,73 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#include <kddockwidgets/Config.h>
#include <kddockwidgets/core/DockRegistry.h>
#include <kddockwidgets/core/MDILayout.h>
#include <kddockwidgets/qtquick/ViewFactory.h>
#include <kddockwidgets/qtquick/Platform.h>
#include <kddockwidgets/qtquick/views/DockWidget.h>
#include <kddockwidgets/qtquick/views/MainWindow.h>
#include <kddockwidgets/qtquick/views/MDILayout.h>
#include <QQmlApplicationEngine>
#include <QGuiApplication>
#include <QCommandLineParser>
int main(int argc, char *argv[])
{
#ifdef Q_OS_WIN
QGuiApplication::setAttribute(Qt::AA_UseOpenGLES);
#endif
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
QGuiApplication app(argc, argv);
KDDockWidgets::initFrontend(KDDockWidgets::FrontendType::QtQuick);
// Create your engine which loads main.qml. A simple QQuickView would work too.
QQmlApplicationEngine appEngine;
KDDockWidgets::QtQuick::Platform::instance()->setQmlEngine(&appEngine);
appEngine.load((QUrl("qrc:/main.qml")));
// Below we illustrate usage of our C++ API. Alternatively you can use declarative API.
// See main.qml for examples of dockwidgets created directly in QML
auto dw1 = new KDDockWidgets::QtQuick::DockWidget("Dock #1");
dw1->setGuestItem(QStringLiteral("qrc:/Guest1.qml"));
dw1->resize(QSize(800, 800));
dw1->open();
auto dw3 = new KDDockWidgets::QtQuick::DockWidget("Dock #3");
dw3->setGuestItem(QStringLiteral("qrc:/Guest3.qml"));
dw1->addDockWidgetToContainingWindow(dw3, KDDockWidgets::Location_OnRight);
// Access the main area we created in QML with DockingArea {}
auto mainArea = KDDockWidgets::DockRegistry::self()->mainDockingAreas().constFirst();
auto mdiLayout = new KDDockWidgets::Core::MDILayout();
mainArea->setPersistentCentralView(mdiLayout->view()->asWrapper());
auto dwInMDI1 = new KDDockWidgets::QtQuick::DockWidget("Dock #mdi1");
dwInMDI1->setGuestItem(QStringLiteral("qrc:/Guest3.qml"));
auto dwInMDI2 = new KDDockWidgets::QtQuick::DockWidget("Dock #mdi2");
dwInMDI2->setGuestItem(QStringLiteral("qrc:/Guest3.qml"));
mdiLayout->addDockWidget(dwInMDI1->dockWidget(), { 100, 100 });
mdiLayout->addDockWidget(dwInMDI2->dockWidget(), { 140, 140 });
return app.exec();
}

View File

@@ -0,0 +1,75 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.6
import QtQuick.Controls 2.12
import com.kdab.dockwidgets 2.0 as KDDW
ApplicationWindow {
visible: true
width: 1300
height: 1300
menuBar: MenuBar {
Menu {
title: qsTr("&File")
Action {
text: qsTr("Close All")
onTriggered: {
_kddwDockRegistry.clear();
}
}
MenuSeparator { }
Action { text: qsTr("&Quit")
onTriggered: {
Qt.quit();
}
}
}
}
KDDW.DockingArea {
options: KDDW.KDDockWidgets.MainWindowOption_HasCentralWidget
anchors.fill: parent
// Each main layout needs a unique id
uniqueName: "MainLayout-1"
KDDW.DockWidget {
id: dock5
uniqueName: "dock5"
Rectangle {
id: guest
color: "pink"
anchors.fill: parent
}
}
KDDW.DockWidget {
id: dock6
uniqueName: "dock6"
Rectangle {
color: "black"
anchors.fill: parent
}
}
Component.onCompleted: {
// Add dock4 to the Bottom location
addDockWidget(dock5, KDDW.KDDockWidgets.Location_OnLeft, null, Qt.size(150, 0));
// Add dock5 to the left of dock4
addDockWidget(dock6, KDDW.KDDockWidgets.Location_OnBottom, null, Qt.size(0, 150));
}
}
}

View File

@@ -0,0 +1,10 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>Guest1.qml</file>
<file>Guest2.qml</file>
<file>Guest3.qml</file>
<file>Guest.qml</file>
<file>Another.qml</file>
</qresource>
</RCC>