Skip to content
Snippets Groups Projects
Commit 3be695e1 authored by mfekari's avatar mfekari Committed by Nicolas Arnaud-Cormos
Browse files

Qnx: Enable deploying existing Qt apps by adding the bar descriptor file


Change-Id: I4a7f4f8b033ac11b5d43010b3a9f479802022c46
Reviewed-by: default avatarNicolas Arnaud-Cormos <nicolas@kdab.com>
parent 49a337f2
No related branches found
No related tags found
No related merge requests found
......@@ -37,10 +37,15 @@
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/target.h>
#include <projectexplorer/projectexplorer.h>
#include <qt4projectmanager/qt4nodes.h>
#include <qt4projectmanager/qt4project.h>
#include <qt4projectmanager/qt4buildconfiguration.h>
#include <coreplugin/icore.h>
#include <ssh/sshconnection.h>
#include <QMessageBox>
using namespace Qnx;
using namespace Qnx::Internal;
......@@ -75,6 +80,74 @@ void BlackBerryDeployConfiguration::ctor()
setDefaultDisplayName(tr("Deploy to BlackBerry Device"));
}
void BlackBerryDeployConfiguration::setupBarDescriptor()
{
Qt4ProjectManager::Qt4BuildConfiguration *bc = qobject_cast<Qt4ProjectManager::Qt4BuildConfiguration *>(target()->activeBuildConfiguration());
if (!bc || !target()->kit())
return;
Core::Id deviceType = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(target()->kit());
QString projectName = target()->project()->displayName();
if (deviceType == Constants::QNX_BB_OS_TYPE) {
const QLatin1String barDescriptorFileName("bar-descriptor.xml");
Utils::FileName barDescriptorPath = Utils::FileName::fromString(target()->project()->projectDirectory()).appendPath(barDescriptorFileName);
const QFile barDescriptorFile(barDescriptorPath.toString());
if (barDescriptorFile.exists())
return;
Utils::FileReader reader;
QString barDescriptorTemplate;
if (QDir(Utils::FileName::fromString(target()->project()->projectDirectory()).appendPath(QLatin1String("qml")).toString()).exists())
barDescriptorTemplate = Core::ICore::resourcePath()
+ QLatin1String("/templates/wizards/bb-quickapp/") + barDescriptorFileName;
else
barDescriptorTemplate = Core::ICore::resourcePath()
+ QLatin1String("/templates/wizards/bb-guiapp/") + barDescriptorFileName;
if (!reader.fetch(barDescriptorTemplate)) {
QMessageBox::warning(Core::ICore::mainWindow(),
tr("Error while setting up bar descriptor"),
tr("Reading bar descriptor template failed"),
QMessageBox::Ok);
return;
}
QString content = QString::fromUtf8(reader.data());
content.replace(QLatin1String("%ProjectName%"), projectName);
Utils::FileSaver writer(barDescriptorFile.fileName(), QIODevice::WriteOnly);
writer.write(content.toUtf8());
if (!writer.finalize()) {
QMessageBox::warning(Core::ICore::mainWindow(),
tr("Error while setting up bar descriptor"),
tr("Failure writing bar descriptor file."),
QMessageBox::Ok);
return;
}
// Add the Bar Descriptor to the existing project
if (target()->project()->rootProjectNode())
addBarDescriptorToProject(barDescriptorPath.toString());
}
}
void BlackBerryDeployConfiguration::addBarDescriptorToProject(const QString &barDesciptorPath)
{
if (barDesciptorPath.isEmpty())
return;
QMessageBox::StandardButton button =
QMessageBox::question(Core::ICore::mainWindow(),
tr("Add bar-descriptor.xml file to project"),
tr("Qt Creator has set up a bar descriptor file to enable "
"packaging.\nDo you want to add it to the project?"),
QMessageBox::Yes | QMessageBox::No);
if (button == QMessageBox::Yes)
ProjectExplorer::ProjectExplorerPlugin::instance()
->addExistingFiles(target()->project()->rootProjectNode(), QStringList() << barDesciptorPath);
}
BlackBerryDeployConfiguration::~BlackBerryDeployConfiguration()
{
}
......
......@@ -67,6 +67,8 @@ protected:
private:
void ctor();
void setupBarDescriptor();
void addBarDescriptorToProject(const QString& barDescriptorPath);
};
} // namespace Internal
......
......@@ -92,6 +92,7 @@ ProjectExplorer::DeployConfiguration *BlackBerryDeployConfigurationFactory::crea
return 0;
BlackBerryDeployConfiguration *dc = new BlackBerryDeployConfiguration(parent);
dc->setupBarDescriptor();
dc->stepList()->insertStep(0, new BlackBerryCreatePackageStep(dc->stepList()));
dc->stepList()->insertStep(1, new BlackBerryDeployStep(dc->stepList()));
return dc;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment