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.
*/
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>