forked from qt-creator/qt-creator
BlackBerry: Do not add bar-descriptor.xml to .pro file
The bar-descriptor.xml file will no longer be added to the .pro file as OTHER_FILES, as it was not necessarily the file listed in the .pro file that was used for creating the package later on, as that is configured in the deployment settings. Instead, the file configured in the deployment settings is now added to the file project tree, and kept in sync if the user changes the file to use for deployment. Task-number: QTCREATORBUG-10054 Change-Id: I3068fedf8ea17f4e60131f9106b3844086d1552b Reviewed-by: David Kaspar <dkaspar@blackberry.com> Reviewed-by: Mehdi Fekari <mfekari@blackberry.com> Reviewed-by: Nicolas Arnaud-Cormos <nicolas@kdab.com>
This commit is contained in:
committed by
Tobias Nätterlund
parent
3b786e7faf
commit
8ee451b94a
48
src/plugins/qnx/bardescriptorfilenode.cpp
Normal file
48
src/plugins/qnx/bardescriptorfilenode.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
|
||||
**
|
||||
** Contact: BlackBerry (qt@blackberry.com)
|
||||
** Contact: KDAB (info@kdab.com)
|
||||
**
|
||||
** 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 "bardescriptorfilenode.h"
|
||||
|
||||
using namespace Qnx;
|
||||
using namespace Qnx::Internal;
|
||||
|
||||
BarDescriptorFileNode::BarDescriptorFileNode(const QString &filePath)
|
||||
: ProjectExplorer::FileNode(filePath, ProjectExplorer::ProjectFileType, false)
|
||||
{
|
||||
}
|
||||
|
||||
QList<ProjectExplorer::ProjectAction> BarDescriptorFileNode::supportedActions(ProjectExplorer::Node *node) const
|
||||
{
|
||||
Q_UNUSED(node)
|
||||
|
||||
// To disable "Remove File..." and "Rename..." context menu actions
|
||||
return QList<ProjectExplorer::ProjectAction>();
|
||||
}
|
||||
52
src/plugins/qnx/bardescriptorfilenode.h
Normal file
52
src/plugins/qnx/bardescriptorfilenode.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
|
||||
**
|
||||
** Contact: BlackBerry (qt@blackberry.com)
|
||||
** Contact: KDAB (info@kdab.com)
|
||||
**
|
||||
** 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 QNX_INTERNAL_BARDESCRIPTORFILENODE_H
|
||||
#define QNX_INTERNAL_BARDESCRIPTORFILENODE_H
|
||||
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
|
||||
namespace Qnx {
|
||||
namespace Internal {
|
||||
|
||||
class BarDescriptorFileNode : public ProjectExplorer::FileNode
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BarDescriptorFileNode(const QString &filePath);
|
||||
|
||||
QList<ProjectExplorer::ProjectAction> supportedActions(Node *node) const;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qnx
|
||||
|
||||
#endif // QNX_INTERNAL_BARDESCRIPTORFILENODE_H
|
||||
300
src/plugins/qnx/bardescriptorfilenodemanager.cpp
Normal file
300
src/plugins/qnx/bardescriptorfilenodemanager.cpp
Normal file
@@ -0,0 +1,300 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
|
||||
**
|
||||
** Contact: BlackBerry (qt@blackberry.com)
|
||||
** Contact: KDAB (info@kdab.com)
|
||||
**
|
||||
** 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 "bardescriptorfilenodemanager.h"
|
||||
|
||||
#include "bardescriptorfilenode.h"
|
||||
#include "blackberrydeployconfiguration.h"
|
||||
#include "blackberrydeployinformation.h"
|
||||
#include "qnxconstants.h"
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <qmakeprojectmanager/qmakenodes.h>
|
||||
#include <qtsupport/baseqtversion.h>
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
#include <utils/checkablemessagebox.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
using namespace Qnx;
|
||||
using namespace Qnx::Internal;
|
||||
|
||||
namespace {
|
||||
const char SKIP_BAR_DESCRIPTOR_CREATION_KEY[] = "Qnx.BlackBerry.BarDescriptorFileNodeManager.SkipCreation";
|
||||
}
|
||||
|
||||
BarDescriptorFileNodeManager::BarDescriptorFileNodeManager(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
connect(ProjectExplorer::ProjectExplorerPlugin::instance(),
|
||||
SIGNAL(currentProjectChanged(ProjectExplorer::Project*)),
|
||||
this, SLOT(setCurrentProject(ProjectExplorer::Project*)));
|
||||
}
|
||||
|
||||
void BarDescriptorFileNodeManager::setCurrentProject(ProjectExplorer::Project *project)
|
||||
{
|
||||
if (!project)
|
||||
return;
|
||||
|
||||
connect(project, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
|
||||
this, SLOT(updateBarDescriptorNodes(ProjectExplorer::Target*)), Qt::UniqueConnection);
|
||||
|
||||
updateBarDescriptorNodes(project->activeTarget());
|
||||
}
|
||||
|
||||
void BarDescriptorFileNodeManager::updateBarDescriptorNodes(ProjectExplorer::Target *target)
|
||||
{
|
||||
if (!target)
|
||||
return;
|
||||
|
||||
// We are not consistently getting a signal when the current project changes,
|
||||
// so instead use target->project() to get access to the current project
|
||||
|
||||
if (ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(target->kit()) != Constants::QNX_BB_OS_TYPE) {
|
||||
removeBarDescriptorNodes(target->project());
|
||||
return;
|
||||
}
|
||||
|
||||
updateBarDescriptorNodes(target->project(), true);
|
||||
|
||||
QList<ProjectExplorer::DeployConfiguration*> deployConfigurations = target->deployConfigurations();
|
||||
foreach (ProjectExplorer::DeployConfiguration *deployConfiguration, deployConfigurations) {
|
||||
BlackBerryDeployConfiguration *bbdc = qobject_cast<BlackBerryDeployConfiguration*>(deployConfiguration);
|
||||
if (!bbdc)
|
||||
continue;
|
||||
|
||||
connect(bbdc->deploymentInfo(), SIGNAL(dataChanged(QModelIndex,QModelIndex)),
|
||||
this, SLOT(handleDeploymentInfoChanged()), Qt::UniqueConnection);
|
||||
connect(bbdc->deploymentInfo(), SIGNAL(modelReset()),
|
||||
this, SLOT(handleDeploymentInfoChanged()), Qt::UniqueConnection);
|
||||
}
|
||||
}
|
||||
|
||||
void BarDescriptorFileNodeManager::handleDeploymentInfoChanged()
|
||||
{
|
||||
BlackBerryDeployInformation *deployInfo = qobject_cast<BlackBerryDeployInformation*>(sender());
|
||||
QTC_ASSERT(deployInfo, return);
|
||||
|
||||
updateBarDescriptorNodes(deployInfo->target()->project(), false);
|
||||
}
|
||||
|
||||
void BarDescriptorFileNodeManager::updateBarDescriptorNodes(ProjectExplorer::Project *project, bool attemptCreate)
|
||||
{
|
||||
if (!project)
|
||||
return;
|
||||
|
||||
ProjectExplorer::ProjectNode *rootProject = project->rootProjectNode();
|
||||
if (!rootProject)
|
||||
return;
|
||||
|
||||
BlackBerryDeployConfiguration *dc =
|
||||
qobject_cast<BlackBerryDeployConfiguration*>(project->activeTarget()->activeDeployConfiguration());
|
||||
if (!dc)
|
||||
return;
|
||||
|
||||
QList<BarPackageDeployInformation> packages = dc->deploymentInfo()->allPackages();
|
||||
foreach (const BarPackageDeployInformation &package, packages) {
|
||||
ProjectExplorer::ProjectNode *projectNode = rootProject->path() == package.proFilePath ?
|
||||
rootProject : findProjectNode(rootProject, package.proFilePath);
|
||||
if (!projectNode)
|
||||
continue;
|
||||
|
||||
if (!QFileInfo(package.appDescriptorPath()).exists()) {
|
||||
if (!attemptCreate)
|
||||
continue;
|
||||
|
||||
if (!createBarDescriptor(project, package.appDescriptorPath(), projectNode))
|
||||
continue;
|
||||
}
|
||||
|
||||
BarDescriptorFileNode *existingNode = findBarDescriptorFileNode(projectNode);
|
||||
if (existingNode) {
|
||||
if (existingNode->path() != package.appDescriptorPath()) {
|
||||
// Reload the new bar-descriptor document in the existing editor (if there is one)
|
||||
Core::IDocument *oldDocument = Core::EditorManager::documentModel()->documentForFilePath(existingNode->path());
|
||||
if (oldDocument) {
|
||||
QString errorMessage;
|
||||
|
||||
if (!oldDocument->save(&errorMessage)) {
|
||||
Core::MessageManager::write(tr("Cannot save bar descriptor file: %1").arg(errorMessage));
|
||||
continue;
|
||||
} else {
|
||||
oldDocument->setFilePath(package.appDescriptorPath());
|
||||
|
||||
if (!oldDocument->reload(&errorMessage, Core::IDocument::FlagReload, Core::IDocument::TypeContents))
|
||||
Core::MessageManager::write(tr("Cannot reload bar descriptor file: %1").arg(errorMessage));
|
||||
}
|
||||
}
|
||||
|
||||
existingNode->setPath(package.appDescriptorPath());
|
||||
}
|
||||
} else {
|
||||
BarDescriptorFileNode *fileNode = new BarDescriptorFileNode(package.appDescriptorPath());
|
||||
projectNode->addFileNodes(QList<ProjectExplorer::FileNode*>() << fileNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool BarDescriptorFileNodeManager::createBarDescriptor(ProjectExplorer::Project *project,
|
||||
const QString &barDescriptorPath,
|
||||
ProjectExplorer::ProjectNode *projectNode)
|
||||
{
|
||||
const QString projectName = QFileInfo(projectNode->path()).completeBaseName();
|
||||
|
||||
QmakeProjectManager::QmakeProFileNode *proFileNode =
|
||||
qobject_cast<QmakeProjectManager::QmakeProFileNode*>(projectNode);
|
||||
QTC_ASSERT(proFileNode, return false);
|
||||
const QString targetName = proFileNode->targetInformation().target;
|
||||
|
||||
const QFile barDescriptorFile(barDescriptorPath);
|
||||
if (barDescriptorFile.exists())
|
||||
return false;
|
||||
|
||||
bool skipFileCreation = project->namedSettings(QLatin1String(SKIP_BAR_DESCRIPTOR_CREATION_KEY)).toBool();
|
||||
|
||||
if (skipFileCreation)
|
||||
return false;
|
||||
|
||||
QDialogButtonBox::StandardButton button = Utils::CheckableMessageBox::question(Core::ICore::mainWindow(),
|
||||
tr("Setup Application Descriptor File"),
|
||||
tr("You need to set up a bar descriptor file to enable "
|
||||
"packaging.\nDo you want Qt Creator to generate it for your project (%1)?")
|
||||
.arg(project->projectFilePath()),
|
||||
tr("Don't ask again for this project"), &skipFileCreation);
|
||||
|
||||
if (button != QDialogButtonBox::Yes) {
|
||||
project->setNamedSettings(QLatin1String(SKIP_BAR_DESCRIPTOR_CREATION_KEY), skipFileCreation);
|
||||
return false;
|
||||
}
|
||||
|
||||
QString barDescriptorTemplate;
|
||||
QtSupport::QtVersionNumber qtVersion =
|
||||
QtSupport::QtKitInformation::qtVersion(project->activeTarget()->kit())->qtVersion();
|
||||
if (qtVersion >= QtSupport::QtVersionNumber(5, 0, 0))
|
||||
barDescriptorTemplate = Core::ICore::resourcePath()
|
||||
+ QLatin1String("/templates/wizards/bb-qt5-bardescriptor/bar-descriptor.xml");
|
||||
else
|
||||
barDescriptorTemplate = Core::ICore::resourcePath()
|
||||
+ QLatin1String("/templates/wizards/bb-bardescriptor/bar-descriptor.xml");
|
||||
|
||||
Utils::FileReader reader;
|
||||
if (!reader.fetch(barDescriptorTemplate)) {
|
||||
Core::MessageManager::write(tr("Cannot set up application descriptor file: "
|
||||
"Reading the bar descriptor template failed."));
|
||||
return false;
|
||||
}
|
||||
|
||||
QString content = QString::fromUtf8(reader.data());
|
||||
content.replace(QLatin1String("PROJECTNAME"), projectName);
|
||||
content.replace(QLatin1String("PROJECTPATH"), targetName);
|
||||
content.replace(QLatin1String("ID"), QLatin1String("com.example.") + projectName);
|
||||
|
||||
if (Utils::FileName::fromString(project->projectDirectory())
|
||||
.appendPath(QLatin1String("qml")).toFileInfo().exists())
|
||||
content.replace(QLatin1String("</qnx>"),
|
||||
QLatin1String(" <asset path=\"%SRC_DIR%/qml\">qml</asset>\n</qnx>"));
|
||||
|
||||
Utils::FileSaver writer(barDescriptorFile.fileName(), QIODevice::WriteOnly);
|
||||
writer.write(content.toUtf8());
|
||||
if (!writer.finalize()) {
|
||||
Core::MessageManager::write(tr("Cannot set up application descriptor file: "
|
||||
"Writing the bar descriptor file failed."));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BarDescriptorFileNodeManager::removeBarDescriptorNodes(ProjectExplorer::Project *project)
|
||||
{
|
||||
if (!project)
|
||||
return;
|
||||
|
||||
ProjectExplorer::ProjectNode *rootProject = project->rootProjectNode();
|
||||
if (!rootProject)
|
||||
return;
|
||||
|
||||
BarDescriptorFileNode *existingNode = findBarDescriptorFileNode(rootProject);
|
||||
if (existingNode)
|
||||
rootProject->removeFileNodes(QList<ProjectExplorer::FileNode*>() << existingNode);
|
||||
|
||||
// Also remove the bar descriptor nodes for sub-projects
|
||||
removeBarDescriptorNodes(rootProject);
|
||||
}
|
||||
|
||||
void BarDescriptorFileNodeManager::removeBarDescriptorNodes(ProjectExplorer::ProjectNode *parent)
|
||||
{
|
||||
QList<ProjectExplorer::ProjectNode*> projectNodes = parent->subProjectNodes();
|
||||
foreach (ProjectExplorer::ProjectNode *projectNode, projectNodes) {
|
||||
BarDescriptorFileNode *existingNode = findBarDescriptorFileNode(projectNode);
|
||||
if (existingNode)
|
||||
projectNode->removeFileNodes(QList<ProjectExplorer::FileNode*>() << existingNode);
|
||||
|
||||
removeBarDescriptorNodes(projectNode);
|
||||
}
|
||||
}
|
||||
|
||||
BarDescriptorFileNode *BarDescriptorFileNodeManager::findBarDescriptorFileNode(ProjectExplorer::ProjectNode *parent) const
|
||||
{
|
||||
QTC_ASSERT(parent, return 0);
|
||||
|
||||
QList<ProjectExplorer::FileNode*> fileNodes = parent->fileNodes();
|
||||
foreach (ProjectExplorer::FileNode *fileNode, fileNodes) {
|
||||
BarDescriptorFileNode *barDescriptorNode = qobject_cast<BarDescriptorFileNode*>(fileNode);
|
||||
if (barDescriptorNode)
|
||||
return barDescriptorNode;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
ProjectExplorer::ProjectNode *BarDescriptorFileNodeManager::findProjectNode(ProjectExplorer::ProjectNode *parent,
|
||||
const QString &projectFilePath) const
|
||||
{
|
||||
QTC_ASSERT(parent, return 0);
|
||||
|
||||
QList<ProjectExplorer::ProjectNode*> projectNodes = parent->subProjectNodes();
|
||||
foreach (ProjectExplorer::ProjectNode *projectNode, projectNodes) {
|
||||
if (projectNode->path() == projectFilePath) {
|
||||
return projectNode;
|
||||
} else if (!projectNode->subProjectNodes().isEmpty()) {
|
||||
ProjectExplorer::ProjectNode *hit = findProjectNode(projectNode, projectFilePath);
|
||||
if (hit)
|
||||
return hit;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
76
src/plugins/qnx/bardescriptorfilenodemanager.h
Normal file
76
src/plugins/qnx/bardescriptorfilenodemanager.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
|
||||
**
|
||||
** Contact: BlackBerry (qt@blackberry.com)
|
||||
** Contact: KDAB (info@kdab.com)
|
||||
**
|
||||
** 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 QNX_INTERNAL_BARDESCRIPTORFILENODEMANAGER_H
|
||||
#define QNX_INTERNAL_BARDESCRIPTORFILENODEMANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class DeployConfiguration;
|
||||
class Project;
|
||||
class ProjectNode;
|
||||
class Target;
|
||||
}
|
||||
|
||||
namespace Qnx {
|
||||
namespace Internal {
|
||||
|
||||
class BarDescriptorFileNode;
|
||||
|
||||
class BarDescriptorFileNodeManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BarDescriptorFileNodeManager(QObject *parent = 0);
|
||||
|
||||
private slots:
|
||||
void setCurrentProject(ProjectExplorer::Project *project);
|
||||
void updateBarDescriptorNodes(ProjectExplorer::Target *target);
|
||||
void handleDeploymentInfoChanged();
|
||||
|
||||
private:
|
||||
BarDescriptorFileNode *findBarDescriptorFileNode(ProjectExplorer::ProjectNode *parent) const;
|
||||
ProjectExplorer::ProjectNode *findProjectNode(ProjectExplorer::ProjectNode *parent,
|
||||
const QString &projectFilePath) const;
|
||||
|
||||
void updateBarDescriptorNodes(ProjectExplorer::Project *project, bool attemptCreate);
|
||||
bool createBarDescriptor(ProjectExplorer::Project *project, const QString &barDescriptorPath,
|
||||
ProjectExplorer::ProjectNode *projectNode);
|
||||
|
||||
void removeBarDescriptorNodes(ProjectExplorer::Project *project);
|
||||
void removeBarDescriptorNodes(ProjectExplorer::ProjectNode *parent);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qnx
|
||||
|
||||
#endif // QNX_INTERNAL_BARDESCRIPTORFILENODEMANAGER_H
|
||||
@@ -32,28 +32,15 @@
|
||||
#include "blackberrydeployconfiguration.h"
|
||||
|
||||
#include "qnxconstants.h"
|
||||
#include "bardescriptorfilenode.h"
|
||||
#include "blackberrydeployconfigurationwidget.h"
|
||||
#include "blackberrydeployinformation.h"
|
||||
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <qmakeprojectmanager/qmakenodes.h>
|
||||
#include <qmakeprojectmanager/qmakeproject.h>
|
||||
#include <qmakeprojectmanager/qmakebuildconfiguration.h>
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <ssh/sshconnection.h>
|
||||
#include <utils/checkablemessagebox.h>
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
using namespace Qnx;
|
||||
using namespace Qnx::Internal;
|
||||
|
||||
namespace {
|
||||
const char DEPLOYMENT_INFO_KEY[] = "Qnx.BlackBerry.DeployInformation";
|
||||
const char BAR_DESC_SETUP[] = "Qnx.BlackBerry.DeployInformation.BarDescriptorSetup";
|
||||
}
|
||||
|
||||
BlackBerryDeployConfiguration::BlackBerryDeployConfiguration(ProjectExplorer::Target *parent)
|
||||
@@ -73,105 +60,10 @@ BlackBerryDeployConfiguration::BlackBerryDeployConfiguration(ProjectExplorer::Ta
|
||||
void BlackBerryDeployConfiguration::ctor()
|
||||
{
|
||||
m_deployInformation = new BlackBerryDeployInformation(target());
|
||||
m_appBarDesciptorSetup = false;
|
||||
|
||||
connect(target()->project(), SIGNAL(proFilesEvaluated()), this, SLOT(setupBarDescriptor()), Qt::UniqueConnection);
|
||||
|
||||
setDefaultDisplayName(tr("Deploy to BlackBerry Device"));
|
||||
}
|
||||
|
||||
void BlackBerryDeployConfiguration::setupBarDescriptor()
|
||||
{
|
||||
QmakeProjectManager::QmakeBuildConfiguration *bc = qobject_cast<QmakeProjectManager::QmakeBuildConfiguration *>(target()->activeBuildConfiguration());
|
||||
if (!bc || !target()->kit())
|
||||
return;
|
||||
|
||||
Core::Id deviceType = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(target()->kit());
|
||||
QString projectName = target()->project()->displayName();
|
||||
|
||||
QString targetName;
|
||||
QmakeProjectManager::QmakeProject *project = static_cast<QmakeProjectManager::QmakeProject *>(target()->project());
|
||||
foreach (QmakeProjectManager::QmakeProFileNode *node, project->applicationProFiles()) {
|
||||
QString target = node->targetInformation().target;
|
||||
if (!target.isEmpty()) {
|
||||
targetName = target;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if (m_appBarDesciptorSetup)
|
||||
return;
|
||||
|
||||
QDialogButtonBox::StandardButton button = Utils::CheckableMessageBox::question(Core::ICore::mainWindow(),
|
||||
tr("Setup Application Descriptor File"),
|
||||
tr("You need to set up a BAR descriptor file to enable "
|
||||
"packaging.\nDo you want Qt Creator to generate it for your project (%1)?")
|
||||
.arg(target()->project()->projectFilePath()),
|
||||
tr("Do not ask again for this project"), &m_appBarDesciptorSetup);
|
||||
|
||||
if (button == QDialogButtonBox::No)
|
||||
return;
|
||||
|
||||
QString barDescriptorTemplate;
|
||||
QtSupport::QtVersionNumber qtVersion = QtSupport::QtKitInformation::qtVersion(target()->kit())->qtVersion();
|
||||
if (qtVersion >= QtSupport::QtVersionNumber(5, 0, 0))
|
||||
barDescriptorTemplate = Core::ICore::resourcePath()
|
||||
+ QLatin1String("/templates/wizards/bb-qt5-bardescriptor/bar-descriptor.xml");
|
||||
else
|
||||
barDescriptorTemplate = Core::ICore::resourcePath()
|
||||
+ QLatin1String("/templates/wizards/bb-bardescriptor/bar-descriptor.xml");
|
||||
|
||||
Utils::FileReader reader;
|
||||
if (!reader.fetch(barDescriptorTemplate)) {
|
||||
QMessageBox::warning(Core::ICore::mainWindow(),
|
||||
tr("Cannot Set up Application Descriptor File"),
|
||||
tr("Reading the BAR descriptor template failed."),
|
||||
QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
|
||||
QString content = QString::fromUtf8(reader.data());
|
||||
content.replace(QLatin1String("PROJECTNAME"), projectName);
|
||||
content.replace(QLatin1String("PROJECTPATH"), targetName);
|
||||
content.replace(QLatin1String("ID"), QLatin1String("com.example.") + projectName);
|
||||
|
||||
if (Utils::FileName::fromString(target()->project()->projectDirectory())
|
||||
.appendPath(QLatin1String("qml")).toFileInfo().exists())
|
||||
content.replace(QLatin1String("</qnx>"),
|
||||
QLatin1String(" <asset path=\"%SRC_DIR%/qml\">qml</asset>\n</qnx>"));
|
||||
|
||||
Utils::FileSaver writer(barDescriptorFile.fileName(), QIODevice::WriteOnly);
|
||||
writer.write(content.toUtf8());
|
||||
if (!writer.finalize()) {
|
||||
QMessageBox::warning(Core::ICore::mainWindow(),
|
||||
tr("Cannot Set up Application Descriptor File"),
|
||||
tr("Writing the BAR descriptor file failed."),
|
||||
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;
|
||||
|
||||
ProjectExplorer::ProjectExplorerPlugin::instance()
|
||||
->addExistingFiles(target()->project()->rootProjectNode(), QStringList() << barDesciptorPath);
|
||||
}
|
||||
|
||||
BlackBerryDeployConfiguration::~BlackBerryDeployConfiguration()
|
||||
{
|
||||
}
|
||||
@@ -190,7 +82,6 @@ QVariantMap BlackBerryDeployConfiguration::toMap() const
|
||||
{
|
||||
QVariantMap map(ProjectExplorer::DeployConfiguration::toMap());
|
||||
map.insert(QLatin1String(DEPLOYMENT_INFO_KEY), deploymentInfo()->toMap());
|
||||
map.insert(QLatin1String(BAR_DESC_SETUP), m_appBarDesciptorSetup);
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -199,7 +90,6 @@ bool BlackBerryDeployConfiguration::fromMap(const QVariantMap &map)
|
||||
if (!ProjectExplorer::DeployConfiguration::fromMap(map))
|
||||
return false;
|
||||
|
||||
m_appBarDesciptorSetup = map.value(QLatin1String(BAR_DESC_SETUP)).toBool();
|
||||
QVariantMap deployInfoMap = map.value(QLatin1String(DEPLOYMENT_INFO_KEY)).toMap();
|
||||
deploymentInfo()->fromMap(deployInfoMap);
|
||||
return true;
|
||||
|
||||
@@ -36,8 +36,6 @@
|
||||
|
||||
#include "blackberrydeviceconfiguration.h"
|
||||
|
||||
namespace ProjectExplorer { class Target; }
|
||||
|
||||
namespace Qnx {
|
||||
namespace Internal {
|
||||
|
||||
@@ -63,15 +61,10 @@ protected:
|
||||
|
||||
bool fromMap(const QVariantMap &map);
|
||||
|
||||
private slots:
|
||||
void setupBarDescriptor();
|
||||
|
||||
private:
|
||||
void ctor();
|
||||
void addBarDescriptorToProject(const QString& barDescriptorPath);
|
||||
|
||||
BlackBerryDeployInformation *m_deployInformation;
|
||||
bool m_appBarDesciptorSetup;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -183,6 +183,11 @@ QList<BarPackageDeployInformation> BlackBerryDeployInformation::enabledPackages(
|
||||
return result;
|
||||
}
|
||||
|
||||
QList<BarPackageDeployInformation> BlackBerryDeployInformation::allPackages() const
|
||||
{
|
||||
return m_deployInformation;
|
||||
}
|
||||
|
||||
QVariantMap BlackBerryDeployInformation::toMap() const
|
||||
{
|
||||
QVariantMap outerMap;
|
||||
@@ -232,6 +237,11 @@ void BlackBerryDeployInformation::fromMap(const QVariantMap &map)
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
ProjectExplorer::Target *BlackBerryDeployInformation::target() const
|
||||
{
|
||||
return m_target;
|
||||
}
|
||||
|
||||
void BlackBerryDeployInformation::updateModel()
|
||||
{
|
||||
if (m_deployInformation.isEmpty()) {
|
||||
|
||||
@@ -85,10 +85,13 @@ public:
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
|
||||
QList<BarPackageDeployInformation> enabledPackages() const;
|
||||
QList<BarPackageDeployInformation> allPackages() const;
|
||||
|
||||
QVariantMap toMap() const;
|
||||
void fromMap(const QVariantMap &map);
|
||||
|
||||
ProjectExplorer::Target *target() const;
|
||||
|
||||
private slots:
|
||||
void updateModel();
|
||||
|
||||
|
||||
@@ -104,7 +104,9 @@ SOURCES += qnxplugin.cpp \
|
||||
blackberrysetupwidget.cpp \
|
||||
blackberryruntimeconfiguration.cpp \
|
||||
blackberryapilevelconfiguration.cpp \
|
||||
blackberrypotentialkit.cpp
|
||||
blackberrypotentialkit.cpp \
|
||||
bardescriptorfilenode.cpp \
|
||||
bardescriptorfilenodemanager.cpp
|
||||
|
||||
HEADERS += qnxplugin.h\
|
||||
qnxconstants.h \
|
||||
@@ -208,7 +210,9 @@ HEADERS += qnxplugin.h\
|
||||
blackberrysetupwidget.h \
|
||||
blackberryruntimeconfiguration.h \
|
||||
blackberryapilevelconfiguration.h \
|
||||
blackberrypotentialkit.h
|
||||
blackberrypotentialkit.h \
|
||||
bardescriptorfilenode.h \
|
||||
bardescriptorfilenodemanager.h
|
||||
|
||||
FORMS += \
|
||||
blackberrydeviceconfigurationwizardsetuppage.ui \
|
||||
|
||||
@@ -52,6 +52,10 @@ QtcPlugin {
|
||||
"bardescriptoreditorpermissionswidget.ui",
|
||||
"bardescriptoreditorwidget.cpp",
|
||||
"bardescriptoreditorwidget.h",
|
||||
"bardescriptorfilenode.cpp",
|
||||
"bardescriptorfilenode.h",
|
||||
"bardescriptorfilenodemanager.cpp",
|
||||
"bardescriptorfilenodemanager.h",
|
||||
"bardescriptormagicmatcher.cpp",
|
||||
"bardescriptormagicmatcher.h",
|
||||
"bardescriptorpermissionsmodel.cpp",
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
#include "qnxtoolchain.h"
|
||||
#include "qnxattachdebugsupport.h"
|
||||
#include "blackberrypotentialkit.h"
|
||||
#include "bardescriptorfilenodemanager.h"
|
||||
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
@@ -106,6 +107,7 @@ bool QNXPlugin::initialize(const QStringList &arguments, QString *errorString)
|
||||
addAutoReleasedObject(new BlackBerryCheckDeviceStatusStepFactory);
|
||||
addAutoReleasedObject(new CascadesImportWizard);
|
||||
addAutoReleasedObject(new BlackBerryPotentialKit);
|
||||
addAutoReleasedObject(new BarDescriptorFileNodeManager);
|
||||
BlackBerryDeviceConnectionManager::instance()->initialize();
|
||||
|
||||
// Handles QNX
|
||||
|
||||
Reference in New Issue
Block a user