diff --git a/qmlUiKirigami/ImageViewer.qml b/qmlUiKirigami/ImageViewer.qml --- a/qmlUiKirigami/ImageViewer.qml +++ b/qmlUiKirigami/ImageViewer.qml @@ -39,7 +39,6 @@ leftPadding: 0 rightPadding: 0 - state: "closed" states: [ State { name: "open" diff --git a/qmlUiKirigami/Main.qml b/qmlUiKirigami/Main.qml --- a/qmlUiKirigami/Main.qml +++ b/qmlUiKirigami/Main.qml @@ -110,7 +110,6 @@ if( indexForUrl(imagePathArgument) != -1) { currentImage.model = this currentImage.index = indexForUrl(imagePathArgument) - imageViewer.state = "open" } } } @@ -189,6 +188,7 @@ sourceModel: currentImage.model imageWidth: root.width imageHeight: root.height + state: imagePathArgument == "" ? "closed" : "open" } Component.onCompleted: { diff --git a/src/imagefoldermodel.cpp b/src/imagefoldermodel.cpp --- a/src/imagefoldermodel.cpp +++ b/src/imagefoldermodel.cpp @@ -78,13 +78,15 @@ void ImageFolderModel::setUrl(QString& url) { - if (url.isEmpty()) { - return; - } - Q_ASSERT( QUrl(url).isLocalFile()); url = QUrl(url).path(); + if (url.isEmpty()) { + QStringList locations = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation); + Q_ASSERT(locations.size() > 1); + url = locations.first().append("/"); + } + QString directoryUrl; if( QDir(url).exists()) { diff --git a/src/main.cpp b/src/main.cpp --- a/src/main.cpp +++ b/src/main.cpp @@ -76,11 +76,11 @@ QUrl currentDirPath = QUrl::fromLocalFile(QDir::currentPath().append('/')); QUrl resolvedImagePath = parser.positionalArguments().isEmpty() - ? QUrl::fromLocalFile(locations.first().append('/')) + ? QUrl() : currentDirPath.resolved( parser.positionalArguments().first()); if( !resolvedImagePath.isLocalFile()) { - resolvedImagePath = QUrl::fromLocalFile(locations.first().append('/')) ; + resolvedImagePath = QUrl() ; } FileSystemTracker tracker;