From 2044b998187ee094726556a25a245a237efd697f Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Thu, 16 Jan 2020 12:30:09 +0100 Subject: [PATCH] Add support for stashing and restoring states in caf::UiStyleSheet --- .../cafUserInterface/cafUiStyleSheet.cpp | 19 +++++++++++++++++++ Fwk/AppFwk/cafUserInterface/cafUiStyleSheet.h | 3 +++ 2 files changed, 22 insertions(+) diff --git a/Fwk/AppFwk/cafUserInterface/cafUiStyleSheet.cpp b/Fwk/AppFwk/cafUserInterface/cafUiStyleSheet.cpp index 5cb4f0b39e..c46d44d2f8 100644 --- a/Fwk/AppFwk/cafUserInterface/cafUiStyleSheet.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafUiStyleSheet.cpp @@ -213,6 +213,25 @@ void caf::UiStyleSheet::setWidgetState(QWidget* widget, QString stateTag, bool o refreshWidget(widget); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void caf::UiStyleSheet::stashWidgetStates() +{ + m_stashedStates.swap(m_states); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void caf::UiStyleSheet::restoreWidgetStates() +{ + if (!m_stashedStates.empty()) + { + m_stashedStates.swap(m_states); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafUserInterface/cafUiStyleSheet.h b/Fwk/AppFwk/cafUserInterface/cafUiStyleSheet.h index e1e9cec7cb..f6b0613204 100644 --- a/Fwk/AppFwk/cafUserInterface/cafUiStyleSheet.h +++ b/Fwk/AppFwk/cafUserInterface/cafUiStyleSheet.h @@ -86,6 +86,8 @@ public: void applyToWidgetAndChildren(QWidget* widget); static void clearWidgetStates(QWidget* widget); void setWidgetState(QWidget* widget, QString stateTag, bool on = true) const; + void stashWidgetStates(); + void restoreWidgetStates(); private: QString fullText(const QString& className, const QString& objectName, bool applyToSubClasses) const; @@ -93,5 +95,6 @@ private: private: std::map m_states; + std::map m_stashedStates; }; }