[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, WaitingSpinnerWidget::WaitingSpinnerWidget(QWidget *parent,
bool centerOnParent, bool centerOnParent,
bool disableParentWhenSpinning) bool disableParentWhenSpinning)
: QWidget(parent), : WaitingSpinnerWidget(Qt::WindowModality::NonModal, parent, centerOnParent, disableParentWhenSpinning)
_centerOnParent(centerOnParent), {}
_disableParentWhenSpinning(disableParentWhenSpinning) {
initialize();
}
WaitingSpinnerWidget::WaitingSpinnerWidget(Qt::WindowModality modality, WaitingSpinnerWidget::WaitingSpinnerWidget(Qt::WindowModality modality,
QWidget *parent, QWidget *parent,
bool centerOnParent, bool centerOnParent,
bool disableParentWhenSpinning) bool disableParentWhenSpinning)
: QWidget(parent, Qt::Dialog | Qt::FramelessWindowHint), : QWidget(parent, modality == Qt::WindowModality::NonModal ? Qt::WindowFlags() : Qt::Dialog | Qt::FramelessWindowHint),
_centerOnParent(centerOnParent), _centerOnParent(centerOnParent),
_disableParentWhenSpinning(disableParentWhenSpinning){ _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() {
_timer = new QTimer(this); _timer = new QTimer(this);
connect(_timer, SIGNAL(timeout()), this, SLOT(rotate())); connect(_timer, SIGNAL(timeout()), this, SLOT(rotate()));
updateSize(); updateSize();
updateTimer(); updateTimer();
hide(); 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 *) { void WaitingSpinnerWidget::paintEvent(QPaintEvent *) {

View File

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