aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/CMakeLists.txt2
-rw-r--r--desktop-widgets/tab-widgets/maintab.ui7
-rw-r--r--desktop-widgets/textedit.cpp7
-rw-r--r--desktop-widgets/textedit.h20
4 files changed, 35 insertions, 1 deletions
diff --git a/desktop-widgets/CMakeLists.txt b/desktop-widgets/CMakeLists.txt
index c494f1a8b..c451c46ef 100644
--- a/desktop-widgets/CMakeLists.txt
+++ b/desktop-widgets/CMakeLists.txt
@@ -126,6 +126,8 @@ set(SUBSURFACE_INTERFACE
tableview.h
tagwidget.cpp
tagwidget.h
+ textedit.cpp
+ textedit.h
updatemanager.cpp
updatemanager.h
usersurvey.cpp
diff --git a/desktop-widgets/tab-widgets/maintab.ui b/desktop-widgets/tab-widgets/maintab.ui
index 34ce65186..cc79634e6 100644
--- a/desktop-widgets/tab-widgets/maintab.ui
+++ b/desktop-widgets/tab-widgets/maintab.ui
@@ -454,7 +454,7 @@
<number>0</number>
</property>
<item>
- <widget class="QTextEdit" name="notes">
+ <widget class="TextEdit" name="notes">
<property name="readOnly">
<bool>false</bool>
</property>
@@ -601,6 +601,11 @@
<extends>QLineEdit</extends>
<header>desktop-widgets/locationinformation.h</header>
</customwidget>
+ <customwidget>
+ <class>TextEdit</class>
+ <extends>QTextEdit</extends>
+ <header>desktop-widgets/textedit.h</header>
+ </customwidget>
</customwidgets>
<resources>
<include location="../../subsurface.qrc"/>
diff --git a/desktop-widgets/textedit.cpp b/desktop-widgets/textedit.cpp
new file mode 100644
index 000000000..0e5619e84
--- /dev/null
+++ b/desktop-widgets/textedit.cpp
@@ -0,0 +1,7 @@
+#include "textedit.h"
+
+void TextEdit::focusOutEvent(QFocusEvent *ev)
+{
+ QTextEdit::focusOutEvent(ev);
+ emit editingFinished();
+}
diff --git a/desktop-widgets/textedit.h b/desktop-widgets/textedit.h
new file mode 100644
index 000000000..1b90c0248
--- /dev/null
+++ b/desktop-widgets/textedit.h
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-2.0
+#ifndef TEXTEDIT_H
+#define TEXTEDIT_H
+
+#include <QTextEdit>
+
+// QTextEdit does not possess a signal that fires when the user finished
+// editing the text. This subclass therefore overrides the focusOutEvent
+// and sends the textEdited signal.
+class TextEdit : public QTextEdit {
+ Q_OBJECT
+public:
+ using QTextEdit::QTextEdit; // Make constructors of QTextEdit available
+signals:
+ void editingFinished();
+private:
+ void focusOutEvent(QFocusEvent *ev) override;
+};
+
+#endif