Commit d7bcf6de authored by Derek Christ's avatar Derek Christ Committed by Nate Graham
Browse files

Fix create-folder-shortcut (F10)

The create folder shortcut worked as long as the user did not right-
click into an empty space on the desktop to invoke the context menu.

The problem was that the create-folder-action was set to not visible
so that it is not shown in the context menu. But as soon as the context
menu is opened, the action is set to not visible in the plasmoid
contextual action list. The reason it works before opening the menu is
because the action for the plasmoid is created without setting it to
not visible.

This commit fixes the bug by using an already existing workaround class
that uses an event filter to respond to the
KStandardShortcut::createFolder key sequence.

BUG: 443512


(cherry picked from commit 12350fb1)
parent 1ebc4a5c
......@@ -1004,9 +1004,14 @@ FocusScope {
onDeleteFile: {
dir.deleteSelected();
}
onRenameFile: {
rename();
}
onCreateFolder: {
model.createFolder();
}
}
Keys.onPressed: {
......
......@@ -17,7 +17,7 @@ import org.kde.private.desktopcontainment.folder 0.1 as Folder
FocusScope {
id: folderViewLayerComponent
property variant sharedActions: ["newMenu", "paste", "undo", "refresh", "emptyTrash", "create_dir"]
property variant sharedActions: ["newMenu", "paste", "undo", "refresh", "emptyTrash"]
property Component folderViewDialogComponent: Qt.createComponent("FolderViewDialog.qml", Qt.Asynchronous, root)
property Item view: folderView
......
......@@ -1597,11 +1597,6 @@ void FolderModel::createActions()
refresh->setShortcut(QKeySequence(QKeySequence::Refresh));
connect(refresh, &QAction::triggered, this, &FolderModel::refresh);
QAction *newDirAction = new QAction(QIcon::fromTheme(QStringLiteral("create_dir")), i18n("&Create Folder"), this);
m_actionCollection.setDefaultShortcut(newDirAction, KStandardShortcut::createFolder().last());
newDirAction->setVisible(false);
connect(newDirAction, &QAction::triggered, this, &FolderModel::createFolder);
QAction *rename = KStandardAction::renameFile(this, &FolderModel::requestRename, this);
QAction *trash = KStandardAction::moveToTrash(this, &FolderModel::moveSelectedToTrash, this);
RemoveAction *remove = new RemoveAction(&m_actionCollection, this);
......@@ -1630,7 +1625,6 @@ void FolderModel::createActions()
m_actionCollection.addAction(QStringLiteral("del"), del);
m_actionCollection.addAction(QStringLiteral("restoreFromTrash"), restoreFromTrash);
m_actionCollection.addAction(QStringLiteral("emptyTrash"), emptyTrash);
m_actionCollection.addAction(QStringLiteral("create_dir"), newDirAction);
// The RemoveAction needs to be updated after adding all actions to the actionCollection
remove->update();
......
......@@ -34,6 +34,8 @@ bool ShortCut::eventFilter(QObject *obj, QEvent *e)
Q_EMIT renameFile();
} else if (KStandardShortcut::moveToTrash().contains(QKeySequence(keyInt))) {
Q_EMIT moveToTrash();
} else if (KStandardShortcut::createFolder().contains(QKeySequence(keyInt))) {
Q_EMIT createFolder();
}
}
......
......@@ -34,6 +34,7 @@ Q_SIGNALS:
void deleteFile();
void renameFile();
void moveToTrash();
void createFolder();
protected:
bool eventFilter(QObject *obj, QEvent *e) override;
......
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