style: 调整代码格式
调整代码格式 Log: Influence: 无 Task: https://pms.uniontech.com/task-view-96831.html Change-Id: Ife0c47f5c50b5bc6a8ec767cc3caf041fdef9768
This commit is contained in:
parent
8c0836b1cf
commit
3a4135a1b7
@ -129,14 +129,14 @@ public Q_SLOTS: // METHODS
|
|||||||
void RequestUndock();
|
void RequestUndock();
|
||||||
|
|
||||||
Q_SIGNALS: // SIGNALS
|
Q_SIGNALS: // SIGNALS
|
||||||
void IsActiveChanged(bool value);
|
void IsActiveChanged(bool value) const;
|
||||||
void IsDockedChanged(bool value);
|
void IsDockedChanged(bool value) const;
|
||||||
void MenuChanged(QString value);
|
void MenuChanged(const QString &value) const;
|
||||||
void IconChanged(QString value);
|
void IconChanged(const QString &value) const;
|
||||||
void NameChanged(QString value);
|
void NameChanged(const QString &value) const;
|
||||||
void DesktopFileChanged(QString value);
|
void DesktopFileChanged(const QString &value) const;
|
||||||
void CurrentWindowChanged(uint32_t value);
|
void CurrentWindowChanged(uint32_t value) const;
|
||||||
void WindowInfosChanged(WindowInfoMap value);
|
void WindowInfosChanged(WindowInfoMap value) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -38,12 +38,7 @@ DockManager::DockManager(QObject *parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!con.registerObject(dbusPath, dock, QDBusConnection::ExportAdaptors))
|
if (!con.registerObject(dbusPath, dock, QDBusConnection::ExportAdaptors))
|
||||||
{
|
|
||||||
qWarning() << "register object Dock1 error:" << con.lastError().message();
|
qWarning() << "register object Dock1 error:" << con.lastError().message();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DockManager::~DockManager()
|
DockManager::~DockManager()
|
||||||
|
@ -71,11 +71,7 @@ Entry::~Entry()
|
|||||||
|
|
||||||
bool Entry::isValid()
|
bool Entry::isValid()
|
||||||
{
|
{
|
||||||
bool valid = false;
|
return app ? app->isValidApp() : false;
|
||||||
if (app)
|
|
||||||
valid = app->isValidApp();
|
|
||||||
|
|
||||||
return valid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Entry::getId()
|
QString Entry::getId()
|
||||||
@ -86,11 +82,13 @@ QString Entry::getId()
|
|||||||
QString Entry::getName()
|
QString Entry::getName()
|
||||||
{
|
{
|
||||||
QString ret;
|
QString ret;
|
||||||
if (app)
|
if (app) {
|
||||||
ret = app->getName();
|
ret = app->getName();
|
||||||
|
}
|
||||||
|
|
||||||
if (ret.isEmpty() && !!current)
|
if (ret.isEmpty() && !!current) {
|
||||||
ret = current->getDisplayName();
|
ret = current->getDisplayName();
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -104,22 +102,26 @@ QString Entry::getIcon()
|
|||||||
{
|
{
|
||||||
QString ret;
|
QString ret;
|
||||||
if (hasWindow()) {
|
if (hasWindow()) {
|
||||||
if (!current)
|
if (!current) {
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// has window && current not nullptr
|
// has window && current not nullptr
|
||||||
if (winIconPreferred) {
|
if (winIconPreferred) {
|
||||||
// try current window icon first
|
// try current window icon first
|
||||||
ret = current->getIcon();
|
ret = current->getIcon();
|
||||||
if (ret.size() > 0)
|
if (ret.size() > 0) {
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (app) {
|
if (app) {
|
||||||
icon = app->getIcon();
|
icon = app->getIcon();
|
||||||
if (icon.size() > 0)
|
if (icon.size() > 0) {
|
||||||
return icon;
|
return icon;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return current->getIcon();
|
return current->getIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,11 +145,7 @@ void Entry::setInnerId(QString _innerId)
|
|||||||
|
|
||||||
QString Entry::getFileName()
|
QString Entry::getFileName()
|
||||||
{
|
{
|
||||||
QString fileName;
|
return app ? app->getFileName() : QString();
|
||||||
if (app)
|
|
||||||
fileName = app->getFileName();
|
|
||||||
|
|
||||||
return fileName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AppInfo *Entry::getApp()
|
AppInfo *Entry::getApp()
|
||||||
@ -157,11 +155,13 @@ AppInfo *Entry::getApp()
|
|||||||
|
|
||||||
void Entry::setApp(AppInfo *appinfo)
|
void Entry::setApp(AppInfo *appinfo)
|
||||||
{
|
{
|
||||||
if (app == appinfo)
|
if (app == appinfo) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (app)
|
if (app) {
|
||||||
delete app;
|
delete app;
|
||||||
|
}
|
||||||
|
|
||||||
app = appinfo;
|
app = appinfo;
|
||||||
if (!appinfo) {
|
if (!appinfo) {
|
||||||
@ -212,10 +212,8 @@ void Entry::startExport()
|
|||||||
}
|
}
|
||||||
|
|
||||||
objctPath = entryDBusObjPathPrefix + getId();
|
objctPath = entryDBusObjPathPrefix + getId();
|
||||||
if (!con.registerObject(objctPath, this))
|
if (!con.registerObject(objctPath, this)) {
|
||||||
{
|
|
||||||
qWarning() << "register object Dock1 error:" << con.lastError().message();
|
qWarning() << "register object Dock1 error:" << con.lastError().message();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,8 +249,7 @@ void Entry::updateMenu()
|
|||||||
for (auto &item :getMenuItemDesktopActions())
|
for (auto &item :getMenuItemDesktopActions())
|
||||||
appMenu->appendItem(item);
|
appMenu->appendItem(item);
|
||||||
|
|
||||||
bool hasWin = hasWindow();
|
if (hasWindow())
|
||||||
if (hasWin)
|
|
||||||
appMenu->appendItem(getMenuItemAllWindows());
|
appMenu->appendItem(getMenuItemAllWindows());
|
||||||
|
|
||||||
// menu item dock or undock
|
// menu item dock or undock
|
||||||
@ -273,6 +270,7 @@ void Entry::updateMenu()
|
|||||||
if (getAllowedCloseWindows().size() > 0)
|
if (getAllowedCloseWindows().size() > 0)
|
||||||
appMenu->appendItem(getMenuItemCloseAll());
|
appMenu->appendItem(getMenuItemCloseAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
setMenu(appMenu);
|
setMenu(appMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,25 +299,20 @@ void Entry::updateIsActive()
|
|||||||
|
|
||||||
WindowInfoBase *Entry::getWindowInfoByPid(int pid)
|
WindowInfoBase *Entry::getWindowInfoByPid(int pid)
|
||||||
{
|
{
|
||||||
WindowInfoBase *ret = nullptr;
|
|
||||||
for (const auto &windowInfo : windowInfoMap) {
|
for (const auto &windowInfo : windowInfoMap) {
|
||||||
if (windowInfo->getPid() == pid) {
|
if (windowInfo->getPid() == pid)
|
||||||
ret = windowInfo;
|
return windowInfo;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowInfoBase *Entry::getWindowInfoByWinId(XWindow windowId)
|
WindowInfoBase *Entry::getWindowInfoByWinId(XWindow windowId)
|
||||||
{
|
{
|
||||||
WindowInfoBase *ret = nullptr;
|
if (windowInfoMap.find(windowId) != windowInfoMap.end())
|
||||||
if (windowInfoMap.find(windowId) != windowInfoMap.end()) {
|
return windowInfoMap[windowId];
|
||||||
ret = windowInfoMap[windowId];
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entry::setPropIsDocked(bool docked)
|
void Entry::setPropIsDocked(bool docked)
|
||||||
@ -403,8 +396,8 @@ QString Entry::getExec(bool oneLine)
|
|||||||
if (process) {
|
if (process) {
|
||||||
if (oneLine)
|
if (oneLine)
|
||||||
return process->getOneCommandLine().c_str();
|
return process->getOneCommandLine().c_str();
|
||||||
else
|
|
||||||
return process->getShellScriptLines().c_str();
|
return process->getShellScriptLines().c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
@ -429,8 +422,9 @@ void Entry::updateExportWindowInfos()
|
|||||||
infos[xid] = winInfo;
|
infos[xid] = winInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool changed = false;
|
bool changed = true;
|
||||||
if (infos.size() == exportWindowInfos.size()) {
|
if (infos.size() == exportWindowInfos.size()) {
|
||||||
|
changed = false;
|
||||||
for (auto iter = infos.begin(); iter != infos.end(); iter++) {
|
for (auto iter = infos.begin(); iter != infos.end(); iter++) {
|
||||||
XWindow xid = iter.key();
|
XWindow xid = iter.key();
|
||||||
if (infos[xid].title != exportWindowInfos[xid].title ||
|
if (infos[xid].title != exportWindowInfos[xid].title ||
|
||||||
@ -439,8 +433,6 @@ void Entry::updateExportWindowInfos()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
changed = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
@ -457,9 +449,11 @@ bool Entry::detachWindow(WindowInfoBase *info)
|
|||||||
XWindow winId = info->getXid();
|
XWindow winId = info->getXid();
|
||||||
deleteWindow(winId);
|
deleteWindow(winId);
|
||||||
|
|
||||||
if (windowInfoMap.size() == 0) {
|
if (windowInfoMap.isEmpty()) {
|
||||||
if (!isDocked) // 既无窗口也非驻留应用,无需在任务栏显示
|
if (!isDocked) {
|
||||||
|
// 既无窗口也非驻留应用,无需在任务栏显示
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
setCurrentWindowInfo(nullptr);
|
setCurrentWindowInfo(nullptr);
|
||||||
} else {
|
} else {
|
||||||
@ -516,11 +510,10 @@ bool Entry::containsWindow(XWindow xid)
|
|||||||
|
|
||||||
void Entry::deleteWindow(XWindow xid)
|
void Entry::deleteWindow(XWindow xid)
|
||||||
{
|
{
|
||||||
WindowInfoBase *info = windowInfoMap[xid];
|
if (windowInfoMap.contains(xid)) {
|
||||||
windowInfoMap.remove(xid);
|
WindowInfoBase *info = windowInfoMap[xid];
|
||||||
exportWindowInfos.remove(xid);
|
windowInfoMap.remove(xid);
|
||||||
|
exportWindowInfos.remove(xid);
|
||||||
if (info) {
|
|
||||||
delete info;
|
delete info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -591,8 +584,9 @@ void Entry::forceQuit()
|
|||||||
void Entry::presentWindows()
|
void Entry::presentWindows()
|
||||||
{
|
{
|
||||||
QList<uint> windows;
|
QList<uint> windows;
|
||||||
for (auto iter = windowInfoMap.begin(); iter != windowInfoMap.end(); iter++)
|
for (auto iter = windowInfoMap.begin(); iter != windowInfoMap.end(); iter++) {
|
||||||
windows.push_back(iter.key());
|
windows.push_back(iter.key());
|
||||||
|
}
|
||||||
|
|
||||||
dock->presentWindows(windows);
|
dock->presentWindows(windows);
|
||||||
}
|
}
|
||||||
@ -628,14 +622,12 @@ void Entry::active(uint32_t timestamp)
|
|||||||
bool showing = dock->isShowingDesktop();
|
bool showing = dock->isShowingDesktop();
|
||||||
if (showing || winInfo->isMinimized()) {
|
if (showing || winInfo->isMinimized()) {
|
||||||
winInfo->activate();
|
winInfo->activate();
|
||||||
|
} else if (windowInfoMap.size() == 1) {
|
||||||
|
winInfo->minimize();
|
||||||
} else {
|
} else {
|
||||||
if (windowInfoMap.size() == 1) {
|
WindowInfoBase *nextWin = findNextLeader();
|
||||||
winInfo->minimize();
|
if (nextWin) {
|
||||||
} else {
|
nextWin->activate();
|
||||||
WindowInfoBase *nextWin = findNextLeader();
|
|
||||||
if (nextWin) {
|
|
||||||
nextWin->activate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -658,14 +650,12 @@ void Entry::active(uint32_t timestamp)
|
|||||||
if (found) {
|
if (found) {
|
||||||
// 激活隐藏窗口
|
// 激活隐藏窗口
|
||||||
dock->doActiveWindow(xid);
|
dock->doActiveWindow(xid);
|
||||||
} else {
|
} else if (windowInfoMap.size() == 1) {
|
||||||
if (windowInfoMap.size() == 1) {
|
XCB->minimizeWindow(xid);
|
||||||
XCB->minimizeWindow(xid);
|
} else if (dock->getActiveWindow()->getXid() == xid) {
|
||||||
} else if (dock->getActiveWindow()->getXid() == xid) {
|
WindowInfoBase *nextWin = findNextLeader();
|
||||||
WindowInfoBase *nextWin = findNextLeader();
|
if (nextWin) {
|
||||||
if (nextWin) {
|
nextWin->activate();
|
||||||
nextWin->activate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -714,8 +704,9 @@ QVector<WindowInfoBase *> Entry::getAllowedCloseWindows()
|
|||||||
QVector<WindowInfoBase *> ret;
|
QVector<WindowInfoBase *> ret;
|
||||||
for (auto iter = windowInfoMap.begin(); iter != windowInfoMap.end(); iter++) {
|
for (auto iter = windowInfoMap.begin(); iter != windowInfoMap.end(); iter++) {
|
||||||
WindowInfoBase *info = iter.value();
|
WindowInfoBase *info = iter.value();
|
||||||
if (info && info->allowClose())
|
if (info && info->allowClose()) {
|
||||||
ret.push_back(info);
|
ret.push_back(info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -724,8 +715,9 @@ QVector<WindowInfoBase *> Entry::getAllowedCloseWindows()
|
|||||||
QVector<AppMenuItem> Entry::getMenuItemDesktopActions()
|
QVector<AppMenuItem> Entry::getMenuItemDesktopActions()
|
||||||
{
|
{
|
||||||
QVector<AppMenuItem> ret;
|
QVector<AppMenuItem> ret;
|
||||||
if (!app)
|
if (!app) {
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
for (auto action : app->getActions()) {
|
for (auto action : app->getActions()) {
|
||||||
AppMenuAction fn = [=](uint32_t timestamp) {
|
AppMenuAction fn = [=](uint32_t timestamp) {
|
||||||
@ -746,12 +738,13 @@ QVector<AppMenuItem> Entry::getMenuItemDesktopActions()
|
|||||||
AppMenuItem Entry::getMenuItemLaunch()
|
AppMenuItem Entry::getMenuItemLaunch()
|
||||||
{
|
{
|
||||||
QString itemName;
|
QString itemName;
|
||||||
if (hasWindow())
|
if (hasWindow()) {
|
||||||
itemName = getName();
|
itemName = getName();
|
||||||
else
|
} else {
|
||||||
itemName = "Open";
|
itemName = "Open";
|
||||||
|
}
|
||||||
|
|
||||||
AppMenuAction fn = [&](uint32_t timestamp) {
|
AppMenuAction fn = [this](uint32_t timestamp) {
|
||||||
qInfo() << "do MenuItem: Open";
|
qInfo() << "do MenuItem: Open";
|
||||||
this->launchApp(timestamp);
|
this->launchApp(timestamp);
|
||||||
};
|
};
|
||||||
@ -765,7 +758,7 @@ AppMenuItem Entry::getMenuItemLaunch()
|
|||||||
|
|
||||||
AppMenuItem Entry::getMenuItemCloseAll()
|
AppMenuItem Entry::getMenuItemCloseAll()
|
||||||
{
|
{
|
||||||
AppMenuAction fn = [&](uint32_t timestamp) {
|
AppMenuAction fn = [this](uint32_t timestamp) {
|
||||||
qInfo() << "do MenuItem: Close All";
|
qInfo() << "do MenuItem: Close All";
|
||||||
auto winInfos = getAllowedCloseWindows();
|
auto winInfos = getAllowedCloseWindows();
|
||||||
|
|
||||||
@ -796,7 +789,7 @@ AppMenuItem Entry::getMenuItemCloseAll()
|
|||||||
AppMenuItem Entry::getMenuItemForceQuit()
|
AppMenuItem Entry::getMenuItemForceQuit()
|
||||||
{
|
{
|
||||||
bool active = dock->getForceQuitAppStatus() != ForceQuitAppMode::Deactivated;
|
bool active = dock->getForceQuitAppStatus() != ForceQuitAppMode::Deactivated;
|
||||||
AppMenuAction fn = [&](uint32_t) {
|
AppMenuAction fn = [this](uint32_t) {
|
||||||
qInfo() << "do MenuItem: Force Quit";
|
qInfo() << "do MenuItem: Force Quit";
|
||||||
forceQuit();
|
forceQuit();
|
||||||
};
|
};
|
||||||
@ -834,10 +827,11 @@ AppMenuItem Entry::getMenuItemDock()
|
|||||||
{
|
{
|
||||||
AppMenuItem item;
|
AppMenuItem item;
|
||||||
item.text = "Dock";
|
item.text = "Dock";
|
||||||
item.action = [&](uint32_t) {
|
item.action = [this](uint32_t) {
|
||||||
qInfo() << "do MenuItem: Dock";
|
qInfo() << "do MenuItem: Dock";
|
||||||
requestDock();
|
requestDock();
|
||||||
};
|
};
|
||||||
|
|
||||||
item.isActive = true;
|
item.isActive = true;
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
@ -846,10 +840,11 @@ AppMenuItem Entry::getMenuItemUndock()
|
|||||||
{
|
{
|
||||||
AppMenuItem item;
|
AppMenuItem item;
|
||||||
item.text = "Undock";
|
item.text = "Undock";
|
||||||
item.action = [&](uint32_t) {
|
item.action = [this](uint32_t) {
|
||||||
qInfo() << "do MenuItem: Undock";
|
qInfo() << "do MenuItem: Undock";
|
||||||
requestUndock();
|
requestUndock();
|
||||||
};
|
};
|
||||||
|
|
||||||
item.isActive = true;
|
item.isActive = true;
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
@ -858,10 +853,11 @@ AppMenuItem Entry::getMenuItemAllWindows()
|
|||||||
{
|
{
|
||||||
AppMenuItem item;
|
AppMenuItem item;
|
||||||
item.text = "All Windows";
|
item.text = "All Windows";
|
||||||
item.action = [&](uint32_t) {
|
item.action = [this](uint32_t) {
|
||||||
qInfo() << "do MenuItem: All Windows";
|
qInfo() << "do MenuItem: All Windows";
|
||||||
presentWindows();
|
presentWindows();
|
||||||
};
|
};
|
||||||
|
|
||||||
item.isActive = true;
|
item.isActive = true;
|
||||||
item.hint = menuItemHintShowAllWindows;
|
item.hint = menuItemHintShowAllWindows;
|
||||||
return item;
|
return item;
|
||||||
@ -880,13 +876,13 @@ bool Entry::killProcess(int pid)
|
|||||||
|
|
||||||
bool Entry::setPropDesktopFile(QString value)
|
bool Entry::setPropDesktopFile(QString value)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
|
||||||
if (value != desktopFile) {
|
if (value != desktopFile) {
|
||||||
desktopFile = value;
|
desktopFile = value;
|
||||||
ret = true;
|
|
||||||
Q_EMIT desktopFileChanged(value);
|
Q_EMIT desktopFileChanged(value);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return ret;
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user