forked from qt-creator/qt-creator
Copy filename to clipboard as extension to Copy full path to clipboard.
Change-Id: I832c58b670e6957f839caa01d15dc2c3ce01df5d Reviewed-by: Eike Ziller <eike.ziller@digia.com> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com>
This commit is contained in:
committed by
Eike Ziller
parent
78081ecb49
commit
ab70e6c27e
@@ -317,10 +317,12 @@ void EditorToolBar::listContextMenu(QPoint pos)
|
|||||||
DocumentModel::Entry *entry = EditorManager::documentModel()->documentAtRow(
|
DocumentModel::Entry *entry = EditorManager::documentModel()->documentAtRow(
|
||||||
d->m_editorList->currentIndex());
|
d->m_editorList->currentIndex());
|
||||||
QString fileName = entry ? entry->fileName() : QString();
|
QString fileName = entry ? entry->fileName() : QString();
|
||||||
if (fileName.isEmpty())
|
QString shortFileName = entry ? QFileInfo(fileName).fileName() : QString();
|
||||||
|
if (fileName.isEmpty() || shortFileName.isEmpty())
|
||||||
return;
|
return;
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
QAction *copyPath = menu.addAction(tr("Copy Full Path to Clipboard"));
|
QAction *copyPath = menu.addAction(tr("Copy Full Path to Clipboard"));
|
||||||
|
QAction *copyFileName = menu.addAction(tr("Copy File Name to Clipboard"));
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
EditorManager::addSaveAndCloseEditorActions(&menu, entry);
|
EditorManager::addSaveAndCloseEditorActions(&menu, entry);
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
@@ -328,6 +330,8 @@ void EditorToolBar::listContextMenu(QPoint pos)
|
|||||||
QAction *result = menu.exec(d->m_editorList->mapToGlobal(pos));
|
QAction *result = menu.exec(d->m_editorList->mapToGlobal(pos));
|
||||||
if (result == copyPath)
|
if (result == copyPath)
|
||||||
QApplication::clipboard()->setText(QDir::toNativeSeparators(fileName));
|
QApplication::clipboard()->setText(QDir::toNativeSeparators(fileName));
|
||||||
|
if (result == copyFileName)
|
||||||
|
QApplication::clipboard()->setText(shortFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorToolBar::makeEditorWritable()
|
void EditorToolBar::makeEditorWritable()
|
||||||
|
|||||||
Reference in New Issue
Block a user