diff --git a/src/plugins/resourceeditor/qrceditor/qrceditor.cpp b/src/plugins/resourceeditor/qrceditor/qrceditor.cpp index 79120d34cf7..0a3fa718109 100644 --- a/src/plugins/resourceeditor/qrceditor/qrceditor.cpp +++ b/src/plugins/resourceeditor/qrceditor/qrceditor.cpp @@ -354,6 +354,11 @@ void QrcEditor::editCurrentItem() m_treeview->edit(m_treeview->selectionModel()->currentIndex()); } +QString QrcEditor::currentResourcePath() const +{ + return m_treeview->currentResourcePath(); +} + // Slot for change of line edit content 'alias' void QrcEditor::onAliasChanged(const QString &alias) { diff --git a/src/plugins/resourceeditor/qrceditor/qrceditor.h b/src/plugins/resourceeditor/qrceditor/qrceditor.h index 0c6dea9b984..1d228f18857 100644 --- a/src/plugins/resourceeditor/qrceditor/qrceditor.h +++ b/src/plugins/resourceeditor/qrceditor/qrceditor.h @@ -68,6 +68,8 @@ public: void refresh(); void editCurrentItem(); + QString currentResourcePath() const; + signals: void dirtyChanged(bool dirty); void itemActivated(const QString &fileName); diff --git a/src/plugins/resourceeditor/qrceditor/resourcefile_p.h b/src/plugins/resourceeditor/qrceditor/resourcefile_p.h index 2794ef6946a..ffcc09025db 100644 --- a/src/plugins/resourceeditor/qrceditor/resourcefile_p.h +++ b/src/plugins/resourceeditor/qrceditor/resourcefile_p.h @@ -244,10 +244,10 @@ public: QString absolutePath(const QString &path) const { return m_resource_file.absolutePath(path); } - -private: QString relativePath(const QString &path) const { return m_resource_file.relativePath(path); } + +private: QString lastResourceOpenDirectory() const; bool renameFile(const QString &fileName, const QString &newFileName); diff --git a/src/plugins/resourceeditor/qrceditor/resourceview.cpp b/src/plugins/resourceeditor/qrceditor/resourceview.cpp index 3762981062c..ddf2d218f84 100644 --- a/src/plugins/resourceeditor/qrceditor/resourceview.cpp +++ b/src/plugins/resourceeditor/qrceditor/resourceview.cpp @@ -438,6 +438,19 @@ QString ResourceView::currentLanguage() const return m_qrcModel->lang(preindex); } +QString ResourceView::currentResourcePath() const +{ + const QModelIndex current = currentIndex(); + if (!current.isValid()) + return QString(); + + const QString alias = m_qrcModel->alias(current); + if (!alias.isEmpty()) + return QLatin1Char(':') + currentPrefix() + QLatin1Char('/') + alias; + + return QLatin1Char(':') + currentPrefix() + QLatin1Char('/') + m_qrcModel->relativePath(m_qrcModel->file(current)); +} + QString ResourceView::getCurrentValue(NodeProperty property) const { switch (property) { diff --git a/src/plugins/resourceeditor/qrceditor/resourceview.h b/src/plugins/resourceeditor/qrceditor/resourceview.h index 68ac557ee15..739c72e67d5 100644 --- a/src/plugins/resourceeditor/qrceditor/resourceview.h +++ b/src/plugins/resourceeditor/qrceditor/resourceview.h @@ -100,6 +100,7 @@ public: QString currentAlias() const; QString currentPrefix() const; QString currentLanguage() const; + QString currentResourcePath() const; void setResourceDragEnabled(bool e); bool resourceDragEnabled() const; diff --git a/src/plugins/resourceeditor/resourceeditorw.cpp b/src/plugins/resourceeditor/resourceeditorw.cpp index cb4bd0c867c..b77626ab110 100644 --- a/src/plugins/resourceeditor/resourceeditorw.cpp +++ b/src/plugins/resourceeditor/resourceeditorw.cpp @@ -52,7 +52,7 @@ #include #include #include -#include +#include namespace ResourceEditor { namespace Internal { @@ -102,7 +102,9 @@ ResourceEditorW::ResourceEditorW(const Core::Context &context, m_resourceEditor->setResourceDragEnabled(true); m_contextMenu->addAction(tr("Open File"), this, SLOT(openCurrentFile())); m_openWithMenu = m_contextMenu->addMenu(tr("Open With")); - m_renameAction = m_contextMenu->addAction(tr("Rename File..."), this, SLOT(renameCurrentFile()), Qt::Key_F2); + m_renameAction = m_contextMenu->addAction(tr("Rename File..."), this, SLOT(renameCurrentFile())); + m_copyFileNameAction = m_contextMenu->addAction(tr("Copy Resource Path to Clipboard"), this, SLOT(copyCurrentResourcePath())); + // Below we need QueuedConnection because otherwise, if this qrc file // is inside of the qrc file, crashes happen when using "Open With" on it. // (That is because this editor instance is deleted in executeOpenWithMenuAction @@ -323,6 +325,11 @@ void ResourceEditorW::renameCurrentFile() m_resourceEditor->editCurrentItem(); } +void ResourceEditorW::copyCurrentResourcePath() +{ + QApplication::clipboard()->setText(m_resourceEditor->currentResourcePath()); +} + void ResourceEditorW::onUndo() { m_resourceEditor->onUndo(); diff --git a/src/plugins/resourceeditor/resourceeditorw.h b/src/plugins/resourceeditor/resourceeditorw.h index 1342d09fc30..323426d661d 100644 --- a/src/plugins/resourceeditor/resourceeditorw.h +++ b/src/plugins/resourceeditor/resourceeditorw.h @@ -105,6 +105,7 @@ private slots: void openCurrentFile(); void openFile(const QString &fileName); void renameCurrentFile(); + void copyCurrentResourcePath(); private: const QString m_extension; @@ -121,6 +122,7 @@ private: QString m_currentFileName; QToolBar *m_toolBar; QAction *m_renameAction; + QAction *m_copyFileNameAction; public slots: void onRefresh();