Android: allow style extraction method selection to the manifest editor

Make a bit more easier to choose the method of style extraction to
the manifest editor UI.

Task-number: QTCREATORBUG-23283
Change-Id: I65ad52f07d31913cf091ef4ef1693617ac82d4ad
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Assam Boudjelthia
2020-02-28 00:16:03 +02:00
parent daa9804699
commit b081d7dc8f
2 changed files with 42 additions and 7 deletions

View File

@@ -240,6 +240,18 @@ void AndroidManifestEditorWidget::initializePage()
m_targetLineEdit->installEventFilter(this);
formLayout->addRow(tr("Run:"), m_targetLineEdit);
m_styleExtractMethod = new QComboBox(applicationGroupBox);
formLayout->addRow(tr("Style extraction:"), m_styleExtractMethod);
QList<QStringList> styleMethodsMap = {
{"default", "In most cases this will be the same as \"full\", but it can also be something else if needed, e.g. for compatibility reasons."},
{"full", "Useful for Qt Widgets & Qt Quick Controls 1 apps."},
{"minimal", "Useful for Qt Quick Controls 2 apps, it is much faster than \"full\"."},
{"none", "Useful for apps that don't use Qt Widgets, Qt Quick Controls 1 or Qt Quick Controls 2."}};
for (int i = 0; i <styleMethodsMap.size(); ++i) {
m_styleExtractMethod->addItem(styleMethodsMap.at(i).at(0));
m_styleExtractMethod->setItemData(i, styleMethodsMap.at(i).at(1), Qt::ToolTipRole);
}
auto iconLayout = new QHBoxLayout();
createDPIButton(iconLayout,
@@ -297,6 +309,9 @@ void AndroidManifestEditorWidget::initializePage()
this, setDirtyFunc);
connect(m_targetLineEdit, &QComboBox::currentTextChanged,
this, setDirtyFunc);
connect(m_styleExtractMethod,
QOverload<int>::of(&QComboBox::currentIndexChanged),
this, setDirtyFunc);
connect(m_masterIconButton, &QAbstractButton::clicked,
this, &AndroidManifestEditorWidget::setMasterIcon);
@@ -804,11 +819,21 @@ void AndroidManifestEditorWidget::syncToWidgets(const QDomDocument &doc)
QDomElement metadataElem = activityElem.firstChildElement(QLatin1String("meta-data"));
const int parseItemsCount = 2;
int counter = 0;
while (!metadataElem.isNull()) {
if (metadataElem.attribute(QLatin1String("android:name")) == QLatin1String("android.app.lib_name")) {
m_targetLineEdit->setEditText(metadataElem.attribute(QLatin1String("android:value")));
break;
++counter;
} else if (metadataElem.attribute(QLatin1String("android:name"))
== QLatin1String("android.app.extract_android_style")) {
m_styleExtractMethod->setCurrentText(
metadataElem.attribute(QLatin1String("android:value")));
++counter;
}
if (counter == parseItemsCount)
break;
metadataElem = metadataElem.nextSiblingElement(QLatin1String("meta-data"));
}
@@ -1093,15 +1118,24 @@ bool AndroidManifestEditorWidget::parseMetaData(QXmlStreamReader &reader, QXmlSt
{
Q_ASSERT(reader.isStartElement());
bool found = false;
const int parseItemsCount = 2;
int counter = 0;
QXmlStreamAttributes attributes = reader.attributes();
QXmlStreamAttributes result;
QStringList keys;
QStringList values;
if (attributes.value(QLatin1String("android:name")) == QLatin1String("android.app.lib_name")) {
QStringList keys = QStringList("android:value");
QStringList values = QStringList(m_targetLineEdit->currentText());
keys = QStringList("android:value");
values = QStringList(m_targetLineEdit->currentText());
result = modifyXmlStreamAttributes(attributes, keys, values);
found = true;
++counter;
} else if (attributes.value(QLatin1String("android:name"))
== QLatin1String("android.app.extract_android_style")) {
keys = QStringList("android:value");
values = QStringList(m_styleExtractMethod->currentText());
result = modifyXmlStreamAttributes(attributes, keys, values);
++counter;
} else {
result = attributes;
}
@@ -1114,7 +1148,7 @@ bool AndroidManifestEditorWidget::parseMetaData(QXmlStreamReader &reader, QXmlSt
while (!reader.atEnd()) {
if (reader.isEndElement()) {
writer.writeCurrentToken(reader);
return found;
return counter == parseItemsCount;
} else if (reader.isStartElement()) {
parseUnknownElement(reader, writer);
} else {
@@ -1122,7 +1156,7 @@ bool AndroidManifestEditorWidget::parseMetaData(QXmlStreamReader &reader, QXmlSt
}
reader.readNext();
}
return found; // should never be reached
return counter == parseItemsCount; // should never be reached
}
void AndroidManifestEditorWidget::parseUsesSdk(QXmlStreamReader &reader, QXmlStreamWriter & writer)

View File

@@ -189,6 +189,7 @@ private:
QLineEdit *m_appNameLineEdit;
QLineEdit *m_activityNameLineEdit;
QComboBox *m_targetLineEdit;
QComboBox *m_styleExtractMethod;
QToolButton *m_masterIconButton;
QToolButton *m_lIconButton;
QToolButton *m_lIconClearButton;