forked from qt-creator/qt-creator
Android: Simplify code in manifest editor
Change-Id: I1a54cc1d59b9fdf03083363cc26c25f72e893006 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -86,15 +86,15 @@ bool checkPackageName(const QString &packageName)
|
|||||||
return QRegExp(packageNameRegExp).exactMatch(packageName);
|
return QRegExp(packageNameRegExp).exactMatch(packageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
Project *androidProject(const Utils::FilePath &fileName)
|
Target *androidTarget(const Utils::FilePath &fileName)
|
||||||
{
|
{
|
||||||
for (Project *project : SessionManager::projects()) {
|
for (Project *project : SessionManager::projects()) {
|
||||||
if (!project->activeTarget())
|
if (Target *target = project->activeTarget()) {
|
||||||
continue;
|
Kit *kit = target->kit();
|
||||||
Kit *kit = project->activeTarget()->kit();
|
|
||||||
if (DeviceTypeKitAspect::deviceTypeId(kit) == Android::Constants::ANDROID_DEVICE_TYPE
|
if (DeviceTypeKitAspect::deviceTypeId(kit) == Android::Constants::ANDROID_DEVICE_TYPE
|
||||||
&& fileName.isChildOf(project->projectDirectory()))
|
&& fileName.isChildOf(project->projectDirectory()))
|
||||||
return project;
|
return target;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -489,18 +489,14 @@ void AndroidManifestEditorWidget::focusInEvent(QFocusEvent *event)
|
|||||||
|
|
||||||
void AndroidManifestEditorWidget::updateTargetComboBox()
|
void AndroidManifestEditorWidget::updateTargetComboBox()
|
||||||
{
|
{
|
||||||
Project *project = androidProject(m_textEditorWidget->textDocument()->filePath());
|
|
||||||
QStringList items;
|
QStringList items;
|
||||||
if (project) {
|
if (Target *target = androidTarget(m_textEditorWidget->textDocument()->filePath())) {
|
||||||
Kit *kit = project->activeTarget()->kit();
|
ProjectNode *root = target->project()->rootProjectNode();
|
||||||
if (DeviceTypeKitAspect::deviceTypeId(kit) == Constants::ANDROID_DEVICE_TYPE) {
|
|
||||||
ProjectNode *root = project->rootProjectNode();
|
|
||||||
root->forEachProjectNode([&items](const ProjectNode *projectNode) {
|
root->forEachProjectNode([&items](const ProjectNode *projectNode) {
|
||||||
items << projectNode->targetApplications();
|
items << projectNode->targetApplications();
|
||||||
});
|
});
|
||||||
items.sort();
|
items.sort();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// QComboBox randomly resets what the user has entered
|
// QComboBox randomly resets what the user has entered
|
||||||
// if all rows are removed, thus we ensure that the current text
|
// if all rows are removed, thus we ensure that the current text
|
||||||
@@ -606,9 +602,7 @@ void AndroidManifestEditorWidget::preSave()
|
|||||||
void AndroidManifestEditorWidget::postSave()
|
void AndroidManifestEditorWidget::postSave()
|
||||||
{
|
{
|
||||||
const Utils::FilePath docPath = m_textEditorWidget->textDocument()->filePath();
|
const Utils::FilePath docPath = m_textEditorWidget->textDocument()->filePath();
|
||||||
ProjectExplorer::Project *project = androidProject(docPath);
|
if (Target *target = androidTarget(docPath)) {
|
||||||
if (project) {
|
|
||||||
if (Target *target = project->activeTarget()) {
|
|
||||||
if (BuildConfiguration *bc = target->activeBuildConfiguration()) {
|
if (BuildConfiguration *bc = target->activeBuildConfiguration()) {
|
||||||
QString androidNdkPlatform = AndroidConfigurations::currentConfig()
|
QString androidNdkPlatform = AndroidConfigurations::currentConfig()
|
||||||
.bestNdkPlatformMatch(AndroidManager::minimumSDK(target));
|
.bestNdkPlatformMatch(AndroidManager::minimumSDK(target));
|
||||||
@@ -619,7 +613,6 @@ void AndroidManifestEditorWidget::postSave()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::IEditor *AndroidManifestEditorWidget::editor() const
|
Core::IEditor *AndroidManifestEditorWidget::editor() const
|
||||||
|
Reference in New Issue
Block a user