]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix disabling of DolphinNewFileMenu
authorElvis Angelaccio <elvis.angelaccio@kde.org>
Sun, 7 Oct 2018 11:19:17 +0000 (13:19 +0200)
committerElvis Angelaccio <elvis.angelaccio@kde.org>
Sun, 7 Oct 2018 13:43:34 +0000 (15:43 +0200)
Summary:
Commit e133c4557ecc37ed3f7e1b9 doesn't work because the actions in the
KNewFileMenu are added only when we show the context menu for the first
time.

Fixes the failing test cases in D16005.

Test Plan: Run `dolphinmainwindowtest` and open the context menu in different places (Home, Root, Trash, `bluetooth:/`, etc.)

Reviewers: #dolphin

Subscribers: kfm-devel

Tags: #dolphin

Differential Revision: https://phabricator.kde.org/D16006

src/dolphinmainwindow.cpp

index a93405f537aa240db46f30f7d11ea2d61ac9aba2..38537d92a9edc4d52cf2e73a69398975c62383cd 100644 (file)
@@ -457,10 +457,6 @@ void DolphinMainWindow::updateNewMenu()
     m_newFileMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->hiddenFilesShown());
     m_newFileMenu->checkUpToDate();
     m_newFileMenu->setPopupFiles(activeViewContainer()->url());
-
-    // If we're in the trash, also disable all the 'create new' items
-    // TODO: remove this once https://phabricator.kde.org/T8234 is implemented
-    slotWriteStateChanged(m_activeViewContainer->view()->url().scheme() != QLatin1String("trash"));
 }
 
 void DolphinMainWindow::createDirectory()
@@ -808,10 +804,9 @@ void DolphinMainWindow::slotHandleUrlStatFinished(KJob* job)
 
 void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable)
 {
-    const auto actions = m_newFileMenu->menu()->actions();
-    for (auto menuItem : actions) {
-        menuItem->setEnabled(isFolderWritable);
-    }
+    // trash:/ is writable but we don't want to create new items in it.
+    // TODO: remove the trash check once https://phabricator.kde.org/T8234 is implemented
+    newFileMenu()->setEnabled(isFolderWritable && m_activeViewContainer->url().scheme() != QLatin1String("trash"));
 }
 
 void DolphinMainWindow::openContextMenu(const QPoint& pos,