diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-08-19 16:01:05 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-08-21 10:13:23 +0200 |
commit | 63a4ecea93e278eeaa5de23d774d4dee06d9c4fa (patch) | |
tree | 01e0b9031cb3dba9c5ec8af8ba95a87790d8b4c8 /examples/quickcontrols2/texteditor/documenthandler.h | |
parent | 7c2ec7dc49799fffb2ed48a3a5afe2d8561ce3ee (diff) |
TextEditor: Add modified handling
Add a modified property to the document and add
handling in onClosing(). Connect the actions to
call close() instead of Qt.quit() for it to
become active.
Change-Id: I0fec75629db64e91508ed8ba45d4fb60be146b1b
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'examples/quickcontrols2/texteditor/documenthandler.h')
-rw-r--r-- | examples/quickcontrols2/texteditor/documenthandler.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/examples/quickcontrols2/texteditor/documenthandler.h b/examples/quickcontrols2/texteditor/documenthandler.h index a6125bc3..97e55658 100644 --- a/examples/quickcontrols2/texteditor/documenthandler.h +++ b/examples/quickcontrols2/texteditor/documenthandler.h @@ -84,6 +84,8 @@ class DocumentHandler : public QObject Q_PROPERTY(QString fileType READ fileType NOTIFY fileUrlChanged) Q_PROPERTY(QUrl fileUrl READ fileUrl NOTIFY fileUrlChanged) + Q_PROPERTY(bool modified READ modified WRITE setModified NOTIFY modifiedChanged) + public: explicit DocumentHandler(QObject *parent = nullptr); @@ -124,6 +126,9 @@ public: QString fileType() const; QUrl fileUrl() const; + bool modified() const; + void setModified(bool m); + public Q_SLOTS: void load(const QUrl &fileUrl); void saveAs(const QUrl &fileUrl); @@ -150,6 +155,8 @@ Q_SIGNALS: void loaded(const QString &text); void error(const QString &message); + void modifiedChanged(); + private: void reset(); QTextCursor textCursor() const; |