Extra library editor for Android

Add a list view to the deployment settings which allows you
to add and remove libraries from the ANDROID_EXTRA_LIBS
variable in the .pro file.

Task-number: QTCREATORBUG-9849
Change-Id: Ic0131c46be8fdef4b226b5ceb0ee82ea4dd82c6a
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
Eskil Abrahamsen Blomfeldt
2013-09-30 15:32:06 +02:00
parent bd144ab0f5
commit c8393b10fd
8 changed files with 386 additions and 65 deletions

View File

@@ -47,7 +47,8 @@ HEADERS += \
certificatesmodel.h \ certificatesmodel.h \
androiddeployqtwidget.h \ androiddeployqtwidget.h \
createandroidmanifestwizard.h \ createandroidmanifestwizard.h \
androidpotentialkit.h androidpotentialkit.h \
androidextralibrarylistmodel.h
SOURCES += \ SOURCES += \
androidconfigurations.cpp \ androidconfigurations.cpp \
@@ -89,7 +90,8 @@ SOURCES += \
certificatesmodel.cpp \ certificatesmodel.cpp \
androiddeployqtwidget.cpp \ androiddeployqtwidget.cpp \
createandroidmanifestwizard.cpp \ createandroidmanifestwizard.cpp \
androidpotentialkit.cpp androidpotentialkit.cpp \
androidextralibrarylistmodel.cpp
FORMS += \ FORMS += \
androidsettingswidget.ui \ androidsettingswidget.ui \

View File

@@ -35,6 +35,7 @@
#include "androiddeployqtstep.h" #include "androiddeployqtstep.h"
#include "androidmanager.h" #include "androidmanager.h"
#include "createandroidmanifestwizard.h" #include "createandroidmanifestwizard.h"
#include "androidextralibrarylistmodel.h"
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
#include <qt4projectmanager/qt4buildconfiguration.h> #include <qt4projectmanager/qt4buildconfiguration.h>
@@ -133,6 +134,19 @@ AndroidDeployQtWidget::AndroidDeployQtWidget(AndroidDeployQtStep *step)
connect(m_ui->createAndroidManifestButton, SIGNAL(clicked()), connect(m_ui->createAndroidManifestButton, SIGNAL(clicked()),
this, SLOT(createManifestButton())); this, SLOT(createManifestButton()));
m_extraLibraryListModel = new AndroidExtraLibraryListModel(static_cast<Qt4ProjectManager::Qt4Project *>(m_step->project()),
this);
m_ui->androidExtraLibsListView->setModel(m_extraLibraryListModel);
connect(m_ui->androidExtraLibsListView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SLOT(checkEnableRemoveButton()));
connect(m_ui->addAndroidExtraLibButton, SIGNAL(clicked()), this, SLOT(addAndroidExtraLib()));
connect(m_ui->removeAndroidExtraLibButton, SIGNAL(clicked()), this, SLOT(removeAndroidExtraLib()));
connect(m_step->project(), SIGNAL(proFilesEvaluated()), this, SLOT(checkProjectTemplate()));
checkProjectTemplate();
} }
AndroidDeployQtWidget::~AndroidDeployQtWidget() AndroidDeployQtWidget::~AndroidDeployQtWidget()
@@ -140,6 +154,15 @@ AndroidDeployQtWidget::~AndroidDeployQtWidget()
delete m_ui; delete m_ui;
} }
void AndroidDeployQtWidget::checkProjectTemplate()
{
Qt4ProjectManager::Qt4Project *project = static_cast<Qt4ProjectManager::Qt4Project *>(m_step->project());
if (project->rootQt4ProjectNode()->projectType() == Qt4ProjectManager::ApplicationTemplate)
m_ui->additionalLibrariesGroupBox->setEnabled(true);
else
m_ui->additionalLibrariesGroupBox->setEnabled(false);
}
void AndroidDeployQtWidget::createManifestButton() void AndroidDeployQtWidget::createManifestButton()
{ {
CreateAndroidManifestWizard wizard(m_step->target()); CreateAndroidManifestWizard wizard(m_step->target());
@@ -322,3 +345,25 @@ void AndroidDeployQtWidget::updateSigningWarning()
m_ui->signingDebugWarningLabel->setVisible(false); m_ui->signingDebugWarningLabel->setVisible(false);
} }
} }
void AndroidDeployQtWidget::addAndroidExtraLib()
{
QStringList fileNames = QFileDialog::getOpenFileNames(this,
tr("Select additional libraries"),
QDir::homePath(),
tr("Libraries (*.so)"));
if (!fileNames.isEmpty())
m_extraLibraryListModel->addEntries(fileNames);
}
void AndroidDeployQtWidget::removeAndroidExtraLib()
{
QModelIndexList removeList = m_ui->androidExtraLibsListView->selectionModel()->selectedIndexes();
m_extraLibraryListModel->removeEntries(removeList);
}
void AndroidDeployQtWidget::checkEnableRemoveButton()
{
m_ui->removeAndroidExtraLibButton->setEnabled(m_ui->androidExtraLibsListView->selectionModel()->hasSelection());
}

