First Commit
This commit is contained in:
35
3rdparty/kddockwidgets/examples/qtquick/customtitlebar/CMakeLists.txt
vendored
Normal file
35
3rdparty/kddockwidgets/examples/qtquick/customtitlebar/CMakeLists.txt
vendored
Normal 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)
|
||||
47
3rdparty/kddockwidgets/examples/qtquick/customtitlebar/Guest.qml
vendored
Normal file
47
3rdparty/kddockwidgets/examples/qtquick/customtitlebar/Guest.qml
vendored
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
18
3rdparty/kddockwidgets/examples/qtquick/customtitlebar/Guest1.qml
vendored
Normal file
18
3rdparty/kddockwidgets/examples/qtquick/customtitlebar/Guest1.qml
vendored
Normal 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"
|
||||
}
|
||||
17
3rdparty/kddockwidgets/examples/qtquick/customtitlebar/Guest2.qml
vendored
Normal file
17
3rdparty/kddockwidgets/examples/qtquick/customtitlebar/Guest2.qml
vendored
Normal 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"
|
||||
}
|
||||
18
3rdparty/kddockwidgets/examples/qtquick/customtitlebar/Guest3.qml
vendored
Normal file
18
3rdparty/kddockwidgets/examples/qtquick/customtitlebar/Guest3.qml
vendored
Normal 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"
|
||||
}
|
||||
18
3rdparty/kddockwidgets/examples/qtquick/customtitlebar/Guest4.qml
vendored
Normal file
18
3rdparty/kddockwidgets/examples/qtquick/customtitlebar/Guest4.qml
vendored
Normal 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"
|
||||
}
|
||||
41
3rdparty/kddockwidgets/examples/qtquick/customtitlebar/MySeparator.qml
vendored
Normal file
41
3rdparty/kddockwidgets/examples/qtquick/customtitlebar/MySeparator.qml
vendored
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
83
3rdparty/kddockwidgets/examples/qtquick/customtitlebar/MyTitleBar.qml
vendored
Normal file
83
3rdparty/kddockwidgets/examples/qtquick/customtitlebar/MyTitleBar.qml
vendored
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
83
3rdparty/kddockwidgets/examples/qtquick/customtitlebar/main.cpp
vendored
Normal file
83
3rdparty/kddockwidgets/examples/qtquick/customtitlebar/main.cpp
vendored
Normal 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();
|
||||
}
|
||||
42
3rdparty/kddockwidgets/examples/qtquick/customtitlebar/main.qml
vendored
Normal file
42
3rdparty/kddockwidgets/examples/qtquick/customtitlebar/main.qml
vendored
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
12
3rdparty/kddockwidgets/examples/qtquick/customtitlebar/resources_qtquick_example.qrc
vendored
Normal file
12
3rdparty/kddockwidgets/examples/qtquick/customtitlebar/resources_qtquick_example.qrc
vendored
Normal 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>
|
||||
Reference in New Issue
Block a user