[partition] Prepare for swap options

- Extend PrettyRadioButton with options (combo-boxes which may
   be added later).
main
Adriaan de Groot 6 years ago
parent 07a0e7b075
commit c813375908

@ -21,15 +21,16 @@
#include "utils/CalamaresUtilsGui.h"
#include "widgets/ClickableLabel.h"
#include <QComboBox>
#include <QGridLayout>
#include <QLabel>
#include <QBoxLayout>
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 );
}

@ -22,7 +22,16 @@
#include <QRadioButton>
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

Loading…
Cancel
Save