platform depending code moved to QskSkin
This commit is contained in:
parent
7f63392eed
commit
cdb17476b5
@ -321,6 +321,16 @@ bool QskSkin::hasGraphicProvider() const
|
||||
return m_data->graphicProviders.size() > 0;
|
||||
}
|
||||
|
||||
QString QskSkin::dialogButtonText( int action ) const
|
||||
{
|
||||
const auto theme = QGuiApplicationPrivate::platformTheme();
|
||||
|
||||
auto text = theme->standardButtonText( action );
|
||||
text = QPlatformTheme::removeMnemonics( text );
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
const int* QskSkin::dialogButtonLayout( Qt::Orientation orientation ) const
|
||||
{
|
||||
// auto policy = QPlatformDialogHelper::UnknownLayout;
|
||||
|
@ -75,6 +75,7 @@ class QSK_EXPORT QskSkin : public QObject
|
||||
bool hasGraphicProvider() const;
|
||||
|
||||
virtual const int* dialogButtonLayout( Qt::Orientation ) const;
|
||||
virtual QString dialogButtonText( int button ) const;
|
||||
|
||||
void setStateMask( QskAspect::States );
|
||||
QskAspect::States stateMask() const;
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include <qpointer.h>
|
||||
#include <qquickwindow.h>
|
||||
|
||||
#include <qpa/qplatformdialoghelper.h>
|
||||
|
||||
static QskDialog::Action qskActionCandidate( const QskDialogButtonBox* buttonBox )
|
||||
{
|
||||
// not the fastest code ever, but usually we always
|
||||
@ -336,4 +338,12 @@ QString QskDialog::select(
|
||||
|
||||
}
|
||||
|
||||
QskDialog::ActionRole QskDialog::actionRole( Action action )
|
||||
{
|
||||
using Q = QPlatformDialogHelper;
|
||||
|
||||
const auto role = Q::buttonRole( static_cast< Q::StandardButton >( action ) );
|
||||
return static_cast< ActionRole >( role );
|
||||
}
|
||||
|
||||
#include "moc_QskDialog.cpp"
|
||||
|
@ -139,6 +139,8 @@ class QSK_EXPORT QskDialog : public QObject
|
||||
const QString& title, const QString& text,
|
||||
const QStringList& entries, int selectedRow = 0 ) const;
|
||||
|
||||
static ActionRole actionRole( Action action );
|
||||
|
||||
Q_SIGNALS:
|
||||
void transientParentChanged();
|
||||
void policyChanged();
|
||||
|
@ -5,17 +5,27 @@
|
||||
|
||||
#include "QskDialogButton.h"
|
||||
#include "QskDialogButtonBox.h"
|
||||
#include "QskSkin.h"
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
QskDialogButton::QskDialogButton(
|
||||
QskDialog::Action action, QQuickItem* parent )
|
||||
: QskPushButton( parent )
|
||||
, m_action( action )
|
||||
{
|
||||
setText( QskDialogButtonBox::buttonText( m_action ) );
|
||||
setText( qskButtonText( this, m_action ) );
|
||||
}
|
||||
|
||||
QskDialogButton::QskDialogButton( QQuickItem* parent )
|
||||
@ -47,7 +57,7 @@ void QskDialogButton::setAction( QskDialog::Action action )
|
||||
if ( action != m_action )
|
||||
{
|
||||
m_action = action;
|
||||
setText( QskDialogButtonBox::buttonText( m_action ) );
|
||||
setText( qskButtonText( this, action ) );
|
||||
|
||||
Q_EMIT actionChanged();
|
||||
}
|
||||
@ -60,8 +70,12 @@ QskDialog::Action QskDialogButton::action() const
|
||||
|
||||
void QskDialogButton::changeEvent( QEvent* event )
|
||||
{
|
||||
if ( event->type() == QEvent::LocaleChange )
|
||||
setText( QskDialogButtonBox::buttonText( m_action ) );
|
||||
switch( static_cast< int >( event->type() ) )
|
||||
{
|
||||
case QEvent::LocaleChange:
|
||||
case QEvent::StyleChange:
|
||||
setText( qskButtonText( this, m_action ) );
|
||||
}
|
||||
|
||||
Inherited::changeEvent( event );
|
||||
}
|
||||
|
@ -15,11 +15,6 @@
|
||||
#include <qvector.h>
|
||||
|
||||
#include <qpa/qplatformdialoghelper.h>
|
||||
#include <qpa/qplatformtheme.h>
|
||||
|
||||
QSK_QT_PRIVATE_BEGIN
|
||||
#include <private/qguiapplication_p.h>
|
||||
QSK_QT_PRIVATE_END
|
||||
|
||||
#include <limits>
|
||||
|
||||
@ -31,14 +26,6 @@ static void qskSendEventTo( QObject* object, QEvent::Type type )
|
||||
QCoreApplication::sendEvent( object, &event );
|
||||
}
|
||||
|
||||
static inline QskDialog::ActionRole qskActionRole( QskDialog::Action action )
|
||||
{
|
||||
const auto role = QPlatformDialogHelper::buttonRole(
|
||||
static_cast< QPlatformDialogHelper::StandardButton >( action ) );
|
||||
|
||||
return static_cast< QskDialog::ActionRole >( role );
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
class LayoutEngine : public QskLinearLayoutEngine
|
||||
@ -346,9 +333,8 @@ void QskDialogButtonBox::addButton(
|
||||
|
||||
void QskDialogButtonBox::addAction( QskDialog::Action action )
|
||||
{
|
||||
QskPushButton* button = createButton( action );
|
||||
if ( button )
|
||||
addButton( button, qskActionRole( action ) );
|
||||
if ( auto button = createButton( action ) )
|
||||
addButton( button, QskDialog::actionRole( action ) );
|
||||
}
|
||||
|
||||
void QskDialogButtonBox::removeButton( QskPushButton* button )
|
||||
@ -591,15 +577,4 @@ bool QskDialogButtonBox::isDefaultButtonKeyEvent( const QKeyEvent* event )
|
||||
}
|
||||
}
|
||||
|
||||
QString QskDialogButtonBox::buttonText( QskDialog::Action action )
|
||||
{
|
||||
// should be redirected through the skin !
|
||||
|
||||
const auto theme = QGuiApplicationPrivate::platformTheme();
|
||||
QString text = theme->standardButtonText( action );
|
||||
text = QPlatformTheme::removeMnemonics( text );
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
#include "moc_QskDialogButtonBox.cpp"
|
||||
|
@ -61,7 +61,6 @@ class QSK_EXPORT QskDialogButtonBox : public QskBox
|
||||
QskPushButton* defaultButton() const;
|
||||
|
||||
static bool isDefaultButtonKeyEvent( const QKeyEvent* );
|
||||
static QString buttonText( QskDialog::Action );
|
||||
|
||||
Q_SIGNALS:
|
||||
void clicked( QskPushButton* button );
|
||||
|
Loading…
x
Reference in New Issue
Block a user