X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/f31a541925033c2ef5e27b85c099d47791b50121..abf17941f7:/src/main.cpp diff --git a/src/main.cpp b/src/main.cpp index 6d71bd720..9de7b609a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,16 +15,17 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #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(); + } }