[libcalamaresui] Sanitize API of PrettyRadioButton

- Don't expose internals
- Drop unnecessary virtual
- Offer new API to do the things, for which internals were exposed
main
Adriaan de Groot 5 years ago
parent 3b7c3c4f5d
commit 17231ae41f

@ -21,6 +21,7 @@
#include "utils/CalamaresUtilsGui.h"
#include "widgets/ClickableLabel.h"
#include <QButtonGroup>
#include <QComboBox>
#include <QGridLayout>
#include <QHBoxLayout>
@ -80,12 +81,26 @@ PrettyRadioButton::iconSize() const
}
QRadioButton*
PrettyRadioButton::buttonWidget() const
void
PrettyRadioButton::setChecked( bool checked )
{
m_radio->setChecked( checked );
}
bool
PrettyRadioButton::isChecked() const
{
return m_radio;
return m_radio->isChecked();
}
void
PrettyRadioButton::addToGroup( QButtonGroup* group, int id )
{
group->addButton( m_radio, id );
}
void
PrettyRadioButton::addOptionsComboBox( QComboBox* box )
{

@ -23,6 +23,7 @@
#include <QRadioButton>
class QButtonGroup;
class QComboBox;
class QGridLayout;
class QHBoxLayout;
@ -32,6 +33,9 @@ namespace Calamares
class ClickableLabel;
/** @brief A radio button with fancy label next to it.
*
* The fancy label is used so that the text alongside the radio
* button can word-wrap, be multi-line, and support rich text.
*
* The radio button itself can be retrieved with buttonWidget(),
* and the whole behaves a lot like a label. Extra options can be
@ -45,17 +49,26 @@ public:
explicit PrettyRadioButton( QWidget* parent = nullptr );
virtual ~PrettyRadioButton() { }
virtual void setText( const QString& text );
virtual void setIconSize( const QSize& size );
/// @brief Passes @p text on to the ClickableLabel
void setText( const QString& text );
virtual void setIcon( const QIcon& icon );
// Icon applies to the radio-button part
void setIconSize( const QSize& size );
QSize iconSize() const;
void setIcon( const QIcon& icon );
virtual QSize iconSize() const;
// Applies to the radio-button part
void setChecked( bool checked );
bool isChecked() const;
virtual QRadioButton* buttonWidget() const;
/** @brief Adds the radio-button part to the given @p group
*
* For managing the pretty-radio-button in button groups like normal
* radio buttons, call addToGroup() rather that group->addButton().
*/
void addToGroup( QButtonGroup* group, int id = -1 );
/** @brief Add an options drop-down to this button. */
/// @brief Add an options drop-down to this button.
void addOptionsComboBox( QComboBox* );
protected slots:

Loading…
Cancel
Save