diff --git a/src/modules/partition/gui/PrettyRadioButton.cpp b/src/modules/partition/gui/PrettyRadioButton.cpp index a697ed270..be09f5753 100644 --- a/src/modules/partition/gui/PrettyRadioButton.cpp +++ b/src/modules/partition/gui/PrettyRadioButton.cpp @@ -21,15 +21,16 @@ #include "utils/CalamaresUtilsGui.h" #include "widgets/ClickableLabel.h" +#include +#include #include -#include PrettyRadioButton::PrettyRadioButton( QWidget* parent ) : QWidget( parent ) { - QHBoxLayout* mainLayout = new QHBoxLayout; - setLayout( mainLayout ); + m_mainLayout = new QGridLayout; + setLayout( m_mainLayout ); m_radio = new QRadioButton; m_label = new ClickableLabel; @@ -41,9 +42,9 @@ PrettyRadioButton::PrettyRadioButton( QWidget* parent ) m_label->setWordWrap( true ); m_label->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); - mainLayout->addWidget( m_radio ); - mainLayout->addWidget( m_label ); - mainLayout->setContentsMargins( 0, 0, 0, 0 ); + m_mainLayout->addWidget( m_radio, 0, 0 ); + m_mainLayout->addWidget( m_label, 0, 1, -1, 1 ); // Row span to right edge + m_mainLayout->setContentsMargins( 0, 0, 0, 0 ); } @@ -80,3 +81,11 @@ PrettyRadioButton::buttonWidget() const { return m_radio; } + +void +PrettyRadioButton::addOptionsComboBox( const QString& label, QComboBox* box ) +{ + int row = m_mainLayout->rowCount(); // Rows index from 0, count from 1 + m_mainLayout->addWidget( new QLabel( label ), row, 1 ); + m_mainLayout->addWidget( box, row, 2 ); +} diff --git a/src/modules/partition/gui/PrettyRadioButton.h b/src/modules/partition/gui/PrettyRadioButton.h index f475ce528..c5ed6b336 100644 --- a/src/modules/partition/gui/PrettyRadioButton.h +++ b/src/modules/partition/gui/PrettyRadioButton.h @@ -22,7 +22,16 @@ #include class ClickableLabel; +class QComboBox; +class QGridLayout; +/** @brief A radio button with fancy label next to it. + * + * The radio button itself can be retrieved with buttonWidget(), + * and the whole behaves a lot like a label. Extra options can be + * added to the display (options are hidden when the button is + * not selected) with addOptionsComboBox(). + */ class PrettyRadioButton : public QWidget { Q_OBJECT @@ -40,9 +49,13 @@ public: virtual QRadioButton* buttonWidget() const; + /** @brief Add an options drop-down to this button. */ + void addOptionsComboBox( const QString& label, QComboBox* ); + protected: ClickableLabel* m_label; QRadioButton* m_radio; + QGridLayout* m_mainLayout; }; #endif // PRETTYRADIOBUTTON_H