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

移除Qt5、v23等适配标签 #2075

Merged
merged 2 commits into from
Jul 1, 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
18 changes: 6 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ include(install_plugin_quick_module)
include(install_dconfig)

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

if(QT_VERSION_MAJOR EQUAL "6")
Expand All @@ -35,8 +35,7 @@ else()
endif()

find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)
find_package(Dtk${DTK_VERSION_MAJOR}CMake REQUIRED)
#if no debug, can't out in code define key '__FUNCTION__' and so on
#if no debug, can't out in codke define key '__FUNCTION__' and so on
add_definitions(-DQT_MESSAGELOGCONTEXT)

# TODO: control it by CI. (Automation Testing)
Expand All @@ -47,15 +46,10 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
endif()

#Indentify the version
if (${DEEPIN_OS_VERSION} MATCHES "23")
add_definitions(-DCOMPILE_ON_V23)
set(COMPLIE_ON_V23 TRUE)
message("COMPILE ON v23")
else()
add_definitions(-DCOMPILE_ON_V20)
set(COMPLIE_ON_V20 TRUE)
message("COMPILE ON v20")
endif()
# TODO: remove it
add_definitions(-DCOMPILE_ON_V23)
set(COMPLIE_ON_V23 TRUE)
message("COMPILE ON v23")

# TODO(zhangs): enable it
# Disbale qDebug(), qInfo(), qWaring(), qCritical()
Expand Down
2 changes: 1 addition & 1 deletion include/dfm-framework/lifecycle/pluginmetaobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef PLUGINMETAOBJECT_H
#define PLUGINMETAOBJECT_H

#include "dfm-framework/lifecycle/pluginquickmetadata.h"
#include <dfm-framework/lifecycle/pluginquickmetadata.h>
#include <dfm-framework/dfm_framework_global.h>
#include <dfm-framework/lifecycle/plugindepend.h>

Expand Down
2 changes: 1 addition & 1 deletion include/dfm-framework/lifecycle/pluginquickmetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class PluginQuickMetaData final

private:
QScopedPointer<PluginQuickData> d;
Q_DISABLE_COPY(PluginQuickMetaData);
Q_DISABLE_COPY(PluginQuickMetaData)
};

using PluginQuickMetaPtr = QSharedPointer<PluginQuickMetaData>;
Expand Down
2 changes: 1 addition & 1 deletion include/dfm-gui/dfm_gui_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#define DFMGUI_END_NAMESPACE }
#define DFMGUI_USE_NAMESPACE using namespace DFMGUI_NAMESPACE;

#include <dfm-base/dfm_log_defines.h>
#include <QLoggingCategory>

Q_DECLARE_LOGGING_CATEGORY(logDFMGui)

Expand Down
14 changes: 8 additions & 6 deletions include/dfm-gui/windowmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ class WindowManagerPrivate;
class WindowManager : public QObject
{
Q_OBJECT

explicit WindowManager();
~WindowManager() override;
Q_DISABLE_COPY_MOVE(WindowManager)

public:
using Handle = QPointer<Panel>;
Expand All @@ -32,7 +30,7 @@ class WindowManager : public QObject
QSharedPointer<QQmlEngine> engine() const;

Handle createWindow(const QUrl &url, const QString &pluginName,
const QString &quickId, const QVariantMap &var = {});
const QString &quickId, const QVariantMap &var = {});
void showWindow(const Handle &handle) const;
bool activeExistsWindowByUrl(const QUrl &url) const;

Expand All @@ -55,10 +53,14 @@ class WindowManager : public QObject
void lastWindowClosed(quint64 windId);
void currentUrlChanged(quint64 windId, const QUrl &url);

private:
explicit WindowManager();
~WindowManager() override;

private:
QScopedPointer<WindowManagerPrivate> dptr;
Q_DECLARE_PRIVATE_D(dptr, WindowManager);
Q_DISABLE_COPY(WindowManager)

Q_DECLARE_PRIVATE_D(dptr, WindowManager)
};

using WindowHandle = WindowManager::Handle;
Expand Down
21 changes: 12 additions & 9 deletions src/apps/dde-desktop/data/applications/dfm-open.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

sys_name=$(grep "^SystemName=" /etc/os-version | cut -d'=' -f2)
sys_ver=$(grep "^MajorVersion=" /etc/os-version | cut -d'=' -f2)
# sys_name=$(grep "^SystemName=" /etc/os-version | cut -d'=' -f2)
# sys_ver=$(grep "^MajorVersion=" /etc/os-version | cut -d'=' -f2)

