blob: 55533d110c4de7c8462577276084c09dca38468e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#include "snippeteditor.h"
#include <texteditor/textdocument.h>
#include <texteditor/texteditorconstants.h>
#include <texteditor/texteditorsettings.h>
#include <utils/qtcassert.h>
#include <QFocusEvent>
namespace TextEditor {
/*!
\class TextEditor::SnippetEditorWidget
\brief The SnippetEditorWidget class is a lightweight editor for code snippets
with basic support for syntax highlighting, indentation, and others.
\ingroup Snippets
*/
SnippetEditorWidget::SnippetEditorWidget(QWidget *parent)
: TextEditorWidget(parent)
{
setupFallBackEditor(TextEditor::Constants::SNIPPET_EDITOR_ID);
setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
setHighlightCurrentLine(false);
setLineNumbersVisible(false);
setParenthesesMatchingEnabled(true);
}
void SnippetEditorWidget::focusOutEvent(QFocusEvent *event)
{
if (event->reason() != Qt::ActiveWindowFocusReason && document()->isModified()) {
document()->setModified(false);
emit snippetContentChanged();
}
TextEditorWidget::focusOutEvent(event);
}
void SnippetEditorWidget::contextMenuEvent(QContextMenuEvent *e)
{
QPlainTextEdit::contextMenuEvent(e);
}
} // namespace
|