Commit 59dfa775 authored by Domenico Panella's avatar Domenico Panella Committed by David Edmundson
Browse files

[folderview] Allow folder creation on desktop via F10 shortcut

BUG: 425191
parent 358f804f
......@@ -28,7 +28,7 @@ import org.kde.private.desktopcontainment.folder 0.1 as Folder
FocusScope {
id: folderViewLayerComponent
property variant sharedActions: ["newMenu", "paste", "undo", "refresh", "emptyTrash"]
property variant sharedActions: ["newMenu", "paste", "undo", "refresh", "emptyTrash", "create_dir"]
property Component folderViewDialogComponent: Qt.createComponent("FolderViewDialog.qml", Qt.Asynchronous, root)
property Item view: folderView
......
......@@ -1610,7 +1610,12 @@ void FolderModel::createActions()
QAction *refresh = new QAction(QIcon::fromTheme(QStringLiteral("view-refresh")), i18n("&Refresh View"), this);
refresh->setShortcut(QKeySequence(QKeySequence::Refresh));
connect(refresh, &QAction::triggered, this, &FolderModel::refresh);
QAction* newDirAction = new QAction(QIcon::fromTheme(QStringLiteral("create_dir")), i18n("&CreateFolder"), 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);
......@@ -1637,7 +1642,8 @@ 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);
m_newMenu = new KNewFileMenu(&m_actionCollection, QStringLiteral("newMenu"), this);
m_newMenu->setModal(false);
connect(m_newMenu, &KNewFileMenu::directoryCreated, this, &FolderModel::newFileMenuItemCreated);
......@@ -2112,3 +2118,8 @@ void FolderModel::undoTextChanged(const QString &text)
}
}
void FolderModel::createFolder()
{
m_newMenu->setPopupFiles(QList<QUrl>() << m_dirModel->dirLister()->url());
m_newMenu->createDirectory();
}
......@@ -248,6 +248,7 @@ class FOLDERPLUGIN_TESTS_EXPORT FolderModel : public QSortFilterProxyModel, publ
Q_INVOKABLE void openSelected();
Q_INVOKABLE void undo();
Q_INVOKABLE void refresh();
Q_INVOKABLE void createFolder();
void setScreen(int screen);
......
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