More functionality for the generic highlighter options. Other small changes.

This commit is contained in:
Leandro Melo
2010-05-28 14:37:25 +02:00
parent 68cec6a7c7
commit 2dc7a6a1eb
14 changed files with 166 additions and 64 deletions

View File

@@ -32,10 +32,15 @@
#include "texteditorconstants.h"
#include "texteditorplugin.h"
#include "texteditoractionhandler.h"
#include "texteditorsettings.h"
#include "manager.h"
#include "highlightersettings.h"
#include <coreplugin/coreconstants.h>
#include <coreplugin/editormanager/editormanager.h>
#include <QDebug>
using namespace TextEditor;
using namespace TextEditor::Internal;
@@ -47,6 +52,9 @@ PlainTextEditorFactory::PlainTextEditorFactory(QObject *parent)
TextEditorActionHandler::Format |
TextEditorActionHandler::UnCommentSelection);
m_mimeTypes << QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT);
connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)),
this, SLOT(updateEditorInfoBar(Core::IEditor*)));
}
PlainTextEditorFactory::~PlainTextEditorFactory()
@@ -77,6 +85,25 @@ Core::IEditor *PlainTextEditorFactory::createEditor(QWidget *parent)
return rc->editableInterface();
}
void PlainTextEditorFactory::updateEditorInfoBar(Core::IEditor *editor)
{
PlainTextEditorEditable *editorEditable = qobject_cast<PlainTextEditorEditable *>(editor);
if (editorEditable) {
PlainTextEditor *textEditor = static_cast<PlainTextEditor *>(editorEditable->editor());
if (textEditor->isMissingSyntaxDefinition() &&
TextEditorSettings::instance()->highlighterSettings().m_alertWhenNoDefinition) {
Core::EditorManager::instance()->showEditorInfoBar(
Constants::INFO_SYNTAX_DEFINITION,
tr("A highlight definition was not found for this file. Would you like to try to find one?"),
tr("Show highlighter options"),
Manager::instance(),
SLOT(showGenericHighlighterOptions()));
}
} else {
Core::EditorManager::instance()->hideEditorInfoBar(Constants::INFO_SYNTAX_DEFINITION);
}
}
void PlainTextEditorFactory::addMimeType(const QString &type)
{
m_mimeTypes.append(type);