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 ...@@ -28,7 +28,7 @@ import org.kde.private.desktopcontainment.folder 0.1 as Folder
FocusScope { FocusScope {
id: folderViewLayerComponent 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 Component folderViewDialogComponent: Qt.createComponent("FolderViewDialog.qml", Qt.Asynchronous, root)
property Item view: folderView property Item view: folderView
......
...@@ -1611,6 +1611,11 @@ void FolderModel::createActions() ...@@ -1611,6 +1611,11 @@ void FolderModel::createActions()
refresh->setShortcut(QKeySequence(QKeySequence::Refresh)); refresh->setShortcut(QKeySequence(QKeySequence::Refresh));
connect(refresh, &QAction::triggered, this, &FolderModel::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 *rename = KStandardAction::renameFile(this, &FolderModel::requestRename, this);
QAction *trash = KStandardAction::moveToTrash(this, &FolderModel::moveSelectedToTrash, this); QAction *trash = KStandardAction::moveToTrash(this, &FolderModel::moveSelectedToTrash, this);
...@@ -1637,6 +1642,7 @@ void FolderModel::createActions() ...@@ -1637,6 +1642,7 @@ void FolderModel::createActions()
m_actionCollection.addAction(QStringLiteral("del"), del); m_actionCollection.addAction(QStringLiteral("del"), del);
m_actionCollection.addAction(QStringLiteral("restoreFromTrash"), restoreFromTrash); m_actionCollection.addAction(QStringLiteral("restoreFromTrash"), restoreFromTrash);
m_actionCollection.addAction(QStringLiteral("emptyTrash"), emptyTrash); m_actionCollection.addAction(QStringLiteral("emptyTrash"), emptyTrash);
m_actionCollection.addAction(QStringLiteral("create_dir"), newDirAction);
m_newMenu = new KNewFileMenu(&m_actionCollection, QStringLiteral("newMenu"), this); m_newMenu = new KNewFileMenu(&m_actionCollection, QStringLiteral("newMenu"), this);
m_newMenu->setModal(false); m_newMenu->setModal(false);
...@@ -2112,3 +2118,8 @@ void FolderModel::undoTextChanged(const QString &text) ...@@ -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 ...@@ -248,6 +248,7 @@ class FOLDERPLUGIN_TESTS_EXPORT FolderModel : public QSortFilterProxyModel, publ
Q_INVOKABLE void openSelected(); Q_INVOKABLE void openSelected();
Q_INVOKABLE void undo(); Q_INVOKABLE void undo();
Q_INVOKABLE void refresh(); Q_INVOKABLE void refresh();
Q_INVOKABLE void createFolder();
void setScreen(int screen); 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