diff --git a/CMakeLists.txt b/CMakeLists.txt index 20c39c01..814a83ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -172,8 +172,7 @@ endif() if(${PROJECT_NAME}_EXAMPLES) if (${PROJECT_NAME}_QTQUICK) - add_subdirectory(examples/qtquick/dockwidgets) - set_compiler_flags(kddockwidgets_example_quick) + add_subdirectory(examples/qtquick) else() add_subdirectory(examples/dockwidgets) add_subdirectory(examples/minimal) diff --git a/examples/qtquick/CMakeLists.txt b/examples/qtquick/CMakeLists.txt new file mode 100644 index 00000000..d2f2323d --- /dev/null +++ b/examples/qtquick/CMakeLists.txt @@ -0,0 +1,5 @@ +add_subdirectory(customtitlebar) +add_subdirectory(dockwidgets) + +set_compiler_flags(kddockwidgets_example_quick) +set_compiler_flags(kddockwidgets_customtitlebar_quick) diff --git a/examples/qtquick/customtitlebar/CMakeLists.txt b/examples/qtquick/customtitlebar/CMakeLists.txt new file mode 100644 index 00000000..1693e4d4 --- /dev/null +++ b/examples/qtquick/customtitlebar/CMakeLists.txt @@ -0,0 +1,36 @@ +# +# This file is part of KDDockWidgets. +# +# SPDX-FileCopyrightText: 2019-2020 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(kddockwidgets_customtitlebar_quick) + +set(CMAKE_AUTOMOC 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() + +qt5_add_resources(RESOURCES_EXAMPLE_SRC + ${CMAKE_CURRENT_SOURCE_DIR}/resources_qtquick_example.qrc + ${CMAKE_CURRENT_SOURCE_DIR}/../../dockwidgets/resources_example.qrc) + +add_executable(kddockwidgets_customtitlebar_quick + main.cpp + ${RESOURCES_EXAMPLE_SRC} +) + +target_link_libraries(kddockwidgets_customtitlebar_quick + PRIVATE + KDAB::kddockwidgets +) diff --git a/examples/qtquick/customtitlebar/Guest.qml b/examples/qtquick/customtitlebar/Guest.qml new file mode 100644 index 00000000..ee2b94aa --- /dev/null +++ b/examples/qtquick/customtitlebar/Guest.qml @@ -0,0 +1,36 @@ +/* + This file is part of KDDockWidgets. + + SPDX-FileCopyrightText: 2020 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/customtitlebar/Guest1.qml b/examples/qtquick/customtitlebar/Guest1.qml new file mode 100644 index 00000000..102a9399 --- /dev/null +++ b/examples/qtquick/customtitlebar/Guest1.qml @@ -0,0 +1,18 @@ +/* + This file is part of KDDockWidgets. + + SPDX-FileCopyrightText: 2020 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/customtitlebar/Guest2.qml b/examples/qtquick/customtitlebar/Guest2.qml new file mode 100644 index 00000000..cb132abf --- /dev/null +++ b/examples/qtquick/customtitlebar/Guest2.qml @@ -0,0 +1,17 @@ +/* + This file is part of KDDockWidgets. + + SPDX-FileCopyrightText: 2020 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/customtitlebar/Guest3.qml b/examples/qtquick/customtitlebar/Guest3.qml new file mode 100644 index 00000000..2afe58e3 --- /dev/null +++ b/examples/qtquick/customtitlebar/Guest3.qml @@ -0,0 +1,18 @@ +/* + This file is part of KDDockWidgets. + + SPDX-FileCopyrightText: 2020 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/customtitlebar/main.cpp b/examples/qtquick/customtitlebar/main.cpp new file mode 100644 index 00000000..085f12dc --- /dev/null +++ b/examples/qtquick/customtitlebar/main.cpp @@ -0,0 +1,103 @@ +/* + This file is part of KDDockWidgets. + + SPDX-FileCopyrightText: 2020 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 + +int main(int argc, char *argv[]) +{ +#ifdef Q_OS_WIN + QGuiApplication::setAttribute(Qt::AA_UseOpenGLES); +#endif + QGuiApplication app(argc, argv); + QCommandLineParser parser; + parser.setApplicationDescription("KDDockWidgets example application"); + parser.addHelpOption(); + + +#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 nativeTitleBar("native-title-bar", QCoreApplication::translate("main", "(internal) FloatingWindows a native title bar")); + QCommandLineOption noDropIndicators("no-drop-indicators", QCoreApplication::translate("main", "(internal) Don't use any drop indicators")); + + parser.addOption(noQtTool); + parser.addOption(noParentForFloating); + parser.addOption(nativeTitleBar); + parser.addOption(noDropIndicators); + +# if defined(Q_OS_WIN) + QCommandLineOption noAeroSnap("no-aero-snap", QCoreApplication::translate("main", "(internal) Disable AeroSnap")); + parser.addOption(noAeroSnap); +# endif +#endif + + auto flags = KDDockWidgets::Config::self().flags(); + +#if defined(DOCKS_DEVELOPER_MODE) + parser.process(app); + + if (parser.isSet(noQtTool)) + flags |= KDDockWidgets::Config::Flag_internal_DontUseQtToolWindowsForFloatingWindows; + + if (parser.isSet(noParentForFloating)) + flags |= KDDockWidgets::Config::Flag_internal_DontUseParentForFloatingWindows; + + if (parser.isSet(nativeTitleBar)) + flags |= KDDockWidgets::Config::Flag_NativeTitleBar; + else if (parser.isSet(noDropIndicators)) + KDDockWidgets::DefaultWidgetFactory::s_dropIndicatorType = KDDockWidgets::DropIndicatorType::None; + +# if defined(Q_OS_WIN) + if (parser.isSet(noAeroSnap)) + flags |= KDDockWidgets::Config::Flag_internal_NoAeroSnap; +# endif + +#endif + + KDDockWidgets::Config::self().setFlags(flags); + + QQuickView view; + view.setObjectName("MainWindow QQuickView"); + KDDockWidgets::Config::self().setQmlEngine(view.engine()); + view.resize(1000, 800); + view.show(); + view.setResizeMode(QQuickView::SizeRootObjectToView); + + auto dw1 = new KDDockWidgets::DockWidgetQuick("Dock #1"); + view.setSource(QUrl("qrc:/main.qml")); + + dw1->setWidget(QStringLiteral("qrc:/Guest1.qml")); + dw1->resize(QSize(800, 800)); + dw1->show(); + + auto dw2 = new KDDockWidgets::DockWidgetQuick("Dock #2"); + dw2->setWidget(QStringLiteral("qrc:/Guest2.qml")); + dw2->resize(QSize(800, 800)); + dw2->show(); + + auto dw3 = new KDDockWidgets::DockWidgetQuick("Dock #3"); + dw3->setWidget(QStringLiteral("qrc:/Guest3.qml")); + + dw1->addDockWidgetToContainingWindow(dw3, KDDockWidgets::Location_OnRight); + + KDDockWidgets::MainWindowBase *mainWindow = KDDockWidgets::DockRegistry::self()->mainwindows().constFirst(); + mainWindow->addDockWidget(dw2, KDDockWidgets::Location_OnTop); + + return app.exec(); +} diff --git a/examples/qtquick/customtitlebar/main.qml b/examples/qtquick/customtitlebar/main.qml new file mode 100644 index 00000000..34f32740 --- /dev/null +++ b/examples/qtquick/customtitlebar/main.qml @@ -0,0 +1,23 @@ +/* + This file is part of KDDockWidgets. + + SPDX-FileCopyrightText: 2020 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 com.kdab.dockwidgets 1.0 as KDDW + +KDDW.MainWindow { + id: root + + + Component.onCompleted: { + root.init("MyWindowName-1"); + } +} + diff --git a/examples/qtquick/customtitlebar/resources_qtquick_example.qrc b/examples/qtquick/customtitlebar/resources_qtquick_example.qrc new file mode 100644 index 00000000..f80890cb --- /dev/null +++ b/examples/qtquick/customtitlebar/resources_qtquick_example.qrc @@ -0,0 +1,9 @@ + + + main.qml + Guest1.qml + Guest2.qml + Guest3.qml + Guest.qml + +