# this is for adapt the new ApplicationManager.
# open computer/trash root with 'gio open',
Expand All @@ -16,11 +16,14 @@ sys_ver=$(grep "^MajorVersion=" /etc/os-version | cut -d'=' -f2)
# So, after opening a directory with xdg-open,
# the application's cgroup can be categorized into the file manager as expected.

if [ "$sys_name" = "Deepin" ] && [ "$sys_ver" = "23" ]; then
echo "open $1 with xdg-open."
xdg-open $1
else
echo "open $1 with gio open."
gio open $1
fi
# if [ "$sys_name" = "Deepin" ] && [ "$sys_ver" = "23" ]; then
# echo "open $1 with xdg-open."
# xdg-open $1
# else
# echo "open $1 with gio open."
# gio open $1
# fi

echo "open $1 with xdg-open."
xdg-open $1

2 changes: 0 additions & 2 deletions src/apps/dde-file-manager/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@

#include <dfm-framework/dpf.h>

// #include <DApplicationSettings>
#include <DSysInfo>

#include <QIcon>
#include <QDir>
// #include <QTextCodec>
#include <QProcess>
#include <QTimer>
#include <QQmlEngine>
Expand Down
25 changes: 10 additions & 15 deletions src/dfm-base/utils/fileutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,8 @@
#include <sys/stat.h>
#include <linux/limits.h>

#ifdef COMPILE_ON_V23
# define APPEARANCE_SERVICE "org.deepin.dde.Appearance1"
# define APPEARANCE_PATH "/org/deepin/dde/Appearance1"
#else
# define APPEARANCE_SERVICE "com.deepin.daemon.Appearance"
# define APPEARANCE_PATH "/com/deepin/daemon/Appearance"
#endif
#define APPEARANCE_SERVICE "org.deepin.dde.Appearance1"
#define APPEARANCE_PATH "/org/deepin/dde/Appearance1"

namespace dfmbase {

Expand Down Expand Up @@ -772,16 +767,16 @@ QString FileUtils::toUnicode(const QByteArray &data, const QString &fileName)
if (data.isEmpty())
return QString();

// const QByteArray &encoding = detectCharset(data, fileName);
// const QByteArray &encoding = detectCharset(data, fileName);

// if (QTextCodec *codec = QTextCodec::codecForName(encoding)) {
// return codec->toUnicode(data);
// }
// if (QTextCodec *codec = QTextCodec::codecForName(encoding)) {
// return codec->toUnicode(data);
// }

// // auto decoder = QStringDecoder(QStringEncoder::System);
// // QString decoding = decoder.decode(encoding);
// // if (!decoding.isEmpty())
// // return decoding;
// // auto decoder = QStringDecoder(QStringEncoder::System);
// // QString decoding = decoder.decode(encoding);
// // if (!decoding.isEmpty())
// // return decoding;

return QString::fromLocal8Bit(data);
}
Expand Down
128 changes: 20 additions & 108 deletions src/dfm-base/utils/universalutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,47 +21,25 @@
#include <QRegularExpression>
#include <DUtil>

#ifdef COMPILE_ON_V23
# define APP_MANAGER_SERVICE "org.desktopspec.ApplicationManager1"
# define APP_MANAGER_PATH_PREFIX "/org/desktopspec/ApplicationManager1"
# define APP_INTERFACE "org.desktopspec.ApplicationManager1.Application"

# define SYSTEM_SYSTEMINFO_SERVICE "org.deepin.dde.SystemInfo1"
# define SYSTEM_SYSTEMINFO_PATH "/org/deepin/dde/SystemInfo1"
# define SYSTEM_SYSTEMINFO_INTERFACE "org.deepin.dde.SystemInfo1"

# define DEAMON_SYSTEMINFO_SERVICE "org.deepin.daemon.SystemInfo1"
# define DEAMON_SYSTEMINFO_PATH "/org/deepin/daemon/SystemInfo1"
# define DEAMON_SYSTEMINFO_INTERFACE "org.deepin.daemon.SystemInfo1"

# define DEAMON_DOCK_SERVICE "org.deepin.dde.daemon.Dock1"
# define DEAMON_DOCK_PATH "/org/deepin/dde/daemon/Dock1"
# define DEAMON_DOCK_INTERFACE "org.deepin.dde.daemon.Dock1"

