Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
iamsergio committed Jan 25, 2025
1 parent 6c7ce9d commit 5a15069
Show file tree
Hide file tree
Showing 28 changed files with 151 additions and 67 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,5 @@ generated_plugins.cmake
/book/
/src/flutter/dart/build/
/tests/flutter/linux/flutter/ephemeral
/src/.qmlls.ini
/.qmlls.ini
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ option(KDDockWidgets_FLUTTER_TESTS_AOT "Flutter tests will be built in AOT mode"
option(KDDockWidgets_NO_SPDLOG "Don't use spdlog, even if it is found." OFF)
option(KDDockWidgets_USE_LLD "Use lld for linking" OFF)
option(KDDockWidgets_USE_VALGRIND "Runs the tests under valgrind" OFF)
option(KDDockWidgets_QML_MODULE "The QtQuick support will be built as a QML module" ON) # change to off!

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/ECM/modules")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/KDAB/modules")
Expand Down Expand Up @@ -245,6 +246,10 @@ if(KDDW_FRONTEND_QTWIDGETS OR KDDW_FRONTEND_QTQUICK)
set(KDDW_FRONTEND_QT ON)
endif()

if(KDDockWidgets_QML_MODULE AND (NOT KDDW_FRONTEND_QTQUICK OR NOT KDDockWidgets_QT6))
message(WARNING "KDDockWidgets_QML_MODULE=ON ignored. Only available for QtQuick on Qt6.")
endif()