View File

@@ -43,6 +43,7 @@ namespace Qt4ProjectManager { class Qt4BuildConfiguration; }
namespace Android { namespace Android {
namespace Internal { namespace Internal {
class AndroidDeployQtStep; class AndroidDeployQtStep;
class AndroidExtraLibraryListModel;
class AndroidDeployQtWidget : public ProjectExplorer::BuildStepConfigWidget class AndroidDeployQtWidget : public ProjectExplorer::BuildStepConfigWidget
{ {
Q_OBJECT Q_OBJECT
@@ -71,6 +72,11 @@ private slots:
void updateInputFileUi(); void updateInputFileUi();
void inputFileComboBoxIndexChanged(); void inputFileComboBoxIndexChanged();
void createManifestButton(); void createManifestButton();
void addAndroidExtraLib();
void removeAndroidExtraLib();
void checkEnableRemoveButton();
void checkProjectTemplate();
private: private:
virtual QString summaryText() const; virtual QString summaryText() const;
virtual QString displayName() const; virtual QString displayName() const;
@@ -78,6 +84,7 @@ private:
Ui::AndroidDeployQtWidget *m_ui; Ui::AndroidDeployQtWidget *m_ui;
AndroidDeployQtStep *m_step; AndroidDeployQtStep *m_step;
AndroidExtraLibraryListModel *m_extraLibraryListModel;
Qt4ProjectManager::Qt4BuildConfiguration *m_currentBuildConfiguration; Qt4ProjectManager::Qt4BuildConfiguration *m_currentBuildConfiguration;
bool m_ignoreChange; bool m_ignoreChange;
}; };

View File

@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>682</width> <width>682</width>
<height>467</height> <height>615</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -80,7 +80,7 @@
<string/> <string/>
</property> </property>
<property name="pixmap"> <property name="pixmap">
<pixmap resource="../projectexplorer/projectexplorer.qrc">:/projectexplorer/images/compile_warning.png</pixmap> <pixmap>:/projectexplorer/images/compile_warning.png</pixmap>
</property> </property>
</widget> </widget>
</item> </item>
@@ -137,62 +137,6 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="3" column="0">
<widget class="QGroupBox" name="qtDeployment">
<property name="title">
<string>Qt Deployment</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="ministroOption">
<property name="toolTip">
<string>Use the external Ministro application to download and maintain Qt libraries.</string>
</property>
<property name="text">
<string>Use Ministro service to install Qt</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="temporaryQtOption">
<property name="toolTip">
<string>Push local Qt libraries to device. You must have Qt libraries compiled for that platform.
The APK will not be usable on any other device.</string>
</property>
<property name="text">
<string>Deploy local Qt libraries to temporary directory</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="bundleQtOption">
<property name="toolTip">
<string>Creates a standalone APK.</string>
</property>
<property name="text">
<string>Bundle Qt libraries in APK</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="QGroupBox" name="advancedActions"> <widget class="QGroupBox" name="advancedActions">
<property name="title"> <property name="title">
@@ -287,7 +231,7 @@ The APK will not be usable on any other device.</string>
<string/> <string/>
</property> </property>
<property name="pixmap"> <property name="pixmap">
<pixmap resource="../projectexplorer/projectexplorer.qrc">:/projectexplorer/images/compile_warning.png</pixmap> <pixmap>:/projectexplorer/images/compile_warning.png</pixmap>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
@@ -306,10 +250,133 @@ The APK will not be usable on any other device.</string>
</item> </item>
</layout> </layout>
</item> </item>
<item row="3" column="0">
<widget class="QGroupBox" name="qtDeployment">
<property name="title">
<string>Qt Deployment</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="ministroOption">
<property name="toolTip">
<string>Use the external Ministro application to download and maintain Qt libraries.</string>
</property>
<property name="text">
<string>Use Ministro service to install Qt</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="temporaryQtOption">
<property name="toolTip">
<string>Push local Qt libraries to device. You must have Qt libraries compiled for that platform.
The APK will not be usable on any other device.</string>
</property>
<property name="text">
<string>Deploy local Qt libraries to temporary directory</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="bundleQtOption">
<property name="toolTip">
<string>Creates a standalone APK.</string>
</property>
<property name="text">
<string>Bundle Qt libraries in APK</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QGroupBox" name="additionalLibrariesGroupBox">
<property name="title">
<string>Additional libraries</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="androidExtraLibsLayout">
<item>
<widget class="QListView" name="androidExtraLibsListView">
<property name="toolTip">
<string>List of extra libraries to include in Android package and load on start-up.</string>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="androidExtraLibsButtonLayout">
<item>
<widget class="QToolButton" name="addAndroidExtraLibButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Select a library to include in package</string>
</property>
<property name="text">
<string>Add</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextOnly</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="removeAndroidExtraLibButton">
<property name="toolTip">
<string>Remove currently selected library from list</string>
</property>
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<resources> <resources/>
<include location="../projectexplorer/projectexplorer.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>

View File

@@ -0,0 +1,131 @@
/**************************************************************************
**
** Copyright (c) 2013 BogDan Vatra <bog_dan_ro@yahoo.com>
** 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 "androidextralibrarylistmodel.h"
#include <qt4projectmanager/qt4project.h>
#include <qt4projectmanager/qt4nodes.h>
using namespace Android;
using namespace Internal;
AndroidExtraLibraryListModel::AndroidExtraLibraryListModel(Qt4ProjectManager::Qt4Project *project,
QObject *parent)
: QAbstractItemModel(parent)
, m_project(project)
{
reset();
connect(m_project, SIGNAL(proFilesEvaluated()), this, SLOT(reset()));
}
QModelIndex AndroidExtraLibraryListModel::index(int row, int column, const QModelIndex &) const
{
return createIndex(row, column);
}
QModelIndex AndroidExtraLibraryListModel::parent(const QModelIndex &) const
{
return QModelIndex();
}
int AndroidExtraLibraryListModel::rowCount(const QModelIndex &) const
{
return m_entries.size();
}
int AndroidExtraLibraryListModel::columnCount(const QModelIndex &) const
{
return 1;
}
QVariant AndroidExtraLibraryListModel::data(const QModelIndex &index, int role) const
{
Q_ASSERT(index.row() >= 0 && index.row() < m_entries.size());
const QString &entry = m_entries.at(index.row());
switch (role) {
case Qt::DisplayRole: return entry;
default: return QVariant();
};
}
void AndroidExtraLibraryListModel::reset()
{
if (m_project->rootQt4ProjectNode()->projectType() != Qt4ProjectManager::ApplicationTemplate)
return;
beginResetModel();
Qt4ProjectManager::Qt4ProFileNode *node = m_project->rootQt4ProjectNode();
m_entries = node->variableValue(Qt4ProjectManager::AndroidExtraLibs);
endResetModel();
}
void AndroidExtraLibraryListModel::addEntries(const QStringList &list)
{
if (m_project->rootQt4ProjectNode()->projectType() != Qt4ProjectManager::ApplicationTemplate)
return;
beginInsertRows(QModelIndex(), m_entries.size(), m_entries.size() + list.size());
foreach (QString path, list)
m_entries += QDir(m_project->projectDirectory()).relativeFilePath(path);
Qt4ProjectManager::Qt4ProFileNode *node = m_project->rootQt4ProjectNode();
node->setProVariable(QLatin1String("ANDROID_EXTRA_LIBS"), m_entries.join(QLatin1Char(' ')));
endInsertRows();
}
void AndroidExtraLibraryListModel::removeEntries(const QModelIndexList &list)
{
if (list.isEmpty() || m_project->rootQt4ProjectNode()->projectType() != Qt4ProjectManager::ApplicationTemplate)
return;
QStringList oldList = m_entries;
int i = 0;
while (i < list.size()) {
int firstRow = list.at(i++).row();
int lastRow = firstRow;
while (i < list.size() && list.at(i).row() - lastRow <= 1 && list.at(i).row() > firstRow)
lastRow = list.at(i++).row();
int first = m_entries.indexOf(oldList.at(firstRow));
int count = lastRow - firstRow + 1;
Q_ASSERT(count > 0);
Q_ASSERT(oldList.at(lastRow) == m_entries.at(first + count - 1));
beginRemoveRows(QModelIndex(), first, first + count - 1);
while (count-- > 0)
m_entries.removeAt(first);
endRemoveRows();
}
Qt4ProjectManager::Qt4ProFileNode *node = m_project->rootQt4ProjectNode();
node->setProVariable(QLatin1String("ANDROID_EXTRA_LIBS"), m_entries.join(QLatin1Char(' ')));
}

View File

@@ -0,0 +1,67 @@
/**************************************************************************
**
** Copyright (c) 2013 BogDan Vatra <bog_dan_ro@yahoo.com>
** 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 ANDROIDEXTRALIBRARYLISTMODEL_H
#define ANDROIDEXTRALIBRARYLISTMODEL_H
#include <QAbstractItemModel>
namespace Qt4ProjectManager { class Qt4Project; }
namespace Android {
namespace Internal {
class AndroidExtraLibraryListModel : public QAbstractItemModel
{
Q_OBJECT
public:
explicit AndroidExtraLibraryListModel(Qt4ProjectManager::Qt4Project *project,
QObject *parent = 0);
QModelIndex index(int row, int column, const QModelIndex &parent) const;
QModelIndex parent(const QModelIndex &child) const;
int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
void removeEntries(const QModelIndexList &list);
void addEntries(const QStringList &list);
private slots:
void reset();
private:
Qt4ProjectManager::Qt4Project *m_project;
QStringList m_entries;
};
} // namespace Internal
} // namespace Android
#endif // ANDROIDEXTRALIBRARYLISTMODEL_H

View File

@@ -1999,6 +1999,7 @@ void Qt4ProFileNode::applyEvaluate(EvalResult evalResult, bool async)
newVarValues[AndroidArchVar] = m_readerExact->values(QLatin1String("ANDROID_TARGET_ARCH")); newVarValues[AndroidArchVar] = m_readerExact->values(QLatin1String("ANDROID_TARGET_ARCH"));
newVarValues[AndroidDeploySettingsFile] = m_readerExact->values(QLatin1String("ANDROID_DEPLOYMENT_SETTINGS_FILE")); newVarValues[AndroidDeploySettingsFile] = m_readerExact->values(QLatin1String("ANDROID_DEPLOYMENT_SETTINGS_FILE"));
newVarValues[AndroidPackageSourceDir] = m_readerExact->values(QLatin1String("ANDROID_PACKAGE_SOURCE_DIR")); newVarValues[AndroidPackageSourceDir] = m_readerExact->values(QLatin1String("ANDROID_PACKAGE_SOURCE_DIR"));
newVarValues[AndroidExtraLibs] = m_readerExact->values(QLatin1String("ANDROID_EXTRA_LIBS"));
m_isDeployable = false; m_isDeployable = false;
if (m_projectType == ApplicationTemplate) { if (m_projectType == ApplicationTemplate) {

View File

@@ -107,7 +107,8 @@ enum Qt4Variable {
ShLibExtensionVar, ShLibExtensionVar,
AndroidArchVar, AndroidArchVar,
AndroidDeploySettingsFile, AndroidDeploySettingsFile,
AndroidPackageSourceDir AndroidPackageSourceDir,
AndroidExtraLibs
}; };
// Import base classes into namespace // Import base classes into namespace