forked from qt-creator/qt-creator
Open file with default editor when it's activated in ResourceEditor.
This patch provides more convenient way to view/edit resource files than "Open With" context menu. Change-Id: I1c1fbfe48ed069d004f900e040b6517a4064b0f1 Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
committed by
Eike Ziller
parent
9b3e46b08f
commit
dec03a0d6c
@@ -92,6 +92,7 @@ ResourceEditorW::ResourceEditorW(const Core::Context &context,
|
||||
agg->add(new Find::TreeViewFind(m_resourceEditor->treeView()));
|
||||
|
||||
m_resourceEditor->setResourceDragEnabled(true);
|
||||
m_contextMenu->addAction(tr("Open File"), this, SLOT(openCurrentFile()));
|
||||
m_openWithMenu = m_contextMenu->addMenu(tr("Open With"));
|
||||
// Below we need QueuedConnection because otherwise, if this qrc file
|
||||
// is inside of the qrc file, crashes happen when using "Open With" on it.
|
||||
@@ -106,6 +107,8 @@ ResourceEditorW::ResourceEditorW(const Core::Context &context,
|
||||
this, SLOT(onUndoStackChanged(bool,bool)));
|
||||
connect(m_resourceEditor, SIGNAL(showContextMenu(QPoint,QString)),
|
||||
this, SLOT(showContextMenu(QPoint,QString)));
|
||||
connect(m_resourceEditor, SIGNAL(itemActivated(QString)),
|
||||
this, SLOT(openFile(QString)));
|
||||
connect(m_resourceEditor->commandHistory(), SIGNAL(indexChanged(int)),
|
||||
this, SLOT(setShouldAutoSave()));
|
||||
connect(m_resourceDocument, SIGNAL(changed()), this, SIGNAL(changed()));
|
||||
@@ -280,8 +283,20 @@ void ResourceEditorW::onUndoStackChanged(bool canUndo, bool canRedo)
|
||||
void ResourceEditorW::showContextMenu(const QPoint &globalPoint, const QString &fileName)
|
||||
{
|
||||
Core::DocumentManager::populateOpenWithMenu(m_openWithMenu, fileName);
|
||||
if (!m_openWithMenu->actions().isEmpty())
|
||||
if (!m_openWithMenu->actions().isEmpty()) {
|
||||
m_currentFileName = fileName;
|
||||
m_contextMenu->popup(globalPoint);
|
||||
}
|
||||
}
|
||||
|
||||
void ResourceEditorW::openCurrentFile()
|
||||
{
|
||||
openFile(m_currentFileName);
|
||||
}
|
||||
|
||||
void ResourceEditorW::openFile(const QString &fileName)
|
||||
{
|
||||
Core::EditorManager::openEditor(fileName);
|
||||
}
|
||||
|
||||
void ResourceEditorW::onUndo()
|
||||
|
||||
Reference in New Issue
Block a user