aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quickcontrols2/texteditor
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quickcontrols2/texteditor')
-rw-r--r--examples/quickcontrols2/texteditor/CMakeLists.txt1
-rw-r--r--examples/quickcontrols2/texteditor/documenthandler.cpp69
-rw-r--r--examples/quickcontrols2/texteditor/documenthandler.h16
-rw-r--r--examples/quickcontrols2/texteditor/qml/+touch/texteditor.qml3
-rw-r--r--examples/quickcontrols2/texteditor/qtquickcontrols2.conf11
-rw-r--r--examples/quickcontrols2/texteditor/texteditor.qrc1
6 files changed, 85 insertions, 16 deletions
diff --git a/examples/quickcontrols2/texteditor/CMakeLists.txt b/examples/quickcontrols2/texteditor/CMakeLists.txt
index 187d1a88b4..6c3de0891f 100644
--- a/examples/quickcontrols2/texteditor/CMakeLists.txt
+++ b/examples/quickcontrols2/texteditor/CMakeLists.txt
@@ -37,7 +37,6 @@ set(texteditor_resource_files
"images/qt-logo.png"
"qml/+touch/texteditor.qml"
"qml/texteditor.qml"
- "qtquickcontrols2.conf"
"texteditor.html"
)
diff --git a/examples/quickcontrols2/texteditor/documenthandler.cpp b/examples/quickcontrols2/texteditor/documenthandler.cpp
index d904e6f637..b266bc5694 100644
--- a/examples/quickcontrols2/texteditor/documenthandler.cpp
+++ b/examples/quickcontrols2/texteditor/documenthandler.cpp
@@ -323,4 +323,73 @@ void DocumentHandler::setFont(const QFont & font){
emit fontChanged();
}
+bool DocumentHandler::bold() const
+{
+ const QTextCursor cursor = textCursor();
+ if (cursor.isNull())
+ return m_document->textDocument()->defaultFont().bold();
+ return cursor.charFormat().font().bold();
+}
+
+void DocumentHandler::setBold(bool bold)
+{
+ const QTextCursor cursor = textCursor();
+ if (!cursor.isNull() && cursor.charFormat().font().bold() == bold)
+ return;
+
+ QFont font = cursor.charFormat().font();
+ font.setBold(bold);
+ QTextCharFormat format;
+ format.setFont(font);
+ mergeFormatOnWordOrSelection(format);
+
+ emit boldChanged();
+}
+
+bool DocumentHandler::underline() const
+{
+ const QTextCursor cursor = textCursor();
+ if (cursor.isNull())
+ return m_document->textDocument()->defaultFont().underline();
+ return cursor.charFormat().font().underline();
+}
+
+void DocumentHandler::setUnderline(bool underline)
+{
+ const QTextCursor cursor = textCursor();
+ if (!cursor.isNull() && cursor.charFormat().font().underline() == underline)
+ return;
+
+ QFont font = cursor.charFormat().font();
+ font.setUnderline(underline);
+ QTextCharFormat format;
+ format.setFont(font);
+ mergeFormatOnWordOrSelection(format);
+
+ emit underlineChanged();
+}
+
+bool DocumentHandler::italic() const
+{
+ const QTextCursor cursor = textCursor();
+ if (cursor.isNull())
+ return m_document->textDocument()->defaultFont().italic();
+ return cursor.charFormat().font().italic();
+}
+
+void DocumentHandler::setItalic(bool italic)
+{
+ const QTextCursor cursor = textCursor();
+ if (!cursor.isNull() && cursor.charFormat().font().italic() == italic)
+ return;
+
+ QFont font = cursor.charFormat().font();
+ font.setItalic(italic);
+ QTextCharFormat format;
+ format.setFont(font);
+ mergeFormatOnWordOrSelection(format);
+
+ emit italicChanged();
+}
+
#include "moc_documenthandler.cpp"
diff --git a/examples/quickcontrols2/texteditor/documenthandler.h b/examples/quickcontrols2/texteditor/documenthandler.h
index 66b5957a20..aa3f257558 100644
--- a/examples/quickcontrols2/texteditor/documenthandler.h
+++ b/examples/quickcontrols2/texteditor/documenthandler.h
@@ -75,6 +75,10 @@ class DocumentHandler : public QObject
Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
+ Q_PROPERTY(bool bold READ bold WRITE setBold NOTIFY boldChanged)
+ Q_PROPERTY(bool underline READ underline WRITE setUnderline NOTIFY underlineChanged)
+ Q_PROPERTY(bool italic READ italic WRITE setItalic NOTIFY italicChanged)
+
Q_PROPERTY(QString fileName READ fileName NOTIFY fileUrlChanged)
Q_PROPERTY(QString fileType READ fileType NOTIFY fileUrlChanged)
Q_PROPERTY(QUrl fileUrl READ fileUrl NOTIFY fileUrlChanged)
@@ -105,6 +109,15 @@ public:
QFont font() const;
void setFont(const QFont & font);
+ bool bold() const;
+ void setBold(bool bold);
+
+ bool underline() const;
+ void setUnderline(bool underline);
+
+ bool italic() const;
+ void setItalic(bool italic);
+
QString fileName() const;
QString fileType() const;
QUrl fileUrl() const;
@@ -123,6 +136,9 @@ Q_SIGNALS:
void selectionEndChanged();
void fontChanged();
+ void boldChanged();
+ void underlineChanged();
+ void italicChanged();
void textColorChanged();
void alignmentChanged();
diff --git a/examples/quickcontrols2/texteditor/qml/+touch/texteditor.qml b/examples/quickcontrols2/texteditor/qml/+touch/texteditor.qml
index 7d7554f44b..677d25fbd9 100644
--- a/examples/quickcontrols2/texteditor/qml/+touch/texteditor.qml
+++ b/examples/quickcontrols2/texteditor/qml/+touch/texteditor.qml
@@ -149,9 +149,6 @@ ApplicationWindow {
footer: ToolBar {
visible: !textArea.readOnly && textArea.activeFocus
- Material.primary: "#E0E0E0"
- Material.elevation: 0
-
Flickable {
anchors.fill: parent
contentWidth: toolRow.implicitWidth
diff --git a/examples/quickcontrols2/texteditor/qtquickcontrols2.conf b/examples/quickcontrols2/texteditor/qtquickcontrols2.conf
deleted file mode 100644
index ecac617fcb..0000000000
--- a/examples/quickcontrols2/texteditor/qtquickcontrols2.conf
+++ /dev/null
@@ -1,11 +0,0 @@
-[Controls]
-Style=Material
-
-[Material]
-Primary=White
-Foreground=#444444
-Accent=Blue
-Theme=System
-
-[Universal]
-Theme=System
diff --git a/examples/quickcontrols2/texteditor/texteditor.qrc b/examples/quickcontrols2/texteditor/texteditor.qrc
index 8f2da8432b..cdb7225a39 100644
--- a/examples/quickcontrols2/texteditor/texteditor.qrc
+++ b/examples/quickcontrols2/texteditor/texteditor.qrc
@@ -1,6 +1,5 @@
<RCC>
<qresource prefix="/">
- <file>qtquickcontrols2.conf</file>
<file>images/qt-logo.png</file>
<file>fonts/fontello.ttf</file>
<file>qml/texteditor.qml</file>