forked from qt-creator/qt-creator
Add control for set Android manifest screenOrientation param
Android manifest have a param called screenOrientation for instruct Android to show the app in landscape mode, portrait mode and so on. This patch add a control allowing to set the preferred one by selecting from the list of all currently availables. Change-Id: Id53dd8aa1efaa603bc30b02c8a5a8db55e97e75b Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -423,6 +423,44 @@ QGroupBox *Android::Internal::AndroidManifestEditorWidget::createApplicationGrou
|
|||||||
m_styleExtractMethod->addItem(styleMethodsMap.at(i).first());
|
m_styleExtractMethod->addItem(styleMethodsMap.at(i).first());
|
||||||
m_styleExtractMethod->setItemData(i, styleMethodsMap.at(i).at(1), Qt::ToolTipRole);
|
m_styleExtractMethod->setItemData(i, styleMethodsMap.at(i).at(1), Qt::ToolTipRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_screenOrientation = new QComboBox(applicationGroupBox);
|
||||||
|
formLayout->addRow(tr("Screen orientation:"), m_screenOrientation);
|
||||||
|
// https://developer.android.com/guide/topics/manifest/activity-element#screen
|
||||||
|
const QList<QStringList> screenOrientationMap = {
|
||||||
|
{"unspecified", "The default value. The system chooses the orientation. The policy it uses, and therefore the "
|
||||||
|
"choices made in specific contexts, may differ from device to device."},
|
||||||
|
{"behind", "The same orientation as the activity that's immediately beneath it in the activity stack."},
|
||||||
|
{"landscape", "Landscape orientation (the display is wider than it is tall)."},
|
||||||
|
{"portrait", "Portrait orientation (the display is taller than it is wide)."},
|
||||||
|
{"reverseLandscape", "Landscape orientation in the opposite direction from normal landscape."},
|
||||||
|
{"reversePortrait", "Portrait orientation in the opposite direction from normal portrait."},
|
||||||
|
{"sensorLandscape", "Landscape orientation, but can be either normal or reverse landscape based on the device "
|
||||||
|
"sensor. The sensor is used even if the user has locked sensor-based rotation."},
|
||||||
|
{"sensorPortrait", "Portrait orientation, but can be either normal or reverse portrait based on the device sensor. "
|
||||||
|
"The sensor is used even if the user has locked sensor-based rotation."},
|
||||||
|
{"userLandscape", "Landscape orientation, but can be either normal or reverse landscape based on the device "
|
||||||
|
"sensor and the user's preference."},
|
||||||
|
{"userPortrait", "Portrait orientation, but can be either normal or reverse portrait based on the device sensor "
|
||||||
|
"and the user's preference."},
|
||||||
|
{"sensor", "The orientation is determined by the device orientation sensor. The orientation of the display "
|
||||||
|
"depends on how the user is holding the device; it changes when the user rotates the device. "
|
||||||
|
"Some devices, though, will not rotate to all four possible orientations, by default. To allow all four "
|
||||||
|
"orientations, use \"fullSensor\" The sensor is used even if the user locked sensor-based rotation."},
|
||||||
|
{"fullSensor", "The orientation is determined by the device orientation sensor for any of the 4 orientations. This "
|
||||||
|
"is similar to \"sensor\" except this allows any of the 4 possible screen orientations, regardless "
|
||||||
|
"of what the device will normally do (for example, some devices won't normally use reverse "
|
||||||
|
"portrait or reverse landscape, but this enables those)."},
|
||||||
|
{"nosensor", "The orientation is determined without reference to a physical orientation sensor. The sensor is "
|
||||||
|
"ignored, so the display will not rotate based on how the user moves the device."},
|
||||||
|
{"user", "The user's current preferred orientation."},
|
||||||
|
{"fullUser", "If the user has locked sensor-based rotation, this behaves the same as user, otherwise it "
|
||||||
|
"behaves the same as fullSensor and allows any of the 4 possible screen orientations."},
|
||||||
|
{"locked", "Locks the orientation to its current rotation, whatever that is."}};
|
||||||
|
for (int i = 0; i <screenOrientationMap.size(); ++i) {
|
||||||
|
m_screenOrientation->addItem(screenOrientationMap.at(i).first());
|
||||||
|
m_screenOrientation->setItemData(i, screenOrientationMap.at(i).at(1), Qt::ToolTipRole);
|
||||||
|
}
|
||||||
applicationGroupBox->setLayout(formLayout);
|
applicationGroupBox->setLayout(formLayout);
|
||||||
|
|
||||||
connect(m_appNameLineEdit, &QLineEdit::textEdited,
|
connect(m_appNameLineEdit, &QLineEdit::textEdited,
|
||||||
@@ -434,6 +472,9 @@ QGroupBox *Android::Internal::AndroidManifestEditorWidget::createApplicationGrou
|
|||||||
connect(m_styleExtractMethod,
|
connect(m_styleExtractMethod,
|
||||||
QOverload<int>::of(&QComboBox::currentIndexChanged),
|
QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
this, [this]() { setDirty(); });
|
this, [this]() { setDirty(); });
|
||||||
|
connect(m_screenOrientation,
|
||||||
|
QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
|
this, [this]() { setDirty(); });
|
||||||
|
|
||||||
return applicationGroupBox;
|
return applicationGroupBox;
|
||||||
}
|
}
|
||||||
@@ -818,6 +859,7 @@ void AndroidManifestEditorWidget::syncToWidgets(const QDomDocument &doc)
|
|||||||
|
|
||||||
QDomElement activityElem = applicationElement.firstChildElement(QLatin1String("activity"));
|
QDomElement activityElem = applicationElement.firstChildElement(QLatin1String("activity"));
|
||||||
m_activityNameLineEdit->setText(activityElem.attribute(QLatin1String("android:label")));
|
m_activityNameLineEdit->setText(activityElem.attribute(QLatin1String("android:label")));
|
||||||
|
m_screenOrientation->setCurrentText(activityElem.attribute(QLatin1String("android:screenOrientation")));
|
||||||
|
|
||||||
QString appIconValue = applicationElement.attribute(QLatin1String("android:icon"));
|
QString appIconValue = applicationElement.attribute(QLatin1String("android:icon"));
|
||||||
if (!appIconValue.isEmpty()) {
|
if (!appIconValue.isEmpty()) {
|
||||||
@@ -1309,8 +1351,8 @@ void AndroidManifestEditorWidget::parseActivity(QXmlStreamReader &reader, QXmlSt
|
|||||||
|
|
||||||
writer.writeStartElement(reader.name().toString());
|
writer.writeStartElement(reader.name().toString());
|
||||||
QXmlStreamAttributes attributes = reader.attributes();
|
QXmlStreamAttributes attributes = reader.attributes();
|
||||||
QStringList keys = { QLatin1String("android:label") };
|
QStringList keys = { QLatin1String("android:label"), QLatin1String("android:screenOrientation") };
|
||||||
QStringList values = { m_activityNameLineEdit->text() };
|
QStringList values = { m_activityNameLineEdit->text(), m_screenOrientation->currentText() };
|
||||||
QXmlStreamAttributes result = modifyXmlStreamAttributes(attributes, keys, values);
|
QXmlStreamAttributes result = modifyXmlStreamAttributes(attributes, keys, values);
|
||||||
writer.writeAttributes(result);
|
writer.writeAttributes(result);
|
||||||
|
|
||||||
|
@@ -181,6 +181,7 @@ private:
|
|||||||
QLineEdit *m_activityNameLineEdit;
|
QLineEdit *m_activityNameLineEdit;
|
||||||
QComboBox *m_targetLineEdit;
|
QComboBox *m_targetLineEdit;
|
||||||
QComboBox *m_styleExtractMethod;
|
QComboBox *m_styleExtractMethod;
|
||||||
|
QComboBox *m_screenOrientation;
|
||||||
AndroidManifestEditorIconContainerWidget *m_iconButtons;
|
AndroidManifestEditorIconContainerWidget *m_iconButtons;
|
||||||
SplashIconContainerWidget *m_splashButtons;
|
SplashIconContainerWidget *m_splashButtons;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user