summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Mühlenpfordt <[email protected]>2018-01-24 09:56:00 +0100
committerPeter Mühlenpfordt <[email protected]>2018-01-26 08:35:47 +0100
commit8a6a4ea6b9853ef4c9a916d2d91d8a7a02ad6b64 (patch)
tree63b52a7683fd791ddd49f017ca3b12dd162f4e0f
parent5bcb8cc92d3774263fe9c24cf9cbbf64da22b2f6 (diff)
Fix issues with clicking directories in tree view
Summary: Selecting another directory in tree while showing an image in view mode, opens the first image from the selected directory in view mode. If the folder contains subfolders, gwenview selects the first one and switches to browse mode. This patch changes selection of first **item** back to first **image** (introduced in D8934) to fix this and toggles between browse/view mode only after clicking the already selected directory in tree. Additionally a trailing slash is stripped from the current dir url in context manager to fix a failing compare to initially stored dir url. BUG: 306835 Test Plan: 1. Open image in view mode 2. Click on another directory in tree view -> Should view the first image in new directory 1. Open image in view mode 2. Click multiple times on the same directory in tree view -> Should toggle browse/view mode Reviewers: rkflx Reviewed By: rkflx Subscribers: ngraham, rkflx Differential Revision: https://phabricator.kde.org/D9886
-rw-r--r--app/mainwindow.cpp33
-rw-r--r--app/mainwindow.h2
-rw-r--r--doc/index.docbook3
-rw-r--r--lib/contextmanager.cpp3
4 files changed, 34 insertions, 7 deletions
diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp
index bc74b37..bfba397 100644
--- a/app/mainwindow.cpp
+++ b/app/mainwindow.cpp
@@ -514,8 +514,8 @@ struct MainWindow::Private
// Create context manager items
FolderViewContextManagerItem* folderViewItem = new FolderViewContextManagerItem(mContextManager);
- connect(folderViewItem, SIGNAL(urlChanged(QUrl)),
- q, SLOT(openDirUrl(QUrl)));
+ connect(folderViewItem, &FolderViewContextManagerItem::urlChanged,
+ q, &MainWindow::folderViewUrlChanged);
InfoContextManagerItem* infoItem = new InfoContextManagerItem(mContextManager);
@@ -1046,6 +1046,25 @@ void MainWindow::openDirUrl(const QUrl &url)
d->mViewMainPage->reset();
}
+void MainWindow::folderViewUrlChanged(const QUrl &url) {
+ const QUrl currentUrl = d->mContextManager->currentDirUrl();
+
+ if (url == currentUrl) {
+ switch (d->mCurrentMainPageId) {
+ case ViewMainPageId:
+ d->mBrowseAction->trigger();
+ break;
+ case BrowseMainPageId:
+ d->mViewAction->trigger();
+ break;
+ case StartMainPageId:
+ break;
+ }
+ } else {
+ openDirUrl(url);
+ }
+}
+
void MainWindow::toggleSideBar(bool on)
{
d->mSideBar->setVisible(on);
@@ -1155,9 +1174,13 @@ void MainWindow::slotDirListerCompleted()
if (d->mContextManager->selectionModel()->hasSelection()) {
updatePreviousNextActions();
} else {
- QModelIndex index = d->mThumbnailView->model()->index(0, 0);
- if (index.isValid()) {
- d->mThumbnailView->setCurrentIndex(index);
+ d->goToFirstDocument();
+
+ if (!d->mContextManager->selectionModel()->hasSelection()) {
+ const QModelIndex index = d->mThumbnailView->model()->index(0, 0);
+ if (index.isValid()) {
+ d->mThumbnailView->setCurrentIndex(index);
+ }
}
}
d->mThumbnailView->scrollToSelectedIndex();
diff --git a/app/mainwindow.h b/app/mainwindow.h
index e8a472d..9183f38 100644
--- a/app/mainwindow.h
+++ b/app/mainwindow.h
@@ -136,6 +136,8 @@ private:
void openSelectedDocuments();
void saveConfig();
+
+ void folderViewUrlChanged(const QUrl &url);
};
} // namespace
diff --git a/doc/index.docbook b/doc/index.docbook
index 5aa43ae..61ac18e 100644
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -428,7 +428,8 @@ The sidebar contains several tabs:</para>
switch between them. In Browse Mode thumbnails from the folder will be displayed,
while in View Mode the first image in the folder will appear, from which you can
browse through the folder using the <guibutton>Previous</guibutton> and
-<guibutton>Next</guibutton> buttons or shortcuts.</para></listitem>
+<guibutton>Next</guibutton> buttons or shortcuts. Clicking on a folder multiple
+times toggles between View Mode and Browse Mode.</para></listitem>
</varlistentry>
<varlistentry>
diff --git a/lib/contextmanager.cpp b/lib/contextmanager.cpp
index 9e8fb35..0b1275b 100644
--- a/lib/contextmanager.cpp
+++ b/lib/contextmanager.cpp
@@ -174,8 +174,9 @@ KFileItemList ContextManager::selectedFileItemList() const
return d->mSelectedFileItemList;
}
-void ContextManager::setCurrentDirUrl(const QUrl &url)
+void ContextManager::setCurrentDirUrl(const QUrl &_url)
{
+ const QUrl url = _url.adjusted(QUrl::StripTrailingSlash);
if (url == d->mCurrentDirUrl) {
return;
}