forked from qt-creator/qt-creator
Merge branch 'master' of ssh://codereview.qt-project.org/qt-creator/qt-creator
This commit is contained in:
@@ -45,6 +45,8 @@ AndroidManifestDocument::AndroidManifestDocument(AndroidManifestEditorWidget *ed
|
|||||||
m_editorWidget(editorWidget)
|
m_editorWidget(editorWidget)
|
||||||
{
|
{
|
||||||
setMimeType(QLatin1String(Constants::ANDROID_MANIFEST_MIME_TYPE));
|
setMimeType(QLatin1String(Constants::ANDROID_MANIFEST_MIME_TYPE));
|
||||||
|
connect(editorWidget, SIGNAL(guiChanged()),
|
||||||
|
this, SIGNAL(changed()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AndroidManifestDocument::save(QString *errorString, const QString &fileName, bool autoSave)
|
bool AndroidManifestDocument::save(QString *errorString, const QString &fileName, bool autoSave)
|
||||||
|
|||||||
@@ -36,36 +36,32 @@
|
|||||||
|
|
||||||
#include <QActionGroup>
|
#include <QActionGroup>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
|
#include <QTextBlock>
|
||||||
|
|
||||||
using namespace Android;
|
using namespace Android;
|
||||||
using namespace Internal;
|
using namespace Internal;
|
||||||
|
|
||||||
Android::Internal::AndroidManifestEditor::AndroidManifestEditor(AndroidManifestEditorWidget *editorWidget)
|
Android::Internal::AndroidManifestEditor::AndroidManifestEditor(AndroidManifestEditorWidget *editorWidget)
|
||||||
: BaseTextEditor(editorWidget),
|
: Core::IEditor(editorWidget), m_toolBar(0)
|
||||||
m_document(new AndroidManifestDocument(editorWidget))
|
|
||||||
{
|
{
|
||||||
QToolBar *toolBar = new QToolBar;
|
m_toolBar = new QToolBar(editorWidget);
|
||||||
|
|
||||||
m_actionGroup = new QActionGroup(this);
|
m_actionGroup = new QActionGroup(this);
|
||||||
connect(m_actionGroup, SIGNAL(triggered(QAction*)), this, SLOT(changeEditorPage(QAction*)));
|
connect(m_actionGroup, SIGNAL(triggered(QAction*)), this, SLOT(changeEditorPage(QAction*)));
|
||||||
|
|
||||||
QAction *generalAction = toolBar->addAction(tr("General"));
|
QAction *generalAction = m_toolBar->addAction(tr("General"));
|
||||||
generalAction->setData(AndroidManifestEditorWidget::General);
|
generalAction->setData(AndroidManifestEditorWidget::General);
|
||||||
generalAction->setCheckable(true);
|
generalAction->setCheckable(true);
|
||||||
m_actionGroup->addAction(generalAction);
|
m_actionGroup->addAction(generalAction);
|
||||||
|
|
||||||
QAction *sourceAction = toolBar->addAction(tr("XML Source"));
|
QAction *sourceAction = m_toolBar->addAction(tr("XML Source"));
|
||||||
sourceAction->setData(AndroidManifestEditorWidget::Source);
|
sourceAction->setData(AndroidManifestEditorWidget::Source);
|
||||||
sourceAction->setCheckable(true);
|
sourceAction->setCheckable(true);
|
||||||
m_actionGroup->addAction(sourceAction);
|
m_actionGroup->addAction(sourceAction);
|
||||||
|
|
||||||
generalAction->setChecked(true);
|
generalAction->setChecked(true);
|
||||||
|
|
||||||
insertExtraToolBarWidget(BaseTextEditor::Left, toolBar);
|
setContext(Core::Context(Constants::ANDROID_MANIFEST_EDITOR_CONTEXT));
|
||||||
|
setWidget(editorWidget);
|
||||||
|
|
||||||
setContext(Core::Context(Constants::ANDROID_MANIFEST_EDITOR_CONTEXT,
|
|
||||||
TextEditor::Constants::C_TEXTEDITOR));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::Id AndroidManifestEditor::id() const
|
Core::Id AndroidManifestEditor::id() const
|
||||||
@@ -73,12 +69,47 @@ Core::Id AndroidManifestEditor::id() const
|
|||||||
return Constants::ANDROID_MANIFEST_EDITOR_ID;
|
return Constants::ANDROID_MANIFEST_EDITOR_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AndroidManifestEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
|
||||||
|
{
|
||||||
|
return widget()->open(errorString, fileName, realFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *AndroidManifestEditor::toolBar()
|
||||||
|
{
|
||||||
|
return m_toolBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
AndroidManifestEditorWidget *AndroidManifestEditor::widget() const
|
||||||
|
{
|
||||||
|
return static_cast<AndroidManifestEditorWidget *>(Core::IEditor::widget());
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::IDocument *AndroidManifestEditor::document()
|
||||||
|
{
|
||||||
|
return textEditor()->baseTextDocument();
|
||||||
|
}
|
||||||
|
|
||||||
|
TextEditor::BaseTextEditorWidget *AndroidManifestEditor::textEditor() const
|
||||||
|
{
|
||||||
|
return widget()->textEditorWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
int AndroidManifestEditor::currentLine() const
|
||||||
|
{
|
||||||
|
return textEditor()->textCursor().blockNumber() + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int AndroidManifestEditor::currentColumn() const
|
||||||
|
{
|
||||||
|
QTextCursor cursor = textEditor()->textCursor();
|
||||||
|
return cursor.position() - cursor.block().position() + 1;
|
||||||
|
}
|
||||||
|
|
||||||
void AndroidManifestEditor::changeEditorPage(QAction *action)
|
void AndroidManifestEditor::changeEditorPage(QAction *action)
|
||||||
{
|
{
|
||||||
AndroidManifestEditorWidget *editorWidget = static_cast<AndroidManifestEditorWidget *>(widget());
|
if (!widget()->setActivePage(static_cast<AndroidManifestEditorWidget::EditorPage>(action->data().toInt()))) {
|
||||||
if (!editorWidget->setActivePage(static_cast<AndroidManifestEditorWidget::EditorPage>(action->data().toInt()))) {
|
|
||||||
foreach (QAction *action, m_actionGroup->actions()) {
|
foreach (QAction *action, m_actionGroup->actions()) {
|
||||||
if (action->data().toInt() == editorWidget->activePage()) {
|
if (action->data().toInt() == widget()->activePage()) {
|
||||||
action->setChecked(true);
|
action->setChecked(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#define ANDROIDMANIFESTEDITOR_H
|
#define ANDROIDMANIFESTEDITOR_H
|
||||||
|
|
||||||
#include "androidmanifestdocument.h"
|
#include "androidmanifestdocument.h"
|
||||||
|
#include "androidmanifesteditorwidget.h"
|
||||||
|
|
||||||
#include <coreplugin/editormanager/ieditor.h>
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
#include <texteditor/basetexteditor.h>
|
#include <texteditor/basetexteditor.h>
|
||||||
@@ -41,9 +42,8 @@ QT_END_NAMESPACE
|
|||||||
|
|
||||||
namespace Android {
|
namespace Android {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
class AndroidManifestEditorWidget;
|
|
||||||
|
|
||||||
class AndroidManifestEditor : public TextEditor::BaseTextEditor
|
class AndroidManifestEditor : public Core::IEditor
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -51,13 +51,22 @@ public:
|
|||||||
explicit AndroidManifestEditor(AndroidManifestEditorWidget *editorWidget);
|
explicit AndroidManifestEditor(AndroidManifestEditorWidget *editorWidget);
|
||||||
|
|
||||||
Core::Id id() const;
|
Core::Id id() const;
|
||||||
|
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
|
||||||
|
QWidget *toolBar();
|
||||||
|
AndroidManifestEditorWidget *widget() const;
|
||||||
|
Core::IDocument *document();
|
||||||
|
TextEditor::BaseTextEditorWidget *textEditor() const;
|
||||||
|
|
||||||
|
int currentLine() const;
|
||||||
|
int currentColumn() const;
|
||||||
|
void gotoLine(int line, int column = 0) { textEditor()->gotoLine(line, column); }
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void changeEditorPage(QAction *action);
|
void changeEditorPage(QAction *action);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AndroidManifestDocument *m_document;
|
|
||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
|
QToolBar *m_toolBar;
|
||||||
QActionGroup *m_actionGroup;
|
QActionGroup *m_actionGroup;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,19 @@
|
|||||||
using namespace Android;
|
using namespace Android;
|
||||||
using namespace Android::Internal;
|
using namespace Android::Internal;
|
||||||
|
|
||||||
|
class AndroidTextEditorActionHandler : public TextEditor::TextEditorActionHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit AndroidTextEditorActionHandler(QObject *parent)
|
||||||
|
: TextEditorActionHandler(parent, Constants::ANDROID_MANIFEST_EDITOR_CONTEXT)
|
||||||
|
{}
|
||||||
|
private:
|
||||||
|
TextEditor::BaseTextEditorWidget *resolveTextEditorWidget(Core::IEditor *editor) const
|
||||||
|
{
|
||||||
|
AndroidManifestEditor *androidManifestEditor = static_cast<AndroidManifestEditor *>(editor);
|
||||||
|
return androidManifestEditor->textEditor();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
AndroidManifestEditorFactory::AndroidManifestEditorFactory(QObject *parent)
|
AndroidManifestEditorFactory::AndroidManifestEditorFactory(QObject *parent)
|
||||||
: Core::IEditorFactory(parent)
|
: Core::IEditorFactory(parent)
|
||||||
@@ -46,12 +59,11 @@ AndroidManifestEditorFactory::AndroidManifestEditorFactory(QObject *parent)
|
|||||||
setId(Constants::ANDROID_MANIFEST_EDITOR_ID);
|
setId(Constants::ANDROID_MANIFEST_EDITOR_ID);
|
||||||
setDisplayName(tr("Android Manifest editor"));
|
setDisplayName(tr("Android Manifest editor"));
|
||||||
addMimeType(Constants::ANDROID_MANIFEST_MIME_TYPE);
|
addMimeType(Constants::ANDROID_MANIFEST_MIME_TYPE);
|
||||||
new TextEditor::TextEditorActionHandler(this, Constants::ANDROID_MANIFEST_EDITOR_CONTEXT);
|
new AndroidTextEditorActionHandler(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::IEditor *AndroidManifestEditorFactory::createEditor()
|
Core::IEditor *AndroidManifestEditorFactory::createEditor()
|
||||||
{
|
{
|
||||||
AndroidManifestEditorWidget *editor = new AndroidManifestEditorWidget();
|
AndroidManifestEditorWidget *androidManifestEditorWidget = new AndroidManifestEditorWidget();
|
||||||
TextEditor::TextEditorSettings::initializeEditor(editor);
|
return androidManifestEditorWidget->editor();
|
||||||
return editor->editor();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/infobar.h>
|
#include <coreplugin/infobar.h>
|
||||||
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
#include <texteditor/plaintexteditor.h>
|
#include <texteditor/plaintexteditor.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
#include <projectexplorer/projectwindow.h>
|
#include <projectexplorer/projectwindow.h>
|
||||||
@@ -44,6 +45,7 @@
|
|||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
#include <projectexplorer/kitinformation.h>
|
#include <projectexplorer/kitinformation.h>
|
||||||
#include <texteditor/texteditoractionhandler.h>
|
#include <texteditor/texteditoractionhandler.h>
|
||||||
|
#include <texteditor/texteditorsettings.h>
|
||||||
#include <qmakeprojectmanager/qmakeproject.h>
|
#include <qmakeprojectmanager/qmakeproject.h>
|
||||||
|
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
@@ -95,49 +97,44 @@ Project *androidProject(const QString &file)
|
|||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
AndroidManifestEditorWidget::AndroidManifestEditorWidget(QWidget *parent)
|
AndroidManifestEditorWidget::AndroidManifestEditorWidget()
|
||||||
: TextEditor::PlainTextEditorWidget(new AndroidManifestDocument(this), parent),
|
: QWidget(),
|
||||||
m_dirty(false),
|
m_dirty(false),
|
||||||
m_stayClean(false),
|
m_stayClean(false),
|
||||||
m_setAppName(false),
|
m_setAppName(false),
|
||||||
m_appNameInStringsXml(false)
|
m_appNameInStringsXml(false)
|
||||||
{
|
{
|
||||||
configure(QLatin1String(Constants::ANDROID_MANIFEST_MIME_TYPE));
|
m_textEditorWidget = new AndroidManifestTextEditorWidget(this);
|
||||||
|
TextEditor::TextEditorSettings::initializeEditor(m_textEditorWidget);
|
||||||
|
|
||||||
initializePage();
|
initializePage();
|
||||||
|
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
||||||
|
|
||||||
m_timerParseCheck.setInterval(800);
|
m_timerParseCheck.setInterval(800);
|
||||||
m_timerParseCheck.setSingleShot(true);
|
m_timerParseCheck.setSingleShot(true);
|
||||||
|
|
||||||
|
m_editor = new AndroidManifestEditor(this);
|
||||||
|
|
||||||
connect(&m_timerParseCheck, SIGNAL(timeout()),
|
connect(&m_timerParseCheck, SIGNAL(timeout()),
|
||||||
this, SLOT(delayedParseCheck()));
|
this, SLOT(delayedParseCheck()));
|
||||||
|
|
||||||
connect(document(), SIGNAL(contentsChanged()),
|
connect(m_textEditorWidget->document(), SIGNAL(contentsChanged()),
|
||||||
this, SLOT(startParseCheck()));
|
this, SLOT(startParseCheck()));
|
||||||
}
|
}
|
||||||
|
|
||||||
TextEditor::BaseTextEditor *AndroidManifestEditorWidget::createEditor()
|
|
||||||
{
|
|
||||||
return new AndroidManifestEditor(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AndroidManifestEditorWidget::initializePage()
|
void AndroidManifestEditorWidget::initializePage()
|
||||||
{
|
{
|
||||||
QWidget *mainWidget = new QWidget(this);
|
QHBoxLayout *layout = new QHBoxLayout(this);
|
||||||
mainWidget->setAutoFillBackground(true);
|
layout->setMargin(0);
|
||||||
// If the user clicks on the mainwidget it gets focus, even though that's not visible
|
m_stackedWidget = new QStackedWidget(this); // simplfy make AndroidManifestEditorWidget a stacked widget
|
||||||
// This is to prevent the parent, the actual basetexteditorwidget from getting focus
|
layout->addWidget(m_stackedWidget);
|
||||||
mainWidget->setFocusPolicy(Qt::WheelFocus);
|
|
||||||
mainWidget->installEventFilter(this);
|
|
||||||
|
|
||||||
Core::IContext *myContext = new Core::IContext(this);
|
Core::IContext *myContext = new Core::IContext(this);
|
||||||
myContext->setWidget(mainWidget);
|
myContext->setWidget(m_stackedWidget);
|
||||||
myContext->setContext(Core::Context(androidManifestEditorGeneralPaneContextId));
|
myContext->setContext(Core::Context(androidManifestEditorGeneralPaneContextId)); // where is the context used?
|
||||||
Core::ICore::addContextObject(myContext);
|
Core::ICore::addContextObject(myContext);
|
||||||
|
|
||||||
|
QWidget *mainWidget = new QWidget; // different name
|
||||||
|
|
||||||
QVBoxLayout *topLayout = new QVBoxLayout(mainWidget);
|
QVBoxLayout *topLayout = new QVBoxLayout(mainWidget);
|
||||||
|
|
||||||
QGroupBox *packageGroupBox = new QGroupBox(mainWidget);
|
QGroupBox *packageGroupBox = new QGroupBox(mainWidget);
|
||||||
@@ -444,7 +441,8 @@ void AndroidManifestEditorWidget::initializePage()
|
|||||||
|
|
||||||
topLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::MinimumExpanding));
|
topLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::MinimumExpanding));
|
||||||
|
|
||||||
m_overlayWidget = mainWidget;
|
m_stackedWidget->insertWidget(General, mainWidget);
|
||||||
|
m_stackedWidget->insertWidget(Source, m_textEditorWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AndroidManifestEditorWidget::eventFilter(QObject *obj, QEvent *event)
|
bool AndroidManifestEditorWidget::eventFilter(QObject *obj, QEvent *event)
|
||||||
@@ -454,18 +452,12 @@ bool AndroidManifestEditorWidget::eventFilter(QObject *obj, QEvent *event)
|
|||||||
QTimer::singleShot(0, this, SLOT(updateTargetComboBox()));
|
QTimer::singleShot(0, this, SLOT(updateTargetComboBox()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj == m_overlayWidget)
|
return QWidget::eventFilter(obj, event);
|
||||||
if (event->type() == QEvent::KeyPress
|
|
||||||
|| event->type() == QEvent::KeyRelease) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TextEditor::PlainTextEditorWidget::eventFilter(obj, event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidManifestEditorWidget::updateTargetComboBox()
|
void AndroidManifestEditorWidget::updateTargetComboBox()
|
||||||
{
|
{
|
||||||
const QString docPath(baseTextDocument()->filePath());
|
const QString docPath(m_textEditorWidget->baseTextDocument()->filePath());
|
||||||
ProjectExplorer::Project *project = androidProject(docPath);
|
ProjectExplorer::Project *project = androidProject(docPath);
|
||||||
QStringList items;
|
QStringList items;
|
||||||
if (project) {
|
if (project) {
|
||||||
@@ -487,28 +479,20 @@ void AndroidManifestEditorWidget::updateTargetComboBox()
|
|||||||
m_targetLineEdit->addItems(items);
|
m_targetLineEdit->addItems(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidManifestEditorWidget::resizeEvent(QResizeEvent *event)
|
|
||||||
{
|
|
||||||
PlainTextEditorWidget::resizeEvent(event);
|
|
||||||
QSize s = QSize(rect().width(), rect().height());
|
|
||||||
m_overlayWidget->resize(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AndroidManifestEditorWidget::open(QString *errorString, const QString &fileName, const QString &realFileName)
|
bool AndroidManifestEditorWidget::open(QString *errorString, const QString &fileName, const QString &realFileName)
|
||||||
{
|
{
|
||||||
bool result = PlainTextEditorWidget::open(errorString, fileName, realFileName);
|
bool result = m_textEditorWidget->open(errorString, fileName, realFileName);
|
||||||
|
|
||||||
updateSdkVersions();
|
updateSdkVersions();
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
Q_UNUSED(errorString);
|
|
||||||
QString error;
|
QString error;
|
||||||
int errorLine;
|
int errorLine;
|
||||||
int errorColumn;
|
int errorColumn;
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
if (doc.setContent(toPlainText(), &error, &errorLine, &errorColumn)) {
|
if (doc.setContent(m_textEditorWidget->toPlainText(), &error, &errorLine, &errorColumn)) {
|
||||||
if (checkDocument(doc, &error, &errorLine, &errorColumn)) {
|
if (checkDocument(doc, &error, &errorLine, &errorColumn)) {
|
||||||
if (activePage() != Source)
|
if (activePage() != Source)
|
||||||
syncToWidgets(doc);
|
syncToWidgets(doc);
|
||||||
@@ -518,7 +502,6 @@ bool AndroidManifestEditorWidget::open(QString *errorString, const QString &file
|
|||||||
// some error occured
|
// some error occured
|
||||||
updateInfoBar(error, errorLine, errorColumn);
|
updateInfoBar(error, errorLine, errorColumn);
|
||||||
setActivePage(Source);
|
setActivePage(Source);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -527,7 +510,7 @@ void AndroidManifestEditorWidget::setDirty(bool dirty)
|
|||||||
if (m_stayClean)
|
if (m_stayClean)
|
||||||
return;
|
return;
|
||||||
m_dirty = dirty;
|
m_dirty = dirty;
|
||||||
emit changed();
|
emit guiChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AndroidManifestEditorWidget::isModified() const
|
bool AndroidManifestEditorWidget::isModified() const
|
||||||
@@ -541,7 +524,7 @@ bool AndroidManifestEditorWidget::isModified() const
|
|||||||
|
|
||||||
AndroidManifestEditorWidget::EditorPage AndroidManifestEditorWidget::activePage() const
|
AndroidManifestEditorWidget::EditorPage AndroidManifestEditorWidget::activePage() const
|
||||||
{
|
{
|
||||||
return m_overlayWidget->isVisibleTo(const_cast<AndroidManifestEditorWidget *>(this)) ? General : Source;
|
return AndroidManifestEditorWidget::EditorPage(m_stackedWidget->currentIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AndroidManifestEditorWidget::setActivePage(EditorPage page)
|
bool AndroidManifestEditorWidget::setActivePage(EditorPage page)
|
||||||
@@ -557,22 +540,15 @@ bool AndroidManifestEditorWidget::setActivePage(EditorPage page)
|
|||||||
} else {
|
} else {
|
||||||
if (!syncToWidgets())
|
if (!syncToWidgets())
|
||||||
return false;
|
return false;
|
||||||
|
// TODO?
|
||||||
QWidget *fw = m_overlayWidget->focusWidget();
|
// QWidget *fw = m_overlayWidget->focusWidget();
|
||||||
if (fw && fw != m_overlayWidget)
|
// if (fw && fw != m_overlayWidget)
|
||||||
fw->setFocus();
|
// fw->setFocus();
|
||||||
else
|
// else
|
||||||
m_packageNameLineEdit->setFocus();
|
// m_packageNameLineEdit->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_overlayWidget->setVisible(page == General);
|
m_stackedWidget->setCurrentIndex(page);
|
||||||
if (page == General) {
|
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
||||||
} else {
|
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -582,7 +558,7 @@ void AndroidManifestEditorWidget::preSave()
|
|||||||
syncToEditor();
|
syncToEditor();
|
||||||
|
|
||||||
if (m_setAppName && m_appNameInStringsXml) {
|
if (m_setAppName && m_appNameInStringsXml) {
|
||||||
QString baseDir = QFileInfo(baseTextDocument()->filePath()).absolutePath();
|
QString baseDir = QFileInfo(m_textEditorWidget->baseTextDocument()->filePath()).absolutePath();
|
||||||
QString fileName = baseDir + QLatin1String("/res/values/strings.xml");
|
QString fileName = baseDir + QLatin1String("/res/values/strings.xml");
|
||||||
QFile f(fileName);
|
QFile f(fileName);
|
||||||
if (f.open(QIODevice::ReadOnly)) {
|
if (f.open(QIODevice::ReadOnly)) {
|
||||||
@@ -606,7 +582,7 @@ void AndroidManifestEditorWidget::preSave()
|
|||||||
m_setAppName = false;
|
m_setAppName = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString baseDir = QFileInfo(baseTextDocument()->filePath()).absolutePath();
|
QString baseDir = QFileInfo(m_textEditorWidget->baseTextDocument()->filePath()).absolutePath();
|
||||||
if (!m_lIconPath.isEmpty()) {
|
if (!m_lIconPath.isEmpty()) {
|
||||||
copyIcon(LowDPI, baseDir, m_lIconPath);
|
copyIcon(LowDPI, baseDir, m_lIconPath);
|
||||||
m_lIconPath.clear();
|
m_lIconPath.clear();
|
||||||
@@ -624,12 +600,22 @@ void AndroidManifestEditorWidget::preSave()
|
|||||||
updateInfoBar();
|
updateInfoBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Core::IEditor *AndroidManifestEditorWidget::editor() const
|
||||||
|
{
|
||||||
|
return m_editor;
|
||||||
|
}
|
||||||
|
|
||||||
|
TextEditor::PlainTextEditorWidget *AndroidManifestEditorWidget::textEditorWidget() const
|
||||||
|
{
|
||||||
|
return m_textEditorWidget;
|
||||||
|
}
|
||||||
|
|
||||||
bool AndroidManifestEditorWidget::syncToWidgets()
|
bool AndroidManifestEditorWidget::syncToWidgets()
|
||||||
{
|
{
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
int errorLine, errorColumn;
|
int errorLine, errorColumn;
|
||||||
if (doc.setContent(toPlainText(), &errorMessage, &errorLine, &errorColumn)) {
|
if (doc.setContent(m_textEditorWidget->toPlainText(), &errorMessage, &errorLine, &errorColumn)) {
|
||||||
if (checkDocument(doc, &errorMessage, &errorLine, &errorColumn)) {
|
if (checkDocument(doc, &errorMessage, &errorLine, &errorColumn)) {
|
||||||
hideInfoBar();
|
hideInfoBar();
|
||||||
syncToWidgets(doc);
|
syncToWidgets(doc);
|
||||||
@@ -678,7 +664,7 @@ void AndroidManifestEditorWidget::updateInfoBar()
|
|||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
int errorLine, errorColumn;
|
int errorLine, errorColumn;
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
if (doc.setContent(toPlainText(), &errorMessage, &errorLine, &errorColumn)) {
|
if (doc.setContent(m_textEditorWidget->toPlainText(), &errorMessage, &errorLine, &errorColumn)) {
|
||||||
if (checkDocument(doc, &errorMessage, &errorLine, &errorColumn)) {
|
if (checkDocument(doc, &errorMessage, &errorLine, &errorColumn)) {
|
||||||
hideInfoBar();
|
hideInfoBar();
|
||||||
return;
|
return;
|
||||||
@@ -690,7 +676,7 @@ void AndroidManifestEditorWidget::updateInfoBar()
|
|||||||
|
|
||||||
void AndroidManifestEditorWidget::updateSdkVersions()
|
void AndroidManifestEditorWidget::updateSdkVersions()
|
||||||
{
|
{
|
||||||
const QString docPath(baseTextDocument()->filePath());
|
const QString docPath(m_textEditorWidget->baseTextDocument()->filePath());
|
||||||
Project *project = androidProject(docPath);
|
Project *project = androidProject(docPath);
|
||||||
QPair<int, int> apiLevels = AndroidManager::apiLevelRange(project ? project->activeTarget() : 0);
|
QPair<int, int> apiLevels = AndroidManager::apiLevelRange(project ? project->activeTarget() : 0);
|
||||||
for (int i = apiLevels.first; i < apiLevels.second + 1; ++i)
|
for (int i = apiLevels.first; i < apiLevels.second + 1; ++i)
|
||||||
@@ -708,7 +694,7 @@ void AndroidManifestEditorWidget::updateSdkVersions()
|
|||||||
|
|
||||||
void AndroidManifestEditorWidget::updateInfoBar(const QString &errorMessage, int line, int column)
|
void AndroidManifestEditorWidget::updateInfoBar(const QString &errorMessage, int line, int column)
|
||||||
{
|
{
|
||||||
Core::InfoBar *infoBar = baseTextDocument()->infoBar();
|
Core::InfoBar *infoBar = m_textEditorWidget->baseTextDocument()->infoBar();
|
||||||
QString text;
|
QString text;
|
||||||
if (line < 0)
|
if (line < 0)
|
||||||
text = tr("Could not parse file: '%1'.").arg(errorMessage);
|
text = tr("Could not parse file: '%1'.").arg(errorMessage);
|
||||||
@@ -726,14 +712,14 @@ void AndroidManifestEditorWidget::updateInfoBar(const QString &errorMessage, int
|
|||||||
|
|
||||||
void AndroidManifestEditorWidget::hideInfoBar()
|
void AndroidManifestEditorWidget::hideInfoBar()
|
||||||
{
|
{
|
||||||
Core::InfoBar *infoBar = baseTextDocument()->infoBar();
|
Core::InfoBar *infoBar = m_textEditorWidget->baseTextDocument()->infoBar();
|
||||||
infoBar->removeInfo(infoBarId);
|
infoBar->removeInfo(infoBarId);
|
||||||
m_timerParseCheck.stop();
|
m_timerParseCheck.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidManifestEditorWidget::gotoError()
|
void AndroidManifestEditorWidget::gotoError()
|
||||||
{
|
{
|
||||||
gotoLine(m_errorLine, m_errorColumn);
|
m_textEditorWidget->gotoLine(m_errorLine, m_errorColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setApiLevel(QComboBox *box, const QDomElement &element, const QString &attribute)
|
void setApiLevel(QComboBox *box, const QDomElement &element, const QString &attribute)
|
||||||
@@ -765,7 +751,7 @@ void AndroidManifestEditorWidget::syncToWidgets(const QDomDocument &doc)
|
|||||||
setApiLevel(m_androidMinSdkVersion, usesSdkElement, QLatin1String("android:minSdkVersion"));
|
setApiLevel(m_androidMinSdkVersion, usesSdkElement, QLatin1String("android:minSdkVersion"));
|
||||||
setApiLevel(m_androidTargetSdkVersion, usesSdkElement, QLatin1String("android:targetSdkVersion"));
|
setApiLevel(m_androidTargetSdkVersion, usesSdkElement, QLatin1String("android:targetSdkVersion"));
|
||||||
|
|
||||||
QString baseDir = QFileInfo(baseTextDocument()->filePath()).absolutePath();
|
QString baseDir = QFileInfo(m_textEditorWidget->baseTextDocument()->filePath()).absolutePath();
|
||||||
QString fileName = baseDir + QLatin1String("/res/values/strings.xml");
|
QString fileName = baseDir + QLatin1String("/res/values/strings.xml");
|
||||||
|
|
||||||
QDomElement applicationElement = manifest.firstChildElement(QLatin1String("application"));
|
QDomElement applicationElement = manifest.firstChildElement(QLatin1String("application"));
|
||||||
@@ -883,7 +869,7 @@ int extractVersion(const QString &string)
|
|||||||
void AndroidManifestEditorWidget::syncToEditor()
|
void AndroidManifestEditorWidget::syncToEditor()
|
||||||
{
|
{
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
if (!doc.setContent(toPlainText())) {
|
if (!doc.setContent(m_textEditorWidget->toPlainText())) {
|
||||||
// This should not happen
|
// This should not happen
|
||||||
updateInfoBar();
|
updateInfoBar();
|
||||||
return;
|
return;
|
||||||
@@ -930,11 +916,11 @@ void AndroidManifestEditorWidget::syncToEditor()
|
|||||||
|
|
||||||
|
|
||||||
QString newText = doc.toString(4);
|
QString newText = doc.toString(4);
|
||||||
if (newText == toPlainText())
|
if (newText == m_textEditorWidget->toPlainText())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
setPlainText(newText);
|
m_textEditorWidget->setPlainText(newText);
|
||||||
document()->setModified(true); // Why is this necessary?
|
m_textEditorWidget->document()->setModified(true);
|
||||||
|
|
||||||
m_dirty = false;
|
m_dirty = false;
|
||||||
}
|
}
|
||||||
@@ -1062,7 +1048,7 @@ void AndroidManifestEditorWidget::removePermission()
|
|||||||
void AndroidManifestEditorWidget::setAppName()
|
void AndroidManifestEditorWidget::setAppName()
|
||||||
{
|
{
|
||||||
m_setAppName = true;
|
m_setAppName = true;
|
||||||
emit changed();
|
setDirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidManifestEditorWidget::setPackageName()
|
void AndroidManifestEditorWidget::setPackageName()
|
||||||
@@ -1154,3 +1140,12 @@ int PermissionsModel::rowCount(const QModelIndex &parent) const
|
|||||||
Q_UNUSED(parent)
|
Q_UNUSED(parent)
|
||||||
return m_permissions.count();
|
return m_permissions.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AndroidManifestTextEditorWidget::AndroidManifestTextEditorWidget(AndroidManifestEditorWidget *parent)
|
||||||
|
: TextEditor::PlainTextEditorWidget(new AndroidManifestDocument(parent), parent),
|
||||||
|
m_parent(parent)
|
||||||
|
{
|
||||||
|
baseTextDocument()->setMimeType(QLatin1String(Constants::ANDROID_MANIFEST_MIME_TYPE));
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ namespace Core { class IEditor; }
|
|||||||
namespace Android {
|
namespace Android {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
class AndroidManifestEditor;
|
class AndroidManifestEditor;
|
||||||
|
class AndroidManifestEditorWidget;
|
||||||
|
|
||||||
|
|
||||||
class PermissionsModel: public QAbstractListModel
|
class PermissionsModel: public QAbstractListModel
|
||||||
@@ -75,16 +76,24 @@ private:
|
|||||||
QStringList m_permissions;
|
QStringList m_permissions;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AndroidManifestEditorWidget : public TextEditor::PlainTextEditorWidget
|
class AndroidManifestTextEditorWidget : public TextEditor::PlainTextEditorWidget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AndroidManifestTextEditorWidget(AndroidManifestEditorWidget *parent = 0);
|
||||||
|
protected:
|
||||||
|
AndroidManifestEditorWidget *m_parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
class AndroidManifestEditorWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum EditorPage {
|
enum EditorPage {
|
||||||
General,
|
General = 0,
|
||||||
Source
|
Source = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit AndroidManifestEditorWidget(QWidget *parent = 0);
|
explicit AndroidManifestEditorWidget();
|
||||||
|
|
||||||
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
|
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
|
||||||
|
|
||||||
@@ -95,12 +104,16 @@ public:
|
|||||||
|
|
||||||
void preSave();
|
void preSave();
|
||||||
|
|
||||||
|
Core::IEditor *editor() const;
|
||||||
|
TextEditor::PlainTextEditorWidget *textEditorWidget() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setDirty(bool dirty = true);
|
void setDirty(bool dirty = true);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void guiChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TextEditor::BaseTextEditor *createEditor();
|
|
||||||
void resizeEvent(QResizeEvent *event);
|
|
||||||
bool eventFilter(QObject *obj, QEvent *event);
|
bool eventFilter(QObject *obj, QEvent *event);
|
||||||
private slots:
|
private slots:
|
||||||
void setLDPIIcon();
|
void setLDPIIcon();
|
||||||
@@ -165,8 +178,10 @@ private:
|
|||||||
QPushButton *m_removePermissionButton;
|
QPushButton *m_removePermissionButton;
|
||||||
QComboBox *m_permissionsComboBox;
|
QComboBox *m_permissionsComboBox;
|
||||||
|
|
||||||
QWidget *m_overlayWidget;
|
|
||||||
QTimer m_timerParseCheck;
|
QTimer m_timerParseCheck;
|
||||||
|
TextEditor::PlainTextEditorWidget *m_textEditorWidget;
|
||||||
|
QStackedWidget *m_stackedWidget;
|
||||||
|
AndroidManifestEditor *m_editor;
|
||||||
};
|
};
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Android
|
} // namespace Android
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ QList<LocatorFilterEntry> LineNumberFilter::matchesFor(QFutureInterface<Core::Lo
|
|||||||
column = lineAndColumn.at(1).toInt(&ok);
|
column = lineAndColumn.at(1).toInt(&ok);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
return value;
|
return value;
|
||||||
if (currentTextEditor() && (line > 0 || column > 0)) {
|
if (EditorManager::currentEditor() && (line > 0 || column > 0)) {
|
||||||
LineColumn data;
|
LineColumn data;
|
||||||
data.first = line;
|
data.first = line;
|
||||||
data.second = column - 1; // column API is 0-based
|
data.second = column - 1; // column API is 0-based
|
||||||
@@ -88,21 +88,13 @@ QList<LocatorFilterEntry> LineNumberFilter::matchesFor(QFutureInterface<Core::Lo
|
|||||||
|
|
||||||
void LineNumberFilter::accept(LocatorFilterEntry selection) const
|
void LineNumberFilter::accept(LocatorFilterEntry selection) const
|
||||||
{
|
{
|
||||||
ITextEditor *editor = currentTextEditor();
|
IEditor *editor = EditorManager::currentEditor();
|
||||||
if (editor) {
|
if (editor) {
|
||||||
EditorManager::addCurrentPositionToNavigationHistory();
|
EditorManager::addCurrentPositionToNavigationHistory();
|
||||||
LineColumn data = selection.internalData.value<LineColumn>();
|
LineColumn data = selection.internalData.value<LineColumn>();
|
||||||
if (data.first < 1) { // jump to column in same line
|
if (data.first < 1) // jump to column in same line
|
||||||
int currLine, currColumn;
|
data.first = editor->currentLine();
|
||||||
editor->convertPosition(editor->position(), &currLine, &currColumn);
|
|
||||||
data.first = currLine;
|
|
||||||
}
|
|
||||||
editor->gotoLine(data.first, data.second);
|
editor->gotoLine(data.first, data.second);
|
||||||
EditorManager::activateEditor(editor);
|
EditorManager::activateEditor(editor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ITextEditor *LineNumberFilter::currentTextEditor() const
|
|
||||||
{
|
|
||||||
return qobject_cast<TextEditor::ITextEditor *>(EditorManager::currentEditor());
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -36,10 +36,11 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QFutureInterface>
|
#include <QFutureInterface>
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class IEditor;
|
||||||
|
}
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
|
|
||||||
class ITextEditor;
|
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class LineNumberFilter : public Core::ILocatorFilter
|
class LineNumberFilter : public Core::ILocatorFilter
|
||||||
@@ -52,9 +53,6 @@ public:
|
|||||||
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry);
|
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry);
|
||||||
void accept(Core::LocatorFilterEntry selection) const;
|
void accept(Core::LocatorFilterEntry selection) const;
|
||||||
void refresh(QFutureInterface<void> &) {}
|
void refresh(QFutureInterface<void> &) {}
|
||||||
|
|
||||||
private:
|
|
||||||
ITextEditor *currentTextEditor() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user