mirror of
https://github.com/OPM/ResInsight.git
synced 2026-09-03 20:53:13 -05:00
Clean up RiuWidgetStyleSheet and add more comments
This commit is contained in:
@@ -93,7 +93,7 @@ RiuWidgetStyleSheet::RiuWidgetStyleSheet()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
/// Set keys and values directly to the default state
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuWidgetStyleSheet::set( const QString& key, const QString& value )
|
void RiuWidgetStyleSheet::set( const QString& key, const QString& value )
|
||||||
{
|
{
|
||||||
@@ -101,7 +101,7 @@ void RiuWidgetStyleSheet::set( const QString& key, const QString& value )
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
/// Get values directly from the default state
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QString RiuWidgetStyleSheet::get( const QString& key ) const
|
QString RiuWidgetStyleSheet::get( const QString& key ) const
|
||||||
{
|
{
|
||||||
@@ -110,7 +110,7 @@ QString RiuWidgetStyleSheet::get( const QString& key ) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
/// Access a particular state in the stylesheet
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RiuWidgetStyleSheet::State& RiuWidgetStyleSheet::state( StateTag stateTag )
|
RiuWidgetStyleSheet::State& RiuWidgetStyleSheet::state( StateTag stateTag )
|
||||||
{
|
{
|
||||||
@@ -121,19 +121,7 @@ RiuWidgetStyleSheet::State& RiuWidgetStyleSheet::state( StateTag stateTag )
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
/// Apply the current stylesheet to the provided widget instance
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
QString RiuWidgetStyleSheet::propertyName( StateTag state )
|
|
||||||
{
|
|
||||||
if ( state < PSEUDO_STATE_LIMIT )
|
|
||||||
{
|
|
||||||
return StateTagEnum::text( state );
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuWidgetStyleSheet::applyToWidget( QWidget* widget ) const
|
void RiuWidgetStyleSheet::applyToWidget( QWidget* widget ) const
|
||||||
{
|
{
|
||||||
@@ -144,16 +132,7 @@ void RiuWidgetStyleSheet::applyToWidget( QWidget* widget ) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
/// Put the provided widget into the provided state
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RiuWidgetStyleSheet::refreshWidget( QWidget* widget ) const
|
|
||||||
{
|
|
||||||
widget->style()->unpolish( widget );
|
|
||||||
widget->style()->polish( widget );
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuWidgetStyleSheet::setWidgetState( QWidget* widget, StateTag widgetState ) const
|
void RiuWidgetStyleSheet::setWidgetState( QWidget* widget, StateTag widgetState ) const
|
||||||
{
|
{
|
||||||
@@ -187,6 +166,15 @@ QString RiuWidgetStyleSheet::fullText( const QString& className, const QString&
|
|||||||
return textForAllStates.join( "\n" );
|
return textForAllStates.join( "\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiuWidgetStyleSheet::refreshWidget( QWidget* widget ) const
|
||||||
|
{
|
||||||
|
widget->style()->unpolish( widget );
|
||||||
|
widget->style()->polish( widget );
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -203,3 +191,15 @@ QString RiuWidgetStyleSheet::buildStateString( StateTag state )
|
|||||||
}
|
}
|
||||||
return stateString;
|
return stateString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QString RiuWidgetStyleSheet::propertyName( StateTag state )
|
||||||
|
{
|
||||||
|
if ( state < PSEUDO_STATE_LIMIT )
|
||||||
|
{
|
||||||
|
return StateTagEnum::text( state );
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|||||||
@@ -37,12 +37,14 @@ public:
|
|||||||
enum StateTag
|
enum StateTag
|
||||||
{
|
{
|
||||||
DEFAULT = 0x0000,
|
DEFAULT = 0x0000,
|
||||||
// Dynamic Properties:
|
// Dynamic Properties (Applied to a widget using setWidgetState())
|
||||||
SELECTED = 0x0001,
|
SELECTED = 0x0001,
|
||||||
DRAG_TARGET_BEFORE = 0x0002,
|
DRAG_TARGET_BEFORE = 0x0002,
|
||||||
DRAG_TARGET_AFTER = 0x0004,
|
DRAG_TARGET_AFTER = 0x0004,
|
||||||
DRAG_TARGET_INTO = 0x0008,
|
DRAG_TARGET_INTO = 0x0008,
|
||||||
// Pseudo States:
|
// Pseudo States (Qt sets the widget into these states automatically)
|
||||||
|
// And we have no way of forcing the widget to be in this state.
|
||||||
|
// However we can define the look when the widget is in the state
|
||||||
PSEUDO_STATE_LIMIT = 0x1000,
|
PSEUDO_STATE_LIMIT = 0x1000,
|
||||||
HOVER = 0x1000
|
HOVER = 0x1000
|
||||||
};
|
};
|
||||||
@@ -54,6 +56,9 @@ public:
|
|||||||
State( const QString& stateString );
|
State( const QString& stateString );
|
||||||
void set( const QString& key, const QString& value );
|
void set( const QString& key, const QString& value );
|
||||||
QString get( const QString& key ) const;
|
QString get( const QString& key ) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class RiuWidgetStyleSheet;
|
||||||
QString fullText( const QString& className, const QString& objectName ) const;
|
QString fullText( const QString& className, const QString& objectName ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -69,8 +74,6 @@ public:
|
|||||||
|
|
||||||
State& state( StateTag stateTag );
|
State& state( StateTag stateTag );
|
||||||
|
|
||||||
static QString propertyName( StateTag stateTag );
|
|
||||||
|
|
||||||
void applyToWidget( QWidget* widget ) const;
|
void applyToWidget( QWidget* widget ) const;
|
||||||
void setWidgetState( QWidget* widget, StateTag widgetState ) const;
|
void setWidgetState( QWidget* widget, StateTag widgetState ) const;
|
||||||
|
|
||||||
@@ -80,6 +83,7 @@ private:
|
|||||||
|
|
||||||
void refreshWidget( QWidget* widget ) const;
|
void refreshWidget( QWidget* widget ) const;
|
||||||
static QString buildStateString( StateTag stateTag );
|
static QString buildStateString( StateTag stateTag );
|
||||||
|
static QString propertyName( StateTag stateTag );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<StateTag, State> m_states;
|
std::map<StateTag, State> m_states;
|
||||||
|
|||||||
Reference in New Issue
Block a user