[partition] Prepare for swap options
- Extend PrettyRadioButton with options (combo-boxes which may be added later).
This commit is contained in:
parent
07a0e7b075
commit
c813375908
@ -21,15 +21,16 @@
|
|||||||
#include "utils/CalamaresUtilsGui.h"
|
#include "utils/CalamaresUtilsGui.h"
|
||||||
#include "widgets/ClickableLabel.h"
|
#include "widgets/ClickableLabel.h"
|
||||||
|
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QGridLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QBoxLayout>
|
|
||||||
|
|
||||||
|
|
||||||
PrettyRadioButton::PrettyRadioButton( QWidget* parent )
|
PrettyRadioButton::PrettyRadioButton( QWidget* parent )
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
{
|
{
|
||||||
QHBoxLayout* mainLayout = new QHBoxLayout;
|
m_mainLayout = new QGridLayout;
|
||||||
setLayout( mainLayout );
|
setLayout( m_mainLayout );
|
||||||
|
|
||||||
m_radio = new QRadioButton;
|
m_radio = new QRadioButton;
|
||||||
m_label = new ClickableLabel;
|
m_label = new ClickableLabel;
|
||||||
@ -41,9 +42,9 @@ PrettyRadioButton::PrettyRadioButton( QWidget* parent )
|
|||||||
m_label->setWordWrap( true );
|
m_label->setWordWrap( true );
|
||||||
m_label->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
|
m_label->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
|
||||||
|
|
||||||
mainLayout->addWidget( m_radio );
|
m_mainLayout->addWidget( m_radio, 0, 0 );
|
||||||
mainLayout->addWidget( m_label );
|
m_mainLayout->addWidget( m_label, 0, 1, -1, 1 ); // Row span to right edge
|
||||||
mainLayout->setContentsMargins( 0, 0, 0, 0 );
|
m_mainLayout->setContentsMargins( 0, 0, 0, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -80,3 +81,11 @@ PrettyRadioButton::buttonWidget() const
|
|||||||
{
|
{
|
||||||
return m_radio;
|
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>
|
#include <QRadioButton>
|
||||||
|
|
||||||
class ClickableLabel;
|
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
|
class PrettyRadioButton : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -40,9 +49,13 @@ public:
|
|||||||
|
|
||||||
virtual QRadioButton* buttonWidget() const;
|
virtual QRadioButton* buttonWidget() const;
|
||||||
|
|
||||||
|
/** @brief Add an options drop-down to this button. */
|
||||||
|
void addOptionsComboBox( const QString& label, QComboBox* );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ClickableLabel* m_label;
|
ClickableLabel* m_label;
|
||||||
QRadioButton* m_radio;
|
QRadioButton* m_radio;
|
||||||
|
QGridLayout* m_mainLayout;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PRETTYRADIOBUTTON_H
|
#endif // PRETTYRADIOBUTTON_H
|
||||||
|
Loading…
Reference in New Issue
Block a user