diff --git a/examples/qtquick/CMakeLists.txt b/examples/qtquick/CMakeLists.txt index 9dfd0959..fd2c9c80 100644 --- a/examples/qtquick/CMakeLists.txt +++ b/examples/qtquick/CMakeLists.txt @@ -23,3 +23,9 @@ set_compiler_flags(qtquick_customtitlebar) set_target_properties( qtquick_customtitlebar PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/examples/" ) + +add_subdirectory(customtabbar) +set_compiler_flags(qtquick_customtabbar) +set_target_properties( + qtquick_customtabbar PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/examples/" +) diff --git a/examples/qtquick/customtabbar/CMakeLists.txt b/examples/qtquick/customtabbar/CMakeLists.txt new file mode 100644 index 00000000..7f42ad5c --- /dev/null +++ b/examples/qtquick/customtabbar/CMakeLists.txt @@ -0,0 +1,31 @@ +# +# This file is part of KDDockWidgets. +# +# SPDX-FileCopyrightText: 2019-2022 Klarälvdalens Datakonsult AB, a KDAB Group company +# Author: Sergio Martins +# +# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only +# +# Contact KDAB at for commercial licensing options. +# + +cmake_minimum_required(VERSION 3.7) +project(qtquick_customtabbar) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_INCLUDE_CURRENT_DIRS ON) + +if(NOT TARGET kddockwidgets) + # This will look for Qt, do find_package yourself manually before if you want + # to look for a specific Qt version for instance. + find_package(KDDockWidgets REQUIRED) +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) diff --git a/examples/qtquick/customtabbar/Guest.qml b/examples/qtquick/customtabbar/Guest.qml new file mode 100644 index 00000000..c26b979e --- /dev/null +++ b/examples/qtquick/customtabbar/Guest.qml @@ -0,0 +1,36 @@ +/* + This file is part of KDDockWidgets. + + SPDX-FileCopyrightText: 2020-2022 Klarälvdalens Datakonsult AB, a KDAB Group company + Author: Sergio Martins + + SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only + + Contact KDAB at 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 + } + } + } +} diff --git a/examples/qtquick/customtabbar/Guest1.qml b/examples/qtquick/customtabbar/Guest1.qml new file mode 100644 index 00000000..ac66ffbc --- /dev/null +++ b/examples/qtquick/customtabbar/Guest1.qml @@ -0,0 +1,18 @@ +/* + This file is part of KDDockWidgets. + + SPDX-FileCopyrightText: 2020-2022 Klarälvdalens Datakonsult AB, a KDAB Group company + Author: Sergio Martins + + SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only + + Contact KDAB at for commercial licensing options. +*/ + +import QtQuick 2.9 + +Guest { + anchors.fill: parent + background: "qrc:/assets/triangles.png" + logo: "qrc:/assets/KDAB_bubble_white.png" +} diff --git a/examples/qtquick/customtabbar/Guest2.qml b/examples/qtquick/customtabbar/Guest2.qml new file mode 100644 index 00000000..4b8b6af4 --- /dev/null +++ b/examples/qtquick/customtabbar/Guest2.qml @@ -0,0 +1,17 @@ +/* + This file is part of KDDockWidgets. + + SPDX-FileCopyrightText: 2020-2022 Klarälvdalens Datakonsult AB, a KDAB Group company + Author: Sergio Martins + + SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only + + Contact KDAB at for commercial licensing options. +*/ + +import QtQuick 2.9 + +Guest { + anchors.fill: parent + logo: "qrc:/assets/KDAB_bubble_blue.png" +} diff --git a/examples/qtquick/customtabbar/Guest3.qml b/examples/qtquick/customtabbar/Guest3.qml new file mode 100644 index 00000000..4b1371bb --- /dev/null +++ b/examples/qtquick/customtabbar/Guest3.qml @@ -0,0 +1,18 @@ +/* + This file is part of KDDockWidgets. + + SPDX-FileCopyrightText: 2020-2022 Klarälvdalens Datakonsult AB, a KDAB Group company + Author: Sergio Martins + + SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only + + Contact KDAB at for commercial licensing options. +*/ + +import QtQuick 2.9 + +Guest { + anchors.fill: parent + background: "qrc:/assets/base.png" + logo: "qrc:/assets/KDAB_bubble_fulcolor.png" +} diff --git a/examples/qtquick/customtabbar/MyTabBar.qml b/examples/qtquick/customtabbar/MyTabBar.qml new file mode 100644 index 00000000..cb616c16 --- /dev/null +++ b/examples/qtquick/customtabbar/MyTabBar.qml @@ -0,0 +1,25 @@ +/* + This file is part of KDDockWidgets. + + SPDX-FileCopyrightText: 2020-2022 Klarälvdalens Datakonsult AB, a KDAB Group company + Author: Sergio Martins + + SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only + + Contact KDAB at 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 + +Rectangle { + id: root + color: "black" + border.color: "orange" + border.width: 2 + + implicitHeight: 50 + +} diff --git a/examples/qtquick/customtabbar/main.cpp b/examples/qtquick/customtabbar/main.cpp new file mode 100644 index 00000000..4f5a774e --- /dev/null +++ b/examples/qtquick/customtabbar/main.cpp @@ -0,0 +1,77 @@ +/* + This file is part of KDDockWidgets. + + SPDX-FileCopyrightText: 2020-2022 Klarälvdalens Datakonsult AB, a KDAB Group company + Author: Sergio Martins + + SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only + + Contact KDAB at for commercial licensing options. +*/ + + +#include +#include +#include +#include +#include +#include + + +#include +#include +#include + +class CustomViewFactory : public KDDockWidgets::ViewFactory_qtquick +{ +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::Platform_qtquick::instance()->setQmlEngine(&appEngine); + appEngine.load((QUrl("qrc:/main.qml"))); + + auto dw1 = new KDDockWidgets::Views::DockWidget_qtquick("Dock #1"); + + dw1->setGuestItem(QStringLiteral("qrc:/Guest1.qml")); + dw1->resize(QSize(800, 800)); + dw1->show(); + + auto dw2 = new KDDockWidgets::Views::DockWidget_qtquick("Dock #2"); + dw2->setGuestItem(QStringLiteral("qrc:/Guest2.qml")); + dw2->resize(QSize(800, 800)); + dw2->show(); + + auto dw3 = new KDDockWidgets::Views::DockWidget_qtquick("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(); +} diff --git a/examples/qtquick/customtabbar/main.qml b/examples/qtquick/customtabbar/main.qml new file mode 100644 index 00000000..d3f46fd8 --- /dev/null +++ b/examples/qtquick/customtabbar/main.qml @@ -0,0 +1,27 @@ +/* + This file is part of KDDockWidgets. + + SPDX-FileCopyrightText: 2020-2022 Klarälvdalens Datakonsult AB, a KDAB Group company + Author: Sergio Martins + + SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only + + Contact KDAB at 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" + } +} diff --git a/examples/qtquick/customtabbar/resources_qtquick_example.qrc b/examples/qtquick/customtabbar/resources_qtquick_example.qrc new file mode 100644 index 00000000..07daa44b --- /dev/null +++ b/examples/qtquick/customtabbar/resources_qtquick_example.qrc @@ -0,0 +1,10 @@ + + + main.qml + Guest1.qml + Guest2.qml + Guest3.qml + Guest.qml + MyTabBar.qml + +