if(KDDW_FRONTEND_FLUTTER)
if(KDDW_FRONTEND_QT)
message(FATAL_ERROR "The flutter frontend is not compatible with the Qt frontends. Chose a single one.")
Expand Down
7 changes: 6 additions & 1 deletion code.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@
"files.insertFinalNewline": true,
"files.associations": {
"*.code-workspace.template": "json"
}
},
"qt-qml.qmlls.customExePath": "/data/secured/home/serj/Qt/6.8.1/gcc_64/bin/qmlls",
"qt-qml.qmlls.verboseOutput": true,
"qt-qml.qmlls.additionalImportPaths": [
"/data/sources/kddockwidgets/build-dev6/com/kdab/kddockwidgets/"
]
},
"launch": {
"version": "0.2.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/qtquick/customplayground/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ApplicationWindow {
uniqueName: "dock4"
source: "qrc:/Guest4.qml"
onIsFocusedChanged: {
console.log("Dock4 focus changed to: " + isFocused);
console.log("Dock4 focus changed to: " + isFocused);
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/qtquick/customseparator/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ApplicationWindow {
uniqueName: "dock4"
source: "qrc:/Guest4.qml"
onIsFocusedChanged: {
console.log("Dock4 focus changed to: " + isFocused);
console.log("Dock4 focus changed to: " + isFocused);
}
}

Expand Down
6 changes: 3 additions & 3 deletions examples/qtquick/customtabbar/MyTabBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ KDDW.TabBarBase {
Rectangle {
id: addButton
width: 50
color: addButtonMouseArea.containsMouse ? (addButtonMouseArea.pressed ? "#d6ce93" : "#ffecd1" ) : "#ffecd1"
color: addButtonMouseArea.containsMouse ? (addButtonMouseArea.pressed ? "#d6ce93" : "#ffecd1") : "#ffecd1"
anchors {
right: parent.right
top: parent.top
Expand Down Expand Up @@ -103,7 +103,7 @@ KDDW.TabBarBase {
spacing: 2

/// Needed only if you want to style hovered tabs differently
property int hoveredIndex: -1;
property int hoveredIndex: -1

/// ##HERE## The list of tabs is stored in a C++ model. This repeater populates our tab bar
Repeater {
Expand All @@ -112,7 +112,7 @@ KDDW.TabBarBase {
id: tab
height: parent.height
width: 150
readonly property bool isCurrent: index == root.groupCpp.currentIndex;
readonly property bool isCurrent: index == root.groupCpp.currentIndex
color: (tabBarRow.hoveredIndex == index) ? "#d6ce93" : (isCurrent ? "#d6ce93" : "#ffecd1")
border.color: "black"

Expand Down
20 changes: 10 additions & 10 deletions examples/qtquick/customtabbar/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ApplicationWindow {
// For demonstration purposes, show how to change title:
text: qsTr("Change title of #4")
onTriggered: {
dock4.title = "new title";
dock4.title = "new title";
}
}
}
Expand All @@ -51,13 +51,13 @@ ApplicationWindow {
id: dock5
uniqueName: "dock5"
Rectangle {
color: "#85baa1"
anchors.fill: parent
Text {
font.pixelSize: 25
text: "Five"
anchors.centerIn: parent
}
color: "#85baa1"
anchors.fill: parent
Text {
font.pixelSize: 25
text: "Five"
anchors.centerIn: parent
}
}
}

Expand All @@ -68,8 +68,8 @@ ApplicationWindow {
uniqueName: "MyMainLayout"

Component.onCompleted: {
addDockWidget(dock4, KDDW.KDDockWidgets.Location_OnBottom);
dock4.addDockWidgetAsTab(dock5);
addDockWidget(dock4, KDDW.KDDockWidgets.Location_OnBottom);
dock4.addDockWidgetAsTab(dock5);
}
}
}
2 changes: 1 addition & 1 deletion examples/qtquick/customtitlebar/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ApplicationWindow {
uniqueName: "dock4"
source: "qrc:/Guest4.qml"
onIsFocusedChanged: {
console.log("Dock4 focus changed to: " + isFocused);
console.log("Dock4 focus changed to: " + isFocused);
}
}

Expand Down
15 changes: 7 additions & 8 deletions examples/qtquick/dockwidgets/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,21 @@ ApplicationWindow {
Action {
text: qsTr("Close All")
onTriggered: {
_kddwDockRegistry.clear();
_kddwDockRegistry.clear();
}
}

Action {
// Shows how to use direct deletion
text: qsTr("Delete widget #5")
onTriggered: {
dock5.deleteDockWidget();
dock5.deleteDockWidget();
}
}

MenuSeparator { }
Action { text: qsTr("&Quit")
MenuSeparator {}
Action {
text: qsTr("&Quit")
onTriggered: {
Qt.quit();
}
Expand Down Expand Up @@ -129,7 +130,7 @@ ApplicationWindow {

onIsOpenChanged: {
// Just an example of detecting when a dockwidget is closed
console.log("Dock4 is open ? " + isOpen)
console.log("Dock4 is open ? " + isOpen);
}
}

Expand Down Expand Up @@ -186,9 +187,7 @@ ApplicationWindow {
// 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);

addDockWidget(dock6, KDDW.KDDockWidgets.Location_OnLeft, null, Qt.size(500, 100), KDDW.KDDockWidgets.StartHidden);

// dock7 will be tabbed with dock7:
dock5.addDockWidgetAsTab(dock7);
Expand Down
7 changes: 4 additions & 3 deletions examples/qtquick/mdi_with_docking/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ ApplicationWindow {
Action {
text: qsTr("Close All")
onTriggered: {
_kddwDockRegistry.clear();
_kddwDockRegistry.clear();
}
}

MenuSeparator { }
Action { text: qsTr("&Quit")
MenuSeparator {}
Action {
text: qsTr("&Quit")
onTriggered: {
Qt.quit();
}
Expand Down
64 changes: 61 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ set(KDDW_FRONTEND_QTQUICK_SRCS
qtquick/Helpers.cpp
qtquick/ViewFactory.cpp
qtquick/LayoutSaverInstantiator.cpp
qtquick/MainWindowInstantiator.cpp
qtquick/MainWindowMDIInstantiator.cpp
qtquick/DockWidgetInstantiator.cpp
qtquick/QmlTypes.cpp
Expand Down Expand Up @@ -257,7 +256,7 @@ endif()
include(ECMGenerateHeaders)
ecm_generate_headers(camelcase_HEADERS ORIGINAL CAMELCASE HEADER_NAMES Config LayoutSaver)

add_library(kddockwidgets ${KDDockWidgets_LIBRARY_MODE} ${DOCKSLIBS_SRCS} ${KDDW_PUBLIC_HEADERS})
qt_add_library(kddockwidgets ${KDDockWidgets_LIBRARY_MODE} ${DOCKSLIBS_SRCS} ${KDDW_PUBLIC_HEADERS})

add_library(KDAB::kddockwidgets ALIAS kddockwidgets)
set_target_properties(kddockwidgets PROPERTIES OUTPUT_NAME "kddockwidgets${KDDockWidgets_LIBRARY_QTID}")
Expand Down Expand Up @@ -285,7 +284,10 @@ if(KDDW_FRONTEND_QTWIDGETS)
endif()

if(KDDW_FRONTEND_QTQUICK)
target_include_directories(kddockwidgets PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/fwd_headers/qtquick>)
target_include_directories(
kddockwidgets PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/fwd_headers/qtquick>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/qtquick>
)
endif()

if(KDDW_FRONTEND_FLUTTER)
Expand Down Expand Up @@ -559,6 +561,62 @@ if(KDDW_FRONTEND_QTQUICK)
qtquick/views/TitleBar.h
)

if(KDDockWidgets_QML_MODULE)
qt_policy(SET QTP0001 NEW)
function(fix_resource_paths)
foreach(SOURCE_FILE IN LISTS ARGN)
get_filename_component(FILENAME ${SOURCE_FILE} NAME)
set_source_files_properties(${SOURCE_FILE} PROPERTIES QT_RESOURCE_ALIAS ${FILENAME})
endforeach()
endfunction()

set(KDDW_QML_FILES
qtquick/views/qml/DockWidget.qml
qtquick/views/qml/DropArea.qml
qtquick/views/qml/TitleBarBase.qml
qtquick/views/qml/TitleBar.qml
qtquick/views/qml/Group.qml
qtquick/views/qml/FloatingWindow.qml
qtquick/views/qml/TabBarBase.qml
qtquick/views/qml/TabBar.qml
qtquick/views/qml/Separator.qml
qtquick/views/qml/MainWindowMDI.qml
qtquick/views/qml/MDIResizeHandlerHelper.qml
qtquick/views/qml/RubberBand.qml
qtquick/views/qml/TitleBarButton.qml
qtquick/views/qml/ClassicIndicatorsOverlay.qml
qtquick/views/qml/ClassicIndicator.qml
)

fix_resource_paths(${KDDW_QML_FILES})

target_compile_definitions(kddockwidgets PUBLIC KDDW_QML_MODULE)

qt_add_qml_module(
kddockwidgets
URI
com.kdab.dockwidgets
VERSION
2.0
QML_FILES
${KDDW_QML_FILES}
NO_CACHEGEN
SOURCES
KDDockWidgets.h
qtquick/MainWindowInstantiator.cpp
qtquick/MainWindowInstantiator.h
qtquick/LayoutSaverInstantiator.cpp
qtquick/LayoutSaverInstantiator.h
qtquick/DockWidgetInstantiator.cpp
qtquick/DockWidgetInstantiator.h
qtquick/MainWindowMDIInstantiator.cpp
qtquick/MainWindowMDIInstantiator.h
OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/com/kdab/dockwidgets
# NO_PLUGIN # For now. Feel free to enable plugin but add CI test coverage
)
endif()

install(FILES ${KDDW_QTQUICK_HEADERS} DESTINATION ${DOCKS_INCLUDES_INSTALL_PATH}/kddockwidgets/qtquick)
install(FILES ${KDDW_QTQUICK_VIEW_HEADERS} DESTINATION ${DOCKS_INCLUDES_INSTALL_PATH}/kddockwidgets/qtquick)
install(FILES ${KDDW_FRONTEND_QTQUICK_VIEW_HEADERS}
Expand Down
2 changes: 1 addition & 1 deletion src/KDDockWidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void KDDockWidgets::initFrontend(FrontendType type)

const char *KDDockWidgets::spdlogLoggerName()
{
return "com.kdab.kddockwidgets";
return "com.kdab.dockwidgets";
}

NeighbourSqueezeStrategy InitialOption::s_defaultNeighbourSqueezeStrategy = NeighbourSqueezeStrategy::AllNeighbours;
Expand Down
6 changes: 6 additions & 0 deletions src/KDDockWidgets.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@

#endif

#ifdef KDDW_FRONTEND_QTQUICK
#include <QQmlEngine>
#endif


namespace KDDockWidgets::QtQuick {
}
namespace KDDockWidgets::QtWidgets {
Expand All @@ -48,6 +53,7 @@ namespace KDDockWidgets::Flutter {
namespace KDDockWidgets {
QT_DOCKS_EXPORT
Q_NAMESPACE
QML_ELEMENT

namespace QtWidgets {
class DockWidget;
Expand Down
2 changes: 2 additions & 0 deletions src/qtquick/DockWidgetInstantiator.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <QQmlParserStatus>
#include <QQuickItem>
#include <QString>
#include <QQmlEngine>

namespace KDDockWidgets {

Expand All @@ -32,6 +33,7 @@ namespace KDDockWidgets {
class DockWidgetInstantiator : public QQuickItem
{
Q_OBJECT
QML_NAMED_ELEMENT(DockWidget)
Q_PROPERTY(QString uniqueName READ uniqueName WRITE setUniqueName NOTIFY uniqueNameChanged)
Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged)
Q_PROPERTY(KDDockWidgets::QtQuick::DockWidget *dockWidget READ dockWidget NOTIFY
Expand Down
3 changes: 2 additions & 1 deletion src/qtquick/LayoutSaverInstantiator.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "LayoutSaver.h"

#include <QObject>

#include <QQmlEngine>

QT_BEGIN_NAMESPACE
class QQuickItem;
Expand All @@ -33,6 +33,7 @@ namespace KDDockWidgets {
class DOCKS_EXPORT LayoutSaverInstantiator : public QObject, public LayoutSaver
{
Q_OBJECT
QML_NAMED_ELEMENT(LayoutSaver)
Q_PROPERTY(QVector<QString> affinities READ affinities WRITE setAffinities NOTIFY affinitiesChanged)
public:
explicit LayoutSaverInstantiator(QObject *parent = nullptr);
Expand Down
2 changes: 2 additions & 0 deletions src/qtquick/MainWindowInstantiator.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "kddockwidgets/KDDockWidgets.h"

#include <QQuickItem>
#include <QQmlEngine>

namespace KDDockWidgets {

Expand All @@ -30,6 +31,7 @@ class SideBar;
class DOCKS_EXPORT MainWindowInstantiator : public QQuickItem
{
Q_OBJECT
QML_NAMED_ELEMENT(DockingArea)
Q_PROPERTY(QString uniqueName READ uniqueName WRITE setUniqueName NOTIFY uniqueNameChanged)
Q_PROPERTY(QString persistentCentralItemFileName READ persistentCentralItemFileName WRITE setPersistentCentralItemFileName NOTIFY uniqueNameChanged)
Q_PROPERTY(KDDockWidgets::MainWindowOptions options READ options WRITE setOptions NOTIFY
Expand Down
2 changes: 2 additions & 0 deletions src/qtquick/MainWindowMDIInstantiator.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "kddockwidgets/KDDockWidgets.h"

#include <QQuickItem>
#include <QQmlEngine>

namespace KDDockWidgets {

Expand All @@ -30,6 +31,7 @@ class SideBar;
class DOCKS_EXPORT MainWindowMDIInstantiator : public QQuickItem
{
Q_OBJECT
QML_NAMED_ELEMENT(MDIDockingArea)
Q_PROPERTY(QString uniqueName READ uniqueName WRITE setUniqueName NOTIFY uniqueNameChanged)
Q_PROPERTY(QVector<QString> affinities READ affinities CONSTANT)
public:
Expand Down
3 changes: 3 additions & 0 deletions src/qtquick/Platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ void Platform::init()
initResources();
#endif

#ifndef KDDW_QML_MODULE
KDDockWidgets::registerQmlTypes();
#endif

QQuickWindow::setDefaultAlphaBuffer(true);

qGuiApp->connect(qApp, &QGuiApplication::focusObjectChanged, qApp, [this](QObject *obj) {
Expand Down
Loading

0 comments on commit 5a15069

Please sign in to comment.