Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
messageeditorwidgets.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef MESSAGEEDITORWIDGETS_H
5#define MESSAGEEDITORWIDGETS_H
6
7#include <QAbstractButton>
8#include <QIcon>
9#include <QImage>
10#include <QLabel>
11#include <QMap>
12#include <QTextEdit>
13#include <QUrl>
14#include <QWidget>
15
17
18class QAction;
19class QContextMenuEvent;
20class QKeyEvent;
21class QMenu;
22class QSizeF;
23class QString;
24class QVariant;
25
27
28/*
29 Automatically adapt height to document contents
30 */
32{
34
35public:
37 QSize sizeHint() const override;
38 QSize minimumSizeHint() const override;
39
40private slots:
41 void updateHeight(const QSizeF &documentSize);
42 void reallyEnsureCursorVisible();
43
44private:
45 int m_minimumHeight;
46};
47
48/*
49 Format markup & control characters
50*/
52{
54public:
57 void setEditable(bool editable);
58
61
62public slots:
63 void setPlainText(const QString & text, bool userAction);
64 void setVisualizeWhitespace(bool value);
65
66private:
67 bool event(QEvent *event) override;
68 void applyReadOnlySelectionPalette();
69
70 MessageHighlighter *m_highlighter = nullptr;
71 QPalette m_defaultPalette;
72};
73
74/*
75 Displays text field & associated label
76*/
77class FormWidget : public QWidget
78{
80public:
81 FormWidget(const QString &label, bool isEditable, QWidget *parent = 0);
82 void setLabel(const QString &label) { m_label->setText(label); }
83 void setTranslation(const QString &text, bool userAction = false);
84 void clearTranslation() { setTranslation(QString(), false); }
85 QString getTranslation() { return m_editor->toPlainText(); }
86 void setEditingEnabled(bool enable);
87 void setHideWhenEmpty(bool optional) { m_hideWhenEmpty = optional; }
88 FormatTextEdit *getEditor() { return m_editor; }
89
92 void selectionChanged(QTextEdit *);
94
95private slots:
97 void slotTextChanged();
98
99private:
100 QLabel *m_label;
101 FormatTextEdit *m_editor;
102 bool m_hideWhenEmpty;
103};
104
105/*
106 Displays text fields & associated label
107*/
109{
111public:
113 void setLabel(const QString &label) { m_label->setText(label); }
114 void setTranslation(const QString &text, bool userAction = false);
115 void clearTranslation() { setTranslation(QString(), false); }
116 QString getTranslation() const;
117 void setEditingEnabled(bool enable);
118 void setMultiEnabled(bool enable);
119 void setHideWhenEmpty(bool optional) { m_hideWhenEmpty = optional; }
120 const QList<FormatTextEdit *> &getEditors() const { return m_editors; }
121
122signals:
124 void textChanged(QTextEdit *);
125 void selectionChanged(QTextEdit *);
127
128protected:
129 bool eventFilter(QObject *watched, QEvent *event) override;
130
131private slots:
132 void slotTextChanged();
133 void slotSelectionChanged();
134 void minusButtonClicked();
135 void plusButtonClicked();
136 void updateIcons();
137private:
138 void addEditor(int idx);
139 void updateLayout();
140
141 template<typename Func>
142 QAbstractButton *makeButton(const QIcon &icon, Func slot)
143 {
144 auto *button = makeButton(icon);
145 connect(button, &QAbstractButton::clicked,
146 this, slot);
147 return button;
148 }
149 QAbstractButton *makeButton(const QIcon &icon);
150 void insertEditor(int idx);
151 void deleteEditor(int idx);
152
153 QLabel *m_label;
154 QList<FormatTextEdit *> m_editors;
155 QList<QWidget *> m_plusButtons;
156 QList<QAbstractButton *> m_minusButtons;
157 bool m_hideWhenEmpty;
158 bool m_multiEnabled;
159 QIcon m_plusIcon, m_minusIcon;
160};
161
162QT_END_NAMESPACE
163
164#endif // MESSAGEEDITORWIDGETS_H
QSize minimumSizeHint() const override
QSize sizeHint() const override
void setLabel(const QString &label)
void selectionChanged(QTextEdit *)
void setHideWhenEmpty(bool optional)
void setTranslation(const QString &text, bool userAction=false)
void textChanged(QTextEdit *)
QString getTranslation() const
bool eventFilter(QObject *watched, QEvent *event) override
Filters events if this object has been installed as an event filter for the watched object.
void setMultiEnabled(bool enable)
void setEditingEnabled(bool enable)
void cursorPositionChanged()
const QList< FormatTextEdit * > & getEditors() const
void setLabel(const QString &label)
void setTranslation(const QString &text, bool userAction=false)
QString getTranslation()
void selectionChanged(QTextEdit *)
void setEditingEnabled(bool enable)
void cursorPositionChanged()
FormatTextEdit * getEditor()
void setHideWhenEmpty(bool optional)
void setVisualizeWhitespace(bool value)
bool event(QEvent *event) override
void setEditable(bool editable)
void setLengthVariants(bool on)
int activeModel() const
void setVisualizeWhitespace(bool value)
void setEditorFocusForModel(int model)
void setFontSize(const float fontSize)
void setUnfinishedEditorFocus()
bool focusNextUnfinished()
void showMessage(const MultiDataIndex &index)
bool eventFilter(QObject *, QEvent *) override
bool ncrMode() const
void setNcrMode(bool mode)
const TranslatorMessage & message() const
TranslatorMessage::Type type() const
int model() const
MessageItem * messageItem(const MultiDataIndex &index, int model) const
DataModel * model(int i)
void allModelsDeleted()
void languageChanged(int model)
bool isModelWritable(int model) const
void modelDeleted(int model)
static void clearSelection(QTextEdit *t)
FormWidget * transCommentText