forked from qt-creator/qt-creator
Android: Implement a "editor" for android manifest files
Change-Id: I18c00ab452db21e5aa1ae3ad2eff465cfeff54b6 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
This commit is contained in:
@@ -36,7 +36,11 @@ HEADERS += \
|
||||
androiddevice.h \
|
||||
androidgdbserverkitinformation.h \
|
||||
androidanalyzesupport.h \
|
||||
androidrunsupport.h
|
||||
androidrunsupport.h \
|
||||
androidmanifesteditorfactory.h \
|
||||
androidmanifesteditor.h \
|
||||
androidmanifesteditorwidget.h \
|
||||
androidmanifestdocument.h
|
||||
|
||||
SOURCES += \
|
||||
androidconfigurations.cpp \
|
||||
@@ -67,7 +71,11 @@ SOURCES += \
|
||||
androiddevice.cpp \
|
||||
androidgdbserverkitinformation.cpp \
|
||||
androidanalyzesupport.cpp \
|
||||
androidrunsupport.cpp
|
||||
androidrunsupport.cpp \
|
||||
androidmanifesteditorfactory.cpp \
|
||||
androidmanifesteditor.cpp \
|
||||
androidmanifesteditorwidget.cpp \
|
||||
androidmanifestdocument.cpp
|
||||
|
||||
FORMS += \
|
||||
androidsettingswidget.ui \
|
||||
|
||||
@@ -62,6 +62,9 @@ const char ANDROIDQT[] = "Qt4ProjectManager.QtVersion.Android";
|
||||
|
||||
const char ANDROID_DEVICE_TYPE[] = "Android.Device.Type";
|
||||
const char ANDROID_DEVICE_ID[] = "Android Device";
|
||||
const char ANDROID_MANIFEST_MIME_TYPE[] = "application/vnd.google.android.android_manifest";
|
||||
const char ANDROID_MANIFEST_EDITOR_ID[] = "Android.AndroidManifestEditor.Id";
|
||||
const char ANDROID_MANIFEST_EDITOR_CONTEXT[] = "Android.AndroidManifestEditor.Id";
|
||||
} // namespace Constants;
|
||||
} // namespace Android
|
||||
|
||||
|
||||
@@ -182,41 +182,6 @@ bool AndroidManager::setApplicationName(ProjectExplorer::Target *target, const Q
|
||||
return saveXmlFile(target, doc, path);
|
||||
}
|
||||
|
||||
QStringList AndroidManager::permissions(ProjectExplorer::Target *target)
|
||||
{
|
||||
QStringList per;
|
||||
QDomDocument doc;
|
||||
if (!openManifest(target, doc))
|
||||
return per;
|
||||
QDomElement permissionElem = doc.documentElement().firstChildElement(QLatin1String("uses-permission"));
|
||||
while (!permissionElem.isNull()) {
|
||||
per << permissionElem.attribute(QLatin1String("android:name"));
|
||||
permissionElem = permissionElem.nextSiblingElement(QLatin1String("uses-permission"));
|
||||
}
|
||||
return per;
|
||||
}
|
||||
|
||||
bool AndroidManager::setPermissions(ProjectExplorer::Target *target, const QStringList &permissions)
|
||||
{
|
||||
QDomDocument doc;
|
||||
if (!openManifest(target, doc))
|
||||
return false;
|
||||
QDomElement docElement = doc.documentElement();
|
||||
QDomElement permissionElem = docElement.firstChildElement(QLatin1String("uses-permission"));
|
||||
while (!permissionElem.isNull()) {
|
||||
docElement.removeChild(permissionElem);
|
||||
permissionElem = docElement.firstChildElement(QLatin1String("uses-permission"));
|
||||
}
|
||||
|
||||
foreach (const QString &permission, permissions ) {
|
||||
permissionElem = doc.createElement(QLatin1String("uses-permission"));
|
||||
permissionElem.setAttribute(QLatin1String("android:name"), permission);
|
||||
docElement.appendChild(permissionElem);
|
||||
}
|
||||
|
||||
return saveManifest(target, doc);
|
||||
}
|
||||
|
||||
QString AndroidManager::intentName(ProjectExplorer::Target *target)
|
||||
{
|
||||
return packageName(target) + QLatin1Char('/') + activityName(target);
|
||||
@@ -231,54 +196,6 @@ QString AndroidManager::activityName(ProjectExplorer::Target *target)
|
||||
return activityElem.attribute(QLatin1String("android:name"));
|
||||
}
|
||||
|
||||
int AndroidManager::versionCode(ProjectExplorer::Target *target)
|
||||
{
|
||||
QDomDocument doc;
|
||||
if (!openManifest(target, doc))
|
||||
return 0;
|
||||
QDomElement manifestElem = doc.documentElement();
|
||||
return manifestElem.attribute(QLatin1String("android:versionCode")).toInt();
|
||||
}
|
||||
|
||||
bool AndroidManager::setVersionCode(ProjectExplorer::Target *target, int version)
|
||||
{
|
||||
QDomDocument doc;
|
||||
if (!openManifest(target, doc))
|
||||
return false;
|
||||
QDomElement manifestElem = doc.documentElement();
|
||||
manifestElem.setAttribute(QLatin1String("android:versionCode"), version);
|
||||
return saveManifest(target, doc);
|
||||
}
|
||||
|
||||
QString AndroidManager::versionName(ProjectExplorer::Target *target)
|
||||
{
|
||||
QDomDocument doc;
|
||||
if (!openManifest(target, doc))
|
||||
return QString();
|
||||
QDomElement manifestElem = doc.documentElement();
|
||||
return manifestElem.attribute(QLatin1String("android:versionName"));
|
||||
}
|
||||
|
||||
bool AndroidManager::setVersionName(ProjectExplorer::Target *target, const QString &version)
|
||||
{
|
||||
QDomDocument doc;
|
||||
if (!openManifest(target, doc))
|
||||
return false;
|
||||
QDomElement manifestElem = doc.documentElement();
|
||||
manifestElem.setAttribute(QLatin1String("android:versionName"), version);
|
||||
return saveManifest(target, doc);
|
||||
}
|
||||
|
||||
bool AndroidManager::ensureIconAttribute(ProjectExplorer::Target *target)
|
||||
{
|
||||
QDomDocument doc;
|
||||
if (!openManifest(target, doc))
|
||||
return false;
|
||||
QDomElement applicationElem = doc.documentElement().firstChildElement(QLatin1String("application"));
|
||||
applicationElem.setAttribute(QLatin1String("android:icon"), QLatin1String("@drawable/icon"));
|
||||
return saveManifest(target, doc);
|
||||
}
|
||||
|
||||
QString AndroidManager::targetSDK(ProjectExplorer::Target *target)
|
||||
{
|
||||
QVariant v = target->namedSettings(QLatin1String("AndroidManager.TargetSdk"));
|
||||
@@ -322,39 +239,6 @@ QString AndroidManager::targetArch(ProjectExplorer::Target *target)
|
||||
return node->singleVariableValue(Qt4ProjectManager::AndroidArchVar);
|
||||
}
|
||||
|
||||
QIcon AndroidManager::highDpiIcon(ProjectExplorer::Target *target)
|
||||
{
|
||||
return icon(target, HighDPI);
|
||||
}
|
||||
|
||||
bool AndroidManager::setHighDpiIcon(ProjectExplorer::Target *target, const QString &iconFilePath)
|
||||
{
|
||||
return ensureIconAttribute(target) &&
|
||||
setIcon(target, HighDPI, iconFilePath);
|
||||
}
|
||||
|
||||
QIcon AndroidManager::mediumDpiIcon(ProjectExplorer::Target *target)
|
||||
{
|
||||
return icon(target, MediumDPI);
|
||||
}
|
||||
|
||||
bool AndroidManager::setMediumDpiIcon(ProjectExplorer::Target *target, const QString &iconFilePath)
|
||||
{
|
||||
return ensureIconAttribute(target) &&
|
||||
setIcon(target, MediumDPI, iconFilePath);
|
||||
}
|
||||
|
||||
QIcon AndroidManager::lowDpiIcon(ProjectExplorer::Target *target)
|
||||
{
|
||||
return icon(target, LowDPI);
|
||||
}
|
||||
|
||||
bool AndroidManager::setLowDpiIcon(ProjectExplorer::Target *target, const QString &iconFilePath)
|
||||
{
|
||||
return ensureIconAttribute(target) &&
|
||||
setIcon(target, LowDPI, iconFilePath);
|
||||
}
|
||||
|
||||
Utils::FileName AndroidManager::dirPath(ProjectExplorer::Target *target)
|
||||
{
|
||||
return Utils::FileName::fromString(target->project()->projectDirectory()).appendPath(AndroidDirName);
|
||||
@@ -1029,20 +913,6 @@ bool AndroidManager::saveManifest(ProjectExplorer::Target *target, QDomDocument
|
||||
return saveXmlFile(target, doc, manifestPath(target));
|
||||
}
|
||||
|
||||
QString AndroidManager::iconPath(ProjectExplorer::Target *target, AndroidManager::IconType type)
|
||||
{
|
||||
switch (type) {
|
||||
case HighDPI:
|
||||
return dirPath(target).appendPath(QLatin1String("res/drawable-hdpi/icon.png")).toString();
|
||||
case MediumDPI:
|
||||
return dirPath(target).appendPath(QLatin1String("res/drawable-mdpi/icon.png")).toString();
|
||||
case LowDPI:
|
||||
return dirPath(target).appendPath(QLatin1String("res/drawable-ldpi/icon.png")).toString();
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QStringList AndroidManager::libsXml(ProjectExplorer::Target *target, const QString &tag)
|
||||
{
|
||||
QStringList libs;
|
||||
@@ -1089,23 +959,6 @@ bool AndroidManager::setLibsXml(ProjectExplorer::Target *target, const QStringLi
|
||||
}
|
||||
|
||||
|
||||
QIcon AndroidManager::icon(ProjectExplorer::Target *target, IconType type)
|
||||
{
|
||||
return QIcon(iconPath(target, type));
|
||||
}
|
||||
|
||||
bool AndroidManager::setIcon(ProjectExplorer::Target *target, IconType type, const QString &iconFileName)
|
||||
{
|
||||
if (!QFileInfo(iconFileName).exists())
|
||||
return false;
|
||||
|
||||
const QString path = iconPath(target, type);
|
||||
QFile::remove(path);
|
||||
QDir dir;
|
||||
dir.mkpath(QFileInfo(path).absolutePath());
|
||||
return QFile::copy(iconFileName, path);
|
||||
}
|
||||
|
||||
QStringList AndroidManager::dependencies(const Utils::FileName &readelfPath, const QString &lib)
|
||||
{
|
||||
QStringList libs;
|
||||
|
||||
@@ -61,25 +61,9 @@ public:
|
||||
static QString applicationName(ProjectExplorer::Target *target);
|
||||
static bool setApplicationName(ProjectExplorer::Target *target, const QString &name);
|
||||
|
||||
static QStringList permissions(ProjectExplorer::Target *target);
|
||||
static bool setPermissions(ProjectExplorer::Target *target, const QStringList &permissions);
|
||||
|
||||
static QString intentName(ProjectExplorer::Target *target);
|
||||
static QString activityName(ProjectExplorer::Target *target);
|
||||
|
||||
static int versionCode(ProjectExplorer::Target *target);
|
||||
static bool setVersionCode(ProjectExplorer::Target *target, int version);
|
||||
static QString versionName(ProjectExplorer::Target *target);
|
||||
static bool setVersionName(ProjectExplorer::Target *target, const QString &version);
|
||||
|
||||
static QIcon highDpiIcon(ProjectExplorer::Target *target);
|
||||
static bool setHighDpiIcon(ProjectExplorer::Target *target, const QString &iconFilePath);
|
||||
static QIcon mediumDpiIcon(ProjectExplorer::Target *target);
|
||||
static bool setMediumDpiIcon(ProjectExplorer::Target *target, const QString &iconFilePath);
|
||||
static QIcon lowDpiIcon(ProjectExplorer::Target *target);
|
||||
static bool setLowDpiIcon(ProjectExplorer::Target *target, const QString &iconFilePath);
|
||||
static bool ensureIconAttribute(ProjectExplorer::Target *target);
|
||||
|
||||
static QStringList availableTargetApplications(ProjectExplorer::Target *target);
|
||||
static QString targetApplication(ProjectExplorer::Target *target);
|
||||
static bool setTargetApplication(ProjectExplorer::Target *target, const QString &name);
|
||||
@@ -159,16 +143,6 @@ private:
|
||||
};
|
||||
static QString loadLocal(ProjectExplorer::Target *target, int apiLevel, ItemType item, const QString &attribute=QLatin1String("file"));
|
||||
|
||||
enum IconType
|
||||
{
|
||||
HighDPI,
|
||||
MediumDPI,
|
||||
LowDPI
|
||||
};
|
||||
static QString iconPath(ProjectExplorer::Target *target, IconType type);
|
||||
static QIcon icon(ProjectExplorer::Target *target, IconType type);
|
||||
static bool setIcon(ProjectExplorer::Target *target, IconType type, const QString &iconFileName);
|
||||
|
||||
static QStringList dependencies(const Utils::FileName &readelfPath, const QString &lib);
|
||||
static int setLibraryLevel(const QString &library, LibrariesMap &mapLibs);
|
||||
static bool qtLibrariesLessThan(const Library &a, const Library &b);
|
||||
|
||||
75
src/plugins/android/androidmanifestdocument.cpp
Normal file
75
src/plugins/android/androidmanifestdocument.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "androidmanifestdocument.h"
|
||||
#include "androidmanifesteditorwidget.h"
|
||||
#include "androidconstants.h"
|
||||
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QDomDocument>
|
||||
|
||||
using namespace Android;
|
||||
using namespace Android::Internal;
|
||||
|
||||
|
||||
AndroidManifestDocument::AndroidManifestDocument(AndroidManifestEditorWidget *editorWidget)
|
||||
: TextEditor::BaseTextDocument(),
|
||||
m_editorWidget(editorWidget)
|
||||
{
|
||||
}
|
||||
|
||||
bool AndroidManifestDocument::save(QString *errorString, const QString &fileName, bool autoSave)
|
||||
{
|
||||
m_editorWidget->preSave();
|
||||
return BaseTextDocument::save(errorString, fileName, autoSave);
|
||||
}
|
||||
|
||||
QString AndroidManifestDocument::defaultPath() const
|
||||
{
|
||||
QFileInfo fi(fileName());
|
||||
return fi.absolutePath();
|
||||
}
|
||||
|
||||
QString AndroidManifestDocument::suggestedFileName() const
|
||||
{
|
||||
QFileInfo fi(fileName());
|
||||
return fi.fileName();
|
||||
}
|
||||
|
||||
bool AndroidManifestDocument::isModified() const
|
||||
{
|
||||
return BaseTextDocument::isModified() || m_editorWidget->isModified();
|
||||
}
|
||||
|
||||
bool AndroidManifestDocument::isSaveAsAllowed() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
58
src/plugins/android/androidmanifestdocument.h
Normal file
58
src/plugins/android/androidmanifestdocument.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ANDROIDMANIFESTDOCUMENT_H
|
||||
#define ANDROIDMANIFESTDOCUMENT_H
|
||||
|
||||
#include <coreplugin/textdocument.h>
|
||||
#include <texteditor/basetextdocument.h>
|
||||
|
||||
namespace Android {
|
||||
namespace Internal {
|
||||
class AndroidManifestEditorWidget;
|
||||
|
||||
class AndroidManifestDocument : public TextEditor::BaseTextDocument
|
||||
{
|
||||
public:
|
||||
explicit AndroidManifestDocument(AndroidManifestEditorWidget *editorWidget);
|
||||
bool save(QString *errorString, const QString &fileName = QString(), bool autoSave = false);
|
||||
|
||||
QString defaultPath() const;
|
||||
QString suggestedFileName() const;
|
||||
|
||||
bool isModified() const;
|
||||
bool isSaveAsAllowed() const;
|
||||
private:
|
||||
AndroidManifestEditorWidget *m_editorWidget;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Android
|
||||
|
||||
#endif // ANDROIDMANIFESTDOCUMENT_H
|
||||
103
src/plugins/android/androidmanifesteditor.cpp
Normal file
103
src/plugins/android/androidmanifesteditor.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "androidmanifesteditor.h"
|
||||
#include "androidmanifestdocument.h"
|
||||
#include "androidmanifesteditorwidget.h"
|
||||
#include "androidconstants.h"
|
||||
|
||||
#include <texteditor/texteditorconstants.h>
|
||||
|
||||
#include <QActionGroup>
|
||||
#include <QToolBar>
|
||||
|
||||
using namespace Android;
|
||||
using namespace Internal;
|
||||
|
||||
Android::Internal::AndroidManifestEditor::AndroidManifestEditor(AndroidManifestEditorWidget *editorWidget)
|
||||
: BaseTextEditor(editorWidget),
|
||||
m_document(new AndroidManifestDocument(editorWidget))
|
||||
{
|
||||
QToolBar *toolBar = new QToolBar;
|
||||
|
||||
m_actionGroup = new QActionGroup(this);
|
||||
connect(m_actionGroup, SIGNAL(triggered(QAction*)), this, SLOT(changeEditorPage(QAction*)));
|
||||
|
||||
QAction *generalAction = toolBar->addAction(tr("General"));
|
||||
generalAction->setData(AndroidManifestEditorWidget::General);
|
||||
generalAction->setCheckable(true);
|
||||
m_actionGroup->addAction(generalAction);
|
||||
|
||||
QAction *sourceAction = toolBar->addAction(tr("XML Source"));
|
||||
sourceAction->setData(AndroidManifestEditorWidget::Source);
|
||||
sourceAction->setCheckable(true);
|
||||
m_actionGroup->addAction(sourceAction);
|
||||
|
||||
generalAction->setChecked(true);
|
||||
|
||||
insertExtraToolBarWidget(BaseTextEditor::Left, toolBar);
|
||||
|
||||
|
||||
setContext(Core::Context(Constants::ANDROID_MANIFEST_EDITOR_CONTEXT,
|
||||
TextEditor::Constants::C_TEXTEDITOR));
|
||||
}
|
||||
|
||||
Core::Id AndroidManifestEditor::id() const
|
||||
{
|
||||
return Constants::ANDROID_MANIFEST_EDITOR_ID;
|
||||
}
|
||||
|
||||
bool AndroidManifestEditor::duplicateSupported() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Core::IEditor *AndroidManifestEditor::duplicate(QWidget *parent)
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool AndroidManifestEditor::isTemporary() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void AndroidManifestEditor::changeEditorPage(QAction *action)
|
||||
{
|
||||
AndroidManifestEditorWidget *editorWidget = static_cast<AndroidManifestEditorWidget *>(widget());
|
||||
if (!editorWidget->setActivePage(static_cast<AndroidManifestEditorWidget::EditorPage>(action->data().toInt()))) {
|
||||
foreach (QAction *action, m_actionGroup->actions()) {
|
||||
if (action->data().toInt() == editorWidget->activePage()) {
|
||||
action->setChecked(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
70
src/plugins/android/androidmanifesteditor.h
Normal file
70
src/plugins/android/androidmanifesteditor.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ANDROIDMANIFESTEDITOR_H
|
||||
#define ANDROIDMANIFESTEDITOR_H
|
||||
|
||||
#include "androidmanifestdocument.h"
|
||||
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <texteditor/basetexteditor.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QToolBar;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Android {
|
||||
namespace Internal {
|
||||
class AndroidManifestEditorWidget;
|
||||
|
||||
class AndroidManifestEditor : public TextEditor::BaseTextEditor
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AndroidManifestEditor(AndroidManifestEditorWidget *editorWidget);
|
||||
|
||||
Core::Id id() const;
|
||||
|
||||
bool duplicateSupported() const;
|
||||
Core::IEditor *duplicate(QWidget *parent);
|
||||
|
||||
bool isTemporary() const;
|
||||
private slots:
|
||||
void changeEditorPage(QAction *action);
|
||||
|
||||
private:
|
||||
AndroidManifestDocument *m_document;
|
||||
QString m_displayName;
|
||||
QActionGroup *m_actionGroup;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Android
|
||||
|
||||
#endif // ANDROIDMANIFESTEDITOR_H
|
||||
69
src/plugins/android/androidmanifesteditorfactory.cpp
Normal file
69
src/plugins/android/androidmanifesteditorfactory.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "androidmanifesteditorfactory.h"
|
||||
#include "androidconstants.h"
|
||||
#include "androidmanifesteditorwidget.h"
|
||||
#include "androidmanifesteditor.h"
|
||||
|
||||
#include <coreplugin/id.h>
|
||||
#include <texteditor/texteditoractionhandler.h>
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
|
||||
using namespace Android;
|
||||
using namespace Android::Internal;
|
||||
|
||||
|
||||
AndroidManifestEditorFactory::AndroidManifestEditorFactory(QObject *parent)
|
||||
: Core::IEditorFactory(parent),
|
||||
m_actionHandler(new TextEditor::TextEditorActionHandler(Constants::ANDROID_MANIFEST_EDITOR_CONTEXT))
|
||||
{
|
||||
}
|
||||
|
||||
QStringList AndroidManifestEditorFactory::mimeTypes() const
|
||||
{
|
||||
return QStringList() << QLatin1String(Constants::ANDROID_MANIFEST_MIME_TYPE);
|
||||
}
|
||||
|
||||
Core::Id AndroidManifestEditorFactory::id() const
|
||||
{
|
||||
return Constants::ANDROID_MANIFEST_EDITOR_ID;
|
||||
}
|
||||
|
||||
QString AndroidManifestEditorFactory::displayName() const
|
||||
{
|
||||
return tr("Android Manifest editor");
|
||||
}
|
||||
|
||||
Core::IEditor *AndroidManifestEditorFactory::createEditor(QWidget *parent)
|
||||
{
|
||||
AndroidManifestEditorWidget *editor = new AndroidManifestEditorWidget(parent, m_actionHandler);
|
||||
TextEditor::TextEditorSettings::instance()->initializeEditor(editor);
|
||||
return editor->editor();
|
||||
}
|
||||
58
src/plugins/android/androidmanifesteditorfactory.h
Normal file
58
src/plugins/android/androidmanifesteditorfactory.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ANDROIDMANIFESTEDITORFACTORY_H
|
||||
#define ANDROIDMANIFESTEDITORFACTORY_H
|
||||
|
||||
#include <coreplugin/editormanager/ieditorfactory.h>
|
||||
|
||||
namespace TextEditor { class TextEditorActionHandler; }
|
||||
|
||||
namespace Android {
|
||||
namespace Internal {
|
||||
|
||||
class AndroidManifestEditorFactory : public Core::IEditorFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AndroidManifestEditorFactory(QObject *parent = 0);
|
||||
|
||||
QStringList mimeTypes() const;
|
||||
Core::Id id() const;
|
||||
QString displayName() const;
|
||||
|
||||
Core::IEditor *createEditor(QWidget *parent);
|
||||
private:
|
||||
TextEditor::TextEditorActionHandler *m_actionHandler;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Android
|
||||
|
||||
#endif // ANDROIDMANIFESTEDITORFACTORY_H
|
||||
910
src/plugins/android/androidmanifesteditorwidget.cpp
Normal file
910
src/plugins/android/androidmanifesteditorwidget.cpp
Normal file
@@ -0,0 +1,910 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "androidmanifesteditorwidget.h"
|
||||
#include "androidmanifesteditor.h"
|
||||
#include "androidconstants.h"
|
||||
#include "androidmanifestdocument.h"
|
||||
|
||||
#include <coreplugin/infobar.h>
|
||||
#include <texteditor/plaintexteditor.h>
|
||||
#include <projectexplorer/projectwindow.h>
|
||||
#include <projectexplorer/iprojectproperties.h>
|
||||
#include <texteditor/texteditoractionhandler.h>
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QFileInfo>
|
||||
#include <QDomDocument>
|
||||
#include <QDir>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QFormLayout>
|
||||
#include <QComboBox>
|
||||
#include <QSpinBox>
|
||||
#include <QDebug>
|
||||
#include <QToolButton>
|
||||
#include <utils/fileutils.h>
|
||||
#include <QListView>
|
||||
#include <QPushButton>
|
||||
#include <QFileDialog>
|
||||
#include <QTimer>
|
||||
|
||||
namespace {
|
||||
const QLatin1String packageNameRegExp("^([a-z_]{1}[a-z0-9_]+(\\.[a-zA-Z_]{1}[a-zA-Z0-9_]*)*)$");
|
||||
const char infoBarId[] = "Android.AndroidManifestEditor.InfoBar";
|
||||
|
||||
bool checkPackageName(const QString &packageName)
|
||||
{
|
||||
return QRegExp(packageNameRegExp).exactMatch(packageName);
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
using namespace Android;
|
||||
using namespace Android::Internal;
|
||||
|
||||
AndroidManifestEditorWidget::AndroidManifestEditorWidget(QWidget *parent, TextEditor::TextEditorActionHandler *ah)
|
||||
: TextEditor::PlainTextEditorWidget(parent),
|
||||
m_dirty(false),
|
||||
m_stayClean(false),
|
||||
m_setAppName(false),
|
||||
m_ah(ah)
|
||||
{
|
||||
QSharedPointer<AndroidManifestDocument> doc(new AndroidManifestDocument(this));
|
||||
doc->setMimeType(QLatin1String(Constants::ANDROID_MANIFEST_MIME_TYPE));
|
||||
setBaseTextDocument(doc);
|
||||
|
||||
ah->setupActions(this);
|
||||
configure(QLatin1String(Constants::ANDROID_MANIFEST_MIME_TYPE));
|
||||
|
||||
initializePage();
|
||||
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
|
||||
m_timerParseCheck.setInterval(800);
|
||||
m_timerParseCheck.setSingleShot(true);
|
||||
|
||||
connect(&m_timerParseCheck, SIGNAL(timeout()),
|
||||
this, SLOT(delayedParseCheck()));
|
||||
|
||||
connect(document(), SIGNAL(contentsChanged()),
|
||||
this, SLOT(startParseCheck()));
|
||||
}
|
||||
|
||||
TextEditor::BaseTextEditor *AndroidManifestEditorWidget::createEditor()
|
||||
{
|
||||
return new AndroidManifestEditor(this);
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::initializePage()
|
||||
{
|
||||
ProjectExplorer::PanelsWidget *generalPanel = new ProjectExplorer::PanelsWidget(this);
|
||||
generalPanel->widget()->setMinimumWidth(0);
|
||||
generalPanel->widget()->setMaximumWidth(900);
|
||||
|
||||
// Package
|
||||
ProjectExplorer::PropertiesPanel *manifestPanel = new ProjectExplorer::PropertiesPanel;
|
||||
manifestPanel->setDisplayName(tr("Package"));
|
||||
{
|
||||
QWidget *mainWidget = new QWidget();
|
||||
|
||||
QFormLayout *formLayout = new QFormLayout(mainWidget);
|
||||
|
||||
m_packageNameLineEdit = new QLineEdit(mainWidget);
|
||||
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(QPixmap(QString::fromUtf8(":/projectexplorer/images/compile_warning.png")));
|
||||
m_packageNameWarningIcon->setVisible(false);
|
||||
m_packageNameWarningIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
|
||||
QHBoxLayout *warningRow = new QHBoxLayout;
|
||||
warningRow->setMargin(0);
|
||||
warningRow->addWidget(m_packageNameWarningIcon);
|
||||
warningRow->addWidget(m_packageNameWarning);
|
||||
|
||||
formLayout->addRow(QString(), warningRow);
|
||||
|
||||
|
||||
m_versionCode = new QSpinBox(mainWidget);
|
||||
m_versionCode->setMaximum(99);
|
||||
m_versionCode->setValue(1);
|
||||
formLayout->addRow(tr("Version code:"), m_versionCode);
|
||||
|
||||
m_versionNameLinedit = new QLineEdit(mainWidget);
|
||||
formLayout->addRow(tr("Version name:"), m_versionNameLinedit);
|
||||
|
||||
manifestPanel->setWidget(mainWidget);
|
||||
|
||||
connect(m_packageNameLineEdit, SIGNAL(textEdited(QString)),
|
||||
this, SLOT(setPackageName()));
|
||||
connect(m_versionCode, SIGNAL(valueChanged(int)),
|
||||
this, SLOT(setDirty()));
|
||||
connect(m_versionNameLinedit, SIGNAL(textEdited(QString)),
|
||||
this, SLOT(setDirty()));
|
||||
|
||||
}
|
||||
generalPanel->addPropertiesPanel(manifestPanel);
|
||||
|
||||
// Application
|
||||
ProjectExplorer::PropertiesPanel *applicationPanel = new ProjectExplorer::PropertiesPanel;
|
||||
applicationPanel->setDisplayName(tr("Application"));
|
||||
{
|
||||
QWidget *mainWidget = new QWidget();
|
||||
QFormLayout *formLayout = new QFormLayout(mainWidget);
|
||||
|
||||
m_appNameLineEdit = new QLineEdit(mainWidget);
|
||||
formLayout->addRow(tr("Application name:"), m_appNameLineEdit);
|
||||
|
||||
m_targetLineEdit = new QLineEdit(mainWidget);
|
||||
formLayout->addRow(tr("Run:"), m_targetLineEdit);
|
||||
|
||||
QHBoxLayout *iconLayout = new QHBoxLayout();
|
||||
m_lIconButton = new QToolButton(mainWidget);
|
||||
m_lIconButton->setMinimumSize(QSize(48, 48));
|
||||
m_lIconButton->setMaximumSize(QSize(48, 48));
|
||||
iconLayout->addWidget(m_lIconButton);
|
||||
|
||||
iconLayout->addItem(new QSpacerItem(28, 20, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
||||
|
||||
m_mIconButton = new QToolButton(mainWidget);
|
||||
m_mIconButton->setMinimumSize(QSize(48, 48));
|
||||
m_mIconButton->setMaximumSize(QSize(48, 48));
|
||||
iconLayout->addWidget(m_mIconButton);
|
||||
|
||||
iconLayout->addItem(new QSpacerItem(28, 20, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
||||
|
||||
m_hIconButton = new QToolButton(mainWidget);
|
||||
m_hIconButton->setMinimumSize(QSize(48, 48));
|
||||
m_hIconButton->setMaximumSize(QSize(48, 48));
|
||||
iconLayout->addWidget(m_hIconButton);
|
||||
|
||||
formLayout->addRow(tr("Application icon:"), iconLayout);
|
||||
|
||||
applicationPanel->setWidget(mainWidget);
|
||||
|
||||
connect(m_appNameLineEdit, SIGNAL(textEdited(QString)),
|
||||
this, SLOT(setAppName()));
|
||||
connect(m_targetLineEdit, SIGNAL(textEdited(QString)),
|
||||
this, SLOT(setDirty()));
|
||||
|
||||
connect(m_lIconButton, SIGNAL(clicked()), SLOT(setLDPIIcon()));
|
||||
connect(m_mIconButton, SIGNAL(clicked()), SLOT(setMDPIIcon()));
|
||||
connect(m_hIconButton, SIGNAL(clicked()), SLOT(setHDPIIcon()));
|
||||
}
|
||||
generalPanel->addPropertiesPanel(applicationPanel);
|
||||
|
||||
|
||||
// Permissions
|
||||
ProjectExplorer::PropertiesPanel *permissionsPanel = new ProjectExplorer::PropertiesPanel;
|
||||
permissionsPanel->setDisplayName(tr("Permissions"));
|
||||
{
|
||||
QWidget *mainWidget = new QWidget();
|
||||
QGridLayout *layout = new QGridLayout(mainWidget);
|
||||
|
||||
m_permissionsModel = new PermissionsModel(this);
|
||||
|
||||
m_permissionsListView = new QListView(mainWidget);
|
||||
m_permissionsListView->setModel(m_permissionsModel);
|
||||
m_permissionsListView->setMinimumSize(QSize(0, 200));
|
||||
layout->addWidget(m_permissionsListView, 0, 0, 3, 1);
|
||||
|
||||
m_removePermissionButton = new QPushButton(mainWidget);
|
||||
m_removePermissionButton->setText(tr("Remove"));
|
||||
layout->addWidget(m_removePermissionButton, 0, 1);
|
||||
|
||||
m_permissionsComboBox = new QComboBox(mainWidget);
|
||||
m_permissionsComboBox->insertItems(0, QStringList()
|
||||
<< QStringLiteral("android.permission.ACCESS_CHECKIN_PROPERTIES")
|
||||
<< QStringLiteral("android.permission.ACCESS_COARSE_LOCATION")
|
||||
<< QStringLiteral("android.permission.ACCESS_FINE_LOCATION")
|
||||
<< QStringLiteral("android.permission.ACCESS_LOCATION_EXTRA_COMMANDS")
|
||||
<< QStringLiteral("android.permission.ACCESS_MOCK_LOCATION")
|
||||
<< QStringLiteral("android.permission.ACCESS_NETWORK_STATE")
|
||||
<< QStringLiteral("android.permission.ACCESS_SURFACE_FLINGER")
|
||||
<< QStringLiteral("android.permission.ACCESS_WIFI_STATE")
|
||||
<< QStringLiteral("android.permission.ACCOUNT_MANAGER")
|
||||
<< QStringLiteral("android.permission.AUTHENTICATE_ACCOUNTS")
|
||||
<< QStringLiteral("android.permission.BATTERY_STATS")
|
||||
<< QStringLiteral("android.permission.BIND_APPWIDGET")
|
||||
<< QStringLiteral("android.permission.BIND_DEVICE_ADMIN")
|
||||
<< QStringLiteral("android.permission.BIND_INPUT_METHOD")
|
||||
<< QStringLiteral("android.permission.BIND_REMOTEVIEWS")
|
||||
<< QStringLiteral("android.permission.BIND_WALLPAPER")
|
||||
<< QStringLiteral("android.permission.BLUETOOTH")
|
||||
<< QStringLiteral("android.permission.BLUETOOTH_ADMIN")
|
||||
<< QStringLiteral("android.permission.BRICK")
|
||||
<< QStringLiteral("android.permission.BROADCAST_PACKAGE_REMOVED")
|
||||
<< QStringLiteral("android.permission.BROADCAST_SMS")
|
||||
<< QStringLiteral("android.permission.BROADCAST_STICKY")
|
||||
<< QStringLiteral("android.permission.BROADCAST_WAP_PUSH")
|
||||
<< QStringLiteral("android.permission.CALL_PHONE")
|
||||
<< QStringLiteral("android.permission.CALL_PRIVILEGED")
|
||||
<< QStringLiteral("android.permission.CAMERA")
|
||||
<< QStringLiteral("android.permission.CHANGE_COMPONENT_ENABLED_STATE")
|
||||
<< QStringLiteral("android.permission.CHANGE_CONFIGURATION")
|
||||
<< QStringLiteral("android.permission.CHANGE_NETWORK_STATE")
|
||||
<< QStringLiteral("android.permission.CHANGE_WIFI_MULTICAST_STATE")
|
||||
<< QStringLiteral("android.permission.CHANGE_WIFI_STATE")
|
||||
<< QStringLiteral("android.permission.CLEAR_APP_CACHE")
|
||||
<< QStringLiteral("android.permission.CLEAR_APP_USER_DATA")
|
||||
<< QStringLiteral("android.permission.CONTROL_LOCATION_UPDATES")
|
||||
<< QStringLiteral("android.permission.DELETE_CACHE_FILES")
|
||||
<< QStringLiteral("android.permission.DELETE_PACKAGES")
|
||||
<< QStringLiteral("android.permission.DEVICE_POWER")
|
||||
<< QStringLiteral("android.permission.DIAGNOSTIC")
|
||||
<< QStringLiteral("android.permission.DISABLE_KEYGUARD")
|
||||
<< QStringLiteral("android.permission.DUMP")
|
||||
<< QStringLiteral("android.permission.EXPAND_STATUS_BAR")
|
||||
<< QStringLiteral("android.permission.FACTORY_TEST")
|
||||
<< QStringLiteral("android.permission.FLASHLIGHT")
|
||||
<< QStringLiteral("android.permission.FORCE_BACK")
|
||||
<< QStringLiteral("android.permission.GET_ACCOUNTS")
|
||||
<< QStringLiteral("android.permission.GET_PACKAGE_SIZE")
|
||||
<< QStringLiteral("android.permission.GET_TASKS")
|
||||
<< QStringLiteral("android.permission.GLOBAL_SEARCH")
|
||||
<< QStringLiteral("android.permission.HARDWARE_TEST")
|
||||
<< QStringLiteral("android.permission.INJECT_EVENTS")
|
||||
<< QStringLiteral("android.permission.INSTALL_LOCATION_PROVIDER")
|
||||
<< QStringLiteral("android.permission.INSTALL_PACKAGES")
|
||||
<< QStringLiteral("android.permission.INTERNAL_SYSTEM_WINDOW")
|
||||
<< QStringLiteral("android.permission.INTERNET")
|
||||
<< QStringLiteral("android.permission.KILL_BACKGROUND_PROCESSES")
|
||||
<< QStringLiteral("android.permission.MANAGE_ACCOUNTS")
|
||||
<< QStringLiteral("android.permission.MANAGE_APP_TOKENS")
|
||||
<< QStringLiteral("android.permission.MASTER_CLEAR")
|
||||
<< QStringLiteral("android.permission.MODIFY_AUDIO_SETTINGS")
|
||||
<< QStringLiteral("android.permission.MODIFY_PHONE_STATE")
|
||||
<< QStringLiteral("android.permission.MOUNT_FORMAT_FILESYSTEMS")
|
||||
<< QStringLiteral("android.permission.MOUNT_UNMOUNT_FILESYSTEMS")
|
||||
<< QStringLiteral("android.permission.NFC")
|
||||
<< QStringLiteral("android.permission.PERSISTENT_ACTIVITY")
|
||||
<< QStringLiteral("android.permission.PROCESS_OUTGOING_CALLS")
|
||||
<< QStringLiteral("android.permission.READ_CALENDAR")
|
||||
<< QStringLiteral("android.permission.READ_CONTACTS")
|
||||
<< QStringLiteral("android.permission.READ_FRAME_BUFFER")
|
||||
<< QStringLiteral("com.android.browser.permission.READ_HISTORY_BOOKMARKS")
|
||||
<< QStringLiteral("android.permission.READ_INPUT_STATE")
|
||||
<< QStringLiteral("android.permission.READ_LOGS")
|
||||
<< QStringLiteral("android.permission.READ_OWNER_DATA")
|
||||
<< QStringLiteral("android.permission.READ_PHONE_STATE")
|
||||
<< QStringLiteral("android.permission.READ_SMS")
|
||||
<< QStringLiteral("android.permission.READ_SYNC_SETTINGS")
|
||||
<< QStringLiteral("android.permission.READ_SYNC_STATS")
|
||||
<< QStringLiteral("android.permission.REBOOT")
|
||||
<< QStringLiteral("android.permission.RECEIVE_BOOT_COMPLETED")
|
||||
<< QStringLiteral("android.permission.RECEIVE_MMS")
|
||||
<< QStringLiteral("android.permission.RECEIVE_SMS")
|
||||
<< QStringLiteral("android.permission.RECEIVE_WAP_PUSH")
|
||||
<< QStringLiteral("android.permission.RECORD_AUDIO")
|
||||
<< QStringLiteral("android.permission.REORDER_TASKS")
|
||||
<< QStringLiteral("android.permission.RESTART_PACKAGES")
|
||||
<< QStringLiteral("android.permission.SEND_SMS")
|
||||
<< QStringLiteral("android.permission.SET_ACTIVITY_WATCHER")
|
||||
<< QStringLiteral("com.android.alarm.permission.SET_ALARM")
|
||||
<< QStringLiteral("android.permission.SET_ALWAYS_FINISH")
|
||||
<< QStringLiteral("android.permission.SET_ANIMATION_SCALE")
|
||||
<< QStringLiteral("android.permission.SET_DEBUG_APP")
|
||||
<< QStringLiteral("android.permission.SET_ORIENTATION")
|
||||
<< QStringLiteral("android.permission.SET_PREFERRED_APPLICATIONS")
|
||||
<< QStringLiteral("android.permission.SET_PROCESS_LIMIT")
|
||||
<< QStringLiteral("android.permission.SET_TIME")
|
||||
<< QStringLiteral("android.permission.SET_TIME_ZONE")
|
||||
<< QStringLiteral("android.permission.SET_WALLPAPER")
|
||||
<< QStringLiteral("android.permission.SET_WALLPAPER_HINTS")
|
||||
<< QStringLiteral("android.permission.SIGNAL_PERSISTENT_PROCESSES")
|
||||
<< QStringLiteral("android.permission.STATUS_BAR")
|
||||
<< QStringLiteral("android.permission.SUBSCRIBED_FEEDS_READ")
|
||||
<< QStringLiteral("android.permission.SUBSCRIBED_FEEDS_WRITE")
|
||||
<< QStringLiteral("android.permission.SYSTEM_ALERT_WINDOW")
|
||||
<< QStringLiteral("android.permission.UPDATE_DEVICE_STATS")
|
||||
<< QStringLiteral("android.permission.USE_CREDENTIALS")
|
||||
<< QStringLiteral("android.permission.USE_SIP")
|
||||
<< QStringLiteral("android.permission.VIBRATE")
|
||||
<< QStringLiteral("android.permission.WAKE_LOCK")
|
||||
<< QStringLiteral("android.permission.WRITE_APN_SETTINGS")
|
||||
<< QStringLiteral("android.permission.WRITE_CALENDAR")
|
||||
<< QStringLiteral("android.permission.WRITE_CONTACTS")
|
||||
<< QStringLiteral("android.permission.WRITE_EXTERNAL_STORAGE")
|
||||
<< QStringLiteral("android.permission.WRITE_GSERVICES")
|
||||
<< QStringLiteral("com.android.browser.permission.WRITE_HISTORY_BOOKMARKS")
|
||||
<< QStringLiteral("android.permission.WRITE_OWNER_DATA")
|
||||
<< QStringLiteral("android.permission.WRITE_SECURE_SETTINGS")
|
||||
<< QStringLiteral("android.permission.WRITE_SETTINGS")
|
||||
<< QStringLiteral("android.permission.WRITE_SMS")
|
||||
<< QStringLiteral("android.permission.WRITE_SYNC_SETTINGS")
|
||||
);
|
||||
m_permissionsComboBox->setEditable(true);
|
||||
layout->addWidget(m_permissionsComboBox, 4, 0);
|
||||
|
||||
m_addPermissionButton = new QPushButton(mainWidget);
|
||||
m_addPermissionButton->setText(tr("Add"));
|
||||
layout->addWidget(m_addPermissionButton, 4, 1);
|
||||
|
||||
permissionsPanel->setWidget(mainWidget);
|
||||
|
||||
connect(m_addPermissionButton, SIGNAL(clicked()),
|
||||
this, SLOT(addPermission()));
|
||||
connect(m_removePermissionButton, SIGNAL(clicked()),
|
||||
this, SLOT(removePermission()));
|
||||
connect(m_permissionsComboBox, SIGNAL(currentTextChanged(QString)),
|
||||
this, SLOT(updateAddRemovePermissionButtons()));
|
||||
}
|
||||
generalPanel->addPropertiesPanel(permissionsPanel);
|
||||
|
||||
m_overlayWidget = generalPanel;
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
PlainTextEditorWidget::resizeEvent(event);
|
||||
QSize s = QSize(rect().width(), rect().height());
|
||||
m_overlayWidget->resize(s);
|
||||
}
|
||||
|
||||
bool AndroidManifestEditorWidget::open(QString *errorString, const QString &fileName, const QString &realFileName)
|
||||
{
|
||||
bool result = PlainTextEditorWidget::open(errorString, fileName, realFileName);
|
||||
if (!result)
|
||||
return result;
|
||||
|
||||
Q_UNUSED(errorString);
|
||||
QString error;
|
||||
int errorLine;
|
||||
int errorColumn;
|
||||
QDomDocument doc;
|
||||
if (doc.setContent(toPlainText(), &error, &errorLine, &errorColumn)) {
|
||||
if (checkDocument(doc, &error, &errorLine, &errorColumn)) {
|
||||
if (activePage() != Source)
|
||||
syncToWidgets(doc);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// some error occured
|
||||
updateInfoBar(error, errorLine, errorColumn);
|
||||
setActivePage(Source);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::setDirty(bool dirty)
|
||||
{
|
||||
if (m_stayClean)
|
||||
return;
|
||||
m_dirty = dirty;
|
||||
emit changed();
|
||||
}
|
||||
|
||||
bool AndroidManifestEditorWidget::isModified() const
|
||||
{
|
||||
return m_dirty
|
||||
|| !m_hIconPath.isEmpty()
|
||||
|| !m_mIconPath.isEmpty()
|
||||
|| !m_lIconPath.isEmpty()
|
||||
|| m_setAppName;
|
||||
}
|
||||
|
||||
AndroidManifestEditorWidget::EditorPage AndroidManifestEditorWidget::activePage() const
|
||||
{
|
||||
return m_overlayWidget->isVisibleTo(this) ? General : Source;
|
||||
}
|
||||
|
||||
bool AndroidManifestEditorWidget::setActivePage(EditorPage page)
|
||||
{
|
||||
EditorPage prevPage = activePage();
|
||||
|
||||
if (prevPage == page)
|
||||
return true;
|
||||
|
||||
if (page == Source) {
|
||||
syncToEditor();
|
||||
} else if (prevPage == Source) {
|
||||
if (!syncToWidgets()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
m_overlayWidget->setVisible(page == General);
|
||||
if (page == General) {
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
} else {
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::preSave()
|
||||
{
|
||||
if (activePage() != Source)
|
||||
syncToEditor();
|
||||
|
||||
if (m_setAppName) {
|
||||
QString baseDir = QFileInfo(static_cast<AndroidManifestDocument *>(editor()->document())->fileName()).absolutePath();
|
||||
QString fileName = baseDir + QLatin1String("/res/values/strings.xml");
|
||||
QFile f(fileName);
|
||||
if (f.open(QIODevice::ReadOnly)) {
|
||||
QDomDocument doc;
|
||||
if (doc.setContent(f.readAll())) {
|
||||
QDomElement metadataElem = doc.documentElement().firstChildElement(QLatin1String("string"));
|
||||
while (!metadataElem.isNull()) {
|
||||
if (metadataElem.attribute(QLatin1String("name")) == QLatin1String("app_name")) {
|
||||
metadataElem.removeChild(metadataElem.firstChild());
|
||||
metadataElem.appendChild(doc.createTextNode(m_appNameLineEdit->text()));
|
||||
break;
|
||||
}
|
||||
metadataElem = metadataElem.nextSiblingElement(QLatin1String("string"));
|
||||
}
|
||||
|
||||
f.close();
|
||||
f.open(QIODevice::WriteOnly);
|
||||
f.write(doc.toByteArray((4)));
|
||||
}
|
||||
}
|
||||
m_setAppName = false;
|
||||
}
|
||||
|
||||
QString baseDir = QFileInfo(static_cast<AndroidManifestDocument *>(editor()->document())->fileName()).absolutePath();
|
||||
if (!m_lIconPath.isEmpty()) {
|
||||
copyIcon(LowDPI, baseDir, m_lIconPath);
|
||||
m_lIconPath.clear();
|
||||
}
|
||||
if (!m_mIconPath.isEmpty()) {
|
||||
copyIcon(MediumDPI, baseDir, m_mIconPath);
|
||||
m_mIconPath.clear();
|
||||
}
|
||||
if (!m_hIconPath.isEmpty()) {
|
||||
copyIcon(HighDPI, baseDir, m_hIconPath);
|
||||
m_hIconPath.clear();
|
||||
}
|
||||
// no need to emit changed() since this is called as part of saving
|
||||
|
||||
updateInfoBar();
|
||||
}
|
||||
|
||||
bool AndroidManifestEditorWidget::syncToWidgets()
|
||||
{
|
||||
QDomDocument doc;
|
||||
QString errorMessage;
|
||||
int errorLine, errorColumn;
|
||||
if (doc.setContent(toPlainText(), &errorMessage, &errorLine, &errorColumn)) {
|
||||
if (checkDocument(doc, &errorMessage, &errorLine, &errorColumn)) {
|
||||
hideInfoBar();
|
||||
syncToWidgets(doc);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
updateInfoBar(errorMessage, errorLine, errorColumn);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AndroidManifestEditorWidget::checkDocument(QDomDocument doc, QString *errorMessage, int *errorLine, int *errorColumn)
|
||||
{
|
||||
QDomElement manifest = doc.documentElement();
|
||||
if (manifest.tagName() != QLatin1String("manifest")) {
|
||||
*errorMessage = tr("The structure of the android manifest file is corrupt. Expected a top level 'manifest' node.");
|
||||
*errorLine = -1;
|
||||
*errorColumn = -1;
|
||||
return false;
|
||||
} else if (manifest.firstChildElement(QLatin1String("application")).firstChildElement(QLatin1String("activity")).isNull()) {
|
||||
// missing either application or activity element
|
||||
*errorMessage = tr("The structure of the android manifest file is corrupt. Expected a 'application' and 'activity' sub node.");
|
||||
*errorLine = -1;
|
||||
*errorColumn = -1;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::startParseCheck()
|
||||
{
|
||||
m_timerParseCheck.start();
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::delayedParseCheck()
|
||||
{
|
||||
updateInfoBar();
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::updateInfoBar()
|
||||
{
|
||||
if (activePage() != Source) {
|
||||
m_timerParseCheck.stop();
|
||||
return;
|
||||
}
|
||||
QDomDocument doc;
|
||||
int errorLine, errorColumn;
|
||||
QString errorMessage;
|
||||
if (doc.setContent(toPlainText(), &errorMessage, &errorLine, &errorColumn)) {
|
||||
if (checkDocument(doc, &errorMessage, &errorLine, &errorColumn)) {
|
||||
hideInfoBar();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
updateInfoBar(errorMessage, errorLine, errorColumn);
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::updateInfoBar(const QString &errorMessage, int line, int column)
|
||||
{
|
||||
Core::InfoBar *infoBar = editorDocument()->infoBar();
|
||||
QString text;
|
||||
if (line < 0)
|
||||
text = tr("Could not parse file: '%1'").arg(errorMessage);
|
||||
else
|
||||
text = tr("%2: Could not parse file: '%1'").arg(errorMessage).arg(line);
|
||||
Core::InfoBarEntry infoBarEntry(infoBarId, text);
|
||||
infoBarEntry.setCustomButtonInfo(tr("Goto error"), this, SLOT(gotoError()));
|
||||
infoBar->removeInfo(infoBarId);
|
||||
infoBar->addInfo(infoBarEntry);
|
||||
|
||||
m_errorLine = line;
|
||||
m_errorColumn = column;
|
||||
m_timerParseCheck.stop();
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::hideInfoBar()
|
||||
{
|
||||
Core::InfoBar *infoBar = editorDocument()->infoBar();
|
||||
infoBar->removeInfo(infoBarId);
|
||||
m_timerParseCheck.stop();
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::gotoError()
|
||||
{
|
||||
gotoLine(m_errorLine, m_errorColumn);
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::syncToWidgets(const QDomDocument &doc)
|
||||
{
|
||||
m_stayClean = true;
|
||||
QDomElement manifest = doc.documentElement();
|
||||
m_packageNameLineEdit->setText(manifest.attribute(QLatin1String("package")));
|
||||
m_versionCode->setValue(manifest.attribute(QLatin1String("android:versionCode")).toInt());
|
||||
m_versionNameLinedit->setText(manifest.attribute(QLatin1String("android:versionName")));
|
||||
|
||||
QString baseDir = QFileInfo(static_cast<AndroidManifestDocument *>(editor()->document())->fileName()).absolutePath();
|
||||
QString fileName = baseDir + QLatin1String("/res/values/strings.xml");
|
||||
|
||||
QFile f(fileName);
|
||||
if (f.exists() && f.open(QIODevice::ReadOnly)) {
|
||||
QDomDocument doc;
|
||||
if (doc.setContent(&f)) {
|
||||
QDomElement metadataElem = doc.documentElement().firstChildElement(QLatin1String("string"));
|
||||
while (!metadataElem.isNull()) {
|
||||
if (metadataElem.attribute(QLatin1String("name")) == QLatin1String("app_name")) {
|
||||
m_appNameLineEdit->setText(metadataElem.text());
|
||||
break;
|
||||
}
|
||||
metadataElem = metadataElem.nextSiblingElement(QLatin1String("string"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QDomElement metadataElem = manifest.firstChildElement(QLatin1String("application")).firstChildElement(QLatin1String("activity")).firstChildElement(QLatin1String("meta-data"));
|
||||
while (!metadataElem.isNull()) {
|
||||
if (metadataElem.attribute(QLatin1String("android:name")) == QLatin1String("android.app.lib_name")) {
|
||||
m_targetLineEdit->setText(metadataElem.attribute(QLatin1String("android:value")));
|
||||
break;
|
||||
}
|
||||
metadataElem = metadataElem.nextSiblingElement(QLatin1String("meta-data"));
|
||||
}
|
||||
|
||||
m_lIconButton->setIcon(icon(baseDir, LowDPI));
|
||||
m_mIconButton->setIcon(icon(baseDir, MediumDPI));
|
||||
m_hIconButton->setIcon(icon(baseDir, HighDPI));
|
||||
m_lIconPath.clear();
|
||||
m_mIconPath.clear();
|
||||
m_hIconPath.clear();
|
||||
|
||||
QStringList permissions;
|
||||
QDomElement permissionElem = manifest.firstChildElement(QLatin1String("uses-permission"));
|
||||
while (!permissionElem.isNull()) {
|
||||
permissions << permissionElem.attribute(QLatin1String("android:name"));
|
||||
permissionElem = permissionElem.nextSiblingElement(QLatin1String("uses-permission"));
|
||||
}
|
||||
|
||||
m_permissionsModel->setPermissions(permissions);
|
||||
updateAddRemovePermissionButtons();
|
||||
|
||||
m_stayClean = false;
|
||||
m_dirty = false;
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::syncToEditor()
|
||||
{
|
||||
QDomDocument doc;
|
||||
if (!doc.setContent(toPlainText())) {
|
||||
// This should not happen
|
||||
updateInfoBar();
|
||||
return;
|
||||
}
|
||||
|
||||
QDomElement manifest = doc.documentElement();
|
||||
manifest.setAttribute(QLatin1String("package"), m_packageNameLineEdit->text());
|
||||
manifest.setAttribute(QLatin1String("android:versionCode"), m_versionCode->value());
|
||||
manifest.setAttribute(QLatin1String("android:versionName"), m_versionNameLinedit->text());
|
||||
|
||||
setAndroidAppLibName(doc, manifest.firstChildElement(QLatin1String("application")).firstChildElement(QLatin1String("activity")), m_targetLineEdit->text());
|
||||
|
||||
// permissions
|
||||
QDomElement permissionElem = manifest.firstChildElement(QLatin1String("uses-permission"));
|
||||
while (!permissionElem.isNull()) {
|
||||
manifest.removeChild(permissionElem);
|
||||
permissionElem = manifest.firstChildElement(QLatin1String("uses-permission"));
|
||||
}
|
||||
|
||||
foreach (const QString &permission, m_permissionsModel->permissions()) {
|
||||
permissionElem = doc.createElement(QLatin1String("uses-permission"));
|
||||
permissionElem.setAttribute(QLatin1String("android:name"), permission);
|
||||
manifest.appendChild(permissionElem);
|
||||
}
|
||||
|
||||
bool ensureIconAttribute = !m_lIconPath.isEmpty()
|
||||
|| !m_mIconPath.isEmpty()
|
||||
|| !m_hIconPath.isEmpty();
|
||||
|
||||
if (ensureIconAttribute) {
|
||||
QDomElement applicationElem = manifest.firstChildElement(QLatin1String("application"));
|
||||
applicationElem.setAttribute(QLatin1String("android:icon"), QLatin1String("@drawable/icon"));
|
||||
}
|
||||
|
||||
|
||||
QString newText = doc.toString();
|
||||
if (newText == toPlainText())
|
||||
return;
|
||||
|
||||
setPlainText(newText);
|
||||
document()->setModified(true); // Why is this necessary?
|
||||
|
||||
m_dirty = false;
|
||||
}
|
||||
|
||||
bool AndroidManifestEditorWidget::setAndroidAppLibName(QDomDocument document, QDomElement activity, const QString &name)
|
||||
{
|
||||
QDomElement metadataElem = activity.firstChildElement(QLatin1String("meta-data"));
|
||||
while (!metadataElem.isNull()) {
|
||||
if (metadataElem.attribute(QLatin1String("android:name")) == QLatin1String("android.app.lib_name")) {
|
||||
metadataElem.setAttribute(QLatin1String("android:value"), name);
|
||||
return true;
|
||||
}
|
||||
metadataElem = metadataElem.nextSiblingElement(QLatin1String("meta-data"));
|
||||
}
|
||||
QDomElement elem = document.createElement(QLatin1String("meta-data"));
|
||||
elem.setAttribute(QLatin1String("android:name"), QLatin1String("android.app.lib_name"));
|
||||
elem.setAttribute(QLatin1String("android:value"), name);
|
||||
activity.appendChild(elem);
|
||||
return true;
|
||||
}
|
||||
|
||||
QString AndroidManifestEditorWidget::iconPath(const QString &baseDir, IconDPI dpi)
|
||||
{
|
||||
Utils::FileName fileName = Utils::FileName::fromString(baseDir);
|
||||
switch (dpi) {
|
||||
case HighDPI:
|
||||
fileName.appendPath(QLatin1String("res/drawable-hdpi/icon.png"));
|
||||
break;
|
||||
case MediumDPI:
|
||||
fileName.appendPath(QLatin1String("res/drawable-mdpi/icon.png"));
|
||||
break;
|
||||
case LowDPI:
|
||||
fileName.appendPath(QLatin1String("res/drawable-ldpi/icon.png"));
|
||||
break;
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
return fileName.toString();
|
||||
}
|
||||
|
||||
QIcon AndroidManifestEditorWidget::icon(const QString &baseDir, IconDPI dpi)
|
||||
{
|
||||
|
||||
if (dpi == HighDPI && !m_hIconPath.isEmpty())
|
||||
return QIcon(m_hIconPath);
|
||||
|
||||
if (dpi == MediumDPI && !m_mIconPath.isEmpty())
|
||||
return QIcon(m_mIconPath);
|
||||
|
||||
if (dpi == LowDPI && !m_lIconPath.isEmpty())
|
||||
return QIcon(m_lIconPath);
|
||||
|
||||
QString fileName = iconPath(baseDir, dpi);
|
||||
if (fileName.isEmpty())
|
||||
return QIcon();
|
||||
return QIcon(fileName);
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::copyIcon(IconDPI dpi, const QString &baseDir, const QString &filePath)
|
||||
{
|
||||
if (!QFileInfo(filePath).exists())
|
||||
return;
|
||||
|
||||
const QString targetPath = iconPath(baseDir, dpi);
|
||||
QFile::remove(targetPath);
|
||||
QDir dir;
|
||||
dir.mkpath(QFileInfo(targetPath).absolutePath());
|
||||
QFile::copy(filePath, targetPath);
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::setLDPIIcon()
|
||||
{
|
||||
QString file = QFileDialog::getOpenFileName(this, tr("Choose Low DPI Icon"), QDir::homePath(), tr("PNG images (*.png)"));
|
||||
if (file.isEmpty())
|
||||
return;
|
||||
m_lIconPath = file;
|
||||
m_lIconButton->setIcon(QIcon(file));
|
||||
setDirty(true);
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::setMDPIIcon()
|
||||
{
|
||||
QString file = QFileDialog::getOpenFileName(this, tr("Choose Medium DPI Icon"), QDir::homePath(), tr("PNG images (*.png)"));
|
||||
if (file.isEmpty())
|
||||
return;
|
||||
m_mIconPath = file;
|
||||
m_mIconButton->setIcon(QIcon(file));
|
||||
setDirty(true);
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::setHDPIIcon()
|
||||
{
|
||||
QString file = QFileDialog::getOpenFileName(this, tr("Choose High DPI Icon"), QDir::homePath(), tr("PNG images (*.png)"));
|
||||
if (file.isEmpty())
|
||||
return;
|
||||
m_hIconPath = file;
|
||||
m_hIconButton->setIcon(QIcon(file));
|
||||
setDirty(true);
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::updateAddRemovePermissionButtons()
|
||||
{
|
||||
QStringList permissions = m_permissionsModel->permissions();
|
||||
m_removePermissionButton->setEnabled(!permissions.isEmpty());
|
||||
|
||||
m_addPermissionButton->setEnabled(!permissions.contains(m_permissionsComboBox->currentText()));
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::addPermission()
|
||||
{
|
||||
m_permissionsModel->addPermission(m_permissionsComboBox->currentText());
|
||||
updateAddRemovePermissionButtons();
|
||||
setDirty(true);
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::removePermission()
|
||||
{
|
||||
QModelIndex idx = m_permissionsListView->currentIndex();
|
||||
if (idx.isValid())
|
||||
m_permissionsModel->removePermission(idx.row());
|
||||
updateAddRemovePermissionButtons();
|
||||
setDirty(true);
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::setAppName()
|
||||
{
|
||||
m_setAppName = true;
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::setPackageName()
|
||||
{
|
||||
const QString packageName= m_packageNameLineEdit->text();
|
||||
|
||||
bool valid = checkPackageName(packageName);
|
||||
m_packageNameWarning->setVisible(!valid);
|
||||
m_packageNameWarningIcon->setVisible(!valid);
|
||||
setDirty(true);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////// PermissionsModel /////////////////////////////
|
||||
|
||||
PermissionsModel::PermissionsModel(QObject *parent)
|
||||
: QAbstractListModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void PermissionsModel::setPermissions(const QStringList &permissions)
|
||||
{
|
||||
beginResetModel();
|
||||
m_permissions = permissions;
|
||||
qSort(m_permissions);
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
const QStringList &PermissionsModel::permissions()
|
||||
{
|
||||
return m_permissions;
|
||||
}
|
||||
|
||||
QModelIndex PermissionsModel::addPermission(const QString &permission)
|
||||
{
|
||||
const int idx = qLowerBound(m_permissions, permission) - m_permissions.constBegin();
|
||||
beginInsertRows(QModelIndex(), idx, idx);
|
||||
m_permissions.insert(idx, permission);
|
||||
endInsertRows();
|
||||
return index(idx);
|
||||
}
|
||||
|
||||
bool PermissionsModel::updatePermission(QModelIndex index, const QString &permission)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return false;
|
||||
if (m_permissions[index.row()] == permission)
|
||||
return false;
|
||||
|
||||
int newIndex = qLowerBound(m_permissions.constBegin(), m_permissions.constEnd(), permission) - m_permissions.constBegin();
|
||||
if (newIndex == index.row() || newIndex == index.row() + 1) {
|
||||
m_permissions[index.row()] = permission;
|
||||
emit dataChanged(index, index);
|
||||
return true;
|
||||
}
|
||||
|
||||
beginMoveRows(QModelIndex(), index.row(), index.row(), QModelIndex(), newIndex);
|
||||
|
||||
if (newIndex > index.row()) {
|
||||
m_permissions.insert(newIndex, permission);
|
||||
m_permissions.removeAt(index.row());
|
||||
} else {
|
||||
m_permissions.removeAt(index.row());
|
||||
m_permissions.insert(newIndex, permission);
|
||||
}
|
||||
endMoveRows();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void PermissionsModel::removePermission(int index)
|
||||
{
|
||||
if (index >= m_permissions.size())
|
||||
return;
|
||||
beginRemoveRows(QModelIndex(), index, index);
|
||||
m_permissions.removeAt(index);
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
QVariant PermissionsModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || !index.isValid())
|
||||
return QVariant();
|
||||
return m_permissions[index.row()];
|
||||
}
|
||||
|
||||
int PermissionsModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return m_permissions.count();
|
||||
}
|
||||
173
src/plugins/android/androidmanifesteditorwidget.h
Normal file
173
src/plugins/android/androidmanifesteditorwidget.h
Normal file
@@ -0,0 +1,173 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ANDROIDMANIFESTEDITORWIDGET_H
|
||||
#define ANDROIDMANIFESTEDITORWIDGET_H
|
||||
|
||||
#include <texteditor/basetexteditor.h>
|
||||
#include <texteditor/plaintexteditor.h>
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <QStackedWidget>
|
||||
#include <QTimer>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QDomDocument;
|
||||
class QDomElement;
|
||||
class QComboBox;
|
||||
class QPushButton;
|
||||
class QLabel;
|
||||
class QLineEdit;
|
||||
class QListView;
|
||||
class QSpinBox;
|
||||
class QToolButton;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core { class IEditor; }
|
||||
|
||||
namespace TextEditor { class TextEditorActionHandler; }
|
||||
|
||||
namespace Android {
|
||||
namespace Internal {
|
||||
class AndroidManifestEditor;
|
||||
|
||||
|
||||
class PermissionsModel: public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PermissionsModel(QObject *parent = 0 );
|
||||
void setPermissions(const QStringList &permissions);
|
||||
const QStringList &permissions();
|
||||
QModelIndex addPermission(const QString &permission);
|
||||
bool updatePermission(QModelIndex index, const QString &permission);
|
||||
void removePermission(int index);
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
|
||||
protected:
|
||||
int rowCount(const QModelIndex &parent) const;
|
||||
|
||||
private:
|
||||
QStringList m_permissions;
|
||||
};
|
||||
|
||||
class AndroidManifestEditorWidget : public TextEditor::PlainTextEditorWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum EditorPage {
|
||||
General,
|
||||
Source
|
||||
};
|
||||
|
||||
explicit AndroidManifestEditorWidget(QWidget *parent, TextEditor::TextEditorActionHandler *ah);
|
||||
|
||||
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
|
||||
|
||||
bool isModified() const;
|
||||
|
||||
EditorPage activePage() const;
|
||||
bool setActivePage(EditorPage page);
|
||||
|
||||
void preSave();
|
||||
|
||||
public slots:
|
||||
void setDirty(bool dirty = true);
|
||||
|
||||
protected:
|
||||
TextEditor::BaseTextEditor *createEditor();
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
|
||||
private slots:
|
||||
void setLDPIIcon();
|
||||
void setMDPIIcon();
|
||||
void setHDPIIcon();
|
||||
void addPermission();
|
||||
void removePermission();
|
||||
void updateAddRemovePermissionButtons();
|
||||
void setAppName();
|
||||
void setPackageName();
|
||||
void gotoError();
|
||||
void updateInfoBar();
|
||||
void startParseCheck();
|
||||
void delayedParseCheck();
|
||||
private:
|
||||
void initializePage();
|
||||
bool syncToWidgets();
|
||||
void syncToWidgets(const QDomDocument &doc);
|
||||
void syncToEditor();
|
||||
|
||||
bool checkDocument(QDomDocument doc, QString *errorMessage, int *errorLine, int *errorColumn);
|
||||
bool setAndroidAppLibName(QDomDocument document, QDomElement activity, const QString &name);
|
||||
enum IconDPI { LowDPI, MediumDPI, HighDPI };
|
||||
QIcon icon(const QString &baseDir, IconDPI dpi);
|
||||
QString iconPath(const QString &baseDir, IconDPI dpi);
|
||||
void copyIcon(IconDPI dpi, const QString &baseDir, const QString &filePath);
|
||||
|
||||
void updateInfoBar(const QString &errorMessage, int line, int column);
|
||||
void hideInfoBar();
|
||||
|
||||
bool m_dirty; // indicates that we need to call syncToEditor()
|
||||
bool m_stayClean;
|
||||
bool m_setAppName;
|
||||
int m_errorLine;
|
||||
int m_errorColumn;
|
||||
|
||||
QLineEdit *m_packageNameLineEdit;
|
||||
QLabel *m_packageNameWarningIcon;
|
||||
QLabel *m_packageNameWarning;
|
||||
QSpinBox *m_versionCode;
|
||||
QLineEdit *m_versionNameLinedit;
|
||||
|
||||
// Application
|
||||
QLineEdit *m_appNameLineEdit;
|
||||
QLineEdit *m_targetLineEdit;
|
||||
QToolButton *m_lIconButton;
|
||||
QToolButton *m_mIconButton;
|
||||
QToolButton *m_hIconButton;
|
||||
QString m_lIconPath; // only set if the user changed the icon
|
||||
QString m_mIconPath;
|
||||
QString m_hIconPath;
|
||||
|
||||
// Permissions
|
||||
PermissionsModel *m_permissionsModel;
|
||||
QListView *m_permissionsListView;
|
||||
QPushButton *m_addPermissionButton;
|
||||
QPushButton *m_removePermissionButton;
|
||||
QComboBox *m_permissionsComboBox;
|
||||
|
||||
TextEditor::TextEditorActionHandler *m_ah;
|
||||
QWidget *m_overlayWidget;
|
||||
QTimer m_timerParseCheck;
|
||||
};
|
||||
} // namespace Internal
|
||||
} // namespace Android
|
||||
|
||||
|
||||
#endif // ANDROIDMANIFESTEDITORWIDGET_H
|
||||
@@ -57,13 +57,6 @@ namespace Internal {
|
||||
|
||||
using namespace Qt4ProjectManager;
|
||||
|
||||
const QLatin1String packageNameRegExp("^([a-z_]{1}[a-z0-9_]+(\\.[a-zA-Z_]{1}[a-zA-Z0-9_]*)*)$");
|
||||
|
||||
bool checkPackageName(const QString &packageName)
|
||||
{
|
||||
return QRegExp(packageNameRegExp).exactMatch(packageName);
|
||||
}
|
||||
|
||||
///////////////////////////// CheckModel /////////////////////////////
|
||||
|
||||
CheckModel::CheckModel(QObject *parent)
|
||||
@@ -140,87 +133,6 @@ Qt::ItemFlags CheckModel::flags(const QModelIndex &/*index*/) const
|
||||
return Qt::ItemIsSelectable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////// PermissionsModel /////////////////////////////
|
||||
|
||||
PermissionsModel::PermissionsModel(QObject *parent)
|
||||
: QAbstractListModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void PermissionsModel::setPermissions(const QStringList &permissions)
|
||||
{
|
||||
beginResetModel();
|
||||
m_permissions = permissions;
|
||||
qSort(m_permissions);
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
const QStringList &PermissionsModel::permissions()
|
||||
{
|
||||
return m_permissions;
|
||||
}
|
||||
|
||||
QModelIndex PermissionsModel::addPermission(const QString &permission)
|
||||
{
|
||||
const int idx = qLowerBound(m_permissions, permission) - m_permissions.constBegin();
|
||||
beginInsertRows(QModelIndex(), idx, idx);
|
||||
m_permissions.insert(idx, permission);
|
||||
endInsertRows();
|
||||
return index(idx);
|
||||
}
|
||||
|
||||
bool PermissionsModel::updatePermission(QModelIndex index, const QString &permission)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return false;
|
||||
if (m_permissions[index.row()] == permission)
|
||||
return false;
|
||||
|
||||
int newIndex = qLowerBound(m_permissions.constBegin(), m_permissions.constEnd(), permission) - m_permissions.constBegin();
|
||||
if (newIndex == index.row() || newIndex == index.row() + 1) {
|
||||
m_permissions[index.row()] = permission;
|
||||
emit dataChanged(index, index);
|
||||
return true;
|
||||
}
|
||||
|
||||
beginMoveRows(QModelIndex(), index.row(), index.row(), QModelIndex(), newIndex);
|
||||
|
||||
if (newIndex > index.row()) {
|
||||
m_permissions.insert(newIndex, permission);
|
||||
m_permissions.removeAt(index.row());
|
||||
} else {
|
||||
m_permissions.removeAt(index.row());
|
||||
m_permissions.insert(newIndex, permission);
|
||||
}
|
||||
endMoveRows();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void PermissionsModel::removePermission(int index)
|
||||
{
|
||||
if (index >= m_permissions.size())
|
||||
return;
|
||||
beginRemoveRows(QModelIndex(), index, index);
|
||||
m_permissions.removeAt(index);
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
QVariant PermissionsModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || !index.isValid())
|
||||
return QVariant();
|
||||
return m_permissions[index.row()];
|
||||
}
|
||||
|
||||
int PermissionsModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return m_permissions.count();
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////// AndroidPackageCreationWidget /////////////////////////////
|
||||
|
||||
AndroidPackageCreationWidget::AndroidPackageCreationWidget(AndroidPackageCreationStep *step)
|
||||
@@ -231,7 +143,6 @@ AndroidPackageCreationWidget::AndroidPackageCreationWidget(AndroidPackageCreatio
|
||||
{
|
||||
m_qtLibsModel = new CheckModel(this);
|
||||
m_prebundledLibs = new CheckModel(this);
|
||||
m_permissionsModel = new PermissionsModel(this);
|
||||
|
||||
m_ui->setupUi(this);
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
@@ -252,19 +163,7 @@ void AndroidPackageCreationWidget::initGui()
|
||||
connect(m_fileSystemWatcher, SIGNAL(fileChanged(QString)), this,
|
||||
SLOT(updateAndroidProjectInfo()));
|
||||
|
||||
m_ui->packageNameLineEdit->setValidator(new QRegExpValidator(QRegExp(packageNameRegExp), this));
|
||||
connect(m_ui->packageNameLineEdit, SIGNAL(editingFinished()), SLOT(setPackageName()));
|
||||
connect(m_ui->appNameLineEdit, SIGNAL(editingFinished()), SLOT(setApplicationName()));
|
||||
connect(m_ui->versionCode, SIGNAL(editingFinished()), SLOT(setVersionCode()));
|
||||
connect(m_ui->versionNameLinedit, SIGNAL(editingFinished()), SLOT(setVersionName()));
|
||||
connect(m_ui->targetSDKComboBox, SIGNAL(activated(QString)), SLOT(setTargetSDK(QString)));
|
||||
connect(m_ui->permissionsListView, SIGNAL(activated(QModelIndex)), SLOT(permissionActivated(QModelIndex)));
|
||||
connect(m_ui->addPermissionButton, SIGNAL(clicked()), SLOT(addPermission()));
|
||||
connect(m_ui->removePermissionButton, SIGNAL(clicked()), SLOT(removePermission()));
|
||||
connect(m_ui->permissionsComboBox->lineEdit(), SIGNAL(editingFinished()), SLOT(updatePermission()));
|
||||
connect(m_ui->savePermissionsButton, SIGNAL(clicked()), SLOT(savePermissionsButton()));
|
||||
connect(m_ui->discardPermissionsButton, SIGNAL(clicked()), SLOT(discardPermissionsButton()));
|
||||
connect(m_ui->targetComboBox, SIGNAL(activated(QString)), SLOT(setTarget(QString)));
|
||||
connect(m_qtLibsModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), SLOT(setQtLibs(QModelIndex,QModelIndex)));
|
||||
connect(m_prebundledLibs, SIGNAL(dataChanged(QModelIndex,QModelIndex)), SLOT(setPrebundledLibs(QModelIndex,QModelIndex)));
|
||||
connect(m_ui->prebundledLibsListView, SIGNAL(activated(QModelIndex)), SLOT(prebundledLibSelected(QModelIndex)));
|
||||
@@ -273,13 +172,8 @@ void AndroidPackageCreationWidget::initGui()
|
||||
connect(m_ui->downPushButton, SIGNAL(clicked()), SLOT(prebundledLibMoveDown()));
|
||||
connect(m_ui->readInfoPushButton, SIGNAL(clicked()), SLOT(readElfInfo()));
|
||||
|
||||
connect(m_ui->hIconButton, SIGNAL(clicked()), SLOT(setHDPIIcon()));
|
||||
connect(m_ui->mIconButton, SIGNAL(clicked()), SLOT(setMDPIIcon()));
|
||||
connect(m_ui->lIconButton, SIGNAL(clicked()), SLOT(setLDPIIcon()));
|
||||
|
||||
m_ui->qtLibsListView->setModel(m_qtLibsModel);
|
||||
m_ui->prebundledLibsListView->setModel(m_prebundledLibs);
|
||||
m_ui->permissionsListView->setModel(m_permissionsModel);
|
||||
m_ui->KeystoreLocationLineEdit->setText(m_step->keystorePath().toUserOutput());
|
||||
|
||||
// Make the buildconfiguration emit a evironmentChanged() signal
|
||||
@@ -295,7 +189,6 @@ void AndroidPackageCreationWidget::initGui()
|
||||
void AndroidPackageCreationWidget::updateAndroidProjectInfo()
|
||||
{
|
||||
ProjectExplorer::Target *target = m_step->target();
|
||||
const QString packageName = AndroidManager::packageName(target);
|
||||
m_ui->targetSDKComboBox->clear();
|
||||
|
||||
int minApiLevel = 4;
|
||||
@@ -306,59 +199,11 @@ void AndroidPackageCreationWidget::updateAndroidProjectInfo()
|
||||
QStringList targets = AndroidConfigurations::instance().sdkTargets(minApiLevel);
|
||||
m_ui->targetSDKComboBox->addItems(targets);
|
||||
m_ui->targetSDKComboBox->setCurrentIndex(targets.indexOf(AndroidManager::targetSDK(target)));
|
||||
m_ui->packageNameLineEdit->setText(packageName);
|
||||
m_ui->appNameLineEdit->setText(AndroidManager::applicationName(target));
|
||||
if (!m_ui->appNameLineEdit->text().length()) {
|
||||
QString applicationName = target->project()->displayName();
|
||||
AndroidManager::setPackageName(target, packageName + QLatin1Char('.') + applicationName);
|
||||
m_ui->packageNameLineEdit->setText(packageName);
|
||||
if (!applicationName.isEmpty())
|
||||
applicationName[0] = applicationName[0].toUpper();
|
||||
m_ui->appNameLineEdit->setText(applicationName);
|
||||
AndroidManager::setApplicationName(target, applicationName);
|
||||
}
|
||||
m_ui->versionCode->setValue(AndroidManager::versionCode(target));
|
||||
m_ui->versionNameLinedit->setText(AndroidManager::versionName(target));
|
||||
|
||||
m_qtLibsModel->setAvailableItems(AndroidManager::availableQtLibs(target));
|
||||
m_qtLibsModel->setCheckedItems(AndroidManager::qtLibs(target));
|
||||
m_prebundledLibs->setAvailableItems(AndroidManager::availablePrebundledLibs(target));
|
||||
m_prebundledLibs->setCheckedItems(AndroidManager::prebundledLibs(target));
|
||||
|
||||
m_permissionsModel->setPermissions(AndroidManager::permissions(target));
|
||||
m_ui->removePermissionButton->setEnabled(m_permissionsModel->permissions().size());
|
||||
|
||||
targets = AndroidManager::availableTargetApplications(target);
|
||||
m_ui->targetComboBox->clear();
|
||||
m_ui->targetComboBox->addItems(targets);
|
||||
m_ui->targetComboBox->setCurrentIndex(targets.indexOf(AndroidManager::targetApplication(target)));
|
||||
if (m_ui->targetComboBox->currentIndex() == -1 && targets.count()) {
|
||||
m_ui->targetComboBox->setCurrentIndex(0);
|
||||
AndroidManager::setTargetApplication(target, m_ui->targetComboBox->currentText());
|
||||
}
|
||||
m_ui->hIconButton->setIcon(AndroidManager::highDpiIcon(target));
|
||||
m_ui->mIconButton->setIcon(AndroidManager::mediumDpiIcon(target));
|
||||
m_ui->lIconButton->setIcon(AndroidManager::lowDpiIcon(target));
|
||||
}
|
||||
|
||||
void AndroidPackageCreationWidget::setPackageName()
|
||||
{
|
||||
const QString packageName= m_ui->packageNameLineEdit->text();
|
||||
if (!checkPackageName(packageName)) {
|
||||
QMessageBox::critical(this, tr("Invalid Package Name") ,
|
||||
tr("The package name '%1' is not valid.\n"
|
||||
"Please choose a valid package name for your application (e.g. \"org.example.myapplication\").")
|
||||
.arg(packageName));
|
||||
m_ui->packageNameLineEdit->selectAll();
|
||||
m_ui->packageNameLineEdit->setFocus();
|
||||
return;
|
||||
}
|
||||
AndroidManager::setPackageName(m_step->target(), packageName);
|
||||
}
|
||||
|
||||
void AndroidPackageCreationWidget::setApplicationName()
|
||||
{
|
||||
AndroidManager::setApplicationName(m_step->target(), m_ui->appNameLineEdit->text());
|
||||
}
|
||||
|
||||
void AndroidPackageCreationWidget::setTargetSDK(const QString &sdk)
|
||||
@@ -385,21 +230,6 @@ void AndroidPackageCreationWidget::setTargetSDK(const QString &sdk)
|
||||
bc->setUseSystemEnvironment(use);
|
||||
}
|
||||
|
||||
void AndroidPackageCreationWidget::setVersionCode()
|
||||
{
|
||||
AndroidManager::setVersionCode(m_step->target(), m_ui->versionCode->value());
|
||||
}
|
||||
|
||||
void AndroidPackageCreationWidget::setVersionName()
|
||||
{
|
||||
AndroidManager::setVersionName(m_step->target(), m_ui->versionNameLinedit->text());
|
||||
}
|
||||
|
||||
void AndroidPackageCreationWidget::setTarget(const QString &target)
|
||||
{
|
||||
AndroidManager::setTargetApplication(m_step->target(), target);
|
||||
}
|
||||
|
||||
void AndroidPackageCreationWidget::setQtLibs(QModelIndex, QModelIndex)
|
||||
{
|
||||
AndroidManager::setQtLibs(m_step->target(), m_qtLibsModel->checkedItems());
|
||||
@@ -442,78 +272,6 @@ void AndroidPackageCreationWidget::prebundledLibMoveDown()
|
||||
m_prebundledLibs->moveUp(index.row() + 1);
|
||||
}
|
||||
|
||||
void AndroidPackageCreationWidget::setHDPIIcon()
|
||||
{
|
||||
QString file = QFileDialog::getOpenFileName(this, tr("Choose High DPI Icon"), QDir::homePath(), tr("PNG images (*.png)"));
|
||||
if (!file.length())
|
||||
return;
|
||||
AndroidManager::setHighDpiIcon(m_step->target(), file);
|
||||
m_ui->hIconButton->setIcon(AndroidManager::highDpiIcon(m_step->target()));
|
||||
}
|
||||
|
||||
void AndroidPackageCreationWidget::setMDPIIcon()
|
||||
{
|
||||
QString file = QFileDialog::getOpenFileName(this, tr("Choose Medium DPI Icon"), QDir::homePath(), tr("PNG images (*.png)"));
|
||||
if (!file.length())
|
||||
return;
|
||||
AndroidManager::setMediumDpiIcon(m_step->target(), file);
|
||||
m_ui->mIconButton->setIcon(AndroidManager::mediumDpiIcon(m_step->target()));
|
||||
}
|
||||
|
||||
void AndroidPackageCreationWidget::setLDPIIcon()
|
||||
{
|
||||
QString file = QFileDialog::getOpenFileName(this, tr("Choose Low DPI Icon"), QDir::homePath(), tr("PNG images (*.png)"));
|
||||
if (!file.length())
|
||||
return;
|
||||
AndroidManager::setLowDpiIcon(m_step->target(), file);
|
||||
m_ui->lIconButton->setIcon(AndroidManager::lowDpiIcon(m_step->target()));
|
||||
}
|
||||
|
||||
void AndroidPackageCreationWidget::permissionActivated(QModelIndex index)
|
||||
{
|
||||
m_ui->permissionsComboBox->setCurrentIndex(
|
||||
m_ui->permissionsComboBox->findText(m_permissionsModel->data(index, Qt::DisplayRole).toString()));
|
||||
m_ui->permissionsComboBox->lineEdit()->setText(m_permissionsModel->data(index, Qt::DisplayRole).toString());
|
||||
}
|
||||
|
||||
void AndroidPackageCreationWidget::addPermission()
|
||||
{
|
||||
setEnabledSaveDiscardButtons(true);
|
||||
m_ui->permissionsListView->setCurrentIndex(m_permissionsModel->addPermission(tr("< Type or choose a permission >")));
|
||||
m_ui->permissionsComboBox->lineEdit()->setText(tr("< Type or choose a permission >"));
|
||||
m_ui->permissionsComboBox->setFocus();
|
||||
m_ui->removePermissionButton->setEnabled(m_permissionsModel->permissions().size());
|
||||
}
|
||||
|
||||
void AndroidPackageCreationWidget::updatePermission()
|
||||
{
|
||||
if (m_permissionsModel->updatePermission(m_ui->permissionsListView->currentIndex(),
|
||||
m_ui->permissionsComboBox->lineEdit()->text()))
|
||||
setEnabledSaveDiscardButtons(true);
|
||||
}
|
||||
|
||||
void AndroidPackageCreationWidget::removePermission()
|
||||
{
|
||||
setEnabledSaveDiscardButtons(true);
|
||||
if (m_ui->permissionsListView->currentIndex().isValid())
|
||||
m_permissionsModel->removePermission(m_ui->permissionsListView->currentIndex().row());
|
||||
m_ui->removePermissionButton->setEnabled(m_permissionsModel->permissions().size());
|
||||
}
|
||||
|
||||
void AndroidPackageCreationWidget::savePermissionsButton()
|
||||
{
|
||||
setEnabledSaveDiscardButtons(false);
|
||||
AndroidManager::setPermissions(m_step->target(), m_permissionsModel->permissions());
|
||||
}
|
||||
|
||||
void AndroidPackageCreationWidget::discardPermissionsButton()
|
||||
{
|
||||
setEnabledSaveDiscardButtons(false);
|
||||
m_permissionsModel->setPermissions(AndroidManager::permissions(m_step->target()));
|
||||
m_ui->permissionsComboBox->setCurrentIndex(-1);
|
||||
m_ui->removePermissionButton->setEnabled(m_permissionsModel->permissions().size());
|
||||
}
|
||||
|
||||
void AndroidPackageCreationWidget::updateRequiredLibrariesModels()
|
||||
{
|
||||
m_qtLibsModel->setCheckedItems(AndroidManager::qtLibs(m_step->target()));
|
||||
@@ -525,14 +283,6 @@ void AndroidPackageCreationWidget::readElfInfo()
|
||||
m_step->checkRequiredLibraries();
|
||||
}
|
||||
|
||||
void AndroidPackageCreationWidget::setEnabledSaveDiscardButtons(bool enabled)
|
||||
{
|
||||
if (!enabled)
|
||||
m_ui->permissionsListView->setFocus();
|
||||
m_ui->savePermissionsButton->setEnabled(enabled);
|
||||
m_ui->discardPermissionsButton->setEnabled(enabled);
|
||||
}
|
||||
|
||||
QString AndroidPackageCreationWidget::summaryText() const
|
||||
{
|
||||
return tr("<b>Package configurations</b>");
|
||||
|
||||
@@ -65,25 +65,6 @@ private:
|
||||
QStringList m_checkedItems;
|
||||
};
|
||||
|
||||
class PermissionsModel: public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PermissionsModel(QObject *parent = 0 );
|
||||
void setPermissions(const QStringList &permissions);
|
||||
const QStringList &permissions();
|
||||
QModelIndex addPermission(const QString &permission);
|
||||
bool updatePermission(QModelIndex index, const QString &permission);
|
||||
void removePermission(int index);
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
|
||||
protected:
|
||||
int rowCount(const QModelIndex &parent) const;
|
||||
|
||||
private:
|
||||
QStringList m_permissions;
|
||||
};
|
||||
|
||||
class AndroidPackageCreationWidget : public ProjectExplorer::BuildStepConfigWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -104,12 +85,7 @@ private slots:
|
||||
void initGui();
|
||||
void updateAndroidProjectInfo();
|
||||
|
||||
void setPackageName();
|
||||
void setApplicationName();
|
||||
void setTargetSDK(const QString &sdk);
|
||||
void setVersionCode();
|
||||
void setVersionName();
|
||||
void setTarget(const QString &target);
|
||||
|
||||
void setQtLibs(QModelIndex, QModelIndex);
|
||||
void setPrebundledLibs(QModelIndex, QModelIndex);
|
||||
@@ -117,16 +93,6 @@ private slots:
|
||||
void prebundledLibMoveUp();
|
||||
void prebundledLibMoveDown();
|
||||
|
||||
void setHDPIIcon();
|
||||
void setMDPIIcon();
|
||||
void setLDPIIcon();
|
||||
|
||||
void permissionActivated(QModelIndex index);
|
||||
void addPermission();
|
||||
void updatePermission();
|
||||
void removePermission();
|
||||
void savePermissionsButton();
|
||||
void discardPermissionsButton();
|
||||
void updateRequiredLibrariesModels();
|
||||
void on_signPackageCheckBox_toggled(bool checked);
|
||||
void on_KeystoreCreatePushButton_clicked();
|
||||
@@ -141,7 +107,6 @@ private:
|
||||
Ui::AndroidPackageCreationWidget *const m_ui;
|
||||
CheckModel *m_qtLibsModel;
|
||||
CheckModel *m_prebundledLibs;
|
||||
PermissionsModel *m_permissionsModel;
|
||||
QFileSystemWatcher *m_fileSystemWatcher;
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -43,6 +43,10 @@
|
||||
#include "androidqtversionfactory.h"
|
||||
#include "androiddeployconfiguration.h"
|
||||
#include "androidgdbserverkitinformation.h"
|
||||
#include "androidmanifesteditorfactory.h"
|
||||
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <qtsupport/qtversionmanager.h>
|
||||
|
||||
@@ -74,6 +78,20 @@ bool AndroidPlugin::initialize(const QStringList &arguments, QString *errorMessa
|
||||
addAutoReleasedObject(new Internal::AndroidDeviceFactory);
|
||||
ProjectExplorer::KitManager::instance()->registerKitInformation(new Internal::AndroidGdbServerKitInformation);
|
||||
|
||||
// AndroidManifest.xml editor
|
||||
Core::MimeGlobPattern androidManifestGlobPattern(QLatin1String("AndroidManifest.xml"), Core::MimeGlobPattern::MaxWeight);
|
||||
Core::MimeType androidManifestMimeType;
|
||||
androidManifestMimeType.setType(QLatin1String(Constants::ANDROID_MANIFEST_MIME_TYPE));
|
||||
androidManifestMimeType.setComment(tr("Android Manifest file"));
|
||||
androidManifestMimeType.setGlobPatterns(QList<Core::MimeGlobPattern>() << androidManifestGlobPattern);
|
||||
androidManifestMimeType.setSubClassesOf(QStringList() << QLatin1String("application/xml"));
|
||||
|
||||
if (!Core::ICore::mimeDatabase()->addMimeType(androidManifestMimeType)) {
|
||||
*errorMessage = tr("Could not add mime-type for AndroidManifest.xml editor.");
|
||||
return false;
|
||||
}
|
||||
addAutoReleasedObject(new Internal::AndroidManifestEditorFactory);
|
||||
|
||||
connect(ProjectExplorer::KitManager::instance(), SIGNAL(kitsLoaded()),
|
||||
this, SLOT(kitsRestored()));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user