2013-01-11 14:24:43 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
|
2013-01-11 14:24:43 +01:00
|
|
|
**
|
2013-10-11 17:44:13 +02:00
|
|
|
** Contact: BlackBerry (qt@blackberry.com)
|
2013-01-11 14:24:43 +01:00
|
|
|
** 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 "bardescriptoreditorwidget.h"
|
|
|
|
|
|
|
|
|
|
#include "qnxconstants.h"
|
|
|
|
|
#include "bardescriptoreditor.h"
|
2013-03-07 07:25:21 +01:00
|
|
|
#include "bardescriptoreditorassetswidget.h"
|
|
|
|
|
#include "bardescriptoreditorauthorinformationwidget.h"
|
|
|
|
|
#include "bardescriptoreditorentrypointwidget.h"
|
|
|
|
|
#include "bardescriptoreditorenvironmentwidget.h"
|
|
|
|
|
#include "bardescriptoreditorgeneralwidget.h"
|
|
|
|
|
#include "bardescriptoreditorpackageinformationwidget.h"
|
|
|
|
|
#include "bardescriptoreditorpermissionswidget.h"
|
|
|
|
|
|
2013-10-17 09:16:18 +02:00
|
|
|
#include <coreplugin/icore.h>
|
2013-03-07 07:25:21 +01:00
|
|
|
#include <projectexplorer/iprojectproperties.h>
|
|
|
|
|
#include <projectexplorer/projectwindow.h>
|
2013-12-23 15:36:42 +01:00
|
|
|
#include <projectexplorer/task.h>
|
|
|
|
|
#include <projectexplorer/taskhub.h>
|
2013-01-11 14:24:43 +01:00
|
|
|
#include <texteditor/plaintexteditor.h>
|
2013-10-17 09:16:18 +02:00
|
|
|
#include <texteditor/texteditorsettings.h>
|
|
|
|
|
#include <texteditor/texteditorconstants.h>
|
2013-12-23 15:36:42 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2013-01-11 14:24:43 +01:00
|
|
|
|
|
|
|
|
using namespace Qnx;
|
|
|
|
|
using namespace Qnx::Internal;
|
|
|
|
|
|
2014-01-14 13:07:51 +01:00
|
|
|
BarDescriptorEditorWidget::BarDescriptorEditorWidget(BarDescriptorEditor *editor, QWidget *parent)
|
2013-01-11 14:24:43 +01:00
|
|
|
: QStackedWidget(parent)
|
2014-01-14 13:07:51 +01:00
|
|
|
, m_editor(editor)
|
2013-01-11 14:24:43 +01:00
|
|
|
{
|
2013-10-17 09:16:18 +02:00
|
|
|
Core::IContext *myContext = new Core::IContext(this);
|
|
|
|
|
myContext->setWidget(this);
|
|
|
|
|
myContext->setContext(Core::Context(Constants::QNX_BAR_DESCRIPTOR_EDITOR_CONTEXT, TextEditor::Constants::C_TEXTEDITOR));
|
|
|
|
|
Core::ICore::addContextObject(myContext);
|
|
|
|
|
|
2013-01-11 14:24:43 +01:00
|
|
|
initGeneralPage();
|
|
|
|
|
initApplicationPage();
|
|
|
|
|
initAssetsPage();
|
|
|
|
|
initSourcePage();
|
|
|
|
|
|
2013-03-07 07:25:21 +01:00
|
|
|
setCurrentIndex(0);
|
2013-12-23 15:36:42 +01:00
|
|
|
|
|
|
|
|
connect(m_entryPointWidget, SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), barDescriptorDocument(), SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
|
|
|
|
|
connect(m_packageInformationWidget, SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), barDescriptorDocument(), SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
|
|
|
|
|
connect(m_authorInformationWidget, SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), barDescriptorDocument(), SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
|
|
|
|
|
connect(m_generalWidget, SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), barDescriptorDocument(), SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
|
|
|
|
|
connect(m_permissionsWidget, SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), barDescriptorDocument(), SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
|
|
|
|
|
connect(m_environmentWidget, SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), barDescriptorDocument(), SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
|
|
|
|
|
connect(m_assetsWidget, SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), barDescriptorDocument(), SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
|
|
|
|
|
|
|
|
|
|
connect(barDescriptorDocument(), SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), m_entryPointWidget, SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
|
|
|
|
|
connect(barDescriptorDocument(), SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), m_packageInformationWidget, SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
|
|
|
|
|
connect(barDescriptorDocument(), SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), m_authorInformationWidget, SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
|
|
|
|
|
connect(barDescriptorDocument(), SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), m_generalWidget, SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
|
|
|
|
|
connect(barDescriptorDocument(), SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), m_permissionsWidget, SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
|
|
|
|
|
connect(barDescriptorDocument(), SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), m_environmentWidget, SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
|
|
|
|
|
connect(barDescriptorDocument(), SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), m_assetsWidget, SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
|
|
|
|
|
|
|
|
|
|
connect(m_xmlSourceWidget, SIGNAL(textChanged()), this, SLOT(updateDocumentContent()));
|
|
|
|
|
connect(barDescriptorDocument(), SIGNAL(changed()), this, SLOT(updateSourceView()));
|
2013-01-11 14:24:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BarDescriptorEditorWidget::initGeneralPage()
|
|
|
|
|
{
|
2013-03-07 07:25:21 +01:00
|
|
|
ProjectExplorer::PanelsWidget *generalPanel = new ProjectExplorer::PanelsWidget(this);
|
|
|
|
|
initPanelSize(generalPanel);
|
|
|
|
|
addWidget(generalPanel);
|
2013-01-11 14:24:43 +01:00
|
|
|
|
2013-03-07 07:25:21 +01:00
|
|
|
// Entry-Point Text and Images
|
|
|
|
|
ProjectExplorer::PropertiesPanel *entryPointPanel = new ProjectExplorer::PropertiesPanel;
|
|
|
|
|
m_entryPointWidget = new BarDescriptorEditorEntryPointWidget;
|
|
|
|
|
entryPointPanel->setDisplayName(tr("Entry-Point Text and Images"));
|
|
|
|
|
entryPointPanel->setWidget(m_entryPointWidget);
|
|
|
|
|
generalPanel->addPropertiesPanel(entryPointPanel);
|
|
|
|
|
|
|
|
|
|
// Package Information
|
|
|
|
|
ProjectExplorer::PropertiesPanel *packageInformationPanel = new ProjectExplorer::PropertiesPanel;
|
|
|
|
|
m_packageInformationWidget = new BarDescriptorEditorPackageInformationWidget;
|
|
|
|
|
packageInformationPanel->setDisplayName(tr("Package Information"));
|
|
|
|
|
packageInformationPanel->setWidget(m_packageInformationWidget);
|
|
|
|
|
generalPanel->addPropertiesPanel(packageInformationPanel);
|
|
|
|
|
|
|
|
|
|
// Author information
|
|
|
|
|
ProjectExplorer::PropertiesPanel *authorInformationPanel = new ProjectExplorer::PropertiesPanel;
|
|
|
|
|
m_authorInformationWidget = new BarDescriptorEditorAuthorInformationWidget;
|
|
|
|
|
authorInformationPanel->setDisplayName(tr("Author Information"));
|
|
|
|
|
authorInformationPanel->setWidget(m_authorInformationWidget);
|
|
|
|
|
generalPanel->addPropertiesPanel(authorInformationPanel);
|
2013-01-11 14:24:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BarDescriptorEditorWidget::initApplicationPage()
|
|
|
|
|
{
|
2013-03-07 07:25:21 +01:00
|
|
|
ProjectExplorer::PanelsWidget *applicationPanel = new ProjectExplorer::PanelsWidget(this);
|
|
|
|
|
initPanelSize(applicationPanel);
|
|
|
|
|
addWidget(applicationPanel);
|
2013-01-11 14:24:43 +01:00
|
|
|
|
2013-03-07 07:25:21 +01:00
|
|
|
// General
|
|
|
|
|
ProjectExplorer::PropertiesPanel *generalPanel = new ProjectExplorer::PropertiesPanel;
|
|
|
|
|
m_generalWidget = new BarDescriptorEditorGeneralWidget;
|
|
|
|
|
generalPanel->setDisplayName(tr("General"));
|
|
|
|
|
generalPanel->setWidget(m_generalWidget);
|
|
|
|
|
applicationPanel->addPropertiesPanel(generalPanel);
|
2013-01-11 14:24:43 +01:00
|
|
|
|
|
|
|
|
//Permissions
|
2013-03-07 07:25:21 +01:00
|
|
|
ProjectExplorer::PropertiesPanel *permissionsPanel = new ProjectExplorer::PropertiesPanel;
|
|
|
|
|
m_permissionsWidget = new BarDescriptorEditorPermissionsWidget;
|
|
|
|
|
permissionsPanel->setDisplayName(tr("Permissions"));
|
|
|
|
|
permissionsPanel->setWidget(m_permissionsWidget);
|
|
|
|
|
applicationPanel->addPropertiesPanel(permissionsPanel);
|
2013-01-11 14:24:43 +01:00
|
|
|
|
|
|
|
|
// Environment
|
2013-03-07 07:25:21 +01:00
|
|
|
ProjectExplorer::PropertiesPanel *environmentPanel = new ProjectExplorer::PropertiesPanel;
|
|
|
|
|
m_environmentWidget = new BarDescriptorEditorEnvironmentWidget;
|
|
|
|
|
environmentPanel->setDisplayName(tr("Environment"));
|
|
|
|
|
environmentPanel->setWidget(m_environmentWidget);
|
|
|
|
|
applicationPanel->addPropertiesPanel(environmentPanel);
|
2013-01-11 14:24:43 +01:00
|
|
|
}
|
|
|
|
|
|
2013-03-07 07:25:21 +01:00
|
|
|
void BarDescriptorEditorWidget::initAssetsPage()
|
2013-01-11 14:24:43 +01:00
|
|
|
{
|
2013-03-07 07:25:21 +01:00
|
|
|
ProjectExplorer::PanelsWidget *assetsPanel = new ProjectExplorer::PanelsWidget(this);
|
|
|
|
|
initPanelSize(assetsPanel);
|
|
|
|
|
addWidget(assetsPanel);
|
2013-01-11 14:24:43 +01:00
|
|
|
|
2013-03-07 07:25:21 +01:00
|
|
|
ProjectExplorer::PropertiesPanel *assetsPropertiesPanel = new ProjectExplorer::PropertiesPanel;
|
|
|
|
|
m_assetsWidget = new BarDescriptorEditorAssetsWidget;
|
|
|
|
|
assetsPropertiesPanel->setDisplayName(tr("Assets"));
|
|
|
|
|
assetsPropertiesPanel->setWidget(m_assetsWidget);
|
|
|
|
|
assetsPanel->addPropertiesPanel(assetsPropertiesPanel);
|
2013-01-11 14:24:43 +01:00
|
|
|
|
2013-03-07 07:25:21 +01:00
|
|
|
m_entryPointWidget->setAssetsModel(m_assetsWidget->assetsModel());
|
|
|
|
|
connect(m_entryPointWidget, SIGNAL(imageAdded(QString)), m_assetsWidget, SLOT(addAsset(QString)));
|
|
|
|
|
connect(m_entryPointWidget, SIGNAL(imageRemoved(QString)), m_assetsWidget, SLOT(removeAsset(QString)));
|
2013-01-11 14:24:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BarDescriptorEditorWidget::initSourcePage()
|
|
|
|
|
{
|
2013-03-07 07:25:21 +01:00
|
|
|
m_xmlSourceWidget = new TextEditor::PlainTextEditorWidget(this);
|
|
|
|
|
addWidget(m_xmlSourceWidget);
|
2013-01-11 14:24:43 +01:00
|
|
|
|
2013-10-17 09:16:18 +02:00
|
|
|
TextEditor::TextEditorSettings::initializeEditor(m_xmlSourceWidget);
|
2013-03-07 07:25:21 +01:00
|
|
|
m_xmlSourceWidget->configure(QLatin1String(Constants::QNX_BAR_DESCRIPTOR_MIME_TYPE));
|
2013-02-22 13:42:23 +01:00
|
|
|
}
|
|
|
|
|
|
2013-03-07 07:25:21 +01:00
|
|
|
void BarDescriptorEditorWidget::initPanelSize(ProjectExplorer::PanelsWidget *panelsWidget)
|
2013-02-22 13:42:23 +01:00
|
|
|
{
|
2013-03-07 07:25:21 +01:00
|
|
|
panelsWidget->widget()->setMaximumWidth(900);
|
|
|
|
|
panelsWidget->widget()->setMinimumWidth(0);
|
2013-02-22 13:42:23 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-17 09:16:18 +02:00
|
|
|
TextEditor::BaseTextEditorWidget *BarDescriptorEditorWidget::sourceWidget() const
|
|
|
|
|
{
|
|
|
|
|
return m_xmlSourceWidget;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-13 21:04:36 +02:00
|
|
|
void BarDescriptorEditorWidget::setFilePath(const QString &filePath)
|
|
|
|
|
{
|
2013-12-12 15:07:54 +01:00
|
|
|
Core::IDocument *doc = m_xmlSourceWidget->baseTextDocument();
|
2013-12-23 15:36:42 +01:00
|
|
|
if (doc)
|
2013-09-13 21:04:36 +02:00
|
|
|
doc->setFilePath(filePath);
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-23 15:36:42 +01:00
|
|
|
void BarDescriptorEditorWidget::updateDocumentContent()
|
2013-01-11 14:24:43 +01:00
|
|
|
{
|
2013-12-23 15:36:42 +01:00
|
|
|
ProjectExplorer::TaskHub::clearTasks(Constants::QNX_TASK_CATEGORY_BARDESCRIPTOR);
|
|
|
|
|
QString errorMsg;
|
|
|
|
|
int errorLine;
|
2013-01-11 14:24:43 +01:00
|
|
|
|
2013-12-23 15:36:42 +01:00
|
|
|
disconnect(barDescriptorDocument(), SIGNAL(changed()), this, SLOT(updateSourceView()));
|
|
|
|
|
bool result = barDescriptorDocument()->loadContent(m_xmlSourceWidget->toPlainText(), true, &errorMsg, &errorLine);
|
|
|
|
|
connect(barDescriptorDocument(), SIGNAL(changed()), this, SLOT(updateSourceView()));
|
2013-01-11 14:24:43 +01:00
|
|
|
|
2013-12-23 15:36:42 +01:00
|
|
|
if (!result) {
|
|
|
|
|
ProjectExplorer::TaskHub::addTask(ProjectExplorer::Task::Error, errorMsg, Constants::QNX_TASK_CATEGORY_BARDESCRIPTOR,
|
|
|
|
|
Utils::FileName::fromString(barDescriptorDocument()->filePath()), errorLine);
|
|
|
|
|
ProjectExplorer::TaskHub::requestPopup();
|
|
|
|
|
}
|
2013-01-11 14:24:43 +01:00
|
|
|
}
|
|
|
|
|
|
2013-12-23 15:36:42 +01:00
|
|
|
void BarDescriptorEditorWidget::updateSourceView()
|
2013-01-11 14:24:43 +01:00
|
|
|
{
|
2013-12-23 15:36:42 +01:00
|
|
|
bool blocked = m_xmlSourceWidget->blockSignals(true);
|
2013-03-07 07:25:21 +01:00
|
|
|
|
2013-12-23 15:36:42 +01:00
|
|
|
int line;
|
|
|
|
|
int column;
|
|
|
|
|
int position = m_xmlSourceWidget->position();
|
|
|
|
|
m_xmlSourceWidget->convertPosition(position, &line, &column);
|
2013-03-07 07:25:21 +01:00
|
|
|
|
2013-12-23 15:36:42 +01:00
|
|
|
m_xmlSourceWidget->setPlainText(barDescriptorDocument()->xmlSource());
|
|
|
|
|
|
|
|
|
|
m_xmlSourceWidget->gotoLine(line, column);
|
2013-03-07 07:25:21 +01:00
|
|
|
|
|
|
|
|
m_xmlSourceWidget->blockSignals(blocked);
|
2013-01-11 14:24:43 +01:00
|
|
|
}
|
|
|
|
|
|
2013-12-23 15:36:42 +01:00
|
|
|
BarDescriptorDocument *BarDescriptorEditorWidget::barDescriptorDocument() const
|
2013-01-11 14:24:43 +01:00
|
|
|
{
|
2013-12-23 15:36:42 +01:00
|
|
|
return qobject_cast<BarDescriptorDocument*>(m_editor->document());
|
2013-01-11 14:24:43 +01:00
|
|
|
}
|