mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-25 03:15:44 -05:00
Initial commit for ExpandableRadioButton.
ExpandableRadioButton extends PrettyRadioButton with an optional user-provided QWidget at the bottom, which only shows up when the button is checked.
This commit is contained in:
parent
e83fdfbd13
commit
32e97c6ef2
2 changed files with 115 additions and 0 deletions
73
src/modules/partition/gui/ExpandableRadioButton.cpp
Normal file
73
src/modules/partition/gui/ExpandableRadioButton.cpp
Normal file
|
@ -0,0 +1,73 @@
|
|||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2015, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Calamares is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Calamares is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "ExpandableRadioButton.h"
|
||||
|
||||
#include <utils/CalamaresUtilsGui.h>
|
||||
#include <widgets/ClickableLabel.h>
|
||||
|
||||
#include <QBoxLayout>
|
||||
|
||||
|
||||
ExpandableRadioButton::ExpandableRadioButton( QWidget* parent )
|
||||
: PrettyRadioButton( parent )
|
||||
, m_expandableWidget( nullptr )
|
||||
{
|
||||
QBoxLayout* mainLayout = qobject_cast< QBoxLayout* >( layout() );
|
||||
mainLayout->setDirection( QBoxLayout::TopToBottom );
|
||||
mainLayout->setContentsMargins( 0, 0, 0, 0 );
|
||||
QBoxLayout* prettyRadioButtonLayout = new QHBoxLayout;
|
||||
prettyRadioButtonLayout->addWidget( m_radio );
|
||||
prettyRadioButtonLayout->addWidget( m_label );
|
||||
mainLayout->addLayout( prettyRadioButtonLayout );
|
||||
}
|
||||
|
||||
|
||||
QSize
|
||||
ExpandableRadioButton::sizeHint() const
|
||||
{
|
||||
return PrettyRadioButton::sizeHint();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ExpandableRadioButton::setExpandableWidget( QWidget* widget )
|
||||
{
|
||||
if ( m_expandableWidget )
|
||||
{
|
||||
layout()->removeWidget( m_expandableWidget );
|
||||
m_expandableWidget->deleteLater();
|
||||
}
|
||||
|
||||
m_expandableWidget = widget;
|
||||
m_expandableWidget->setVisible( m_radio->isChecked() );
|
||||
layout()->addWidget( m_expandableWidget );
|
||||
updateGeometry();
|
||||
|
||||
connect( m_radio, &QRadioButton::toggled,
|
||||
m_expandableWidget, &QWidget::setVisible );
|
||||
}
|
||||
|
||||
|
||||
QWidget*
|
||||
ExpandableRadioButton::expandableWidget() const
|
||||
{
|
||||
return m_expandableWidget;
|
||||
}
|
||||
|
42
src/modules/partition/gui/ExpandableRadioButton.h
Normal file
42
src/modules/partition/gui/ExpandableRadioButton.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2015, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Calamares is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Calamares is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef EXPANDABLERADIOBUTTON_H
|
||||
#define EXPANDABLERADIOBUTTON_H
|
||||
|
||||
#include "PrettyRadioButton.h"
|
||||
|
||||
class ExpandableRadioButton : public PrettyRadioButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ExpandableRadioButton( QWidget* parent = nullptr );
|
||||
virtual ~ExpandableRadioButton() {}
|
||||
|
||||
QSize sizeHint() const override;
|
||||
|
||||
void setExpandableWidget( QWidget* widget );
|
||||
QWidget* expandableWidget() const;
|
||||
|
||||
private:
|
||||
QWidget* m_expandableWidget;
|
||||
bool m_expanded;
|
||||
};
|
||||
|
||||
#endif // EXPANDABLERADIOBUTTON_H
|
Loading…
Add table
Reference in a new issue