+ m_mainWindow = new DolphinMainWindow();
+ m_mainWindow->setAttribute(Qt::WA_DeleteOnClose);
+ m_mainWindow->show();
+
+ KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
+
+ bool resetSplitSettings = false;
+ if (args->isSet("split") && !GeneralSettings::splitView()) {
+ // Dolphin should be opened with a split view although this is not
+ // set in the GeneralSettings. Temporary adjust the setting until
+ // all passed URLs have been opened.
+ GeneralSettings::setSplitView(true);
+ resetSplitSettings = true;
+ }
+
+ const int argsCount = args->count();
+ if (argsCount > 0) {
+ QList<KUrl> urls;
+ for (int i = 0; i < argsCount; ++i) {
+ const KUrl url = args->url(i);
+ if (url.isValid()) {
+ urls.append(url);
+ }
+ }
+
+ if (!urls.isEmpty()) {
+ if (args->isSet("select")) {
+ m_mainWindow->openFiles(urls);
+ } else {
+ m_mainWindow->openDirectories(urls);
+ }
+ }
+ }
+ args->clear();
+
+ if (resetSplitSettings) {
+ GeneralSettings::setSplitView(false);
+ }