forked from qt-creator/qt-creator
Add some actions to folders in the project tree.
"Show in Finder", "Add new file...", "Add existing files...".
This commit is contained in:
@@ -426,6 +426,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
|||||||
cmd = am->registerAction(m_showInFinder, ProjectExplorer::Constants::SHOWINFINDER,
|
cmd = am->registerAction(m_showInFinder, ProjectExplorer::Constants::SHOWINFINDER,
|
||||||
globalcontext);
|
globalcontext);
|
||||||
mfilec->addAction(cmd, Constants::G_FILE_OPEN);
|
mfilec->addAction(cmd, Constants::G_FILE_OPEN);
|
||||||
|
mfolder->addAction(cmd, Constants::G_FOLDER_FILES);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Open With menu
|
// Open With menu
|
||||||
@@ -592,6 +593,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
|||||||
globalcontext);
|
globalcontext);
|
||||||
mproject->addAction(cmd, Constants::G_PROJECT_FILES);
|
mproject->addAction(cmd, Constants::G_PROJECT_FILES);
|
||||||
msubProject->addAction(cmd, Constants::G_PROJECT_FILES);
|
msubProject->addAction(cmd, Constants::G_PROJECT_FILES);
|
||||||
|
mfolder->addAction(cmd, Constants::G_FOLDER_FILES);
|
||||||
|
|
||||||
// add existing file action
|
// add existing file action
|
||||||
m_addExistingFilesAction = new QAction(tr("Add Existing Files..."), this);
|
m_addExistingFilesAction = new QAction(tr("Add Existing Files..."), this);
|
||||||
@@ -599,6 +601,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
|||||||
globalcontext);
|
globalcontext);
|
||||||
mproject->addAction(cmd, Constants::G_PROJECT_FILES);
|
mproject->addAction(cmd, Constants::G_PROJECT_FILES);
|
||||||
msubProject->addAction(cmd, Constants::G_PROJECT_FILES);
|
msubProject->addAction(cmd, Constants::G_PROJECT_FILES);
|
||||||
|
mfolder->addAction(cmd, Constants::G_FOLDER_FILES);
|
||||||
|
|
||||||
// remove file action
|
// remove file action
|
||||||
m_removeFileAction = new QAction(tr("Remove File..."), this);
|
m_removeFileAction = new QAction(tr("Remove File..."), this);
|
||||||
@@ -1676,9 +1679,9 @@ void ProjectExplorerPlugin::updateContextMenuActions()
|
|||||||
|
|
||||||
void ProjectExplorerPlugin::addNewFile()
|
void ProjectExplorerPlugin::addNewFile()
|
||||||
{
|
{
|
||||||
if (!m_currentNode && m_currentNode->nodeType() == ProjectNodeType)
|
QTC_ASSERT(m_currentNode, return)
|
||||||
return;
|
QFileInfo fi(m_currentNode->path());
|
||||||
const QString location = QFileInfo(m_currentNode->path()).dir().absolutePath();
|
const QString location = (fi.isDir() ? fi.absoluteFilePath() : fi.absolutePath());
|
||||||
Core::ICore::instance()->showNewItemDialog(tr("New File", "Title of dialog"),
|
Core::ICore::instance()->showNewItemDialog(tr("New File", "Title of dialog"),
|
||||||
Core::IWizard::wizardsOfKind(Core::IWizard::FileWizard)
|
Core::IWizard::wizardsOfKind(Core::IWizard::FileWizard)
|
||||||
+ Core::IWizard::wizardsOfKind(Core::IWizard::ClassWizard),
|
+ Core::IWizard::wizardsOfKind(Core::IWizard::ClassWizard),
|
||||||
@@ -1687,11 +1690,12 @@ void ProjectExplorerPlugin::addNewFile()
|
|||||||
|
|
||||||
void ProjectExplorerPlugin::addExistingFiles()
|
void ProjectExplorerPlugin::addExistingFiles()
|
||||||
{
|
{
|
||||||
if (!m_currentNode && m_currentNode->nodeType() == ProjectNodeType)
|
QTC_ASSERT(m_currentNode, return)
|
||||||
return;
|
|
||||||
ProjectNode *projectNode = qobject_cast<ProjectNode*>(m_currentNode);
|
ProjectNode *projectNode = qobject_cast<ProjectNode*>(m_currentNode->projectNode());
|
||||||
Core::ICore *core = Core::ICore::instance();
|
Core::ICore *core = Core::ICore::instance();
|
||||||
const QString dir = QFileInfo(m_currentNode->path()).dir().absolutePath();
|
QFileInfo fi(m_currentNode->path());
|
||||||
|
const QString dir = (fi.isDir() ? fi.absoluteFilePath() : fi.absolutePath());
|
||||||
QStringList fileNames = QFileDialog::getOpenFileNames(core->mainWindow(), tr("Add Existing Files"), dir);
|
QStringList fileNames = QFileDialog::getOpenFileNames(core->mainWindow(), tr("Add Existing Files"), dir);
|
||||||
if (fileNames.isEmpty())
|
if (fileNames.isEmpty())
|
||||||
return;
|
return;
|
||||||
@@ -1741,8 +1745,7 @@ void ProjectExplorerPlugin::addExistingFiles()
|
|||||||
|
|
||||||
void ProjectExplorerPlugin::openFile()
|
void ProjectExplorerPlugin::openFile()
|
||||||
{
|
{
|
||||||
if (!m_currentNode)
|
QTC_ASSERT(m_currentNode, return)
|
||||||
return;
|
|
||||||
Core::EditorManager *em = Core::EditorManager::instance();
|
Core::EditorManager *em = Core::EditorManager::instance();
|
||||||
em->openEditor(m_currentNode->path());
|
em->openEditor(m_currentNode->path());
|
||||||
em->ensureEditorManagerVisible();
|
em->ensureEditorManagerVisible();
|
||||||
@@ -1751,8 +1754,7 @@ void ProjectExplorerPlugin::openFile()
|
|||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
void ProjectExplorerPlugin::showInFinder()
|
void ProjectExplorerPlugin::showInFinder()
|
||||||
{
|
{
|
||||||
if (!m_currentNode)
|
QTC_ASSERT(m_currentNode, return)
|
||||||
return;
|
|
||||||
QProcess::execute("/usr/bin/osascript", QStringList()
|
QProcess::execute("/usr/bin/osascript", QStringList()
|
||||||
<< "-e"
|
<< "-e"
|
||||||
<< QString("tell application \"Finder\" to reveal POSIX file \"%1\"")
|
<< QString("tell application \"Finder\" to reveal POSIX file \"%1\"")
|
||||||
@@ -1765,8 +1767,7 @@ void ProjectExplorerPlugin::showInFinder()
|
|||||||
|
|
||||||
void ProjectExplorerPlugin::removeFile()
|
void ProjectExplorerPlugin::removeFile()
|
||||||
{
|
{
|
||||||
if (!m_currentNode && m_currentNode->nodeType() == FileNodeType)
|
QTC_ASSERT(m_currentNode && m_currentNode->nodeType() == FileNodeType, return)
|
||||||
return;
|
|
||||||
|
|
||||||
FileNode *fileNode = qobject_cast<FileNode*>(m_currentNode);
|
FileNode *fileNode = qobject_cast<FileNode*>(m_currentNode);
|
||||||
Core::ICore *core = Core::ICore::instance();
|
Core::ICore *core = Core::ICore::instance();
|
||||||
|
Reference in New Issue
Block a user