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"
|
2022-03-08 14:59:35 +00:00
|
|
|
#include "QskSkin.h"
|
2017-07-21 16:21:34 +00:00
|
|
|
|
|
|
|
QSK_SUBCONTROL( QskDialogButton, Panel )
|
|
|
|
QSK_SUBCONTROL( QskDialogButton, Text )
|
|
|
|
QSK_SUBCONTROL( QskDialogButton, Graphic )
|
|
|
|
|
2022-03-08 14:59:35 +00:00
|
|
|
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(
|
2018-11-05 12:29:52 +00:00
|
|
|
QskDialog::Action action, QQuickItem* parent )
|
2018-08-03 06:15:28 +00:00
|
|
|
: QskPushButton( parent )
|
2018-11-05 12:29:52 +00:00
|
|
|
, m_action( action )
|
2017-07-21 16:21:34 +00:00
|
|
|
{
|
2022-03-08 14:59:35 +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 )
|
2018-11-05 12:29:52 +00:00
|
|
|
: QskDialogButton( QskDialog::NoAction, parent )
|
2017-07-21 16:21:34 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
QskDialogButton::~QskDialogButton()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-08-04 13:06:04 +00:00
|
|
|
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;
|
|
|
|
|
2021-08-05 13:31:00 +00:00
|
|
|
return Inherited::substitutedSubcontrol( subControl );
|
2017-07-21 16:21:34 +00:00
|
|
|
}
|
|
|
|
|
2018-11-05 12:29:52 +00:00
|
|
|
void QskDialogButton::setAction( QskDialog::Action action )
|
2017-07-21 16:21:34 +00:00
|
|
|
{
|
2018-11-05 12:29:52 +00:00
|
|
|
if ( action != m_action )
|
2017-07-21 16:21:34 +00:00
|
|
|
{
|
2018-11-05 12:29:52 +00:00
|
|
|
m_action = action;
|
2022-03-08 14:59:35 +00:00
|
|
|
setText( qskButtonText( this, action ) );
|
2017-07-21 16:21:34 +00:00
|
|
|
|
2018-11-05 12:29:52 +00:00
|
|
|
Q_EMIT actionChanged();
|
2017-07-21 16:21:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-05 12:29:52 +00:00
|
|
|
QskDialog::Action QskDialogButton::action() const
|
2017-07-21 16:21:34 +00:00
|
|
|
{
|
2018-11-05 12:29:52 +00:00
|
|
|
return m_action;
|
2017-07-21 16:21:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void QskDialogButton::changeEvent( QEvent* event )
|
|
|
|
{
|
2022-03-08 14:59:35 +00:00
|
|
|
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"
|