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,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>