예제 #1
0
int main(int argc, char* argv[])
{
    QApplication::setAttribute(Qt::AA_X11InitThreads, true);
    QApplication app(argc, argv);

    if(QDBusConnection::sessionBus().registerService(DBUS_NAME)){

        QmlLoader* qmlLoader = new QmlLoader();
        qmlLoader->rootContext->setContextProperty("mainObject", qmlLoader);
        qmlLoader->load(QUrl("qrc:///views/Main.qml"));
        QObject::connect(qmlLoader->engine, SIGNAL(quit()), QApplication::instance(), SLOT(quit()));

        if(argc == 2){
            QString order = argv[1];
            if(order == "show"){
                qmlLoader->show();
            }
            else if(order == "toggle"){
                qmlLoader->toggle();
            }
            else {
                qmlLoader->showModule(order);
            }
        }

        return app.exec();
    } else {
        qWarning() << "dde control center is running...";
        if(argc == 2){
            QDBusInterface *iface;
            iface = new QDBusInterface(DBUS_NAME, DBUS_PATH, DBUS_NAME, QDBusConnection::sessionBus());
            QString order = argv[1];
            if(order == "show"){
                iface->call("Show");
            }
            else if(order == "toggle"){
                iface->call("Toggle");
            }
            else {
                iface->call("ShowModule", order);
            }
        }
        return 0;
    }
}
예제 #2
0
int main(int argc, char* argv[])
{
    QApplication::setAttribute(Qt::AA_X11InitThreads, true);
    QApplication app(argc, argv);
    if(QDBusConnection::sessionBus().registerService("com.deepin.dialog")){

        QmlLoader* qmlLoader = new QmlLoader();
        qmlLoader->rootContext->setContextProperty("mainObject", qmlLoader);
        qmlLoader->load(QUrl("qrc:///qml/main.qml"));
        QObject::connect(qmlLoader->engine, SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit()));

        return app.exec();
    }
    else{
        qWarning() << "is running...";
        return 0;
    }
}