feat: 实现StartManager功能
实现StartManager功能, 曝露在ApplicationManager服务上 Log: 实现StartManager功能 Task: https://pms.uniontech.com/task-view-130337.html Influence: 无 Change-Id: I8e83a66f8c25b09e0f4be1e4be9defac95b02b80
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
@ -46,7 +46,7 @@ void AppInfo::init(DesktopInfo &info)
|
||||
return;
|
||||
}
|
||||
|
||||
std::string xDeepinVendor= info.kf.getStr(MainSection, "X-Deepin-Vendor");
|
||||
std::string xDeepinVendor= info.getKeyFile()->getStr(MainSection, "X-Deepin-Vendor");
|
||||
if (xDeepinVendor == "deepin") {
|
||||
name = info.getGenericName().c_str();
|
||||
if (name.isEmpty())
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
@ -81,7 +81,7 @@ Dock::Dock(QObject *parent)
|
||||
});
|
||||
thread.detach();
|
||||
x11Manager->listenRootWindowXEvent();
|
||||
connect(x11Manager, SIGNAL(X11Manager::needUpdateHideState), this, SLOT(updateHideState));
|
||||
connect(x11Manager, SIGNAL(X11Manager::requestUpdateHideState), this, SLOT(updateHideState));
|
||||
}
|
||||
Q_EMIT serviceRestarted();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
@ -262,7 +262,7 @@ void X11Manager::handleRootWindowPropertyNotifyEvent(XCBAtom atom)
|
||||
else if (atom == XCB->getAtom("_NET_ACTIVE_WINDOW"))
|
||||
handleActiveWindowChangedX();
|
||||
else if (atom == XCB->getAtom("_NET_SHOWING_DESKTOP"))
|
||||
Q_EMIT needUpdateHideState(false);
|
||||
Q_EMIT requestUpdateHideState(false);
|
||||
}
|
||||
|
||||
// destory event
|
||||
@ -302,7 +302,7 @@ void X11Manager::handleConfigureNotifyEvent(XWindow xid, int x, int y, int width
|
||||
if (wmClass.className.c_str() == frontendWindowWmClass)
|
||||
return; // ignore frontend window ConfigureNotify event
|
||||
|
||||
Q_EMIT needUpdateHideState(winInfo->isGeometryChanged(x, y, width, height));
|
||||
Q_EMIT requestUpdateHideState(winInfo->isGeometryChanged(x, y, width, height));
|
||||
}
|
||||
|
||||
// property changed event
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
@ -58,8 +58,8 @@ public:
|
||||
void listenXEventUseXlib();
|
||||
void listenXEventUseXCB();
|
||||
|
||||
signals:
|
||||
void needUpdateHideState(bool delay);
|
||||
Q_SIGNALS:
|
||||
void requestUpdateHideState(bool delay);
|
||||
|
||||
private:
|
||||
void addWindowLastConfigureEvent(XWindow xid, ConfigureEvent* event);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
@ -254,9 +254,9 @@ bool Launcher::requestSendToDesktop(QString appId)
|
||||
|
||||
// 创建桌面快捷方式文件
|
||||
DesktopInfo dinfo(itemsMap[appId].info.path.toStdString());
|
||||
dinfo.kf.setKey(MainSection, dbusService.toStdString(), "X-Deepin-CreatedBy");
|
||||
dinfo.kf.setKey(MainSection, appId.toStdString(), "X-Deepin-AppID");
|
||||
if (!dinfo.kf.saveToFile(filePath.toStdString()))
|
||||
dinfo.getKeyFile()->setKey(MainSection, dbusService.toStdString(), "X-Deepin-CreatedBy");
|
||||
dinfo.getKeyFile()->setKey(MainSection, appId.toStdString(), "X-Deepin-AppID");
|
||||
if (!dinfo.getKeyFile()->saveToFile(filePath.toStdString()))
|
||||
return false;
|
||||
|
||||
std::thread thread([]() {
|
||||
@ -824,7 +824,7 @@ AppType Launcher::getAppType(DesktopInfo &info, const Item &item)
|
||||
QFileInfo fileInfo;
|
||||
// 判断是否为flatpak应用
|
||||
do {
|
||||
if (!info.kf.containKey(MainSection, "X-Flatpak"))
|
||||
if (!info.getKeyFile()->containKey(MainSection, "X-Flatpak"))
|
||||
break;
|
||||
|
||||
std::vector<std::string> parts = DString::splitStr(info.getCommandLine(), ' ');
|
||||
@ -863,7 +863,7 @@ AppType Launcher::getAppType(DesktopInfo &info, const Item &item)
|
||||
|
||||
// 判断是否为wineApp
|
||||
do {
|
||||
std::string createdBy = info.kf.getStr(MainSection, "X-Created-By");
|
||||
std::string createdBy = info.getKeyFile()->getStr(MainSection, "X-Created-By");
|
||||
if (DString::startWith(createdBy, "cxoffice-") || strstr(info.getCommandLine().c_str(), "env WINEPREFIX=")) {
|
||||
ty = AppType::WineApp;
|
||||
goto end;
|
||||
@ -1052,10 +1052,10 @@ bool Launcher::isDeepinCustomDesktopFile(QString fileName)
|
||||
|
||||
Item Launcher:: NewItemWithDesktopInfo(DesktopInfo &info)
|
||||
{
|
||||
QString enName(info.kf.getStr(MainSection, KeyName).c_str());
|
||||
QString enComment(info.kf.getStr(MainSection, KeyComment).c_str());
|
||||
QString xDeepinCategory(info.kf.getStr(MainSection, "X-Deepin-Category").c_str());
|
||||
QString xDeepinVendor(info.kf.getStr(MainSection, "X-Deepin-Vendor").c_str());
|
||||
QString enName(info.getKeyFile()->getStr(MainSection, KeyName).c_str());
|
||||
QString enComment(info.getKeyFile()->getStr(MainSection, KeyComment).c_str());
|
||||
QString xDeepinCategory(info.getKeyFile()->getStr(MainSection, "X-Deepin-Category").c_str());
|
||||
QString xDeepinVendor(info.getKeyFile()->getStr(MainSection, "X-Deepin-Vendor").c_str());
|
||||
|
||||
QString appName;
|
||||
if (xDeepinVendor == "deepin")
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
@ -113,7 +113,8 @@ QVector<QString> LauncherSettings::getHiddenApps()
|
||||
return ret;
|
||||
}
|
||||
|
||||
LauncherSettings::LauncherSettings(QObject *parent) : QObject(parent)
|
||||
LauncherSettings::LauncherSettings(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
// 绑定属性
|
||||
connect(dconfig, &DConfig::valueChanged, this, [&] (const QString &key) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
|
64
src/modules/startmanager/common.h
Normal file
64
src/modules/startmanager/common.h
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* Maintainer: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
const QString AMServiceName = "/org/desktopspec/ApplicationManager";
|
||||
const QString autostartDir = "autostart";
|
||||
const QString proxychainsBinary = "proxychains4";
|
||||
|
||||
const QString configLauncher = "com.deepin.dde.launcher";
|
||||
const QString keyAppsUseProxy = "Apps_Use_Proxy";
|
||||
const QString keyAppsDisableScaling = "Apps_Disable_Scaling";
|
||||
|
||||
const QString KeyXGnomeAutostartDelay = "X-GNOME-Autostart-Delay";
|
||||
const QString KeyXGnomeAutoRestart = "X-GNOME-AutoRestart";
|
||||
const QString KeyXDeepinCreatedBy = "X-Deepin-CreatedBy";
|
||||
const QString KeyXDeepinAppID = "X-Deepin-AppID";
|
||||
|
||||
const QString configStartdde = "com.deepin.dde.startdde";
|
||||
const QString keyAutostartDelay = "Autostart_Delay";
|
||||
const QString keyMemCheckerEnabled = "Memchecker_Enabled";
|
||||
const QString keySwapSchedEnabled = "swap-sched-enabled";
|
||||
|
||||
const QString configXsettings = "com.deepin.xsettings";
|
||||
const QString keyScaleFactor = "Scale_Factor";
|
||||
|
||||
const QString uiAppSchedHooksDir = "/usr/lib/UIAppSched.hooks";
|
||||
const QString launchedHookDir = uiAppSchedHooksDir + "/launched";
|
||||
|
||||
const QString cpuFreqAdjustFile = "/usr/share/startdde/app_startup.conf";
|
||||
const QString performanceGovernor = "performance";
|
||||
|
||||
const int restartRateLimitSeconds = 60;
|
||||
|
||||
const QString sysMemLimitConfig = "/usr/share/startdde/memchecker.json";
|
||||
|
||||
const int defaultMinMemAvail = 300; // 300M
|
||||
const int defaultMaxSwapUsed = 1200; // 1200M
|
||||
|
||||
const QString autostartAdded = "added";
|
||||
const QString autostartDeleted = "deleted";
|
||||
|
||||
#endif // COMMON_H
|
470
src/modules/startmanager/startmanager.cpp
Normal file
470
src/modules/startmanager/startmanager.cpp
Normal file
@ -0,0 +1,470 @@
|
||||
/*
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* Maintainer: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "startmanager.h"
|
||||
#include "basedir.h"
|
||||
#include "dfile.h"
|
||||
#include "common.h"
|
||||
#include "desktopinfo.h"
|
||||
#include "startmanagersettings.h"
|
||||
#include "startmanagerdbushandler.h"
|
||||
#include "meminfo.h"
|
||||
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QProcess>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QTimer>
|
||||
#include <QThread>
|
||||
|
||||
#define DESKTOPEXT ".desktop"
|
||||
#define SETTING StartManagerSettings::instance()
|
||||
|
||||
StartManager::StartManager(QObject *parent)
|
||||
: QObject(parent)
|
||||
, minMemAvail(0)
|
||||
, maxSwapUsed(0)
|
||||
, dbusHandler(new StartManagerDBusHandler(this))
|
||||
, fileWatcher(new QFileSystemWatcher(this))
|
||||
{
|
||||
// load sysMemLimitConfig
|
||||
loadSysMemLimitConfig();
|
||||
|
||||
autostartFiles = getAutostartList();
|
||||
|
||||
// listen autostart files
|
||||
listenAutostartFileEvents();
|
||||
|
||||
// start autostart
|
||||
// TODO only running once when starting system
|
||||
//startAutostartProgram();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief StartManager::addAutostart
|
||||
* @param fileName desktopFile
|
||||
* @return
|
||||
*/
|
||||
bool StartManager::addAutostart(QString fileName)
|
||||
{
|
||||
return setAutostart(fileName, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief StartManager::removeAutostart
|
||||
* @param fileName desktopFile
|
||||
* @return
|
||||
*/
|
||||
bool StartManager::removeAutostart(QString fileName)
|
||||
{
|
||||
return setAutostart(fileName, false);
|
||||
}
|
||||
|
||||
QStringList StartManager::autostartList()
|
||||
{
|
||||
if (autostartFiles.size() == 0) {
|
||||
autostartFiles = getAutostartList();
|
||||
}
|
||||
|
||||
return autostartFiles;
|
||||
}
|
||||
|
||||
QString StartManager::dumpMemRecord()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString StartManager::getApps()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief StartManager::isAutostart
|
||||
* @param fileName desktopFile
|
||||
* @return
|
||||
*/
|
||||
bool StartManager::isAutostart(QString fileName)
|
||||
{
|
||||
if (!fileName.endsWith(DESKTOPEXT))
|
||||
return false;
|
||||
|
||||
for (auto autostartDir : BaseDir::autoStartDirs()) {
|
||||
std::string filePath = autostartDir + fileName.toStdString();
|
||||
if (DFile::isExisted(filePath)) {
|
||||
DesktopInfo info(filePath);
|
||||
if (info.isValidDesktop() && !info.getIsHidden()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool StartManager::isMemSufficient()
|
||||
{
|
||||
return SETTING->getMemCheckerEnabled() ? MemInfo::isSufficient(minMemAvail, maxSwapUsed) : true;
|
||||
}
|
||||
|
||||
void StartManager::launchApp(QString desktopFile, uint32_t timestamp, QStringList files)
|
||||
{
|
||||
doLaunchAppWithOptions(desktopFile, timestamp, files, QMap<QString, QString>());
|
||||
}
|
||||
|
||||
void StartManager::launchAppAction(QString desktopFile, QString actionSection, uint32_t timestamp)
|
||||
{
|
||||
DesktopInfo info(desktopFile.toStdString());
|
||||
if (!info.isValidDesktop())
|
||||
return;
|
||||
|
||||
DesktopAction targetAction;
|
||||
for (auto action : info.getActions()) {
|
||||
if (!action.section.empty() && action.section.c_str() == actionSection) {
|
||||
targetAction = action;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (targetAction.section.empty()) {
|
||||
qWarning() << "launchAppAction: targetAction section is empty";
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetAction.exec.empty()) {
|
||||
qInfo() << "launchAppAction: targetAction exe is empty";
|
||||
return;
|
||||
}
|
||||
|
||||
launch(&info, targetAction.exec.c_str(), timestamp, QStringList());
|
||||
|
||||
// mark app launched
|
||||
dbusHandler->markLaunched(desktopFile);
|
||||
}
|
||||
|
||||
void StartManager::launchAppWithOptions(QString desktopFile, uint32_t timestamp, QStringList files, QMap<QString, QString> options)
|
||||
{
|
||||
doLaunchAppWithOptions(desktopFile, timestamp, files, options);
|
||||
}
|
||||
|
||||
void StartManager::runCommand(QString exe, QStringList args)
|
||||
{
|
||||
doRunCommandWithOptions(exe, args, QMap<QString, QString>());
|
||||
}
|
||||
|
||||
void StartManager::runCommandWithOptions(QString exe, QStringList args, QMap<QString, QString> options)
|
||||
{
|
||||
doRunCommandWithOptions(exe, args, options);
|
||||
}
|
||||
|
||||
void StartManager::tryAgain(bool launch)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void StartManager::onAutoStartupPathChange(const QString &dirPath)
|
||||
{
|
||||
QStringList autostartFilesList = getAutostartList();
|
||||
QSet<QString> newAutostartFiles = QSet<QString>::fromList(autostartFilesList);
|
||||
QSet<QString> oldAutostartFiles = QSet<QString>::fromList(autostartFiles);
|
||||
|
||||
// 添加
|
||||
QSet<QString> newFiles = newAutostartFiles - oldAutostartFiles;
|
||||
QStringList newFile = newFiles.toList();
|
||||
|
||||
// 移除
|
||||
QSet<QString> deletedFiles = oldAutostartFiles - newAutostartFiles;
|
||||
QStringList deleteFile = deletedFiles.toList();
|
||||
|
||||
// 更新autostartFiles记录
|
||||
autostartFiles = autostartFilesList;
|
||||
|
||||
for (auto &file : newFile) {
|
||||
Q_EMIT autostartChanged(autostartAdded, file);
|
||||
}
|
||||
|
||||
for (auto &file : deleteFile) {
|
||||
Q_EMIT autostartChanged(autostartDeleted, file);
|
||||
}
|
||||
}
|
||||
|
||||
bool StartManager::setAutostart(QString fileName, bool value)
|
||||
{
|
||||
if (!fileName.endsWith(DESKTOPEXT))
|
||||
return false;
|
||||
|
||||
if (isAutostart(fileName) == value)
|
||||
return true;
|
||||
|
||||
QFileInfo info(fileName);
|
||||
QString appId = info.baseName();
|
||||
QString autostartDir(BaseDir::userAutoStartDir().c_str());
|
||||
QString autostartFileName = fileName;
|
||||
bool isUserAutostart = false;
|
||||
// if has no user autostart file, create it
|
||||
if (info.isAbsolute()) {
|
||||
if (info.exists() && info.baseName() == autostartDir) {
|
||||
isUserAutostart = true;
|
||||
}
|
||||
} else {
|
||||
autostartFileName = autostartDir + fileName;
|
||||
if (DFile::isExisted(autostartFileName.toStdString())) {
|
||||
isUserAutostart = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isUserAutostart && !DFile::isExisted(autostartFileName.toStdString())) {
|
||||
// get system autostart desktop file
|
||||
for (auto appDir : BaseDir::appDirs()) {
|
||||
QDir dir(appDir.c_str());
|
||||
dir.setFilter(QDir::Files);
|
||||
dir.setNameFilters({ "*.desktop" });
|
||||
bool hiddenStatusChanged = false;
|
||||
for (auto entry : dir.entryInfoList()) {
|
||||
QString desktopFile = entry.absoluteFilePath();
|
||||
if (!desktopFile.contains(fileName))
|
||||
continue;
|
||||
|
||||
if (!QFile::copy(desktopFile, autostartFileName)) // copy origin file
|
||||
return false;
|
||||
|
||||
hiddenStatusChanged = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (hiddenStatusChanged)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// change autostart hidden status in file
|
||||
KeyFile kf;
|
||||
kf.loadFile(autostartFileName.toStdString());
|
||||
kf.setKey(MainSection, KeyXDeepinCreatedBy.toStdString(), AMServiceName.toStdString());
|
||||
kf.setKey(MainSection, KeyXDeepinAppID.toStdString(), appId.toStdString());
|
||||
kf.setBool(MainSection, KeyHidden, !value ? "true" : "false");
|
||||
kf.saveToFile(autostartFileName.toStdString());
|
||||
|
||||
if (value && autostartFiles.indexOf(fileName) != -1) {
|
||||
autostartFiles.push_back(fileName);
|
||||
} else if (!value) {
|
||||
autostartFiles.removeAll(fileName);
|
||||
}
|
||||
|
||||
Q_EMIT autostartChanged(value ? autostartAdded : autostartDeleted, fileName);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StartManager::doLaunchAppWithOptions(QString desktopFile, uint32_t timestamp, QStringList files, QMap<QString, QString> options)
|
||||
{
|
||||
// launchApp
|
||||
DesktopInfo info(desktopFile.toStdString());
|
||||
if (!info.isValidDesktop())
|
||||
return false;
|
||||
|
||||
if (options.find("path") != options.end()) {
|
||||
info.getKeyFile()->setKey(MainSection, KeyPath, options["path"].toStdString());
|
||||
}
|
||||
|
||||
if (options.find("desktop-override-exec") != options.end()) {
|
||||
info.setDesktopOverrideExec(options["desktop-override-exec"].toStdString());
|
||||
}
|
||||
|
||||
if (info.getCommandLine().empty()) {
|
||||
qInfo() << "command line is empty";
|
||||
return false;
|
||||
}
|
||||
|
||||
launch(&info, info.getCommandLine().c_str(), timestamp, files);
|
||||
|
||||
// mark app launched
|
||||
dbusHandler->markLaunched(desktopFile);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StartManager::launch(DesktopInfo *info, QString cmdLine, uint32_t timestamp, QStringList files)
|
||||
{
|
||||
QProcess process;
|
||||
QStringList cmdPrefixesEnvs;
|
||||
QStringList envs;
|
||||
QString desktopFile(info->getFileName().c_str());
|
||||
QFileInfo fileInfo(desktopFile);
|
||||
QString appId = fileInfo.baseName();
|
||||
|
||||
bool useProxy = shouldUseProxy(appId);
|
||||
for (QString var : QProcess::systemEnvironment()) {
|
||||
if (useProxy && (var.startsWith("auto_proxy")
|
||||
|| var.startsWith("http_proxy")
|
||||
|| var.startsWith("https_proxy")
|
||||
|| var.startsWith("ftp_proxy")
|
||||
|| var.startsWith("all_proxy")
|
||||
|| var.startsWith("SOCKS_SERVER")
|
||||
|| var.startsWith("no_proxy"))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
envs << var;
|
||||
}
|
||||
|
||||
if (!appId.isEmpty() && shouldDisableScaling(appId)) {
|
||||
double scale = SETTING->getScaleFactor();
|
||||
scale = scale > 0 ? 1 / scale : 1;
|
||||
QString qtEnv = "QT_SCALE_FACTOR=" + QString::number(scale, 'f', -1);
|
||||
cmdPrefixesEnvs << "/usr/bin/env" << "GDK_DPI_SCALE=1" << "GDK_SCALE=1" << qtEnv;
|
||||
}
|
||||
|
||||
envs << cmdPrefixesEnvs;
|
||||
|
||||
QStringList exeArgs;
|
||||
exeArgs << cmdLine.split(" ") << files;
|
||||
|
||||
if (info->getTerminal()) {
|
||||
exeArgs.insert(0, SETTING->getDefaultTerminalExecArg());
|
||||
exeArgs.insert(0, SETTING->getDefaultTerminalExec());
|
||||
}
|
||||
|
||||
std::string workingDir = info->getKeyFile()->getStr(MainSection, KeyPath);
|
||||
if (workingDir.empty()) {
|
||||
workingDir = BaseDir::homeDir();
|
||||
}
|
||||
|
||||
QString exec = exeArgs[0];
|
||||
exeArgs.removeAt(0);
|
||||
|
||||
qDebug() << "launchApp: " << desktopFile << " exec: " << exec << " args: " << exeArgs;
|
||||
process.setWorkingDirectory(workingDir.c_str());
|
||||
process.setEnvironment(envs);
|
||||
return process.startDetached(exec, exeArgs);
|
||||
}
|
||||
|
||||
bool StartManager::doRunCommandWithOptions(QString exe, QStringList args, QMap<QString, QString> options)
|
||||
{
|
||||
QProcess process;
|
||||
if (options.find("dir") != options.end()) {
|
||||
process.setWorkingDirectory(options["dir"]);
|
||||
}
|
||||
|
||||
return process.startDetached(exe, args);
|
||||
}
|
||||
|
||||
void StartManager::waitCmd(DesktopInfo *info, QProcess *process, QString cmdName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool StartManager::shouldUseProxy(QString appId)
|
||||
{
|
||||
auto useProxyApps = SETTING->getUseProxyApps();
|
||||
if (!useProxyApps.contains(appId))
|
||||
return false;
|
||||
|
||||
if (dbusHandler->getProxyMsg().isEmpty())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StartManager::shouldDisableScaling(QString appId)
|
||||
{
|
||||
auto disableScalingApps = SETTING->getDisableScalingApps();
|
||||
return disableScalingApps.contains(appId);
|
||||
}
|
||||
|
||||
void StartManager::loadSysMemLimitConfig()
|
||||
{
|
||||
std::string configPath = BaseDir::userConfigDir() + "deepin/startdde/memchecker.json";
|
||||
QFile file(configPath.c_str());
|
||||
if (!file.exists())
|
||||
file.setFileName(sysMemLimitConfig);
|
||||
|
||||
do {
|
||||
if (!file.exists())
|
||||
break;
|
||||
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
break;
|
||||
|
||||
QJsonDocument doc = QJsonDocument::fromJson(file.readAll());
|
||||
file.close();
|
||||
if (!doc.isObject())
|
||||
break;
|
||||
|
||||
minMemAvail = uint64_t(doc.object()["min-mem-available"].toInt());
|
||||
maxSwapUsed = uint64_t(doc.object()["max-swap-used"].toInt());
|
||||
return;
|
||||
} while (0);
|
||||
|
||||
minMemAvail = defaultMinMemAvail;
|
||||
maxSwapUsed = defaultMaxSwapUsed;
|
||||
}
|
||||
|
||||
void StartManager::listenAutostartFileEvents()
|
||||
{
|
||||
for (auto autostartDir : BaseDir::autoStartDirs()) {
|
||||
fileWatcher->addPath(autostartDir.c_str());
|
||||
}
|
||||
connect(fileWatcher, &QFileSystemWatcher::directoryChanged, this, &StartManager::onAutoStartupPathChange, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void StartManager::startAutostartProgram()
|
||||
{
|
||||
auto func = [&] (QString file, uint64_t delayTime) {
|
||||
QThread::sleep(uint64_t(delayTime));
|
||||
this->launchApp(file, 0, QStringList());
|
||||
};
|
||||
|
||||
for (QString desktopFile : autostartList()) {
|
||||
DesktopInfo info(desktopFile.toStdString());
|
||||
if (!info.isValidDesktop())
|
||||
continue;
|
||||
|
||||
int delayTime = info.getKeyFile()->getInt(MainSection, KeyXGnomeAutostartDelay.toStdString());
|
||||
QTimer::singleShot(0, this, [&, desktopFile, delayTime] {
|
||||
QThread::sleep(uint64_t(delayTime));
|
||||
this->launchApp(desktopFile, 0, QStringList());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
QStringList StartManager::getAutostartList()
|
||||
{
|
||||
QStringList ret;
|
||||
for (auto autostartDir : BaseDir::autoStartDirs()) {
|
||||
if (!DFile::isExisted(autostartDir))
|
||||
continue;
|
||||
|
||||
QDir dir(autostartDir.c_str());
|
||||
dir.setFilter(QDir::Files);
|
||||
dir.setNameFilters({ "*.desktop" });
|
||||
for (auto entry : dir.entryInfoList()) {
|
||||
if (ret.contains(entry.absoluteFilePath()))
|
||||
continue;
|
||||
|
||||
ret.push_back(entry.absoluteFilePath());
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
81
src/modules/startmanager/startmanager.h
Normal file
81
src/modules/startmanager/startmanager.h
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* Maintainer: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef STARTMANAGER_H
|
||||
#define STARTMANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
|
||||
class AppLaunchContext;
|
||||
class StartManagerDBusHandler;
|
||||
class DesktopInfo;
|
||||
class QProcess;
|
||||
class QFileSystemWatcher;
|
||||
|
||||
class StartManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit StartManager(QObject *parent = nullptr);
|
||||
|
||||
bool addAutostart(QString fileName);
|
||||
bool removeAutostart(QString fileName);
|
||||
QStringList autostartList();
|
||||
QString dumpMemRecord();
|
||||
QString getApps();
|
||||
bool isAutostart(QString fileName);
|
||||
bool isMemSufficient();
|
||||
void launchApp(QString desktopFile, uint32_t timestamp, QStringList files);
|
||||
void launchAppAction(QString desktopFile, QString actionSection, uint32_t timestamp);
|
||||
void launchAppWithOptions(QString desktopFile, uint32_t timestamp, QStringList files, QMap<QString, QString> options);
|
||||
void runCommand(QString exe, QStringList args);
|
||||
void runCommandWithOptions(QString exe, QStringList args, QMap<QString, QString> options);
|
||||
void tryAgain(bool launch);
|
||||
|
||||
Q_SIGNALS:
|
||||
void autostartChanged(QString status, QString fileName);
|
||||
|
||||
public Q_SLOTS:
|
||||
void onAutoStartupPathChange(const QString &dirPath);
|
||||
|
||||
private:
|
||||
bool setAutostart(QString fileName, bool value);
|
||||
bool doLaunchAppWithOptions(QString desktopFile, uint32_t timestamp, QStringList files, QMap<QString, QString> options);
|
||||
bool launch(DesktopInfo *info, QString cmdLine, uint32_t timestamp, QStringList files);
|
||||
bool doRunCommandWithOptions(QString exe, QStringList args, QMap<QString, QString> options);
|
||||
void waitCmd(DesktopInfo *info, QProcess *process, QString cmdName);
|
||||
bool shouldUseProxy(QString appId);
|
||||
bool shouldDisableScaling(QString appId);
|
||||
void loadSysMemLimitConfig();
|
||||
QStringList getDefaultTerminal();
|
||||
void listenAutostartFileEvents();
|
||||
void startAutostartProgram();
|
||||
QStringList getAutostartList();
|
||||
|
||||
uint64_t minMemAvail;
|
||||
uint64_t maxSwapUsed;
|
||||
StartManagerDBusHandler *dbusHandler;
|
||||
QStringList autostartFiles;
|
||||
QFileSystemWatcher *fileWatcher;
|
||||
};
|
||||
|
||||
#endif // STARTMANAGER_H
|
56
src/modules/startmanager/startmanagerdbushandler.cpp
Normal file
56
src/modules/startmanager/startmanagerdbushandler.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* Maintainer: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "startmanagerdbushandler.h"
|
||||
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusReply>
|
||||
|
||||
StartManagerDBusHandler::StartManagerDBusHandler(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void StartManagerDBusHandler::markLaunched(QString desktopFile)
|
||||
{
|
||||
QDBusInterface interface = QDBusInterface("org.deepin.daemon.AlRecoder1", "/org/deepin/daemon/AlRecoder1", "org.deepin.daemon.AlRecoder1");
|
||||
interface.call("MarkLaunched", desktopFile);
|
||||
}
|
||||
|
||||
QString StartManagerDBusHandler::getProxyMsg()
|
||||
{
|
||||
QString ret;
|
||||
QDBusInterface interface = QDBusInterface("com.deepin.system.proxy", "/com/deepin/system/proxy", "com.deepin.system.proxy.App");
|
||||
QDBusReply<QString> reply = interface.call("GetProxy");
|
||||
if (reply.isValid())
|
||||
ret = reply.value();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void StartManagerDBusHandler::addProxyProc(int32_t pid)
|
||||
{
|
||||
QDBusInterface interface = QDBusInterface("com.deepin.system.proxy", "/com/deepin/system/proxy", "com.deepin.system.proxy.App");
|
||||
interface.call("AddProc");
|
||||
}
|
||||
|
||||
|
43
src/modules/startmanager/startmanagerdbushandler.h
Normal file
43
src/modules/startmanager/startmanagerdbushandler.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* Maintainer: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef STARTMANAGERDBUSHANDLER_H
|
||||
#define STARTMANAGERDBUSHANDLER_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class StartManagerDBusHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit StartManagerDBusHandler(QObject *parent = nullptr);
|
||||
|
||||
void markLaunched(QString desktopFile);
|
||||
|
||||
QString getProxyMsg();
|
||||
void addProxyProc(int32_t pid);
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
||||
#endif // STARTMANAGERDBUSHANDLER_H
|
108
src/modules/startmanager/startmanagersettings.cpp
Normal file
108
src/modules/startmanager/startmanagersettings.cpp
Normal file
@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* Maintainer: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "startmanagersettings.h"
|
||||
#include "settings.h"
|
||||
#include "gsetting.h"
|
||||
|
||||
#include <DConfig>
|
||||
#include <QDebug>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
|
||||
DCORE_USE_NAMESPACE
|
||||
|
||||
static DConfig *launchConfig = Settings::ConfigPtr(configLauncher);
|
||||
static DConfig *startConfig = Settings::ConfigPtr(configStartdde);
|
||||
static DConfig *xsettingsConfig = Settings::ConfigPtr(configXsettings);
|
||||
|
||||
QVector<QString> StartManagerSettings::getUseProxyApps()
|
||||
{
|
||||
QVector<QString> ret;
|
||||
if (!launchConfig)
|
||||
return ret;
|
||||
|
||||
QList<QVariant> apps = launchConfig->value(keyAppsUseProxy).toList();
|
||||
for (auto app : apps) {
|
||||
ret.push_back(app.toString());
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
QVector<QString> StartManagerSettings::getDisableScalingApps()
|
||||
{
|
||||
QVector<QString> ret;
|
||||
if (!launchConfig)
|
||||
return ret;
|
||||
|
||||
QList<QVariant> apps = launchConfig->value(keyAppsDisableScaling).toList();
|
||||
for (auto app : apps) {
|
||||
ret.push_back(app.toString());
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool StartManagerSettings::getMemCheckerEnabled()
|
||||
{
|
||||
bool ret = false;
|
||||
if (startConfig) {
|
||||
ret = startConfig->value(keyMemCheckerEnabled).toBool();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double StartManagerSettings::getScaleFactor()
|
||||
{
|
||||
double ret = 0;
|
||||
if (xsettingsConfig) {
|
||||
xsettingsConfig->value(keyScaleFactor).toDouble();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString StartManagerSettings::getDefaultTerminalExec()
|
||||
{
|
||||
QString ret;
|
||||
GSetting settings("com.deepin.desktop.default-applications.terminal");
|
||||
auto exec = settings.getString("exec");
|
||||
if (!exec.empty()) {
|
||||
ret = exec.c_str();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString StartManagerSettings::getDefaultTerminalExecArg()
|
||||
{
|
||||
QString ret;
|
||||
GSetting settings("com.deepin.desktop.default-applications.terminal");
|
||||
auto execArg = settings.getString("exec-arg");
|
||||
if (!execArg.empty()) {
|
||||
ret = execArg.c_str();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
StartManagerSettings::StartManagerSettings(QObject *paret)
|
||||
{
|
||||
|
||||
}
|
62
src/modules/startmanager/startmanagersettings.h
Normal file
62
src/modules/startmanager/startmanagersettings.h
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* Maintainer: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef STARTMANAGERSETTINGS_H
|
||||
#define STARTMANAGERSETTINGS_H
|
||||
#ifdef signals
|
||||
#undef signals
|
||||
#endif
|
||||
|
||||
#include "common.h"
|
||||
#include "gsetting.h"
|
||||
|
||||
|
||||
#include <QObject>
|
||||
#include <QVector>
|
||||
|
||||
class StartManagerSettings : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static inline StartManagerSettings *instance() {
|
||||
static StartManagerSettings instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
QVector<QString> getUseProxyApps();
|
||||
QVector<QString> getDisableScalingApps();
|
||||
|
||||
bool getMemCheckerEnabled();
|
||||
|
||||
double getScaleFactor();
|
||||
|
||||
QString getDefaultTerminalExec();
|
||||
QString getDefaultTerminalExecArg();
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
private:
|
||||
StartManagerSettings(QObject *paret = nullptr);
|
||||
StartManagerSettings(const StartManagerSettings &);
|
||||
StartManagerSettings& operator= (const StartManagerSettings &);
|
||||
};
|
||||
|
||||
#endif // STARTMANAGERSETTINGS_H
|
Reference in New Issue
Block a user