From 12344ae9d8bd914a3eb87db3d0da4d309d3cae08 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 5 Oct 2018 15:59:21 +0200 Subject: [PATCH] NotificationDisplay: add an Error-State and implement signal to trigger on change this is more or less gratitious functionality for now, yet I consider it a proof-of-concept --- src/gui/widget/error-log-display.hpp | 34 ++++++++++++++++++++++++++++ tests/gui/abstract-tangible-test.cpp | 4 ++-- wiki/thinkPad.ichthyo.mm | 32 +++++++++++++++++++++----- 3 files changed, 62 insertions(+), 8 deletions(-) diff --git a/src/gui/widget/error-log-display.hpp b/src/gui/widget/error-log-display.hpp index 3a2fce578..d33f87aa8 100644 --- a/src/gui/widget/error-log-display.hpp +++ b/src/gui/widget/error-log-display.hpp @@ -129,6 +129,9 @@ namespace widget { vector errorMarks_; TextWidget textLog_; + sigc::signal errorChangedSignal_; + + public: ~ErrorLogDisplay() { }; @@ -158,12 +161,17 @@ namespace widget { void clearAll() { + bool shallNotify = not errorMarks_.empty(); + errorMarks_.clear(); size_t lineCnt = textLog_.get_buffer()->get_line_count(); string placeholder; if (lineCnt > 0) placeholder = _Fmt{_("───════ %d preceding lines removed ════───\n")} % lineCnt; textLog_.get_buffer()->set_text (placeholder); // discard existing content + + if (shallNotify) + errorChangedSignal_.emit (true); } @@ -192,10 +200,15 @@ namespace widget { void addError (string text) { + bool shallNotify = errorMarks_.empty(); + errorMarks_.emplace_back( addEntry ("ERROR: "+text, TAG_ERROR)); if (not expand.isExpanded()) expand (true); + + if (shallNotify) + errorChangedSignal_.emit (true); } /** @@ -240,6 +253,8 @@ namespace widget { void turnError_into_InfoMsg() { + bool shallNotify = not errorMarks_.empty(); + auto buff = textLog_.get_buffer(); for (Entry& entry : errorMarks_) { @@ -250,6 +265,9 @@ namespace widget { buff->apply_tag_by_name (uString{TAG_WARN}, begin,end); } errorMarks_.clear(); + + if (shallNotify) + errorChangedSignal_.emit (true); } @@ -264,6 +282,22 @@ namespace widget { } + /* ======= Error-State ======= */ + + bool + isError() const + { + return not errorMarks_.empty(); + } + + /** signal fired when error state changes */ + sigc::signal + signalErrorChanged() + { + return errorChangedSignal_; + } + + private:/* ===== Internals ===== */ diff --git a/tests/gui/abstract-tangible-test.cpp b/tests/gui/abstract-tangible-test.cpp index 087c4b61e..9382b4c9d 100644 --- a/tests/gui/abstract-tangible-test.cpp +++ b/tests/gui/abstract-tangible-test.cpp @@ -180,8 +180,8 @@ namespace test { invokeCommand(); markState(); revealer(); -// notify(); -// mutate(); + notify(); + mutate(); } diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 0341d5f1a..1285bcd45 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -2484,6 +2484,22 @@ + + + + + + + + + + + + + + + + @@ -2569,8 +2585,8 @@ - - + + @@ -2865,13 +2881,14 @@ - - + + - - + + + @@ -3793,6 +3810,9 @@ + + +