diff --git a/src/imagefoldermodel.h b/src/imagefoldermodel.h --- a/src/imagefoldermodel.h +++ b/src/imagefoldermodel.h @@ -53,7 +53,7 @@ QHash roleNames() const override; - void setUrl(const QString& url); + void setUrl(QString& url); QString url() const; QVariant data(const QModelIndex &index, int role) const; diff --git a/src/imagefoldermodel.cpp b/src/imagefoldermodel.cpp --- a/src/imagefoldermodel.cpp +++ b/src/imagefoldermodel.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include @@ -76,20 +76,23 @@ return dirLister()->url().toString(); } -void ImageFolderModel::setUrl(const QString& url) +void ImageFolderModel::setUrl(QString& url) { if (url.isEmpty()) { return; } + Q_ASSERT( QUrl(url).isLocalFile()); + url = QUrl(url).path(); + QString directoryUrl; - if( !QFileInfo(url).isDir()) { + if( QDir(url).exists()) { + directoryUrl = QUrl::fromLocalFile(url).toString(); + } else { m_imagePath = url; - directoryUrl = url.left(url.lastIndexOf('/')); + directoryUrl = QUrl::fromLocalFile(url.left(url.lastIndexOf('/'))).toString(); emit showImageViewer( indexForUrl(m_imagePath)); - } else { - directoryUrl = "file://" + url; } if (dirLister()->url().path() == directoryUrl) { diff --git a/src/main.cpp b/src/main.cpp --- a/src/main.cpp +++ b/src/main.cpp @@ -76,9 +76,13 @@ QUrl currentDirPath = QUrl::fromLocalFile(QDir::currentPath().append('/')); QUrl resolvedImagePath = parser.positionalArguments().isEmpty() - ? QUrl(locations.first().append('/')) + ? QUrl::fromLocalFile(locations.first().append('/')) : currentDirPath.resolved( parser.positionalArguments().first()); + if( !resolvedImagePath.isLocalFile()) { + resolvedImagePath = QUrl::fromLocalFile(locations.first().append('/')) ; + } + FileSystemTracker tracker; tracker.setFolder(locations.first()); tracker.moveToThread(&trackerThread);