# define DDE_LOCKSERVICE_SERVICE "org.deepin.dde.LockService1"
# define DDE_LOCKSERVICE_PATH "/org/deepin/dde/LockService1"
# define DDE_LOCKSERVICE_INTERFACE "org.deepin.dde.LockService1"
#else
# define APP_MANAGER_SERVICE "com.deepin.SessionManager"
# define APP_MANAGER_PATH "/com/deepin/StartManager"
# define APP_MANAGER_INTERFACE "com.deepin.StartManager"

# define SYSTEM_SYSTEMINFO_SERVICE "com.deepin.system.SystemInfo"
# define SYSTEM_SYSTEMINFO_PATH "/com/deepin/system/SystemInfo"
# define SYSTEM_SYSTEMINFO_INTERFACE "com.deepin.system.SystemInfo"

# define DEAMON_SYSTEMINFO_SERVICE "com.deepin.daemon.SystemInfo"
# define DEAMON_SYSTEMINFO_PATH "/com/deepin/daemon/SystemInfo"
# define DEAMON_SYSTEMINFO_INTERFACE "com.deepin.daemon.SystemInfo"

# define DEAMON_DOCK_SERVICE "com.deepin.dde.daemon.Dock"
# define DEAMON_DOCK_PATH "/com/deepin/dde/daemon/Dock"
# define DEAMON_DOCK_INTERFACE "com.deepin.dde.daemon.Dock"

# define DDE_LOCKSERVICE_SERVICE "com.deepin.dde.LockService"
# define DDE_LOCKSERVICE_PATH "/com/deepin/dde/LockService"
# define DDE_LOCKSERVICE_INTERFACE "com.deepin.dde.LockService"
#endif
#define APP_MANAGER_SERVICE "org.desktopspec.ApplicationManager1"
#define APP_MANAGER_PATH_PREFIX "/org/desktopspec/ApplicationManager1"
#define APP_INTERFACE "org.desktopspec.ApplicationManager1.Application"

#define SYSTEM_SYSTEMINFO_SERVICE "org.deepin.dde.SystemInfo1"
#define SYSTEM_SYSTEMINFO_PATH "/org/deepin/dde/SystemInfo1"
#define SYSTEM_SYSTEMINFO_INTERFACE "org.deepin.dde.SystemInfo1"

#define DEAMON_SYSTEMINFO_SERVICE "org.deepin.daemon.SystemInfo1"
#define DEAMON_SYSTEMINFO_PATH "/org/deepin/daemon/SystemInfo1"
#define DEAMON_SYSTEMINFO_INTERFACE "org.deepin.daemon.SystemInfo1"

#define DEAMON_DOCK_SERVICE "org.deepin.dde.daemon.Dock1"
#define DEAMON_DOCK_PATH "/org/deepin/dde/daemon/Dock1"
#define DEAMON_DOCK_INTERFACE "org.deepin.dde.daemon.Dock1"

#define DDE_LOCKSERVICE_SERVICE "org.deepin.dde.LockService1"
#define DDE_LOCKSERVICE_PATH "/org/deepin/dde/LockService1"
#define DDE_LOCKSERVICE_INTERFACE "org.deepin.dde.LockService1"

namespace dfmbase {

Expand Down Expand Up @@ -260,39 +238,13 @@ bool UniversalUtils::checkLaunchAppInterface()
initStatus = false;
return;
}
#ifndef COMPILE_ON_V23
QDBusInterface introspect(APP_MANAGER_SERVICE,
APP_MANAGER_PATH,
"org.freedesktop.DBus.Introspectable",
QDBusConnection::sessionBus());
introspect.setTimeout(1000);
QDBusPendingReply<QString> reply = introspect.asyncCallWithArgumentList(QStringLiteral("Introspect"), {});
reply.waitForFinished();
if (reply.isFinished() && reply.isValid() && !reply.isError()) {
QString xmlCode = reply.argumentAt(0).toString();
if (xmlCode.contains(APP_MANAGER_INTERFACE)) {
if (xmlCode.contains("LaunchApp")) {
initStatus = true;
} else {
qCWarning(logDFMBase) << QString("%1 : doesn't have LaunchApp interface.").arg(APP_MANAGER_SERVICE);
initStatus = false;
}
} else {
qCWarning(logDFMBase) << QString("%1 : Introspect error").arg(APP_MANAGER_SERVICE) << xmlCode;
initStatus = false;
}
} else {
initStatus = false;
}
#endif
});
return initStatus;
}

