Skip to content

Commit

Permalink
feat: support new dman interface
Browse files Browse the repository at this point in the history
Change-Id: Ide7a41caa426dc70549024137b6528f1b1bfd61e
  • Loading branch information
Iceyer authored and deepin-gerrit committed Jan 12, 2018
1 parent 929f215 commit a3e46a4
Showing 1 changed file with 15 additions and 23 deletions.
38 changes: 15 additions & 23 deletions src/widgets/dapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

#ifdef Q_OS_LINUX
#include <QDBusInterface>
#include <QDBusReply>
#include "startupnotificationmonitor.h"
#endif

Expand Down Expand Up @@ -255,11 +256,15 @@ bool DApplicationPrivate::loadTranslator(QList<DPathBuf> translateDirs, const QS

bool DApplicationPrivate::isUserManualExists()
{
const QString appName = qApp->applicationName();
bool dmanAppExists = QFile::exists("/usr/bin/dman");
bool dmanDataExists = QFile::exists("/usr/share/dman/" + appName) ||
QFile::exists("/app/share/dman/" + appName);
return dmanAppExists && dmanDataExists;
#ifdef Q_OS_LINUX
QDBusInterface manualSearch("com.deepin.Manual.Search",
"/com/deepin/Manual/Search",
"com.deepin.Manual.Search");
QDBusReply<bool> reply = manualSearch.call("ManualExists", qApp->applicationName());
return reply.value();
#else
return false;
#endif
}

/**
Expand Down Expand Up @@ -580,25 +585,12 @@ void DApplication::setAboutDialog(DAboutDialog *aboutDialog)
*/
void DApplication::handleHelpAction()
{
QString appid = applicationName();
#ifdef DTK_DMAN_PORTAL
if (!qgetenv("FLATPAK_APPID").isEmpty()) {
appid = qgetenv("FLATPAK_APPID");
}

QDBusInterface dmanInterface("com.deepin.dman",
"/com/deepin/dman",
"com.deepin.dman");
if (dmanInterface.isValid()) {
auto reply = dmanInterface.call("ShowManual", appid);
if (dmanInterface.lastError().isValid()) {
qCritical() << "failed call ShowManual" << appid << dmanInterface.lastError();
}
} else {
qCritical() << "can not create dman dbus interface";
}
#ifdef Q_OS_LINUX
QDBusInterface manual("com.deepin.Manual.Open",
"/com/deepin/Manual/Open",
"com.deepin.Manual.Open");
manual.asyncCall("ShowManual", qApp->applicationName());
#else
QProcess::startDetached("dman", QStringList() << appid);
#endif
}

Expand Down

0 comments on commit a3e46a4

Please sign in to comment.