forked from qt-creator/qt-creator
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:
@@ -240,6 +240,18 @@ void AndroidManifestEditorWidget::initializePage()
|
|||||||
m_targetLineEdit->installEventFilter(this);
|
m_targetLineEdit->installEventFilter(this);
|
||||||
formLayout->addRow(tr("Run:"), m_targetLineEdit);
|
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();
|
auto iconLayout = new QHBoxLayout();
|
||||||
|
|
||||||
createDPIButton(iconLayout,
|
createDPIButton(iconLayout,
|
||||||
@@ -297,6 +309,9 @@ void AndroidManifestEditorWidget::initializePage()
|
|||||||
this, setDirtyFunc);
|
this, setDirtyFunc);
|
||||||
connect(m_targetLineEdit, &QComboBox::currentTextChanged,
|
connect(m_targetLineEdit, &QComboBox::currentTextChanged,
|
||||||
this, setDirtyFunc);
|
this, setDirtyFunc);
|
||||||
|
connect(m_styleExtractMethod,
|
||||||
|
QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
|
this, setDirtyFunc);
|
||||||
|
|
||||||
connect(m_masterIconButton, &QAbstractButton::clicked,
|
connect(m_masterIconButton, &QAbstractButton::clicked,
|
||||||
this, &AndroidManifestEditorWidget::setMasterIcon);
|
this, &AndroidManifestEditorWidget::setMasterIcon);
|
||||||
@@ -804,11 +819,21 @@ void AndroidManifestEditorWidget::syncToWidgets(const QDomDocument &doc)
|
|||||||
|
|
||||||
QDomElement metadataElem = activityElem.firstChildElement(QLatin1String("meta-data"));
|
QDomElement metadataElem = activityElem.firstChildElement(QLatin1String("meta-data"));
|
||||||
|
|
||||||
|
const int parseItemsCount = 2;
|
||||||
|
int counter = 0;
|
||||||
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->setEditText(metadataElem.attribute(QLatin1String("android:value")));
|
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"));
|
metadataElem = metadataElem.nextSiblingElement(QLatin1String("meta-data"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1093,15 +1118,24 @@ bool AndroidManifestEditorWidget::parseMetaData(QXmlStreamReader &reader, QXmlSt
|
|||||||
{
|
{
|
||||||
Q_ASSERT(reader.isStartElement());
|
Q_ASSERT(reader.isStartElement());
|
||||||
|
|
||||||
bool found = false;
|
const int parseItemsCount = 2;
|
||||||
|
int counter = 0;
|
||||||
QXmlStreamAttributes attributes = reader.attributes();
|
QXmlStreamAttributes attributes = reader.attributes();
|
||||||
QXmlStreamAttributes result;
|
QXmlStreamAttributes result;
|
||||||
|
QStringList keys;
|
||||||
|
QStringList values;
|
||||||
|
|
||||||
if (attributes.value(QLatin1String("android:name")) == QLatin1String("android.app.lib_name")) {
|
if (attributes.value(QLatin1String("android:name")) == QLatin1String("android.app.lib_name")) {
|
||||||
QStringList keys = QStringList("android:value");
|
keys = QStringList("android:value");
|
||||||
QStringList values = QStringList(m_targetLineEdit->currentText());
|
values = QStringList(m_targetLineEdit->currentText());
|
||||||
result = modifyXmlStreamAttributes(attributes, keys, values);
|
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 {
|
} else {
|
||||||
result = attributes;
|
result = attributes;
|
||||||
}
|
}
|
||||||
@@ -1114,7 +1148,7 @@ bool AndroidManifestEditorWidget::parseMetaData(QXmlStreamReader &reader, QXmlSt
|
|||||||
while (!reader.atEnd()) {
|
while (!reader.atEnd()) {
|
||||||
if (reader.isEndElement()) {
|
if (reader.isEndElement()) {
|
||||||
writer.writeCurrentToken(reader);
|
writer.writeCurrentToken(reader);
|
||||||
return found;
|
return counter == parseItemsCount;
|
||||||
} else if (reader.isStartElement()) {
|
} else if (reader.isStartElement()) {
|
||||||
parseUnknownElement(reader, writer);
|
parseUnknownElement(reader, writer);
|
||||||
} else {
|
} else {
|
||||||
@@ -1122,7 +1156,7 @@ bool AndroidManifestEditorWidget::parseMetaData(QXmlStreamReader &reader, QXmlSt
|
|||||||
}
|
}
|
||||||
reader.readNext();
|
reader.readNext();
|
||||||
}
|
}
|
||||||
return found; // should never be reached
|
return counter == parseItemsCount; // should never be reached
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidManifestEditorWidget::parseUsesSdk(QXmlStreamReader &reader, QXmlStreamWriter & writer)
|
void AndroidManifestEditorWidget::parseUsesSdk(QXmlStreamReader &reader, QXmlStreamWriter & writer)
|
||||||
|
@@ -189,6 +189,7 @@ private:
|
|||||||
QLineEdit *m_appNameLineEdit;
|
QLineEdit *m_appNameLineEdit;
|
||||||
QLineEdit *m_activityNameLineEdit;
|
QLineEdit *m_activityNameLineEdit;
|
||||||
QComboBox *m_targetLineEdit;
|
QComboBox *m_targetLineEdit;
|
||||||
|
QComboBox *m_styleExtractMethod;
|
||||||
QToolButton *m_masterIconButton;
|
QToolButton *m_masterIconButton;
|
||||||
QToolButton *m_lIconButton;
|
QToolButton *m_lIconButton;
|
||||||
QToolButton *m_lIconClearButton;
|
QToolButton *m_lIconClearButton;
|
||||||
|
Reference in New Issue
Block a user