[libcalamaresui] Warnings-- for Qt 5.15 deprecations

Introduce a GUI-oriented compatibility header that introduces aliases
for some enum values that are deprecated in Qt 5.15
This commit is contained in:
Adriaan de Groot 2020-10-24 12:49:56 +02:00
parent b28a50de6f
commit 84936a95fc
6 changed files with 52 additions and 6 deletions

View File

@ -0,0 +1,42 @@
/* === This file is part of Calamares - <https://calamares.io> ===
*
* SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
* SPDX-License-Identifier: GPL-3.0-or-later
* Calamares is Free Software: see the License-Identifier above.
*
*/
/**@file Handle compatibility and deprecations across Qt versions
*
* Since Calamares is supposed to work with Qt 5.9 or later, it covers a
* lot of changes in the Qt API. Especially the later Qt 5.15 (last LTS)
* versions deprecate a number of enum values and parts of the QWidgets
* API. This file adjusts for that by introducing suitable aliases
* and workaround-functions.
*
* For a similar approach for QtCore, see libcalamares/utils/String.h
*/
#ifndef UTILS_QTCOMPAT_H
#define UTILS_QTCOMPAT_H
#include <QPalette>
/* Avoid warnings about QPalette changes */
constexpr static const auto WindowBackground =
#if QT_VERSION < QT_VERSION_CHECK( 5, 15, 0 )
QPalette::Background
#else
QPalette::Window
#endif
;
constexpr static const auto WindowText =
#if QT_VERSION < QT_VERSION_CHECK( 5, 15, 0 )
QPalette::Foreground
#else
QPalette::WindowText
#endif
;
#endif

View File

@ -13,6 +13,7 @@
#include "LicenseWidget.h"
#include "utils/Logger.h"
#include "utils/QtCompat.h"
#include <QDesktopServices>
#include <QFile>
@ -48,7 +49,7 @@ LicenseWidget::LicenseWidget( LicenseEntry entry, QWidget* parent )
, m_isExpanded( m_entry.expandByDefault() )
{
QPalette pal( palette() );
pal.setColor( QPalette::Background, palette().window().color().lighter( 108 ) );
pal.setColor( WindowBackground, palette().window().color().lighter( 108 ) );
setObjectName( "licenseItem" );

View File

@ -12,6 +12,7 @@
#include "core/PartUtils.h"
#include "utils/CalamaresUtilsGui.h"
#include "utils/QtCompat.h"
#include "utils/Retranslator.h"
#include <QDir>
@ -45,7 +46,7 @@ BootInfoWidget::BootInfoWidget( QWidget* parent )
m_bootLabel->setAlignment( Qt::AlignCenter );
QPalette palette;
palette.setBrush( QPalette::Foreground, QColor( "#4D4D4D" ) ); //dark grey
palette.setBrush( WindowText, QColor( "#4D4D4D" ) ); //dark grey
m_bootIcon->setAutoFillBackground( true );
m_bootLabel->setAutoFillBackground( true );

View File

@ -7,13 +7,13 @@
*
*/
#include "DeviceInfoWidget.h"
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "utils/CalamaresUtilsGui.h"
#include "utils/Logger.h"
#include "utils/QtCompat.h"
#include "utils/Retranslator.h"
#include <QDir>
@ -47,7 +47,7 @@ DeviceInfoWidget::DeviceInfoWidget( QWidget* parent )
m_ptLabel->setAlignment( Qt::AlignCenter );
QPalette palette;
palette.setBrush( QPalette::Foreground, QColor( "#4D4D4D" ) ); //dark grey
palette.setBrush( WindowText, QColor( "#4D4D4D" ) ); //dark grey
m_ptIcon->setAutoFillBackground( true );
m_ptLabel->setAutoFillBackground( true );

View File

@ -34,6 +34,7 @@
#include "utils/CalamaresUtilsGui.h"
#include "utils/Logger.h"
#include "utils/NamedEnum.h"
#include "utils/QtCompat.h"
#include "utils/Retranslator.h"
#include "utils/Variant.h"
#include "widgets/WaitingWidget.h"
@ -273,7 +274,7 @@ PartitionViewStep::createSummaryWidget() const
jobsLabel->setText( jobsLines.join( "<br/>" ) );
jobsLabel->setMargin( CalamaresUtils::defaultFontHeight() / 2 );
QPalette pal;
pal.setColor( QPalette::Background, pal.window().color().lighter( 108 ) );
pal.setColor( WindowBackground, pal.window().color().lighter( 108 ) );
jobsLabel->setAutoFillBackground( true );
jobsLabel->setPalette( pal );
}

View File

@ -19,6 +19,7 @@
#include "utils/CalamaresUtilsGui.h"
#include "utils/Logger.h"
#include "utils/QtCompat.h"
#include "utils/Retranslator.h"
#include "viewpages/ExecutionViewStep.h"
@ -183,7 +184,7 @@ SummaryPage::createBodyLabel( const QString& text ) const
QLabel* label = new QLabel;
label->setMargin( CalamaresUtils::defaultFontHeight() / 2 );
QPalette pal( palette() );
pal.setColor( QPalette::Background, palette().window().color().lighter( 108 ) );
pal.setColor( WindowBackground, palette().window().color().lighter( 108 ) );
label->setAutoFillBackground( true );
label->setPalette( pal );
label->setText( text );