diff --git a/src/libcalamaresui/widgets/WaitingWidget.cpp b/src/libcalamaresui/widgets/WaitingWidget.cpp index 7adc00405..f3616c916 100644 --- a/src/libcalamaresui/widgets/WaitingWidget.cpp +++ b/src/libcalamaresui/widgets/WaitingWidget.cpp @@ -11,19 +11,37 @@ #include "WaitingWidget.h" #include "utils/Gui.h" +#include "utils/Logger.h" #include +#include #include #include +static void +colorSpinner( WaitingSpinnerWidget* spinner ) +{ + const auto color = spinner->palette().text().color(); + spinner->setTextColor( color ); + spinner->setColor( color ); +} + +static void +styleSpinner( WaitingSpinnerWidget* spinner, int size ) +{ + spinner->setFixedSize( size, size ); + spinner->setInnerRadius( size / 2 ); + spinner->setLineLength( size / 2 ); + spinner->setLineWidth( size / 8 ); + colorSpinner( spinner ); +} + + WaitingWidget::WaitingWidget( const QString& text, QWidget* parent ) : WaitingSpinnerWidget( parent, false, false ) { int spnrSize = Calamares::defaultFontHeight() * 4; - setFixedSize( spnrSize, spnrSize ); - setInnerRadius( spnrSize / 2 ); - setLineLength( spnrSize / 2 ); - setLineWidth( spnrSize / 8 ); + styleSpinner( this, spnrSize ); setAlignment( Qt::AlignmentFlag::AlignBottom ); setText( text ); start(); @@ -31,6 +49,16 @@ WaitingWidget::WaitingWidget( const QString& text, QWidget* parent ) WaitingWidget::~WaitingWidget() {} +void +WaitingWidget::changeEvent( QEvent* event ) +{ + if ( event->type() == QEvent::PaletteChange ) + { + colorSpinner( this ); + } + WaitingSpinnerWidget::changeEvent( event ); +} + struct CountdownWaitingWidget::Private { std::chrono::seconds duration; @@ -52,13 +80,8 @@ CountdownWaitingWidget::CountdownWaitingWidget( std::chrono::seconds duration, Q { // Set up the label first for sizing const int labelHeight = qBound( 16, Calamares::defaultFontHeight() * 3 / 2, 64 ); - - // Set up the spinner - setFixedSize( labelHeight, labelHeight ); + styleSpinner( this, labelHeight ); setRevolutionsPerSecond( 1.0 / double( duration.count() ) ); - setInnerRadius( labelHeight / 2 ); - setLineLength( labelHeight / 2 ); - setLineWidth( labelHeight / 8 ); setAlignment( Qt::AlignmentFlag::AlignVCenter ); // Last because it updates the text @@ -117,3 +140,13 @@ CountdownWaitingWidget::tick() timeout(); } } + +void +CountdownWaitingWidget::changeEvent( QEvent* event ) +{ + if ( event->type() == QEvent::PaletteChange ) + { + colorSpinner( this ); + } + WaitingSpinnerWidget::changeEvent( event ); +} diff --git a/src/libcalamaresui/widgets/WaitingWidget.h b/src/libcalamaresui/widgets/WaitingWidget.h index 3a7f03bc2..312914e0d 100644 --- a/src/libcalamaresui/widgets/WaitingWidget.h +++ b/src/libcalamaresui/widgets/WaitingWidget.h @@ -32,6 +32,9 @@ public: /// Create a WaitingWidget with initial @p text label. explicit WaitingWidget( const QString& text, QWidget* parent = nullptr ); ~WaitingWidget() override; + +protected: + void changeEvent( QEvent* event ) override; }; /** @brief A spinner and a countdown inside it @@ -64,6 +67,9 @@ Q_SIGNALS: protected Q_SLOTS: void tick(); +protected: + void changeEvent( QEvent* event ) override; + private: struct Private; std::unique_ptr< Private > d;