Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
55bd2977
Commit
55bd2977
authored
Feb 03, 2010
by
Robert Loehning
Browse files
Added "Open with" menu to FolderNavigationWidget.
parent
3a463fc3
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/plugins/projectexplorer/foldernavigationwidget.cpp
View file @
55bd2977
...
...
@@ -284,6 +284,14 @@ void FolderNavigationWidget::contextMenuEvent(QContextMenuEvent *ev)
actionExplorer
->
setEnabled
(
hasCurrentItem
);
QAction
*
actionTerminal
=
menu
.
addAction
(
msgTerminalAction
());
actionTerminal
->
setEnabled
(
hasCurrentItem
);
// open with...
if
(
!
m_fileSystemModel
->
isDir
(
current
))
{
QMenu
*
openWith
=
menu
.
addMenu
(
tr
(
"Open with"
));
ProjectExplorerPlugin
::
populateOpenWithMenu
(
openWith
,
m_fileSystemModel
->
filePath
(
current
));
}
// Open file dialog to choose a path starting from current
QAction
*
actionChooseFolder
=
menu
.
addAction
(
tr
(
"Choose folder..."
));
// Sync checkable action
...
...
@@ -319,6 +327,8 @@ void FolderNavigationWidget::contextMenuEvent(QContextMenuEvent *ev)
showInGraphicalShell
(
this
,
m_fileSystemModel
->
filePath
(
current
));
return
;
}
ProjectExplorerPlugin
::
openEditorFromAction
(
action
,
m_fileSystemModel
->
filePath
(
current
));
}
QString
FolderNavigationWidget
::
msgGraphicalShellAction
()
...
...
src/plugins/projectexplorer/projectexplorer.cpp
View file @
55bd2977
...
...
@@ -2025,15 +2025,14 @@ void ProjectExplorerPlugin::runConfigurationMenuTriggered(QAction *action)
setStartupProject
(
runConfiguration
->
project
());
}
void
ProjectExplorerPlugin
::
populateOpenWithMenu
()
void
ProjectExplorerPlugin
::
populateOpenWithMenu
(
QMenu
*
menu
,
const
QString
&
fileName
)
{
typedef
QList
<
Core
::
IEditorFactory
*>
EditorFactoryList
;
typedef
QList
<
Core
::
IExternalEditor
*>
ExternalEditorList
;
d
->
m_openWithM
enu
->
clear
();
m
enu
->
clear
();
bool
anyMatches
=
false
;
const
QString
fileName
=
currentNode
()
->
path
();
Core
::
ICore
*
core
=
Core
::
ICore
::
instance
();
if
(
const
Core
::
MimeType
mt
=
core
->
mimeDatabase
()
->
findByFile
(
QFileInfo
(
fileName
)))
{
...
...
@@ -2046,7 +2045,7 @@ void ProjectExplorerPlugin::populateOpenWithMenu()
foreach
(
Core
::
IEditorFactory
*
editorFactory
,
factories
)
{
// Add action to open with this very editor factory
QString
const
actionTitle
=
editorFactory
->
displayName
();
QAction
*
const
action
=
d
->
m_openWithM
enu
->
addAction
(
actionTitle
);
QAction
*
const
action
=
m
enu
->
addAction
(
actionTitle
);
action
->
setData
(
qVariantFromValue
(
editorFactory
));
// File already open in an editor -> only enable that entry since
// we currently do not support opening a file in two editors at once
...
...
@@ -2062,31 +2061,40 @@ void ProjectExplorerPlugin::populateOpenWithMenu()
}
// for editor factories
// Add all suitable external editors
foreach
(
Core
::
IExternalEditor
*
externalEditor
,
externalEditors
)
{
QAction
*
const
action
=
d
->
m_openWithM
enu
->
addAction
(
externalEditor
->
displayName
());
QAction
*
const
action
=
m
enu
->
addAction
(
externalEditor
->
displayName
());
action
->
setData
(
qVariantFromValue
(
externalEditor
));
}
}
// matches
}
d
->
m_openWithMenu
->
setEnabled
(
anyMatches
);
menu
->
setEnabled
(
anyMatches
);
}
void
ProjectExplorerPlugin
::
populateOpenWithMenu
()
{
populateOpenWithMenu
(
d
->
m_openWithMenu
,
currentNode
()
->
path
());
}
void
ProjectExplorerPlugin
::
openWithMenuTriggered
(
QAction
*
action
)
{
if
(
!
action
)
{
if
(
!
action
)
qWarning
()
<<
"ProjectExplorerPlugin::openWithMenuTriggered no action, can't happen."
;
return
;
}
else
openEditorFromAction
(
action
,
currentNode
()
->
path
());
}
void
ProjectExplorerPlugin
::
openEditorFromAction
(
QAction
*
action
,
const
QString
&
fileName
)
{
Core
::
EditorManager
*
em
=
Core
::
EditorManager
::
instance
();
const
QVariant
data
=
action
->
data
();
if
(
qVariantCanConvert
<
Core
::
IEditorFactory
*>
(
data
))
{
Core
::
IEditorFactory
*
factory
=
qVariantValue
<
Core
::
IEditorFactory
*>
(
data
);
em
->
openEditor
(
currentNode
()
->
path
()
,
factory
->
id
());
em
->
openEditor
(
fileName
,
factory
->
id
());
em
->
ensureEditorManagerVisible
();
return
;
}
if
(
qVariantCanConvert
<
Core
::
IExternalEditor
*>
(
data
))
{
Core
::
IExternalEditor
*
externalEditor
=
qVariantValue
<
Core
::
IExternalEditor
*>
(
data
);
em
->
openExternalEditor
(
currentNode
()
->
path
()
,
externalEditor
->
id
());
em
->
openExternalEditor
(
fileName
,
externalEditor
->
id
());
}
}
...
...
src/plugins/projectexplorer/projectexplorer.h
View file @
55bd2977
...
...
@@ -41,6 +41,7 @@ QT_BEGIN_NAMESPACE
class
QPoint
;
class
QAction
;
class
QComboBox
;
class
QMenu
;
QT_END_NAMESPACE
namespace
Core
{
...
...
@@ -122,6 +123,8 @@ public:
bool
saveModifiedFiles
();
void
showContextMenu
(
const
QPoint
&
globalPos
,
Node
*
node
);
static
void
populateOpenWithMenu
(
QMenu
*
menu
,
const
QString
&
fileName
);
static
void
openEditorFromAction
(
QAction
*
action
,
const
QString
&
fileName
);
//PluginInterface
bool
initialize
(
const
QStringList
&
arguments
,
QString
*
error_message
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment