diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -1220,6 +1220,8 @@
this, &DolphinMainWindow::openNewTab);
connect(foldersPanel, &FoldersPanel::errorMessage,
this, &DolphinMainWindow::showErrorMessage);
+ connect(this, &DolphinMainWindow::settingsChanged,
+ foldersPanel, &FoldersPanel::refreshFoldersPanel);
// Setup "Terminal"
#ifndef Q_OS_WIN
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp
--- a/src/kitemviews/kfileitemmodel.cpp
+++ b/src/kitemviews/kfileitemmodel.cpp
@@ -638,6 +638,11 @@
QUrl urlToExpand = m_dirLister->url();
const QStringList subDirs = url.path().mid(pos).split(QDir::separator());
for (int i = 0; i < subDirs.count() - 1; ++i) {
+ // first subdir can be empty, if m_dirLister->url().path() does not end with '/'
+ // this happens if baseUrl is not root but a home directory, see FoldersPanel
+ if (subDirs.at(i).isEmpty()) {
+ continue;
+ }
urlToExpand.setPath(urlToExpand.path() + '/' + subDirs.at(i));
m_urlsToExpand.insert(urlToExpand);
}
diff --git a/src/panels/folders/dolphin_folderspanelsettings.kcfg b/src/panels/folders/dolphin_folderspanelsettings.kcfg
--- a/src/panels/folders/dolphin_folderspanelsettings.kcfg
+++ b/src/panels/folders/dolphin_folderspanelsettings.kcfg
@@ -10,6 +10,10 @@
false
+
+
+ true
+
true
diff --git a/src/panels/folders/folderspanel.h b/src/panels/folders/folderspanel.h
--- a/src/panels/folders/folderspanel.h
+++ b/src/panels/folders/folderspanel.h
@@ -43,7 +43,9 @@
virtual ~FoldersPanel();
void setShowHiddenFiles(bool show);
+ void setLimitFoldersPanelToHome(bool enable);
bool showHiddenFiles() const;
+ bool limitFoldersPanelToHome() const;
void setAutoScrolling(bool enable);
bool autoScrolling() const;
@@ -81,6 +83,9 @@
*/
void startFadeInAnimation();
+public slots:
+ void refreshFoldersPanel();
+
private:
/**
* Initializes the base URL of the tree and expands all
diff --git a/src/panels/folders/folderspanel.cpp b/src/panels/folders/folderspanel.cpp
--- a/src/panels/folders/folderspanel.cpp
+++ b/src/panels/folders/folderspanel.cpp
@@ -82,6 +82,17 @@
return FoldersPanelSettings::hiddenFilesShown();
}
+void FoldersPanel::setLimitFoldersPanelToHome(bool enable)
+{
+ FoldersPanelSettings::setLimitFoldersPanelToHome(enable);
+ refreshFoldersPanel();
+}
+
+bool FoldersPanel::limitFoldersPanelToHome() const
+{
+ return FoldersPanelSettings::limitFoldersPanelToHome();
+}
+
void FoldersPanel::setAutoScrolling(bool enable)
{
// TODO: Not supported yet in Dolphin 2.0
@@ -122,6 +133,14 @@
return true;
}
+void FoldersPanel::refreshFoldersPanel()
+{
+ if (m_controller) {
+ loadTree(url());
+ }
+}
+
+
void FoldersPanel::showEvent(QShowEvent* event)
{
if (event->spontaneous()) {
@@ -172,7 +191,9 @@
layout->addWidget(container);
}
- loadTree(url());
+ if (url().isValid()) {
+ loadTree(url());
+ }
Panel::showEvent(event);
}
@@ -303,9 +324,14 @@
m_updateCurrentItem = false;
QUrl baseUrl;
+ const QUrl homeUrl(QUrl::fromLocalFile(GeneralSettings::homeUrl()));
if (url.isLocalFile()) {
- // Use the root directory as base for local URLs (#150941)
- baseUrl = QUrl::fromLocalFile(QDir::rootPath());
+ if (FoldersPanelSettings::limitFoldersPanelToHome() && (homeUrl.isParentOf(url) || homeUrl == url)) {
+ baseUrl = homeUrl;
+ } else {
+ // Use the root directory as base for local URLs (#150941)
+ baseUrl = QUrl::fromLocalFile(QDir::rootPath());
+ }
} else {
// Clear the path for non-local URLs and use it as base
baseUrl = url;
@@ -323,16 +349,21 @@
} else {
m_updateCurrentItem = true;
m_model->expandParentDirectories(url);
+
+ if (FoldersPanelSettings::limitFoldersPanelToHome() && homeUrl == url) {
+ KItemListSelectionManager* selectionManager = m_controller->selectionManager();
+ selectionManager->clearSelection();
+ }
// slotLoadingCompleted() will be invoked after the model has
// expanded the url
}
}
void FoldersPanel::updateCurrentItem(int index)
{
KItemListSelectionManager* selectionManager = m_controller->selectionManager();
- selectionManager->setCurrentItem(index);
selectionManager->clearSelection();
+ selectionManager->setCurrentItem(index);
selectionManager->setSelected(index);
m_controller->view()->scrollToItem(index);
diff --git a/src/panels/folders/treeviewcontextmenu.h b/src/panels/folders/treeviewcontextmenu.h
--- a/src/panels/folders/treeviewcontextmenu.h
+++ b/src/panels/folders/treeviewcontextmenu.h
@@ -79,6 +79,12 @@
void setShowHiddenFiles(bool show);
/**
+ * Sets the 'Limit folders panel to home' setting for the
+ * folders panel to \a enable.
+ */
+ void setLimitFoldersPanelToHome(bool enable);
+
+ /**
* Sets the 'Automatic Scrolling' setting for the
* folders panel to \a enable.
*/
diff --git a/src/panels/folders/treeviewcontextmenu.cpp b/src/panels/folders/treeviewcontextmenu.cpp
--- a/src/panels/folders/treeviewcontextmenu.cpp
+++ b/src/panels/folders/treeviewcontextmenu.cpp
@@ -124,6 +124,13 @@
popup->addAction(showHiddenFilesAction);
connect(showHiddenFilesAction, &QAction::toggled, this, &TreeViewContextMenu::setShowHiddenFiles);
+ // insert 'Limit folders panel to home directory if inside home'
+ QAction* limitFoldersPanelToHomeAction = new QAction(i18nc("@action:inmenu", "Limit folders panel to home directory if inside home"), this);
+ limitFoldersPanelToHomeAction->setCheckable(true);
+ limitFoldersPanelToHomeAction->setChecked(m_parent->limitFoldersPanelToHome());
+ popup->addAction(limitFoldersPanelToHomeAction);
+ connect(limitFoldersPanelToHomeAction, &QAction::toggled, this, &TreeViewContextMenu::setLimitFoldersPanelToHome);
+
// insert 'Automatic Scrolling'
QAction* autoScrollingAction = new QAction(i18nc("@action:inmenu", "Automatic Scrolling"), this);
autoScrollingAction->setCheckable(true);
@@ -229,6 +236,11 @@
m_parent->setShowHiddenFiles(show);
}
+void TreeViewContextMenu::setLimitFoldersPanelToHome(bool enable)
+{
+ m_parent->setLimitFoldersPanelToHome(enable);
+}
+
void TreeViewContextMenu::setAutoScrolling(bool enable)
{
m_parent->setAutoScrolling(enable);
diff --git a/src/settings/dolphin_generalsettings.kcfg b/src/settings/dolphin_generalsettings.kcfg
--- a/src/settings/dolphin_generalsettings.kcfg
+++ b/src/settings/dolphin_generalsettings.kcfg
@@ -62,6 +62,10 @@
true
+
+
+ false
+
true
diff --git a/src/settings/general/behaviorsettingspage.h b/src/settings/general/behaviorsettingspage.h
--- a/src/settings/general/behaviorsettingspage.h
+++ b/src/settings/general/behaviorsettingspage.h
@@ -66,6 +66,7 @@
QCheckBox* m_renameInline;
QCheckBox* m_useTabForSplitViewSwitch;
+ QCheckBox* m_limitFolderPanelToHome;
};
#endif
diff --git a/src/settings/general/behaviorsettingspage.cpp b/src/settings/general/behaviorsettingspage.cpp
--- a/src/settings/general/behaviorsettingspage.cpp
+++ b/src/settings/general/behaviorsettingspage.cpp
@@ -42,7 +42,8 @@
m_caseSensitiveSorting(0),
m_caseInsensitiveSorting(0),
m_renameInline(0),
- m_useTabForSplitViewSwitch(0)
+ m_useTabForSplitViewSwitch(0),
+ m_limitFolderPanelToHome(0)
{
QVBoxLayout* topLayout = new QVBoxLayout(this);
@@ -82,12 +83,16 @@
// 'Use tab for switching between right and left split'
m_useTabForSplitViewSwitch = new QCheckBox(i18nc("option:check", "Use tab for switching between right and left split view"), this);
+ // 'Limit folder panel to home directory if inside home'
+ m_limitFolderPanelToHome = new QCheckBox(i18nc("option:check", "Limit folder panel to home directory if inside home"), this);
+
topLayout->addWidget(viewPropsBox);
topLayout->addWidget(sortingPropsBox);
topLayout->addWidget(m_showToolTips);
topLayout->addWidget(m_showSelectionToggle);
topLayout->addWidget(m_renameInline);
topLayout->addWidget(m_useTabForSplitViewSwitch);
+ topLayout->addWidget(m_limitFolderPanelToHome);
topLayout->addStretch();
loadSettings();
@@ -101,6 +106,7 @@
connect(m_caseSensitiveSorting, &QRadioButton::toggled, this, &BehaviorSettingsPage::changed);
connect(m_renameInline, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed);
connect(m_useTabForSplitViewSwitch, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed);
+ connect(m_limitFolderPanelToHome, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed);
}
BehaviorSettingsPage::~BehaviorSettingsPage()
@@ -119,6 +125,7 @@
setSortingChoiceValue(settings);
settings->setRenameInline(m_renameInline->isChecked());
settings->setUseTabForSwitchingSplitView(m_useTabForSplitViewSwitch->isChecked());
+ settings->setLimitFolderPanelToHome(m_limitFolderPanelToHome->isChecked());
settings->save();
if (useGlobalViewProps) {
@@ -149,6 +156,7 @@
m_showSelectionToggle->setChecked(GeneralSettings::showSelectionToggle());
m_renameInline->setChecked(GeneralSettings::renameInline());
m_useTabForSplitViewSwitch->setChecked(GeneralSettings::useTabForSwitchingSplitView());
+ m_limitFolderPanelToHome->setChecked(GeneralSettings::limitFolderPanelToHome());
loadSortingChoiceSettings();
}