feat: 修改自启动应用启动方式
*修改自启动应用启动方式, 采用loader进程先校验应用信息,再拉起应用的方式 *修复launcher模块部分接口导出失败的问题 *增加launcher、dock、loader模块代码注释 Log: 修改自启动应用启动方式 Task: https://pms.uniontech.com/task-view-131611.html Influence: 应用启动方式不同 Change-Id: Ie88027602d1395c6bbad69e610f3639ecc7dfbc1
This commit is contained in:
parent
68f52fe831
commit
5997b3a2a1
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,2 @@
|
|||||||
CMakeLists.txt.user
|
CMakeLists.txt.user
|
||||||
build/
|
build/
|
||||||
|
@ -1,16 +1,9 @@
|
|||||||
<interface name='org.desktopspec.ApplicationManager'>
|
<interface name='org.desktopspec.ApplicationManager'>
|
||||||
<method name='Run'>
|
<method name='Launch'>
|
||||||
<arg type='s' name='id' direction='in'/>
|
<arg type='s' name='id' direction='in'/>
|
||||||
|
<arg type='as' name='files' direction='in' />
|
||||||
<arg type='o' name='instance' direction='out'/>
|
<arg type='o' name='instance' direction='out'/>
|
||||||
</method>
|
</method>
|
||||||
<method name='GetInformation'>
|
|
||||||
<arg type='s' name='id' direction='in' />
|
|
||||||
<arg type='o' name='info' direction='out' />
|
|
||||||
</method>
|
|
||||||
<method name='GetInstances'>
|
|
||||||
<arg type='s' name='id' direction='in' />
|
|
||||||
<arg type='ao' name='instances' direction='out' />
|
|
||||||
</method>
|
|
||||||
<method name='AddAutostart'>
|
<method name='AddAutostart'>
|
||||||
<arg type='s' name='fileNamae' direction='in' />
|
<arg type='s' name='fileNamae' direction='in' />
|
||||||
<arg type='b' name='outArg0' direction='out' />
|
<arg type='b' name='outArg0' direction='out' />
|
||||||
@ -32,11 +25,6 @@
|
|||||||
<method name='IsMemSufficient'>
|
<method name='IsMemSufficient'>
|
||||||
<arg type='b' name='outArg0' direction='out' />
|
<arg type='b' name='outArg0' direction='out' />
|
||||||
</method>
|
</method>
|
||||||
<method name='LaunchApp'>
|
|
||||||
<arg type='s' name='desktopFile' direction='in' />
|
|
||||||
<arg type='u' name='timestamp' direction='in' />
|
|
||||||
<arg type='as' name='files' direction='in' />
|
|
||||||
</method>
|
|
||||||
<method name='LaunchAppAction'>
|
<method name='LaunchAppAction'>
|
||||||
<arg type='s' name='desktopFile' direction='in' />
|
<arg type='s' name='desktopFile' direction='in' />
|
||||||
<arg type='s' name='action' direction='in' />
|
<arg type='s' name='action' direction='in' />
|
||||||
|
@ -3,7 +3,7 @@ set(DCONFIG_FILES
|
|||||||
com.deepin.dde.dock.json
|
com.deepin.dde.dock.json
|
||||||
com.deepin.dde.appearance.json
|
com.deepin.dde.appearance.json
|
||||||
com.deepin.dde.startdde.json
|
com.deepin.dde.startdde.json
|
||||||
com.deepin.dde.xsettings.json
|
com.deepin.xsettings.json
|
||||||
)
|
)
|
||||||
|
|
||||||
install(FILES ${DCONFIG_FILES} DESTINATION /usr/share/dsg/configs/dde-application-manager)
|
install(FILES ${DCONFIG_FILES} DESTINATION /usr/share/dsg/configs/dde-application-manager)
|
||||||
|
@ -22,13 +22,13 @@
|
|||||||
|
|
||||||
bool LauncherItemInfo::operator!=(const LauncherItemInfo &itemInfo)
|
bool LauncherItemInfo::operator!=(const LauncherItemInfo &itemInfo)
|
||||||
{
|
{
|
||||||
return itemInfo.ID != ID;
|
return itemInfo.id != id;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDBusArgument &operator<<(QDBusArgument &argument, const LauncherItemInfo &itemInfo)
|
QDBusArgument &operator<<(QDBusArgument &argument, const LauncherItemInfo &itemInfo)
|
||||||
{
|
{
|
||||||
argument.beginStructure();
|
argument.beginStructure();
|
||||||
argument << itemInfo.Path << itemInfo.Name << itemInfo.ID << itemInfo.Icon << itemInfo.CategoryID << itemInfo.TimeInstalled;
|
argument << itemInfo.path << itemInfo.name << itemInfo.id << itemInfo.icon << itemInfo.categoryId << itemInfo.timeInstalled << itemInfo.keywords;
|
||||||
argument.endStructure();
|
argument.endStructure();
|
||||||
return argument;
|
return argument;
|
||||||
}
|
}
|
||||||
@ -36,7 +36,7 @@ QDBusArgument &operator<<(QDBusArgument &argument, const LauncherItemInfo &itemI
|
|||||||
const QDBusArgument &operator>>(const QDBusArgument &argument, LauncherItemInfo &itemInfo)
|
const QDBusArgument &operator>>(const QDBusArgument &argument, LauncherItemInfo &itemInfo)
|
||||||
{
|
{
|
||||||
argument.beginStructure();
|
argument.beginStructure();
|
||||||
argument >> itemInfo.Path >> itemInfo.Name >> itemInfo.ID >> itemInfo.Icon >> itemInfo.CategoryID >> itemInfo.TimeInstalled;
|
argument >> itemInfo.path >> itemInfo.name >> itemInfo.id >> itemInfo.icon >> itemInfo.categoryId >> itemInfo.timeInstalled >> itemInfo.keywords;
|
||||||
argument.endStructure();
|
argument.endStructure();
|
||||||
return argument;
|
return argument;
|
||||||
}
|
}
|
||||||
|
@ -26,12 +26,13 @@
|
|||||||
#include <QDBusMetaType>
|
#include <QDBusMetaType>
|
||||||
|
|
||||||
struct LauncherItemInfo {
|
struct LauncherItemInfo {
|
||||||
QString Path;
|
QString path;
|
||||||
QString Name;
|
QString name;
|
||||||
QString ID;
|
QString id;
|
||||||
QString Icon;
|
QString icon;
|
||||||
qint64 CategoryID;
|
qint64 categoryId;
|
||||||
qint64 TimeInstalled;
|
qint64 timeInstalled;
|
||||||
|
QStringList keywords;
|
||||||
bool operator!=(const LauncherItemInfo &versionInfo);
|
bool operator!=(const LauncherItemInfo &versionInfo);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ public:
|
|||||||
friend const QDBusArgument &operator>>(const QDBusArgument &arg, Rect &rect);
|
friend const QDBusArgument &operator>>(const QDBusArgument &arg, Rect &rect);
|
||||||
friend QDBusArgument &operator<<(QDBusArgument &arg, const Rect &rect);
|
friend QDBusArgument &operator<<(QDBusArgument &arg, const Rect &rect);
|
||||||
|
|
||||||
private:
|
|
||||||
qint32 X, Y, Width, Height;
|
qint32 X, Y, Width, Height;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
7
src/frameworkdbus/types/unlaunchedappmap.cpp
Normal file
7
src/frameworkdbus/types/unlaunchedappmap.cpp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#include "unlaunchedappmap.h"
|
||||||
|
|
||||||
|
void registerUnLaunchedAppMapMetaType()
|
||||||
|
{
|
||||||
|
qRegisterMetaType<UnLaunchedAppMap>("UnLaunchedAppMap");
|
||||||
|
qDBusRegisterMetaType<UnLaunchedAppMap>();
|
||||||
|
}
|
14
src/frameworkdbus/types/unlaunchedappmap.h
Normal file
14
src/frameworkdbus/types/unlaunchedappmap.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#ifndef TYPES_H
|
||||||
|
#define TYPES_H
|
||||||
|
|
||||||
|
#include <QMap>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QDBusMetaType>
|
||||||
|
|
||||||
|
typedef QMap<QString, QStringList> UnLaunchedAppMap;
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(UnLaunchedAppMap)
|
||||||
|
|
||||||
|
void registerUnLaunchedAppMapMetaType();
|
||||||
|
|
||||||
|
#endif // TYPES_H
|
@ -48,7 +48,7 @@ std::string BaseDir::userDataDir()
|
|||||||
if (!xdgDataHomePtr)
|
if (!xdgDataHomePtr)
|
||||||
return defaultDir;
|
return defaultDir;
|
||||||
|
|
||||||
if (!DFile::isAbs(xdgDataHomePtr))
|
if (!DFile::isDir(xdgDataHomePtr))
|
||||||
return defaultDir;
|
return defaultDir;
|
||||||
|
|
||||||
return std::string(xdgDataHomePtr) + "/";
|
return std::string(xdgDataHomePtr) + "/";
|
||||||
@ -80,7 +80,7 @@ std::string BaseDir::userConfigDir()
|
|||||||
return defaultDir;
|
return defaultDir;
|
||||||
|
|
||||||
std::string xdgConfigHome(xdgConfigHomePtr);
|
std::string xdgConfigHome(xdgConfigHomePtr);
|
||||||
if (!DFile::isAbs(xdgConfigHome))
|
if (!DFile::isDir(xdgConfigHome))
|
||||||
return defaultDir;
|
return defaultDir;
|
||||||
|
|
||||||
return xdgConfigHome + "/";
|
return xdgConfigHome + "/";
|
||||||
@ -112,7 +112,7 @@ std::string BaseDir::userCacheDir()
|
|||||||
return defaultDir;
|
return defaultDir;
|
||||||
|
|
||||||
std::string xdgCacheHome(xdgCacheHomePtr);
|
std::string xdgCacheHome(xdgCacheHomePtr);
|
||||||
if (!DFile::isAbs(xdgCacheHome))
|
if (!DFile::isDir(xdgCacheHome))
|
||||||
return defaultDir;
|
return defaultDir;
|
||||||
|
|
||||||
return xdgCacheHome + "/";
|
return xdgCacheHome + "/";
|
||||||
@ -158,7 +158,7 @@ std::string BaseDir::userAutoStartDir()
|
|||||||
void BaseDir::filterNotAbs(std::vector<std::string> &dirs)
|
void BaseDir::filterNotAbs(std::vector<std::string> &dirs)
|
||||||
{
|
{
|
||||||
for (auto iter = dirs.begin(); iter != dirs.end();) { // erase element in vector
|
for (auto iter = dirs.begin(); iter != dirs.end();) { // erase element in vector
|
||||||
if (!DFile::isAbs(*iter))
|
if (!DFile::isDir(*iter))
|
||||||
iter = dirs.erase(iter);
|
iter = dirs.erase(iter);
|
||||||
else
|
else
|
||||||
iter++;
|
iter++;
|
||||||
|
@ -43,7 +43,7 @@ DesktopInfo::DesktopInfo(const std::string &_fileName)
|
|||||||
|
|
||||||
m_fileName = fileNameWithSuffix;
|
m_fileName = fileNameWithSuffix;
|
||||||
|
|
||||||
if (!DFile::isAbs(m_fileName)) {
|
if (DFile::dir(m_fileName).empty()) {
|
||||||
// fileName是文件名,增加目录
|
// fileName是文件名,增加目录
|
||||||
bool isExisted = false;
|
bool isExisted = false;
|
||||||
for (const auto &dir : BaseDir::appDirs()) {
|
for (const auto &dir : BaseDir::appDirs()) {
|
||||||
|
@ -21,7 +21,9 @@
|
|||||||
|
|
||||||
#include "dfile.h"
|
#include "dfile.h"
|
||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
|
#include "dstring.h"
|
||||||
|
|
||||||
|
#include<sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
@ -30,14 +32,39 @@ DFile::DFile()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DFile::isAbs(std::string file)
|
// 符号连接
|
||||||
|
bool DFile::isLink(std::string file)
|
||||||
{
|
{
|
||||||
char resolved_path[MAX_FILEPATH_LEN];
|
if (file.empty())
|
||||||
if (realpath(file.c_str(), resolved_path)) {
|
return false;
|
||||||
std::string filePath(resolved_path);
|
|
||||||
if (filePath == file)
|
struct stat fileStat;
|
||||||
return true;
|
if (!stat(file.c_str(), &fileStat))
|
||||||
}
|
return S_ISLNK(fileStat.st_mode);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DFile::isRegularFile(std::string file)
|
||||||
|
{
|
||||||
|
if (file.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
struct stat fileStat;
|
||||||
|
if (!stat(file.c_str(), &fileStat))
|
||||||
|
return S_ISREG(fileStat.st_mode);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DFile::isDir(std::string dir)
|
||||||
|
{
|
||||||
|
if (dir.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
struct stat fileStat;
|
||||||
|
if (!stat(dir.c_str(), &fileStat))
|
||||||
|
return S_ISDIR(fileStat.st_mode);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -47,13 +74,15 @@ bool DFile::isExisted(std::string file)
|
|||||||
return !access(file.c_str(), F_OK);
|
return !access(file.c_str(), F_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DFile::dir(std::string file)
|
std::string DFile::dir(std::string path)
|
||||||
{
|
{
|
||||||
std::string ret;
|
std::string ret;
|
||||||
if (isAbs(file)) {
|
if (isDir(path)) {
|
||||||
size_t pos = file.find_last_of("/");
|
ret = path;
|
||||||
|
} else {
|
||||||
|
size_t pos = path.find_last_of("/");
|
||||||
if (pos != std::string::npos) {
|
if (pos != std::string::npos) {
|
||||||
ret.assign(file, 0, pos + 1); // 包含结尾斜杠/
|
ret.assign(path, 0, pos + 1); // 包含结尾斜杠/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,9 +28,11 @@ class DFile
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit DFile();
|
explicit DFile();
|
||||||
static bool isAbs(std::string file);
|
static bool isLink(std::string file);
|
||||||
|
static bool isRegularFile(std::string file);
|
||||||
|
static bool isDir(std::string dir);
|
||||||
static bool isExisted(std::string file);
|
static bool isExisted(std::string file);
|
||||||
static std::string dir(std::string file);
|
static std::string dir(std::string path);
|
||||||
static std::string base(std::string file);
|
static std::string base(std::string file);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,7 +25,11 @@
|
|||||||
#define _likely_(x) (__builtin_expect(!!(x), 1))
|
#define _likely_(x) (__builtin_expect(!!(x), 1))
|
||||||
#define _unlikely_(x) (__builtin_expect(!!(x), 0))
|
#define _unlikely_(x) (__builtin_expect(!!(x), 0))
|
||||||
|
|
||||||
|
#define MAX(x, y) (x) > (y) ? (x) : (y)
|
||||||
|
#define MIN(x, y) (x) < (y) ? (x) : (y)
|
||||||
|
|
||||||
#define MAX_FILEPATH_LEN 256
|
#define MAX_FILEPATH_LEN 256
|
||||||
#define MAX_LINE_LEN 256
|
#define MAX_LINE_LEN 256
|
||||||
|
|
||||||
|
|
||||||
#endif // MACRO_H
|
#endif // MACRO_H
|
||||||
|
@ -53,9 +53,11 @@ static App parseApp(const std::string& app)
|
|||||||
}
|
}
|
||||||
|
|
||||||
App result;
|
App result;
|
||||||
result.prefix = strings[0];
|
if (strings.size() == 3) {
|
||||||
result.type = strings[1];
|
result.prefix = strings[0];
|
||||||
result.id = strings[2];
|
result.type = strings[1];
|
||||||
|
result.id = strings[2];
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -80,20 +82,12 @@ int runLinglong(void* _arg)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int child(void* _arg)
|
int child(Methods::Task* task, std::string path)
|
||||||
{
|
{
|
||||||
Methods::Task* task = (Methods::Task*) _arg;
|
|
||||||
|
|
||||||
prctl(PR_SET_PDEATHSIG, SIGKILL);
|
prctl(PR_SET_PDEATHSIG, SIGKILL);
|
||||||
prctl(PR_SET_PDEATHSIG, SIGTERM);
|
prctl(PR_SET_PDEATHSIG, SIGTERM);
|
||||||
prctl(PR_SET_PDEATHSIG, SIGHUP);
|
prctl(PR_SET_PDEATHSIG, SIGHUP);
|
||||||
|
|
||||||
App app = parseApp(task->runId.toStdString());
|
|
||||||
std::string path{ "/usr/share/applications/" + app.id + ".desktop" };
|
|
||||||
if (app.type == "user") {
|
|
||||||
struct passwd* user = getpwuid(getuid());
|
|
||||||
path = std::string(user->pw_dir) + "/.local/share/applications/" + app.id + ".desktop";
|
|
||||||
}
|
|
||||||
DesktopDeconstruction dd(path);
|
DesktopDeconstruction dd(path);
|
||||||
dd.beginGroup("Desktop Entry");
|
dd.beginGroup("Desktop Entry");
|
||||||
std::cout << dd.value<std::string>("Exec") << std::endl;
|
std::cout << dd.value<std::string>("Exec") << std::endl;
|
||||||
@ -114,8 +108,8 @@ int child(void* _arg)
|
|||||||
std::filesystem::path container_root_path(annotations.container_root_path.toStdString());
|
std::filesystem::path container_root_path(annotations.container_root_path.toStdString());
|
||||||
if (!std::filesystem::exists(container_root_path)) {
|
if (!std::filesystem::exists(container_root_path)) {
|
||||||
if (!std::filesystem::create_directories(container_root_path)) {
|
if (!std::filesystem::create_directories(container_root_path)) {
|
||||||
std::cout << "[Loader] [Warning] cannot create container root path." << std::endl;
|
std::cout << "[Loader] [Warning] cannot create container root path." << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,10 +131,12 @@ int child(void* _arg)
|
|||||||
runtime.process.args.push_back(QString::fromStdString(s));
|
runtime.process.args.push_back(QString::fromStdString(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 应用运行信息
|
||||||
QByteArray runtimeArray;
|
QByteArray runtimeArray;
|
||||||
toJson(runtimeArray, runtime);
|
toJson(runtimeArray, runtime);
|
||||||
qWarning() << "runtimeArray: " << runtimeArray;
|
qWarning() << "runtimeArray: " << runtimeArray;
|
||||||
|
|
||||||
|
// 使用Pipe进行父子进程通信
|
||||||
int pipeEnds[2];
|
int pipeEnds[2];
|
||||||
if (pipe(pipeEnds) != 0) {
|
if (pipe(pipeEnds) != 0) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
@ -153,22 +149,29 @@ int child(void* _arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
|
// 子进程
|
||||||
(void) close(pipeEnds[1]);
|
(void) close(pipeEnds[1]);
|
||||||
|
|
||||||
|
// 重定向到LINGLONG
|
||||||
if (dup2(pipeEnds[0], LINGLONG) == -1) {
|
if (dup2(pipeEnds[0], LINGLONG) == -1) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
(void) close(pipeEnds[0]);
|
(void) close(pipeEnds[0]);
|
||||||
|
|
||||||
|
// 初始化运行命令和参数,并执行
|
||||||
char const* const args[] = { "/usr/bin/ll-box", LL_TOSTRING(LINGLONG), nullptr };
|
char const* const args[] = { "/usr/bin/ll-box", LL_TOSTRING(LINGLONG), nullptr };
|
||||||
int ret = execvp(args[0], (char**) args);
|
int ret = execvp(args[0], (char**) args);
|
||||||
std::cout << "[Loader] [Fork] " << ret << std::endl;
|
std::cout << "[Loader] [Fork] " << ret << std::endl;
|
||||||
//std::filesystem::remove(container_root_path);
|
//std::filesystem::remove(container_root_path);
|
||||||
exit(ret);
|
exit(ret);
|
||||||
}
|
} else {
|
||||||
else {
|
// 父进程
|
||||||
QByteArray runtimeArray;
|
QByteArray runtimeArray;
|
||||||
linglong::toJson(runtimeArray, runtime);
|
linglong::toJson(runtimeArray, runtime);
|
||||||
const std::string data = runtimeArray.data();
|
const std::string data = runtimeArray.data();
|
||||||
close(pipeEnds[0]);
|
close(pipeEnds[0]);
|
||||||
|
|
||||||
|
// 将运行时信息通过pipe传递给子进程
|
||||||
write(pipeEnds[1], data.c_str(), data.size());
|
write(pipeEnds[1], data.c_str(), data.size());
|
||||||
close(pipeEnds[1]);
|
close(pipeEnds[1]);
|
||||||
}
|
}
|
||||||
@ -190,22 +193,24 @@ int main(int argc, char* argv[])
|
|||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: move to a utils.h
|
char socketPath[50];
|
||||||
std::string socketPath{ "/run/user/1000/deepin-application-manager.socket" };
|
sprintf(socketPath, "/run/user/%d/deepin-application-manager.socket", getuid());
|
||||||
|
|
||||||
// register client and run quitConnect
|
// register client and run quitConnect
|
||||||
Socket::Client client;
|
Socket::Client client;
|
||||||
client.connect(socketPath);
|
client.connect(socketPath);
|
||||||
|
|
||||||
|
// 初始化应用注册信息
|
||||||
QByteArray registerArray;
|
QByteArray registerArray;
|
||||||
Methods::Registe registe;
|
Methods::Registe registe;
|
||||||
registe.id = dam_task_type;
|
registe.id = dam_task_type;
|
||||||
registe.hash = dam_task_hash;
|
registe.hash = dam_task_hash;
|
||||||
Methods::toJson(registerArray, registe);
|
Methods::toJson(registerArray, registe);
|
||||||
|
|
||||||
|
// 向AM注册应用信息进行校验
|
||||||
Methods::Registe registe_result;
|
Methods::Registe registe_result;
|
||||||
registe_result.state = false;
|
registe_result.state = false;
|
||||||
auto result = client.get(registerArray);
|
QByteArray result = client.get(registerArray);
|
||||||
if (!result.isEmpty()) {
|
if (!result.isEmpty()) {
|
||||||
Methods::fromJson(result, registe_result);
|
Methods::fromJson(result, registe_result);
|
||||||
}
|
}
|
||||||
@ -213,16 +218,31 @@ int main(int argc, char* argv[])
|
|||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 初始化应用实例信息
|
||||||
Methods::Instance instance;
|
Methods::Instance instance;
|
||||||
instance.hash = registe_result.hash;
|
instance.hash = registe_result.hash;
|
||||||
std::cout << "get task" << std::endl;
|
|
||||||
QByteArray instanceArray;
|
QByteArray instanceArray;
|
||||||
Methods::toJson(instanceArray, instance);
|
Methods::toJson(instanceArray, instance);
|
||||||
|
|
||||||
|
// 向AM注册应用实例信息进行校验
|
||||||
result = client.get(instanceArray);
|
result = client.get(instanceArray);
|
||||||
Methods::Task task;
|
Methods::Task task;
|
||||||
Methods::toJson(result, task);
|
Methods::fromJson(result, task); // fromJson TODO 数据解析异常
|
||||||
qWarning() << "[result] " << result;
|
qWarning() << "[result] " << result;
|
||||||
|
|
||||||
|
// 校验task内容
|
||||||
|
App app = parseApp(task.runId.toStdString());
|
||||||
|
if (task.id.isEmpty() || app.id.empty() || app.type.empty() || app.prefix.empty()) {
|
||||||
|
std::cout << "get task error" << std::endl;
|
||||||
|
return -4;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string path{ "/usr/share/applications/" + app.id + ".desktop" };
|
||||||
|
if (app.type == "user") {
|
||||||
|
struct passwd* user = getpwuid(getuid());
|
||||||
|
path = std::string(user->pw_dir) + "/.local/share/applications/" + app.id + ".desktop";
|
||||||
|
}
|
||||||
|
|
||||||
pthread_attr_t attr;
|
pthread_attr_t attr;
|
||||||
size_t stack_size;
|
size_t stack_size;
|
||||||
pthread_attr_init(&attr);
|
pthread_attr_init(&attr);
|
||||||
@ -237,7 +257,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
//char* stack = (char*) malloc(stack_size);
|
//char* stack = (char*) malloc(stack_size);
|
||||||
//pid_t pid = clone(child, stack + stack_size, CLONE_NEWPID | SIGCHLD, static_cast<void*>(&task));
|
//pid_t pid = clone(child, stack + stack_size, CLONE_NEWPID | SIGCHLD, static_cast<void*>(&task));
|
||||||
pid_t pid = child(&task);
|
pid_t pid = child(&task, path);
|
||||||
// TODO: 启动线程,创建新的连接去接受服务器的消息
|
// TODO: 启动线程,创建新的连接去接受服务器的消息
|
||||||
|
|
||||||
/* 设置捕捉函数 */
|
/* 设置捕捉函数 */
|
||||||
|
@ -35,30 +35,19 @@ AlRecorder::AlRecorder(DFWatcher *_watcher, QObject *parent)
|
|||||||
, watcher(_watcher)
|
, watcher(_watcher)
|
||||||
, mutex(QMutex(QMutex::NonRecursive))
|
, mutex(QMutex(QMutex::NonRecursive))
|
||||||
{
|
{
|
||||||
QDBusConnection con = QDBusConnection::sessionBus();
|
|
||||||
if (!con.registerService("org.deepin.daemon.AlRecorder1"))
|
|
||||||
{
|
|
||||||
qWarning() << "register service AlRecorder1 error:" << con.lastError().message();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!con.registerObject("/org/deepin/daemon/AlRecorder1", this, QDBusConnection::ExportAllSlots | QDBusConnection::ExportAllSignals))
|
|
||||||
{
|
|
||||||
qWarning() << "register object AlRecorder1 error:" << con.lastError().message();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
connect(watcher, &DFWatcher::Event, this, &AlRecorder::onDFChanged, Qt::QueuedConnection);
|
connect(watcher, &DFWatcher::Event, this, &AlRecorder::onDFChanged, Qt::QueuedConnection);
|
||||||
Q_EMIT ServiceRestarted();
|
Q_EMIT serviceRestarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
AlRecorder::~AlRecorder()
|
AlRecorder::~AlRecorder()
|
||||||
{
|
{
|
||||||
QDBusConnection::sessionBus().unregisterObject("/org/deepin/daemon/AlRecorder1");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取未启动应用列表
|
/**
|
||||||
QMap<QString, QStringList> AlRecorder::GetNew()
|
* @brief AlRecorder::getNew 获取未启动应用列表
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
QMap<QString, QStringList> AlRecorder::getNew()
|
||||||
{
|
{
|
||||||
QMap<QString, QStringList> ret;
|
QMap<QString, QStringList> ret;
|
||||||
QMutexLocker locker(&mutex);
|
QMutexLocker locker(&mutex);
|
||||||
@ -76,8 +65,11 @@ QMap<QString, QStringList> AlRecorder::GetNew()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 标记应用已启动状态
|
/**
|
||||||
void AlRecorder::MarkLaunched(const QString &filePath)
|
* @brief AlRecorder::markLaunched 标记应用已启动状态
|
||||||
|
* @param filePath
|
||||||
|
*/
|
||||||
|
void AlRecorder::markLaunched(const QString &filePath)
|
||||||
{
|
{
|
||||||
if (!filePath.endsWith(".desktop"))
|
if (!filePath.endsWith(".desktop"))
|
||||||
return;
|
return;
|
||||||
@ -102,12 +94,15 @@ void AlRecorder::MarkLaunched(const QString &filePath)
|
|||||||
end:
|
end:
|
||||||
if (info.isDir()) {
|
if (info.isDir()) {
|
||||||
saveStatusFile(info.absolutePath() + "/");
|
saveStatusFile(info.absolutePath() + "/");
|
||||||
Q_EMIT Launched(filePath);
|
Q_EMIT launched(filePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 记录Launcher服务卸载应用信息, 终端卸载不会调用该函数, desktopFiles为绝对路径
|
/**
|
||||||
void AlRecorder::UninstallHints(const QStringList &desktopFiles)
|
* @brief AlRecorder::uninstallHints 记录Launcher服务卸载应用信息, 终端卸载不会调用该函数, desktopFiles为绝对路径
|
||||||
|
* @param desktopFiles
|
||||||
|
*/
|
||||||
|
void AlRecorder::uninstallHints(const QStringList &desktopFiles)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&mutex);
|
QMutexLocker locker(&mutex);
|
||||||
for (auto desktop : desktopFiles) {
|
for (auto desktop : desktopFiles) {
|
||||||
@ -121,8 +116,11 @@ void AlRecorder::UninstallHints(const QStringList &desktopFiles)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 监控目录
|
/**
|
||||||
void AlRecorder::WatchDirs(const QStringList &dataDirs)
|
* @brief AlRecorder::watchDirs 监控目录
|
||||||
|
* @param dataDirs
|
||||||
|
*/
|
||||||
|
void AlRecorder::watchDirs(const QStringList &dataDirs)
|
||||||
{
|
{
|
||||||
for (auto dirPath : dataDirs) {
|
for (auto dirPath : dataDirs) {
|
||||||
if (subRecoders.contains(dirPath))
|
if (subRecoders.contains(dirPath))
|
||||||
@ -143,7 +141,10 @@ void AlRecorder::WatchDirs(const QStringList &dataDirs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化应用目录记录
|
/**
|
||||||
|
* @brief AlRecorder::initSubRecoder 初始化应用目录记录
|
||||||
|
* @param dirPath
|
||||||
|
*/
|
||||||
void AlRecorder::initSubRecoder(const QString &dirPath)
|
void AlRecorder::initSubRecoder(const QString &dirPath)
|
||||||
{
|
{
|
||||||
subRecorder sub;
|
subRecorder sub;
|
||||||
@ -191,6 +192,11 @@ void AlRecorder::initSubRecoder(const QString &dirPath)
|
|||||||
subRecoders[dirPath] = sub;
|
subRecoders[dirPath] = sub;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief AlRecorder::onDFChanged 处理desktopFile文件改变事件
|
||||||
|
* @param filePath
|
||||||
|
* @param op
|
||||||
|
*/
|
||||||
void AlRecorder::onDFChanged(const QString &filePath, uint32_t op)
|
void AlRecorder::onDFChanged(const QString &filePath, uint32_t op)
|
||||||
{
|
{
|
||||||
QFileInfo info(filePath);
|
QFileInfo info(filePath);
|
||||||
@ -232,6 +238,10 @@ void AlRecorder::onDFChanged(const QString &filePath, uint32_t op)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief AlRecorder::saveStatusFile 保存状态文件
|
||||||
|
* @param dirPath
|
||||||
|
*/
|
||||||
void AlRecorder::saveStatusFile(const QString &dirPath)
|
void AlRecorder::saveStatusFile(const QString &dirPath)
|
||||||
{
|
{
|
||||||
subRecorder sub = subRecoders[dirPath];
|
subRecorder sub = subRecoders[dirPath];
|
||||||
@ -252,6 +262,6 @@ void AlRecorder::saveStatusFile(const QString &dirPath)
|
|||||||
// 覆盖原文件
|
// 覆盖原文件
|
||||||
QFile::remove(sub.statusFile);
|
QFile::remove(sub.statusFile);
|
||||||
QFile::rename(tmpFile, sub.statusFile);
|
QFile::rename(tmpFile, sub.statusFile);
|
||||||
Q_EMIT StatusSaved(dirPath, sub.statusFile, ok);
|
Q_EMIT statusSaved(dirPath, sub.statusFile, ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,18 +46,18 @@ public:
|
|||||||
~AlRecorder();
|
~AlRecorder();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void Launched(const QString &file);
|
void launched(const QString &file);
|
||||||
void StatusSaved(const QString &root, const QString &file, bool ok);
|
void statusSaved(const QString &root, const QString &file, bool ok);
|
||||||
void ServiceRestarted();
|
void serviceRestarted();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onDFChanged(const QString &filePath, uint32_t op);
|
void onDFChanged(const QString &filePath, uint32_t op);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
QMap<QString, QStringList> GetNew();
|
QMap<QString, QStringList> getNew();
|
||||||
void MarkLaunched(const QString &filePath);
|
void markLaunched(const QString &filePath);
|
||||||
void UninstallHints(const QStringList &desktopFiles);
|
void uninstallHints(const QStringList &desktopFiles);
|
||||||
void WatchDirs(const QStringList &dataDirs);
|
void watchDirs(const QStringList &dataDirs);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initSubRecoder(const QString &dirPath);
|
void initSubRecoder(const QString &dirPath);
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "dfwatcher.h"
|
#include "dfwatcher.h"
|
||||||
#include "alrecorder.h"
|
#include "alrecorder.h"
|
||||||
#include "basedir.h"
|
#include "basedir.h"
|
||||||
|
#include "dbusalrecorderadaptor.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
@ -32,12 +33,27 @@ AppManager::AppManager(QObject *parent)
|
|||||||
, watcher(new DFWatcher(this))
|
, watcher(new DFWatcher(this))
|
||||||
, recorder(new AlRecorder(watcher, this))
|
, recorder(new AlRecorder(watcher, this))
|
||||||
{
|
{
|
||||||
|
new DBusAdaptorRecorder(recorder);
|
||||||
|
QDBusConnection con = QDBusConnection::sessionBus();
|
||||||
|
if (!con.registerService("org.deepin.daemon.AlRecorder1"))
|
||||||
|
{
|
||||||
|
qWarning() << "register service AlRecorder1 error:" << con.lastError().message();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!con.registerObject("/org/deepin/daemon/AlRecorder1", recorder))
|
||||||
|
{
|
||||||
|
qWarning() << "register object AlRecorder1 error:" << con.lastError().message();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList dataDirs;
|
QStringList dataDirs;
|
||||||
dataDirs << BaseDir::userAppDir().c_str();
|
dataDirs << BaseDir::userAppDir().c_str();
|
||||||
for (auto &dir : BaseDir::sysAppDirs())
|
for (auto &dir : BaseDir::sysAppDirs())
|
||||||
dataDirs << dir.c_str();
|
dataDirs << dir.c_str();
|
||||||
|
|
||||||
recorder->WatchDirs(dataDirs); // 监控应用desktop
|
recorder->watchDirs(dataDirs); // 监控应用desktop
|
||||||
}
|
}
|
||||||
|
|
||||||
AppManager::~AppManager()
|
AppManager::~AppManager()
|
||||||
|
48
src/modules/apps/dbusalrecorderadaptor.cpp
Normal file
48
src/modules/apps/dbusalrecorderadaptor.cpp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#include "dbusalrecorderadaptor.h"
|
||||||
|
|
||||||
|
DBusAdaptorRecorder::DBusAdaptorRecorder(QObject *parent)
|
||||||
|
: QDBusAbstractAdaptor(parent)
|
||||||
|
{
|
||||||
|
// constructor
|
||||||
|
setAutoRelaySignals(true);
|
||||||
|
if (QMetaType::type("UnlaunchedAppMap") == QMetaType::UnknownType)
|
||||||
|
registerUnLaunchedAppMapMetaType();
|
||||||
|
|
||||||
|
AlRecorder *recorder = static_cast<AlRecorder *>(QObject::parent());
|
||||||
|
if (recorder) {
|
||||||
|
connect(recorder, &AlRecorder::launched, this, &DBusAdaptorRecorder::Launched);
|
||||||
|
connect(recorder, &AlRecorder::serviceRestarted, this, &DBusAdaptorRecorder::ServiceRestarted);
|
||||||
|
connect(recorder, &AlRecorder::statusSaved, this, &DBusAdaptorRecorder::StatusSaved);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DBusAdaptorRecorder::~DBusAdaptorRecorder()
|
||||||
|
{
|
||||||
|
// destructor
|
||||||
|
}
|
||||||
|
|
||||||
|
AlRecorder *DBusAdaptorRecorder::parent() const
|
||||||
|
{
|
||||||
|
return static_cast<AlRecorder *>(QObject::parent());
|
||||||
|
}
|
||||||
|
|
||||||
|
UnLaunchedAppMap DBusAdaptorRecorder::GetNew()
|
||||||
|
{
|
||||||
|
return parent()->getNew();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DBusAdaptorRecorder::MarkLaunched(const QString &desktopFile)
|
||||||
|
{
|
||||||
|
parent()->markLaunched(desktopFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DBusAdaptorRecorder::UninstallHints(const QStringList &desktopFiles)
|
||||||
|
{
|
||||||
|
parent()->uninstallHints(desktopFiles);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DBusAdaptorRecorder::WatchDirs(const QStringList &dirs)
|
||||||
|
{
|
||||||
|
parent()->watchDirs(dirs);
|
||||||
|
}
|
||||||
|
|
67
src/modules/apps/dbusalrecorderadaptor.h
Normal file
67
src/modules/apps/dbusalrecorderadaptor.h
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
#ifndef DBUSALRECORDERADAPTOR_H
|
||||||
|
#define DBUSALRECORDERADAPTOR_H
|
||||||
|
|
||||||
|
#include "alrecorder.h"
|
||||||
|
#include "unlaunchedappmap.h"
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
#include <QtCore/QMetaObject>
|
||||||
|
#include <QtCore/QVariant>
|
||||||
|
#include <QtDBus/QtDBus>
|
||||||
|
#include <QtCore/QByteArray>
|
||||||
|
#include <QtCore/QList>
|
||||||
|
#include <QtCore/QMap>
|
||||||
|
#include <QtCore/QString>
|
||||||
|
#include <QtCore/QStringList>
|
||||||
|
#include <QtCore/QVariant>
|
||||||
|
|
||||||
|
class DBusAdaptorRecorder: public QDBusAbstractAdaptor
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_CLASSINFO("D-Bus Interface", "org.deepin.daemon.AlRecorder1")
|
||||||
|
Q_CLASSINFO("D-Bus Introspection", ""
|
||||||
|
" <interface name=\"org.deepin.daemon.AlRecorder1\">\n"
|
||||||
|
" <method name=\"GetNew\">\n"
|
||||||
|
" <arg direction=\"out\" type=\"a{sas}\" name=\"newApps\"/>\n"
|
||||||
|
" <annotation value=\"UnLaunchedAppMap\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
|
||||||
|
" </method>\n"
|
||||||
|
" <method name=\"MarkLaunched\">\n"
|
||||||
|
" <arg direction=\"in\" type=\"s\" name=\"desktopFile\"/>\n"
|
||||||
|
" </method>\n"
|
||||||
|
" <method name=\"UninstallHints\">\n"
|
||||||
|
" <arg direction=\"in\" type=\"as\" name=\"desktopFiles\"/>\n"
|
||||||
|
" </method>\n"
|
||||||
|
" <method name=\"WatchDirs\">\n"
|
||||||
|
" <arg direction=\"in\" type=\"as\" name=\"dirs\"/>\n"
|
||||||
|
" </method>\n"
|
||||||
|
" <signal name=\"Launched\">\n"
|
||||||
|
" <arg type=\"s\" name=\"file\"/>\n"
|
||||||
|
" </signal>\n"
|
||||||
|
" <signal name=\"StatusSaved\">\n"
|
||||||
|
" <arg type=\"s\" name=\"root\"/>\n"
|
||||||
|
" <arg type=\"s\" name=\"file\"/>\n"
|
||||||
|
" <arg type=\"b\" name=\"ok\"/>\n"
|
||||||
|
" </signal>\n"
|
||||||
|
" <signal name=\"ServiceRestarted\"/>\n"
|
||||||
|
" </interface>\n"
|
||||||
|
"")
|
||||||
|
|
||||||
|
AlRecorder *parent() const;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DBusAdaptorRecorder(QObject *parent);
|
||||||
|
virtual ~DBusAdaptorRecorder();
|
||||||
|
|
||||||
|
public: // PROPERTIES
|
||||||
|
public Q_SLOTS: // METHODS
|
||||||
|
UnLaunchedAppMap GetNew();
|
||||||
|
void MarkLaunched(const QString &desktopFile);
|
||||||
|
void UninstallHints(const QStringList &desktopFiles);
|
||||||
|
void WatchDirs(const QStringList &dirs);
|
||||||
|
Q_SIGNALS: // SIGNALS
|
||||||
|
void Launched(const QString &file);
|
||||||
|
void ServiceRestarted();
|
||||||
|
void StatusSaved(const QString &root, const QString &file, bool ok);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -212,6 +212,31 @@ QString DBusAdaptorDock::QueryWindowIdentifyMethod(uint win)
|
|||||||
return parent()->queryWindowIdentifyMethod(win);
|
return parent()->queryWindowIdentifyMethod(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList DBusAdaptorDock::GetDockedAppsDesktopFiles()
|
||||||
|
{
|
||||||
|
return parent()->getDockedAppsDesktopFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DBusAdaptorDock::GetPluginSettings()
|
||||||
|
{
|
||||||
|
return parent()->getPluginSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DBusAdaptorDock::SetPluginSettings(QString jsonStr)
|
||||||
|
{
|
||||||
|
parent()->setPluginSettings(jsonStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DBusAdaptorDock::MergePluginSettings(QString jsonStr)
|
||||||
|
{
|
||||||
|
parent()->mergePluginSettings(jsonStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DBusAdaptorDock::RemovePluginSettings(QString key1, QStringList key2List)
|
||||||
|
{
|
||||||
|
parent()->removePluginSettings(key1, key2List);
|
||||||
|
}
|
||||||
|
|
||||||
bool DBusAdaptorDock::RequestDock(const QString &desktopFile, int index)
|
bool DBusAdaptorDock::RequestDock(const QString &desktopFile, int index)
|
||||||
{
|
{
|
||||||
return parent()->requestDock(desktopFile, index);
|
return parent()->requestDock(desktopFile, index);
|
||||||
|
@ -44,67 +44,83 @@ class DBusAdaptorDock: public QDBusAbstractAdaptor
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_CLASSINFO("D-Bus Interface", "org.deepin.dde.daemon.Dock1")
|
Q_CLASSINFO("D-Bus Interface", "org.deepin.dde.daemon.Dock1")
|
||||||
Q_CLASSINFO("D-Bus Introspection", ""
|
Q_CLASSINFO("D-Bus Introspection", ""
|
||||||
" <interface name=\"org.deepin.dde.daemon.Dock1\">\n"
|
" <interface name=\"org.deepin.dde.daemon.Dock1\">\n"
|
||||||
" <method name=\"CloseWindow\">\n"
|
" <method name=\"CloseWindow\">\n"
|
||||||
" <arg direction=\"in\" type=\"u\" name=\"win\"/>\n"
|
" <arg direction=\"in\" type=\"u\" name=\"win\"/>\n"
|
||||||
" </method>\n"
|
" </method>\n"
|
||||||
" <method name=\"GetEntryIDs\">\n"
|
" <method name=\"GetEntryIDs\">\n"
|
||||||
" <arg direction=\"out\" type=\"as\" name=\"list\"/>\n"
|
" <arg direction=\"out\" type=\"as\" name=\"list\"/>\n"
|
||||||
" </method>\n"
|
" </method>\n"
|
||||||
" <method name=\"IsDocked\">\n"
|
" <method name=\"IsDocked\">\n"
|
||||||
" <arg direction=\"in\" type=\"s\" name=\"desktopFile\"/>\n"
|
" <arg direction=\"in\" type=\"s\" name=\"desktopFile\"/>\n"
|
||||||
" <arg direction=\"out\" type=\"b\" name=\"value\"/>\n"
|
" <arg direction=\"out\" type=\"b\" name=\"value\"/>\n"
|
||||||
" </method>\n"
|
" </method>\n"
|
||||||
" <method name=\"IsOnDock\">\n"
|
" <method name=\"IsOnDock\">\n"
|
||||||
" <arg direction=\"in\" type=\"s\" name=\"desktopFile\"/>\n"
|
" <arg direction=\"in\" type=\"s\" name=\"desktopFile\"/>\n"
|
||||||
" <arg direction=\"out\" type=\"b\" name=\"value\"/>\n"
|
" <arg direction=\"out\" type=\"b\" name=\"value\"/>\n"
|
||||||
" </method>\n"
|
" </method>\n"
|
||||||
" <method name=\"MoveEntry\">\n"
|
" <method name=\"MoveEntry\">\n"
|
||||||
" <arg direction=\"in\" type=\"i\" name=\"index\"/>\n"
|
" <arg direction=\"in\" type=\"i\" name=\"index\"/>\n"
|
||||||
" <arg direction=\"in\" type=\"i\" name=\"newIndex\"/>\n"
|
" <arg direction=\"in\" type=\"i\" name=\"newIndex\"/>\n"
|
||||||
" </method>\n"
|
" </method>\n"
|
||||||
" <method name=\"QueryWindowIdentifyMethod\">\n"
|
" <method name=\"QueryWindowIdentifyMethod\">\n"
|
||||||
" <arg direction=\"in\" type=\"u\" name=\"win\"/>\n"
|
" <arg direction=\"in\" type=\"u\" name=\"win\"/>\n"
|
||||||
" <arg direction=\"out\" type=\"s\" name=\"identifyMethod\"/>\n"
|
" <arg direction=\"out\" type=\"s\" name=\"identifyMethod\"/>\n"
|
||||||
" </method>\n"
|
" </method>\n"
|
||||||
" <method name=\"RequestDock\">\n"
|
" <method name=\"GetDockedAppsDesktopFiles\">\n"
|
||||||
" <arg direction=\"in\" type=\"s\" name=\"desktopFile\"/>\n"
|
" <arg direction=\"out\" type=\"as\" name=\"desktopFiles\"/>\n"
|
||||||
" <arg direction=\"in\" type=\"i\" name=\"index\"/>\n"
|
" </method>\n"
|
||||||
" <arg direction=\"out\" type=\"b\" name=\"ok\"/>\n"
|
" <method name=\"GetPluginSettings\">\n"
|
||||||
" </method>\n"
|
" <arg direction=\"out\" type=\"s\" name=\"jsonStr\"/>\n"
|
||||||
" <method name=\"RequestUndock\">\n"
|
" </method>\n"
|
||||||
" <arg direction=\"in\" type=\"s\" name=\"desktopFile\"/>\n"
|
" <method name=\"SetPluginSettings\">\n"
|
||||||
" <arg direction=\"out\" type=\"b\" name=\"ok\"/>\n"
|
" <arg direction=\"in\" type=\"s\" name=\"jsonStr\"/>\n"
|
||||||
" </method>\n"
|
" </method>\n"
|
||||||
" <method name=\"SetFrontendWindowRect\">\n"
|
" <method name=\"MergePluginSettings\">\n"
|
||||||
" <arg direction=\"in\" type=\"i\" name=\"x\"/>\n"
|
" <arg direction=\"in\" type=\"s\" name=\"jsonStr\"/>\n"
|
||||||
" <arg direction=\"in\" type=\"i\" name=\"y\"/>\n"
|
" </method>\n"
|
||||||
" <arg direction=\"in\" type=\"u\" name=\"width\"/>\n"
|
" <method name=\"RemovePluginSettings\">\n"
|
||||||
" <arg direction=\"in\" type=\"u\" name=\"height\"/>\n"
|
" <arg direction=\"in\" type=\"s\" name=\"key1\"/>\n"
|
||||||
" </method>\n"
|
" <arg direction=\"in\" type=\"as\" name=\"key2List\"/>\n"
|
||||||
" <signal name=\"ServiceRestarted\"/>\n"
|
" </method>\n"
|
||||||
" <signal name=\"EntryAdded\">\n"
|
" <method name=\"RequestDock\">\n"
|
||||||
" <arg type=\"o\" name=\"path\"/>\n"
|
" <arg direction=\"in\" type=\"s\" name=\"desktopFile\"/>\n"
|
||||||
" <arg type=\"i\" name=\"index\"/>\n"
|
" <arg direction=\"in\" type=\"i\" name=\"index\"/>\n"
|
||||||
" </signal>\n"
|
" <arg direction=\"out\" type=\"b\" name=\"ok\"/>\n"
|
||||||
" <signal name=\"EntryRemoved\">\n"
|
" </method>\n"
|
||||||
" <arg type=\"s\" name=\"entryId\"/>\n"
|
" <method name=\"RequestUndock\">\n"
|
||||||
" </signal>\n"
|
" <arg direction=\"in\" type=\"s\" name=\"desktopFile\"/>\n"
|
||||||
" <property access=\"readwrite\" type=\"u\" name=\"ShowTimeout\"/>\n"
|
" <arg direction=\"out\" type=\"b\" name=\"ok\"/>\n"
|
||||||
" <property access=\"readwrite\" type=\"u\" name=\"HideTimeout\"/>\n"
|
" </method>\n"
|
||||||
" <property access=\"readwrite\" type=\"u\" name=\"WindowSizeEfficient\"/>\n"
|
" <method name=\"SetFrontendWindowRect\">\n"
|
||||||
" <property access=\"readwrite\" type=\"u\" name=\"WindowSizeFashion\"/>\n"
|
" <arg direction=\"in\" type=\"i\" name=\"x\"/>\n"
|
||||||
" <property access=\"read\" type=\"iiii\" name=\"FrontendWindowRect\"/>\n"
|
" <arg direction=\"in\" type=\"i\" name=\"y\"/>\n"
|
||||||
" <property access=\"read\" type=\"d\" name=\"Opacity\"/>\n"
|
" <arg direction=\"in\" type=\"u\" name=\"width\"/>\n"
|
||||||
" <property access=\"read\" type=\"ao\" name=\"Entries\"/>\n"
|
" <arg direction=\"in\" type=\"u\" name=\"height\"/>\n"
|
||||||
" <property access=\"readwrite\" type=\"i\" name=\"HideMode\"/>\n"
|
" </method>\n"
|
||||||
" <property access=\"readwrite\" type=\"i\" name=\"DisplayMode\"/>\n"
|
" <signal name=\"ServiceRestarted\"/>\n"
|
||||||
" <property access=\"read\" type=\"i\" name=\"HideState\"/>\n"
|
" <signal name=\"EntryAdded\">\n"
|
||||||
" <property access=\"readwrite\" type=\"i\" name=\"Position\"/>\n"
|
" <arg type=\"o\" name=\"path\"/>\n"
|
||||||
" <property access=\"readwrite\" type=\"u\" name=\"IconSize\"/>\n"
|
" <arg type=\"i\" name=\"index\"/>\n"
|
||||||
" <property access=\"read\" type=\"as\" name=\"DockedApps\"/>\n"
|
" </signal>\n"
|
||||||
" </interface>\n"
|
" <signal name=\"EntryRemoved\">\n"
|
||||||
"")
|
" <arg type=\"s\" name=\"entryId\"/>\n"
|
||||||
|
" </signal>\n"
|
||||||
|
" <property access=\"readwrite\" type=\"u\" name=\"ShowTimeout\"/>\n"
|
||||||
|
" <property access=\"readwrite\" type=\"u\" name=\"HideTimeout\"/>\n"
|
||||||
|
" <property access=\"readwrite\" type=\"u\" name=\"WindowSizeEfficient\"/>\n"
|
||||||
|
" <property access=\"readwrite\" type=\"u\" name=\"WindowSizeFashion\"/>\n"
|
||||||
|
" <property access=\"read\" type=\"(iiii)\" name=\"FrontendWindowRect\"/>\n"
|
||||||
|
" <property access=\"read\" type=\"d\" name=\"Opacity\"/>\n"
|
||||||
|
" <property access=\"read\" type=\"ao\" name=\"Entries\"/>\n"
|
||||||
|
" <property access=\"readwrite\" type=\"i\" name=\"HideMode\"/>\n"
|
||||||
|
" <property access=\"readwrite\" type=\"i\" name=\"DisplayMode\"/>\n"
|
||||||
|
" <property access=\"read\" type=\"i\" name=\"HideState\"/>\n"
|
||||||
|
" <property access=\"readwrite\" type=\"i\" name=\"Position\"/>\n"
|
||||||
|
" <property access=\"readwrite\" type=\"u\" name=\"IconSize\"/>\n"
|
||||||
|
" <property access=\"read\" type=\"as\" name=\"DockedApps\"/>\n"
|
||||||
|
" </interface>\n"
|
||||||
|
"")
|
||||||
public:
|
public:
|
||||||
DBusAdaptorDock(QObject *parent);
|
DBusAdaptorDock(QObject *parent);
|
||||||
virtual ~DBusAdaptorDock();
|
virtual ~DBusAdaptorDock();
|
||||||
@ -166,6 +182,11 @@ public Q_SLOTS: // METHODS
|
|||||||
bool IsOnDock(const QString &desktopFile);
|
bool IsOnDock(const QString &desktopFile);
|
||||||
void MoveEntry(int index, int newIndex);
|
void MoveEntry(int index, int newIndex);
|
||||||
QString QueryWindowIdentifyMethod(uint win);
|
QString QueryWindowIdentifyMethod(uint win);
|
||||||
|
QStringList GetDockedAppsDesktopFiles();
|
||||||
|
QString GetPluginSettings();
|
||||||
|
void SetPluginSettings(QString jsonStr);
|
||||||
|
void MergePluginSettings(QString jsonStr);
|
||||||
|
void RemovePluginSettings(QString key1, QStringList key2List);
|
||||||
bool RequestDock(const QString &desktopFile, int index);
|
bool RequestDock(const QString &desktopFile, int index);
|
||||||
bool RequestUndock(const QString &desktopFile);
|
bool RequestUndock(const QString &desktopFile);
|
||||||
void SetFrontendWindowRect(int x, int y, uint width, uint height);
|
void SetFrontendWindowRect(int x, int y, uint width, uint height);
|
||||||
|
@ -67,13 +67,13 @@ void DBusHandler::listenWaylandWMSignals()
|
|||||||
|
|
||||||
void DBusHandler::handleLauncherItemChanged(const QString &status, LauncherItemInfo itemInfo, qlonglong categoryID)
|
void DBusHandler::handleLauncherItemChanged(const QString &status, LauncherItemInfo itemInfo, qlonglong categoryID)
|
||||||
{
|
{
|
||||||
qInfo() << "handleLauncherItemChanged status:" << status << " Name:" << itemInfo.Name << " ID:" << itemInfo.ID;
|
qInfo() << "handleLauncherItemChanged status:" << status << " Name:" << itemInfo.name << " ID:" << itemInfo.id;
|
||||||
if (status == "deleted") {
|
if (status == "deleted") {
|
||||||
dock->handleLauncherItemDeleted(itemInfo.Path);
|
dock->handleLauncherItemDeleted(itemInfo.path);
|
||||||
} else if (status == "created") {
|
} else if (status == "created") {
|
||||||
// don't need to download to dock when app reinstall
|
// don't need to download to dock when app reinstall
|
||||||
} else if (status == "updated") {
|
} else if (status == "updated") {
|
||||||
dock->handleLauncherItemUpdated(itemInfo.Path);
|
dock->handleLauncherItemUpdated(itemInfo.path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +186,10 @@ PlasmaWindow *DBusHandler::createPlasmaWindow(QString objPath)
|
|||||||
return new PlasmaWindow("com.deepin.daemon.KWayland.PlasmaWindow", objPath, session, this);
|
return new PlasmaWindow("com.deepin.daemon.KWayland.PlasmaWindow", objPath, session, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取消关联信号
|
/**
|
||||||
|
* @brief DBusHandler::removePlasmaWindowHandler 取消关联信号 TODO
|
||||||
|
* @param window
|
||||||
|
*/
|
||||||
void DBusHandler::removePlasmaWindowHandler(PlasmaWindow *window)
|
void DBusHandler::removePlasmaWindowHandler(PlasmaWindow *window)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
#include "windowinfobase.h"
|
#include "windowinfobase.h"
|
||||||
#include "dbusplasmawindow.h"
|
#include "dbusplasmawindow.h"
|
||||||
|
|
||||||
|
#include "macro.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
@ -40,6 +42,7 @@
|
|||||||
|
|
||||||
Dock::Dock(QObject *parent)
|
Dock::Dock(QObject *parent)
|
||||||
: SynModule(parent)
|
: SynModule(parent)
|
||||||
|
, entriesSum(0)
|
||||||
, windowIdentify(new WindowIdentify(this))
|
, windowIdentify(new WindowIdentify(this))
|
||||||
, entries(new Entries(this))
|
, entries(new Entries(this))
|
||||||
, ddeLauncherVisible(true)
|
, ddeLauncherVisible(true)
|
||||||
@ -91,7 +94,11 @@ Dock::~Dock()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 驻留
|
/**
|
||||||
|
* @brief Dock::dockEntry 驻留应用
|
||||||
|
* @param entry 应用实例
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
bool Dock::dockEntry(Entry *entry)
|
bool Dock::dockEntry(Entry *entry)
|
||||||
{
|
{
|
||||||
if (entry->getIsDocked())
|
if (entry->getIsDocked())
|
||||||
@ -176,7 +183,10 @@ bool Dock::dockEntry(Entry *entry)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取消驻留
|
/**
|
||||||
|
* @brief Dock::undockEntry 取消驻留
|
||||||
|
* @param entry 应用实例
|
||||||
|
*/
|
||||||
void Dock::undockEntry(Entry *entry)
|
void Dock::undockEntry(Entry *entry)
|
||||||
{
|
{
|
||||||
if (!entry->getIsDocked()) {
|
if (!entry->getIsDocked()) {
|
||||||
@ -232,12 +242,20 @@ void Dock::undockEntry(Entry *entry)
|
|||||||
saveDockedApps();
|
saveDockedApps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::allocEntryId 分配应用实例id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
QString Dock::allocEntryId()
|
QString Dock::allocEntryId()
|
||||||
{
|
{
|
||||||
int num = entriesSum++;
|
return QString("e%1T%2").arg(++entriesSum).arg(QString::number(QDateTime::currentMSecsSinceEpoch(), 16));
|
||||||
return QString::number(num);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::shouldShowOnDock 判断是否应该显示到任务栏
|
||||||
|
* @param info
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
bool Dock::shouldShowOnDock(WindowInfoBase *info)
|
bool Dock::shouldShowOnDock(WindowInfoBase *info)
|
||||||
{
|
{
|
||||||
if (info->getWindowType() == "X11") {
|
if (info->getWindowType() == "X11") {
|
||||||
@ -256,56 +274,101 @@ bool Dock::shouldShowOnDock(WindowInfoBase *info)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::setDdeLauncherVisible 记录当前启动器是否可见
|
||||||
|
* @param visible
|
||||||
|
*/
|
||||||
void Dock::setDdeLauncherVisible(bool visible)
|
void Dock::setDdeLauncherVisible(bool visible)
|
||||||
{
|
{
|
||||||
ddeLauncherVisible = visible;
|
ddeLauncherVisible = visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::getWMName 获取窗管名称
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
QString Dock::getWMName()
|
QString Dock::getWMName()
|
||||||
{
|
{
|
||||||
return wmName;
|
return wmName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::setWMName 设置窗管名称
|
||||||
|
* @param name 窗管名称
|
||||||
|
*/
|
||||||
void Dock::setWMName(QString name)
|
void Dock::setWMName(QString name)
|
||||||
{
|
{
|
||||||
wmName = name;
|
wmName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::setSynConfig 同步配置 TODO
|
||||||
|
* @param ba 配置数据
|
||||||
|
*/
|
||||||
void Dock::setSynConfig(QByteArray ba)
|
void Dock::setSynConfig(QByteArray ba)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::getSyncConfig 获取配置 TODO
|
||||||
|
* @return 配置数据
|
||||||
|
*/
|
||||||
QByteArray Dock::getSyncConfig()
|
QByteArray Dock::getSyncConfig()
|
||||||
{
|
{
|
||||||
return QByteArray();
|
return QByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::createPlasmaWindow 创建wayland下窗口
|
||||||
|
* @param objPath
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
PlasmaWindow *Dock::createPlasmaWindow(QString objPath)
|
PlasmaWindow *Dock::createPlasmaWindow(QString objPath)
|
||||||
{
|
{
|
||||||
return dbusHandler->createPlasmaWindow(objPath);
|
return dbusHandler->createPlasmaWindow(objPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::listenKWindowSignals
|
||||||
|
* @param windowInfo
|
||||||
|
*/
|
||||||
void Dock::listenKWindowSignals(WindowInfoK *windowInfo)
|
void Dock::listenKWindowSignals(WindowInfoK *windowInfo)
|
||||||
{
|
{
|
||||||
dbusHandler->listenKWindowSignals(windowInfo);
|
dbusHandler->listenKWindowSignals(windowInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::removePlasmaWindowHandler 关闭窗口后需求对应的connect
|
||||||
|
* @param window
|
||||||
|
*/
|
||||||
void Dock::removePlasmaWindowHandler(PlasmaWindow *window)
|
void Dock::removePlasmaWindowHandler(PlasmaWindow *window)
|
||||||
{
|
{
|
||||||
dbusHandler->removePlasmaWindowHandler(window);
|
dbusHandler->removePlasmaWindowHandler(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::presentWindows 显示窗口
|
||||||
|
* @param windows 窗口id
|
||||||
|
*/
|
||||||
void Dock::presentWindows(QList<uint> windows)
|
void Dock::presentWindows(QList<uint> windows)
|
||||||
{
|
{
|
||||||
dbusHandler->presentWindows(windows);
|
dbusHandler->presentWindows(windows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::getDockHideMode 获取任务栏隐藏模式 一直显示/一直隐藏/智能隐藏
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
HideMode Dock::getDockHideMode()
|
HideMode Dock::getDockHideMode()
|
||||||
{
|
{
|
||||||
return SETTING->getHideMode();
|
return SETTING->getHideMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::getActiveWindow 获取当前活跃窗口
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
WindowInfoBase *Dock::getActiveWindow()
|
WindowInfoBase *Dock::getActiveWindow()
|
||||||
{
|
{
|
||||||
WindowInfoBase *ret = nullptr;
|
WindowInfoBase *ret = nullptr;
|
||||||
@ -317,12 +380,19 @@ WindowInfoBase *Dock::getActiveWindow()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::getClientList 获取窗口client列表
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
QList<XWindow> Dock::getClientList()
|
QList<XWindow> Dock::getClientList()
|
||||||
{
|
{
|
||||||
return QList<XWindow>(clientList);
|
return QList<XWindow>(clientList);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关闭窗口
|
/**
|
||||||
|
* @brief Dock::closeWindow 关闭窗口
|
||||||
|
* @param windowId 窗口id
|
||||||
|
*/
|
||||||
void Dock::closeWindow(uint32_t windowId)
|
void Dock::closeWindow(uint32_t windowId)
|
||||||
{
|
{
|
||||||
qInfo() << "Close Window " << windowId;
|
qInfo() << "Close Window " << windowId;
|
||||||
@ -335,13 +405,22 @@ void Dock::closeWindow(uint32_t windowId)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取所有应用Id for debug
|
/**
|
||||||
|
* @brief Dock::getEntryIDs 获取所有应用Id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
QStringList Dock::getEntryIDs()
|
QStringList Dock::getEntryIDs()
|
||||||
{
|
{
|
||||||
return entries->getEntryIDs();
|
return entries->getEntryIDs();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置任务栏Rect
|
/**
|
||||||
|
* @brief Dock::setFrontendWindowRect 设置任务栏Rect
|
||||||
|
* @param x
|
||||||
|
* @param y
|
||||||
|
* @param width
|
||||||
|
* @param height
|
||||||
|
*/
|
||||||
void Dock::setFrontendWindowRect(int32_t x, int32_t y, uint width, uint height)
|
void Dock::setFrontendWindowRect(int32_t x, int32_t y, uint width, uint height)
|
||||||
{
|
{
|
||||||
if (frontendWindowRect == QRect(x, y, width, height)) {
|
if (frontendWindowRect == QRect(x, y, width, height)) {
|
||||||
@ -358,14 +437,23 @@ void Dock::setFrontendWindowRect(int32_t x, int32_t y, uint width, uint height)
|
|||||||
Q_EMIT frontendWindowRectChanged();
|
Q_EMIT frontendWindowRectChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 应用是否驻留
|
/**
|
||||||
|
* @brief Dock::isDocked 应用是否驻留
|
||||||
|
* @param desktopFile
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
bool Dock::isDocked(const QString desktopFile)
|
bool Dock::isDocked(const QString desktopFile)
|
||||||
{
|
{
|
||||||
auto entry = getDockedEntryByDesktopFile(desktopFile);
|
auto entry = getDockedEntryByDesktopFile(desktopFile);
|
||||||
return !!entry;
|
return !!entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 驻留应用
|
/**
|
||||||
|
* @brief Dock::requestDock 驻留应用
|
||||||
|
* @param desktopFile desktopFile全路径
|
||||||
|
* @param index
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
bool Dock::requestDock(QString desktopFile, int index)
|
bool Dock::requestDock(QString desktopFile, int index)
|
||||||
{
|
{
|
||||||
qInfo() << "RequestDock: " << desktopFile;
|
qInfo() << "RequestDock: " << desktopFile;
|
||||||
@ -394,6 +482,11 @@ bool Dock::requestDock(QString desktopFile, int index)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::requestUndock 取消驻留应用
|
||||||
|
* @param desktopFile desktopFile文件全路径
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
bool Dock::requestUndock(QString desktopFile)
|
bool Dock::requestUndock(QString desktopFile)
|
||||||
{
|
{
|
||||||
auto entry = getDockedEntryByDesktopFile(desktopFile);
|
auto entry = getDockedEntryByDesktopFile(desktopFile);
|
||||||
@ -404,26 +497,41 @@ bool Dock::requestUndock(QString desktopFile)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 移动驻留程序顺序
|
/**
|
||||||
|
* @brief Dock::moveEntry 移动驻留程序顺序
|
||||||
|
* @param oldIndex
|
||||||
|
* @param newIndex
|
||||||
|
*/
|
||||||
void Dock::moveEntry(int oldIndex, int newIndex)
|
void Dock::moveEntry(int oldIndex, int newIndex)
|
||||||
{
|
{
|
||||||
entries->move(oldIndex, newIndex);
|
entries->move(oldIndex, newIndex);
|
||||||
saveDockedApps();
|
saveDockedApps();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 是否在任务栏
|
/**
|
||||||
|
* @brief Dock::isOnDock 是否在任务栏
|
||||||
|
* @param desktopFile desktopFile文件全路径
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
bool Dock::isOnDock(QString desktopFile)
|
bool Dock::isOnDock(QString desktopFile)
|
||||||
{
|
{
|
||||||
return !!getDockedEntryByDesktopFile(desktopFile);
|
return !!entries->getByDesktopFilePath(desktopFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询窗口识别方式
|
/**
|
||||||
|
* @brief Dock::queryWindowIdentifyMethod 查询窗口识别方式
|
||||||
|
* @param windowId 窗口id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
QString Dock::queryWindowIdentifyMethod(XWindow windowId)
|
QString Dock::queryWindowIdentifyMethod(XWindow windowId)
|
||||||
{
|
{
|
||||||
return entries->queryWindowIdentifyMethod(windowId);
|
return entries->queryWindowIdentifyMethod(windowId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取驻留应用desktop文件
|
/**
|
||||||
|
* @brief Dock::getDockedAppsDesktopFiles 获取驻留应用desktop文件
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
QStringList Dock::getDockedAppsDesktopFiles()
|
QStringList Dock::getDockedAppsDesktopFiles()
|
||||||
{
|
{
|
||||||
QStringList ret;
|
QStringList ret;
|
||||||
@ -434,31 +542,46 @@ QStringList Dock::getDockedAppsDesktopFiles()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取任务栏插件配置
|
/**
|
||||||
|
* @brief Dock::getPluginSettings 获取任务栏插件配置
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
QString Dock::getPluginSettings()
|
QString Dock::getPluginSettings()
|
||||||
{
|
{
|
||||||
return SETTING->getPluginSettings();
|
return SETTING->getPluginSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置任务栏插件配置
|
/**
|
||||||
|
* @brief Dock::setPluginSettings 设置任务栏插件配置
|
||||||
|
* @param jsonStr
|
||||||
|
*/
|
||||||
void Dock::setPluginSettings(QString jsonStr)
|
void Dock::setPluginSettings(QString jsonStr)
|
||||||
{
|
{
|
||||||
SETTING->setPluginSettings(jsonStr);
|
SETTING->setPluginSettings(jsonStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 合并任务栏插件配置
|
/**
|
||||||
|
* @brief Dock::mergePluginSettings 合并任务栏插件配置
|
||||||
|
* @param jsonStr
|
||||||
|
*/
|
||||||
void Dock::mergePluginSettings(QString jsonStr)
|
void Dock::mergePluginSettings(QString jsonStr)
|
||||||
{
|
{
|
||||||
SETTING->mergePluginSettings(jsonStr);
|
SETTING->mergePluginSettings(jsonStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 移除任务栏插件配置
|
/**
|
||||||
|
* @brief Dock::removePluginSettings 移除任务栏插件配置
|
||||||
|
* @param pluginName
|
||||||
|
* @param settingkeys
|
||||||
|
*/
|
||||||
void Dock::removePluginSettings(QString pluginName, QStringList settingkeys)
|
void Dock::removePluginSettings(QString pluginName, QStringList settingkeys)
|
||||||
{
|
{
|
||||||
SETTING->removePluginSettings(pluginName, settingkeys);
|
SETTING->removePluginSettings(pluginName, settingkeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 智能隐藏
|
/**
|
||||||
|
* @brief Dock::smartHideModeTimerExpired 设置智能隐藏
|
||||||
|
*/
|
||||||
void Dock::smartHideModeTimerExpired()
|
void Dock::smartHideModeTimerExpired()
|
||||||
{
|
{
|
||||||
HideState state = shouldHideOnSmartHideMode() ? HideState::Hide : HideState::Show;
|
HideState state = shouldHideOnSmartHideMode() ? HideState::Hide : HideState::Show;
|
||||||
@ -466,31 +589,40 @@ void Dock::smartHideModeTimerExpired()
|
|||||||
setPropHideMode(state);
|
setPropHideMode(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::initSettings 初始化配置
|
||||||
|
*/
|
||||||
void Dock::initSettings()
|
void Dock::initSettings()
|
||||||
{
|
{
|
||||||
SETTING->init();
|
SETTING->init();
|
||||||
|
forceQuitAppStatus = SETTING->getForceQuitAppMode();
|
||||||
connect(SETTING, &DockSettings::hideModeChanged, this, [&](HideMode mode) {
|
connect(SETTING, &DockSettings::hideModeChanged, this, [&](HideMode mode) {
|
||||||
this->updateHideState(false);
|
this->updateHideState(false);
|
||||||
});
|
});
|
||||||
connect(SETTING, &DockSettings::displayModeChanged, this, [](DisplayMode mode) {
|
connect(SETTING, &DockSettings::displayModeChanged, this, [](DisplayMode mode) {
|
||||||
qInfo() << "display mode change to " << static_cast<int>(mode);
|
qInfo() << "display mode change to " << static_cast<int>(mode);
|
||||||
});
|
});
|
||||||
connect(SETTING, &DockSettings::positionModeChanged, this, [](PositonMode mode) {
|
connect(SETTING, &DockSettings::positionModeChanged, this, [](PositionMode mode) {
|
||||||
qInfo() << "position mode change to " << static_cast<int>(mode);
|
qInfo() << "position mode change to " << static_cast<int>(mode);
|
||||||
});
|
});
|
||||||
connect(SETTING, &DockSettings::forceQuitAppChanged, this, [&](bool mode) {
|
connect(SETTING, &DockSettings::forceQuitAppChanged, this, [&](ForceQuitAppMode mode) {
|
||||||
qInfo() << "forceQuitApp change to " << mode;
|
qInfo() << "forceQuitApp change to " << int(mode);
|
||||||
|
forceQuitAppStatus = mode;
|
||||||
entries->updateEntriesMenu();
|
entries->updateEntriesMenu();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新所有应用菜单
|
/**
|
||||||
|
* @brief Dock::updateMenu 更新所有应用菜单 TODO
|
||||||
|
*/
|
||||||
void Dock::updateMenu()
|
void Dock::updateMenu()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化应用
|
/**
|
||||||
|
* @brief Dock::initEntries 初始化应用
|
||||||
|
*/
|
||||||
void Dock::initEntries()
|
void Dock::initEntries()
|
||||||
{
|
{
|
||||||
initDockedApps();
|
initDockedApps();
|
||||||
@ -498,6 +630,9 @@ void Dock::initEntries()
|
|||||||
initClientList();
|
initClientList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::initDockedApps 初始化驻留应用
|
||||||
|
*/
|
||||||
void Dock::initDockedApps()
|
void Dock::initDockedApps()
|
||||||
{
|
{
|
||||||
// 初始化驻留应用信息
|
// 初始化驻留应用信息
|
||||||
@ -526,7 +661,9 @@ void Dock::initDockedApps()
|
|||||||
saveDockedApps();
|
saveDockedApps();
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "processinfo.h"
|
/**
|
||||||
|
* @brief Dock::initClientList 初始化窗口列表,关联到对应应用
|
||||||
|
*/
|
||||||
void Dock::initClientList()
|
void Dock::initClientList()
|
||||||
{
|
{
|
||||||
QList<XWindow> clients;
|
QList<XWindow> clients;
|
||||||
@ -542,40 +679,103 @@ void Dock::initClientList()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::findWindowByXidX 通过id获取窗口信息
|
||||||
|
* @param xid
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
WindowInfoX *Dock::findWindowByXidX(XWindow xid)
|
WindowInfoX *Dock::findWindowByXidX(XWindow xid)
|
||||||
{
|
{
|
||||||
return x11Manager->findWindowByXid(xid);
|
return x11Manager->findWindowByXid(xid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::findWindowByXidK 通过xid获取窗口 TODO wayland和x11下窗口尽量完全剥离, 不应该存在通过xid查询wayland窗口的情况
|
||||||
|
* @param xid
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
WindowInfoK *Dock::findWindowByXidK(XWindow xid)
|
WindowInfoK *Dock::findWindowByXidK(XWindow xid)
|
||||||
{
|
{
|
||||||
return waylandManager->findWindowByXid(xid);
|
return waylandManager->findWindowByXid(xid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::isWindowDockOverlapX 判断X环境下窗口和任务栏是否重叠 TODO
|
||||||
|
* @param xid
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
bool Dock::isWindowDockOverlapX(XWindow xid)
|
bool Dock::isWindowDockOverlapX(XWindow xid)
|
||||||
{
|
{
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断窗口和任务栏是否重叠
|
/**
|
||||||
|
* @brief Dock::isWindowDockOverlapK 判断Wayland环境下窗口和任务栏是否重叠
|
||||||
|
* @param info
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
bool Dock::isWindowDockOverlapK(WindowInfoBase *info)
|
bool Dock::isWindowDockOverlapK(WindowInfoBase *info)
|
||||||
{
|
{
|
||||||
if (!info) {
|
WindowInfoK *infoK = static_cast<WindowInfoK *>(info);
|
||||||
qInfo() << "isWindowDockOverlapK: info is nullptr";
|
if (!infoK) {
|
||||||
|
qInfo() << "isWindowDockOverlapK: infoK is nullptr";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO check
|
Rect rect = infoK->getGeometry();
|
||||||
|
bool isActiveWin = infoK->getPlasmaWindow()->IsActive();
|
||||||
|
QString appId = infoK->getAppId();
|
||||||
|
if (!isActiveWin) {
|
||||||
|
qInfo() << "isWindowDockOverlapK: check window " << appId << " is not active";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
QStringList appList = {"dde-desktop", "dde-lock", "dde-shutdown"};
|
||||||
|
if (appList.contains(appId)) {
|
||||||
|
qInfo() << "isWindowDockOverlapK: appId in white list";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hasInterSectionK(rect, frontendWindowRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::hasInterSectionK Wayland环境下判断活动窗口和任务栏区域是否重叠
|
||||||
|
* @param windowRect 活动窗口rect
|
||||||
|
* @param dockRect 任务栏窗口rect
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
bool Dock::hasInterSectionK(const Rect &windowRect, QRect dockRect)
|
||||||
|
{
|
||||||
|
int position = getPosition();
|
||||||
|
int ltX = MAX(windowRect.X, dockRect.x());
|
||||||
|
int ltY = MAX(windowRect.Y, dockRect.y());
|
||||||
|
int rbX = MIN(windowRect.X + windowRect.Width, dockRect.x() + dockRect.width());
|
||||||
|
int rbY = MIN(windowRect.Y + windowRect.Height, dockRect.y() + dockRect.height());
|
||||||
|
|
||||||
|
if (position == int(PositionMode::Left) || position == int(PositionMode::Right)) {
|
||||||
|
return ltX <= rbX && ltY < rbY;
|
||||||
|
} else if (position == int(PositionMode::TOP) || position == int(PositionMode::Bottom)) {
|
||||||
|
return ltX < rbX && ltY <= rbY;
|
||||||
|
} else {
|
||||||
|
return ltX < rbX && ltY < rbY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::getDockedEntryByDesktopFile 获取应用实例
|
||||||
|
* @param desktopFile desktopFile文件全路径
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
Entry *Dock::getDockedEntryByDesktopFile(const QString &desktopFile)
|
Entry *Dock::getDockedEntryByDesktopFile(const QString &desktopFile)
|
||||||
{
|
{
|
||||||
return entries->getDockedEntryByDesktopFile(desktopFile);
|
return entries->getDockedEntryByDesktopFile(desktopFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::shouldHideOnSmartHideMode 判断智能隐藏模式下当前任务栏是否应该隐藏
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
bool Dock::shouldHideOnSmartHideMode()
|
bool Dock::shouldHideOnSmartHideMode()
|
||||||
{
|
{
|
||||||
if (!activeWindow || ddeLauncherVisible)
|
if (!activeWindow || ddeLauncherVisible)
|
||||||
@ -602,6 +802,11 @@ bool Dock::shouldHideOnSmartHideMode()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::getActiveWinGroup
|
||||||
|
* @param xid
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
QVector<XWindow> Dock::getActiveWinGroup(XWindow xid)
|
QVector<XWindow> Dock::getActiveWinGroup(XWindow xid)
|
||||||
{
|
{
|
||||||
QVector<XWindow> ret;
|
QVector<XWindow> ret;
|
||||||
@ -665,7 +870,10 @@ QVector<XWindow> Dock::getActiveWinGroup(XWindow xid)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新任务栏隐藏状态
|
/**
|
||||||
|
* @brief Dock::updateHideState 更新任务栏隐藏状态
|
||||||
|
* @param delay
|
||||||
|
*/
|
||||||
void Dock::updateHideState(bool delay)
|
void Dock::updateHideState(bool delay)
|
||||||
{
|
{
|
||||||
if (ddeLauncherVisible) {
|
if (ddeLauncherVisible) {
|
||||||
@ -691,6 +899,10 @@ void Dock::updateHideState(bool delay)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::setPropHideMode 设置隐藏属性
|
||||||
|
* @param state
|
||||||
|
*/
|
||||||
void Dock::setPropHideMode(HideState state)
|
void Dock::setPropHideMode(HideState state)
|
||||||
{
|
{
|
||||||
if (state == HideState::Unknown) {
|
if (state == HideState::Unknown) {
|
||||||
@ -704,6 +916,10 @@ void Dock::setPropHideMode(HideState state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::attachOrDetachWindow 关联或分离窗口
|
||||||
|
* @param info
|
||||||
|
*/
|
||||||
void Dock::attachOrDetachWindow(WindowInfoBase *info)
|
void Dock::attachOrDetachWindow(WindowInfoBase *info)
|
||||||
{
|
{
|
||||||
if (!info)
|
if (!info)
|
||||||
@ -742,9 +958,13 @@ void Dock::attachOrDetachWindow(WindowInfoBase *info)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::attachWindow 关联窗口
|
||||||
|
* @param info 窗口信息
|
||||||
|
*/
|
||||||
void Dock::attachWindow(WindowInfoBase *info)
|
void Dock::attachWindow(WindowInfoBase *info)
|
||||||
{
|
{
|
||||||
Entry *entry = entries->getByInnerId(info->getEntryInnerId());
|
Entry *entry = entries->getByInnerId(info->getEntryInnerId()); // entries中存在innerid为空的entry, 导致后续新应用通过innerid获取应用一直能获取到
|
||||||
if (entry) {
|
if (entry) {
|
||||||
// entry existed
|
// entry existed
|
||||||
entry->attachWindow(info);
|
entry->attachWindow(info);
|
||||||
@ -757,6 +977,10 @@ void Dock::attachWindow(WindowInfoBase *info)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::detachWindow 分离窗口
|
||||||
|
* @param info 窗口信息
|
||||||
|
*/
|
||||||
void Dock::detachWindow(WindowInfoBase *info)
|
void Dock::detachWindow(WindowInfoBase *info)
|
||||||
{
|
{
|
||||||
auto entry = entries->getByWindowId(info->getXid());
|
auto entry = entries->getByWindowId(info->getXid());
|
||||||
@ -768,21 +992,31 @@ void Dock::detachWindow(WindowInfoBase *info)
|
|||||||
removeAppEntry(entry);
|
removeAppEntry(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dock::markAppLaunched(const QString &filePath)
|
/**
|
||||||
{
|
* @brief Dock::launchApp 启动应用
|
||||||
dbusHandler->markAppLaunched(filePath);
|
* @param timestamp 时间
|
||||||
}
|
* @param files 应用打开文件
|
||||||
|
*/
|
||||||
void Dock::launchApp(uint32_t timestamp, QStringList files)
|
void Dock::launchApp(uint32_t timestamp, QStringList files)
|
||||||
{
|
{
|
||||||
dbusHandler->launchApp(timestamp, files);
|
dbusHandler->launchApp(timestamp, files);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::launchAppAction 启动应用响应
|
||||||
|
* @param timestamp
|
||||||
|
* @param file
|
||||||
|
* @param section
|
||||||
|
*/
|
||||||
void Dock::launchAppAction(uint32_t timestamp, QString file, QString section)
|
void Dock::launchAppAction(uint32_t timestamp, QString file, QString section)
|
||||||
{
|
{
|
||||||
dbusHandler->launchAppAction(timestamp, file, section);
|
dbusHandler->launchAppAction(timestamp, file, section);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::is3DWM 当前窗口模式 2D/3D
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
bool Dock::is3DWM()
|
bool Dock::is3DWM()
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
@ -795,16 +1029,29 @@ bool Dock::is3DWM()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::isWaylandEnv 当前环境
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
bool Dock::isWaylandEnv()
|
bool Dock::isWaylandEnv()
|
||||||
{
|
{
|
||||||
return isWayland;
|
return isWayland;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::handleActiveWindowChangedK 处理活动窗口改变事件 wayland环境
|
||||||
|
* @param activeWin
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
WindowInfoK *Dock::handleActiveWindowChangedK(uint activeWin)
|
WindowInfoK *Dock::handleActiveWindowChangedK(uint activeWin)
|
||||||
{
|
{
|
||||||
return waylandManager->handleActiveWindowChangedK(activeWin);
|
return waylandManager->handleActiveWindowChangedK(activeWin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::handleActiveWindowChanged 处理活动窗口改变事件 X11环境
|
||||||
|
* @param info
|
||||||
|
*/
|
||||||
void Dock::handleActiveWindowChanged(WindowInfoBase *info)
|
void Dock::handleActiveWindowChanged(WindowInfoBase *info)
|
||||||
{
|
{
|
||||||
qInfo() << "handleActiveWindowChanged";
|
qInfo() << "handleActiveWindowChanged";
|
||||||
@ -820,9 +1067,11 @@ void Dock::handleActiveWindowChanged(WindowInfoBase *info)
|
|||||||
updateHideState(true);
|
updateHideState(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::saveDockedApps 保存驻留应用信息
|
||||||
|
*/
|
||||||
void Dock::saveDockedApps()
|
void Dock::saveDockedApps()
|
||||||
{
|
{
|
||||||
// 保存驻留应用信息
|
|
||||||
QList<QString> dockedApps;
|
QList<QString> dockedApps;
|
||||||
for (auto entry : entries->filterDockedEntries()) {
|
for (auto entry : entries->filterDockedEntries()) {
|
||||||
QString path = entry->getApp()->getFileName();
|
QString path = entry->getApp()->getFileName();
|
||||||
@ -838,6 +1087,10 @@ void Dock::saveDockedApps()
|
|||||||
SETTING->setDockedApps(dockedApps);
|
SETTING->setDockedApps(dockedApps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 移除应用实例
|
||||||
|
* @brief Dock::removeAppEntry
|
||||||
|
* @param entry
|
||||||
|
*/
|
||||||
void Dock::removeAppEntry(Entry *entry)
|
void Dock::removeAppEntry(Entry *entry)
|
||||||
{
|
{
|
||||||
if (entry) {
|
if (entry) {
|
||||||
@ -845,6 +1098,9 @@ void Dock::removeAppEntry(Entry *entry)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::handleWindowGeometryChanged 智能隐藏模式下窗口矩形变化,同步更新任务栏隐藏状态
|
||||||
|
*/
|
||||||
void Dock::handleWindowGeometryChanged()
|
void Dock::handleWindowGeometryChanged()
|
||||||
{
|
{
|
||||||
if (SETTING->getHideMode() == HideMode::SmartHide)
|
if (SETTING->getHideMode() == HideMode::SmartHide)
|
||||||
@ -853,31 +1109,59 @@ void Dock::handleWindowGeometryChanged()
|
|||||||
updateHideState(false);
|
updateHideState(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::getEntryByWindowId 根据窗口id获取应用实例
|
||||||
|
* @param windowId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
Entry *Dock::getEntryByWindowId(XWindow windowId)
|
Entry *Dock::getEntryByWindowId(XWindow windowId)
|
||||||
{
|
{
|
||||||
return entries->getByWindowId(windowId);
|
return entries->getByWindowId(windowId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::getDesktopFromWindowByBamf 通过bamf软件服务获取指定窗口的desktop文件
|
||||||
|
* @param windowId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
QString Dock::getDesktopFromWindowByBamf(XWindow windowId)
|
QString Dock::getDesktopFromWindowByBamf(XWindow windowId)
|
||||||
{
|
{
|
||||||
return dbusHandler->getDesktopFromWindowByBamf(windowId);
|
return dbusHandler->getDesktopFromWindowByBamf(windowId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::registerWindowWayland 注册wayland窗口
|
||||||
|
* @param objPath
|
||||||
|
*/
|
||||||
void Dock::registerWindowWayland(const QString &objPath)
|
void Dock::registerWindowWayland(const QString &objPath)
|
||||||
{
|
{
|
||||||
return waylandManager->registerWindow(objPath);
|
return waylandManager->registerWindow(objPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::unRegisterWindowWayland 取消注册wayland窗口
|
||||||
|
* @param objPath
|
||||||
|
*/
|
||||||
void Dock::unRegisterWindowWayland(const QString &objPath)
|
void Dock::unRegisterWindowWayland(const QString &objPath)
|
||||||
{
|
{
|
||||||
return waylandManager->unRegisterWindow(objPath);
|
return waylandManager->unRegisterWindow(objPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::identifyWindow 识别窗口
|
||||||
|
* @param winInfo
|
||||||
|
* @param innerId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
AppInfo *Dock::identifyWindow(WindowInfoBase *winInfo, QString &innerId)
|
AppInfo *Dock::identifyWindow(WindowInfoBase *winInfo, QString &innerId)
|
||||||
{
|
{
|
||||||
return windowIdentify->identifyWindow(winInfo, innerId);
|
return windowIdentify->identifyWindow(winInfo, innerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::markAppLaunched 标识应用已启动
|
||||||
|
* @param appInfo
|
||||||
|
*/
|
||||||
void Dock::markAppLaunched(AppInfo *appInfo)
|
void Dock::markAppLaunched(AppInfo *appInfo)
|
||||||
{
|
{
|
||||||
if (!appInfo || !appInfo->isValidApp())
|
if (!appInfo || !appInfo->isValidApp())
|
||||||
@ -888,21 +1172,37 @@ void Dock::markAppLaunched(AppInfo *appInfo)
|
|||||||
dbusHandler->markAppLaunched(desktopFile);
|
dbusHandler->markAppLaunched(desktopFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::deleteWindow 删除窗口 TODO 检查必要性
|
||||||
|
* @param xid
|
||||||
|
*/
|
||||||
void Dock::deleteWindow(XWindow xid)
|
void Dock::deleteWindow(XWindow xid)
|
||||||
{
|
{
|
||||||
entries->deleteWindow(xid);
|
entries->deleteWindow(xid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::getForceQuitAppStatus 获取强制关闭应用状态
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
ForceQuitAppMode Dock::getForceQuitAppStatus()
|
ForceQuitAppMode Dock::getForceQuitAppStatus()
|
||||||
{
|
{
|
||||||
return forceQuitAppStatus;
|
return forceQuitAppStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::getWinIconPreferredApps 获取推荐的应用窗口图标
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
QVector<QString> Dock::getWinIconPreferredApps()
|
QVector<QString> Dock::getWinIconPreferredApps()
|
||||||
{
|
{
|
||||||
return SETTING->getWinIconPreferredApps();
|
return SETTING->getWinIconPreferredApps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::handleLauncherItemDeleted 处理launcher item被删除信号
|
||||||
|
* @param itemPath
|
||||||
|
*/
|
||||||
void Dock::handleLauncherItemDeleted(QString itemPath)
|
void Dock::handleLauncherItemDeleted(QString itemPath)
|
||||||
{
|
{
|
||||||
for (auto entry : entries->filterDockedEntries()) {
|
for (auto entry : entries->filterDockedEntries()) {
|
||||||
@ -913,7 +1213,10 @@ void Dock::handleLauncherItemDeleted(QString itemPath)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 在收到 launcher item 更新的信号后,需要更新相关信息,包括 appInfo、innerId、名称、图标、菜单。
|
/**
|
||||||
|
* @brief Dock::handleLauncherItemUpdated 在收到 launcher item 更新的信号后,需要更新相关信息,包括 appInfo、innerId、名称、图标、菜单。
|
||||||
|
* @param itemPath
|
||||||
|
*/
|
||||||
void Dock::handleLauncherItemUpdated(QString itemPath)
|
void Dock::handleLauncherItemUpdated(QString itemPath)
|
||||||
{
|
{
|
||||||
Entry * entry = entries->getByDesktopFilePath(itemPath);
|
Entry * entry = entries->getByDesktopFilePath(itemPath);
|
||||||
@ -928,31 +1231,55 @@ void Dock::handleLauncherItemUpdated(QString itemPath)
|
|||||||
entry->forceUpdateIcon(); // 可能存在Icon图片改变,但Icon名称未改变的情况,因此强制发Icon的属性改变信号
|
entry->forceUpdateIcon(); // 可能存在Icon图片改变,但Icon名称未改变的情况,因此强制发Icon的属性改变信号
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::getOpacity 获取透明度
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
double Dock::getOpacity()
|
double Dock::getOpacity()
|
||||||
{
|
{
|
||||||
return SETTING->getOpacity();
|
return SETTING->getOpacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::getFrontendWindowRect 获取任务栏rect
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
QRect Dock::getFrontendWindowRect()
|
QRect Dock::getFrontendWindowRect()
|
||||||
{
|
{
|
||||||
return frontendWindowRect;
|
return frontendWindowRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::getDisplayMode 获取显示模式
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
int Dock::getDisplayMode()
|
int Dock::getDisplayMode()
|
||||||
{
|
{
|
||||||
return int(SETTING->getDisplayMode());
|
return int(SETTING->getDisplayMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::setDisplayMode 设置显示模式
|
||||||
|
* @param mode
|
||||||
|
*/
|
||||||
void Dock::setDisplayMode(int mode)
|
void Dock::setDisplayMode(int mode)
|
||||||
{
|
{
|
||||||
SETTING->setDisplayMode(DisplayMode(mode));
|
SETTING->setDisplayMode(DisplayMode(mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::getDockedApps 获取驻留应用
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
QStringList Dock::getDockedApps()
|
QStringList Dock::getDockedApps()
|
||||||
{
|
{
|
||||||
return SETTING->getDockedApps();
|
return SETTING->getDockedApps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::getEntryPaths 获取应用实例路径
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
QStringList Dock::getEntryPaths()
|
QStringList Dock::getEntryPaths()
|
||||||
{
|
{
|
||||||
QStringList ret;
|
QStringList ret;
|
||||||
@ -963,81 +1290,145 @@ QStringList Dock::getEntryPaths()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::getHideMode 获取隐藏模式
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
HideMode Dock::getHideMode()
|
HideMode Dock::getHideMode()
|
||||||
{
|
{
|
||||||
return SETTING->getHideMode();
|
return SETTING->getHideMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::setHideMode 设置隐藏模式
|
||||||
|
* @param mode
|
||||||
|
*/
|
||||||
void Dock::setHideMode(HideMode mode)
|
void Dock::setHideMode(HideMode mode)
|
||||||
{
|
{
|
||||||
SETTING->setHideMode(mode);
|
SETTING->setHideMode(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::getHideState 获取隐藏状态
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
Dock::HideState Dock::getHideState()
|
Dock::HideState Dock::getHideState()
|
||||||
{
|
{
|
||||||
return hideState;
|
return hideState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::setHideState 设置任务栏隐藏状态
|
||||||
|
* @param state
|
||||||
|
*/
|
||||||
void Dock::setHideState(Dock::HideState state)
|
void Dock::setHideState(Dock::HideState state)
|
||||||
{
|
{
|
||||||
hideState = state;
|
hideState = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::getHideTimeout 获取执行隐藏动作超时时间
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
uint Dock::getHideTimeout()
|
uint Dock::getHideTimeout()
|
||||||
{
|
{
|
||||||
return SETTING->getHideTimeout();
|
return SETTING->getHideTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::setHideTimeout 设置执行隐藏动作超时时间
|
||||||
|
* @param timeout
|
||||||
|
*/
|
||||||
void Dock::setHideTimeout(uint timeout)
|
void Dock::setHideTimeout(uint timeout)
|
||||||
{
|
{
|
||||||
SETTING->setHideTimeout(timeout);
|
SETTING->setHideTimeout(timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::getIconSize 获取应用图标大小
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
uint Dock::getIconSize()
|
uint Dock::getIconSize()
|
||||||
{
|
{
|
||||||
return SETTING->getIconSize();
|
return SETTING->getIconSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::setIconSize 设置应用图标大小
|
||||||
|
* @param size
|
||||||
|
*/
|
||||||
void Dock::setIconSize(uint size)
|
void Dock::setIconSize(uint size)
|
||||||
{
|
{
|
||||||
SETTING->setIconSize(size);
|
SETTING->setIconSize(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::getPosition 获取当前任务栏位置
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
int Dock::getPosition()
|
int Dock::getPosition()
|
||||||
{
|
{
|
||||||
return int(SETTING->getPositionMode());
|
return int(SETTING->getPositionMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::setPosition 设置任务栏位置
|
||||||
|
* @param position
|
||||||
|
*/
|
||||||
void Dock::setPosition(int position)
|
void Dock::setPosition(int position)
|
||||||
{
|
{
|
||||||
SETTING->setPositionMode(PositonMode(position));
|
SETTING->setPositionMode(PositionMode(position));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::getShowTimeout 获取显示超时接口
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
uint Dock::getShowTimeout()
|
uint Dock::getShowTimeout()
|
||||||
{
|
{
|
||||||
return SETTING->getShowTimeout();
|
return SETTING->getShowTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::setShowTimeout 设置显示超时
|
||||||
|
* @param timeout
|
||||||
|
*/
|
||||||
void Dock::setShowTimeout(uint timeout)
|
void Dock::setShowTimeout(uint timeout)
|
||||||
{
|
{
|
||||||
return SETTING->setShowTimeout(timeout);
|
return SETTING->setShowTimeout(timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::getWindowSizeEfficient 获取任务栏高效模式大小
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
uint Dock::getWindowSizeEfficient()
|
uint Dock::getWindowSizeEfficient()
|
||||||
{
|
{
|
||||||
return SETTING->getWindowSizeEfficient();
|
return SETTING->getWindowSizeEfficient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::setWindowSizeEfficient 设置任务栏高效模式大小
|
||||||
|
* @param size
|
||||||
|
*/
|
||||||
void Dock::setWindowSizeEfficient(uint size)
|
void Dock::setWindowSizeEfficient(uint size)
|
||||||
{
|
{
|
||||||
SETTING->setWindowSizeEfficient(size);
|
SETTING->setWindowSizeEfficient(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::getWindowSizeFashion 获取任务栏时尚模式大小
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
uint Dock::getWindowSizeFashion()
|
uint Dock::getWindowSizeFashion()
|
||||||
{
|
{
|
||||||
return SETTING->getWindowSizeFashion();
|
return SETTING->getWindowSizeFashion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dock::setWindowSizeFashion 设置任务栏时尚模式大小
|
||||||
|
* @param size
|
||||||
|
*/
|
||||||
void Dock::setWindowSizeFashion(uint size)
|
void Dock::setWindowSizeFashion(uint size)
|
||||||
{
|
{
|
||||||
SETTING->setWindowSizeFashion(size);
|
SETTING->setWindowSizeFashion(size);
|
||||||
|
@ -65,7 +65,6 @@ public:
|
|||||||
void attachOrDetachWindow(WindowInfoBase *info);
|
void attachOrDetachWindow(WindowInfoBase *info);
|
||||||
void attachWindow(WindowInfoBase *info);
|
void attachWindow(WindowInfoBase *info);
|
||||||
void detachWindow(WindowInfoBase *info);
|
void detachWindow(WindowInfoBase *info);
|
||||||
void markAppLaunched(const QString &filePath);
|
|
||||||
void launchApp(uint32_t timestamp, QStringList files);
|
void launchApp(uint32_t timestamp, QStringList files);
|
||||||
void launchAppAction(uint32_t timestamp, QString file, QString section);
|
void launchAppAction(uint32_t timestamp, QString file, QString section);
|
||||||
bool is3DWM();
|
bool is3DWM();
|
||||||
@ -164,6 +163,7 @@ private:
|
|||||||
WindowInfoK *findWindowByXidK(XWindow xid);
|
WindowInfoK *findWindowByXidK(XWindow xid);
|
||||||
bool isWindowDockOverlapX(XWindow xid);
|
bool isWindowDockOverlapX(XWindow xid);
|
||||||
bool isWindowDockOverlapK(WindowInfoBase *info);
|
bool isWindowDockOverlapK(WindowInfoBase *info);
|
||||||
|
bool hasInterSectionK(const Rect &windowRect, QRect dockRect);
|
||||||
Entry *getDockedEntryByDesktopFile(const QString &desktopFile);
|
Entry *getDockedEntryByDesktopFile(const QString &desktopFile);
|
||||||
bool shouldHideOnSmartHideMode();
|
bool shouldHideOnSmartHideMode();
|
||||||
QVector<XWindow> getActiveWinGroup(XWindow xid);
|
QVector<XWindow> getActiveWinGroup(XWindow xid);
|
||||||
|
@ -48,9 +48,10 @@ void DockSettings::init()
|
|||||||
} else if(key == keyDisplayMode) {
|
} else if(key == keyDisplayMode) {
|
||||||
Q_EMIT displayModeChanged(DisplayMode(dockSettings->value(key).toInt()));
|
Q_EMIT displayModeChanged(DisplayMode(dockSettings->value(key).toInt()));
|
||||||
} else if (key == keyPosition) {
|
} else if (key == keyPosition) {
|
||||||
Q_EMIT positionModeChanged(PositonMode(dockSettings->value(key).toInt()));
|
Q_EMIT positionModeChanged(PositionMode(dockSettings->value(key).toInt()));
|
||||||
} else if (key == keyForceQuitApp){
|
} else if (key == keyForceQuitApp){
|
||||||
Q_EMIT forceQuitAppChanged(dockSettings->value(key).toBool());
|
QString mode = dockSettings->value(key).toString();
|
||||||
|
Q_EMIT forceQuitAppChanged(ForceQuitAppModeHandler(mode).toEnum());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -92,21 +93,21 @@ void DockSettings::setDisplayMode(DisplayMode mode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PositonMode DockSettings::getPositionMode()
|
PositionMode DockSettings::getPositionMode()
|
||||||
{
|
{
|
||||||
PositonMode ret = PositonMode::Unknown;
|
PositionMode ret = PositionMode::Unknown;
|
||||||
if (dockSettings) {
|
if (dockSettings) {
|
||||||
QString mode = dockSettings->value(keyPosition).toString();
|
QString mode = dockSettings->value(keyPosition).toString();
|
||||||
PositonModeHandler handler(mode);
|
PositionModeHandler handler(mode);
|
||||||
ret = handler.toEnum();
|
ret = handler.toEnum();
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DockSettings::setPositionMode(PositonMode mode)
|
void DockSettings::setPositionMode(PositionMode mode)
|
||||||
{
|
{
|
||||||
if (dockSettings) {
|
if (dockSettings) {
|
||||||
dockSettings->setValue(keyPosition, PositonModeHandler(mode).toString());
|
dockSettings->setValue(keyPosition, PositionModeHandler(mode).toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 显示位置
|
// 显示位置
|
||||||
enum class PositonMode {
|
enum class PositionMode {
|
||||||
TOP,
|
TOP,
|
||||||
Right,
|
Right,
|
||||||
Bottom,
|
Bottom,
|
||||||
@ -122,45 +122,45 @@ enum class PositonMode {
|
|||||||
Unknown,
|
Unknown,
|
||||||
};
|
};
|
||||||
|
|
||||||
class PositonModeHandler {
|
class PositionModeHandler {
|
||||||
PositonMode modeEnum;
|
PositionMode modeEnum;
|
||||||
QString modeStr;
|
QString modeStr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PositonModeHandler(PositonMode mode) : modeEnum(mode), modeStr("") {}
|
PositionModeHandler(PositionMode mode) : modeEnum(mode), modeStr("") {}
|
||||||
PositonModeHandler(QString mode) : modeEnum(PositonMode::Unknown), modeStr(mode) {}
|
PositionModeHandler(QString mode) : modeEnum(PositionMode::Unknown), modeStr(mode) {}
|
||||||
|
|
||||||
bool equal(PositonModeHandler displayMode) {
|
bool equal(PositionModeHandler displayMode) {
|
||||||
return toString() == displayMode.toString() || toEnum() == displayMode.toEnum();
|
return toString() == displayMode.toString() || toEnum() == displayMode.toEnum();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString toString() {
|
QString toString() {
|
||||||
switch (modeEnum) {
|
switch (modeEnum) {
|
||||||
case PositonMode::TOP:
|
case PositionMode::TOP:
|
||||||
return "top";
|
return "top";
|
||||||
case PositonMode::Right:
|
case PositionMode::Right:
|
||||||
return "right";
|
return "right";
|
||||||
case PositonMode::Bottom:
|
case PositionMode::Bottom:
|
||||||
return "bottom";
|
return "bottom";
|
||||||
case PositonMode::Left:
|
case PositionMode::Left:
|
||||||
return "left";
|
return "left";
|
||||||
case PositonMode::Unknown:
|
case PositionMode::Unknown:
|
||||||
default:
|
default:
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PositonMode toEnum() {
|
PositionMode toEnum() {
|
||||||
if (modeStr == "top")
|
if (modeStr == "top")
|
||||||
return PositonMode::TOP;
|
return PositionMode::TOP;
|
||||||
else if (modeStr == "right")
|
else if (modeStr == "right")
|
||||||
return PositonMode::Right;
|
return PositionMode::Right;
|
||||||
else if (modeStr == "bottom")
|
else if (modeStr == "bottom")
|
||||||
return PositonMode::Bottom;
|
return PositionMode::Bottom;
|
||||||
else if (modeStr == "left")
|
else if (modeStr == "left")
|
||||||
return PositonMode::Left;
|
return PositionMode::Left;
|
||||||
else
|
else
|
||||||
return PositonMode::Unknown;
|
return PositionMode::Unknown;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -228,8 +228,8 @@ public:
|
|||||||
void setHideMode(HideMode mode);
|
void setHideMode(HideMode mode);
|
||||||
DisplayMode getDisplayMode();
|
DisplayMode getDisplayMode();
|
||||||
void setDisplayMode(DisplayMode mode);
|
void setDisplayMode(DisplayMode mode);
|
||||||
PositonMode getPositionMode();
|
PositionMode getPositionMode();
|
||||||
void setPositionMode(PositonMode mode);
|
void setPositionMode(PositionMode mode);
|
||||||
ForceQuitAppMode getForceQuitAppMode();
|
ForceQuitAppMode getForceQuitAppMode();
|
||||||
void setForceQuitAppMode(ForceQuitAppMode mode);
|
void setForceQuitAppMode(ForceQuitAppMode mode);
|
||||||
uint getIconSize();
|
uint getIconSize();
|
||||||
@ -261,9 +261,9 @@ Q_SIGNALS:
|
|||||||
// 显示样式改变
|
// 显示样式改变
|
||||||
void displayModeChanged(DisplayMode mode);
|
void displayModeChanged(DisplayMode mode);
|
||||||
// 显示位置改变
|
// 显示位置改变
|
||||||
void positionModeChanged(PositonMode mode);
|
void positionModeChanged(PositionMode mode);
|
||||||
// 强制退出应用开关改变
|
// 强制退出应用开关改变
|
||||||
void forceQuitAppChanged(bool forced);
|
void forceQuitAppChanged(ForceQuitAppMode mode);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -21,7 +21,9 @@
|
|||||||
|
|
||||||
#include "processinfo.h"
|
#include "processinfo.h"
|
||||||
#include "dstring.h"
|
#include "dstring.h"
|
||||||
#include "dfile.h"
|
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
ProcessInfo::ProcessInfo(int pid)
|
ProcessInfo::ProcessInfo(int pid)
|
||||||
: hasPid(true)
|
: hasPid(true)
|
||||||
@ -43,10 +45,14 @@ ProcessInfo::ProcessInfo(int pid)
|
|||||||
}
|
}
|
||||||
// args
|
// args
|
||||||
auto verifyExe = [](std::string exe, std::string cwd, std::string firstArg){
|
auto verifyExe = [](std::string exe, std::string cwd, std::string firstArg){
|
||||||
if (DFile::base(firstArg) == firstArg)
|
if (firstArg.size() == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
QFileInfo info(firstArg.c_str());
|
||||||
|
if (info.baseName() == firstArg.c_str())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!DFile::isAbs(firstArg))
|
if (!QDir::isAbsolutePath(firstArg.c_str()))
|
||||||
firstArg = cwd + firstArg;
|
firstArg = cwd + firstArg;
|
||||||
|
|
||||||
return exe == firstArg;
|
return exe == firstArg;
|
||||||
|
@ -34,7 +34,10 @@ WaylandManager::WaylandManager(Dock *_dock, QObject *parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 注册窗口
|
/**
|
||||||
|
* @brief WaylandManager::registerWindow 注册窗口
|
||||||
|
* @param objPath
|
||||||
|
*/
|
||||||
void WaylandManager::registerWindow(const QString &objPath)
|
void WaylandManager::registerWindow(const QString &objPath)
|
||||||
{
|
{
|
||||||
qInfo() << "registerWindow: " << objPath;
|
qInfo() << "registerWindow: " << objPath;
|
||||||
|
@ -176,6 +176,15 @@ void WindowInfoK::updateProcessInfo()
|
|||||||
processInfo = new ProcessInfo(pid);
|
processInfo = new ProcessInfo(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief WindowInfoK::getGeometry 获取窗口大小
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Rect WindowInfoK::getGeometry()
|
||||||
|
{
|
||||||
|
return geometry;
|
||||||
|
}
|
||||||
|
|
||||||
int64_t WindowInfoK::getCreatedTime()
|
int64_t WindowInfoK::getCreatedTime()
|
||||||
{
|
{
|
||||||
return createdTime;
|
return createdTime;
|
||||||
|
@ -64,6 +64,7 @@ public:
|
|||||||
void updateInternalId();
|
void updateInternalId();
|
||||||
void updateCloseable();
|
void updateCloseable();
|
||||||
void updateProcessInfo();
|
void updateProcessInfo();
|
||||||
|
Rect getGeometry();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool updateCalled;
|
bool updateCalled;
|
||||||
|
@ -8,6 +8,10 @@ DBusAdaptorLauncher::DBusAdaptorLauncher(QObject *parent)
|
|||||||
|
|
||||||
Launcher *launcher = static_cast<Launcher *>(QObject::parent());
|
Launcher *launcher = static_cast<Launcher *>(QObject::parent());
|
||||||
if (launcher) {
|
if (launcher) {
|
||||||
|
connect(launcher, &Launcher::itemChanged, this, &DBusAdaptorLauncher::ItemChanged);
|
||||||
|
connect(launcher, &Launcher::newAppLaunched, this, &DBusAdaptorLauncher::NewAppLaunched);
|
||||||
|
connect(launcher, &Launcher::uninstallFailed, this, &DBusAdaptorLauncher::UninstallFailed);
|
||||||
|
connect(launcher, &Launcher::uninstallSuccess, this, &DBusAdaptorLauncher::UninstallSuccess);
|
||||||
connect(launcher, &Launcher::displayModeChanged, this, &DBusAdaptorLauncher::DisplayModeChanged);
|
connect(launcher, &Launcher::displayModeChanged, this, &DBusAdaptorLauncher::DisplayModeChanged);
|
||||||
connect(launcher, &Launcher::fullScreenChanged, this, &DBusAdaptorLauncher::FullScreenChanged);
|
connect(launcher, &Launcher::fullScreenChanged, this, &DBusAdaptorLauncher::FullScreenChanged);
|
||||||
}
|
}
|
||||||
@ -40,21 +44,19 @@ bool DBusAdaptorLauncher::fullscreen() const
|
|||||||
|
|
||||||
void DBusAdaptorLauncher::setFullscreen(bool value)
|
void DBusAdaptorLauncher::setFullscreen(bool value)
|
||||||
{
|
{
|
||||||
parent()->setFullScreen(value);
|
parent()->setFullscreen(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DBusAdaptorLauncher::AddAutostart(const QString &desktopFile)
|
bool DBusAdaptorLauncher::AddAutostart(const QString &desktopFile)
|
||||||
{
|
{
|
||||||
QDBusInterface interface = QDBusInterface("com.deepin.daemon.Display", "/com/deepin/StartManager", "com.deepin.StartManager");
|
QDBusInterface interface = QDBusInterface("com.deepin.SessionManager", "/com/deepin/StartManager", "com.deepin.StartManager");
|
||||||
QDBusReply<bool> reply = interface.call("AddAutostart", desktopFile);
|
QDBusReply<bool> reply = interface.call("AddAutostart", desktopFile);
|
||||||
return reply.isValid() ? reply.value() : false;
|
return reply.isValid() ? reply.value() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
LauncherItemInfoList DBusAdaptorLauncher::GetAllItemInfos()
|
||||||
QString DBusAdaptorLauncher::GetAllItemInfos()
|
|
||||||
{
|
{
|
||||||
// return parent()->getAllItemInfos();
|
return parent()->getAllItemInfos();
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList DBusAdaptorLauncher::GetAllNewInstalledApps()
|
QStringList DBusAdaptorLauncher::GetAllNewInstalledApps()
|
||||||
@ -67,11 +69,9 @@ bool DBusAdaptorLauncher::GetDisableScaling(const QString &id)
|
|||||||
return parent()->getDisableScaling(id);
|
return parent()->getDisableScaling(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
LauncherItemInfo DBusAdaptorLauncher::GetItemInfo(const QString &id)
|
||||||
QString DBusAdaptorLauncher::GetItemInfo(const QString &id)
|
|
||||||
{
|
{
|
||||||
//return parent()->getItemInfo();
|
return parent()->getItemInfo(id);
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DBusAdaptorLauncher::GetUseProxy(const QString &id)
|
bool DBusAdaptorLauncher::GetUseProxy(const QString &id)
|
||||||
@ -85,16 +85,16 @@ bool DBusAdaptorLauncher::IsItemOnDesktop(const QString &id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DBusAdaptorLauncher::LaunchWithTimestamp(const QString &desktopFile, int time)
|
bool DBusAdaptorLauncher::LaunchWithTimestamp(const QString &desktopFile, int time)
|
||||||
{
|
{
|
||||||
|
|
||||||
QDBusInterface interface = QDBusInterface("com.deepin.daemon.Display", "/com/deepin/StartManager", "com.deepin.StartManager");
|
QDBusInterface interface = QDBusInterface("com.deepin.SessionManager", "/com/deepin/StartManager", "com.deepin.StartManager");
|
||||||
QDBusReply<bool> reply = interface.call("LaunchWithTimestamp", desktopFile, time);
|
QDBusReply<bool> reply = interface.call("LaunchWithTimestamp", desktopFile, time);
|
||||||
return reply.isValid() ? reply.value() : false;
|
return reply.isValid() ? reply.value() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DBusAdaptorLauncher::RemoveAutostart(const QString &desktopFile)
|
bool DBusAdaptorLauncher::RemoveAutostart(const QString &desktopFile)
|
||||||
{
|
{
|
||||||
QDBusInterface interface = QDBusInterface("com.deepin.daemon.Display", "/com/deepin/StartManager", "com.deepin.StartManager");
|
QDBusInterface interface = QDBusInterface("com.deepin.SessionManager", "/com/deepin/StartManager", "com.deepin.StartManager");
|
||||||
QDBusReply<bool> reply = interface.call("RemoveAutostart", desktopFile);
|
QDBusReply<bool> reply = interface.call("RemoveAutostart", desktopFile);
|
||||||
return reply.isValid() ? reply.value() : false;
|
return reply.isValid() ? reply.value() : false;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define DBUSADAPTORLAUNCHER_H
|
#define DBUSADAPTORLAUNCHER_H
|
||||||
|
|
||||||
#include "launcher.h"
|
#include "launcher.h"
|
||||||
|
#include "launcheriteminfolist.h"
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QMetaObject>
|
#include <QtCore/QMetaObject>
|
||||||
@ -22,80 +23,83 @@ class DBusAdaptorLauncher: public QDBusAbstractAdaptor
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_CLASSINFO("D-Bus Interface", "org.deepin.dde.daemon.Launcher1")
|
Q_CLASSINFO("D-Bus Interface", "org.deepin.dde.daemon.Launcher1")
|
||||||
Q_CLASSINFO("D-Bus Introspection", ""
|
Q_CLASSINFO("D-Bus Introspection", ""
|
||||||
" <interface name=\"org.deepin.dde.daemon.Launcher1\">\n"
|
" <interface name=\"org.deepin.dde.daemon.Launcher1\">\n"
|
||||||
" <method name=\"GetAllItemInfos\">\n"
|
" <method name=\"GetAllItemInfos\">\n"
|
||||||
" <arg direction=\"out\" type=\"s\" name=\"itemInfoList\"/>\n"
|
" <arg direction=\"out\" type=\"a(ssssxxas)\" name=\"itemInfoList\"/>\n"
|
||||||
" </method>\n"
|
" <annotation value=\"LauncherItemInfoList\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
|
||||||
" <method name=\"GetAllNewInstalledApps\">\n"
|
" </method>\n"
|
||||||
" <arg direction=\"out\" type=\"as\" name=\"apps\"/>\n"
|
" <method name=\"GetAllNewInstalledApps\">\n"
|
||||||
" </method>\n"
|
" <arg direction=\"out\" type=\"as\" name=\"apps\"/>\n"
|
||||||
" <method name=\"GetDisableScaling\">\n"
|
" </method>\n"
|
||||||
" <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
|
" <method name=\"GetDisableScaling\">\n"
|
||||||
" <arg direction=\"out\" type=\"b\" name=\"value\"/>\n"
|
" <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
|
||||||
" </method>\n"
|
" <arg direction=\"out\" type=\"b\" name=\"value\"/>\n"
|
||||||
" <method name=\"GetItemInfo\">\n"
|
" </method>\n"
|
||||||
" <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
|
" <method name=\"GetItemInfo\">\n"
|
||||||
" <arg direction=\"out\" type=\"s\" name=\"itemInfo\"/>\n"
|
" <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
|
||||||
" </method>\n"
|
" <arg direction=\"out\" type=\"(ssssxxas)\" name=\"itemInfo\"/>\n"
|
||||||
" <method name=\"GetUseProxy\">\n"
|
" <annotation value=\"LauncherItemInfo\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
|
||||||
" <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
|
" </method>\n"
|
||||||
" <arg direction=\"out\" type=\"b\" name=\"value\"/>\n"
|
" <method name=\"GetUseProxy\">\n"
|
||||||
" </method>\n"
|
" <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
|
||||||
" <method name=\"IsItemOnDesktop\">\n"
|
" <arg direction=\"out\" type=\"b\" name=\"value\"/>\n"
|
||||||
" <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
|
" </method>\n"
|
||||||
" <arg direction=\"out\" type=\"b\" name=\"result\"/>\n"
|
" <method name=\"IsItemOnDesktop\">\n"
|
||||||
" </method>\n"
|
" <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
|
||||||
" <method name=\"RequestRemoveFromDesktop\">\n"
|
" <arg direction=\"out\" type=\"b\" name=\"result\"/>\n"
|
||||||
" <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
|
" </method>\n"
|
||||||
" <arg direction=\"out\" type=\"b\" name=\"ok\"/>\n"
|
" <method name=\"RequestRemoveFromDesktop\">\n"
|
||||||
" </method>\n"
|
" <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
|
||||||
" <method name=\"RequestSendToDesktop\">\n"
|
" <arg direction=\"out\" type=\"b\" name=\"ok\"/>\n"
|
||||||
" <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
|
" </method>\n"
|
||||||
" <arg direction=\"out\" type=\"b\" name=\"ok\"/>\n"
|
" <method name=\"RequestSendToDesktop\">\n"
|
||||||
" </method>\n"
|
" <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
|
||||||
" <method name=\"RequestUninstall\">\n"
|
" <arg direction=\"out\" type=\"b\" name=\"ok\"/>\n"
|
||||||
" <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
|
" </method>\n"
|
||||||
" </method>\n"
|
" <method name=\"RequestUninstall\">\n"
|
||||||
" <method name=\"SetDisableScaling\">\n"
|
" <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
|
||||||
" <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
|
" </method>\n"
|
||||||
" <arg direction=\"in\" type=\"b\" name=\"value\"/>\n"
|
" <method name=\"SetDisableScaling\">\n"
|
||||||
" </method>\n"
|
" <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
|
||||||
" <method name=\"SetUseProxy\">\n"
|
" <arg direction=\"in\" type=\"b\" name=\"value\"/>\n"
|
||||||
" <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
|
" </method>\n"
|
||||||
" <arg direction=\"in\" type=\"b\" name=\"value\"/>\n"
|
" <method name=\"SetUseProxy\">\n"
|
||||||
" </method>\n"
|
" <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
|
||||||
" <method name=\"LaunchWithTimestamp\">\n"
|
" <arg direction=\"in\" type=\"b\" name=\"value\"/>\n"
|
||||||
" <arg direction=\"in\" type=\"s\" name=\"desktopFile\"/>\n"
|
" </method>\n"
|
||||||
" <arg direction=\"in\" type=\"i\" name=\"time\"/>\n"
|
" <method name=\"LaunchWithTimestamp\">\n"
|
||||||
" <arg direction=\"out\" type=\"b\" name=\"value\"/>\n"
|
" <arg direction=\"in\" type=\"s\" name=\"desktopFile\"/>\n"
|
||||||
" </method>\n"
|
" <arg direction=\"in\" type=\"i\" name=\"time\"/>\n"
|
||||||
" <method name=\"RemoveAutostart\">\n"
|
" <arg direction=\"out\" type=\"b\" name=\"value\"/>\n"
|
||||||
" <arg direction=\"in\" type=\"s\" name=\"desktopFile\"/>\n"
|
" </method>\n"
|
||||||
" <arg direction=\"out\" type=\"b\" name=\"value\"/>\n"
|
" <method name=\"RemoveAutostart\">\n"
|
||||||
" </method>\n"
|
" <arg direction=\"in\" type=\"s\" name=\"desktopFile\"/>\n"
|
||||||
" <method name=\"AddAutostart\">\n"
|
" <arg direction=\"out\" type=\"b\" name=\"value\"/>\n"
|
||||||
" <arg direction=\"in\" type=\"s\" name=\"desktopFile\"/>\n"
|
" </method>\n"
|
||||||
" <arg direction=\"out\" type=\"b\" name=\"value\"/>\n"
|
" <method name=\"AddAutostart\">\n"
|
||||||
" </method>\n"
|
" <arg direction=\"in\" type=\"s\" name=\"desktopFile\"/>\n"
|
||||||
" <signal name=\"ItemChanged\">\n"
|
" <arg direction=\"out\" type=\"b\" name=\"value\"/>\n"
|
||||||
" <arg type=\"s\" name=\"status\"/>\n"
|
" </method>\n"
|
||||||
" <arg type=\"s\" name=\"itemInfo\"/>\n"
|
" <signal name=\"ItemChanged\">\n"
|
||||||
" <arg type=\"x\" name=\"categoryID\"/>\n"
|
" <arg type=\"s\" name=\"status\"/>\n"
|
||||||
" </signal>\n"
|
" <arg type=\"(ssssxxas)\" name=\"itemInfo\"/>\n"
|
||||||
" <signal name=\"NewAppLaunched\">\n"
|
" <annotation value=\"LauncherItemInfo\" name=\"org.qtproject.QtDBus.QtTypeName.Out1\"/>\n"
|
||||||
" <arg type=\"s\" name=\"appID\"/>\n"
|
" <arg type=\"x\" name=\"categoryID\"/>\n"
|
||||||
" </signal>\n"
|
" </signal>\n"
|
||||||
" <signal name=\"UninstallSuccess\">\n"
|
" <signal name=\"NewAppLaunched\">\n"
|
||||||
" <arg type=\"s\" name=\"appID\"/>\n"
|
" <arg type=\"s\" name=\"appID\"/>\n"
|
||||||
" </signal>\n"
|
" </signal>\n"
|
||||||
" <signal name=\"UninstallFailed\">\n"
|
" <signal name=\"UninstallSuccess\">\n"
|
||||||
" <arg type=\"s\" name=\"appId\"/>\n"
|
" <arg type=\"s\" name=\"appID\"/>\n"
|
||||||
" <arg type=\"s\" name=\"errMsg\"/>\n"
|
" </signal>\n"
|
||||||
" </signal>\n"
|
" <signal name=\"UninstallFailed\">\n"
|
||||||
" <property access=\"readwrite\" type=\"b\" name=\"Fullscreen\"/>\n"
|
" <arg type=\"s\" name=\"appId\"/>\n"
|
||||||
" <property access=\"readwrite\" type=\"i\" name=\"DisplayMode\"/>\n"
|
" <arg type=\"s\" name=\"errMsg\"/>\n"
|
||||||
" </interface>\n"
|
" </signal>\n"
|
||||||
"")
|
" <property access=\"readwrite\" type=\"b\" name=\"Fullscreen\"/>\n"
|
||||||
|
" <property access=\"readwrite\" type=\"i\" name=\"DisplayMode\"/>\n"
|
||||||
|
" </interface>\n"
|
||||||
|
"")
|
||||||
public:
|
public:
|
||||||
DBusAdaptorLauncher(QObject *parent);
|
DBusAdaptorLauncher(QObject *parent);
|
||||||
virtual ~DBusAdaptorLauncher();
|
virtual ~DBusAdaptorLauncher();
|
||||||
@ -113,10 +117,10 @@ public: // PROPERTIES
|
|||||||
|
|
||||||
public Q_SLOTS: // METHODS
|
public Q_SLOTS: // METHODS
|
||||||
bool AddAutostart(const QString &desktopFile);
|
bool AddAutostart(const QString &desktopFile);
|
||||||
QString GetAllItemInfos();
|
LauncherItemInfoList GetAllItemInfos();
|
||||||
QStringList GetAllNewInstalledApps();
|
QStringList GetAllNewInstalledApps();
|
||||||
bool GetDisableScaling(const QString &id);
|
bool GetDisableScaling(const QString &id);
|
||||||
QString GetItemInfo(const QString &id);
|
LauncherItemInfo GetItemInfo(const QString &id);
|
||||||
bool GetUseProxy(const QString &id);
|
bool GetUseProxy(const QString &id);
|
||||||
bool IsItemOnDesktop(const QString &id);
|
bool IsItemOnDesktop(const QString &id);
|
||||||
bool LaunchWithTimestamp(const QString &desktopFile, int time);
|
bool LaunchWithTimestamp(const QString &desktopFile, int time);
|
||||||
@ -127,7 +131,7 @@ public Q_SLOTS: // METHODS
|
|||||||
void SetDisableScaling(const QString &id, bool value);
|
void SetDisableScaling(const QString &id, bool value);
|
||||||
void SetUseProxy(const QString &id, bool value);
|
void SetUseProxy(const QString &id, bool value);
|
||||||
Q_SIGNALS: // SIGNALS
|
Q_SIGNALS: // SIGNALS
|
||||||
void ItemChanged(const QString &status, const QString &itemInfo, qlonglong categoryID);
|
void ItemChanged(const QString &status, const LauncherItemInfo &itemInfo, qlonglong categoryID);
|
||||||
void NewAppLaunched(const QString &appID);
|
void NewAppLaunched(const QString &appID);
|
||||||
void UninstallFailed(const QString &appId, const QString &errMsg);
|
void UninstallFailed(const QString &appId, const QString &errMsg);
|
||||||
void UninstallSuccess(const QString &appID);
|
void UninstallSuccess(const QString &appID);
|
||||||
|
@ -69,11 +69,12 @@ Launcher::Launcher(QObject *parent)
|
|||||||
"Event", "", // TODO 修正事件参数
|
"Event", "", // TODO 修正事件参数
|
||||||
this, SLOT(handleFSWatcherEvents(QDBusMessage)));
|
this, SLOT(handleFSWatcherEvents(QDBusMessage)));
|
||||||
|
|
||||||
|
// 监控应用目录
|
||||||
|
watchDataDirs();
|
||||||
// 关联org.deepin.daemon.LRecorder1接口事件ServiceRestarted
|
// 关联org.deepin.daemon.LRecorder1接口事件ServiceRestarted
|
||||||
watchDataDirs(); // 监控应用目录
|
QDBusConnection::sessionBus().connect("org.deepin.daemon.AlRecorder1",
|
||||||
QDBusConnection::sessionBus().connect("org.deepin.daemon.AlRecoder1",
|
"/org/deepin/daemon/AlRecorder1",
|
||||||
"/org/deepin/daemon/AlRecoder1",
|
"org.deepin.daemon.AlRecorder1",
|
||||||
"org.deepin.daemon.AlRecoder1",
|
|
||||||
"ServiceRestarted",
|
"ServiceRestarted",
|
||||||
this, SLOT(handleLRecoderRestart(QDBusMessage)));
|
this, SLOT(handleLRecoderRestart(QDBusMessage)));
|
||||||
|
|
||||||
@ -87,15 +88,15 @@ Launcher::Launcher(QObject *parent)
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 关联org.deepin.daemon.LRecorder1接口事件Launched
|
// 关联org.deepin.daemon.LRecorder1接口事件Launched
|
||||||
QDBusConnection::sessionBus().connect("org.deepin.daemon.AlRecoder1",
|
QDBusConnection::sessionBus().connect("org.deepin.daemon.AlRecorder1",
|
||||||
"/org/deepin/daemon/AlRecoder1",
|
"/org/deepin/daemon/AlRecorder1",
|
||||||
"org.deepin.daemon.AlRecoder1",
|
"org.deepin.daemon.AlRecorder1",
|
||||||
"Launched", "sa",
|
"Launched", "sa",
|
||||||
this, SLOT([&](QDBusMessage msg) {
|
this, SLOT([&](QDBusMessage msg) {
|
||||||
QString path = msg.arguments().at(0).toString();
|
QString path = msg.arguments().at(0).toString();
|
||||||
Item item = getItemByPath(path);
|
Item item = getItemByPath(path);
|
||||||
if (item.isValid())
|
if (item.isValid())
|
||||||
Q_EMIT NewAppLaunched(item.id);
|
Q_EMIT newAppLaunched(item.id);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,27 +146,33 @@ void Launcher::setDisplayMode(int value)
|
|||||||
SETTING->setDisplayMode(value == 1 ? "category" : "free");
|
SETTING->setDisplayMode(value == 1 ? "category" : "free");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Launcher::setFullScreen(bool isFull)
|
void Launcher::setFullscreen(bool isFull)
|
||||||
{
|
{
|
||||||
SETTING->setFullscreenMode(isFull);
|
SETTING->setFullscreenMode(isFull);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取所有应用信息
|
/**
|
||||||
QVector<ItemInfo> Launcher::getAllItemInfos()
|
* @brief Launcher::getAllItemInfos 获取所有应用信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
LauncherItemInfoList Launcher::getAllItemInfos()
|
||||||
{
|
{
|
||||||
QVector<ItemInfo> ret;
|
LauncherItemInfoList ret;
|
||||||
for (auto item : itemsMap) {
|
for (auto item : itemsMap) {
|
||||||
ret.push_back(item.info);
|
ret.push_back(item.info);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取未打开的应用
|
/**
|
||||||
|
* @brief Launcher::getAllNewInstalledApps 获取所有新安装且未打开的应用
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
QStringList Launcher::getAllNewInstalledApps()
|
QStringList Launcher::getAllNewInstalledApps()
|
||||||
{
|
{
|
||||||
QStringList ret;
|
QStringList ret;
|
||||||
QMap<QString, QStringList> newApps;
|
QMap<QString, QStringList> newApps;
|
||||||
QDBusInterface interface = QDBusInterface("org.deepin.daemon.AlRecoder1", "/org/deepin/daemon/AlRecoder1", "org.deepin.daemon.AlRecoder1");
|
QDBusInterface interface = QDBusInterface("org.deepin.daemon.AlRecorder1", "/org/deepin/daemon/AlRecorder1", "org.deepin.daemon.AlRecorder1");
|
||||||
QDBusReply<QMap<QString, QStringList>> reply = interface.call("GetNew");
|
QDBusReply<QMap<QString, QStringList>> reply = interface.call("GetNew");
|
||||||
if (reply.isValid())
|
if (reply.isValid())
|
||||||
newApps = reply;
|
newApps = reply;
|
||||||
@ -178,7 +185,11 @@ QVector<ItemInfo> Launcher::getAllItemInfos()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取应用是否缩放
|
/**
|
||||||
|
* @brief Launcher::getDisableScaling 获取应用是否禁用缩放
|
||||||
|
* @param appId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
bool Launcher::getDisableScaling(QString appId)
|
bool Launcher::getDisableScaling(QString appId)
|
||||||
{
|
{
|
||||||
if (itemsMap.find(appId) == itemsMap.end())
|
if (itemsMap.find(appId) == itemsMap.end())
|
||||||
@ -191,10 +202,14 @@ bool Launcher::getDisableScaling(QString appId)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取应用信息
|
/**
|
||||||
ItemInfo Launcher::getItemInfo(QString appId)
|
* @brief Launcher::getItemInfo 获取应用信息
|
||||||
|
* @param appId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
LauncherItemInfo Launcher::getItemInfo(QString appId)
|
||||||
{
|
{
|
||||||
ItemInfo info;
|
LauncherItemInfo info;
|
||||||
if (itemsMap.find(appId) == itemsMap.end())
|
if (itemsMap.find(appId) == itemsMap.end())
|
||||||
return info;
|
return info;
|
||||||
|
|
||||||
@ -202,7 +217,11 @@ ItemInfo Launcher::getItemInfo(QString appId)
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取应用是否代理
|
/**
|
||||||
|
* @brief Launcher::getUseProxy 获取应用是否代理
|
||||||
|
* @param appId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
bool Launcher::getUseProxy(QString appId)
|
bool Launcher::getUseProxy(QString appId)
|
||||||
{
|
{
|
||||||
if (itemsMap.find(appId) == itemsMap.end())
|
if (itemsMap.find(appId) == itemsMap.end())
|
||||||
@ -215,7 +234,11 @@ bool Launcher::getUseProxy(QString appId)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 桌面是否存在应用desktop文件
|
/**
|
||||||
|
* @brief Launcher::isItemOnDesktop 桌面是否存在应用desktop文件
|
||||||
|
* @param appId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
bool Launcher::isItemOnDesktop(QString appId)
|
bool Launcher::isItemOnDesktop(QString appId)
|
||||||
{
|
{
|
||||||
if (itemsMap.find(appId) == itemsMap.end())
|
if (itemsMap.find(appId) == itemsMap.end())
|
||||||
@ -226,7 +249,11 @@ bool Launcher::isItemOnDesktop(QString appId)
|
|||||||
return info.exists();
|
return info.exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 移除桌面快捷方式
|
/**
|
||||||
|
* @brief Launcher::requestRemoveFromDesktop 移除桌面快捷方式
|
||||||
|
* @param appId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
bool Launcher::requestRemoveFromDesktop(QString appId)
|
bool Launcher::requestRemoveFromDesktop(QString appId)
|
||||||
{
|
{
|
||||||
if (itemsMap.find(appId) == itemsMap.end())
|
if (itemsMap.find(appId) == itemsMap.end())
|
||||||
@ -241,7 +268,11 @@ bool Launcher::requestRemoveFromDesktop(QString appId)
|
|||||||
return file.remove();
|
return file.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送应用到桌面
|
/**
|
||||||
|
* @brief Launcher::requestSendToDesktop 发送应用到桌面
|
||||||
|
* @param appId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
bool Launcher::requestSendToDesktop(QString appId)
|
bool Launcher::requestSendToDesktop(QString appId)
|
||||||
{
|
{
|
||||||
if (itemsMap.find(appId) == itemsMap.end())
|
if (itemsMap.find(appId) == itemsMap.end())
|
||||||
@ -268,7 +299,10 @@ bool Launcher::requestSendToDesktop(QString appId)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 卸载应用
|
/**
|
||||||
|
* @brief Launcher::requestUninstall 卸载应用
|
||||||
|
* @param appId
|
||||||
|
*/
|
||||||
void Launcher::requestUninstall(QString appId)
|
void Launcher::requestUninstall(QString appId)
|
||||||
{
|
{
|
||||||
if (itemsMap.find(appId) == itemsMap.end())
|
if (itemsMap.find(appId) == itemsMap.end())
|
||||||
@ -283,7 +317,7 @@ void Launcher::requestUninstall(QString appId)
|
|||||||
QString result = QString::fromUtf8(process.readAllStandardOutput());
|
QString result = QString::fromUtf8(process.readAllStandardOutput());
|
||||||
qInfo() << "RequestUninstall fucntion called by :" << result;
|
qInfo() << "RequestUninstall fucntion called by :" << result;
|
||||||
process.close();
|
process.close();
|
||||||
if (result == launcherExe) {
|
if (result != launcherExe) {
|
||||||
qWarning() << result << " has no right to uninstall " << appId;
|
qWarning() << result << " has no right to uninstall " << appId;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -296,13 +330,13 @@ void Launcher::requestUninstall(QString appId)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// 即将卸载appId
|
// 即将卸载appId
|
||||||
QDBusInterface interface = QDBusInterface("org.deepin.daemon.AlRecoder1", "/org/deepin/daemon/AlRecoder1", "org.deepin.daemon.AlRecoder1");
|
QDBusInterface interface = QDBusInterface("org.deepin.daemon.AlRecorder1", "/org/deepin/daemon/AlRecorder1", "org.deepin.daemon.AlRecorder1");
|
||||||
interface.call("UninstallHints", item.info.path);
|
interface.call("UninstallHints", QStringList() << item.info.path);
|
||||||
|
|
||||||
bool ret = doUninstall(info, item); // 阻塞等待
|
bool ret = doUninstall(info, item); // 阻塞等待
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
QString msg = QString("uninstall %1 result %2").arg(info.getName().c_str()).arg(ret);
|
QString msg = QString("uninstall %1 result %2").arg(info.getName().c_str()).arg(ret);
|
||||||
Q_EMIT UninstallFailed(appId, msg);
|
Q_EMIT uninstallFailed(appId, msg);
|
||||||
qInfo() << msg;
|
qInfo() << msg;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -311,12 +345,16 @@ void Launcher::requestUninstall(QString appId)
|
|||||||
QString filePath(QDir::homePath() + "/.config/autostart/" + appId + ".desktop");
|
QString filePath(QDir::homePath() + "/.config/autostart/" + appId + ".desktop");
|
||||||
QFile file(filePath);
|
QFile file(filePath);
|
||||||
file.remove();
|
file.remove();
|
||||||
Q_EMIT UninstallSuccess(appId);
|
Q_EMIT uninstallSuccess(appId);
|
||||||
}, appId);
|
}, appId);
|
||||||
thread.detach();
|
thread.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置应用禁用缩放
|
/**
|
||||||
|
* @brief Launcher::setDisableScaling 设置应用是否禁用缩放
|
||||||
|
* @param appId
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
void Launcher::setDisableScaling(QString appId, bool value)
|
void Launcher::setDisableScaling(QString appId, bool value)
|
||||||
{
|
{
|
||||||
if (itemsMap.find(appId) == itemsMap.end())
|
if (itemsMap.find(appId) == itemsMap.end())
|
||||||
@ -346,7 +384,11 @@ void Launcher::setDisableScaling(QString appId, bool value)
|
|||||||
SETTING->setDisableScalingApps(apps);
|
SETTING->setDisableScalingApps(apps);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置用户代理
|
/**
|
||||||
|
* @brief Launcher::setUseProxy 设置用户代理
|
||||||
|
* @param appId
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
void Launcher::setUseProxy(QString appId, bool value)
|
void Launcher::setUseProxy(QString appId, bool value)
|
||||||
{
|
{
|
||||||
if (itemsMap.find(appId) == itemsMap.end())
|
if (itemsMap.find(appId) == itemsMap.end())
|
||||||
@ -376,6 +418,10 @@ void Launcher::setUseProxy(QString appId, bool value)
|
|||||||
SETTING->setUseProxy(apps);
|
SETTING->setUseProxy(apps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Launcher::handleFSWatcherEvents 处理文件改变事件
|
||||||
|
* @param msg
|
||||||
|
*/
|
||||||
void Launcher::handleFSWatcherEvents(QDBusMessage msg)
|
void Launcher::handleFSWatcherEvents(QDBusMessage msg)
|
||||||
{
|
{
|
||||||
QList<QVariant> ret = msg.arguments();
|
QList<QVariant> ret = msg.arguments();
|
||||||
@ -398,8 +444,8 @@ void Launcher::handleFSWatcherEvents(QDBusMessage msg)
|
|||||||
|
|
||||||
Item &item = itemsMap[id];
|
Item &item = itemsMap[id];
|
||||||
Categorytype ty = queryCategoryId(&item);
|
Categorytype ty = queryCategoryId(&item);
|
||||||
if (ty != item.info.categoryId) {
|
if (qint64(ty) != item.info.categoryId) {
|
||||||
item.info.categoryId = ty;
|
item.info.categoryId = qint64(ty);
|
||||||
emitItemChanged(&item, appStatusModified);
|
emitItemChanged(&item, appStatusModified);
|
||||||
}
|
}
|
||||||
noPkgItemIds.remove(id);
|
noPkgItemIds.remove(id);
|
||||||
@ -417,6 +463,9 @@ void Launcher:: handleLRecoderRestart(QDBusMessage msg)
|
|||||||
watchDataDirs();
|
watchDataDirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Launcher::initSettings 初始化启动器配置
|
||||||
|
*/
|
||||||
void Launcher::initSettings()
|
void Launcher::initSettings()
|
||||||
{
|
{
|
||||||
connect(SETTING, &LauncherSettings::displayModeChanged, this, [&](QString mode) {
|
connect(SETTING, &LauncherSettings::displayModeChanged, this, [&](QString mode) {
|
||||||
@ -428,7 +477,9 @@ void Launcher::initSettings()
|
|||||||
appsHidden = SETTING->getHiddenApps();
|
appsHidden = SETTING->getHiddenApps();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载应用包信息
|
/**
|
||||||
|
* @brief Launcher::loadDesktopPkgMap 加载应用包信息
|
||||||
|
*/
|
||||||
void Launcher::loadDesktopPkgMap()
|
void Launcher::loadDesktopPkgMap()
|
||||||
{
|
{
|
||||||
QFile file(desktopPkgMapFile);
|
QFile file(desktopPkgMapFile);
|
||||||
@ -455,7 +506,9 @@ void Launcher::loadDesktopPkgMap()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载应用类型信息
|
/**
|
||||||
|
* @brief Launcher::loadPkgCategoryMap 加载应用类型信息
|
||||||
|
*/
|
||||||
void Launcher::loadPkgCategoryMap()
|
void Launcher::loadPkgCategoryMap()
|
||||||
{
|
{
|
||||||
QFile file(applicationsFile);
|
QFile file(applicationsFile);
|
||||||
@ -523,7 +576,9 @@ void Launcher::checkDesktopFile(QString filePath)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 响应DConfig中隐藏应用配置变化
|
/**
|
||||||
|
* @brief Launcher::handleAppHiddenChanged 响应DConfig中隐藏应用配置变化
|
||||||
|
*/
|
||||||
void Launcher::handleAppHiddenChanged()
|
void Launcher::handleAppHiddenChanged()
|
||||||
{
|
{
|
||||||
auto hiddenApps = SETTING->getHiddenApps();
|
auto hiddenApps = SETTING->getHiddenApps();
|
||||||
@ -569,7 +624,9 @@ void Launcher::handleAppHiddenChanged()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载翻译应用信息
|
/**
|
||||||
|
* @brief Launcher::loadNameMap 加载翻译应用信息
|
||||||
|
*/
|
||||||
void Launcher::loadNameMap()
|
void Launcher::loadNameMap()
|
||||||
{
|
{
|
||||||
QFile file(appNameTranslationsFile);
|
QFile file(appNameTranslationsFile);
|
||||||
@ -607,7 +664,9 @@ void Launcher::loadNameMap()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化应用信息
|
/**
|
||||||
|
* @brief Launcher::initItems 初始化应用信息
|
||||||
|
*/
|
||||||
void Launcher::initItems()
|
void Launcher::initItems()
|
||||||
{
|
{
|
||||||
std::vector<DesktopInfo> infos = AppsDir::getAllDesktopInfos();
|
std::vector<DesktopInfo> infos = AppsDir::getAllDesktopInfos();
|
||||||
@ -638,7 +697,7 @@ void Launcher::addItem(Item item)
|
|||||||
item.info.name = name;
|
item.info.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
item.info.categoryId = queryCategoryId(&item);
|
item.info.categoryId = qint64(queryCategoryId(&item));
|
||||||
itemsMap[item.info.id] = item;
|
itemsMap[item.info.id] = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -660,7 +719,11 @@ Categorytype Launcher::queryCategoryId(const Item *item)
|
|||||||
return getXCategory(item);
|
return getXCategory(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取应用类型
|
/**
|
||||||
|
* @brief Launcher::getXCategory 获取应用类型
|
||||||
|
* @param item
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
Categorytype Launcher::getXCategory(const Item *item)
|
Categorytype Launcher::getXCategory(const Item *item)
|
||||||
{
|
{
|
||||||
// 统计应用类型
|
// 统计应用类型
|
||||||
@ -720,7 +783,11 @@ Categorytype Launcher::getXCategory(const Item *item)
|
|||||||
return maxCatogories[0];
|
return maxCatogories[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 使用dpkg -S,通过文件路径查包
|
/**
|
||||||
|
* @brief Launcher::queryPkgNameWithDpkg 使用dpkg -S,通过文件路径查包
|
||||||
|
* @param itemPath
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
QString Launcher::queryPkgNameWithDpkg(const QString &itemPath)
|
QString Launcher::queryPkgNameWithDpkg(const QString &itemPath)
|
||||||
{
|
{
|
||||||
QProcess process;
|
QProcess process;
|
||||||
@ -741,7 +808,12 @@ QString Launcher::queryPkgNameWithDpkg(const QString &itemPath)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 通过id、path查询包名
|
/**
|
||||||
|
* @brief Launcher::queryPkgName 通过id、path查询包名
|
||||||
|
* @param itemID
|
||||||
|
* @param itemPath
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
QString Launcher::queryPkgName(const QString &itemID, const QString &itemPath)
|
QString Launcher::queryPkgName(const QString &itemID, const QString &itemPath)
|
||||||
{
|
{
|
||||||
if (!itemPath.isEmpty()) {
|
if (!itemPath.isEmpty()) {
|
||||||
@ -789,7 +861,11 @@ QString Launcher::queryPkgName(const QString &itemID, const QString &itemPath)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据desktop路径获取Item信息
|
/**
|
||||||
|
* @brief Launcher::getItemByPath 根据desktop路径获取Item信息
|
||||||
|
* @param itemPath
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
Item Launcher::getItemByPath(QString itemPath)
|
Item Launcher::getItemByPath(QString itemPath)
|
||||||
{
|
{
|
||||||
QString appId = getAppIdByFilePath(itemPath, appDirs);
|
QString appId = getAppIdByFilePath(itemPath, appDirs);
|
||||||
@ -802,20 +878,22 @@ Item Launcher::getItemByPath(QString itemPath)
|
|||||||
return Item();
|
return Item();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 监控应用数据目录
|
/**
|
||||||
|
* @brief Launcher::watchDataDirs 监控应用数据目录
|
||||||
|
*/
|
||||||
void Launcher::watchDataDirs()
|
void Launcher::watchDataDirs()
|
||||||
{
|
{
|
||||||
QStringList dataDirs;
|
QStringList dataDirs;
|
||||||
dataDirs << QDir::homePath() + ".local/share";
|
dataDirs << QDir::homePath() + ".local/share";
|
||||||
dataDirs << "/usr/local/share" << "/usr/share";
|
dataDirs << "/usr/local/share" << "/usr/share";
|
||||||
QDBusInterface interface = QDBusInterface("org.deepin.daemon.AlRecoder1", "/org/deepin/daemon/AlRecoder1", "org.deepin.daemon.AlRecoder1");
|
QDBusInterface interface = QDBusInterface("org.deepin.daemon.AlRecorder1", "/org/deepin/daemon/AlRecorder1", "org.deepin.daemon.AlRecorder1");
|
||||||
interface.call("WatchDirs", dataDirs);
|
interface.call("WatchDirs", dataDirs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Launcher::emitItemChanged(const Item *item, QString status)
|
void Launcher::emitItemChanged(const Item *item, QString status)
|
||||||
{
|
{
|
||||||
ItemInfo info(item->info);
|
LauncherItemInfo info(item->info);
|
||||||
Q_EMIT ItemChanged(status, info, info.categoryId);
|
Q_EMIT itemChanged(status, info, info.categoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
AppType Launcher::getAppType(DesktopInfo &info, const Item &item)
|
AppType Launcher::getAppType(DesktopInfo &info, const Item &item)
|
||||||
@ -875,6 +953,12 @@ end:
|
|||||||
return ty;
|
return ty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Launcher::doUninstall 执行卸载操作
|
||||||
|
* @param info
|
||||||
|
* @param item
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
bool Launcher::doUninstall(DesktopInfo &info, const Item &item)
|
bool Launcher::doUninstall(DesktopInfo &info, const Item &item)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
@ -916,7 +1000,12 @@ bool Launcher::doUninstall(DesktopInfo &info, const Item &item)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 卸载flatpak应用
|
/**
|
||||||
|
* @brief Launcher::uninstallFlatpak 卸载flatpak应用
|
||||||
|
* @param info
|
||||||
|
* @param item
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
bool Launcher::uninstallFlatpak(DesktopInfo &info, const Item &item)
|
bool Launcher::uninstallFlatpak(DesktopInfo &info, const Item &item)
|
||||||
{
|
{
|
||||||
struct FlatpakApp {
|
struct FlatpakApp {
|
||||||
@ -971,7 +1060,11 @@ bool Launcher::uninstallFlatpak(DesktopInfo &info, const Item &item)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 卸载wine应用
|
/**
|
||||||
|
* @brief Launcher::uninstallWineApp 卸载wine应用
|
||||||
|
* @param item
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
bool Launcher::uninstallWineApp(const Item &item)
|
bool Launcher::uninstallWineApp(const Item &item)
|
||||||
{
|
{
|
||||||
QProcess process;
|
QProcess process;
|
||||||
@ -983,19 +1076,27 @@ bool Launcher::uninstallWineApp(const Item &item)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 卸载
|
/**
|
||||||
|
* @brief Launcher::uninstallSysApp 卸载系统App
|
||||||
|
* @param name
|
||||||
|
* @param pkg
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
bool Launcher::uninstallSysApp(const QString &name, const QString &pkg)
|
bool Launcher::uninstallSysApp(const QString &name, const QString &pkg)
|
||||||
{
|
{
|
||||||
QDBusInterface lastoreDbus = QDBusInterface("com.deepin.lastore", "/com/deepin/lastore", "com.deepin.lastore.Manager", QDBusConnection::systemBus());
|
QDBusInterface lastoreDbus = QDBusInterface("com.deepin.lastore", "/com/deepin/lastore", "com.deepin.lastore.Manager", QDBusConnection::systemBus());
|
||||||
QDBusReply<QString> reply = lastoreDbus.call("RemovePackage", name, pkg); // TODO replay为空?
|
QDBusReply<QDBusObjectPath> reply = lastoreDbus.call("RemovePackage", name, pkg);
|
||||||
QString jobPath = reply.isValid() ? reply.value() : "";
|
QDBusObjectPath jobPath;
|
||||||
if (jobPath.isEmpty())
|
if (reply.isValid())
|
||||||
|
reply.value();
|
||||||
|
|
||||||
|
if (jobPath.path().isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QEventLoop loop;
|
QEventLoop loop;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
QDBusConnection::sessionBus().connect("com.deepin.lastore",
|
QDBusConnection::sessionBus().connect("com.deepin.lastore",
|
||||||
jobPath,
|
jobPath.path(),
|
||||||
"com.deepin.lastore.Job",
|
"com.deepin.lastore.Job",
|
||||||
"Status",
|
"Status",
|
||||||
"sa",
|
"sa",
|
||||||
@ -1015,7 +1116,11 @@ bool Launcher::uninstallSysApp(const QString &name, const QString &pkg)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 移除desktop文件
|
/**
|
||||||
|
* @brief Launcher::removeDesktop 移除desktop文件
|
||||||
|
* @param item
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
bool Launcher::removeDesktop(const Item &item)
|
bool Launcher::removeDesktop(const Item &item)
|
||||||
{
|
{
|
||||||
// 移除desktop文件
|
// 移除desktop文件
|
||||||
@ -1029,7 +1134,11 @@ bool Launcher::removeDesktop(const Item &item)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送卸载结果
|
/**
|
||||||
|
* @brief Launcher::notifyUninstallDone 发送卸载结果
|
||||||
|
* @param item
|
||||||
|
* @param result
|
||||||
|
*/
|
||||||
void Launcher::notifyUninstallDone(const Item &item, bool result)
|
void Launcher::notifyUninstallDone(const Item &item, bool result)
|
||||||
{
|
{
|
||||||
QString msg;
|
QString msg;
|
||||||
@ -1042,7 +1151,11 @@ void Launcher::notifyUninstallDone(const Item &item, bool result)
|
|||||||
interface.call("Notify", "deepin-app-store", 0, "deepin-appstore", msg, "", QVariant(), QVariant(), -1);
|
interface.call("Notify", "deepin-app-store", 0, "deepin-appstore", msg, "", QVariant(), QVariant(), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// deepin custom app
|
/**
|
||||||
|
* @brief Launcher::isDeepinCustomDesktopFile 检测是否为Deepin定制应用
|
||||||
|
* @param fileName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
bool Launcher::isDeepinCustomDesktopFile(QString fileName)
|
bool Launcher::isDeepinCustomDesktopFile(QString fileName)
|
||||||
{
|
{
|
||||||
QFileInfo fileInfo(fileName);
|
QFileInfo fileInfo(fileName);
|
||||||
@ -1074,7 +1187,7 @@ Item Launcher:: NewItemWithDesktopInfo(DesktopInfo &info)
|
|||||||
Item item;
|
Item item;
|
||||||
item.info.path = appFileName;
|
item.info.path = appFileName;
|
||||||
item.info.name = appName;
|
item.info.name = appName;
|
||||||
item.info.enName = enName;
|
//item.info.keywords << enName << appName;
|
||||||
item.info.id = getAppIdByFilePath(item.info.path, appDirs);
|
item.info.id = getAppIdByFilePath(item.info.path, appDirs);
|
||||||
item.info.timeInstalled = ctime;
|
item.info.timeInstalled = ctime;
|
||||||
item.exec = info.getCommandLine().c_str();
|
item.exec = info.getCommandLine().c_str();
|
||||||
@ -1083,7 +1196,7 @@ Item Launcher:: NewItemWithDesktopInfo(DesktopInfo &info)
|
|||||||
xDeepinCategory = xDeepinCategory.toLower();
|
xDeepinCategory = xDeepinCategory.toLower();
|
||||||
|
|
||||||
for (auto &keyWord : info.getKeywords()) {
|
for (auto &keyWord : info.getKeywords()) {
|
||||||
item.keywords.push_back(QString(keyWord.c_str()).toLower());
|
item.desktopKeywords.push_back(QString(keyWord.c_str()).toLower());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &category : info.getCategories()) {
|
for (auto &category : info.getCategories()) {
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "synmodule.h"
|
#include "synmodule.h"
|
||||||
#include "category.h"
|
#include "category.h"
|
||||||
|
#include "launcheriteminfolist.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
@ -53,19 +54,19 @@ struct ItemInfo
|
|||||||
{
|
{
|
||||||
QString path;
|
QString path;
|
||||||
QString name;
|
QString name;
|
||||||
QString enName;
|
|
||||||
QString id;
|
QString id;
|
||||||
QString icon;
|
QString icon;
|
||||||
Categorytype categoryId;
|
Categorytype categoryId;
|
||||||
int64_t timeInstalled;
|
int64_t timeInstalled;
|
||||||
|
//QStringList keywords; // 存放前端搜索关键字 name enName
|
||||||
};
|
};
|
||||||
|
|
||||||
// 应用信息类
|
// 应用信息类
|
||||||
struct Item {
|
struct Item {
|
||||||
inline bool isValid() {return !info.path.isEmpty();}
|
inline bool isValid() {return !info.path.isEmpty();}
|
||||||
|
|
||||||
ItemInfo info;
|
LauncherItemInfo info;
|
||||||
QStringList keywords;
|
QStringList desktopKeywords; //desktop file keywords
|
||||||
QStringList categories;
|
QStringList categories;
|
||||||
QString xDeepinCategory;
|
QString xDeepinCategory;
|
||||||
QString exec;
|
QString exec;
|
||||||
@ -91,12 +92,12 @@ public:
|
|||||||
int getDisplayMode();
|
int getDisplayMode();
|
||||||
bool getFullScreen();
|
bool getFullScreen();
|
||||||
void setDisplayMode(int value);
|
void setDisplayMode(int value);
|
||||||
void setFullScreen(bool isFull);
|
void setFullscreen(bool isFull);
|
||||||
|
|
||||||
QVector<ItemInfo> getAllItemInfos();
|
LauncherItemInfoList getAllItemInfos();
|
||||||
QStringList getAllNewInstalledApps();
|
QStringList getAllNewInstalledApps();
|
||||||
bool getDisableScaling(QString appId);
|
bool getDisableScaling(QString appId);
|
||||||
ItemInfo getItemInfo(QString appId);
|
LauncherItemInfo getItemInfo(QString appId);
|
||||||
bool getUseProxy(QString appId);
|
bool getUseProxy(QString appId);
|
||||||
bool isItemOnDesktop(QString appId);
|
bool isItemOnDesktop(QString appId);
|
||||||
bool requestRemoveFromDesktop(QString appId);
|
bool requestRemoveFromDesktop(QString appId);
|
||||||
@ -106,10 +107,10 @@ public:
|
|||||||
void setUseProxy(QString appId, bool value);
|
void setUseProxy(QString appId, bool value);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void ItemChanged(QString status, ItemInfo itemInfo, Categorytype ty);
|
void itemChanged(QString status, LauncherItemInfo itemInfo, qint64 ty);
|
||||||
void NewAppLaunched(QString appId);
|
void newAppLaunched(QString appId);
|
||||||
void UninstallSuccess(QString appId);
|
void uninstallSuccess(QString appId);
|
||||||
void UninstallFailed(QString appId, QString errMsg);
|
void uninstallFailed(QString appId, QString errMsg);
|
||||||
|
|
||||||
void displayModeChanged(int mode);
|
void displayModeChanged(int mode);
|
||||||
void fullScreenChanged(bool isFull);
|
void fullScreenChanged(bool isFull);
|
||||||
|
@ -31,88 +31,6 @@ DCORE_USE_NAMESPACE
|
|||||||
|
|
||||||
static DConfig *dconfig = Settings::ConfigPtr(configLauncher);
|
static DConfig *dconfig = Settings::ConfigPtr(configLauncher);
|
||||||
|
|
||||||
QString LauncherSettings::getDisplayMode()
|
|
||||||
{
|
|
||||||
return dconfig ? dconfig->value(keyDisplayMode).toString() : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
void LauncherSettings::setDisplayMode(QString value)
|
|
||||||
{
|
|
||||||
if (dconfig) {
|
|
||||||
dconfig->setValue(keyDisplayMode, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int LauncherSettings::getFullscreenMode()
|
|
||||||
{
|
|
||||||
return dconfig ? dconfig->value(keyFullscreen).toBool() : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LauncherSettings::setFullscreenMode(int value)
|
|
||||||
{
|
|
||||||
if (dconfig) {
|
|
||||||
dconfig->setValue(keyFullscreen, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QVector<QString> LauncherSettings::getDisableScalingApps()
|
|
||||||
{
|
|
||||||
QVector<QString> ret;
|
|
||||||
if (dconfig) {
|
|
||||||
QList<QVariant> apps = dconfig->value(keyAppsDisableScaling).toList();
|
|
||||||
for (auto app : apps) {
|
|
||||||
ret.push_back(app.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LauncherSettings::setDisableScalingApps(const QVector<QString> &value)
|
|
||||||
{
|
|
||||||
if (dconfig) {
|
|
||||||
QList<QVariant> apps;
|
|
||||||
for (const auto &app : value)
|
|
||||||
apps.push_back(app);
|
|
||||||
|
|
||||||
dconfig->setValue(keyAppsDisableScaling, apps);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QVector<QString> LauncherSettings::getUseProxyApps()
|
|
||||||
{
|
|
||||||
QVector<QString> ret;
|
|
||||||
if (dconfig) {
|
|
||||||
QList<QVariant> apps = dconfig->value(keyAppsUseProxy).toList();
|
|
||||||
for (auto app : apps) {
|
|
||||||
ret.push_back(app.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LauncherSettings::setUseProxy(const QVector<QString> &value)
|
|
||||||
{
|
|
||||||
if (dconfig) {
|
|
||||||
QList<QVariant> apps;
|
|
||||||
for (const auto &app : value)
|
|
||||||
apps.push_back(app);
|
|
||||||
|
|
||||||
dconfig->setValue(keyAppsUseProxy, apps);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QVector<QString> LauncherSettings::getHiddenApps()
|
|
||||||
{
|
|
||||||
QVector<QString> ret;
|
|
||||||
if (dconfig) {
|
|
||||||
QList<QVariant> hiddenApps = dconfig->value(keyAppsHidden).toList();
|
|
||||||
for (auto app : hiddenApps) {
|
|
||||||
ret.push_back(app.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
LauncherSettings::LauncherSettings(QObject *parent)
|
LauncherSettings::LauncherSettings(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
@ -127,3 +45,121 @@ LauncherSettings::LauncherSettings(QObject *parent)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief LauncherSettings::getDisplayMode 获取配置显示模式
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
QString LauncherSettings::getDisplayMode()
|
||||||
|
{
|
||||||
|
return dconfig ? dconfig->value(keyDisplayMode).toString() : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief LauncherSettings::setDisplayMode 设置配置显示模式
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
void LauncherSettings::setDisplayMode(QString value)
|
||||||
|
{
|
||||||
|
if (dconfig) {
|
||||||
|
dconfig->setValue(keyDisplayMode, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief LauncherSettings::getFullscreenMode 获取配置全屏模式
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int LauncherSettings::getFullscreenMode()
|
||||||
|
{
|
||||||
|
return dconfig ? dconfig->value(keyFullscreen).toBool() : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief LauncherSettings::setFullscreenMode 设置配置全屏模式
|
||||||
|
* @param value 全屏模式
|
||||||
|
*/
|
||||||
|
void LauncherSettings::setFullscreenMode(int value)
|
||||||
|
{
|
||||||
|
if (dconfig) {
|
||||||
|
dconfig->setValue(keyFullscreen, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief LauncherSettings::getDisableScalingApps 获取配置禁用缩放应用
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
QVector<QString> LauncherSettings::getDisableScalingApps()
|
||||||
|
{
|
||||||
|
QVector<QString> ret;
|
||||||
|
if (dconfig) {
|
||||||
|
QList<QVariant> apps = dconfig->value(keyAppsDisableScaling).toList();
|
||||||
|
for (auto app : apps) {
|
||||||
|
ret.push_back(app.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief LauncherSettings::setDisableScalingApps 设置配置禁用缩放应用
|
||||||
|
* @param value 应用禁用缩放应用
|
||||||
|
*/
|
||||||
|
void LauncherSettings::setDisableScalingApps(const QVector<QString> &value)
|
||||||
|
{
|
||||||
|
if (dconfig) {
|
||||||
|
QList<QVariant> apps;
|
||||||
|
for (const auto &app : value)
|
||||||
|
apps.push_back(app);
|
||||||
|
|
||||||
|
dconfig->setValue(keyAppsDisableScaling, apps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief LauncherSettings::getUseProxyApps 获取配置代理应用
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
QVector<QString> LauncherSettings::getUseProxyApps()
|
||||||
|
{
|
||||||
|
QVector<QString> ret;
|
||||||
|
if (dconfig) {
|
||||||
|
QList<QVariant> apps = dconfig->value(keyAppsUseProxy).toList();
|
||||||
|
for (auto app : apps) {
|
||||||
|
ret.push_back(app.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief LauncherSettings::setUseProxy 设置配置代理应用
|
||||||
|
* @param value 代理应用
|
||||||
|
*/
|
||||||
|
void LauncherSettings::setUseProxy(const QVector<QString> &value)
|
||||||
|
{
|
||||||
|
if (dconfig) {
|
||||||
|
QList<QVariant> apps;
|
||||||
|
for (const auto &app : value)
|
||||||
|
apps.push_back(app);
|
||||||
|
|
||||||
|
dconfig->setValue(keyAppsUseProxy, apps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief LauncherSettings::getHiddenApps 获取配置隐藏应用
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
QVector<QString> LauncherSettings::getHiddenApps()
|
||||||
|
{
|
||||||
|
QVector<QString> ret;
|
||||||
|
if (dconfig) {
|
||||||
|
QList<QVariant> hiddenApps = dconfig->value(keyAppsHidden).toList();
|
||||||
|
for (auto app : hiddenApps) {
|
||||||
|
ret.push_back(app.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
@ -27,9 +27,14 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
|
// 启动器相关配置
|
||||||
class LauncherSettings : public QObject
|
class LauncherSettings : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
LauncherSettings(QObject *paret = nullptr);
|
||||||
|
LauncherSettings(const LauncherSettings &);
|
||||||
|
LauncherSettings& operator= (const LauncherSettings &);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static inline LauncherSettings *instance() {
|
static inline LauncherSettings *instance() {
|
||||||
static LauncherSettings instance;
|
static LauncherSettings instance;
|
||||||
@ -54,11 +59,6 @@ Q_SIGNALS:
|
|||||||
void displayModeChanged(QString mode);
|
void displayModeChanged(QString mode);
|
||||||
void fullscreenChanged(bool isFull);
|
void fullscreenChanged(bool isFull);
|
||||||
void hiddenAppsChanged();
|
void hiddenAppsChanged();
|
||||||
|
|
||||||
private:
|
|
||||||
LauncherSettings(QObject *paret = nullptr);
|
|
||||||
LauncherSettings(const LauncherSettings &);
|
|
||||||
LauncherSettings& operator= (const LauncherSettings &);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LAUNCHERSETTINGS_H
|
#endif // LAUNCHERSETTINGS_H
|
||||||
|
@ -44,6 +44,7 @@ struct ClientPrivate {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO readFunc function?
|
||||||
if (readFunc) {
|
if (readFunc) {
|
||||||
readThread = new std::thread([=] {
|
readThread = new std::thread([=] {
|
||||||
char buf[512];
|
char buf[512];
|
||||||
@ -72,11 +73,11 @@ struct ClientPrivate {
|
|||||||
send(call);
|
send(call);
|
||||||
|
|
||||||
char buf[512];
|
char buf[512];
|
||||||
std::string result;
|
std::vector<char> data;
|
||||||
int bytesRead;
|
int bytesRead;
|
||||||
while ((bytesRead = recv(socket_fd, buf, 512, 0)) > 0) {
|
while ((bytesRead = recv(socket_fd, buf, 512, 0)) > 0) {
|
||||||
for (int i = 0; i < bytesRead; ++i) {
|
for (int i = 0; i < bytesRead; ++i) {
|
||||||
result += buf[i];
|
data.push_back(buf[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[bytesRead - 1] == '\0') {
|
if (buf[bytesRead - 1] == '\0') {
|
||||||
@ -84,12 +85,12 @@ struct ClientPrivate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonDocument doc = QJsonDocument::fromRawData(result.data(), result.size());
|
return data.data();
|
||||||
return doc.toJson();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t send(const QByteArray &call) {
|
size_t send(const QByteArray &call) {
|
||||||
std::string data = call.data();
|
std::string data = call.data();
|
||||||
|
// \0 作为结尾标记
|
||||||
data += '\0';
|
data += '\0';
|
||||||
return write(socket_fd, data.c_str(), data.length());
|
return write(socket_fd, data.c_str(), data.length());
|
||||||
}
|
}
|
||||||
|
@ -12,109 +12,119 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace Socket {
|
namespace Socket {
|
||||||
class ServerPrivate : public QObject {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
Server *q_ptr;
|
|
||||||
int socket_fd;
|
|
||||||
QThread *workThread;
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
ServerPrivate::ServerPrivate(Server *server)
|
||||||
void requestStart();
|
: QObject()
|
||||||
|
, q_ptr(server)
|
||||||
|
, socket_fd(-1)
|
||||||
|
, workThread(nullptr)
|
||||||
|
{
|
||||||
|
if ((socket_fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
|
||||||
|
std::cout << "socket() failed" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
connect(this, &ServerPrivate::requestStart, this, &ServerPrivate::work, Qt::QueuedConnection);
|
||||||
ServerPrivate(Server *server) : QObject(), q_ptr(server), socket_fd(-1)
|
}
|
||||||
{
|
|
||||||
if ((socket_fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
|
ServerPrivate::~ServerPrivate()
|
||||||
std::cout << "socket() failed" << std::endl;
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerPrivate::work()
|
||||||
|
{
|
||||||
|
// 处理客户端数据
|
||||||
|
while (true) {
|
||||||
|
// 阻塞等待客户端连接
|
||||||
|
int socket = accept(socket_fd, nullptr, nullptr);
|
||||||
|
if (socket == -1) {
|
||||||
|
std::cout << "accept() failed" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
QtConcurrent::run([=] {
|
||||||
connect(this, &ServerPrivate::requestStart, this, &ServerPrivate::work, Qt::QueuedConnection);
|
int readBytes = 0;
|
||||||
}
|
char buffer[1024];
|
||||||
~ServerPrivate() {}
|
std::vector<char> data;
|
||||||
|
while (true) {
|
||||||
void work()
|
readBytes = recv(socket, buffer, 1024, 0);
|
||||||
{
|
if (readBytes == -1) {
|
||||||
// start a thread to listen client read
|
std::cout << "client connect closed" << std::endl;
|
||||||
while (true) {
|
break;
|
||||||
int socket = accept(socket_fd, nullptr, nullptr);
|
|
||||||
if (socket == -1) {
|
|
||||||
std::cout << "accept() failed" << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QtConcurrent::run([=] {
|
|
||||||
int readBytes = 0;
|
|
||||||
char buffer[1024];
|
|
||||||
std::vector<char> data;
|
|
||||||
while (true) {
|
|
||||||
readBytes = recv(socket, buffer, 1024, 0);
|
|
||||||
if (readBytes == -1) {
|
|
||||||
std::cout << "client connect closed" << std::endl;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (readBytes == 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i != readBytes; i++) {
|
|
||||||
data.push_back(buffer[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buffer[readBytes - 1] == '\0') {
|
|
||||||
emit q_ptr->onReadyRead(socket, data);
|
|
||||||
data.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
if (readBytes == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i != readBytes; i++) {
|
||||||
|
data.push_back(buffer[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buffer[readBytes - 1] == '\0') {
|
||||||
|
emit q_ptr->onReadyRead(socket, data);
|
||||||
|
data.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ServerPrivate::listen(const std::string &host)
|
||||||
|
{
|
||||||
|
if (socket_fd < 0) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool listen(const std::string &host)
|
struct sockaddr_un addr;
|
||||||
{
|
memset(&addr, 0, sizeof(struct sockaddr_un));
|
||||||
if (socket_fd < 0) {
|
addr.sun_family = AF_UNIX;
|
||||||
return false;
|
snprintf(addr.sun_path, host.size() + 1, "%s", host.c_str());
|
||||||
}
|
|
||||||
|
|
||||||
struct sockaddr_un addr;
|
// 移除原有套接字文件
|
||||||
memset(&addr, 0, sizeof(struct sockaddr_un));
|
if (remove(host.c_str()) == -1 && errno != ENOENT) {
|
||||||
addr.sun_family = AF_UNIX;
|
std::cout << "remove() failed" << std::endl;
|
||||||
snprintf(addr.sun_path, host.size() + 1, "%s", host.c_str());
|
return false;
|
||||||
|
|
||||||
if (remove(host.c_str()) == -1 && errno != ENOENT) {
|
|
||||||
std::cout << "remove() failed" << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (bind(socket_fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
|
|
||||||
std::cout << "bind() failed" << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (::listen(socket_fd, sizeof(uint)) < 0) {
|
|
||||||
std::cout << "listen() failed" << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void write(int socket, const std::vector<char> &data)
|
// 绑定套接字文件
|
||||||
{
|
if (bind(socket_fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
|
||||||
::write(socket, data.data(), data.size());
|
std::cout << "bind() failed" << std::endl;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void closeClient(int socket)
|
// 监听客户端连接
|
||||||
{
|
if (::listen(socket_fd, 20) < 0) {
|
||||||
::close(socket);
|
std::cout << "listen() failed" << std::endl;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
Server::Server() : QObject(nullptr), d_ptr(new ServerPrivate(this))
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerPrivate::write(int socket, const std::vector<char> &data)
|
||||||
|
{
|
||||||
|
::write(socket, data.data(), data.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerPrivate::closeClient(int socket)
|
||||||
|
{
|
||||||
|
::close(socket);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Server::Server()
|
||||||
|
: QObject(nullptr)
|
||||||
|
, d_ptr(new ServerPrivate(this))
|
||||||
{
|
{
|
||||||
qRegisterMetaType<std::vector<char>>("VectorChar");
|
qRegisterMetaType<std::vector<char>>("VectorChar");
|
||||||
}
|
}
|
||||||
Server::~Server() {}
|
|
||||||
|
Server::~Server()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool Server::listen(const std::string &host)
|
bool Server::listen(const std::string &host)
|
||||||
{
|
{
|
||||||
if (d_ptr->workThread) {
|
if (d_ptr->workThread) {
|
||||||
@ -142,6 +152,7 @@ void Server::close(int socket)
|
|||||||
{
|
{
|
||||||
d_ptr->closeClient(socket);
|
d_ptr->closeClient(socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Socket
|
} // namespace Socket
|
||||||
|
|
||||||
#include "server.moc"
|
#include "server.moc"
|
||||||
|
@ -8,7 +8,29 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
namespace Socket {
|
namespace Socket {
|
||||||
class ServerPrivate;
|
|
||||||
|
class Server;
|
||||||
|
class ServerPrivate : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
Server *q_ptr;
|
||||||
|
int socket_fd;
|
||||||
|
QThread *workThread;
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void requestStart();
|
||||||
|
|
||||||
|
public:
|
||||||
|
ServerPrivate(Server *server);
|
||||||
|
~ServerPrivate();
|
||||||
|
|
||||||
|
void work();
|
||||||
|
bool listen(const std::string &host);
|
||||||
|
void write(int socket, const std::vector<char> &data);
|
||||||
|
void closeClient(int socket);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class Server : public QObject {
|
class Server : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
std::unique_ptr<ServerPrivate> d_ptr;
|
std::unique_ptr<ServerPrivate> d_ptr;
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "startmanagersettings.h"
|
#include "startmanagersettings.h"
|
||||||
#include "startmanagerdbushandler.h"
|
#include "startmanagerdbushandler.h"
|
||||||
#include "meminfo.h"
|
#include "meminfo.h"
|
||||||
|
#include "../../service/impl/application_manager.h"
|
||||||
|
|
||||||
#include <QFileSystemWatcher>
|
#include <QFileSystemWatcher>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@ -47,6 +48,11 @@ StartManager::StartManager(QObject *parent)
|
|||||||
, dbusHandler(new StartManagerDBusHandler(this))
|
, dbusHandler(new StartManagerDBusHandler(this))
|
||||||
, fileWatcher(new QFileSystemWatcher(this))
|
, fileWatcher(new QFileSystemWatcher(this))
|
||||||
{
|
{
|
||||||
|
am = static_cast<ApplicationManager *>(parent);
|
||||||
|
if (!am) {
|
||||||
|
qWarning() << "StartManager init error";
|
||||||
|
}
|
||||||
|
|
||||||
// load sysMemLimitConfig
|
// load sysMemLimitConfig
|
||||||
loadSysMemLimitConfig();
|
loadSysMemLimitConfig();
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ class StartManagerDBusHandler;
|
|||||||
class DesktopInfo;
|
class DesktopInfo;
|
||||||
class QProcess;
|
class QProcess;
|
||||||
class QFileSystemWatcher;
|
class QFileSystemWatcher;
|
||||||
|
class ApplicationManager;
|
||||||
|
|
||||||
class StartManager : public QObject
|
class StartManager : public QObject
|
||||||
{
|
{
|
||||||
@ -76,6 +77,7 @@ private:
|
|||||||
StartManagerDBusHandler *dbusHandler;
|
StartManagerDBusHandler *dbusHandler;
|
||||||
QStringList autostartFiles;
|
QStringList autostartFiles;
|
||||||
QFileSystemWatcher *fileWatcher;
|
QFileSystemWatcher *fileWatcher;
|
||||||
|
ApplicationManager *am;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // STARTMANAGER_H
|
#endif // STARTMANAGER_H
|
||||||
|
@ -32,7 +32,7 @@ StartManagerDBusHandler::StartManagerDBusHandler(QObject *parent)
|
|||||||
|
|
||||||
void StartManagerDBusHandler::markLaunched(QString desktopFile)
|
void StartManagerDBusHandler::markLaunched(QString desktopFile)
|
||||||
{
|
{
|
||||||
QDBusInterface interface = QDBusInterface("org.deepin.daemon.AlRecoder1", "/org/deepin/daemon/AlRecoder1", "org.deepin.daemon.AlRecoder1");
|
QDBusInterface interface = QDBusInterface("org.deepin.daemon.AlRecorder1", "/org/deepin/daemon/AlRecorder1", "org.deepin.daemon.AlRecorder1");
|
||||||
interface.call("MarkLaunched", desktopFile);
|
interface.call("MarkLaunched", desktopFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
|
|
||||||
namespace linglong {
|
namespace linglong {
|
||||||
namespace util {
|
namespace util {
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ add_definitions(-DUSE_QT)
|
|||||||
set(SRCS ${PROJECT_BINARY_DIR}/src/define.h)
|
set(SRCS ${PROJECT_BINARY_DIR}/src/define.h)
|
||||||
|
|
||||||
set(SRCS
|
set(SRCS
|
||||||
|
./applicationhelper.h
|
||||||
./main.cpp
|
./main.cpp
|
||||||
./impl/application_manager.h
|
./impl/application_manager.h
|
||||||
./impl/application_manager.cpp
|
./impl/application_manager.cpp
|
||||||
@ -36,7 +37,6 @@ set(SRCS
|
|||||||
./impl/application.cpp
|
./impl/application.cpp
|
||||||
./impl/application_instance.h
|
./impl/application_instance.h
|
||||||
./impl/application_instance.cpp
|
./impl/application_instance.cpp
|
||||||
../modules/applicationhelper/helper.h
|
|
||||||
../modules/tools/desktop_deconstruction.hpp
|
../modules/tools/desktop_deconstruction.hpp
|
||||||
../modules/socket/server.h
|
../modules/socket/server.h
|
||||||
../modules/socket/server.cpp
|
../modules/socket/server.cpp
|
||||||
@ -45,7 +45,6 @@ set(SRCS
|
|||||||
../modules/methods/instance.hpp
|
../modules/methods/instance.hpp
|
||||||
../modules/methods/quit.hpp
|
../modules/methods/quit.hpp
|
||||||
../modules/methods/registe.hpp
|
../modules/methods/registe.hpp
|
||||||
|
|
||||||
../lib/desktopinfo.h
|
../lib/desktopinfo.h
|
||||||
../lib/desktopinfo.cpp
|
../lib/desktopinfo.cpp
|
||||||
../lib/dlocale.h
|
../lib/dlocale.h
|
||||||
@ -82,6 +81,8 @@ set(SRCS
|
|||||||
../modules/apps/appmanager.cpp
|
../modules/apps/appmanager.cpp
|
||||||
../modules/apps/dfwatcher.h
|
../modules/apps/dfwatcher.h
|
||||||
../modules/apps/dfwatcher.cpp
|
../modules/apps/dfwatcher.cpp
|
||||||
|
../modules/apps/dbusalrecorderadaptor.h
|
||||||
|
../modules/apps/dbusalrecorderadaptor.cpp
|
||||||
../modules/launcher/common.h
|
../modules/launcher/common.h
|
||||||
../modules/launcher/launcher.h
|
../modules/launcher/launcher.h
|
||||||
../modules/launcher/launcher.cpp
|
../modules/launcher/launcher.cpp
|
||||||
@ -142,6 +143,8 @@ set(SRCS
|
|||||||
../frameworkdbus/types/launcheriteminfolist.cpp
|
../frameworkdbus/types/launcheriteminfolist.cpp
|
||||||
../frameworkdbus/types/rect.h
|
../frameworkdbus/types/rect.h
|
||||||
../frameworkdbus/types/rect.cpp
|
../frameworkdbus/types/rect.cpp
|
||||||
|
../frameworkdbus/types/unlaunchedappmap.h
|
||||||
|
../frameworkdbus/types/unlaunchedappmap.cpp
|
||||||
../frameworkdbus/dbuslauncherfront.h
|
../frameworkdbus/dbuslauncherfront.h
|
||||||
../frameworkdbus/dbuslauncherfront.cpp
|
../frameworkdbus/dbuslauncherfront.cpp
|
||||||
../frameworkdbus/dbuslauncher.h
|
../frameworkdbus/dbuslauncher.h
|
||||||
@ -192,6 +195,7 @@ target_include_directories(deepin-application-manager PUBLIC
|
|||||||
../utils
|
../utils
|
||||||
../frameworkdbus
|
../frameworkdbus
|
||||||
../frameworkdbus/qtdbusextended
|
../frameworkdbus/qtdbusextended
|
||||||
|
../frameworkdbus/types
|
||||||
)
|
)
|
||||||
|
|
||||||
install(TARGETS deepin-application-manager DESTINATION bin)
|
install(TARGETS deepin-application-manager DESTINATION bin)
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
#ifndef A7B4B7B1_0422_4EC9_8441_778273A85F9C
|
#include "../modules/tools/desktop_deconstruction.hpp"
|
||||||
#define A7B4B7B1_0422_4EC9_8441_778273A85F9C
|
|
||||||
|
|
||||||
#include "../tools/desktop_deconstruction.hpp"
|
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
@ -45,6 +42,7 @@ public:
|
|||||||
return value<QString>("Icon");
|
return value<QString>("Icon");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// appId
|
||||||
QString id() const
|
QString id() const
|
||||||
{
|
{
|
||||||
return m_file.split("/").last().split(".").first();
|
return m_file.split("/").last().split(".").first();
|
||||||
@ -76,4 +74,3 @@ public:
|
|||||||
} // namespace ApplicationHelper
|
} // namespace ApplicationHelper
|
||||||
} // namespace modules
|
} // namespace modules
|
||||||
|
|
||||||
#endif /* A7B4B7B1_0422_4EC9_8441_778273A85F9C */
|
|
@ -6,7 +6,7 @@
|
|||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "../modules/applicationhelper/helper.h"
|
#include "../applicationhelper.h"
|
||||||
#include "../modules/tools/desktop_deconstruction.hpp"
|
#include "../modules/tools/desktop_deconstruction.hpp"
|
||||||
#include "application_instance.h"
|
#include "application_instance.h"
|
||||||
|
|
||||||
@ -141,11 +141,11 @@ QString Application::filePath() const
|
|||||||
return d->helper->desktop();
|
return d->helper->desktop();
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<ApplicationInstance> Application::createInstance()
|
QSharedPointer<ApplicationInstance> Application::createInstance(QStringList files)
|
||||||
{
|
{
|
||||||
Q_D(Application);
|
Q_D(Application);
|
||||||
|
|
||||||
d->instances << QSharedPointer<ApplicationInstance>(new ApplicationInstance(this, d->helper));
|
d->instances << QSharedPointer<ApplicationInstance>(new ApplicationInstance(this, d->helper, files));
|
||||||
|
|
||||||
connect(d->instances.last().get(), &ApplicationInstance::taskFinished, this, [=] {
|
connect(d->instances.last().get(), &ApplicationInstance::taskFinished, this, [=] {
|
||||||
for (auto it = d->instances.begin(); it != d->instances.end(); ++it) {
|
for (auto it = d->instances.begin(); it != d->instances.end(); ++it) {
|
||||||
|
@ -50,7 +50,7 @@ public: // PROPERTIES
|
|||||||
|
|
||||||
QString filePath() const;
|
QString filePath() const;
|
||||||
|
|
||||||
QSharedPointer<ApplicationInstance> createInstance();
|
QSharedPointer<ApplicationInstance> createInstance(QStringList files);
|
||||||
|
|
||||||
public Q_SLOTS: // METHODS
|
public Q_SLOTS: // METHODS
|
||||||
QString Comment(const QString &locale);
|
QString Comment(const QString &locale);
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
#include <QtConcurrent/QtConcurrent>
|
#include <QtConcurrent/QtConcurrent>
|
||||||
|
|
||||||
#include "../../modules/applicationhelper/helper.h"
|
#include "../applicationhelper.h"
|
||||||
#include "application.h"
|
#include "application.h"
|
||||||
#include "applicationinstanceadaptor.h"
|
#include "applicationinstanceadaptor.h"
|
||||||
|
|
||||||
@ -46,6 +46,7 @@ public:
|
|||||||
void run()
|
void run()
|
||||||
{
|
{
|
||||||
#ifdef DEFINE_LOADER_PATH
|
#ifdef DEFINE_LOADER_PATH
|
||||||
|
|
||||||
const QString task_hash{ QString("DAM_TASK_HASH=%1").arg(m_id) };
|
const QString task_hash{ QString("DAM_TASK_HASH=%1").arg(m_id) };
|
||||||
const QString task_type{ "DAM_TASK_TYPE=freedesktop " };
|
const QString task_type{ "DAM_TASK_TYPE=freedesktop " };
|
||||||
QProcess* p = new QProcess(q_ptr);
|
QProcess* p = new QProcess(q_ptr);
|
||||||
@ -88,7 +89,10 @@ public:
|
|||||||
void _kill() {}
|
void _kill() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
ApplicationInstance::ApplicationInstance(Application* parent, QSharedPointer<modules::ApplicationHelper::Helper> helper) : QObject(nullptr), dd_ptr(new ApplicationInstancePrivate(this))
|
ApplicationInstance::ApplicationInstance(Application* parent, QSharedPointer<modules::ApplicationHelper::Helper> helper, QStringList files)
|
||||||
|
: QObject(nullptr)
|
||||||
|
, dd_ptr(new ApplicationInstancePrivate(this))
|
||||||
|
, m_files(files)
|
||||||
{
|
{
|
||||||
Q_D(ApplicationInstance);
|
Q_D(ApplicationInstance);
|
||||||
|
|
||||||
@ -143,6 +147,7 @@ Methods::Task ApplicationInstance::taskInfo() const
|
|||||||
task.id = d->m_id;
|
task.id = d->m_id;
|
||||||
task.runId = d->application->id();
|
task.runId = d->application->id();
|
||||||
task.date = QString::number(startuptime());
|
task.date = QString::number(startuptime());
|
||||||
|
task.arguments = m_files;
|
||||||
|
|
||||||
// TODO: debug to display environment
|
// TODO: debug to display environment
|
||||||
task.environments.insert( "DISPLAY", ":0" );
|
task.environments.insert( "DISPLAY", ":0" );
|
||||||
|
@ -18,8 +18,10 @@ class ApplicationInstance : public QObject {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
QScopedPointer<ApplicationInstancePrivate> dd_ptr;
|
QScopedPointer<ApplicationInstancePrivate> dd_ptr;
|
||||||
Q_DECLARE_PRIVATE_D(qGetPtrHelper(dd_ptr), ApplicationInstance)
|
Q_DECLARE_PRIVATE_D(qGetPtrHelper(dd_ptr), ApplicationInstance)
|
||||||
|
|
||||||
|
QStringList m_files; // 实例打开的文件
|
||||||
public:
|
public:
|
||||||
ApplicationInstance(Application* parent, QSharedPointer<modules::ApplicationHelper::Helper> helper);
|
ApplicationInstance(Application* parent, QSharedPointer<modules::ApplicationHelper::Helper> helper, QStringList files);
|
||||||
~ApplicationInstance() override;
|
~ApplicationInstance() override;
|
||||||
|
|
||||||
public: // PROPERTIES
|
public: // PROPERTIES
|
||||||
|
@ -17,112 +17,111 @@
|
|||||||
#include "../../modules/methods/quit.hpp"
|
#include "../../modules/methods/quit.hpp"
|
||||||
#include "../../modules/methods/registe.hpp"
|
#include "../../modules/methods/registe.hpp"
|
||||||
#include "../../modules/methods/task.hpp"
|
#include "../../modules/methods/task.hpp"
|
||||||
#include "../../modules/socket/server.h"
|
|
||||||
#include "../../modules/startmanager/startmanager.h"
|
#include "../../modules/startmanager/startmanager.h"
|
||||||
#include "application.h"
|
#include "application.h"
|
||||||
#include "application_instance.h"
|
#include "application_instance.h"
|
||||||
#include "applicationinstanceadaptor.h"
|
#include "applicationinstanceadaptor.h"
|
||||||
|
|
||||||
class ApplicationManagerPrivate : public QObject
|
ApplicationManagerPrivate::ApplicationManagerPrivate(ApplicationManager *parent)
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
ApplicationManager *q_ptr = nullptr;
|
|
||||||
Q_DECLARE_PUBLIC(ApplicationManager);
|
|
||||||
|
|
||||||
QList<QSharedPointer<Application>> applications;
|
|
||||||
Socket::Server server;
|
|
||||||
std::multimap<std::string, QSharedPointer<ApplicationInstance>> tasks;
|
|
||||||
|
|
||||||
StartManager *startManager;
|
|
||||||
|
|
||||||
public:
|
|
||||||
ApplicationManagerPrivate(ApplicationManager *parent)
|
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, q_ptr(parent)
|
, q_ptr(parent)
|
||||||
, startManager(new StartManager(this))
|
, startManager(new StartManager(this))
|
||||||
{
|
{
|
||||||
const QString socketPath{QString("/run/user/%1/deepin-application-manager.socket").arg(getuid())};
|
const QString socketPath{QString("/run/user/%1/deepin-application-manager.socket").arg(getuid())};
|
||||||
connect(&server, &Socket::Server::onReadyRead, this, &ApplicationManagerPrivate::recvClientData, Qt::QueuedConnection);
|
connect(&server, &Socket::Server::onReadyRead, this, &ApplicationManagerPrivate::recvClientData, Qt::QueuedConnection);
|
||||||
server.listen(socketPath.toStdString());
|
server.listen(socketPath.toStdString());
|
||||||
}
|
}
|
||||||
~ApplicationManagerPrivate() {}
|
|
||||||
|
|
||||||
bool checkDMsgUid()
|
ApplicationManagerPrivate::~ApplicationManagerPrivate()
|
||||||
{
|
{
|
||||||
QDBusReply<uint> reply = q_ptr->connection().interface()->serviceUid(q_ptr->message().service());
|
|
||||||
return reply.isValid() && (reply.value() == getuid());
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
}
|
||||||
void recvClientData(int socket, const std::vector<char> &data)
|
|
||||||
{
|
bool ApplicationManagerPrivate::checkDMsgUid()
|
||||||
std::string tmp;
|
{
|
||||||
for (char c : data) {
|
QDBusReply<uint> reply = q_ptr->connection().interface()->serviceUid(q_ptr->message().service());
|
||||||
tmp += c;
|
return reply.isValid() && (reply.value() == getuid());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ApplicationManagerPrivate::recvClientData 接受客户端数据,进行校验
|
||||||
|
* @param socket 客户端套接字
|
||||||
|
* @param data 接受到客户端数据
|
||||||
|
*/
|
||||||
|
void ApplicationManagerPrivate::recvClientData(int socket, const std::vector<char> &data)
|
||||||
|
{
|
||||||
|
QByteArray jsonArray = data.data();
|
||||||
|
Methods::Basic basic;
|
||||||
|
Methods::fromJson(jsonArray, basic);
|
||||||
|
QByteArray tmpArray;
|
||||||
|
do {
|
||||||
|
// 运行实例
|
||||||
|
if (basic.type == "instance") {
|
||||||
|
Methods::Instance instance;
|
||||||
|
Methods::fromJson(jsonArray, instance);
|
||||||
|
|
||||||
|
// 校验实例信息
|
||||||
|
auto find = tasks.find(instance.hash.toStdString());
|
||||||
|
if (find != tasks.end()) {
|
||||||
|
Methods::Task task = find->second->taskInfo();
|
||||||
|
Methods::toJson(tmpArray, task);
|
||||||
|
|
||||||
|
// 通过校验,传入应用启动信息
|
||||||
|
write(socket, tmpArray.toStdString());
|
||||||
|
tasks.erase(find);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray jsonArray = data.data();
|
// 退出
|
||||||
Methods::Basic basic;
|
if (basic.type == "quit") {
|
||||||
Methods::fromJson(jsonArray, basic);
|
Methods::Quit quit;
|
||||||
QByteArray tmpArray;
|
Methods::fromJson(jsonArray, quit);
|
||||||
do {
|
server.close(socket);
|
||||||
if (basic.type == "instance") {
|
std::cout << "client quit" << std::endl;
|
||||||
Methods::Instance instance;
|
break;
|
||||||
Methods::fromJson(jsonArray, instance);
|
}
|
||||||
auto find = tasks.find(instance.hash.toStdString());
|
|
||||||
if (find != tasks.end())
|
|
||||||
{
|
|
||||||
Methods::Task task = find->second->taskInfo();
|
|
||||||
Methods::toJson(tmpArray, task);
|
|
||||||
write(socket, tmpArray.toStdString());
|
|
||||||
tasks.erase(find);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (basic.type == "quit") {
|
|
||||||
Methods::Quit quit;
|
|
||||||
Methods::fromJson(jsonArray, quit);
|
|
||||||
server.close(socket);
|
|
||||||
std::cout << "client quit" << std::endl;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (basic.type == "registe") {
|
|
||||||
Methods::Registe registe;
|
|
||||||
Methods::fromJson(jsonArray, registe);
|
|
||||||
Methods::Registe result;
|
|
||||||
result.state = false;
|
|
||||||
// std::lock_guard<std::mutex> lock(task_mutex);
|
|
||||||
for (auto it = tasks.begin(); it != tasks.end(); ++it) {
|
|
||||||
result.state = true;
|
|
||||||
result.hash = QString::fromStdString(it->first);
|
|
||||||
}
|
|
||||||
Methods::toJson(tmpArray, result);
|
|
||||||
write(socket, tmpArray.toStdString());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
write(socket, jsonArray.toStdString());
|
|
||||||
} while (false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void write(int socket, const std::vector<char> &data)
|
// 注册应用
|
||||||
{
|
if (basic.type == "registe") {
|
||||||
std::vector<char> tmp = data;
|
Methods::Registe registe;
|
||||||
tmp.push_back('\0');
|
Methods::fromJson(jsonArray, registe);
|
||||||
server.write(socket, tmp);
|
Methods::Registe result;
|
||||||
}
|
result.state = false;
|
||||||
void write(int socket, const std::string &data)
|
// std::lock_guard<std::mutex> lock(task_mutex);
|
||||||
{
|
for (auto it = tasks.begin(); it != tasks.end(); ++it) {
|
||||||
std::vector<char> result;
|
result.state = true;
|
||||||
std::copy(data.cbegin(), data.cend(), std::back_inserter(result));
|
result.hash = QString::fromStdString(it->first);
|
||||||
return write(socket, result);
|
}
|
||||||
}
|
Methods::toJson(tmpArray, result);
|
||||||
void write(int socket, const char c)
|
write(socket, tmpArray.toStdString());
|
||||||
{
|
break;
|
||||||
return write(socket, std::vector<char>(c));
|
}
|
||||||
}
|
write(socket, jsonArray.toStdString());
|
||||||
};
|
} while (false);
|
||||||
|
}
|
||||||
|
|
||||||
ApplicationManager* ApplicationManager::Instance() {
|
void ApplicationManagerPrivate::write(int socket, const std::vector<char> &data)
|
||||||
|
{
|
||||||
|
std::vector<char> tmp = data;
|
||||||
|
tmp.push_back('\0');
|
||||||
|
server.write(socket, tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplicationManagerPrivate::write(int socket, const std::string &data)
|
||||||
|
{
|
||||||
|
std::vector<char> result;
|
||||||
|
std::copy(data.cbegin(), data.cend(), std::back_inserter(result));
|
||||||
|
return write(socket, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplicationManagerPrivate::write(int socket, const char c)
|
||||||
|
{
|
||||||
|
return write(socket, std::vector<char>(c));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ApplicationManager* ApplicationManager::instance() {
|
||||||
static ApplicationManager manager;
|
static ApplicationManager manager;
|
||||||
return &manager;
|
return &manager;
|
||||||
}
|
}
|
||||||
@ -145,6 +144,23 @@ void ApplicationManager::addApplication(const QList<QSharedPointer<Application>>
|
|||||||
d->applications = list;
|
d->applications = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ApplicationManager::launchAutostartApps 加载自启动应用
|
||||||
|
* TODO 待优化点: 多个loader使用同一个套接字通信,串行执行,效率低
|
||||||
|
*/
|
||||||
|
void ApplicationManager::launchAutostartApps()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Launch("/freedesktop/system/seahorse", QStringList());
|
||||||
|
QTimer::singleShot(1000, [&] {
|
||||||
|
for (auto app : startManager->autostartList()) {
|
||||||
|
QString id = app.split("/").last().split(".").first();
|
||||||
|
Launch(id, QStringList());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
QDBusObjectPath ApplicationManager::GetInformation(const QString &id)
|
QDBusObjectPath ApplicationManager::GetInformation(const QString &id)
|
||||||
{
|
{
|
||||||
Q_D(ApplicationManager);
|
Q_D(ApplicationManager);
|
||||||
@ -175,7 +191,13 @@ QList<QDBusObjectPath> ApplicationManager::GetInstances(const QString &id)
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
QDBusObjectPath ApplicationManager::Run(const QString &id)
|
/**
|
||||||
|
* @brief ApplicationManager::Launch 启动应用
|
||||||
|
* @param id QString("/%1/%2/%3").arg(Apptype).arg(d->m_type == Application::Type::System ? "system" : "user").arg(appId)
|
||||||
|
* @param files 应用打开的文件
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
QDBusObjectPath ApplicationManager::Launch(const QString &id, QStringList files)
|
||||||
{
|
{
|
||||||
Q_D(ApplicationManager);
|
Q_D(ApplicationManager);
|
||||||
if (!d->checkDMsgUid())
|
if (!d->checkDMsgUid())
|
||||||
@ -183,9 +205,10 @@ QDBusObjectPath ApplicationManager::Run(const QString &id)
|
|||||||
|
|
||||||
// 创建一个实例
|
// 创建一个实例
|
||||||
for (const QSharedPointer<Application> &app : d->applications) {
|
for (const QSharedPointer<Application> &app : d->applications) {
|
||||||
|
QString appId = app->id();
|
||||||
if (app->id() == id) {
|
if (app->id() == id) {
|
||||||
// 创建任务所需的数据,并记录到任务队列,等待 loader 消耗
|
// 创建任务所需的数据,并记录到任务队列,等待 loader 消耗
|
||||||
QSharedPointer<ApplicationInstance> instance{app->createInstance()};
|
QSharedPointer<ApplicationInstance> instance{app->createInstance(files)};
|
||||||
const std::string hash{instance->hash().toStdString()};
|
const std::string hash{instance->hash().toStdString()};
|
||||||
connect(instance.get(), &ApplicationInstance::taskFinished, this, [=] {
|
connect(instance.get(), &ApplicationInstance::taskFinished, this, [=] {
|
||||||
for (auto it = d->tasks.begin(); it != d->tasks.end(); ++it) {
|
for (auto it = d->tasks.begin(); it != d->tasks.end(); ++it) {
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#ifndef A2862DC7_5DA3_4129_9796_671D88015BED
|
#ifndef A2862DC7_5DA3_4129_9796_671D88015BED
|
||||||
#define A2862DC7_5DA3_4129_9796_671D88015BED
|
#define A2862DC7_5DA3_4129_9796_671D88015BED
|
||||||
|
|
||||||
|
#include "../../modules/startmanager/startmanager.h"
|
||||||
|
#include "../../modules/socket/server.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QDBusObjectPath>
|
#include <QDBusObjectPath>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
@ -9,7 +12,34 @@
|
|||||||
|
|
||||||
class Application;
|
class Application;
|
||||||
class ApplicationInstance;
|
class ApplicationInstance;
|
||||||
class ApplicationManagerPrivate;
|
class ApplicationManagerPrivate : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
ApplicationManager *q_ptr = nullptr;
|
||||||
|
Q_DECLARE_PUBLIC(ApplicationManager);
|
||||||
|
|
||||||
|
QList<QSharedPointer<Application>> applications;
|
||||||
|
Socket::Server server;
|
||||||
|
std::multimap<std::string, QSharedPointer<ApplicationInstance>> tasks;
|
||||||
|
StartManager *startManager;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ApplicationManagerPrivate(ApplicationManager *parent);
|
||||||
|
~ApplicationManagerPrivate();
|
||||||
|
|
||||||
|
// 检测调用方身份
|
||||||
|
bool checkDMsgUid();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void recvClientData(int socket, const std::vector<char> &data);
|
||||||
|
|
||||||
|
void write(int socket, const std::vector<char> &data);
|
||||||
|
|
||||||
|
void write(int socket, const std::string &data);
|
||||||
|
|
||||||
|
void write(int socket, const char c);
|
||||||
|
};
|
||||||
|
|
||||||
class ApplicationManager : public QObject, public QDBusContext
|
class ApplicationManager : public QObject, public QDBusContext
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -21,9 +51,10 @@ class ApplicationManager : public QObject, public QDBusContext
|
|||||||
public:
|
public:
|
||||||
ApplicationManager(QObject *parent = nullptr);
|
ApplicationManager(QObject *parent = nullptr);
|
||||||
~ApplicationManager() override;
|
~ApplicationManager() override;
|
||||||
static ApplicationManager* Instance();
|
static ApplicationManager* instance();
|
||||||
|
|
||||||
void addApplication(const QList<QSharedPointer<Application>> &list);
|
void addApplication(const QList<QSharedPointer<Application>> &list);
|
||||||
|
void launchAutostartApps();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void AutostartChanged(QString status, QString filePath);
|
void AutostartChanged(QString status, QString filePath);
|
||||||
@ -35,7 +66,7 @@ public: // PROPERTIES
|
|||||||
public Q_SLOTS: // METHODS
|
public Q_SLOTS: // METHODS
|
||||||
QDBusObjectPath GetInformation(const QString &id);
|
QDBusObjectPath GetInformation(const QString &id);
|
||||||
QList<QDBusObjectPath> GetInstances(const QString &id);
|
QList<QDBusObjectPath> GetInstances(const QString &id);
|
||||||
QDBusObjectPath Run(const QString &id);
|
QDBusObjectPath Launch(const QString &id, QStringList files);
|
||||||
|
|
||||||
// com.deepin.StartManager
|
// com.deepin.StartManager
|
||||||
bool AddAutostart(QString fileName);
|
bool AddAutostart(QString fileName);
|
||||||
@ -53,7 +84,6 @@ public Q_SLOTS: // METHODS
|
|||||||
void RunCommand(QString exe, QStringList args);
|
void RunCommand(QString exe, QStringList args);
|
||||||
void RunCommandWithOptions(QString exe, QStringList args, QMap<QString, QString> options);
|
void RunCommandWithOptions(QString exe, QStringList args, QMap<QString, QString> options);
|
||||||
void TryAgain(bool launch);
|
void TryAgain(bool launch);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* A2862DC7_5DA3_4129_9796_671D88015BED */
|
#endif /* A2862DC7_5DA3_4129_9796_671D88015BED */
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "impl/application.h"
|
#include "impl/application.h"
|
||||||
#include "applicationmanageradaptor.h"
|
#include "applicationmanageradaptor.h"
|
||||||
#include "applicationadaptor.h"
|
#include "applicationadaptor.h"
|
||||||
#include "../modules/applicationhelper/helper.h"
|
#include "applicationhelper.h"
|
||||||
#include "../modules/apps/appmanager.h"
|
#include "../modules/apps/appmanager.h"
|
||||||
#include "../modules/launcher/launchermanager.h"
|
#include "../modules/launcher/launchermanager.h"
|
||||||
#include "../modules/dock/dockmanager.h"
|
#include "../modules/dock/dockmanager.h"
|
||||||
@ -72,15 +72,15 @@ int main(int argc, char *argv[])
|
|||||||
DLogManager::registerConsoleAppender();
|
DLogManager::registerConsoleAppender();
|
||||||
DLogManager::registerFileAppender();
|
DLogManager::registerFileAppender();
|
||||||
|
|
||||||
new AppManager(ApplicationManager::Instance());
|
new AppManager(ApplicationManager::instance());
|
||||||
new LauncherManager(ApplicationManager::Instance());
|
new LauncherManager(ApplicationManager::instance());
|
||||||
new DockManager(ApplicationManager::Instance());
|
new DockManager(ApplicationManager::instance());
|
||||||
new StartManager(ApplicationManager::Instance());
|
new StartManager(ApplicationManager::instance());
|
||||||
new ApplicationManagerAdaptor(ApplicationManager::Instance());
|
new ApplicationManagerAdaptor(ApplicationManager::instance());
|
||||||
|
|
||||||
QDBusConnection::sessionBus().registerService("org.desktopspec.Application");
|
QDBusConnection::sessionBus().registerService("org.desktopspec.Application");
|
||||||
QDBusConnection::sessionBus().registerService("org.desktopspec.ApplicationManager");
|
QDBusConnection::sessionBus().registerService("org.desktopspec.ApplicationManager");
|
||||||
QDBusConnection::sessionBus().registerObject("/org/desktopspec/ApplicationManager", "org.desktopspec.ApplicationManager", ApplicationManager::Instance());
|
QDBusConnection::sessionBus().registerObject("/org/desktopspec/ApplicationManager", "org.desktopspec.ApplicationManager", ApplicationManager::instance());
|
||||||
|
|
||||||
QList<QSharedPointer<Application>> apps{ scanFiles() };
|
QList<QSharedPointer<Application>> apps{ scanFiles() };
|
||||||
QList<QSharedPointer<ApplicationAdaptor>> appAdapters;
|
QList<QSharedPointer<ApplicationAdaptor>> appAdapters;
|
||||||
@ -90,7 +90,9 @@ int main(int argc, char *argv[])
|
|||||||
QDBusConnection::sessionBus().registerObject(app->path().path(), "org.desktopspec.Application", app.get());
|
QDBusConnection::sessionBus().registerObject(app->path().path(), "org.desktopspec.Application", app.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplicationManager::Instance()->addApplication(apps);
|
ApplicationManager::instance()->addApplication(apps);
|
||||||
|
|
||||||
|
ApplicationManager::instance()->launchAutostartApps();
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user