forked from qt-creator/qt-creator
Android: re-organize manifest editor widget
The current manifest editor has too many things at once with a long scroll bar, that can be overwhelming, this changes that by re-organizing elements and grouping others. Change-Id: Ie997af475939effbc575fa9e2a1d20184e943ff1 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -64,7 +64,6 @@
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QFormLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QImage>
|
||||
#include <QLabel>
|
||||
@@ -134,162 +133,10 @@ AndroidManifestEditorWidget::AndroidManifestEditorWidget()
|
||||
this, &AndroidManifestEditorWidget::updateAfterFileLoad);
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::initializePage()
|
||||
QGroupBox *AndroidManifestEditorWidget::createPermissionsGroupBox(QWidget *parent)
|
||||
{
|
||||
QWidget *mainWidget = new QWidget; // different name
|
||||
|
||||
auto topLayout = new QVBoxLayout(mainWidget);
|
||||
|
||||
auto packageGroupBox = new QGroupBox(mainWidget);
|
||||
topLayout->addWidget(packageGroupBox);
|
||||
|
||||
auto setDirtyFunc = [this] { setDirty(); };
|
||||
packageGroupBox->setTitle(tr("Package"));
|
||||
{
|
||||
auto formLayout = new QFormLayout();
|
||||
|
||||
m_packageNameLineEdit = new QLineEdit(packageGroupBox);
|
||||
m_packageNameLineEdit->setToolTip(tr(
|
||||
"<p align=\"justify\">Please choose a valid package name "
|
||||
"for your application (for example, \"org.example.myapplication\").</p>"
|
||||
"<p align=\"justify\">Packages are usually defined using a hierarchical naming pattern, "
|
||||
"with levels in the hierarchy separated by periods (.) (pronounced \"dot\").</p>"
|
||||
"<p align=\"justify\">In general, a package name begins with the top level domain name"
|
||||
" of the organization and then the organization's domain and then any subdomains listed"
|
||||
" in reverse order. The organization can then choose a specific name for their package."
|
||||
" Package names should be all lowercase characters whenever possible.</p>"
|
||||
"<p align=\"justify\">Complete conventions for disambiguating package names and rules for"
|
||||
" naming packages when the Internet domain name cannot be directly used as a package name"
|
||||
" are described in section 7.7 of the Java Language Specification.</p>"));
|
||||
formLayout->addRow(tr("Package name:"), m_packageNameLineEdit);
|
||||
|
||||
m_packageNameWarning = new QLabel;
|
||||
m_packageNameWarning->setText(tr("The package name is not valid."));
|
||||
m_packageNameWarning->setVisible(false);
|
||||
|
||||
m_packageNameWarningIcon = new QLabel;
|
||||
m_packageNameWarningIcon->setPixmap(Utils::Icons::WARNING.pixmap());
|
||||
m_packageNameWarningIcon->setVisible(false);
|
||||
m_packageNameWarningIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
|
||||
auto warningRow = new QHBoxLayout;
|
||||
warningRow->setContentsMargins(0, 0, 0, 0);
|
||||
warningRow->addWidget(m_packageNameWarningIcon);
|
||||
warningRow->addWidget(m_packageNameWarning);
|
||||
|
||||
formLayout->addRow(QString(), warningRow);
|
||||
|
||||
m_versionCodeLineEdit = new QLineEdit(packageGroupBox);
|
||||
formLayout->addRow(tr("Version code:"), m_versionCodeLineEdit);
|
||||
|
||||
m_versionNameLinedit = new QLineEdit(packageGroupBox);
|
||||
formLayout->addRow(tr("Version name:"), m_versionNameLinedit);
|
||||
|
||||
m_androidMinSdkVersion = new QComboBox(packageGroupBox);
|
||||
m_androidMinSdkVersion->setToolTip(
|
||||
tr("Sets the minimum required version on which this application can be run."));
|
||||
m_androidMinSdkVersion->addItem(tr("Not set"), 0);
|
||||
|
||||
formLayout->addRow(tr("Minimum required SDK:"), m_androidMinSdkVersion);
|
||||
|
||||
m_androidTargetSdkVersion = new QComboBox(packageGroupBox);
|
||||
m_androidTargetSdkVersion->setToolTip(
|
||||
tr("Sets the target SDK. Set this to the highest tested version. "
|
||||
"This disables compatibility behavior of the system for your application."));
|
||||
m_androidTargetSdkVersion->addItem(tr("Not set"), 0);
|
||||
|
||||
formLayout->addRow(tr("Target SDK:"), m_androidTargetSdkVersion);
|
||||
|
||||
packageGroupBox->setLayout(formLayout);
|
||||
|
||||
updateSdkVersions();
|
||||
|
||||
connect(m_packageNameLineEdit, &QLineEdit::textEdited,
|
||||
this, &AndroidManifestEditorWidget::setPackageName);
|
||||
connect(m_versionCodeLineEdit, &QLineEdit::textEdited,
|
||||
this, setDirtyFunc);
|
||||
connect(m_versionNameLinedit, &QLineEdit::textEdited,
|
||||
this, setDirtyFunc);
|
||||
connect(m_androidMinSdkVersion,
|
||||
QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this, setDirtyFunc);
|
||||
connect(m_androidTargetSdkVersion,
|
||||
QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this, setDirtyFunc);
|
||||
|
||||
}
|
||||
|
||||
// Application
|
||||
auto applicationGroupBox = new QGroupBox(mainWidget);
|
||||
topLayout->addWidget(applicationGroupBox);
|
||||
|
||||
applicationGroupBox->setTitle(tr("Application"));
|
||||
{
|
||||
auto formLayout = new QFormLayout();
|
||||
|
||||
m_appNameLineEdit = new QLineEdit(applicationGroupBox);
|
||||
formLayout->addRow(tr("Application name:"), m_appNameLineEdit);
|
||||
|
||||
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 = {
|
||||
{"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).first());
|
||||
m_styleExtractMethod->setItemData(i, styleMethodsMap.at(i).at(1), Qt::ToolTipRole);
|
||||
}
|
||||
|
||||
m_iconButtons = new AndroidManifestEditorIconContainerWidget(applicationGroupBox, m_textEditorWidget);
|
||||
formLayout->addRow(tr("Application icon:"), new QLabel());
|
||||
formLayout->addRow(QString(), m_iconButtons);
|
||||
|
||||
m_splashButtons = new SplashIconContainerWidget(applicationGroupBox, m_textEditorWidget);
|
||||
formLayout->addRow(tr("Splash screen:"), new QLabel());
|
||||
formLayout->addRow(QString(), m_splashButtons);
|
||||
|
||||
m_services = new AndroidServiceWidget(this);
|
||||
formLayout->addRow(tr("Android services:"), m_services);
|
||||
|
||||
applicationGroupBox->setLayout(formLayout);
|
||||
|
||||
connect(m_appNameLineEdit, &QLineEdit::textEdited,
|
||||
this, setDirtyFunc);
|
||||
connect(m_activityNameLineEdit, &QLineEdit::textEdited,
|
||||
this, setDirtyFunc);
|
||||
connect(m_targetLineEdit, &QComboBox::currentTextChanged,
|
||||
this, setDirtyFunc);
|
||||
connect(m_styleExtractMethod,
|
||||
QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this, setDirtyFunc);
|
||||
connect(m_services, &AndroidServiceWidget::servicesModified,
|
||||
this, setDirtyFunc);
|
||||
connect(m_splashButtons, &SplashIconContainerWidget::splashScreensModified,
|
||||
this, setDirtyFunc);
|
||||
connect(m_services, &AndroidServiceWidget::servicesModified,
|
||||
this, &AndroidManifestEditorWidget::clearInvalidServiceInfo);
|
||||
connect(m_services, &AndroidServiceWidget::servicesInvalid,
|
||||
this, &AndroidManifestEditorWidget::setInvalidServiceInfo);
|
||||
}
|
||||
|
||||
|
||||
// Permissions
|
||||
auto permissionsGroupBox = new QGroupBox(mainWidget);
|
||||
topLayout->addWidget(permissionsGroupBox);
|
||||
|
||||
auto permissionsGroupBox = new QGroupBox(parent);
|
||||
permissionsGroupBox->setTitle(tr("Permissions"));
|
||||
{
|
||||
auto layout = new QGridLayout(permissionsGroupBox);
|
||||
|
||||
m_defaultPermissonsCheckBox = new QCheckBox(this);
|
||||
@@ -463,9 +310,174 @@ void AndroidManifestEditorWidget::initializePage()
|
||||
this, &AndroidManifestEditorWidget::removePermission);
|
||||
connect(m_permissionsComboBox, &QComboBox::currentTextChanged,
|
||||
this, &AndroidManifestEditorWidget::updateAddRemovePermissionButtons);
|
||||
|
||||
return permissionsGroupBox;
|
||||
}
|
||||
|
||||
topLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::MinimumExpanding));
|
||||
QGroupBox *AndroidManifestEditorWidget::createPackageFormLayout(QWidget *parent)
|
||||
{
|
||||
auto packageGroupBox = new QGroupBox(parent);
|
||||
packageGroupBox->setTitle(tr("Package"));
|
||||
auto formLayout = new QFormLayout();
|
||||
|
||||
m_packageNameLineEdit = new QLineEdit(packageGroupBox);
|
||||
m_packageNameLineEdit->setToolTip(tr(
|
||||
"<p align=\"justify\">Please choose a valid package name for your application (for "
|
||||
"example, \"org.example.myapplication\").</p><p align=\"justify\">Packages are usually "
|
||||
"defined using a hierarchical naming pattern, with levels in the hierarchy separated "
|
||||
"by periods (.) (pronounced \"dot\").</p><p align=\"justify\">In general, a package "
|
||||
"name begins with the top level domain name of the organization and then the "
|
||||
"organization's domain and then any subdomains listed in reverse order. The "
|
||||
"organization can then choose a specific name for their package. Package names should "
|
||||
"be all lowercase characters whenever possible.</p><p align=\"justify\">Complete "
|
||||
"conventions for disambiguating package names and rules for naming packages when the "
|
||||
"Internet domain name cannot be directly used as a package name are described in "
|
||||
"section 7.7 of the Java Language Specification.</p>"));
|
||||
formLayout->addRow(tr("Package name:"), m_packageNameLineEdit);
|
||||
|
||||
m_packageNameWarning = new QLabel;
|
||||
m_packageNameWarning->setText(tr("The package name is not valid."));
|
||||
m_packageNameWarning->setVisible(false);
|
||||
|
||||
m_packageNameWarningIcon = new QLabel;
|
||||
m_packageNameWarningIcon->setPixmap(Utils::Icons::WARNING.pixmap());
|
||||
m_packageNameWarningIcon->setVisible(false);
|
||||
m_packageNameWarningIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
|
||||
auto warningRow = new QHBoxLayout;
|
||||
warningRow->setContentsMargins(0, 0, 0, 0);
|
||||
warningRow->addWidget(m_packageNameWarningIcon);
|
||||
warningRow->addWidget(m_packageNameWarning);
|
||||
|
||||
formLayout->addRow(QString(), warningRow);
|
||||
|
||||
m_versionCodeLineEdit = new QLineEdit(packageGroupBox);
|
||||
formLayout->addRow(tr("Version code:"), m_versionCodeLineEdit);
|
||||
|
||||
m_versionNameLinedit = new QLineEdit(packageGroupBox);
|
||||
formLayout->addRow(tr("Version name:"), m_versionNameLinedit);
|
||||
|
||||
m_androidMinSdkVersion = new QComboBox(packageGroupBox);
|
||||
m_androidMinSdkVersion->setToolTip(
|
||||
tr("Sets the minimum required version on which this application can be run."));
|
||||
m_androidMinSdkVersion->addItem(tr("Not set"), 0);
|
||||
|
||||
formLayout->addRow(tr("Minimum required SDK:"), m_androidMinSdkVersion);
|
||||
|
||||
m_androidTargetSdkVersion = new QComboBox(packageGroupBox);
|
||||
m_androidTargetSdkVersion->setToolTip(
|
||||
tr("Sets the target SDK. Set this to the highest tested version. "
|
||||
"This disables compatibility behavior of the system for your application."));
|
||||
m_androidTargetSdkVersion->addItem(tr("Not set"), 0);
|
||||
|
||||
formLayout->addRow(tr("Target SDK:"), m_androidTargetSdkVersion);
|
||||
|
||||
packageGroupBox->setLayout(formLayout);
|
||||
|
||||
updateSdkVersions();
|
||||
|
||||
connect(m_packageNameLineEdit, &QLineEdit::textEdited,
|
||||
this, &AndroidManifestEditorWidget::setPackageName);
|
||||
connect(m_versionCodeLineEdit, &QLineEdit::textEdited,
|
||||
this, [this]() { setDirty(); });
|
||||
connect(m_versionNameLinedit, &QLineEdit::textEdited,
|
||||
this, [this]() { setDirty(); });
|
||||
connect(m_androidMinSdkVersion,
|
||||
QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this, [this]() { setDirty(); });
|
||||
connect(m_androidTargetSdkVersion,
|
||||
QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this, [this]() { setDirty(); });
|
||||
|
||||
return packageGroupBox;
|
||||
}
|
||||
|
||||
QGroupBox *Android::Internal::AndroidManifestEditorWidget::createApplicationGroupBox(QWidget *parent)
|
||||
{
|
||||
auto applicationGroupBox = new QGroupBox(parent);
|
||||
applicationGroupBox->setTitle(tr("Application"));
|
||||
auto formLayout = new QFormLayout();
|
||||
|
||||
m_appNameLineEdit = new QLineEdit(applicationGroupBox);
|
||||
formLayout->addRow(tr("Application name:"), m_appNameLineEdit);
|
||||
|
||||
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 = {
|
||||
{"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).first());
|
||||
m_styleExtractMethod->setItemData(i, styleMethodsMap.at(i).at(1), Qt::ToolTipRole);
|
||||
}
|
||||
applicationGroupBox->setLayout(formLayout);
|
||||
|
||||
connect(m_appNameLineEdit, &QLineEdit::textEdited,
|
||||
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(); });
|
||||
|
||||
return applicationGroupBox;
|
||||
}
|
||||
|
||||
QGroupBox *AndroidManifestEditorWidget::createAdvancedGroupBox(QWidget *parent)
|
||||
{
|
||||
auto otherGroupBox = new QGroupBox(parent);
|
||||
otherGroupBox->setTitle(tr("Advanced"));
|
||||
m_advanvedTabWidget = new QTabWidget(otherGroupBox);
|
||||
auto formLayout = new QFormLayout();
|
||||
|
||||
m_iconButtons = new AndroidManifestEditorIconContainerWidget(otherGroupBox, m_textEditorWidget);
|
||||
m_advanvedTabWidget->addTab(m_iconButtons, tr("Application icon"));
|
||||
|
||||
m_services = new AndroidServiceWidget(otherGroupBox);
|
||||
m_advanvedTabWidget->addTab(m_services, tr("Android services"));
|
||||
|
||||
m_splashButtons = new SplashIconContainerWidget(otherGroupBox, m_textEditorWidget);
|
||||
m_advanvedTabWidget->addTab(m_splashButtons, tr("Splash screen"));
|
||||
|
||||
connect(m_services, &AndroidServiceWidget::servicesModified, this, [this]() { setDirty(); });
|
||||
connect(m_services, &AndroidServiceWidget::servicesModified,
|
||||
this, &AndroidManifestEditorWidget::clearInvalidServiceInfo);
|
||||
connect(m_services, &AndroidServiceWidget::servicesInvalid,
|
||||
this, &AndroidManifestEditorWidget::setInvalidServiceInfo);
|
||||
connect(m_splashButtons, &SplashIconContainerWidget::splashScreensModified,
|
||||
this, [this]() { setDirty(); });
|
||||
|
||||
formLayout->addRow(m_advanvedTabWidget);
|
||||
otherGroupBox->setLayout(formLayout);
|
||||
|
||||
return otherGroupBox;
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::initializePage()
|
||||
{
|
||||
QWidget *mainWidget = new QWidget(); // different name
|
||||
auto topLayout = new QGridLayout(mainWidget);
|
||||
|
||||
topLayout->addWidget(createPackageFormLayout(mainWidget), 0, 0);
|
||||
topLayout->addWidget(createApplicationGroupBox(mainWidget), 0, 1);
|
||||
topLayout->addWidget(createPermissionsGroupBox(mainWidget), 1, 0, 1, 2);
|
||||
topLayout->addWidget(createAdvancedGroupBox(mainWidget), 2, 0, 1, 2);
|
||||
topLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::MinimumExpanding), 3, 0);
|
||||
|
||||
auto mainWidgetScrollArea = new QScrollArea;
|
||||
mainWidgetScrollArea->setWidgetResizable(true);
|
||||
@@ -575,6 +587,7 @@ bool AndroidManifestEditorWidget::setActivePage(EditorPage page)
|
||||
if (!servicesValid(m_services->services())) {
|
||||
QMessageBox::critical(nullptr, tr("Service Definition Invalid"),
|
||||
tr("Cannot switch to source when there are invalid services."));
|
||||
m_advanvedTabWidget->setCurrentIndex(1);
|
||||
return false;
|
||||
}
|
||||
syncToEditor();
|
||||
|
@@ -28,6 +28,9 @@
|
||||
#include <texteditor/texteditor.h>
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <QGroupBox>
|
||||
#include <QGridLayout>
|
||||
#include <QTabWidget>
|
||||
#include <QStackedWidget>
|
||||
#include <QTimer>
|
||||
|
||||
@@ -156,6 +159,11 @@ private:
|
||||
QString parseComment(QXmlStreamReader &reader, QXmlStreamWriter &writer);
|
||||
void parseUnknownElement(QXmlStreamReader &reader, QXmlStreamWriter &writer, bool ignore=false);
|
||||
|
||||
QGroupBox *createPermissionsGroupBox(QWidget *parent);
|
||||
QGroupBox *createPackageFormLayout(QWidget *parent);
|
||||
QGroupBox *createApplicationGroupBox(QWidget *parent);
|
||||
QGroupBox *createAdvancedGroupBox(QWidget *parent);
|
||||
|
||||
bool m_dirty; // indicates that we need to call syncToEditor()
|
||||
bool m_stayClean;
|
||||
int m_errorLine;
|
||||
@@ -192,6 +200,7 @@ private:
|
||||
TextEditor::TextEditorWidget *m_textEditorWidget;
|
||||
AndroidManifestEditor *m_editor;
|
||||
QString m_androidNdkPlatform;
|
||||
QTabWidget *m_advanvedTabWidget = nullptr;
|
||||
};
|
||||
} // namespace Internal
|
||||
} // namespace Android
|
||||
|
Reference in New Issue
Block a user