QskDialog::StandardButton renamed to QskDialog::Action
This commit is contained in:
parent
11a4c79f0f
commit
b398d11310
|
|
@ -18,25 +18,20 @@ Window::Window( Qt::Orientation orientation )
|
||||||
m_layoutBox->setExtraSpacingAt( Qt::BottomEdge | Qt::RightEdge );
|
m_layoutBox->setExtraSpacingAt( Qt::BottomEdge | Qt::RightEdge );
|
||||||
|
|
||||||
addBox( QskDialog::Ok );
|
addBox( QskDialog::Ok );
|
||||||
|
addBox( QskDialog::Ok | QskDialog::Cancel );
|
||||||
addBox( QskDialog::StandardButtons( QskDialog::Ok | QskDialog::Cancel ) );
|
addBox( QskDialog::Yes | QskDialog::No );
|
||||||
|
addBox( QskDialog::Save | QskDialog::Discard |
|
||||||
addBox( QskDialog::StandardButtons( QskDialog::Yes | QskDialog::No ) );
|
QskDialog::RestoreDefaults | QskDialog::Help );
|
||||||
|
addBox( QskDialog::Abort | QskDialog::Retry | QskDialog::Ignore );
|
||||||
addBox( QskDialog::StandardButtons( QskDialog::Save | QskDialog::Discard
|
|
||||||
| QskDialog::RestoreDefaults | QskDialog::Help ) );
|
|
||||||
|
|
||||||
addBox( QskDialog::StandardButtons( QskDialog::Abort
|
|
||||||
| QskDialog::Retry | QskDialog::Ignore ) );
|
|
||||||
|
|
||||||
addActionBox();
|
addActionBox();
|
||||||
addItem( m_layoutBox );
|
addItem( m_layoutBox );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::addBox( QskDialog::StandardButtons standardButtons )
|
void Window::addBox( QskDialog::Actions actions )
|
||||||
{
|
{
|
||||||
QskDialogButtonBox* box = new QskDialogButtonBox( m_orientation );
|
QskDialogButtonBox* box = new QskDialogButtonBox( m_orientation );
|
||||||
box->setStandardButtons( standardButtons );
|
box->setActions( actions );
|
||||||
box->setObjectName( "DialogBox" );
|
box->setObjectName( "DialogBox" );
|
||||||
|
|
||||||
m_layoutBox->addItem( box );
|
m_layoutBox->addItem( box );
|
||||||
|
|
@ -48,9 +43,9 @@ void Window::addActionBox()
|
||||||
QskPushButton* centerButton = new QskPushButton( "Center" );
|
QskPushButton* centerButton = new QskPushButton( "Center" );
|
||||||
|
|
||||||
QskDialogButtonBox* box = new QskDialogButtonBox( m_orientation );
|
QskDialogButtonBox* box = new QskDialogButtonBox( m_orientation );
|
||||||
box->addButton( flipButton, QskDialog::ActionRole );
|
box->addButton( flipButton, QskDialog::UserRole );
|
||||||
box->addButton( centerButton, QskDialog::ActionRole );
|
box->addButton( centerButton, QskDialog::UserRole );
|
||||||
box->setObjectName( "ActionBox" );
|
box->setObjectName( "UserBox" );
|
||||||
|
|
||||||
m_layoutBox->addItem( box );
|
m_layoutBox->addItem( box );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ class Window : public QskWindow
|
||||||
void centerButtons();
|
void centerButtons();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addBox( QskDialog::StandardButtons );
|
void addBox( QskDialog::Actions );
|
||||||
void addActionBox();
|
void addActionBox();
|
||||||
|
|
||||||
QVector< QskDialogButtonBox* > dialogBoxes() const;
|
QVector< QskDialogButtonBox* > dialogBoxes() const;
|
||||||
|
|
|
||||||
|
|
@ -278,7 +278,7 @@ void QskQml::registerTypes()
|
||||||
QSK_REGISTER_FLAGS( QskSizePolicy::Policy );
|
QSK_REGISTER_FLAGS( QskSizePolicy::Policy );
|
||||||
QMetaType::registerConverter< int, QskSetupFlagsProvider >();
|
QMetaType::registerConverter< int, QskSetupFlagsProvider >();
|
||||||
|
|
||||||
QSK_REGISTER_FLAGS( QskDialog::StandardButtons );
|
QSK_REGISTER_FLAGS( QskDialog::Actions );
|
||||||
|
|
||||||
QSK_REGISTER_GADGET( QskRgbValue_Gadget, "RgbValue" );
|
QSK_REGISTER_GADGET( QskRgbValue_Gadget, "RgbValue" );
|
||||||
QSK_REGISTER_GADGET( QskStandardSymbol, "StandardSymbol" );
|
QSK_REGISTER_GADGET( QskStandardSymbol, "StandardSymbol" );
|
||||||
|
|
|
||||||
|
|
@ -49,33 +49,33 @@ static QQuickWindow* qskSomeQuickWindow()
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qskSetupSubWindow(
|
static void qskSetupSubWindow(
|
||||||
const QString& title, QskDialog::StandardButtons buttons,
|
const QString& title, QskDialog::Actions actions,
|
||||||
QskDialog::StandardButton defaultButton, QskInputSubWindow* subWindow )
|
QskDialog::Action defaultAction, QskInputSubWindow* subWindow )
|
||||||
{
|
{
|
||||||
subWindow->setModal( true );
|
subWindow->setModal( true );
|
||||||
subWindow->setWindowTitle( title );
|
subWindow->setWindowTitle( title );
|
||||||
subWindow->setStandardButtons( buttons );
|
subWindow->setActions( actions );
|
||||||
|
|
||||||
if ( defaultButton == QskDialog::NoButton )
|
if ( defaultAction == QskDialog::NoAction )
|
||||||
defaultButton = subWindow->buttonBox()->defaultButtonCandidate();
|
defaultAction = subWindow->buttonBox()->defaultActionCandidate();
|
||||||
|
|
||||||
subWindow->setDefaultButton( defaultButton );
|
subWindow->setDefaultAction( defaultAction );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qskSetupWindow(
|
static void qskSetupWindow(
|
||||||
QWindow* transientParent, const QString& title,
|
QWindow* transientParent, const QString& title,
|
||||||
QskDialog::StandardButtons buttons, QskDialog::StandardButton defaultButton,
|
QskDialog::Actions actions, QskDialog::Action defaultAction,
|
||||||
QskInputWindow* window )
|
QskInputWindow* window )
|
||||||
{
|
{
|
||||||
window->setTransientParent( transientParent );
|
window->setTransientParent( transientParent );
|
||||||
|
|
||||||
window->setTitle( title );
|
window->setTitle( title );
|
||||||
window->setStandardButtons( buttons );
|
window->setActions( actions );
|
||||||
|
|
||||||
if ( defaultButton == QskDialog::NoButton )
|
if ( defaultAction == QskDialog::NoAction )
|
||||||
defaultButton = window->buttonBox()->defaultButtonCandidate();
|
defaultAction = window->buttonBox()->defaultActionCandidate();
|
||||||
|
|
||||||
window->setDefaultButton( defaultButton );
|
window->setDefaultAction( defaultAction );
|
||||||
|
|
||||||
window->setModality( transientParent ? Qt::WindowModal : Qt::ApplicationModal );
|
window->setModality( transientParent ? Qt::WindowModal : Qt::ApplicationModal );
|
||||||
|
|
||||||
|
|
@ -98,53 +98,53 @@ static void qskSetupWindow(
|
||||||
window->setModality( Qt::ApplicationModal );
|
window->setModality( Qt::ApplicationModal );
|
||||||
}
|
}
|
||||||
|
|
||||||
static QskDialog::StandardButton qskMessageSubWindow(
|
static QskDialog::Action qskMessageSubWindow(
|
||||||
QQuickWindow* window, const QString& title,
|
QQuickWindow* window, const QString& title,
|
||||||
const QString& text, int symbolType, QskDialog::StandardButtons buttons,
|
const QString& text, int symbolType, QskDialog::Actions actions,
|
||||||
QskDialog::StandardButton defaultButton )
|
QskDialog::Action defaultAction )
|
||||||
{
|
{
|
||||||
QskMessageSubWindow subWindow( window->contentItem() );
|
QskMessageSubWindow subWindow( window->contentItem() );
|
||||||
subWindow.setSymbolType( symbolType );
|
subWindow.setSymbolType( symbolType );
|
||||||
subWindow.setInfoText( text );
|
subWindow.setInfoText( text );
|
||||||
|
|
||||||
qskSetupSubWindow( title, buttons, defaultButton, &subWindow );
|
qskSetupSubWindow( title, actions, defaultAction, &subWindow );
|
||||||
( void ) subWindow.exec();
|
( void ) subWindow.exec();
|
||||||
|
|
||||||
QskDialog::StandardButton clickedButton = subWindow.clickedButton();
|
auto clickedAction = subWindow.clickedAction();
|
||||||
if ( clickedButton == QskDialog::NoButton )
|
if ( clickedAction == QskDialog::NoAction )
|
||||||
{
|
{
|
||||||
// dialog might have been closed by the window menu
|
// dialog might have been closed by the window menu
|
||||||
clickedButton = QskDialog::Cancel;
|
clickedAction = QskDialog::Cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
return clickedButton;
|
return clickedAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QskDialog::StandardButton qskMessageWindow(
|
static QskDialog::Action qskMessageWindow(
|
||||||
QWindow* transientParent, const QString& title,
|
QWindow* transientParent, const QString& title,
|
||||||
const QString& text, int symbolType, QskDialog::StandardButtons buttons,
|
const QString& text, int symbolType, QskDialog::Actions actions,
|
||||||
QskDialog::StandardButton defaultButton )
|
QskDialog::Action defaultAction )
|
||||||
{
|
{
|
||||||
QskMessageWindow messageWindow;
|
QskMessageWindow messageWindow;
|
||||||
messageWindow.setSymbolType( symbolType );
|
messageWindow.setSymbolType( symbolType );
|
||||||
messageWindow.setInfoText( text );
|
messageWindow.setInfoText( text );
|
||||||
|
|
||||||
qskSetupWindow( transientParent, title, buttons, defaultButton, &messageWindow );
|
qskSetupWindow( transientParent, title, actions, defaultAction, &messageWindow );
|
||||||
( void ) qskExec( &messageWindow );
|
( void ) qskExec( &messageWindow );
|
||||||
|
|
||||||
QskDialog::StandardButton clickedButton = messageWindow.clickedButton();
|
auto clickedAction = messageWindow.clickedAction();
|
||||||
if ( clickedButton == QskDialog::NoButton )
|
if ( clickedAction == QskDialog::NoAction )
|
||||||
{
|
{
|
||||||
// dialog might have been closed by the window menu
|
// dialog might have been closed by the window menu
|
||||||
clickedButton = QskDialog::Cancel;
|
clickedAction = QskDialog::Cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
return clickedButton;
|
return clickedAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString qskSelectSubWindow(
|
static QString qskSelectSubWindow(
|
||||||
QQuickWindow* window, const QString& title, const QString& text,
|
QQuickWindow* window, const QString& title, const QString& text,
|
||||||
QskDialog::StandardButtons buttons, QskDialog::StandardButton defaultButton,
|
QskDialog::Actions actions, QskDialog::Action defaultAction,
|
||||||
const QStringList& entries, int selectedRow )
|
const QStringList& entries, int selectedRow )
|
||||||
{
|
{
|
||||||
QskSelectionSubWindow subWindow( window->contentItem() );
|
QskSelectionSubWindow subWindow( window->contentItem() );
|
||||||
|
|
@ -154,7 +154,7 @@ static QString qskSelectSubWindow(
|
||||||
|
|
||||||
QString selectedEntry = subWindow.selectedEntry();
|
QString selectedEntry = subWindow.selectedEntry();
|
||||||
|
|
||||||
qskSetupSubWindow( title, buttons, defaultButton, &subWindow );
|
qskSetupSubWindow( title, actions, defaultAction, &subWindow );
|
||||||
if ( subWindow.exec() == QskDialog::Accepted )
|
if ( subWindow.exec() == QskDialog::Accepted )
|
||||||
selectedEntry = subWindow.selectedEntry();
|
selectedEntry = subWindow.selectedEntry();
|
||||||
|
|
||||||
|
|
@ -163,7 +163,7 @@ static QString qskSelectSubWindow(
|
||||||
|
|
||||||
static QString qskSelectWindow(
|
static QString qskSelectWindow(
|
||||||
QWindow* transientParent, const QString& title, const QString& text,
|
QWindow* transientParent, const QString& title, const QString& text,
|
||||||
QskDialog::StandardButtons buttons, QskDialog::StandardButton defaultButton,
|
QskDialog::Actions actions, QskDialog::Action defaultAction,
|
||||||
const QStringList& entries, int selectedRow )
|
const QStringList& entries, int selectedRow )
|
||||||
{
|
{
|
||||||
QskSelectionWindow window;
|
QskSelectionWindow window;
|
||||||
|
|
@ -173,7 +173,7 @@ static QString qskSelectWindow(
|
||||||
|
|
||||||
QString selectedEntry = window.selectedEntry();
|
QString selectedEntry = window.selectedEntry();
|
||||||
|
|
||||||
qskSetupWindow( transientParent, title, buttons, defaultButton, &window );
|
qskSetupWindow( transientParent, title, actions, defaultAction, &window );
|
||||||
if ( qskExec( &window ) == QskDialog::Accepted )
|
if ( qskExec( &window ) == QskDialog::Accepted )
|
||||||
selectedEntry = window.selectedEntry();
|
selectedEntry = window.selectedEntry();
|
||||||
|
|
||||||
|
|
@ -238,9 +238,9 @@ QWindow* QskDialog::transientParent() const
|
||||||
return m_data->transientParent;
|
return m_data->transientParent;
|
||||||
}
|
}
|
||||||
|
|
||||||
QskDialog::StandardButton QskDialog::message(
|
QskDialog::Action QskDialog::message(
|
||||||
const QString& title, const QString& text, int symbolType,
|
const QString& title, const QString& text, int symbolType,
|
||||||
StandardButtons buttons, StandardButton defaultButton ) const
|
Actions actions, Action defaultAction ) const
|
||||||
{
|
{
|
||||||
if ( m_data->policy == EmbeddedBox )
|
if ( m_data->policy == EmbeddedBox )
|
||||||
{
|
{
|
||||||
|
|
@ -252,44 +252,44 @@ QskDialog::StandardButton QskDialog::message(
|
||||||
if ( quickWindow )
|
if ( quickWindow )
|
||||||
{
|
{
|
||||||
return qskMessageSubWindow( quickWindow,
|
return qskMessageSubWindow( quickWindow,
|
||||||
title, text, symbolType, buttons, defaultButton );
|
title, text, symbolType, actions, defaultAction );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return qskMessageWindow( m_data->transientParent,
|
return qskMessageWindow( m_data->transientParent,
|
||||||
title, text, symbolType, buttons, defaultButton );
|
title, text, symbolType, actions, defaultAction );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskDialog::StandardButton QskDialog::information(
|
QskDialog::Action QskDialog::information(
|
||||||
const QString& title, const QString& text,
|
const QString& title, const QString& text,
|
||||||
StandardButtons buttons, StandardButton defaultButton ) const
|
Actions actions, Action defaultAction ) const
|
||||||
{
|
{
|
||||||
return QskDialog::message( title, text,
|
return QskDialog::message( title, text,
|
||||||
QskStandardSymbol::Information, buttons, defaultButton );
|
QskStandardSymbol::Information, actions, defaultAction );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskDialog::StandardButton QskDialog::warning(
|
QskDialog::Action QskDialog::warning(
|
||||||
const QString& title, const QString& text,
|
const QString& title, const QString& text,
|
||||||
StandardButtons buttons, StandardButton defaultButton ) const
|
Actions actions, Action defaultAction ) const
|
||||||
{
|
{
|
||||||
return QskDialog::message( title, text,
|
return QskDialog::message( title, text,
|
||||||
QskStandardSymbol::Warning, buttons, defaultButton );
|
QskStandardSymbol::Warning, actions, defaultAction );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskDialog::StandardButton QskDialog::critical(
|
QskDialog::Action QskDialog::critical(
|
||||||
const QString& title, const QString& text,
|
const QString& title, const QString& text,
|
||||||
StandardButtons buttons, StandardButton defaultButton ) const
|
Actions actions, Action defaultAction ) const
|
||||||
{
|
{
|
||||||
return QskDialog::message( title, text,
|
return QskDialog::message( title, text,
|
||||||
QskStandardSymbol::Critical, buttons, defaultButton );
|
QskStandardSymbol::Critical, actions, defaultAction );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskDialog::StandardButton QskDialog::question(
|
QskDialog::Action QskDialog::question(
|
||||||
const QString& title, const QString& text,
|
const QString& title, const QString& text,
|
||||||
StandardButtons buttons, StandardButton defaultButton ) const
|
Actions actions, Action defaultAction ) const
|
||||||
{
|
{
|
||||||
return QskDialog::message( title, text,
|
return QskDialog::message( title, text,
|
||||||
QskStandardSymbol::Question, buttons, defaultButton );
|
QskStandardSymbol::Question, actions, defaultAction );
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QskDialog::select(
|
QString QskDialog::select(
|
||||||
|
|
@ -298,8 +298,8 @@ QString QskDialog::select(
|
||||||
{
|
{
|
||||||
#if 1
|
#if 1
|
||||||
// should be parameters
|
// should be parameters
|
||||||
const QskDialog::StandardButtons buttons( QskDialog::Ok | QskDialog::Cancel );
|
const QskDialog::Actions actions( QskDialog::Ok | QskDialog::Cancel );
|
||||||
const QskDialog::StandardButton defaultButton = QskDialog::Ok;
|
const QskDialog::Action defaultAction = QskDialog::Ok;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( m_data->policy == EmbeddedBox )
|
if ( m_data->policy == EmbeddedBox )
|
||||||
|
|
@ -312,12 +312,12 @@ QString QskDialog::select(
|
||||||
if ( quickWindow )
|
if ( quickWindow )
|
||||||
{
|
{
|
||||||
return qskSelectSubWindow( quickWindow,
|
return qskSelectSubWindow( quickWindow,
|
||||||
title, text, buttons, defaultButton, entries, selectedRow );
|
title, text, actions, defaultAction, entries, selectedRow );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return qskSelectWindow( m_data->transientParent, title, text,
|
return qskSelectWindow( m_data->transientParent, title, text,
|
||||||
buttons, defaultButton, entries, selectedRow );
|
actions, defaultAction, entries, selectedRow );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,58 +39,62 @@ class QSK_EXPORT QskDialog : public QObject
|
||||||
TopLevelWindow
|
TopLevelWindow
|
||||||
};
|
};
|
||||||
|
|
||||||
enum StandardButton
|
Q_ENUM( Policy )
|
||||||
|
|
||||||
|
// a.k.a QMessageBox::StandardButton or QPlatformDialogHelper::StandardButton
|
||||||
|
enum Action
|
||||||
{
|
{
|
||||||
NoButton = 0x00000000,
|
NoAction = 0,
|
||||||
Ok = 0x00000400,
|
Ok = 1 << 10,
|
||||||
Save = 0x00000800,
|
Save = 1 << 11,
|
||||||
SaveAll = 0x00001000,
|
SaveAll = 1 << 12,
|
||||||
Open = 0x00002000,
|
Open = 1 << 13,
|
||||||
Yes = 0x00004000,
|
Yes = 1 << 14,
|
||||||
YesToAll = 0x00008000,
|
YesToAll = 1 << 15,
|
||||||
No = 0x00010000,
|
No = 1 << 16,
|
||||||
NoToAll = 0x00020000,
|
NoToAll = 1 << 17,
|
||||||
Abort = 0x00040000,
|
Abort = 1 << 18,
|
||||||
Retry = 0x00080000,
|
Retry = 1 << 19,
|
||||||
Ignore = 0x00100000,
|
Ignore = 1 << 20,
|
||||||
Close = 0x00200000,
|
Close = 1 << 21,
|
||||||
Cancel = 0x00400000,
|
Cancel = 1 << 22,
|
||||||
Discard = 0x00800000,
|
Discard = 1 << 23,
|
||||||
Help = 0x01000000,
|
Help = 1 << 24,
|
||||||
Apply = 0x02000000,
|
Apply = 1 << 25,
|
||||||
Reset = 0x04000000,
|
Reset = 1 << 26,
|
||||||
RestoreDefaults = 0x08000000,
|
RestoreDefaults = 1 << 27
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ButtonRole
|
Q_ENUM( Action )
|
||||||
|
Q_DECLARE_FLAGS( Actions, Action )
|
||||||
|
|
||||||
|
// a.k.a QMessageBox::ButtonRole
|
||||||
|
enum ActionRole
|
||||||
{
|
{
|
||||||
InvalidRole = -1,
|
InvalidRole = -1,
|
||||||
|
|
||||||
AcceptRole,
|
AcceptRole,
|
||||||
RejectRole,
|
RejectRole,
|
||||||
DestructiveRole,
|
DestructiveRole,
|
||||||
ActionRole,
|
UserRole,
|
||||||
HelpRole,
|
HelpRole,
|
||||||
YesRole,
|
YesRole,
|
||||||
NoRole,
|
NoRole,
|
||||||
ResetRole,
|
ResetRole,
|
||||||
ApplyRole,
|
ApplyRole,
|
||||||
|
|
||||||
NButtonRoles
|
NActionRoles
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Q_ENUM( ActionRole )
|
||||||
|
|
||||||
enum DialogCode
|
enum DialogCode
|
||||||
{
|
{
|
||||||
Rejected = 0,
|
Rejected = 0,
|
||||||
Accepted
|
Accepted
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_ENUM( Policy )
|
|
||||||
Q_ENUM( DialogCode )
|
Q_ENUM( DialogCode )
|
||||||
Q_ENUM( ButtonRole )
|
|
||||||
Q_ENUM( StandardButton )
|
|
||||||
|
|
||||||
Q_DECLARE_FLAGS( StandardButtons, StandardButton )
|
|
||||||
|
|
||||||
static QskDialog* instance();
|
static QskDialog* instance();
|
||||||
|
|
||||||
|
|
@ -100,29 +104,26 @@ class QSK_EXPORT QskDialog : public QObject
|
||||||
Q_INVOKABLE void setTransientParent( QWindow* );
|
Q_INVOKABLE void setTransientParent( QWindow* );
|
||||||
Q_INVOKABLE QWindow* transientParent() const;
|
Q_INVOKABLE QWindow* transientParent() const;
|
||||||
|
|
||||||
Q_INVOKABLE StandardButton message(
|
Q_INVOKABLE Action message(
|
||||||
const QString& title, const QString& text,
|
const QString& title, const QString& text, int symbolType,
|
||||||
int symbolType, StandardButtons buttons = Ok,
|
Actions actions = Ok, Action defaultAction = NoAction ) const;
|
||||||
StandardButton defaultButton = NoButton
|
|
||||||
) const;
|
|
||||||
|
|
||||||
Q_INVOKABLE StandardButton information(
|
Q_INVOKABLE Action information(
|
||||||
const QString& title, const QString& text,
|
const QString& title, const QString& text,
|
||||||
StandardButtons buttons = Ok,
|
Actions actions = Ok, Action defaultAction = NoAction ) const;
|
||||||
StandardButton defaultButton = NoButton
|
|
||||||
) const;
|
|
||||||
|
|
||||||
Q_INVOKABLE StandardButton warning(
|
Q_INVOKABLE Action warning(
|
||||||
const QString& title, const QString& text,
|
const QString& title, const QString& text,
|
||||||
StandardButtons buttons = Ok, StandardButton = NoButton ) const;
|
Actions actions = Ok, Action defaultAction = NoAction ) const;
|
||||||
|
|
||||||
Q_INVOKABLE StandardButton critical(
|
Q_INVOKABLE Action critical(
|
||||||
const QString& title, const QString& text,
|
const QString& title, const QString& text,
|
||||||
StandardButtons buttons = Ok, StandardButton = NoButton ) const;
|
Actions actions = Ok, Action defaultAction = NoAction ) const;
|
||||||
|
|
||||||
Q_INVOKABLE StandardButton question(
|
Q_INVOKABLE Action question(
|
||||||
const QString& title, const QString& text,
|
const QString& title, const QString& text,
|
||||||
StandardButtons = StandardButtons( Yes | No ), StandardButton = NoButton ) const;
|
Actions actions = Actions( Yes | No ),
|
||||||
|
Action defaultAction = NoAction ) const;
|
||||||
|
|
||||||
Q_INVOKABLE QString select(
|
Q_INVOKABLE QString select(
|
||||||
const QString& title, const QString& text,
|
const QString& title, const QString& text,
|
||||||
|
|
@ -142,8 +143,8 @@ class QSK_EXPORT QskDialog : public QObject
|
||||||
std::unique_ptr< PrivateData > m_data;
|
std::unique_ptr< PrivateData > m_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE( QskDialog::StandardButton )
|
Q_DECLARE_METATYPE( QskDialog::Action )
|
||||||
Q_DECLARE_METATYPE( QskDialog::StandardButtons )
|
Q_DECLARE_METATYPE( QskDialog::Actions )
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QskDialog::StandardButtons )
|
Q_DECLARE_OPERATORS_FOR_FLAGS( QskDialog::Actions )
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -11,15 +11,15 @@ QSK_SUBCONTROL( QskDialogButton, Text )
|
||||||
QSK_SUBCONTROL( QskDialogButton, Graphic )
|
QSK_SUBCONTROL( QskDialogButton, Graphic )
|
||||||
|
|
||||||
QskDialogButton::QskDialogButton(
|
QskDialogButton::QskDialogButton(
|
||||||
QskDialog::StandardButton standardButton, QQuickItem* parent )
|
QskDialog::Action action, QQuickItem* parent )
|
||||||
: QskPushButton( parent )
|
: QskPushButton( parent )
|
||||||
, m_buttonType( standardButton )
|
, m_action( action )
|
||||||
{
|
{
|
||||||
setText( QskDialogButtonBox::buttonText( m_buttonType ) );
|
setText( QskDialogButtonBox::buttonText( m_action ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskDialogButton::QskDialogButton( QQuickItem* parent )
|
QskDialogButton::QskDialogButton( QQuickItem* parent )
|
||||||
: QskDialogButton( QskDialog::NoButton, parent )
|
: QskDialogButton( QskDialog::NoAction, parent )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -42,26 +42,26 @@ QskAspect::Subcontrol QskDialogButton::effectiveSubcontrol(
|
||||||
return Inherited::effectiveSubcontrol( subControl );
|
return Inherited::effectiveSubcontrol( subControl );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskDialogButton::setStandardButton( QskDialog::StandardButton button )
|
void QskDialogButton::setAction( QskDialog::Action action )
|
||||||
{
|
{
|
||||||
if ( button != m_buttonType )
|
if ( action != m_action )
|
||||||
{
|
{
|
||||||
m_buttonType = button;
|
m_action = action;
|
||||||
setText( QskDialogButtonBox::buttonText( m_buttonType ) );
|
setText( QskDialogButtonBox::buttonText( m_action ) );
|
||||||
|
|
||||||
Q_EMIT standardButtonChanged();
|
Q_EMIT actionChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QskDialog::StandardButton QskDialogButton::standardButton() const
|
QskDialog::Action QskDialogButton::action() const
|
||||||
{
|
{
|
||||||
return m_buttonType;
|
return m_action;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskDialogButton::changeEvent( QEvent* event )
|
void QskDialogButton::changeEvent( QEvent* event )
|
||||||
{
|
{
|
||||||
if ( event->type() == QEvent::LocaleChange )
|
if ( event->type() == QEvent::LocaleChange )
|
||||||
setText( QskDialogButtonBox::buttonText( m_buttonType ) );
|
setText( QskDialogButtonBox::buttonText( m_action ) );
|
||||||
|
|
||||||
Inherited::changeEvent( event );
|
Inherited::changeEvent( event );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,33 +13,33 @@ class QSK_EXPORT QskDialogButton : public QskPushButton
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY( QskDialog::StandardButton standardButton READ standardButton()
|
Q_PROPERTY( QskDialog::Action action READ action()
|
||||||
WRITE setStandardButton NOTIFY standardButtonChanged() FINAL )
|
WRITE setAction NOTIFY actionChanged() FINAL )
|
||||||
|
|
||||||
using Inherited = QskPushButton;
|
using Inherited = QskPushButton;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QSK_SUBCONTROLS( Panel, Text, Graphic )
|
QSK_SUBCONTROLS( Panel, Text, Graphic )
|
||||||
|
|
||||||
QskDialogButton( QskDialog::StandardButton, QQuickItem* parent = nullptr );
|
QskDialogButton( QskDialog::Action, QQuickItem* parent = nullptr );
|
||||||
QskDialogButton( QQuickItem* parent = nullptr );
|
QskDialogButton( QQuickItem* parent = nullptr );
|
||||||
|
|
||||||
~QskDialogButton() override;
|
~QskDialogButton() override;
|
||||||
|
|
||||||
void setStandardButton( QskDialog::StandardButton );
|
void setAction( QskDialog::Action );
|
||||||
QskDialog::StandardButton standardButton() const;
|
QskDialog::Action action() const;
|
||||||
|
|
||||||
QskAspect::Subcontrol effectiveSubcontrol(
|
QskAspect::Subcontrol effectiveSubcontrol(
|
||||||
QskAspect::Subcontrol ) const override;
|
QskAspect::Subcontrol ) const override;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void standardButtonChanged();
|
void actionChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void changeEvent( QEvent* ) override;
|
void changeEvent( QEvent* ) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QskDialog::StandardButton m_buttonType;
|
QskDialog::Action m_action;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -25,13 +25,12 @@ static void qskSendEventTo( QObject* object, QEvent::Type type )
|
||||||
QCoreApplication::sendEvent( object, &event );
|
QCoreApplication::sendEvent( object, &event );
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline QskDialog::ButtonRole qskButtonRole(
|
static inline QskDialog::ActionRole qskActionRole( QskDialog::Action action )
|
||||||
QskDialog::StandardButton standardButton )
|
|
||||||
{
|
{
|
||||||
const auto role = QPlatformDialogHelper::buttonRole(
|
const auto role = QPlatformDialogHelper::buttonRole(
|
||||||
static_cast< QPlatformDialogHelper::StandardButton >( standardButton ) );
|
static_cast< QPlatformDialogHelper::StandardButton >( action ) );
|
||||||
|
|
||||||
return static_cast< QskDialog::ButtonRole >( role );
|
return static_cast< QskDialog::ActionRole >( role );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qskAddToLayout( const QVector< QskPushButton* >& buttons,
|
static void qskAddToLayout( const QVector< QskPushButton* >& buttons,
|
||||||
|
|
@ -59,9 +58,9 @@ class QskDialogButtonBox::PrivateData
|
||||||
}
|
}
|
||||||
|
|
||||||
QskLinearBox* layoutBox = nullptr;
|
QskLinearBox* layoutBox = nullptr;
|
||||||
QVector< QskPushButton* > buttons[ QskDialog::NButtonRoles ];
|
QVector< QskPushButton* > buttons[ QskDialog::NActionRoles ];
|
||||||
|
|
||||||
QskDialog::StandardButton clickedButton = QskDialog::NoButton;
|
QskDialog::Action clickedAction = QskDialog::NoAction;
|
||||||
|
|
||||||
bool centeredButtons : 1;
|
bool centeredButtons : 1;
|
||||||
bool dirtyLayout : 1;
|
bool dirtyLayout : 1;
|
||||||
|
|
@ -245,9 +244,10 @@ bool QskDialogButtonBox::centeredButtons() const
|
||||||
return m_data->centeredButtons;
|
return m_data->centeredButtons;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskDialogButtonBox::addButton( QskPushButton* button, QskDialog::ButtonRole role )
|
void QskDialogButtonBox::addButton(
|
||||||
|
QskPushButton* button, QskDialog::ActionRole role )
|
||||||
{
|
{
|
||||||
if ( role < 0 || role >= QskDialog::NButtonRoles )
|
if ( role < 0 || role >= QskDialog::NActionRoles )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( button )
|
if ( button )
|
||||||
|
|
@ -263,11 +263,11 @@ void QskDialogButtonBox::addButton( QskPushButton* button, QskDialog::ButtonRole
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskDialogButtonBox::addButton( QskDialog::StandardButton standardButton )
|
void QskDialogButtonBox::addButton( QskDialog::Action action )
|
||||||
{
|
{
|
||||||
QskPushButton* button = createButton( standardButton );
|
QskPushButton* button = createButton( action );
|
||||||
if ( button )
|
if ( button )
|
||||||
addButton( button, qskButtonRole( standardButton ) );
|
addButton( button, qskActionRole( action ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskDialogButtonBox::removeButton( QskPushButton* button )
|
void QskDialogButtonBox::removeButton( QskPushButton* button )
|
||||||
|
|
@ -277,7 +277,7 @@ void QskDialogButtonBox::removeButton( QskPushButton* button )
|
||||||
if ( button == nullptr )
|
if ( button == nullptr )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for ( int i = 0; i < QskDialog::NButtonRoles; i++ )
|
for ( int i = 0; i < QskDialog::NActionRoles; i++ )
|
||||||
{
|
{
|
||||||
auto& buttons = m_data->buttons[ i ];
|
auto& buttons = m_data->buttons[ i ];
|
||||||
if ( buttons.removeOne( button ) )
|
if ( buttons.removeOne( button ) )
|
||||||
|
|
@ -292,14 +292,14 @@ void QskDialogButtonBox::removeButton( QskPushButton* button )
|
||||||
}
|
}
|
||||||
|
|
||||||
QskPushButton* QskDialogButtonBox::createButton(
|
QskPushButton* QskDialogButtonBox::createButton(
|
||||||
QskDialog::StandardButton standardButton ) const
|
QskDialog::Action action ) const
|
||||||
{
|
{
|
||||||
return new QskDialogButton( standardButton );
|
return new QskDialogButton( action );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskDialogButtonBox::clear()
|
void QskDialogButtonBox::clear()
|
||||||
{
|
{
|
||||||
for ( int i = 0; i < QskDialog::NButtonRoles; i++ )
|
for ( int i = 0; i < QskDialog::NActionRoles; i++ )
|
||||||
{
|
{
|
||||||
qDeleteAll( m_data->buttons[ i ] );
|
qDeleteAll( m_data->buttons[ i ] );
|
||||||
m_data->buttons[ i ].clear();
|
m_data->buttons[ i ].clear();
|
||||||
|
|
@ -308,9 +308,9 @@ void QskDialogButtonBox::clear()
|
||||||
invalidateLayout();
|
invalidateLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskDialogButtonBox::setStandardButtons( QskDialog::StandardButtons standardButton )
|
void QskDialogButtonBox::setActions( QskDialog::Actions actions )
|
||||||
{
|
{
|
||||||
for ( int i = 0; i < QskDialog::NButtonRoles; i++ )
|
for ( int i = 0; i < QskDialog::NActionRoles; i++ )
|
||||||
{
|
{
|
||||||
qDeleteAll( m_data->buttons[ i ] );
|
qDeleteAll( m_data->buttons[ i ] );
|
||||||
m_data->buttons[ i ].clear();
|
m_data->buttons[ i ].clear();
|
||||||
|
|
@ -318,9 +318,9 @@ void QskDialogButtonBox::setStandardButtons( QskDialog::StandardButtons standard
|
||||||
|
|
||||||
for ( int i = QskDialog::Ok; i <= QskDialog::RestoreDefaults; i <<= 1 )
|
for ( int i = QskDialog::Ok; i <= QskDialog::RestoreDefaults; i <<= 1 )
|
||||||
{
|
{
|
||||||
const QskDialog::StandardButton id = static_cast< QskDialog::StandardButton >( i );
|
const auto action = static_cast< QskDialog::Action >( i );
|
||||||
if ( id & standardButton )
|
if ( action & actions )
|
||||||
addButton( id );
|
addButton( action );
|
||||||
}
|
}
|
||||||
|
|
||||||
invalidateLayout();
|
invalidateLayout();
|
||||||
|
|
@ -330,49 +330,50 @@ QVector< QskPushButton* > QskDialogButtonBox::buttons() const
|
||||||
{
|
{
|
||||||
QVector< QskPushButton* > buttons;
|
QVector< QskPushButton* > buttons;
|
||||||
|
|
||||||
for ( int i = 0; i < QskDialog::NButtonRoles; i++ )
|
for ( int i = 0; i < QskDialog::NActionRoles; i++ )
|
||||||
buttons += m_data->buttons[ i ];
|
buttons += m_data->buttons[ i ];
|
||||||
|
|
||||||
return buttons;
|
return buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
QskDialog::ButtonRole QskDialogButtonBox::buttonRole( const QskPushButton* button ) const
|
QskDialog::ActionRole QskDialogButtonBox::actionRole(
|
||||||
|
const QskPushButton* button ) const
|
||||||
{
|
{
|
||||||
for ( int i = 0; i < QskDialog::NButtonRoles; i++ )
|
for ( int i = 0; i < QskDialog::NActionRoles; i++ )
|
||||||
{
|
{
|
||||||
const auto& buttons = m_data->buttons[ i ];
|
const auto& buttons = m_data->buttons[ i ];
|
||||||
|
|
||||||
for ( const auto btn : buttons )
|
for ( const auto btn : buttons )
|
||||||
{
|
{
|
||||||
if ( button == btn )
|
if ( button == btn )
|
||||||
return static_cast< QskDialog::ButtonRole >( i );
|
return static_cast< QskDialog::ActionRole >( i );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QskDialog::InvalidRole;
|
return QskDialog::InvalidRole;
|
||||||
}
|
}
|
||||||
|
|
||||||
QskDialog::StandardButton QskDialogButtonBox::defaultButtonCandidate() const
|
QskDialog::Action QskDialogButtonBox::defaultActionCandidate() const
|
||||||
{
|
{
|
||||||
// not the fastest code ever, but usually we always
|
// not the fastest code ever, but usually we always
|
||||||
// have a AcceptRole or YesRole button
|
// have a AcceptRole or YesRole button
|
||||||
|
|
||||||
static const QVector< QskDialog::ButtonRole > fallBackRoles =
|
static const QVector< QskDialog::ActionRole > fallBackRoles =
|
||||||
{
|
{
|
||||||
QskDialog::AcceptRole, QskDialog::YesRole,
|
QskDialog::AcceptRole, QskDialog::YesRole,
|
||||||
QskDialog::RejectRole, QskDialog::NoRole, QskDialog::DestructiveRole,
|
QskDialog::RejectRole, QskDialog::NoRole, QskDialog::DestructiveRole,
|
||||||
QskDialog::ActionRole, QskDialog::ResetRole,
|
QskDialog::UserRole, QskDialog::ResetRole,
|
||||||
QskDialog::ApplyRole, QskDialog::HelpRole
|
QskDialog::ApplyRole, QskDialog::HelpRole
|
||||||
};
|
};
|
||||||
|
|
||||||
for ( auto role : fallBackRoles )
|
for ( auto role : fallBackRoles )
|
||||||
{
|
{
|
||||||
const auto defaultButton = standardButton( buttonFromRole( role ) );
|
const auto defaultAction = action( buttonFromRole( role ) );
|
||||||
if ( defaultButton != QskDialog::NoButton )
|
if ( defaultAction != QskDialog::NoAction )
|
||||||
return defaultButton;
|
return defaultAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QskDialog::NoButton;
|
return QskDialog::NoAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskDialogButtonBox::onButtonClicked()
|
void QskDialogButtonBox::onButtonClicked()
|
||||||
|
|
@ -381,12 +382,12 @@ void QskDialogButtonBox::onButtonClicked()
|
||||||
if ( button == nullptr )
|
if ( button == nullptr )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch ( buttonRole( button ) )
|
switch ( actionRole( button ) )
|
||||||
{
|
{
|
||||||
case QskDialog::AcceptRole:
|
case QskDialog::AcceptRole:
|
||||||
case QskDialog::YesRole:
|
case QskDialog::YesRole:
|
||||||
{
|
{
|
||||||
m_data->clickedButton = standardButton( button );
|
m_data->clickedAction = action( button );
|
||||||
|
|
||||||
Q_EMIT clicked( button );
|
Q_EMIT clicked( button );
|
||||||
Q_EMIT accepted();
|
Q_EMIT accepted();
|
||||||
|
|
@ -396,7 +397,7 @@ void QskDialogButtonBox::onButtonClicked()
|
||||||
case QskDialog::NoRole:
|
case QskDialog::NoRole:
|
||||||
case QskDialog::DestructiveRole:
|
case QskDialog::DestructiveRole:
|
||||||
{
|
{
|
||||||
m_data->clickedButton = standardButton( button );
|
m_data->clickedAction = action( button );
|
||||||
|
|
||||||
Q_EMIT clicked( button );
|
Q_EMIT clicked( button );
|
||||||
Q_EMIT rejected();
|
Q_EMIT rejected();
|
||||||
|
|
@ -404,7 +405,7 @@ void QskDialogButtonBox::onButtonClicked()
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
m_data->clickedButton = QskDialog::NoButton;
|
m_data->clickedAction = QskDialog::NoAction;
|
||||||
Q_EMIT clicked( button );
|
Q_EMIT clicked( button );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
@ -412,44 +413,44 @@ void QskDialogButtonBox::onButtonClicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QskDialog::StandardButtons QskDialogButtonBox::standardButtons() const
|
QskDialog::Actions QskDialogButtonBox::actions() const
|
||||||
{
|
{
|
||||||
QskDialog::StandardButtons standardButtons;
|
QskDialog::Actions actions;
|
||||||
|
|
||||||
for ( int i = 0; i < QskDialog::NButtonRoles; i++ )
|
for ( int i = 0; i < QskDialog::NActionRoles; i++ )
|
||||||
{
|
{
|
||||||
const auto& buttons = m_data->buttons[ i ];
|
const auto& buttons = m_data->buttons[ i ];
|
||||||
|
|
||||||
for ( const auto btn : buttons )
|
for ( const auto btn : buttons )
|
||||||
standardButtons |= this->standardButton( btn );
|
actions |= action( btn );
|
||||||
}
|
}
|
||||||
|
|
||||||
return standardButtons;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
QskDialog::StandardButton QskDialogButtonBox::standardButton( const QskPushButton* button ) const
|
QskDialog::Action QskDialogButtonBox::action( const QskPushButton* button ) const
|
||||||
{
|
{
|
||||||
if ( button )
|
if ( button )
|
||||||
{
|
{
|
||||||
if ( auto dialogButton = qobject_cast< const QskDialogButton* >( button ) )
|
if ( auto dialogButton = qobject_cast< const QskDialogButton* >( button ) )
|
||||||
return dialogButton->standardButton();
|
return dialogButton->action();
|
||||||
|
|
||||||
const QVariant value = button->property( "standardButton" );
|
const QVariant value = button->property( "standardButton" );
|
||||||
if ( value.canConvert< int >() )
|
if ( value.canConvert< int >() )
|
||||||
return static_cast< QskDialog::StandardButton >( value.toInt() );
|
return static_cast< QskDialog::Action >( value.toInt() );
|
||||||
}
|
}
|
||||||
|
|
||||||
return QskDialog::NoButton;
|
return QskDialog::NoAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
QskPushButton* QskDialogButtonBox::button( QskDialog::StandardButton standardButton ) const
|
QskPushButton* QskDialogButtonBox::button( QskDialog::Action action ) const
|
||||||
{
|
{
|
||||||
for ( int i = 0; i < QskDialog::NButtonRoles; i++ )
|
for ( int i = 0; i < QskDialog::NActionRoles; i++ )
|
||||||
{
|
{
|
||||||
const auto& buttons = m_data->buttons[ i ];
|
const auto& buttons = m_data->buttons[ i ];
|
||||||
for ( auto btn : buttons )
|
for ( auto btn : buttons )
|
||||||
{
|
{
|
||||||
if ( this->standardButton( btn ) == standardButton )
|
if ( this->action( btn ) == action )
|
||||||
return btn;
|
return btn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -457,18 +458,18 @@ QskPushButton* QskDialogButtonBox::button( QskDialog::StandardButton standardBut
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QskPushButton* QskDialogButtonBox::buttonFromRole( QskDialog::ButtonRole role ) const
|
QskPushButton* QskDialogButtonBox::buttonFromRole( QskDialog::ActionRole role ) const
|
||||||
{
|
{
|
||||||
if ( role < 0 || role >= QskDialog::NButtonRoles )
|
if ( role < 0 || role >= QskDialog::NActionRoles )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const auto& buttons = m_data->buttons[ role ];
|
const auto& buttons = m_data->buttons[ role ];
|
||||||
return buttons.isEmpty() ? nullptr : buttons.first();
|
return buttons.isEmpty() ? nullptr : buttons.first();
|
||||||
}
|
}
|
||||||
|
|
||||||
QskDialog::StandardButton QskDialogButtonBox::clickedButton() const
|
QskDialog::Action QskDialogButtonBox::clickedAction() const
|
||||||
{
|
{
|
||||||
return m_data->clickedButton;
|
return m_data->clickedAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QskDialogButtonBox::event( QEvent* event )
|
bool QskDialogButtonBox::event( QEvent* event )
|
||||||
|
|
@ -493,12 +494,12 @@ bool QskDialogButtonBox::isDefaultButtonKeyEvent( const QKeyEvent* event )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QskDialogButtonBox::buttonText( QskDialog::StandardButton standardButton )
|
QString QskDialogButtonBox::buttonText( QskDialog::Action action )
|
||||||
{
|
{
|
||||||
// should be redirected through the skin !
|
// should be redirected through the skin !
|
||||||
|
|
||||||
const QPlatformTheme* theme = QGuiApplicationPrivate::platformTheme();
|
const QPlatformTheme* theme = QGuiApplicationPrivate::platformTheme();
|
||||||
QString text = theme->standardButtonText( standardButton );
|
QString text = theme->standardButtonText( action );
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK( 5, 7, 0 )
|
#if QT_VERSION < QT_VERSION_CHECK( 5, 7, 0 )
|
||||||
text.remove( '&' );
|
text.remove( '&' );
|
||||||
|
|
|
||||||
|
|
@ -38,24 +38,24 @@ class QSK_EXPORT QskDialogButtonBox : public QskBox
|
||||||
void setCenteredButtons( bool center );
|
void setCenteredButtons( bool center );
|
||||||
bool centeredButtons() const;
|
bool centeredButtons() const;
|
||||||
|
|
||||||
void addButton( QskPushButton* button, QskDialog::ButtonRole role );
|
void addButton( QskPushButton*, QskDialog::ActionRole );
|
||||||
void addButton( QskDialog::StandardButton button );
|
void addButton( QskDialog::Action );
|
||||||
void removeButton( QskPushButton* button );
|
void removeButton( QskPushButton* );
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
QVector< QskPushButton* > buttons() const;
|
QVector< QskPushButton* > buttons() const;
|
||||||
QskDialog::ButtonRole buttonRole( const QskPushButton* ) const;
|
QskDialog::ActionRole actionRole( const QskPushButton* ) const;
|
||||||
|
|
||||||
void setStandardButtons( QskDialog::StandardButtons buttons );
|
void setActions( QskDialog::Actions );
|
||||||
QskDialog::StandardButtons standardButtons() const;
|
QskDialog::Actions actions() const;
|
||||||
QskDialog::StandardButton standardButton( const QskPushButton* ) const;
|
QskDialog::Action action( const QskPushButton* ) const;
|
||||||
|
|
||||||
QskDialog::StandardButton defaultButtonCandidate() const;
|
QskDialog::Action defaultActionCandidate() const;
|
||||||
|
|
||||||
QskPushButton* button( QskDialog::StandardButton ) const;
|
QskPushButton* button( QskDialog::Action ) const;
|
||||||
QskPushButton* buttonFromRole( QskDialog::ButtonRole ) const;
|
QskPushButton* buttonFromRole( QskDialog::ActionRole ) const;
|
||||||
|
|
||||||
QskDialog::StandardButton clickedButton() const;
|
QskDialog::Action clickedAction() const;
|
||||||
|
|
||||||
QSizeF contentsSizeHint() const override;
|
QSizeF contentsSizeHint() const override;
|
||||||
|
|
||||||
|
|
@ -63,7 +63,7 @@ class QSK_EXPORT QskDialogButtonBox : public QskBox
|
||||||
QskAspect::Subcontrol ) const override;
|
QskAspect::Subcontrol ) const override;
|
||||||
|
|
||||||
static bool isDefaultButtonKeyEvent( const QKeyEvent* );
|
static bool isDefaultButtonKeyEvent( const QKeyEvent* );
|
||||||
static QString buttonText( QskDialog::StandardButton );
|
static QString buttonText( QskDialog::Action );
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void clicked( QskPushButton* button );
|
void clicked( QskPushButton* button );
|
||||||
|
|
@ -77,7 +77,7 @@ class QSK_EXPORT QskDialogButtonBox : public QskBox
|
||||||
bool event( QEvent* event ) override;
|
bool event( QEvent* event ) override;
|
||||||
void updateLayout() override;
|
void updateLayout() override;
|
||||||
|
|
||||||
virtual QskPushButton* createButton( QskDialog::StandardButton ) const;
|
virtual QskPushButton* createButton( QskDialog::Action ) const;
|
||||||
|
|
||||||
void invalidateLayout();
|
void invalidateLayout();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,15 +70,8 @@ namespace
|
||||||
class QskInputSubWindow::PrivateData
|
class QskInputSubWindow::PrivateData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PrivateData()
|
QskDialog::Actions actions = QskDialog::NoAction;
|
||||||
: standardButtons( QskDialog::NoButton )
|
QskDialog::Action defaultAction = QskDialog::NoAction;
|
||||||
, defaultButton( QskDialog::NoButton )
|
|
||||||
, inputControl( nullptr )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QskDialog::StandardButtons standardButtons;
|
|
||||||
QskDialog::StandardButton defaultButton;
|
|
||||||
|
|
||||||
QskTextLabel* infoTextLabel;
|
QskTextLabel* infoTextLabel;
|
||||||
QskGraphicLabel* symbolLabel;
|
QskGraphicLabel* symbolLabel;
|
||||||
|
|
@ -129,36 +122,36 @@ QskInputSubWindow::~QskInputSubWindow()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskInputSubWindow::setStandardButtons( QskDialog::StandardButtons buttons )
|
void QskInputSubWindow::setActions( QskDialog::Actions actions )
|
||||||
{
|
{
|
||||||
if ( m_data->standardButtons == buttons )
|
if ( m_data->actions == actions )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_data->standardButtons = buttons;
|
m_data->actions = actions;
|
||||||
|
|
||||||
m_data->buttonBox->setStandardButtons( buttons );
|
m_data->buttonBox->setActions( actions );
|
||||||
m_data->buttonBox->setVisible( buttons != QskDialog::NoButton );
|
m_data->buttonBox->setVisible( actions != QskDialog::NoAction );
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
const auto btns = m_data->buttonBox->buttons();
|
const auto buttons = m_data->buttonBox->buttons();
|
||||||
if ( !btns.isEmpty() )
|
if ( !buttons.isEmpty() )
|
||||||
btns[ 0 ]->setFocus( true );
|
buttons[ 0 ]->setFocus( true );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
QskDialog::StandardButtons QskInputSubWindow::standardButtons() const
|
QskDialog::Actions QskInputSubWindow::actions() const
|
||||||
{
|
{
|
||||||
return m_data->buttonBox->standardButtons();
|
return m_data->buttonBox->actions();
|
||||||
}
|
}
|
||||||
|
|
||||||
QskDialog::StandardButton QskInputSubWindow::defaultButton() const
|
QskDialog::Action QskInputSubWindow::defaultAction() const
|
||||||
{
|
{
|
||||||
return m_data->defaultButton;
|
return m_data->defaultAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskInputSubWindow::setDefaultButton( QskDialog::StandardButton button )
|
void QskInputSubWindow::setDefaultAction( QskDialog::Action action )
|
||||||
{
|
{
|
||||||
m_data->defaultButton = button;
|
m_data->defaultAction = action;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskInputSubWindow::setInfoText( const QString& text )
|
void QskInputSubWindow::setInfoText( const QString& text )
|
||||||
|
|
@ -243,16 +236,16 @@ const QskDialogButtonBox* QskInputSubWindow::buttonBox() const
|
||||||
return m_data->buttonBox;
|
return m_data->buttonBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
QskDialog::StandardButton QskInputSubWindow::clickedButton() const
|
QskDialog::Action QskInputSubWindow::clickedAction() const
|
||||||
{
|
{
|
||||||
return m_data->buttonBox->clickedButton();
|
return m_data->buttonBox->clickedAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskInputSubWindow::keyPressEvent( QKeyEvent* event )
|
void QskInputSubWindow::keyPressEvent( QKeyEvent* event )
|
||||||
{
|
{
|
||||||
if ( QskDialogButtonBox::isDefaultButtonKeyEvent( event ) )
|
if ( QskDialogButtonBox::isDefaultButtonKeyEvent( event ) )
|
||||||
{
|
{
|
||||||
QskPushButton* button = m_data->buttonBox->button( defaultButton() );
|
QskPushButton* button = m_data->buttonBox->button( defaultAction() );
|
||||||
if ( button && button->isEnabled() )
|
if ( button && button->isEnabled() )
|
||||||
button->click();
|
button->click();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,11 +31,11 @@ class QSK_EXPORT QskInputSubWindow : public QskDialogSubWindow
|
||||||
QskInputSubWindow( QQuickItem* parent = nullptr );
|
QskInputSubWindow( QQuickItem* parent = nullptr );
|
||||||
~QskInputSubWindow() override;
|
~QskInputSubWindow() override;
|
||||||
|
|
||||||
QskDialog::StandardButtons standardButtons() const;
|
QskDialog::Actions actions() const;
|
||||||
void setStandardButtons( QskDialog::StandardButtons );
|
void setActions( QskDialog::Actions );
|
||||||
|
|
||||||
QskDialog::StandardButton defaultButton() const;
|
QskDialog::Action defaultAction() const;
|
||||||
void setDefaultButton( QskDialog::StandardButton );
|
void setDefaultAction( QskDialog::Action );
|
||||||
|
|
||||||
void setInfoTextOptions( const QskTextOptions& );
|
void setInfoTextOptions( const QskTextOptions& );
|
||||||
QskTextOptions infoTextOptions() const;
|
QskTextOptions infoTextOptions() const;
|
||||||
|
|
@ -50,7 +50,7 @@ class QSK_EXPORT QskInputSubWindow : public QskDialogSubWindow
|
||||||
void setSymbol( const QskGraphic& );
|
void setSymbol( const QskGraphic& );
|
||||||
QskGraphic symbol() const;
|
QskGraphic symbol() const;
|
||||||
|
|
||||||
QskDialog::StandardButton clickedButton() const;
|
QskDialog::Action clickedAction() const;
|
||||||
|
|
||||||
QskDialogButtonBox* buttonBox();
|
QskDialogButtonBox* buttonBox();
|
||||||
const QskDialogButtonBox* buttonBox() const;
|
const QskDialogButtonBox* buttonBox() const;
|
||||||
|
|
|
||||||
|
|
@ -55,26 +55,26 @@ QskInputSubWindow* QskInputWindow::subWindow() const
|
||||||
return m_subWindow;
|
return m_subWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
QskDialog::StandardButtons QskInputWindow::standardButtons() const
|
QskDialog::Actions QskInputWindow::actions() const
|
||||||
{
|
{
|
||||||
return m_subWindow ? m_subWindow->standardButtons() : QskDialog::NoButton;
|
return m_subWindow ? m_subWindow->actions() : QskDialog::NoAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskInputWindow::setStandardButtons( QskDialog::StandardButtons buttons )
|
void QskInputWindow::setActions( QskDialog::Actions actions )
|
||||||
{
|
{
|
||||||
if ( m_subWindow )
|
if ( m_subWindow )
|
||||||
m_subWindow->setStandardButtons( buttons );
|
m_subWindow->setActions( actions );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskDialog::StandardButton QskInputWindow::defaultButton() const
|
QskDialog::Action QskInputWindow::defaultAction() const
|
||||||
{
|
{
|
||||||
return m_subWindow ? m_subWindow->defaultButton() : QskDialog::NoButton;
|
return m_subWindow ? m_subWindow->defaultAction() : QskDialog::NoAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskInputWindow::setDefaultButton( QskDialog::StandardButton button )
|
void QskInputWindow::setDefaultAction( QskDialog::Action action )
|
||||||
{
|
{
|
||||||
if ( m_subWindow )
|
if ( m_subWindow )
|
||||||
m_subWindow->setDefaultButton( button );
|
m_subWindow->setDefaultAction( action );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskInputWindow::setInfoText( const QString& text )
|
void QskInputWindow::setInfoText( const QString& text )
|
||||||
|
|
@ -136,9 +136,9 @@ QskGraphic QskInputWindow::symbol() const
|
||||||
return m_subWindow ? m_subWindow->symbol() : QskGraphic();
|
return m_subWindow ? m_subWindow->symbol() : QskGraphic();
|
||||||
}
|
}
|
||||||
|
|
||||||
QskDialog::StandardButton QskInputWindow::clickedButton() const
|
QskDialog::Action QskInputWindow::clickedAction() const
|
||||||
{
|
{
|
||||||
return m_subWindow->clickedButton();
|
return m_subWindow->clickedAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
QskDialogButtonBox* QskInputWindow::buttonBox()
|
QskDialogButtonBox* QskInputWindow::buttonBox()
|
||||||
|
|
|
||||||
|
|
@ -33,26 +33,26 @@ class QSK_EXPORT QskInputWindow : public QskDialogWindow
|
||||||
QskInputWindow( QWindow* parent = nullptr );
|
QskInputWindow( QWindow* parent = nullptr );
|
||||||
~QskInputWindow() override;
|
~QskInputWindow() override;
|
||||||
|
|
||||||
QskDialog::StandardButtons standardButtons() const;
|
QskDialog::Actions actions() const;
|
||||||
void setStandardButtons( QskDialog::StandardButtons );
|
void setActions( QskDialog::Actions );
|
||||||
|
|
||||||
QskDialog::StandardButton defaultButton() const;
|
QskDialog::Action defaultAction() const;
|
||||||
void setDefaultButton( QskDialog::StandardButton );
|
void setDefaultAction( QskDialog::Action );
|
||||||
|
|
||||||
void setInfoTextOptions( const QskTextOptions& );
|
void setInfoTextOptions( const QskTextOptions& );
|
||||||
QskTextOptions infoTextOptions() const;
|
QskTextOptions infoTextOptions() const;
|
||||||
|
|
||||||
QString infoText() const;
|
QString infoText() const;
|
||||||
|
|
||||||
void setSymbolType( int symbolType );
|
void setSymbolType( int );
|
||||||
|
|
||||||
void setSymbolSource( const QUrl& url );
|
void setSymbolSource( const QUrl& );
|
||||||
QUrl symbolSource() const;
|
QUrl symbolSource() const;
|
||||||
|
|
||||||
void setSymbol( const QskGraphic& );
|
void setSymbol( const QskGraphic& );
|
||||||
QskGraphic symbol() const;
|
QskGraphic symbol() const;
|
||||||
|
|
||||||
QskDialog::StandardButton clickedButton() const;
|
QskDialog::Action clickedAction() const;
|
||||||
|
|
||||||
QskDialogButtonBox* buttonBox();
|
QskDialogButtonBox* buttonBox();
|
||||||
const QskDialogButtonBox* buttonBox() const;
|
const QskDialogButtonBox* buttonBox() const;
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ QskSelectionSubWindow::QskSelectionSubWindow( QQuickItem* parent )
|
||||||
: Inherited( parent )
|
: Inherited( parent )
|
||||||
{
|
{
|
||||||
setInputControl( new ListBox( this ) );
|
setInputControl( new ListBox( this ) );
|
||||||
setStandardButtons( QskDialog::Ok | QskDialog::Cancel );
|
setActions( QskDialog::Ok | QskDialog::Cancel );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskSelectionSubWindow::~QskSelectionSubWindow()
|
QskSelectionSubWindow::~QskSelectionSubWindow()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue