mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
## Summary
* Adds a "Copy location" item, after the "Copy" Context item and Edit Menu, which will attempt to copy the path of the fist item into clipboard. ## Reasoning Most File Managers have this option through one or another way. Also using the default Copy option often results in different behaviour depending on the target software, Konsole will take the path. Other Programs will use the URI. Which ultimately could lead to non optimal User Experience. ## Notes * Should the target file **not** be on a local hard drive, this fallback to using the remote URL, feedback is wanted on that matter. FEATURE: 407004
This commit is contained in:
parent
d1baf3398e
commit
86e3b82efb
|
@ -392,9 +392,12 @@ void DolphinContextMenu::insertDefaultItemActions(const KFileItemListProperties&
|
|||
{
|
||||
const KActionCollection* collection = m_mainWindow->actionCollection();
|
||||
|
||||
// Insert 'Cut', 'Copy' and 'Paste'
|
||||
// Insert 'Cut', 'Copy', 'Copy location' and 'Paste'
|
||||
addAction(collection->action(KStandardAction::name(KStandardAction::Cut)));
|
||||
addAction(collection->action(KStandardAction::name(KStandardAction::Copy)));
|
||||
QAction* copyPathAction = collection->action(QString("copy_location"));
|
||||
copyPathAction->setEnabled(m_selectedItems.size() == 1);
|
||||
addAction(copyPathAction);
|
||||
addAction(createPasteAction());
|
||||
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("duplicate")));
|
||||
|
||||
|
|
|
@ -1129,6 +1129,7 @@ void DolphinMainWindow::updateControlMenu()
|
|||
|
||||
// Add "Edit" actions
|
||||
bool added = addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Undo)), menu) |
|
||||
addActionToMenu(ac->action(QString("copy_location")), menu) |
|
||||
addActionToMenu(ac->action(QStringLiteral("copy_to_inactive_split_view")), menu) |
|
||||
addActionToMenu(ac->action(QStringLiteral("move_to_inactive_split_view")), menu) |
|
||||
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::SelectAll)), menu) |
|
||||
|
@ -1911,6 +1912,7 @@ void DolphinMainWindow::updateFileAndEditActions()
|
|||
QAction* addToPlacesAction = col->action(QStringLiteral("add_to_places"));
|
||||
QAction* copyToOtherViewAction = col->action(QStringLiteral("copy_to_inactive_split_view"));
|
||||
QAction* moveToOtherViewAction = col->action(QStringLiteral("move_to_inactive_split_view"));
|
||||
QAction* copyLocation = col->action(QString("copy_location"));
|
||||
|
||||
if (list.isEmpty()) {
|
||||
stateChanged(QStringLiteral("has_no_selection"));
|
||||
|
@ -1918,6 +1920,7 @@ void DolphinMainWindow::updateFileAndEditActions()
|
|||
addToPlacesAction->setEnabled(true);
|
||||
copyToOtherViewAction->setEnabled(false);
|
||||
moveToOtherViewAction->setEnabled(false);
|
||||
copyLocation->setEnabled(false);
|
||||
} else {
|
||||
stateChanged(QStringLiteral("has_selection"));
|
||||
|
||||
|
@ -1959,6 +1962,7 @@ void DolphinMainWindow::updateFileAndEditActions()
|
|||
deleteAction->setEnabled(capabilitiesSource.supportsDeleting());
|
||||
deleteWithTrashShortcut->setEnabled(capabilitiesSource.supportsDeleting() && !enableMoveToTrash);
|
||||
cutAction->setEnabled(capabilitiesSource.supportsMoving());
|
||||
copyLocation->setEnabled(list.length() == 1);
|
||||
showTarget->setEnabled(list.length() == 1 && list.at(0).isLink());
|
||||
duplicateAction->setEnabled(capabilitiesSource.supportsWriting());
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
|
||||
<kpartgui name="dolphin" version="31">
|
||||
<kpartgui name="dolphin" version="32">
|
||||
<MenuBar>
|
||||
<Menu name="file">
|
||||
<Action name="new_menu" />
|
||||
|
@ -20,6 +20,15 @@
|
|||
<Action name="properties" />
|
||||
</Menu>
|
||||
<Menu name="edit">
|
||||
<Action name="edit_undo" />
|
||||
<Separator />
|
||||
<Action name="edit_cut" />
|
||||
<Action name="edit_copy" />
|
||||
<Action name="copy_location" />
|
||||
<Action name="edit_paste" />
|
||||
<Separator />
|
||||
<Action name="edit_find" />
|
||||
<Separator />
|
||||
<Action name="copy_to_inactive_split_view" />
|
||||
<Action name="move_to_inactive_split_view" />
|
||||
<Action name="edit_select_all" />
|
||||
|
|
|
@ -1949,3 +1949,21 @@ void DolphinView::forceUrlsSelection(const QUrl& current, const QList<QUrl>& sel
|
|||
markUrlAsCurrent(current);
|
||||
markUrlsAsSelected(selected);
|
||||
}
|
||||
|
||||
void DolphinView::copyPathToClipboard()
|
||||
{
|
||||
const KFileItemList list = selectedItems();
|
||||
if (list.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
const KFileItem& item = list.at(0);
|
||||
QString path = item.localPath();
|
||||
if (path.isEmpty()) {
|
||||
path = item.url().toDisplayString();
|
||||
}
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
if (clipboard == nullptr) {
|
||||
return;
|
||||
}
|
||||
clipboard->setText(path);
|
||||
}
|
||||
|
|
|
@ -390,6 +390,11 @@ public slots:
|
|||
*/
|
||||
void pasteIntoFolder();
|
||||
|
||||
/**
|
||||
* Copies the path of the first selected KFileItem into Clipboard.
|
||||
*/
|
||||
void copyPathToClipboard();
|
||||
|
||||
/**
|
||||
* Creates duplicates of selected items, appending "copy"
|
||||
* to the end.
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include <KNewFileMenu>
|
||||
#include <KPropertiesDialog>
|
||||
#include <KProtocolManager>
|
||||
|
||||
#include <QMenu>
|
||||
#include <QPointer>
|
||||
|
||||
|
@ -156,6 +155,17 @@ void DolphinViewActionHandler::createActions()
|
|||
m_actionCollection->setDefaultShortcuts(propertiesAction, {Qt::ALT + Qt::Key_Return, Qt::ALT + Qt::Key_Enter});
|
||||
connect(propertiesAction, &QAction::triggered, this, &DolphinViewActionHandler::slotProperties);
|
||||
|
||||
QAction *copyPathAction = m_actionCollection->addAction( QStringLiteral("copy_location") );
|
||||
copyPathAction->setText(i18nc("@action:incontextmenu", "Copy location"));
|
||||
copyPathAction->setWhatsThis(i18nc("@info:whatsthis copy_location",
|
||||
"This will copy the path of the first selected item into the clipboard."
|
||||
));
|
||||
|
||||
copyPathAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy")));
|
||||
m_actionCollection->setDefaultShortcuts(copyPathAction, {Qt::CTRL + Qt::SHIFT + Qt::Key_C});
|
||||
connect(copyPathAction, &QAction::triggered, this, &DolphinViewActionHandler::slotCopyPath);
|
||||
|
||||
|
||||
// View menu
|
||||
KToggleAction* iconsAction = iconsModeAction();
|
||||
KToggleAction* compactAction = compactModeAction();
|
||||
|
@ -709,3 +719,8 @@ void DolphinViewActionHandler::slotProperties()
|
|||
dialog->raise();
|
||||
dialog->activateWindow();
|
||||
}
|
||||
|
||||
void DolphinViewActionHandler::slotCopyPath()
|
||||
{
|
||||
m_currentView->copyPathToClipboard();
|
||||
}
|
||||
|
|
|
@ -219,6 +219,11 @@ private Q_SLOTS:
|
|||
*/
|
||||
void slotProperties();
|
||||
|
||||
/**
|
||||
* Copies the path of the first selected KFileItem into Clipboard.
|
||||
*/
|
||||
void slotCopyPath();
|
||||
|
||||
private:
|
||||
/**
|
||||
* Create all the actions.
|
||||
|
|
Loading…
Reference in a new issue