/***************************************************************************
- * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
+ * Copyright (C) 2006 by Peter Penz <peter.penz19@gmail.com> *
* Copyright (C) 2006 by Holger 'zecke' Freyther <freyther@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
#include "dolphinapplication.h"
#include "dolphinmainwindow.h"
+#include "dolphinviewcontainer.h"
#include <applicationadaptor.h>
-#include <kurl.h>
-#include <QDBusConnection>
+#include <KCmdLineArgs>
+#include <KUrl>
+#include <QtDBus/QDBusConnection>
DolphinApplication::DolphinApplication() :
m_lastId(0)
return mainWindow;
}
-int DolphinApplication::openWindow(const QString& url)
-{
- DolphinMainWindow* win = createMainWindow();
- if ((win->activeView() != 0) && !url.isEmpty()) {
- win->activeView()->setUrl(KUrl(url));
- }
- win->show();
- return win->getId();
-}
-
void DolphinApplication::removeMainWindow(DolphinMainWindow* mainWindow)
{
m_mainWindows.removeAll(mainWindow);
}
}
+int DolphinApplication::newInstance()
+{
+ KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
+ static bool first = true;
+
+ const int argsCount = args->count();
+ if ((argsCount > 0) || !first || !isSessionRestored()) {
+ QList<KUrl> urls;
+ for (int i = 0; i < argsCount; ++i) {
+ urls.append(args->url(i));
+ }
+
+ DolphinMainWindow* win = createMainWindow();
+ if (urls.count() > 0) {
+ if (args->isSet("select")) {
+ win->openFiles(urls);
+ } else {
+ win->openDirectories(urls);
+ }
+ }
+ win->show();
+ }
+
+ first = false;
+ args->clear();
+ return 0;
+}
+
+int DolphinApplication::openWindow(const QString& urlString)
+{
+ DolphinMainWindow* win = createMainWindow();
+ const KUrl url(urlString);
+ if (!url.isEmpty()) {
+ win->openDirectories(QList<KUrl>() << url);
+ }
+ win->show();
+ return win->getId();
+}
+
#include "dolphinapplication.moc"