Commit 09ee5c74 authored by Daniel Teske's avatar Daniel Teske

AndroidManifestEditor: Split permissions and features checkbox

So that users can individually disable either the automatic adding of
permissions or features.

Change-Id: Ibf11604e8e20454b79533c1cbf3ea59bfe769e5c
Reviewed-by: default avatarEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
parent d6fbffbf
...@@ -284,20 +284,23 @@ void AndroidManifestEditorWidget::initializePage() ...@@ -284,20 +284,23 @@ void AndroidManifestEditorWidget::initializePage()
QGridLayout *layout = new QGridLayout(permissionsGroupBox); QGridLayout *layout = new QGridLayout(permissionsGroupBox);
m_defaultPermissonsCheckBox = new QCheckBox(this); m_defaultPermissonsCheckBox = new QCheckBox(this);
m_defaultPermissonsCheckBox->setText(tr("Include default permissions and features for Qt modules.")); m_defaultPermissonsCheckBox->setText(tr("Include default permissions for Qt modules."));
m_defaultPermissonsCheckBox->setTristate(true);
layout->addWidget(m_defaultPermissonsCheckBox, 0, 0); layout->addWidget(m_defaultPermissonsCheckBox, 0, 0);
m_defaultFeaturesCheckBox = new QCheckBox(this);
m_defaultFeaturesCheckBox->setText(tr("Include default features for Qt modules."));
layout->addWidget(m_defaultFeaturesCheckBox, 1, 0);
m_permissionsModel = new PermissionsModel(this); m_permissionsModel = new PermissionsModel(this);
m_permissionsListView = new QListView(permissionsGroupBox); m_permissionsListView = new QListView(permissionsGroupBox);
m_permissionsListView->setModel(m_permissionsModel); m_permissionsListView->setModel(m_permissionsModel);
m_permissionsListView->setMinimumSize(QSize(0, 200)); m_permissionsListView->setMinimumSize(QSize(0, 200));
layout->addWidget(m_permissionsListView, 1, 0, 3, 1); layout->addWidget(m_permissionsListView, 2, 0, 3, 1);
m_removePermissionButton = new QPushButton(permissionsGroupBox); m_removePermissionButton = new QPushButton(permissionsGroupBox);
m_removePermissionButton->setText(tr("Remove")); m_removePermissionButton->setText(tr("Remove"));
layout->addWidget(m_removePermissionButton, 1, 1); layout->addWidget(m_removePermissionButton, 2, 1);
m_permissionsComboBox = new QComboBox(permissionsGroupBox); m_permissionsComboBox = new QComboBox(permissionsGroupBox);
m_permissionsComboBox->insertItems(0, QStringList() m_permissionsComboBox->insertItems(0, QStringList()
...@@ -433,16 +436,18 @@ void AndroidManifestEditorWidget::initializePage() ...@@ -433,16 +436,18 @@ void AndroidManifestEditorWidget::initializePage()
<< QLatin1String("android.permission.WRITE_USER_DICTIONARY") << QLatin1String("android.permission.WRITE_USER_DICTIONARY")
); );
m_permissionsComboBox->setEditable(true); m_permissionsComboBox->setEditable(true);
layout->addWidget(m_permissionsComboBox, 5, 0); layout->addWidget(m_permissionsComboBox, 6, 0);
m_addPermissionButton = new QPushButton(permissionsGroupBox); m_addPermissionButton = new QPushButton(permissionsGroupBox);
m_addPermissionButton->setText(tr("Add")); m_addPermissionButton->setText(tr("Add"));
layout->addWidget(m_addPermissionButton, 5, 1); layout->addWidget(m_addPermissionButton, 6, 1);
permissionsGroupBox->setLayout(layout); permissionsGroupBox->setLayout(layout);
connect(m_defaultPermissonsCheckBox, SIGNAL(stateChanged(int)), connect(m_defaultPermissonsCheckBox, SIGNAL(stateChanged(int)),
this, SLOT(defaultPermissionCheckBoxClicked())); this, SLOT(defaultPermissionOrFeatureCheckBoxClicked()));
connect(m_defaultFeaturesCheckBox, SIGNAL(stateChanged(int)),
this, SLOT(defaultPermissionOrFeatureCheckBoxClicked()));
connect(m_addPermissionButton, SIGNAL(clicked()), connect(m_addPermissionButton, SIGNAL(clicked()),
this, SLOT(addPermission())); this, SLOT(addPermission()));
...@@ -801,9 +806,12 @@ void AndroidManifestEditorWidget::syncToWidgets(const QDomDocument &doc) ...@@ -801,9 +806,12 @@ void AndroidManifestEditorWidget::syncToWidgets(const QDomDocument &doc)
m_hIconPath.clear(); m_hIconPath.clear();
disconnect(m_defaultPermissonsCheckBox, SIGNAL(stateChanged(int)), disconnect(m_defaultPermissonsCheckBox, SIGNAL(stateChanged(int)),
this, SLOT(defaultPermissionCheckBoxClicked())); this, SLOT(defaultPermissionOrFeatureCheckBoxClicked()));
disconnect(m_defaultFeaturesCheckBox, SIGNAL(stateChanged(int)),
this, SLOT(defaultPermissionOrFeatureCheckBoxClicked()));
m_defaultPermissonsCheckBox->setChecked(false); m_defaultPermissonsCheckBox->setChecked(false);
m_defaultFeaturesCheckBox->setChecked(false);
QDomNodeList manifestChilds = manifest.childNodes(); QDomNodeList manifestChilds = manifest.childNodes();
bool foundPermissionComment = false; bool foundPermissionComment = false;
bool foundFeatureComment = false; bool foundFeatureComment = false;
...@@ -818,10 +826,13 @@ void AndroidManifestEditorWidget::syncToWidgets(const QDomDocument &doc) ...@@ -818,10 +826,13 @@ void AndroidManifestEditorWidget::syncToWidgets(const QDomDocument &doc)
} }
} }
m_defaultPermissonsCheckBox->setCheckState(Qt::CheckState(foundFeatureComment + foundPermissionComment)); m_defaultPermissonsCheckBox->setChecked(foundPermissionComment);
m_defaultFeaturesCheckBox->setChecked(foundFeatureComment);
connect(m_defaultPermissonsCheckBox, SIGNAL(stateChanged(int)), connect(m_defaultPermissonsCheckBox, SIGNAL(stateChanged(int)),
this, SLOT(defaultPermissionCheckBoxClicked())); this, SLOT(defaultPermissionOrFeatureCheckBoxClicked()));
connect(m_defaultFeaturesCheckBox, SIGNAL(stateChanged(int)),
this, SLOT(defaultPermissionOrFeatureCheckBoxClicked()));
QStringList permissions; QStringList permissions;
QDomElement permissionElem = manifest.firstChildElement(QLatin1String("uses-permission")); QDomElement permissionElem = manifest.firstChildElement(QLatin1String("uses-permission"));
...@@ -963,7 +974,7 @@ void AndroidManifestEditorWidget::parseManifest(QXmlStreamReader &reader, QXmlSt ...@@ -963,7 +974,7 @@ void AndroidManifestEditorWidget::parseManifest(QXmlStreamReader &reader, QXmlSt
if (!foundPermissionComment && m_defaultPermissonsCheckBox->checkState() == Qt::Checked) if (!foundPermissionComment && m_defaultPermissonsCheckBox->checkState() == Qt::Checked)
writer.writeComment(QLatin1String(" %%INSERT_PERMISSIONS ")); writer.writeComment(QLatin1String(" %%INSERT_PERMISSIONS "));
if (!foundFeatureComment && m_defaultPermissonsCheckBox->checkState() == Qt::Checked) if (!foundFeatureComment && m_defaultFeaturesCheckBox->checkState() == Qt::Checked)
writer.writeComment(QLatin1String(" %%INSERT_FEATURES ")); writer.writeComment(QLatin1String(" %%INSERT_FEATURES "));
if (!permissions.isEmpty()) { if (!permissions.isEmpty()) {
...@@ -1179,16 +1190,18 @@ QString AndroidManifestEditorWidget::parseUsesPermission(QXmlStreamReader &reade ...@@ -1179,16 +1190,18 @@ QString AndroidManifestEditorWidget::parseUsesPermission(QXmlStreamReader &reade
QString AndroidManifestEditorWidget::parseComment(QXmlStreamReader &reader, QXmlStreamWriter &writer) QString AndroidManifestEditorWidget::parseComment(QXmlStreamReader &reader, QXmlStreamWriter &writer)
{ {
QString commentText = reader.text().toString().trimmed(); QString commentText = reader.text().toString().trimmed();
if (commentText == QLatin1String("%%INSERT_PERMISSIONS") if (commentText == QLatin1String("%%INSERT_PERMISSIONS")) {
|| commentText == QLatin1String("%%INSERT_FEATURES")) {
if (m_defaultPermissonsCheckBox->checkState() == Qt::Unchecked) if (m_defaultPermissonsCheckBox->checkState() == Qt::Unchecked)
return commentText; return commentText;
}
writer.writeCurrentToken(reader); if (commentText == QLatin1String("%%INSERT_FEATURES")) {
return commentText; if (m_defaultFeaturesCheckBox->checkState() == Qt::Unchecked)
return commentText;
} }
writer.writeCurrentToken(reader); writer.writeCurrentToken(reader);
return QString(); return commentText;
} }
void AndroidManifestEditorWidget::parseUnknownElement(QXmlStreamReader &reader, QXmlStreamWriter &writer) void AndroidManifestEditorWidget::parseUnknownElement(QXmlStreamReader &reader, QXmlStreamWriter &writer)
...@@ -1289,10 +1302,8 @@ void AndroidManifestEditorWidget::setHDPIIcon() ...@@ -1289,10 +1302,8 @@ void AndroidManifestEditorWidget::setHDPIIcon()
setDirty(true); setDirty(true);
} }
void AndroidManifestEditorWidget::defaultPermissionCheckBoxClicked() void AndroidManifestEditorWidget::defaultPermissionOrFeatureCheckBoxClicked()
{ {
if (m_defaultPermissonsCheckBox->checkState() == Qt::PartiallyChecked)
m_defaultPermissonsCheckBox->setChecked(true);
setDirty(true); setDirty(true);
} }
......
...@@ -120,7 +120,7 @@ private slots: ...@@ -120,7 +120,7 @@ private slots:
void setLDPIIcon(); void setLDPIIcon();
void setMDPIIcon(); void setMDPIIcon();
void setHDPIIcon(); void setHDPIIcon();
void defaultPermissionCheckBoxClicked(); void defaultPermissionOrFeatureCheckBoxClicked();
void addPermission(); void addPermission();
void removePermission(); void removePermission();
void updateAddRemovePermissionButtons(); void updateAddRemovePermissionButtons();
...@@ -182,6 +182,7 @@ private: ...@@ -182,6 +182,7 @@ private:
// Permissions // Permissions
QCheckBox *m_defaultPermissonsCheckBox; QCheckBox *m_defaultPermissonsCheckBox;
QCheckBox *m_defaultFeaturesCheckBox;
PermissionsModel *m_permissionsModel; PermissionsModel *m_permissionsModel;
QListView *m_permissionsListView; QListView *m_permissionsListView;
QPushButton *m_addPermissionButton; QPushButton *m_addPermissionButton;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment