Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [framework] init qt6 quick framework #2017

Merged
merged 3 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,22 @@ if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "mips")
add_definitions(-D ARCH_MIPSEL)
endif()

find_package(Qt5 COMPONENTS Widgets REQUIRED)
#CMake module
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(install_plugin_quick_module)

# Select major version.
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
message("Using Qt version: ${QT_VERSION_MAJOR}")

if(QT_VERSION_MAJOR EQUAL "6")
set(DFM_BUILD_WITH_QT6 ON)
set(DTK_VERSION_MAJOR 6)
else()
set(DTK_VERSION_MAJOR "")
endif()

find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)
find_package(DtkCMake REQUIRED)
#if no debug, can't out in code define key '__FUNCTION__' and so on
add_definitions(-DQT_MESSAGELOGCONTEXT)
Expand Down Expand Up @@ -119,6 +134,15 @@ if(NOT DEFINED DFM_THUMBNAIL_TOOL)
set(DFM_THUMBNAIL_TOOL ${LIB_INSTALL_DIR}/dde-file-manager/tools)
endif()

# qml module
if(NOT DEFINED DFM_QML_MODULE)
set(DFM_QML_MODULE ${DFM_PLUGIN_DIR}/qml)
endif()

# qml import path for qt creator
list(APPEND QML_DIRS ${DFM_BUILD_PLUGIN_DIR}/qml)
set(QML_IMPORT_PATH ${QML_DIRS} CACHE STRING "Import local module" FORCE)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
Expand All @@ -128,7 +152,8 @@ endif(NOT CMAKE_BUILD_TYPE)
message("Build type:"${CMAKE_BUILD_TYPE})

if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(BUILD_TESTING ON)
# FIXME: QML refactor, disable test temporary.
set(BUILD_TESTING OFF)
set(BUILD_DOCS Off)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Ofast")
Expand All @@ -143,9 +168,11 @@ add_subdirectory(src/apps)
add_subdirectory(src/dfm-base)
add_subdirectory(src/dfm-extension)
add_subdirectory(src/dfm-framework)
add_subdirectory(src/dfm-gui)
add_subdirectory(src/plugins)
add_subdirectory(src/external)
add_subdirectory(src/tools)
# add_subdirectory(src/external)
# add_subdirectory(src/tools)
add_subdirectory(src/dfm-declarative)

# docs
if (BUILD_DOCS)
Expand Down
7 changes: 7 additions & 0 deletions assets/dev/dfm-gui/dfm-gui.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Name: @BIN_NAME@
Description: @CMAKE_PROJECT_DESCRIPTION@
URL: @CMAKE_PROJECT_HOMEPAGE_URL@
Version: @PROJECT_VERSION@
Cflags: -I"@CMAKE_INSTALL_FULL_INCLUDEDIR@"
Libs: -L"@CMAKE_INSTALL_FULL_LIBDIR@" -l@BIN_NAME@
Libs.private: -L"@CMAKE_INSTALL_FULL_LIBDIR@" -l@BIN_NAME@
3 changes: 3 additions & 0 deletions assets/dev/dfm-gui/dfm-guiConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set(@BIN_NAME@_INCLUDE_DIR @CMAKE_INSTALL_FULL_INCLUDEDIR@)
set(@BIN_NAME@_LIBRARIES @BIN_NAME@)
include_directories("${@BIN_NAME@_INCLUDE_DIR}")
16 changes: 16 additions & 0 deletions cmake/install_plugin_quick_module.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Install all plugin qml component file to

