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
cba54bf4
Commit
cba54bf4
authored
Mar 05, 2010
by
Lasse Holmstedt
Browse files
Disable run controls if no qml file is selected
Task-number: BAUHAUS-396 Reviewed-by: dt
parent
ed4278ab
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/plugins/projectexplorer/projectexplorer.cpp
View file @
cba54bf4
...
...
@@ -1344,6 +1344,7 @@ void ProjectExplorerPlugin::setCurrent(Project *project, QString filePath, Node
newContext
=
project
->
projectManager
()
->
projectContext
();
newLanguageID
=
project
->
projectManager
()
->
projectLanguage
();
}
core
->
removeAdditionalContext
(
oldContext
);
core
->
removeAdditionalContext
(
oldLanguageID
);
core
->
addAdditionalContext
(
newContext
);
...
...
@@ -1685,6 +1686,9 @@ void ProjectExplorerPlugin::startupProjectChanged()
if
(
previousStartupProject
)
{
disconnect
(
previousStartupProject
,
SIGNAL
(
activeTargetChanged
(
ProjectExplorer
::
Target
*
)),
this
,
SLOT
(
updateRunActions
()));
disconnect
(
previousStartupProject
->
activeTarget
()
->
activeRunConfiguration
(),
SIGNAL
(
isEnabledChanged
(
bool
)),
this
,
SLOT
(
updateRunActions
()));
foreach
(
Target
*
t
,
previousStartupProject
->
targets
())
disconnect
(
t
,
SIGNAL
(
activeRunConfigurationChanged
(
ProjectExplorer
::
RunConfiguration
*
)),
this
,
SLOT
(
updateActions
()));
...
...
@@ -1695,6 +1699,8 @@ void ProjectExplorerPlugin::startupProjectChanged()
if
(
project
)
{
connect
(
project
,
SIGNAL
(
activeTargetChanged
(
ProjectExplorer
::
Target
*
)),
this
,
SLOT
(
updateRunActions
()));
connect
(
previousStartupProject
->
activeTarget
()
->
activeRunConfiguration
(),
SIGNAL
(
isEnabledChanged
(
bool
)),
this
,
SLOT
(
updateRunActions
()));
foreach
(
Target
*
t
,
project
->
targets
())
connect
(
t
,
SIGNAL
(
activeRunConfigurationChanged
(
ProjectExplorer
::
RunConfiguration
*
)),
this
,
SLOT
(
updateActions
()));
...
...
@@ -1726,8 +1732,10 @@ void ProjectExplorerPlugin::updateRunActions()
return
;
}
bool
canRun
=
findRunControlFactory
(
project
->
activeTarget
()
->
activeRunConfiguration
(),
ProjectExplorer
::
Constants
::
RUNMODE
);
const
bool
canDebug
=
!
d
->
m_debuggingRunControl
&&
findRunControlFactory
(
project
->
activeTarget
()
->
activeRunConfiguration
(),
ProjectExplorer
::
Constants
::
DEBUGMODE
);
bool
canRun
=
findRunControlFactory
(
project
->
activeTarget
()
->
activeRunConfiguration
(),
ProjectExplorer
::
Constants
::
RUNMODE
)
&&
project
->
activeTarget
()
->
activeRunConfiguration
()
->
isEnabled
();
const
bool
canDebug
=
!
d
->
m_debuggingRunControl
&&
findRunControlFactory
(
project
->
activeTarget
()
->
activeRunConfiguration
(),
ProjectExplorer
::
Constants
::
DEBUGMODE
)
&&
project
->
activeTarget
()
->
activeRunConfiguration
()
->
isEnabled
();
const
bool
building
=
d
->
m_buildManager
->
isBuilding
();
d
->
m_runAction
->
setEnabled
(
canRun
&&
!
building
);
...
...
src/plugins/projectexplorer/runconfiguration.h
View file @
cba54bf4
...
...
@@ -79,6 +79,9 @@ public:
Target
*
target
()
const
;
signals:
void
isEnabledChanged
(
bool
value
);
protected:
RunConfiguration
(
Target
*
parent
,
const
QString
&
id
);
RunConfiguration
(
Target
*
parent
,
RunConfiguration
*
source
);
...
...
src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp
View file @
cba54bf4
...
...
@@ -32,6 +32,8 @@
#include
"qmlprojectrunconfiguration.h"
#include
"qmlprojecttarget.h"
#include
<coreplugin/mimedatabase.h>
#include
<projectexplorer/buildconfiguration.h>
#include
<coreplugin/editormanager/editormanager.h>
#include
<coreplugin/editormanager/ieditor.h>
#include
<coreplugin/icore.h>
...
...
@@ -51,7 +53,9 @@ namespace QmlProjectManager {
QmlProjectRunConfiguration
::
QmlProjectRunConfiguration
(
Internal
::
QmlProjectTarget
*
parent
)
:
ProjectExplorer
::
RunConfiguration
(
parent
,
QLatin1String
(
Constants
::
QML_RC_ID
)),
m_debugServerAddress
(
"127.0.0.1"
),
m_debugServerPort
(
Constants
::
QML_DEFAULT_DEBUG_SERVER_PORT
)
m_debugServerPort
(
Constants
::
QML_DEFAULT_DEBUG_SERVER_PORT
),
m_usingCurrentFile
(
false
),
m_isEnabled
(
false
)
{
ctor
();
}
...
...
@@ -67,8 +71,24 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(Internal::QmlProjectTarge
ctor
();
}
bool
QmlProjectRunConfiguration
::
isEnabled
(
ProjectExplorer
::
BuildConfiguration
*
bc
)
const
{
Q_UNUSED
(
bc
);
if
(
!
QFile
::
exists
(
mainScript
())
||
!
Core
::
ICore
::
instance
()
->
mimeDatabase
()
->
findByFile
(
mainScript
()).
matchesType
(
QLatin1String
(
"application/x-qml"
)))
{
return
false
;
}
return
true
;
}
void
QmlProjectRunConfiguration
::
ctor
()
{
Core
::
EditorManager
*
em
=
Core
::
EditorManager
::
instance
();
connect
(
em
,
SIGNAL
(
currentEditorChanged
(
Core
::
IEditor
*
)),
this
,
SLOT
(
changeCurrentFile
(
Core
::
IEditor
*
)));
setDisplayName
(
tr
(
"QML Viewer"
,
"QMLRunConfiguration display name."
));
// prepend creator/bin dir to search path (only useful for special creator-qml package)
...
...
@@ -193,14 +213,10 @@ QWidget *QmlProjectRunConfiguration::configurationWidget()
QString
QmlProjectRunConfiguration
::
mainScript
()
const
{
if
(
m_scriptFile
.
isEmpty
()
||
m_scriptFile
==
tr
(
"<Current File>"
))
{
Core
::
EditorManager
*
editorManager
=
Core
::
ICore
::
instance
()
->
editorManager
();
if
(
Core
::
IEditor
*
editor
=
editorManager
->
currentEditor
())
{
return
editor
->
file
()
->
fileName
();
}
}
if
(
m_usingCurrentFile
)
return
m_currentFileFilename
;
return
qmlTarget
()
->
qmlProject
()
->
projectDir
().
absoluteFilePath
(
m_s
criptFile
)
;
return
m_mainS
criptFile
name
;
}
void
QmlProjectRunConfiguration
::
onDebugServerAddressChanged
()
...
...
@@ -212,6 +228,15 @@ void QmlProjectRunConfiguration::onDebugServerAddressChanged()
void
QmlProjectRunConfiguration
::
setMainScript
(
const
QString
&
scriptFile
)
{
m_scriptFile
=
scriptFile
;
if
(
m_scriptFile
.
isEmpty
()
||
m_scriptFile
==
CURRENT_FILE
)
{
m_usingCurrentFile
=
true
;
changeCurrentFile
(
Core
::
EditorManager
::
instance
()
->
currentEditor
());
}
else
{
m_usingCurrentFile
=
false
;
m_mainScriptFilename
=
qmlTarget
()
->
qmlProject
()
->
projectDir
().
absoluteFilePath
(
scriptFile
);
setEnabled
(
true
);
}
}
void
QmlProjectRunConfiguration
::
onViewerChanged
()
...
...
@@ -250,11 +275,32 @@ bool QmlProjectRunConfiguration::fromMap(const QVariantMap &map)
{
m_qmlViewerCustomPath
=
map
.
value
(
QLatin1String
(
Constants
::
QML_VIEWER_KEY
)).
toString
();
m_qmlViewerArgs
=
map
.
value
(
QLatin1String
(
Constants
::
QML_VIEWER_ARGUMENTS_KEY
)).
toString
();
m_scriptFile
=
map
.
value
(
QLatin1String
(
Constants
::
QML_MAINSCRIPT_KEY
),
tr
(
"<Current File>"
)
).
toString
();
m_scriptFile
=
map
.
value
(
QLatin1String
(
Constants
::
QML_MAINSCRIPT_KEY
),
CURRENT_FILE
).
toString
();
m_debugServerPort
=
map
.
value
(
QLatin1String
(
Constants
::
QML_DEBUG_SERVER_PORT_KEY
),
Constants
::
QML_DEFAULT_DEBUG_SERVER_PORT
).
toUInt
();
m_debugServerAddress
=
map
.
value
(
QLatin1String
(
Constants
::
QML_DEBUG_SERVER_ADDRESS_KEY
),
QLatin1String
(
"127.0.0.1"
)).
toString
();
setMainScript
(
m_scriptFile
);
return
RunConfiguration
::
fromMap
(
map
);
}
void
QmlProjectRunConfiguration
::
changeCurrentFile
(
Core
::
IEditor
*
editor
)
{
if
(
m_usingCurrentFile
)
{
bool
enable
=
false
;
if
(
editor
)
{
m_currentFileFilename
=
editor
->
file
()
->
fileName
();
if
(
Core
::
ICore
::
instance
()
->
mimeDatabase
()
->
findByFile
(
mainScript
()).
matchesType
(
QLatin1String
(
"application/x-qml"
)))
enable
=
true
;
}
setEnabled
(
enable
);
}
}
void
QmlProjectRunConfiguration
::
setEnabled
(
bool
value
)
{
m_isEnabled
=
value
;
emit
isEnabledChanged
(
m_isEnabled
);
}
}
// namespace QmlProjectManager
src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.h
View file @
cba54bf4
...
...
@@ -33,13 +33,20 @@
#include
"qmlprojectmanager_global.h"
#include
<projectexplorer/runconfiguration.h>
namespace
Core
{
class
IEditor
;
}
namespace
QmlProjectManager
{
namespace
Internal
{
class
QmlProjectTarget
;
class
QmlProjectRunConfigurationFactory
;
}
const
char
*
const
CURRENT_FILE
=
QT_TRANSLATE_NOOP
(
"QmlManager"
,
"<Current File>"
);
class
QMLPROJECTMANAGER_EXPORT
QmlProjectRunConfiguration
:
public
ProjectExplorer
::
RunConfiguration
{
Q_OBJECT
...
...
@@ -51,6 +58,8 @@ public:
Internal
::
QmlProjectTarget
*
qmlTarget
()
const
;
bool
isEnabled
(
ProjectExplorer
::
BuildConfiguration
*
bc
)
const
;
QString
viewerPath
()
const
;
QStringList
viewerArguments
()
const
;
QString
workingDirectory
()
const
;
...
...
@@ -63,8 +72,10 @@ public:
QVariantMap
toMap
()
const
;
private
slots
:
void
changeCurrentFile
(
Core
::
IEditor
*
);
QString
mainScript
()
const
;
void
setMainScript
(
const
QString
&
scriptFile
);
void
onViewerChanged
();
void
onViewerArgsChanged
();
void
onDebugServerAddressChanged
();
...
...
@@ -73,16 +84,26 @@ private slots:
protected:
QmlProjectRunConfiguration
(
Internal
::
QmlProjectTarget
*
parent
,
QmlProjectRunConfiguration
*
source
);
virtual
bool
fromMap
(
const
QVariantMap
&
map
);
void
setEnabled
(
bool
value
);
private:
void
ctor
();
// absolute path to current file (if being used)
QString
m_currentFileFilename
;
// absolute path to selected main script (if being used)
QString
m_mainScriptFilename
;
QString
m_scriptFile
;
QString
m_qmlViewerCustomPath
;
QString
m_qmlViewerDefaultPath
;
QString
m_qmlViewerArgs
;
QString
m_debugServerAddress
;
uint
m_debugServerPort
;
bool
m_usingCurrentFile
;
bool
m_isEnabled
;
};
}
// namespace QmlProjectManager
...
...
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