Android: remove app lib_name field from the manifest editor UI

This field is supposed to hold the name for the *.so lib that
contains the main() function, ideally it shouldn't be edited by
the user, because some users might use the field to set an invalid
name or use the app's human readable name which is wrong.

Change-Id: Ie7feb79d6231d1785c29754ed277e057181e9ca0
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Assam Boudjelthia
2021-04-20 15:00:00 +03:00
parent 3340fa88e4
commit 03712d6a92
2 changed files with 2 additions and 64 deletions

View File

@@ -404,12 +404,6 @@ QGroupBox *Android::Internal::AndroidManifestEditorWidget::createApplicationGrou
m_activityNameLineEdit = new QLineEdit(applicationGroupBox);
formLayout->addRow(tr("Activity name:"), m_activityNameLineEdit);
m_targetLineEdit = new QComboBox(applicationGroupBox);
m_targetLineEdit->setEditable(true);
m_targetLineEdit->setDuplicatesEnabled(true);
m_targetLineEdit->installEventFilter(this);
formLayout->addRow(tr("Run:"), m_targetLineEdit);
m_styleExtractMethod = new QComboBox(applicationGroupBox);
formLayout->addRow(tr("Style extraction:"), m_styleExtractMethod);
const QList<QStringList> styleMethodsMap = {
@@ -467,8 +461,6 @@ QGroupBox *Android::Internal::AndroidManifestEditorWidget::createApplicationGrou
this, [this]() { setDirty(); });
connect(m_activityNameLineEdit, &QLineEdit::textEdited,
this, [this]() { setDirty(); });
connect(m_targetLineEdit, &QComboBox::currentTextChanged,
this, [this]() { setDirty(); });
connect(m_styleExtractMethod,
QOverload<int>::of(&QComboBox::currentIndexChanged),
this, [this]() { setDirty(); });
@@ -532,16 +524,6 @@ void AndroidManifestEditorWidget::initializePage()
insertWidget(Source, m_textEditorWidget);
}
bool AndroidManifestEditorWidget::eventFilter(QObject *obj, QEvent *event)
{
if (obj == m_targetLineEdit) {
if (event->type() == QEvent::FocusIn)
QTimer::singleShot(0, this, &AndroidManifestEditorWidget::updateTargetComboBox);
}
return QWidget::eventFilter(obj, event);
}
void AndroidManifestEditorWidget::focusInEvent(QFocusEvent *event)
{
if (currentWidget()) {
@@ -552,30 +534,6 @@ void AndroidManifestEditorWidget::focusInEvent(QFocusEvent *event)
}
}
void AndroidManifestEditorWidget::updateTargetComboBox()
{
QStringList items;
if (Target *target = androidTarget(m_textEditorWidget->textDocument()->filePath())) {
ProjectNode *root = target->project()->rootProjectNode();
root->forEachProjectNode([&items](const ProjectNode *projectNode) {
items << projectNode->targetApplications();
});
items.sort();
}
// 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::updateAfterFileLoad()
{
QString error;
@@ -877,11 +835,7 @@ void AndroidManifestEditorWidget::syncToWidgets(const QDomDocument &doc)
enum SplashImageParseGuard {splashNone = 0, splash = 1, portraitSplash = 2, landscapeSplash = 4, splashDone = 8};
int splashParseGuard = SplashImageParseGuard::splashNone;
while (!metadataElem.isNull()) {
if (metadataElem.attribute(QLatin1String("android:name")) == QLatin1String("android.app.lib_name")
&& !(activityParseGuard & ActivityParseGuard::libName)) {
m_targetLineEdit->setEditText(metadataElem.attribute(QLatin1String("android:value")));
activityParseGuard |= ActivityParseGuard::libName;
} else if (metadataElem.attribute(QLatin1String("android:name"))
if (metadataElem.attribute(QLatin1String("android:name"))
== QLatin1String("android.app.extract_android_style")
&& !(activityParseGuard & ActivityParseGuard::styleExtract)) {
m_styleExtractMethod->setCurrentText(
@@ -1392,13 +1346,6 @@ void AndroidManifestEditorWidget::parseActivity(QXmlStreamReader &reader, QXmlSt
while (!reader.atEnd()) {
if (reader.isEndElement()) {
parseSplashScreen(writer);
if (!found) {
writer.writeEmptyElement(QLatin1String("meta-data"));
writer.writeAttribute(QLatin1String("android:name"),
QLatin1String("android.app.lib_name"));
writer.writeAttribute(QLatin1String("android:value"),
m_targetLineEdit->currentText());
}
writer.writeCurrentToken(reader);
return;
} else if (reader.isStartElement()) {
@@ -1429,12 +1376,7 @@ bool AndroidManifestEditorWidget::parseMetaData(QXmlStreamReader &reader, QXmlSt
QStringList keys;
QStringList values;
if (attributes.value(QLatin1String("android:name")) == QLatin1String("android.app.lib_name")) {
keys = QStringList("android:value");
values = QStringList(m_targetLineEdit->currentText());
result = modifyXmlStreamAttributes(attributes, keys, values);
found = true;
} else if (attributes.value(QLatin1String("android:name"))
if (attributes.value(QLatin1String("android:name"))
== QLatin1String("android.app.extract_android_style")) {
keys = QStringList("android:value");
values = QStringList(m_styleExtractMethod->currentText());

View File

@@ -115,7 +115,6 @@ signals:
void guiChanged();
protected:
bool eventFilter(QObject *obj, QEvent *event) override;
void focusInEvent(QFocusEvent *event) override;
private:
@@ -142,8 +141,6 @@ private:
void setInvalidServiceInfo();
void clearInvalidServiceInfo();
void updateTargetComboBox();
void parseManifest(QXmlStreamReader &reader, QXmlStreamWriter &writer);
void parseApplication(QXmlStreamReader &reader, QXmlStreamWriter &writer);
void parseSplashScreen(QXmlStreamWriter &writer);
@@ -181,7 +178,6 @@ private:
// Application
QLineEdit *m_appNameLineEdit;
QLineEdit *m_activityNameLineEdit;
QComboBox *m_targetLineEdit;
QComboBox *m_styleExtractMethod;
QComboBox *m_screenOrientation;
AndroidManifestEditorIconContainerWidget *m_iconButtons;