bool UniversalUtils::launchAppByDBus(const QString &desktopFile, const QStringList &filePaths)
{
#ifdef COMPILE_ON_V23
const auto &file = QFileInfo{desktopFile};
const auto &file = QFileInfo { desktopFile };
constexpr auto kDesktopSuffix { u8"desktop" };

if (file.suffix() != kDesktopSuffix) {
Expand All @@ -311,52 +263,12 @@ bool UniversalUtils::launchAppByDBus(const QString &desktopFile, const QStringLi
auto reply = appManager.callWithArgumentList(QDBus::Block, QStringLiteral("Launch"), { QVariant::fromValue(QString {}), QVariant::fromValue(filePaths), QVariant::fromValue(QVariantMap {}) });

return reply.type() == QDBusMessage::ReplyMessage;

#else
QDBusInterface appManager(APP_MANAGER_SERVICE,
APP_MANAGER_PATH,
APP_MANAGER_INTERFACE,
QDBusConnection::sessionBus());

QList<QVariant> argumentList;
argumentList << QVariant::fromValue(desktopFile) << QVariant::fromValue(static_cast<uint>(QX11Info::getTimestamp())) << QVariant::fromValue(filePaths);
appManager.asyncCallWithArgumentList(QStringLiteral("LaunchApp"), argumentList);
return true;
#endif
}

bool UniversalUtils::runCommand(const QString &cmd, const QStringList &args, const QString &wd)
{
#ifdef COMPILE_ON_V23
qCDebug(logDFMBase) << "new AM wouldn't provide any method to run Command, so launch cmd by qt:" << cmd << args;
return QProcess::startDetached(cmd, args, wd);
#else
if (checkLaunchAppInterface()) {
qCDebug(logDFMBase) << "launch cmd by dbus:" << cmd << args;
QDBusInterface appManager(APP_MANAGER_SERVICE,
APP_MANAGER_PATH,
APP_MANAGER_INTERFACE,
QDBusConnection::sessionBus());

QList<QVariant> argumentList;
argumentList << QVariant::fromValue(cmd) << QVariant::fromValue(args);

if (!wd.isEmpty()) {
QVariantMap opt = { { "dir", wd } };
argumentList << QVariant::fromValue(opt);
appManager.asyncCallWithArgumentList(QStringLiteral("RunCommandWithOptions"), argumentList);
} else {
appManager.asyncCallWithArgumentList(QStringLiteral("RunCommand"), argumentList);
}

return true;
} else {
qCDebug(logDFMBase) << "launch cmd by qt:" << cmd << args;
return QProcess::startDetached(cmd, args, wd);
}

return false;
#endif
}

int UniversalUtils::dockHeight()
Expand Down
3 changes: 2 additions & 1 deletion src/dfm-framework/lifecycle/pluginquickmetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include <dfm-framework/lifecycle/pluginquickmetadata.h>
#include "private/pluginquickmetadata_p.h"

#include <dfm-framework/lifecycle/pluginquickmetadata.h>

DPF_BEGIN_NAMESPACE

PluginQuickMetaData::PluginQuickMetaData()
Expand Down
16 changes: 8 additions & 8 deletions src/dfm-framework/lifecycle/private/pluginmanager_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,17 +262,17 @@ void PluginManagerPrivate::jsonToMeta(PluginMetaObjectPointer metaObject, const
metaObject->d->state = PluginMetaObject::kReaded;

// QML 组件信息
QJsonArray quickArray = metaData.value(kQuick).toArray();
for (auto quickItr : quickArray) {
QJsonObject quick = quickItr.toObject();
QJsonArray &&quickArray = metaData.value(kQuick).toArray();
for (const auto &quickItr : quickArray) {
const QJsonObject &quick = quickItr.toObject();

QString quickParent = quick.value(kQuickParent).toString();
// Quick plugin 的 parent 必须在 Depends 字段存在
if (!quickParent.isEmpty()) {
QString parPlugin = quickParent.split('.').first();
QList<PluginDepend> &depends = metaObject->d->depends;
QList<PluginDepend>::iterator findItr = std::find_if(depends.begin(), depends.end(), [&](const PluginDepend &depend) {
return depend.pluginName == parPlugin;
if (!quickParent.isEmpty() && quickParent.contains(".")) {
QString parentPlugin = quickParent.split('.').first();
const QList<PluginDepend> &depends = metaObject->d->depends;
auto findItr = std::find_if(depends.cbegin(), depends.cend(), [&parentPlugin](const PluginDepend &depend) {
return depend.pluginName == parentPlugin;
});

if (findItr == metaObject->d->depends.end()) {
Expand Down
Loading
Loading