#include "dolphinviewcontainer.h"
#include <applicationadaptor.h>
-#include <kcmdlineargs.h>
-#include <kurl.h>
+#include <KCmdLineArgs>
+#include <KUrl>
#include <QtDBus/QDBusConnection>
-#include <QtCore/QDir>
DolphinApplication::DolphinApplication() :
m_lastId(0)
}
}
-
int DolphinApplication::newInstance()
{
- KCmdLineArgs::setCwd(QDir::currentPath().toUtf8());
KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
static bool first = true;
- if (args->count() > 0) {
- for (int i = 0; i < args->count(); ++i) {
- openWindow(args->url(i));
+
+ 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);
+ }
}
- } else if( !first || !isSessionRestored()) {
- openWindow(KUrl());
+ win->show();
}
- first = false;
+ first = false;
args->clear();
-
return 0;
}
-int DolphinApplication::openWindow(const KUrl& url)
+int DolphinApplication::openWindow(const QString& urlString)
{
DolphinMainWindow* win = createMainWindow();
- if ((win->activeViewContainer() != 0) && url.isValid()) {
- win->activeViewContainer()->setUrl(url);
+ const KUrl url(urlString);
+ if (!url.isEmpty()) {
+ win->openDirectories(QList<KUrl>() << url);
}
win->show();
return win->getId();