[libcalamaresui] Use delegating-constructor, drop initialize()

This commit is contained in:
Adriaan de Groot 2022-04-16 12:25:28 +02:00
parent 18f8633dd9
commit e11a0ee448
2 changed files with 16 additions and 18 deletions

View File

@ -47,34 +47,33 @@ static bool isAlignCenter(Qt::AlignmentFlag a)
WaitingSpinnerWidget::WaitingSpinnerWidget(QWidget *parent,
bool centerOnParent,
bool disableParentWhenSpinning)
: QWidget(parent),
_centerOnParent(centerOnParent),
_disableParentWhenSpinning(disableParentWhenSpinning) {
initialize();
}
: WaitingSpinnerWidget(Qt::WindowModality::NonModal, parent, centerOnParent, disableParentWhenSpinning)
{}
WaitingSpinnerWidget::WaitingSpinnerWidget(Qt::WindowModality modality,
QWidget *parent,
bool centerOnParent,
bool disableParentWhenSpinning)
: QWidget(parent, Qt::Dialog | Qt::FramelessWindowHint),
: QWidget(parent, modality == Qt::WindowModality::NonModal ? Qt::WindowFlags() : Qt::Dialog | Qt::FramelessWindowHint),
_centerOnParent(centerOnParent),
_disableParentWhenSpinning(disableParentWhenSpinning){
initialize();
// We need to set the window modality AFTER we've hidden the
// widget for the first time since changing this property while
// the widget is visible has no effect.
setWindowModality(modality);
setAttribute(Qt::WA_TranslucentBackground);
}
void WaitingSpinnerWidget::initialize() {
_disableParentWhenSpinning(disableParentWhenSpinning)
{
_timer = new QTimer(this);
connect(_timer, SIGNAL(timeout()), this, SLOT(rotate()));
updateSize();
updateTimer();
hide();
// We need to set the window modality AFTER we've hidden the
// widget for the first time since changing this property while
// the widget is visible has no effect.
//
// Non-modal windows don't need any work
if ( modality != Qt::WindowModality::NonModal )
{
setWindowModality(modality);
setAttribute(Qt::WA_TranslucentBackground);
}
}
void WaitingSpinnerWidget::paintEvent(QPaintEvent *) {

View File

@ -123,7 +123,6 @@ private:
qreal trailFadePerc, qreal minOpacity,
QColor color);
void initialize();
void updateSize();
void updateTimer();
void updatePosition();