forked from qt-creator/qt-creator
Android Manifest Editor: Show available targets in combobox
Task-number: QTCREATORBUG-9682 Change-Id: I0454d96ff0a1df370e0b9197ae536bf5ae632ac2 Reviewed-by: BogDan Vatra <bogdan@kde.org>
This commit is contained in:
@@ -304,6 +304,8 @@ QStringList AndroidManager::availableTargetApplications(ProjectExplorer::Target
|
|||||||
{
|
{
|
||||||
QStringList apps;
|
QStringList apps;
|
||||||
Qt4ProjectManager::Qt4Project *qt4Project = qobject_cast<Qt4ProjectManager::Qt4Project *>(target->project());
|
Qt4ProjectManager::Qt4Project *qt4Project = qobject_cast<Qt4ProjectManager::Qt4Project *>(target->project());
|
||||||
|
if (!qt4Project)
|
||||||
|
return apps;
|
||||||
foreach (Qt4ProjectManager::Qt4ProFileNode *proFile, qt4Project->applicationProFiles()) {
|
foreach (Qt4ProjectManager::Qt4ProFileNode *proFile, qt4Project->applicationProFiles()) {
|
||||||
if (proFile->projectType() == Qt4ProjectManager::ApplicationTemplate) {
|
if (proFile->projectType() == Qt4ProjectManager::ApplicationTemplate) {
|
||||||
if (proFile->targetInformation().target.startsWith(QLatin1String("lib"))
|
if (proFile->targetInformation().target.startsWith(QLatin1String("lib"))
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
#include <projectexplorer/kitinformation.h>
|
#include <projectexplorer/kitinformation.h>
|
||||||
#include <texteditor/texteditoractionhandler.h>
|
#include <texteditor/texteditoractionhandler.h>
|
||||||
|
#include <qt4projectmanager/qt4project.h>
|
||||||
|
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
@@ -233,7 +234,10 @@ void AndroidManifestEditorWidget::initializePage()
|
|||||||
m_appNameLineEdit = new QLineEdit(applicationGroupBox);
|
m_appNameLineEdit = new QLineEdit(applicationGroupBox);
|
||||||
formLayout->addRow(tr("Application name:"), m_appNameLineEdit);
|
formLayout->addRow(tr("Application name:"), m_appNameLineEdit);
|
||||||
|
|
||||||
m_targetLineEdit = new QLineEdit(applicationGroupBox);
|
m_targetLineEdit = new QComboBox(applicationGroupBox);
|
||||||
|
m_targetLineEdit->setEditable(true);
|
||||||
|
m_targetLineEdit->setDuplicatesEnabled(true);
|
||||||
|
m_targetLineEdit->installEventFilter(this);
|
||||||
formLayout->addRow(tr("Run:"), m_targetLineEdit);
|
formLayout->addRow(tr("Run:"), m_targetLineEdit);
|
||||||
|
|
||||||
QHBoxLayout *iconLayout = new QHBoxLayout();
|
QHBoxLayout *iconLayout = new QHBoxLayout();
|
||||||
@@ -265,7 +269,7 @@ void AndroidManifestEditorWidget::initializePage()
|
|||||||
|
|
||||||
connect(m_appNameLineEdit, SIGNAL(textEdited(QString)),
|
connect(m_appNameLineEdit, SIGNAL(textEdited(QString)),
|
||||||
this, SLOT(setAppName()));
|
this, SLOT(setAppName()));
|
||||||
connect(m_targetLineEdit, SIGNAL(textEdited(QString)),
|
connect(m_targetLineEdit, SIGNAL(currentTextChanged(QString)),
|
||||||
this, SLOT(setDirty()));
|
this, SLOT(setDirty()));
|
||||||
|
|
||||||
connect(m_lIconButton, SIGNAL(clicked()), SLOT(setLDPIIcon()));
|
connect(m_lIconButton, SIGNAL(clicked()), SLOT(setLDPIIcon()));
|
||||||
@@ -448,6 +452,41 @@ void AndroidManifestEditorWidget::initializePage()
|
|||||||
m_overlayWidget = mainWidget;
|
m_overlayWidget = mainWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AndroidManifestEditorWidget::eventFilter(QObject *obj, QEvent *event)
|
||||||
|
{
|
||||||
|
if (obj == m_targetLineEdit) {
|
||||||
|
if (event->type() == QEvent::FocusIn) {
|
||||||
|
QTimer::singleShot(0, this, SLOT(updateTargetComboBox()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TextEditor::PlainTextEditorWidget::eventFilter(obj, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AndroidManifestEditorWidget::updateTargetComboBox()
|
||||||
|
{
|
||||||
|
const QString docPath(static_cast<AndroidManifestDocument *>(editor()->document())->filePath());
|
||||||
|
ProjectExplorer::Project *project = androidProject(docPath);
|
||||||
|
QStringList items;
|
||||||
|
if (project) {
|
||||||
|
ProjectExplorer::Kit *kit = project->activeTarget()->kit();
|
||||||
|
if (ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(kit) == Constants::ANDROID_DEVICE_TYPE)
|
||||||
|
items = AndroidManager::availableTargetApplications(project->activeTarget());
|
||||||
|
}
|
||||||
|
|
||||||
|
// QComboBox randomly resets what the user has entered
|
||||||
|
// if all rows are removed, thus we ensure that the current text
|
||||||
|
// is not removed by first adding it and then removing all old rows
|
||||||
|
// and then adding the new rows
|
||||||
|
QString text = m_targetLineEdit->currentText();
|
||||||
|
m_targetLineEdit->addItem(text);
|
||||||
|
while (m_targetLineEdit->count() > 1)
|
||||||
|
m_targetLineEdit->removeItem(0);
|
||||||
|
items.removeDuplicates();
|
||||||
|
items.removeAll(text);
|
||||||
|
m_targetLineEdit->addItems(items);
|
||||||
|
}
|
||||||
|
|
||||||
void AndroidManifestEditorWidget::resizeEvent(QResizeEvent *event)
|
void AndroidManifestEditorWidget::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
PlainTextEditorWidget::resizeEvent(event);
|
PlainTextEditorWidget::resizeEvent(event);
|
||||||
@@ -745,7 +784,7 @@ void AndroidManifestEditorWidget::syncToWidgets(const QDomDocument &doc)
|
|||||||
QDomElement metadataElem = manifest.firstChildElement(QLatin1String("application")).firstChildElement(QLatin1String("activity")).firstChildElement(QLatin1String("meta-data"));
|
QDomElement metadataElem = manifest.firstChildElement(QLatin1String("application")).firstChildElement(QLatin1String("activity")).firstChildElement(QLatin1String("meta-data"));
|
||||||
while (!metadataElem.isNull()) {
|
while (!metadataElem.isNull()) {
|
||||||
if (metadataElem.attribute(QLatin1String("android:name")) == QLatin1String("android.app.lib_name")) {
|
if (metadataElem.attribute(QLatin1String("android:name")) == QLatin1String("android.app.lib_name")) {
|
||||||
m_targetLineEdit->setText(metadataElem.attribute(QLatin1String("android:value")));
|
m_targetLineEdit->setEditText(metadataElem.attribute(QLatin1String("android:value")));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
metadataElem = metadataElem.nextSiblingElement(QLatin1String("meta-data"));
|
metadataElem = metadataElem.nextSiblingElement(QLatin1String("meta-data"));
|
||||||
@@ -836,7 +875,9 @@ void AndroidManifestEditorWidget::syncToEditor()
|
|||||||
setUsesSdk(doc, manifest, m_androidMinSdkVersion->currentText().toInt(),
|
setUsesSdk(doc, manifest, m_androidMinSdkVersion->currentText().toInt(),
|
||||||
m_androidTargetSdkVersion->currentText().toInt());
|
m_androidTargetSdkVersion->currentText().toInt());
|
||||||
|
|
||||||
setAndroidAppLibName(doc, manifest.firstChildElement(QLatin1String("application")).firstChildElement(QLatin1String("activity")), m_targetLineEdit->text());
|
setAndroidAppLibName(doc, manifest.firstChildElement(QLatin1String("application"))
|
||||||
|
.firstChildElement(QLatin1String("activity")),
|
||||||
|
m_targetLineEdit->currentText());
|
||||||
|
|
||||||
// permissions
|
// permissions
|
||||||
QDomElement permissionElem = manifest.firstChildElement(QLatin1String("uses-permission"));
|
QDomElement permissionElem = manifest.firstChildElement(QLatin1String("uses-permission"));
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public slots:
|
|||||||
protected:
|
protected:
|
||||||
TextEditor::BaseTextEditor *createEditor();
|
TextEditor::BaseTextEditor *createEditor();
|
||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
|
bool eventFilter(QObject *obj, QEvent *event);
|
||||||
private slots:
|
private slots:
|
||||||
void setLDPIIcon();
|
void setLDPIIcon();
|
||||||
void setMDPIIcon();
|
void setMDPIIcon();
|
||||||
@@ -133,6 +133,7 @@ private:
|
|||||||
|
|
||||||
void updateInfoBar(const QString &errorMessage, int line, int column);
|
void updateInfoBar(const QString &errorMessage, int line, int column);
|
||||||
void hideInfoBar();
|
void hideInfoBar();
|
||||||
|
Q_SLOT void updateTargetComboBox();
|
||||||
|
|
||||||
bool m_dirty; // indicates that we need to call syncToEditor()
|
bool m_dirty; // indicates that we need to call syncToEditor()
|
||||||
bool m_stayClean;
|
bool m_stayClean;
|
||||||
@@ -150,7 +151,7 @@ private:
|
|||||||
|
|
||||||
// Application
|
// Application
|
||||||
QLineEdit *m_appNameLineEdit;
|
QLineEdit *m_appNameLineEdit;
|
||||||
QLineEdit *m_targetLineEdit;
|
QComboBox *m_targetLineEdit;
|
||||||
QToolButton *m_lIconButton;
|
QToolButton *m_lIconButton;
|
||||||
QToolButton *m_mIconButton;
|
QToolButton *m_mIconButton;
|
||||||
QToolButton *m_hIconButton;
|
QToolButton *m_hIconButton;
|
||||||
|
|||||||
Reference in New Issue
Block a user