[libcalamares*] Prefer < comparisons in Qt version

This commit is contained in:
Adriaan de Groot 2024-02-04 22:06:22 +01:00
parent 7d7a4597c1
commit 25f9eaf523
4 changed files with 41 additions and 34 deletions

View File

@ -65,7 +65,9 @@ variantToPyObject( const QVariant& variant )
return bp::object( variant.toDouble() );
case Calamares::CharVariantType:
#if QT_VERSION > QT_VERSION_CHECK( 6, 0, 0 )
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
#else
// In Qt6, QChar is also available and different from CharVariantType
case QMetaType::Type::QChar:
#endif
case Calamares::StringVariantType:

View File

@ -82,7 +82,9 @@ variantToPyObject( const QVariant& variant )
return py::float_( variant.toDouble() );
case Calamares::CharVariantType:
#if QT_VERSION > QT_VERSION_CHECK( 6, 0, 0 )
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
#else
// In Qt6, QChar is also available and different from CharVariantType
case QMetaType::Type::QChar:
#endif
case Calamares::StringVariantType:

View File

@ -152,8 +152,8 @@ ViewManager::onInstallationFailed( const QString& message, const QString& detail
cDebug() << Logger::SubEntry << "- message:" << message;
cDebug() << Logger::SubEntry << "- details:" << Logger::NoQuote << details;
QString heading
= Calamares::Settings::instance()->isSetupMode() ? tr( "Setup Failed", "@title" ) : tr( "Installation Failed", "@title" );
QString heading = Calamares::Settings::instance()->isSetupMode() ? tr( "Setup Failed", "@title" )
: tr( "Installation Failed", "@title" );
ErrorDialog* errorDialog = new ErrorDialog();
errorDialog->setWindowTitle( tr( "Error", "@title" ) );
@ -183,7 +183,8 @@ ViewManager::onInitFailed( const QStringList& modules )
// don't bother being precise about installer / setup wording.
QString title( tr( "Calamares Initialization Failed", "@title" ) );
QString description( tr( "%1 can not be installed. Calamares was unable to load all of the configured modules. "
"This is a problem with the way Calamares is being used by the distribution.", "@info" ) );
"This is a problem with the way Calamares is being used by the distribution.",
"@info" ) );
QString detailString;
if ( modules.count() > 0 )
@ -287,7 +288,16 @@ questionBox( QWidget* parent,
const QString& button1 )
{
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
return QMessageBox::question( parent,
title,
question,
button0,
button1,
QString(),
0 /* default first button, i.e. confirm */,
1 /* escape is second button, i.e. cancel */ );
#else
QMessageBox mb( QMessageBox::Question, title, question, QMessageBox::StandardButton::NoButton, parent );
const auto* const okButton = mb.addButton( button0, QMessageBox::AcceptRole );
mb.addButton( button1, QMessageBox::RejectRole );
@ -297,16 +307,6 @@ questionBox( QWidget* parent,
return 0;
}
return 1; // Cancel
#else
return QMessageBox::question( parent,
title,
question,
button0,
button1,
QString(),
0 /* default first button, i.e. confirm */,
1 /* escape is second button, i.e. cancel */ );
#endif
}
@ -329,16 +329,19 @@ ViewManager::next()
// Depending on Calamares::Settings, we show an "are you sure" prompt or not.
if ( settings->showPromptBeforeExecution() && stepIsExecute( m_steps, m_currentStep + 1 ) )
{
QString title
= settings->isSetupMode() ? tr( "Continue with Setup?", "@title" ) : tr( "Continue with Installation?", "@title" );
QString title = settings->isSetupMode() ? tr( "Continue with Setup?", "@title" )
: tr( "Continue with Installation?", "@title" );
QString question = settings->isSetupMode()
? tr( "The %1 setup program is about to make changes to your "
"disk in order to set up %2.<br/><strong>You will not be able "
"to undo these changes.</strong>", "%1 is short product name, %2 is short product name with version" )
"to undo these changes.</strong>",
"%1 is short product name, %2 is short product name with version" )
: tr( "The %1 installer is about to make changes to your "
"disk in order to install %2.<br/><strong>You will not be able "
"to undo these changes.</strong>", "%1 is short product name, %2 is short product name with version" );
QString confirm = settings->isSetupMode() ? tr( "&Set Up Now", "@button" ) : tr( "&Install Now", "@button" );
"to undo these changes.</strong>",
"%1 is short product name, %2 is short product name with version" );
QString confirm
= settings->isSetupMode() ? tr( "&Set Up Now", "@button" ) : tr( "&Install Now", "@button" );
const auto* branding = Calamares::Branding::instance();
int reply = questionBox( m_widget,

View File

@ -24,10 +24,10 @@
#include <QQmlContext>
#include <QQmlEngine>
#include <QQuickItem>
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
#include <QQuickWindow>
#else
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
#include <QQuickWidget>
#else
#include <QQuickWindow>
#endif
#include <QVBoxLayout>
@ -74,13 +74,13 @@ QmlViewStep::QmlViewStep( QObject* parent )
{
Calamares::registerQmlModels();
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
m_qmlEngine = new QQmlEngine( this );
#else
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
m_qmlWidget = new QQuickWidget;
m_qmlWidget->setResizeMode( QQuickWidget::SizeRootObjectToView );
m_qmlWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
m_qmlEngine = m_qmlWidget->engine();
#else
m_qmlEngine = new QQmlEngine( this );
#endif
QVBoxLayout* layout = new QVBoxLayout( m_widget );
@ -192,19 +192,19 @@ QmlViewStep::loadComplete()
}
else
{
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
// setContent() is public API, but not documented publicly.
// It is marked \internal in the Qt sources, but does exactly
// what is needed: sets up visual parent by replacing the root
// item, and handling resizes.
m_qmlWidget->setContent( QUrl( m_qmlFileName ), m_qmlComponent, m_qmlObject );
#else
auto* quick = new QQuickWindow;
auto* root = quick->contentItem();
m_qmlObject->setParentItem( root );
m_qmlObject->bindableWidth().setBinding( [ = ]() { return root->width(); } );
m_qmlObject->bindableHeight().setBinding( [ = ]() { return root->height(); } );
m_qmlWidget = QWidget::createWindowContainer( quick, m_widget );
#else
// setContent() is public API, but not documented publicly.
// It is marked \internal in the Qt sources, but does exactly
// what is needed: sets up visual parent by replacing the root
// item, and handling resizes.
m_qmlWidget->setContent( QUrl( m_qmlFileName ), m_qmlComponent, m_qmlObject );
#endif
showQml();
}