qskinny/src/dialogs/QskDialogButton.cpp

84 lines
2.1 KiB
C++
Raw Normal View History

2017-07-21 16:21:34 +00:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
#include "QskDialogButton.h"
#include "QskDialogButtonBox.h"
#include "QskSkin.h"
2017-07-21 16:21:34 +00:00
QSK_SUBCONTROL( QskDialogButton, Panel )
QSK_SUBCONTROL( QskDialogButton, Text )
QSK_SUBCONTROL( QskDialogButton, Graphic )
static QString qskButtonText(
const QskDialogButton* button, QskDialog::Action action )
{
if ( const auto skin = button->effectiveSkin() )
return skin->dialogButtonText( action );
return QString();
}
2017-07-21 16:21:34 +00:00
QskDialogButton::QskDialogButton(
QskDialog::Action action, QQuickItem* parent )
2018-08-03 06:15:28 +00:00
: QskPushButton( parent )
, m_action( action )
2017-07-21 16:21:34 +00:00
{
setText( qskButtonText( this, m_action ) );
2017-07-21 16:21:34 +00:00
}
2018-08-03 06:15:28 +00:00
QskDialogButton::QskDialogButton( QQuickItem* parent )
: QskDialogButton( QskDialog::NoAction, parent )
2017-07-21 16:21:34 +00:00
{
}
QskDialogButton::~QskDialogButton()
{
}
QskAspect::Subcontrol QskDialogButton::substitutedSubcontrol(
2017-07-21 16:21:34 +00:00
QskAspect::Subcontrol subControl ) const
{
if ( subControl == QskPushButton::Panel )
return QskDialogButton::Panel;
if ( subControl == QskPushButton::Text )
return QskDialogButton::Text;
if ( subControl == QskPushButton::Graphic )
return QskDialogButton::Graphic;
return Inherited::substitutedSubcontrol( subControl );
2017-07-21 16:21:34 +00:00
}
void QskDialogButton::setAction( QskDialog::Action action )
2017-07-21 16:21:34 +00:00
{
if ( action != m_action )
2017-07-21 16:21:34 +00:00
{
m_action = action;
setText( qskButtonText( this, action ) );
2017-07-21 16:21:34 +00:00
Q_EMIT actionChanged();
2017-07-21 16:21:34 +00:00
}
}
QskDialog::Action QskDialogButton::action() const
2017-07-21 16:21:34 +00:00
{
return m_action;
2017-07-21 16:21:34 +00:00
}
void QskDialogButton::changeEvent( QEvent* event )
{
switch( static_cast< int >( event->type() ) )
{
case QEvent::LocaleChange:
case QEvent::StyleChange:
setText( qskButtonText( this, m_action ) );
}
2017-07-21 16:21:34 +00:00
Inherited::changeEvent( event );
}
#include "moc_QskDialogButton.cpp"