Add support for stashing and restoring states in caf::UiStyleSheet

This commit is contained in:
Gaute Lindkvist 2020-01-16 12:30:09 +01:00
parent e5d7af4c18
commit 2044b99818
2 changed files with 22 additions and 0 deletions

View File

@ -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);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -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<QString, State> m_states;
std::map<QString, State> m_stashedStates;
};
}