Commit b4f3a883 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

[Folder View] Let Alt+Enter open properties dialog

This is what Dolphin does. The shortcut is hardcoded here and also common on other platforms.

BUG: 389862
FIXED-IN: 5.13.0

Differential Revision: https://phabricator.kde.org/D10316
parent 85b4344e
......@@ -862,8 +862,14 @@ FocusScope {
Behavior on contentX { id: smoothX; enabled: false; SmoothedAnimation { velocity: 700 } }
Behavior on contentY { id: smoothY; enabled: false; SmoothedAnimation { velocity: 700 } }
Keys.onReturnPressed: runOrCdSelected()
Keys.onEnterPressed: runOrCdSelected()
Keys.onReturnPressed: {
if (event.modifiers === Qt.AltModifier) {
dir.openPropertiesDialog();
} else {
runOrCdSelected();
}
}
Keys.onEnterPressed: Keys.returnPressed(event)
Keys.onMenuPressed: {
if (currentIndex != -1 && dir.hasSelection() && currentItem) {
......
......@@ -1773,9 +1773,7 @@ void FolderModel::openContextMenu(QQuickItem *visualParent)
if (KPropertiesDialog::canDisplay(items)) {
QAction *act = new QAction(menu);
act->setText(i18n("&Properties"));
QObject::connect(act, &QAction::triggered, [this, items]() {
KPropertiesDialog::showDialog(items, nullptr, false /*non modal*/);
});
QObject::connect(act, &QAction::triggered, this, &FolderModel::openPropertiesDialog);
menu->addAction(act);
}
......@@ -1790,6 +1788,29 @@ void FolderModel::openContextMenu(QQuickItem *visualParent)
connect(menu, &QMenu::aboutToHide, [menu]() { menu->deleteLater(); });
}
void FolderModel::openPropertiesDialog()
{
const QModelIndexList indexes = m_selectionModel->selectedIndexes();
if (indexes.isEmpty()) {
return;
}
KFileItemList items;
items.reserve(indexes.count());
for (const QModelIndex &index : indexes) {
KFileItem item = itemForIndex(index);
if (!item.isNull()) {
items.append(item);
}
}
if (!KPropertiesDialog::canDisplay(items)) {
return;
}
KPropertiesDialog::showDialog(items, nullptr, false /*non modal*/);
}
void FolderModel::linkHere(const QUrl &sourceUrl)
{
KIO::CopyJob *job = KIO::link(sourceUrl, m_dirModel->dirLister()->url());
......
......@@ -229,6 +229,8 @@ class FOLDERPLUGIN_TESTS_EXPORT FolderModel : public QSortFilterProxyModel, publ
Q_INVOKABLE void linkHere(const QUrl &sourceUrl);
Q_INVOKABLE void openPropertiesDialog();
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
int indexForUrl(const QUrl &url) const;
KFileItem itemForIndex(const QModelIndex &index) const;
......
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