qskinny/src/controls/QskSkinStateChanger.h

44 lines
1.2 KiB
C
Raw Normal View History

2021-12-23 18:15:07 +01:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
#ifndef QSK_SKIN_STATE_CHANGER_H
#define QSK_SKIN_STATE_CHANGER_H
#include "QskAspect.h"
#include "QskSkinnable.h"
class QskSkinStateChanger
{
public:
QskSkinStateChanger( const QskSkinnable* );
2021-12-23 18:15:07 +01:00
~QskSkinStateChanger();
void setStates( QskAspect::States );
2021-12-27 17:33:06 +01:00
2021-12-23 18:15:07 +01:00
private:
QskSkinnable* m_skinnable;
2021-12-27 17:33:06 +01:00
const QskAspect::States m_oldStates;
2021-12-23 18:15:07 +01:00
};
inline QskSkinStateChanger::QskSkinStateChanger( const QskSkinnable* skinnable )
2021-12-23 18:15:07 +01:00
: m_skinnable( const_cast< QskSkinnable* >( skinnable ) )
, m_oldStates( skinnable->skinStates() )
{
}
inline QskSkinStateChanger::~QskSkinStateChanger()
{
if ( m_oldStates != m_skinnable->skinStates() )
m_skinnable->replaceSkinStates( m_oldStates );
}
inline void QskSkinStateChanger::setStates( QskAspect::States states )
2021-12-27 17:33:06 +01:00
{
if ( states != m_skinnable->skinStates() )
m_skinnable->replaceSkinStates( states );
2021-12-27 17:33:06 +01:00
}
2021-12-23 18:15:07 +01:00
#endif