Fix text based Android manifest editor actions

All text editor actions were disabled. We want the actions to be enabled
when the focus is in the text editor widget in the Android manifest
editor.

For this the text editor action handler must differentiate between the
_editor_ and the _context_ that it handles. The one for the text based
manifest editor handles the manifest editor, but the context is specific
to the text editor part.

Change-Id: Ib91cc763cb27333a7d5b6e5b036dfead33961871
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Eike Ziller
2017-05-08 16:06:35 +02:00
parent 1f6764a54e
commit 2684254fad
7 changed files with 57 additions and 39 deletions

View File

@@ -77,7 +77,6 @@ using namespace Android::Internal;
namespace {
const QLatin1String packageNameRegExp("^([a-z]{1}[a-z0-9_]+(\\.[a-zA-Z]{1}[a-zA-Z0-9_]*)*)$");
const char infoBarId[] = "Android.AndroidManifestEditor.InfoBar";
const char androidManifestEditorGeneralPaneContextId[] = "AndroidManifestEditorWidget.GeneralWidget";
bool checkPackageName(const QString &packageName)
{
@@ -126,11 +125,6 @@ AndroidManifestEditorWidget::AndroidManifestEditorWidget()
void AndroidManifestEditorWidget::initializePage()
{
Core::IContext *myContext = new Core::IContext(this);
myContext->setWidget(this);
myContext->setContext(Core::Context(androidManifestEditorGeneralPaneContextId)); // where is the context used?
Core::ICore::addContextObject(myContext);
QWidget *mainWidget = new QWidget; // different name
QVBoxLayout *topLayout = new QVBoxLayout(mainWidget);
@@ -1405,5 +1399,17 @@ AndroidManifestTextEditorWidget::AndroidManifestTextEditorWidget(AndroidManifest
textDocument()->setMimeType(QLatin1String(Constants::ANDROID_MANIFEST_MIME_TYPE));
setupGenericHighlighter();
setMarksVisible(false);
// this context is used by the TextEditorActionHandler registered for the text editor in
// the AndroidManifestEditorFactory
m_context = new Core::IContext(this);
m_context->setWidget(this);
m_context->setContext(Core::Context(Constants::ANDROID_MANIFEST_EDITOR_CONTEXT));
Core::ICore::addContextObject(m_context);
}
AndroidManifestTextEditorWidget::~AndroidManifestTextEditorWidget()
{
Core::ICore::removeContextObject(m_context);
}