2016-06-02 09:46:43 +08:00
|
|
|
|
|
|
|
#include "window/mainwindow.h"
|
2016-07-08 17:12:40 +08:00
|
|
|
#include "util/themeappicon.h"
|
2016-06-02 09:46:43 +08:00
|
|
|
|
2016-07-20 15:17:41 +08:00
|
|
|
#include <DApplication>
|
|
|
|
#include <DLog>
|
2016-06-24 15:47:35 +08:00
|
|
|
#include <QDir>
|
2016-06-15 11:09:34 +08:00
|
|
|
|
|
|
|
#include <unistd.h>
|
2016-10-14 15:47:43 +08:00
|
|
|
#include "dbus/dbusdockadaptors.h"
|
2016-06-15 11:09:34 +08:00
|
|
|
DWIDGET_USE_NAMESPACE
|
2016-07-20 15:17:41 +08:00
|
|
|
DUTIL_USE_NAMESPACE
|
2016-06-02 09:46:43 +08:00
|
|
|
|
2016-06-23 17:18:45 +08:00
|
|
|
// let startdde know that we've already started.
|
|
|
|
void RegisterDdeSession()
|
|
|
|
{
|
|
|
|
QString envName("DDE_SESSION_PROCESS_COOKIE_ID");
|
|
|
|
|
|
|
|
QByteArray cookie = qgetenv(envName.toUtf8().data());
|
|
|
|
qunsetenv(envName.toUtf8().data());
|
|
|
|
|
|
|
|
if (!cookie.isEmpty()) {
|
|
|
|
QDBusInterface iface("com.deepin.SessionManager",
|
|
|
|
"/com/deepin/SessionManager",
|
|
|
|
"com.deepin.SessionManager",
|
|
|
|
QDBusConnection::sessionBus());
|
|
|
|
iface.asyncCall("Register", QString(cookie));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-02 09:46:43 +08:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2016-12-30 16:30:09 +08:00
|
|
|
DApplication::loadDXcbPlugin();
|
|
|
|
|
2016-06-15 11:09:34 +08:00
|
|
|
DApplication app(argc, argv);
|
|
|
|
if (!app.setSingleInstance(QString("dde-dock_%1").arg(getuid()))) {
|
|
|
|
qDebug() << "set single instance failed!";
|
|
|
|
return -1;
|
|
|
|
}
|
2016-12-30 16:30:09 +08:00
|
|
|
|
2016-06-15 11:09:34 +08:00
|
|
|
app.setOrganizationName("deepin");
|
|
|
|
app.setApplicationName("dde-dock");
|
|
|
|
app.setApplicationDisplayName("DDE Dock");
|
|
|
|
app.setApplicationVersion("2.0");
|
2016-08-08 20:16:50 +08:00
|
|
|
app.loadTranslator();
|
2016-06-02 09:46:43 +08:00
|
|
|
|
2016-07-20 15:17:41 +08:00
|
|
|
DLogManager::registerConsoleAppender();
|
|
|
|
DLogManager::registerFileAppender();
|
|
|
|
|
2016-08-01 11:26:39 +08:00
|
|
|
qDebug() << "\n\ndde-dock startup";
|
|
|
|
|
2016-06-24 15:47:35 +08:00
|
|
|
#ifndef QT_DEBUG
|
|
|
|
QDir::setCurrent(QApplication::applicationDirPath());
|
|
|
|
#endif
|
|
|
|
|
2016-06-23 16:50:16 +08:00
|
|
|
MainWindow mw;
|
2016-10-14 15:47:43 +08:00
|
|
|
DBusDockAdaptors adaptor(&mw);
|
|
|
|
QDBusConnection::sessionBus().registerService("com.deepin.dde.Dock");
|
|
|
|
QDBusConnection::sessionBus().registerObject("/com/deepin/dde/Dock", "com.deepin.dde.Dock", &mw);
|
|
|
|
|
2016-06-23 17:18:45 +08:00
|
|
|
RegisterDdeSession();
|
2016-06-23 16:43:22 +08:00
|
|
|
|
2016-06-30 18:02:09 +08:00
|
|
|
QTimer::singleShot(500, &mw, &MainWindow::show);
|
2016-06-02 09:46:43 +08:00
|
|
|
|
|
|
|
return app.exec();
|
|
|
|
}
|