diff --git a/application.cpp b/application.cpp index 4eb94c2..ee1126e 100644 --- a/application.cpp +++ b/application.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -91,6 +92,17 @@ void Application::openWindow(const QString &path) w->load(QUrl("qrc:/qml/main.qml")); } +QStringList Application::formatUriList(const QStringList &list) +{ + QStringList val = list; + + if (list.isEmpty()) { + val.append(QDir::currentPath()); + } + + return val; +} + bool Application::parseCommandLineArgs() { QCommandLineParser parser; @@ -113,13 +125,7 @@ bool Application::parseCommandLineArgs() if (parser.isSet(desktopOption)) { Desktop desktop; } else { - QStringList paths = parser.positionalArguments(); - - if (paths.isEmpty()) { - paths.append(QDir::currentPath()); - } - - openFiles(paths); + openFiles(formatUriList(parser.positionalArguments())); } } else { QDBusInterface iface("com.cutefish.FileManager", @@ -131,13 +137,7 @@ bool Application::parseCommandLineArgs() // Empty Dialog iface.call("emptyTrash"); } else { - QStringList paths = parser.positionalArguments(); - - if (paths.isEmpty()) { - paths.append(QDir::currentPath()); - } - - iface.call("openFiles", paths); + iface.call("openFiles", formatUriList(parser.positionalArguments())); } } diff --git a/application.h b/application.h index ff2edf5..c6ebd2d 100644 --- a/application.h +++ b/application.h @@ -37,6 +37,7 @@ public: private: void openWindow(const QString &path); + QStringList formatUriList(const QStringList &list); private: bool parseCommandLineArgs(); diff --git a/dbusinterface.cpp b/dbusinterface.cpp index 5a83984..6153f34 100644 --- a/dbusinterface.cpp +++ b/dbusinterface.cpp @@ -20,8 +20,6 @@ void DBusInterface::ShowFolders(const QStringList &uriList, const QString &start { Q_UNUSED(startUpId); - qDebug() << uriList; - QProcess::startDetached("cutefish-filemanager", uriList); } diff --git a/model/foldermodel.cpp b/model/foldermodel.cpp index 952b6e1..7f1883d 100644 --- a/model/foldermodel.cpp +++ b/model/foldermodel.cpp @@ -293,13 +293,19 @@ void FolderModel::setUrl(const QString &url) if (url.isEmpty()) return; - const QUrl &resolvedNewUrl = resolve(url); + QUrl resolvedNewUrl = resolve(url); + QFileInfo info(resolvedNewUrl.toLocalFile()); if (!QFile::exists(resolvedNewUrl.toLocalFile()) && !url.startsWith("trash:/")) { emit notification(tr("The file or folder %1 does not exist.").arg(url)); return; } + // TODO: selected ? + if (info.isFile()) { + resolvedNewUrl = QUrl::fromLocalFile(info.dir().path()); + } + // Refresh this directory. if (url == m_url) { m_dirModel->dirLister()->updateDirectory(resolvedNewUrl); @@ -309,7 +315,7 @@ void FolderModel::setUrl(const QString &url) m_pathHistory.append(resolvedNewUrl); beginResetModel(); - m_url = url; + m_url = resolvedNewUrl.toLocalFile(); m_dirModel->dirLister()->openUrl(resolvedNewUrl); clearDragImages(); m_dragIndexes.clear();