]> cloud.milkyroute.net Git - dolphin.git/commitdiff
[FoldersPanel] Don't show 'Limit to Home Directory' in the view context menu
authorElvis Angelaccio <elvis.angelaccio@kde.org>
Sun, 10 Mar 2019 11:37:25 +0000 (12:37 +0100)
committerElvis Angelaccio <elvis.angelaccio@kde.org>
Sun, 10 Mar 2019 11:37:25 +0000 (12:37 +0100)
The `viewContextMenuRequested` signal is emitted without a valid
KFileItem, so `m_fileItem` will always be null in `TreeViewContextMenu::open()`.

src/panels/folders/treeviewcontextmenu.cpp

index bf97c6d8fcb274d4fc9a79069d36fd2b6b0e6942..f8cb0b4d65573f94a3b340cb0b2451412ac973b4 100644 (file)
@@ -123,15 +123,17 @@ void TreeViewContextMenu::open()
     popup->addAction(showHiddenFilesAction);
     connect(showHiddenFilesAction, &QAction::toggled, this, &TreeViewContextMenu::setShowHiddenFiles);
 
-    // insert 'Limit to Home Directory'
-    const QUrl url = m_fileItem.url();
-    const bool enableLimitToHomeDirectory = url.isLocalFile();
-    QAction* limitFoldersPanelToHomeAction = new QAction(i18nc("@action:inmenu", "Limit to Home Directory"), this);
-    limitFoldersPanelToHomeAction->setCheckable(true);
-    limitFoldersPanelToHomeAction->setEnabled(enableLimitToHomeDirectory);
-    limitFoldersPanelToHomeAction->setChecked(m_parent->limitFoldersPanelToHome());
-    popup->addAction(limitFoldersPanelToHomeAction);
-    connect(limitFoldersPanelToHomeAction, &QAction::toggled, this, &TreeViewContextMenu::setLimitFoldersPanelToHome);
+    if (!m_fileItem.isNull()) {
+        // insert 'Limit to Home Directory'
+        const QUrl url = m_fileItem.url();
+        const bool enableLimitToHomeDirectory = url.isLocalFile();
+        QAction* limitFoldersPanelToHomeAction = new QAction(i18nc("@action:inmenu", "Limit to Home Directory"), this);
+        limitFoldersPanelToHomeAction->setCheckable(true);
+        limitFoldersPanelToHomeAction->setEnabled(enableLimitToHomeDirectory);
+        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);