function(INSTALL_PLUGIN_QUICK_MODULE DST_PATH)
file(GLOB_RECURSE QMLS CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/*.qml")

if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(QML_BUILD_INSTALL_PATH ${PROJECT_BINARY_DIR}/../../${PROJECT_NAME})
EXECUTE_PROCESS(COMMAND mkdir -p ${QML_BUILD_INSTALL_PATH})
EXECUTE_PROCESS(COMMAND cp -f ${QMLS} ${QML_BUILD_INSTALL_PATH})
message("--- Copy qml file to ${QML_BUILD_INSTALL_PATH}")

else()
install(FILES ${QMLS} DESTINATION ${DST_PATH}/${PROJECT_NAME})
message("--- Copy qml file to ${DST_PATH}/${PROJECT_NAME}")
endif()
endfunction(INSTALL_PLUGIN_QUICK_MODULE)
74 changes: 50 additions & 24 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,59 @@ Build-Depends:
doxygen,
debhelper (>=9),
pkg-config,
qtbase5-dev,
qtbase5-private-dev,
qtmultimedia5-dev,
# Default Qt6 support
qt6-base-dev <!pkg.dfm.qt5>,
qt6-base-private-dev <!pkg.dfm.qt5>,
qt6-multimedia-dev <!pkg.dfm.qt5>,
qt6-tools-dev-tools <!pkg.dfm.qt5>,
qt6-tools-dev <!pkg.dfm.qt5>,
qt6-svg-dev <!pkg.dfm.qt5>,
libdtk6core-dev <!pkg.dfm.qt5>,
libdtk6core-bin <!pkg.dmf.qt5>,
libdtk6gui-dev <!pkg.dfm.qt5>,
libdtk6widget-dev <!pkg.dfm.qt5>,
libdtk6declarative-dev <!pkg.dfm.qt5>,
libdfm6-io-dev <!pkg.dfm.qt5>,
libdfm6-mount-dev <!pkg.dfm.qt5>,
libdfm6-burn-dev <!pkg.dfm.qt5>,
# disable for early develop
# libpolkit-qt6-1-dev <!pkg.dfm.qt5>,
# For Qt5 support, e.g.: dpkg-buildpackage -P pkg.dfm.qt5 ...
qtbase5-dev <pkg.dfm.qt5>,
qtbase5-private-dev <pkg.dfm.qt5>,
qtmultimedia5-dev <pkg.dfm.qt5>,
qttools5-dev-tools <pkg.dfm.qt5>,
qttools5-dev <pkg.dfm.qt5>,
libqt5svg5-dev <pkg.dfm.qt5>,
libqt5xdg-dev <pkg.dfm.qt5>,
libdtkwidget-dev <pkg.dfm.qt5>,
libdtkgui-dev <pkg.dfm.qt5>,
libdtkcore-dev <pkg.dfm.qt5>,
libdtkcore5-bin <pkg.dfm.qt5>,
libdfm-io-dev <pkg.dfm.qt5>,
libdfm-mount-dev <pkg.dfm.qt5>,
libdfm-burn-dev <pkg.dfm.qt5>,
libpolkit-qt5-1-dev <pkg.dfm.qt5>,
# deprecated in qt6?
libkf5codecs-dev <pkg.dfm.qt5>,
libgsettings-qt-dev <pkg.dfm.qt5>,
# Another depends
libgio-qt-dev,
libdmr-dev,
libdframeworkdbus-dev,
libdeepin-pdfium-dev,
dde-dock-dev(>=4.8.4.1),
libffmpegthumbnailer-dev,
libqt5svg5-dev,
libpolkit-agent-1-dev,
libpolkit-qt5-1-dev,
libdtkwidget-dev,
libdtkgui-dev,
libdtkcore-dev,
libdtkcore5-bin,
qttools5-dev-tools,
qttools5-dev,
dde-dock-dev(>=4.8.4.1),
libdframeworkdbus-dev,
libtag1-dev,
libdmr-dev,
libicu-dev,
libdeepin-pdfium-dev,
libqt5xdg-dev,
libgio-qt-dev,
libdfm-io-dev,
libdfm-mount-dev,
libdfm-burn-dev,
libssl-dev,
libgtest-dev,
libgmock-dev,
libgsettings-qt-dev,
liblucene++-dev,
libdocparser-dev,
libboost-filesystem-dev,
libsecret-1-dev,
libkf5codecs-dev,
libpoppler-cpp-dev,
libcryptsetup-dev,
libpcre3-dev,
Expand Down Expand Up @@ -67,7 +87,7 @@ Depends:
${misc:Depends},
libdde-file-manager,
libgio-qt,
libqt5xdg3,
libqt5xdg3 <pkg.dfm.qt5>,
socat,
cryfs,
libblockdev-crypto2,
Expand All @@ -76,7 +96,13 @@ Depends:
dde-file-manager-daemon-plugins,
dde-file-manager-server-plugins,
dde-file-manager-common-plugins,
dde-file-manager-preview-plugins
dde-file-manager-preview-plugins,
# qml required
qml6-module-qtqml,
qml6-module-qtquick,
qml6-module-qtquick-controls,
qml6-module-qtquick-layouts,
qml6-module-qtquick-window
Replaces: dde-file-manager-oem, dde-desktop (<< 6.0.1), libdde-file-manager
Recommends: dde-qt5integration, avfs, samba, deepin-anything-server
Description: File manager front end
Expand Down
6 changes: 5 additions & 1 deletion debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ override_dh_auto_configure:
-DAPP_VERSION=$(DEB_VERSION_UPSTREAM) -DVERSION=$(DEB_VERSION_UPSTREAM) LIB_INSTALL_DIR=/usr/lib/$(DEB_HOST_MULTIARCH)

override_dh_auto_build:
dh_auto_build -- -j8
dh_auto_build -- -j8

# FIXME: remove later.
override_dh_install:
echo "FIXME: temporay changes, skip missing file error."
22 changes: 22 additions & 0 deletions examples/appletwindow/AppletItemEx.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import QtQuick 2.15
import QtQuick.Controls
import org.dfm.base

AppletItem {
property int flag: 1

height: 100
width: 500

Rectangle {
color: "lightyellow"
height: 100
width: 200

Text {
id: appletText

text: "Applet: " + Applet
}
}
}
22 changes: 22 additions & 0 deletions examples/appletwindow/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.10)

project(appletwindow)

add_executable(${PROJECT_NAME} main.cpp
Panel.qml
AppletItemEx.qml)

find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick)

target_link_libraries(
${PROJECT_NAME}
Qt6::Core
Qt6::Gui
Qt6::Quick
DFM::framework
DFM::gui)

file(GLOB_RECURSE QMLS CONFIGURE_DEPENDS
"./*.qml"
)
EXECUTE_PROCESS(COMMAND cp -f ${QMLS} ${PROJECT_BINARY_DIR})
61 changes: 61 additions & 0 deletions examples/appletwindow/Panel.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import QtQuick 2.15
import QtQuick.Controls
import org.dfm.base

ApplicationWindow {
height: 600
width: 800

Text {
id: text

text: "Applets: " + Containment.applets
}

SplitView {
anchors.bottom: parent.bottom
anchors.top: text.bottom
width: parent.width

Rectangle {
SplitView.preferredWidth: 150

Control {
contentItem: Containment.objectForProperty("flag", 1)
}
}

Rectangle {
id: content

SplitView.fillHeight: true
SplitView.fillWidth: true
color: "lightblue"

Column {
id: layout

Button {
id: button

text: "add item"

onClicked: {
let item = Containment.objectForProperty("flag", 1);
if (item) {
leftControl.contentItem = item;
}
}
}

Control {
id: leftControl

onContentItemChanged: {
contentItem.anchors.fill = leftControl;
}
}
}
}
}
}
48 changes: 48 additions & 0 deletions examples/appletwindow/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include <QGuiApplication>
#include <QQuickWindow>
#include <QQmlEngine>

#include <dfm-gui/appletmanager.h>
#include <dfm-gui/windowmanager.h>

int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);

dpf::PluginQuickMetaDataCreator creator;
creator.create("app", "Panel", QUrl::fromLocalFile("./Panel.qml"));
creator.setType("Panel");
auto ptr = creator.take();

QString errorString;
dfmgui::AppletManager::instance()->registeApplet(ptr, &errorString);
qWarning() << errorString;

// child
creator.create("plugin", "AppletItemEx", QUrl::fromLocalFile("./AppletItemEx.qml"));
creator.setParent("app.Panel");
ptr = creator.take();
dfmgui::AppletManager::instance()->registeApplet(ptr, &errorString);
qWarning() << errorString;

creator.create("plugin", "AppletItemEx2", QUrl::fromLocalFile("./AppletItemEx.qml"));
creator.setParent("app.Panel");
ptr = creator.take();
dfmgui::AppletManager::instance()->registeApplet(ptr, &errorString);
qWarning() << errorString;

auto handle = dfmgui::WindowManager::instance()->createWindow("app", "Panel");
handle->window()->show();

handle->window()->dumpObjectTree();

auto handle2 = dfmgui::WindowManager::instance()->createWindow("app", "Panel", { { "flag", 2 } });
handle2->window()->show();

int ret = app.exec();
return ret;
}
1 change: 1 addition & 0 deletions include/dfm-base/base/schemefactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ class SortFilterFactory final : public SchemeFactory<AbstractSortFilter>
static SortFilterFactory &instance(); // 获取全局实例
explicit SortFilterFactory() {}
};

} // namespace dfmbase

#endif // SCHEMEFACTORY_H
2 changes: 2 additions & 0 deletions include/dfm-base/interfaces/abstractentryfileentity.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <QUrl>
#include <QIcon>
#include <QDebug>
#include <QObject>
#include <QVariant>

namespace dfmbase {

Expand Down
1 change: 1 addition & 0 deletions include/dfm-framework/lifecycle/lifecycle.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ QStringList lazyLoadList();
PluginMetaObjectPointer pluginMetaObj(const QString &pluginName,
const QString version = "");
QList<PluginMetaObjectPointer> pluginMetaObjs(const std::function<bool(PluginMetaObjectPointer)> &cond = {});
QList<PluginMetaObjectPointer> pluginSortedMetaObjs(const std::function<bool(PluginMetaObjectPointer)> &cond = {});

bool readPlugins();
bool loadPlugins();
Expand Down
1 change: 1 addition & 0 deletions include/dfm-framework/lifecycle/pluginmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class PluginManager : public QObject
QStringList blackList() const;
QStringList lazyLoadList() const;
QQueue<PluginMetaObjectPointer> readQueue() const;
QQueue<PluginMetaObjectPointer> loadQueue() const;
void addPluginIID(const QString &pluginIIDs);
void addBlackPluginName(const QString &name);
void addLazyLoadPluginName(const QString &name);
Expand Down
Loading
Loading