X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/fd43139134da394e413c5d7d5518275379e67798..abf17941f7:/src/main.cpp diff --git a/src/main.cpp b/src/main.cpp index f5a51ee30..9de7b609a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,6 +24,8 @@ #include #include #include +#include +#include static KCmdLineOptions options[] = { @@ -31,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", @@ -53,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 @@ -68,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(); + } }