Commit 8a6a4ea6 authored by Peter Mühlenpfordt's avatar Peter Mühlenpfordt

Fix issues with clicking directories in tree view

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:
parent 5bcb8cc9
......@@ -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)
void MainWindow::folderViewUrlChanged(const QUrl &url) {
const QUrl currentUrl = d->mContextManager->currentDirUrl();
if (url == currentUrl) {
switch (d->mCurrentMainPageId) {
case ViewMainPageId:
case BrowseMainPageId:
case StartMainPageId:
} else {
void MainWindow::toggleSideBar(bool on)
......@@ -1155,9 +1174,13 @@ void MainWindow::slotDirListerCompleted()
if (d->mContextManager->selectionModel()->hasSelection()) {
} else {
QModelIndex index = d->mThumbnailView->model()->index(0, 0);
if (index.isValid()) {
if (!d->mContextManager->selectionModel()->hasSelection()) {
const QModelIndex index = d->mThumbnailView->model()->index(0, 0);
if (index.isValid()) {
......@@ -136,6 +136,8 @@ private:
void openSelectedDocuments();
void saveConfig();
void folderViewUrlChanged(const QUrl &url);
} // namespace
......@@ -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>
......@@ -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) {
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment