Commit 24314562 authored by Tobias Hunger's avatar Tobias Hunger

Profile introduction

Introduce Profiles to store sets of values that describe a system/device.

These profiles are held by a target, getting rid of much of the information
stored in the Build-/Run-/DeployConfigurations, greatly simplifying those.

This is a squash of the wip/profile branch which has been on gerrit for a
while, rebased to current master.

Change-Id: I25956c8dd4d1962b2134bfaa8a8076ae3909460f
Reviewed-by: default avatarDaniel Teske <daniel.teske@nokia.com>
parent 8c77b8c9
......@@ -41,6 +41,39 @@
using namespace Utils;
FadingWidget::FadingWidget(QWidget *parent) :
FadingPanel(parent),
m_opacityEffect(new QGraphicsOpacityEffect)
{
m_opacityEffect->setOpacity(0);
setGraphicsEffect(m_opacityEffect);
// Workaround for issue with QGraphicsEffect. GraphicsEffect
// currently clears with Window color. Remove if flickering
// no longer occurs on fade-in
QPalette pal;
pal.setBrush(QPalette::All, QPalette::Window, Qt::transparent);
setPalette(pal);
}
void FadingWidget::setOpacity(qreal value)
{
m_opacityEffect->setOpacity(value);
}
void FadingWidget::fadeTo(qreal value)
{
QPropertyAnimation *animation = new QPropertyAnimation(m_opacityEffect, "opacity");
animation->setDuration(200);
animation->setEndValue(value);
animation->start(QAbstractAnimation::DeleteWhenStopped);
}
qreal FadingWidget::opacity()
{
return m_opacityEffect->opacity();
}
DetailsButton::DetailsButton(QWidget *parent) : QAbstractButton(parent), m_fader(0)
{
setCheckable(true);
......
......@@ -38,11 +38,15 @@
#include <QAbstractButton>
#include <QPixmap>
#include <QGraphicsOpacityEffect>
QT_FORWARD_DECLARE_CLASS(QGraphicsOpacityEffect)
namespace Utils {
class QTCREATOR_UTILS_EXPORT FadingPanel : public QWidget
{
Q_OBJECT
public:
FadingPanel(QWidget *parent = 0)
: QWidget(parent)
......@@ -51,6 +55,18 @@ public:
virtual void setOpacity(qreal value) = 0;
};
class QTCREATOR_UTILS_EXPORT FadingWidget : public FadingPanel
{
Q_OBJECT
public:
FadingWidget(QWidget *parent = 0);
void fadeTo(qreal value);
qreal opacity();
void setOpacity(qreal value);
protected:
QGraphicsOpacityEffect *m_opacityEffect;
};
class QTCREATOR_UTILS_EXPORT DetailsButton : public QAbstractButton
{
Q_OBJECT
......
......@@ -340,9 +340,9 @@ PersistentSettingsWriter::PersistentSettingsWriter()
static void writeVariantValue(QXmlStreamWriter &w, const Context &ctx,
const QVariant &variant, const QString &key = QString())
{
switch (variant.type()) {
case QVariant::StringList:
case QVariant::List:
switch (static_cast<int>(variant.type())) {
case static_cast<int>(QVariant::StringList):
case static_cast<int>(QVariant::List):
w.writeStartElement(ctx.valueListElement);
w.writeAttribute(ctx.typeAttribute, QLatin1String(QVariant::typeToName(QVariant::List)));
if (!key.isEmpty())
......@@ -351,7 +351,7 @@ static void writeVariantValue(QXmlStreamWriter &w, const Context &ctx,
writeVariantValue(w, ctx, var);
w.writeEndElement();
break;
case QVariant::Map: {
case static_cast<int>(QVariant::Map): {
w.writeStartElement(ctx.valueMapElement);
w.writeAttribute(ctx.typeAttribute, QLatin1String(QVariant::typeToName(QVariant::Map)));
if (!key.isEmpty())
......@@ -363,6 +363,9 @@ static void writeVariantValue(QXmlStreamWriter &w, const Context &ctx,
w.writeEndElement();
}
break;
case static_cast<int>(QMetaType::QObjectStar): // ignore QObjects!
case static_cast<int>(QMetaType::VoidStar): // ignore void pointers!
break;
default:
w.writeStartElement(ctx.valueElement);
w.writeAttribute(ctx.typeAttribute, QLatin1String(variant.typeName()));
......
......@@ -12,6 +12,7 @@ QT += xml network
HEADERS += \
androidconstants.h \
androidconfigurations.h \
androidmanager.h \
androidrunconfiguration.h \
androidruncontrol.h \
androidrunfactories.h \
......@@ -32,14 +33,13 @@ HEADERS += \
androidqtversionfactory.h \
androidqtversion.h \
androiddeployconfiguration.h \
androidtarget.h \
androidtargetfactory.h \
androidcreatekeystorecertificate.h \
javaparser.h \
androidplugin.h
SOURCES += \
androidconfigurations.cpp \
androidmanager.cpp \
androidrunconfiguration.cpp \
androidruncontrol.cpp \
androidrunfactories.cpp \
......@@ -59,8 +59,6 @@ SOURCES += \
androidqtversionfactory.cpp \
androidqtversion.cpp \
androiddeployconfiguration.cpp \
androidtarget.cpp \
androidtargetfactory.cpp \
androidcreatekeystorecertificate.cpp \
javaparser.cpp \
androidplugin.cpp
......
......@@ -42,6 +42,8 @@ QtcPlugin {
"androiddeploystepwidget.h",
"androiddeploystepwidget.ui",
"androidglobal.h",
"androidmanager.h",
"androidmanager.cpp",
"androidpackagecreationfactory.cpp",
"androidpackagecreationfactory.h",
"androidpackagecreationstep.cpp",
......@@ -73,10 +75,6 @@ QtcPlugin {
"androidsettingswidget.cpp",
"androidsettingswidget.h",
"androidsettingswidget.ui",
"androidtarget.cpp",
"androidtargetfactory.cpp",
"androidtargetfactory.h",
"androidtarget.h",
"androidtoolchain.cpp",
"androidtoolchain.h",
"javaparser.cpp",
......
......@@ -67,16 +67,16 @@ public:
AndroidConfig(const QSettings &settings);
void save(QSettings &settings) const;
QString sdkLocation;
QString ndkLocation;
Utils::FileName sdkLocation;
Utils::FileName ndkLocation;
QString ndkToolchainVersion;
QString antLocation;
QString armGdbLocation;
QString armGdbserverLocation;
QString x86GdbLocation;
QString x86GdbserverLocation;
QString openJDKLocation;
QString keystoreLocation;
Utils::FileName antLocation;
Utils::FileName armGdbLocation;
Utils::FileName armGdbserverLocation;
Utils::FileName x86GdbLocation;
Utils::FileName x86GdbserverLocation;
Utils::FileName openJDKLocation;
Utils::FileName keystoreLocation;
unsigned partitionSize;
};
......@@ -97,18 +97,18 @@ public:
void setConfig(const AndroidConfig &config);
QStringList sdkTargets(int minApiLevel = 0) const;
QStringList ndkToolchainVersions() const;
QString adbToolPath() const;
QString androidToolPath() const;
QString antToolPath() const;
QString emulatorToolPath() const;
QString gccPath(ProjectExplorer::Abi::Architecture architecture) const;
QString gdbServerPath(ProjectExplorer::Abi::Architecture architecture) const;
QString gdbPath(ProjectExplorer::Abi::Architecture architecture) const;
QString openJDKPath() const;
QString keytoolPath() const;
QString jarsignerPath() const;
QString stripPath(ProjectExplorer::Abi::Architecture architecture) const;
QString readelfPath(ProjectExplorer::Abi::Architecture architecture) const;
Utils::FileName adbToolPath() const;
Utils::FileName androidToolPath() const;
Utils::FileName antToolPath() const;
Utils::FileName emulatorToolPath() const;
Utils::FileName gccPath(ProjectExplorer::Abi::Architecture architecture) const;
Utils::FileName gdbServerPath(ProjectExplorer::Abi::Architecture architecture) const;
Utils::FileName gdbPath(ProjectExplorer::Abi::Architecture architecture) const;
Utils::FileName openJDKPath() const;
Utils::FileName keytoolPath() const;
Utils::FileName jarsignerPath() const;
Utils::FileName stripPath(ProjectExplorer::Abi::Architecture architecture) const;
Utils::FileName readelfPath(ProjectExplorer::Abi::Architecture architecture) const;
QString getDeployDeviceSerialNumber(int *apiLevel) const;
bool createAVD(const QString &target, const QString &name, int sdcardSize) const;
bool removeAVD(const QString &name) const;
......@@ -127,8 +127,8 @@ public slots:
bool createAVD(int minApiLevel = 0) const;
private:
QString toolPath(ProjectExplorer::Abi::Architecture architecture) const;
QString openJDKBinPath() const;
Utils::FileName toolPath(ProjectExplorer::Abi::Architecture architecture) const;
Utils::FileName openJDKBinPath() const;
AndroidConfigurations(QObject *parent);
void load();
......
......@@ -56,18 +56,8 @@ enum AndroidQemuStatus {
#define ANDROID_BAT_SUFFIX ""
#endif
static const char ANDROID_RC_ID[] = ANDROID_PREFIX;
static const QLatin1String ANDROID_RC_ID_PREFIX(ANDROID_PREFIX ".");
static const QLatin1String AndroidArgumentsKey(ANDROID_PREFIX ".Arguments");
static const QLatin1String AndroidSimulatorPathKey(ANDROID_PREFIX ".Simulator");
static const QLatin1String AndroidDeviceIdKey(ANDROID_PREFIX ".DeviceId");
static const QLatin1String AndroidProFileKey(ANDROID_PREFIX ".ProFile");
static const QLatin1String AndroidExportedLocalDirsKey(ANDROID_PREFIX ".ExportedLocalDirs");
static const QLatin1String AndroidBaseEnvironmentBaseKey(ANDROID_PREFIX ".BaseEnvironmentBase");
static const QLatin1String AndroidUserEnvironmentChangesKey(ANDROID_PREFIX ".UserEnvironmentChanges");
static const QLatin1String AndroidUseRemoteGdbKey(ANDROID_PREFIX ".UseRemoteGdb");
} // namespace Internal
namespace Constants {
......@@ -77,8 +67,6 @@ const char ANDROID_SETTINGS_TR_CATEGORY[] = QT_TRANSLATE_NOOP("Android", "Androi
const char ANDROID_SETTINGS_CATEGORY_ICON[] = ":/android/images/QtAndroid.png";
const char ANDROID_TOOLCHAIN_ID[] = "Qt4ProjectManager.ToolChain.Android";
const char ANDROIDQT[] = "Qt4ProjectManager.QtVersion.Android";
const char ANDROID_PLATFORM[] = "Android";
const char ANDROID_PLATFORM_TR[] = QT_TRANSLATE_NOOP("QtSupport", "Android");
}
} // namespace Android
......
......@@ -56,7 +56,7 @@ AndroidCreateKeystoreCertificate::~AndroidCreateKeystoreCertificate()
delete ui;
}
QString AndroidCreateKeystoreCertificate::keystoreFilePath()
Utils::FileName AndroidCreateKeystoreCertificate::keystoreFilePath()
{
return m_keystoreFilePath;
}
......@@ -155,10 +155,10 @@ void AndroidCreateKeystoreCertificate::on_buttonBox_accepted()
if (!ui->countryLineEdit->text().length())
ui->countryLineEdit->setFocus();
m_keystoreFilePath = QFileDialog::getSaveFileName(this, tr("Keystore file name"),
QDir::homePath() + QLatin1String("/android_release.keystore"),
tr("Keystore files (*.keystore *.jks)"));
if (!m_keystoreFilePath.length())
m_keystoreFilePath = Utils::FileName::fromString(QFileDialog::getSaveFileName(this, tr("Keystore file name"),
QDir::homePath() + QLatin1String("/android_release.keystore"),
tr("Keystore files (*.keystore *.jks)")));
if (m_keystoreFilePath.isEmpty())
return;
QString distinguishedNames(QString::fromLatin1("CN=%1, O=%2, L=%3, C=%4")
.arg(ui->commonNameLineEdit->text().replace(QLatin1Char(','), QLatin1String("\\,")))
......@@ -174,7 +174,7 @@ void AndroidCreateKeystoreCertificate::on_buttonBox_accepted()
QStringList params;
params << QLatin1String("-genkey") << QLatin1String("-keyalg") << QLatin1String("RSA")
<< QLatin1String("-keystore") << m_keystoreFilePath
<< QLatin1String("-keystore") << m_keystoreFilePath.toString()
<< QLatin1String("-storepass") << ui->keystorePassLineEdit->text()
<< QLatin1String("-alias") << ui->aliasNameLineEdit->text()
<< QLatin1String("-keysize") << ui->keySizeSpinBox->text()
......@@ -183,7 +183,7 @@ void AndroidCreateKeystoreCertificate::on_buttonBox_accepted()
<< QLatin1String("-dname") << distinguishedNames;
QProcess genKeyCertProc;
genKeyCertProc.start(AndroidConfigurations::instance().keytoolPath(), params );
genKeyCertProc.start(AndroidConfigurations::instance().keytoolPath().toString(), params );
if (!genKeyCertProc.waitForStarted() || !genKeyCertProc.waitForFinished())
return;
......
......@@ -33,6 +33,8 @@
#ifndef ANDROIDCREATEKEYSTORECERTIFICATE_H
#define ANDROIDCREATEKEYSTORECERTIFICATE_H
#include <utils/fileutils.h>
#include <QDialog>
QT_BEGIN_NAMESPACE
......@@ -54,7 +56,7 @@ class AndroidCreateKeystoreCertificate : public QDialog
public:
explicit AndroidCreateKeystoreCertificate(QWidget *parent = 0);
~AndroidCreateKeystoreCertificate();
QString keystoreFilePath();
Utils::FileName keystoreFilePath();
QString keystorePassword();
QString certificateAlias();
QString certificatePassword();
......@@ -68,7 +70,7 @@ private slots:
private:
Ui::AndroidCreateKeystoreCertificate *ui;
QString m_keystoreFilePath;
Utils::FileName m_keystoreFilePath;
};
} // namespace Internal
......
......@@ -35,17 +35,18 @@
#include "androiddeploystep.h"
#include "androidglobal.h"
#include "androidrunner.h"
#include "androidtarget.h"
#include "androidmanager.h"
#include <debugger/debuggerplugin.h>
#include <debugger/debuggerrunner.h>
#include <debugger/debuggerengine.h>
#include <debugger/debuggerstartparameters.h>
#include <projectexplorer/target.h>
#include <qt4projectmanager/qt4buildconfiguration.h>
#include <qt4projectmanager/qt4target.h>
#include <qt4projectmanager/qt4project.h>
#include <qt4projectmanager/qt4nodes.h>
#include <qt4projectmanager/qt4project.h>
#include <qtsupport/qtprofileinformation.h>
#include <QDir>
......@@ -62,6 +63,8 @@ static const char * const qMakeVariables[] = {
"QT_INSTALL_IMPORTS"
};
static Qt4Project *project(AndroidRunConfiguration *rc)
{ return static_cast<Qt4Project *>(rc->target()->project()); }
RunControl *AndroidDebugSupport::createDebugRunControl(AndroidRunConfiguration *runConfig)
{
......@@ -69,19 +72,20 @@ RunControl *AndroidDebugSupport::createDebugRunControl(AndroidRunConfiguration *
params.toolChainAbi = runConfig->abi();
params.dumperLibrary = runConfig->dumperLib();
params.startMode = AttachToRemoteServer;
params.executable = runConfig->androidTarget()->qt4Project()->rootQt4ProjectNode()->buildDir() + QLatin1String("/app_process");
params.debuggerCommand = runConfig->gdbCmd();
params.executable = project(runConfig)->rootQt4ProjectNode()->buildDir() + QLatin1String("/app_process");
params.debuggerCommand = runConfig->gdbCmd().toString();
params.remoteChannel = runConfig->remoteChannel();
params.displayName = runConfig->androidTarget()->packageName();
params.displayName = AndroidManager::packageName(runConfig->target());
params.solibSearchPath.clear();
QList<Qt4ProFileNode *> nodes = runConfig->androidTarget()->qt4Project()->allProFiles();
QList<Qt4ProFileNode *> nodes = project(runConfig)->allProFiles();
foreach (Qt4ProFileNode *node, nodes)
if (node->projectType() == ApplicationTemplate)
params.solibSearchPath.append(node->targetInformation().buildDir);
params.solibSearchPath.append(qtSoPaths(runConfig->activeQt4BuildConfiguration()->qtVersion()));
QtSupport::BaseQtVersion *version = QtSupport::QtProfileInformation::qtVersion(runConfig->target()->profile());
params.solibSearchPath.append(qtSoPaths(version));
params.useServerStartScript = true;
params.remoteSetupNeeded = true;
......@@ -148,6 +152,9 @@ void AndroidDebugSupport::handleRemoteErrorOutput(const QByteArray &output)
QStringList AndroidDebugSupport::qtSoPaths(QtSupport::BaseQtVersion *qtVersion)
{
if (!qtVersion)
return QStringList();
QSet<QString> paths;
for (uint i = 0; i < sizeof qMakeVariables / sizeof qMakeVariables[0]; ++i) {
if (!qtVersion->versionInfo().contains(QLatin1String(qMakeVariables[i])))
......
......@@ -34,13 +34,14 @@
#include "androidpackageinstallationstep.h"
#include "androidpackagecreationstep.h"
#include "androiddeployconfiguration.h"
#include "androidtarget.h"
#include "androidmanager.h"
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/target.h>
#include <qt4projectmanager/qt4projectmanagerconstants.h>
#include <qt4projectmanager/qt4project.h>
#include <qtsupport/qtprofileinformation.h>
#include <qtsupport/qtsupportconstants.h>
using namespace Android::Internal;
......@@ -64,15 +65,11 @@ AndroidDeployConfiguration::AndroidDeployConfiguration(ProjectExplorer::Target *
AndroidDeployConfigurationFactory::AndroidDeployConfigurationFactory(QObject *parent) :
ProjectExplorer::DeployConfigurationFactory(parent)
{ }
{ setObjectName(QLatin1String("AndroidDeployConfigurationFactory"));}
bool AndroidDeployConfigurationFactory::canCreate(ProjectExplorer::Target *parent, const Core::Id id) const
{
AndroidTarget *t = qobject_cast<AndroidTarget *>(parent);
if (!t || t->id() != Core::Id(Qt4ProjectManager::Constants::ANDROID_DEVICE_TARGET_ID)
|| !id.toString().startsWith(QLatin1String(ANDROID_DEPLOYCONFIGURATION_ID)))
return false;
return true;
return availableCreationIds(parent).contains(id);
}
ProjectExplorer::DeployConfiguration *AndroidDeployConfigurationFactory::create(ProjectExplorer::Target *parent, const Core::Id id)
......@@ -96,8 +93,7 @@ ProjectExplorer::DeployConfiguration *AndroidDeployConfigurationFactory::restore
{
if (!canRestore(parent, map))
return 0;
AndroidTarget *t = static_cast<AndroidTarget *>(parent);
AndroidDeployConfiguration *dc = new AndroidDeployConfiguration(t);
AndroidDeployConfiguration *dc = new AndroidDeployConfiguration(parent);
if (dc->fromMap(map))
return dc;
......@@ -107,7 +103,7 @@ ProjectExplorer::DeployConfiguration *AndroidDeployConfigurationFactory::restore
bool AndroidDeployConfigurationFactory::canClone(ProjectExplorer::Target *parent, ProjectExplorer::DeployConfiguration *source) const
{
if (!qobject_cast<AndroidTarget *>(parent))
if (!AndroidManager::supportsAndroid(parent))
return false;
return source->id() == Core::Id(ANDROID_DEPLOYCONFIGURATION_ID);
}
......@@ -116,24 +112,24 @@ ProjectExplorer::DeployConfiguration *AndroidDeployConfigurationFactory::clone(P
{
if (!canClone(parent, source))
return 0;
AndroidTarget *t = static_cast<AndroidTarget *>(parent);
return new AndroidDeployConfiguration(t, source);
return new AndroidDeployConfiguration(parent, source);
}
QList<Core::Id> AndroidDeployConfigurationFactory::availableCreationIds(ProjectExplorer::Target *parent) const
{
AndroidTarget *target = qobject_cast<AndroidTarget *>(parent);
if (!target ||
target->id() != Core::Id(Qt4ProjectManager::Constants::ANDROID_DEVICE_TARGET_ID))
if (!AndroidManager::supportsAndroid(parent))
return QList<Core::Id>();
QList<Core::Id> result;
foreach (const QString &id, target->qt4Project()->applicationProFilePathes(QLatin1String(ANDROID_DC_PREFIX)))
Qt4ProjectManager::Qt4Project *project = static_cast<Qt4ProjectManager::Qt4Project *>(parent->project());
foreach (const QString &id, project->applicationProFilePathes(QLatin1String(ANDROID_DC_PREFIX)))
result << Core::Id(id.toUtf8().constData());
return result;
}
QString AndroidDeployConfigurationFactory::displayNameForId(const Core::Id/*id*/) const
QString AndroidDeployConfigurationFactory::displayNameForId(const Core::Id id) const
{
return tr("Deploy on Android");
if (id.toString().startsWith(ANDROID_DC_PREFIX))
return tr("Deploy on Android");
return QString();
}
......@@ -72,7 +72,6 @@ public:
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent) const;
// used to translate the ids to names to display to the user
QString displayNameForId(const Core::Id id) const;
};
} // namespace Internal
......
......@@ -37,16 +37,16 @@
#include "androidglobal.h"
#include "androidpackagecreationstep.h"
#include "androidrunconfiguration.h"
#include "androidtarget.h"
#include "androidmanager.h"
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h>
#include <qt4projectmanager/qt4buildconfiguration.h>