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: add dde-shell's plugin #17

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 4 additions & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ Copyright: 2010, Marco Martin <[email protected]>
2019, David Edmundson <[email protected]>
License: LGPL-2.0-or-later

# package metadata
Files: */metadata.json
Copyright: None
License: CC0-1.0
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ add_subdirectory(src/ddeintegration)
add_subdirectory(src/models)

set(SOURCE_FILES
main.cpp
desktopintegration.cpp desktopintegration.h
launchercontroller.cpp launchercontroller.h
debughelper.cpp debughelper.h
Expand Down Expand Up @@ -83,6 +82,7 @@ qt_add_dbus_adaptor(DBUS_ADAPTER_FILES dbus/org.deepin.dde.Launcher1.xml launche
qtquick_compiler_add_resources(RESOURCES qml.qrc)

add_executable(${BIN_NAME}
main.cpp
${SOURCE_FILES}
${DBUS_ADAPTER_FILES}
${RESOURCES}
Expand Down Expand Up @@ -114,3 +114,5 @@ install(
FILES dist/org.deepin.dde.launchpad.appdata.xml
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo"
)

include(dde-shell-wrapper/src.cmake)
304 changes: 304 additions & 0 deletions LICENSES/LGPL-3.0-or-later.txt

Large diffs are not rendered by default.

90 changes: 90 additions & 0 deletions dde-shell-wrapper/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "appsmodel.h"
#include "desktopintegration.h"
#include "favoritedproxymodel.h"
#include "searchfilterproxymodel.h"
#include "categorizedsortproxymodel.h"
#include "multipageproxymodel.h"
#include "launchercontroller.h"
#include "debughelper.h"

#include "corona.h"
#include "qmlengine.h"
#include "pluginfactory.h"
DS_USE_NAMESPACE

#include <QDBusConnection>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QQuickStyle>
#include <QCommandLineParser>
#include <DGuiApplicationHelper>
#include <DStandardPaths>
#include <DPathBuf>
#include <launcherappiconprovider.h>
#include <blurhashimageprovider.h>
#include <ksortfilterproxymodel.h>

DCORE_USE_NAMESPACE
DGUI_USE_NAMESPACE

// we should wait for dtkgui to have a "proper" loadTranslation() to use.
QStringList translationDir() {
QList<QString> translateDirs;
QString appName{"dde-launchpad"};
//("/home/user/.local/share", "/usr/local/share", "/usr/share")
const QStringList dataDirs(DStandardPaths::standardLocations(QStandardPaths::GenericDataLocation));
for (const auto &path : dataDirs) {
DPathBuf DPathBuf(path);
translateDirs << (DPathBuf / appName / "translations").toString();
}
return translateDirs;
}

class LanchpadCorona : public DCorona
{
Q_OBJECT
public:
LanchpadCorona(QObject *parent)

Check warning on line 52 in dde-shell-wrapper/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Class 'LanchpadCorona' has a constructor with 1 argument that is not explicit. Such constructors should in general be explicit for type safety reasons. Using the explicit keyword in the constructor means some mistakes when using the class can be avoided.
: DCorona(parent)
{
}
virtual void init() override
{
DGuiApplicationHelper::loadTranslator(QStringLiteral("dde-launchpad"), translationDir(), { QLocale() });

QDBusConnection connection = QDBusConnection::sessionBus();
if (!connection.registerService(QStringLiteral("org.deepin.dde.Launcher1")) ||
!connection.registerObject(QStringLiteral("/org/deepin/dde/Launcher1"), &LauncherController::instance())) {
qWarning() << "register dbus service failed";
}

qmlRegisterType<KSortFilterProxyModel>("org.deepin.vendored", 1, 0, "KSortFilterProxyModel");
qmlRegisterUncreatableType<AppItem>("org.deepin.launchpad", 1, 0, "AppItem", "AppItem should only be created from C++ side");
qmlRegisterSingletonInstance("org.deepin.launchpad", 1, 0, "AppsModel", &AppsModel::instance());
qmlRegisterSingletonInstance("org.deepin.launchpad", 1, 0, "FavoritedProxyModel", &FavoritedProxyModel::instance());
qmlRegisterSingletonInstance("org.deepin.launchpad", 1, 0, "SearchFilterProxyModel", &SearchFilterProxyModel::instance());
qmlRegisterSingletonInstance("org.deepin.launchpad", 1, 0, "CategorizedSortProxyModel", &CategorizedSortProxyModel::instance());
qmlRegisterSingletonInstance("org.deepin.launchpad", 1, 0, "MultipageProxyModel", &MultipageProxyModel::instance());
qmlRegisterSingletonInstance("org.deepin.launchpad", 1, 0, "DesktopIntegration", &DesktopIntegration::instance());
qmlRegisterSingletonInstance("org.deepin.launchpad", 1, 0, "LauncherController", &LauncherController::instance());
qmlRegisterSingletonInstance("org.deepin.launchpad", 1, 0, "DebugHelper", &DebugHelper::instance());

CategorizedSortProxyModel::instance().setCategoryType(CategorizedSortProxyModel::Alphabetary);

auto &engine = *DQmlEngine().engine();

engine.addImageProvider(QLatin1String("app-icon"), new LauncherAppIconProvider);
engine.addImageProvider(QLatin1String("blurhash"), new BlurhashImageProvider);

DCorona::init();
}
};

D_APPLET_CLASS(LanchpadCorona)

#include "main.moc"
9 changes: 9 additions & 0 deletions dde-shell-wrapper/package/main.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

import "qrc:/qml" as Impl

Impl.Main {

}
8 changes: 8 additions & 0 deletions dde-shell-wrapper/package/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Plugin": {
"Version": "1.0",
"Id": "org.deepin.ds.launchpad",
"Url": "main.qml",
"ContainmentType": "Panel"
}
}
36 changes: 36 additions & 0 deletions dde-shell-wrapper/src.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: CC0-1.0

find_package(DDEShell)
if (DDEShell_FOUND)

add_library(ds-launchpad-wrapper SHARED
${CMAKE_CURRENT_LIST_DIR}/main.cpp
${SOURCE_FILES}
${DBUS_ADAPTER_FILES}
${RESOURCES}
${TRANSLATED_FILES}
)
target_compile_definitions(ds-launchpad-wrapper
PRIVATE
DDE_LAUNCHPAD_VERSION=${CMAKE_PROJECT_VERSION}
)
target_link_libraries(ds-launchpad-wrapper PRIVATE
Dde::Shell

Dtk::Core
Dtk::Gui
Qt${QT_MAJOR_VERSION}::Qml
Qt${QT_MAJOR_VERSION}::Quick
Qt${QT_MAJOR_VERSION}::QuickControls2

gio-utils
launcher-utils
launcher-qml-utils
launcher-models
dde-integration-dbus
)
ds_install_package(PACKAGE org.deepin.ds.launchpad TARGET ds-launchpad-wrapper PACKAGE_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/package)

endif()