mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
register dde session at application start point
Change-Id: I31d034782666be1e96aade75f325ca0fe796063c
This commit is contained in:
parent
2ad69dd66f
commit
7fc70a5d97
Notes:
Deepin Code Review
2016-06-14 07:19:47 +00:00
Verified+1: Anonymous Coward #1000004 Code-Review+2: <mr.asianwang@gmail.com> Submitted-by: <mr.asianwang@gmail.com> Submitted-at: Tue, 01 Sep 2015 13:36:59 +0800 Reviewed-on: https://cr.deepin.io/6688 Project: dde/dde-dock Branch: refs/heads/master
@ -1,8 +1,27 @@
|
||||
#include <QApplication>
|
||||
#include <QFile>
|
||||
#include <QDebug>
|
||||
#include <QDBusConnection>
|
||||
|
||||
#include "mainwidget.h"
|
||||
|
||||
// let startdde know that we've already started.
|
||||
void RegisterDdeSession()
|
||||
{
|
||||
char *envName = "DDE_SESSION_PROCESS_COOKIE_ID";
|
||||
|
||||
QByteArray cookie = qgetenv(envName);
|
||||
qunsetenv(envName);
|
||||
|
||||
if (!cookie.isEmpty()) {
|
||||
QDBusInterface iface("com.deepin.SessionManager",
|
||||
"/com/deepin/SessionManager",
|
||||
"com.deepin.SessionManager",
|
||||
QDBusConnection::sessionBus());
|
||||
iface.asyncCall("Register", QString(cookie));
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
@ -10,25 +29,24 @@ int main(int argc, char *argv[])
|
||||
a.setApplicationName("dde-dock");
|
||||
a.setApplicationDisplayName("Dock");
|
||||
|
||||
if(QDBusConnection::sessionBus().registerService(DBUS_NAME)){
|
||||
if (QDBusConnection::sessionBus().registerService(DBUS_NAME)) {
|
||||
QFile file("://Resources/qss/default.qss");
|
||||
if (file.open(QFile::ReadOnly))
|
||||
{
|
||||
if (file.open(QFile::ReadOnly)) {
|
||||
QString styleSheet = QLatin1String(file.readAll());
|
||||
qApp->setStyleSheet(styleSheet);
|
||||
file.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
qWarning() << "[Error:] Open style file errr!";
|
||||
}
|
||||
|
||||
|
||||
MainWidget w;
|
||||
w.show();
|
||||
|
||||
RegisterDdeSession();
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
qWarning() << "dde dock is running...";
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user