X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/d7d4fb9d26773c2d729b49d71af10e1378381ff3..a0cf8456fe171bd221025b3ff3677db4675390b5:/src/main.cpp diff --git a/src/main.cpp b/src/main.cpp index d48ef548e..9de7b609a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,11 +20,12 @@ #include "dolphinapplication.h" #include "dolphinmainwindow.h" -#include #include #include #include #include +#include +#include static KCmdLineOptions options[] = { @@ -32,6 +33,18 @@ static KCmdLineOptions options[] = KCmdLineLastOption }; +void openWindow(DolphinApplication* app, const QString& url = QString()) +{ + if (app != 0) { + app->openWindow(url); + return; + } + + static QDBusInterface dbusIface("org.kde.dolphin", "/dolphin/Application", "", + QDBusConnection::connectToBus(QDBusConnection::SessionBus, "session_bus")); + QDBusReply reply = dbusIface.call("openWindow", url); +} + int main(int argc, char **argv) { KAboutData about("dolphin", @@ -54,8 +67,10 @@ int main(int argc, char **argv) KCmdLineArgs::init(argc, argv, &about); KCmdLineArgs::addCmdLineOptions(options); - - DolphinApplication app; + DolphinApplication *app = 0; + if (DolphinApplication::start()) { + app = new DolphinApplication(); + } #warning TODO, SessionManagement @@ -69,18 +84,17 @@ int main(int argc, char **argv) } else { #endif - KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); - if (args->count() > 0) { - for (int i = 0; i < args->count(); ++i) { - DolphinMainWindow *win = app.createMainWindow(); - win->activeView()->setUrl(args->url(i)); - win->show(); - } - } else { - DolphinMainWindow* mainWin = app.createMainWindow(); - mainWin->show(); + KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); + if (args->count() > 0) { + for (int i = 0; i < args->count(); ++i) { + openWindow(app, args->arg(i)); } - args->clear(); - - return app.exec(); + } + else { + openWindow(app); + } + args->clear(); + if (app != 0) { + return app->exec(); + } }