2017-07-21 18:21:34 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
|
|
* This file may be used under the terms of the QSkinny License, Version 1.0
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef QSK_DIALOG_BUTTON_BOX_H
|
|
|
|
#define QSK_DIALOG_BUTTON_BOX_H
|
|
|
|
|
|
|
|
#include "QskBox.h"
|
2018-08-03 08:15:28 +02:00
|
|
|
#include "QskDialog.h"
|
2017-07-21 18:21:34 +02:00
|
|
|
|
|
|
|
class QskPushButton;
|
2020-10-23 13:44:29 +02:00
|
|
|
|
2017-07-21 18:21:34 +02:00
|
|
|
class QSK_EXPORT QskDialogButtonBox : public QskBox
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
Q_PROPERTY( Qt::Orientation orientation READ orientation
|
|
|
|
WRITE setOrientation NOTIFY orientationChanged )
|
|
|
|
|
|
|
|
Q_PROPERTY( bool centeredButtons READ centeredButtons
|
|
|
|
WRITE setCenteredButtons NOTIFY centeredButtonsChanged )
|
|
|
|
|
|
|
|
using Inherited = QskBox;
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
public:
|
2017-07-21 18:21:34 +02:00
|
|
|
QSK_SUBCONTROLS( Panel )
|
|
|
|
|
|
|
|
QskDialogButtonBox( QQuickItem* parent = nullptr );
|
|
|
|
QskDialogButtonBox( Qt::Orientation orientation, QQuickItem* parent = nullptr );
|
|
|
|
|
2018-07-31 17:32:25 +02:00
|
|
|
~QskDialogButtonBox() override;
|
2017-07-21 18:21:34 +02:00
|
|
|
|
|
|
|
void setOrientation( Qt::Orientation );
|
|
|
|
Qt::Orientation orientation() const;
|
|
|
|
|
|
|
|
void setCenteredButtons( bool center );
|
|
|
|
bool centeredButtons() const;
|
|
|
|
|
2018-11-05 13:29:52 +01:00
|
|
|
void addButton( QskPushButton*, QskDialog::ActionRole );
|
|
|
|
void removeButton( QskPushButton* );
|
2017-07-21 18:21:34 +02:00
|
|
|
void clear();
|
|
|
|
|
2018-11-05 11:42:46 +01:00
|
|
|
QVector< QskPushButton* > buttons() const;
|
2018-11-06 18:54:21 +01:00
|
|
|
QVector< QskPushButton* > buttons( QskDialog::ActionRole ) const;
|
|
|
|
|
2018-11-05 13:29:52 +01:00
|
|
|
QskDialog::ActionRole actionRole( const QskPushButton* ) const;
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2018-11-08 13:33:30 +01:00
|
|
|
void addAction( QskDialog::Action );
|
|
|
|
|
2018-11-05 13:29:52 +01:00
|
|
|
void setActions( QskDialog::Actions );
|
|
|
|
QskDialog::Actions actions() const;
|
2018-11-08 13:33:30 +01:00
|
|
|
|
2018-11-05 13:29:52 +01:00
|
|
|
QskDialog::Action action( const QskPushButton* ) const;
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2018-11-05 13:29:52 +01:00
|
|
|
QskPushButton* button( QskDialog::Action ) const;
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2018-11-05 13:29:52 +01:00
|
|
|
QskDialog::Action clickedAction() const;
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2018-11-06 18:54:21 +01:00
|
|
|
void setDefaultButton( QskPushButton* );
|
|
|
|
QskPushButton* defaultButton() const;
|
|
|
|
|
2017-07-21 18:21:34 +02:00
|
|
|
static bool isDefaultButtonKeyEvent( const QKeyEvent* );
|
2018-11-05 13:29:52 +01:00
|
|
|
static QString buttonText( QskDialog::Action );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
Q_SIGNALS:
|
2017-07-21 18:21:34 +02:00
|
|
|
void clicked( QskPushButton* button );
|
|
|
|
void accepted();
|
|
|
|
void rejected();
|
|
|
|
|
|
|
|
void centeredButtonsChanged();
|
|
|
|
void orientationChanged();
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
protected:
|
2021-10-27 14:03:39 +02:00
|
|
|
bool event( QEvent* ) override;
|
|
|
|
void itemChange( ItemChange, const ItemChangeData& ) override;
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2019-09-10 17:01:47 +02:00
|
|
|
void updateLayout() override;
|
|
|
|
QSizeF layoutSizeHint( Qt::SizeHint, const QSizeF& ) const override;
|
2019-09-05 15:16:33 +02:00
|
|
|
|
2018-11-05 13:29:52 +01:00
|
|
|
virtual QskPushButton* createButton( QskDialog::Action ) const;
|
2017-07-21 18:21:34 +02:00
|
|
|
void invalidateLayout();
|
|
|
|
|
2021-08-04 15:06:04 +02:00
|
|
|
QskAspect::Subcontrol substitutedSubcontrol(
|
|
|
|
QskAspect::Subcontrol ) const override;
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
private:
|
2018-11-05 11:42:46 +01:00
|
|
|
void onButtonClicked();
|
2017-07-21 18:21:34 +02:00
|
|
|
void rearrangeButtons();
|
2021-10-27 14:03:39 +02:00
|
|
|
void updateTabFocusChain();
|
2017-07-21 18:21:34 +02:00
|
|
|
|
|
|
|
class PrivateData;
|
|
|
|
std::unique_ptr< PrivateData > m_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|