[libcalamares] Deal with deprecations in QComboBox

This commit is contained in:
Adriaan de Groot 2024-12-02 22:57:00 +01:00
parent a067e4fc4f
commit 20e6d1d66c
5 changed files with 50 additions and 19 deletions

View File

@ -0,0 +1,30 @@
/* === This file is part of Calamares - <https://calamares.io> ===
*
* SPDX-FileCopyrightText: 2024 Adriaan de Groot <groot@kde.org>
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Calamares is Free Software: see the License-Identifier above.
*
*
*/
#ifndef CALAMARES_COMPAT_XML_H
#define CALAMARES_COMPAT_XML_H
#include <QCheckBox>
namespace Calamares
{
#if QT_VERSION < QT_VERSION_CHECK( 6, 7, 0 )
using checkBoxStateType = int;
const auto checkBoxStateChangedSignal = &QCheckBox::stateChanged;
constexpr checkBoxStateType checkBoxUncheckedValue = 0;
#else
using checkBoxStateType = Qt::CheckState;
const auto checkBoxStateChangedSignal = &QCheckBox::checkStateChanged;
constexpr checkBoxStateType checkBoxUncheckedValue = Qt::Unchecked;
#endif
} // namespace Calamares
#endif

View File

@ -16,6 +16,7 @@
#include "Branding.h" #include "Branding.h"
#include "Settings.h" #include "Settings.h"
#include "compat/CheckBox.h"
#include "utils/Retranslator.h" #include "utils/Retranslator.h"
#include <QFocusEvent> #include <QFocusEvent>
@ -41,15 +42,10 @@ FinishedPage::FinishedPage( Config* config, QWidget* parent )
ui->restartCheckBox->setEnabled( mode != Mode::Always ); ui->restartCheckBox->setEnabled( mode != Mode::Always );
} ); } );
connect( config, &Config::restartNowWantedChanged, ui->restartCheckBox, &QCheckBox::setChecked ); connect( config, &Config::restartNowWantedChanged, ui->restartCheckBox, &QCheckBox::setChecked );
#if QT_VERSION < QT_VERSION_CHECK( 6, 7, 0 )
connect( ui->restartCheckBox, connect( ui->restartCheckBox,
&QCheckBox::stateChanged, Calamares::checkBoxStateChangedSignal,
[ config ]( int state ) { config->setRestartNowWanted( state != 0 ); } ); [ config ]( Calamares::checkBoxStateType state )
#else { config->setRestartNowWanted( state != Calamares::checkBoxUncheckedValue ); } );
connect( ui->restartCheckBox,
&QCheckBox::checkStateChanged,
[ config ]( Qt::CheckState state ) { config->setRestartNowWanted( state != Qt::Unchecked ); } );
#endif
CALAMARES_RETRANSLATE_SLOT( &FinishedPage::retranslate ); CALAMARES_RETRANSLATE_SLOT( &FinishedPage::retranslate );
} }

View File

@ -34,6 +34,7 @@
#include "Branding.h" #include "Branding.h"
#include "GlobalStorage.h" #include "GlobalStorage.h"
#include "JobQueue.h" #include "JobQueue.h"
#include "compat/CheckBox.h"
#include "partition/PartitionIterator.h" #include "partition/PartitionIterator.h"
#include "partition/PartitionQuery.h" #include "partition/PartitionQuery.h"
#include "utils/Gui.h" #include "utils/Gui.h"
@ -187,7 +188,7 @@ ChoicePage::init( PartitionCoreModule* core )
connect( m_drivesCombo, qOverload< int >( &QComboBox::currentIndexChanged ), this, &ChoicePage::applyDeviceChoice ); connect( m_drivesCombo, qOverload< int >( &QComboBox::currentIndexChanged ), this, &ChoicePage::applyDeviceChoice );
connect( m_encryptWidget, &EncryptWidget::stateChanged, this, &ChoicePage::onEncryptWidgetStateChanged ); connect( m_encryptWidget, &EncryptWidget::stateChanged, this, &ChoicePage::onEncryptWidgetStateChanged );
connect( m_reuseHomeCheckBox, &QCheckBox::stateChanged, this, &ChoicePage::onHomeCheckBoxStateChanged ); connect( m_reuseHomeCheckBox, Calamares::checkBoxStateChangedSignal, this, &ChoicePage::onHomeCheckBoxStateChanged );
ChoicePage::applyDeviceChoice(); ChoicePage::applyDeviceChoice();
} }
@ -361,7 +362,8 @@ ChoicePage::setupChoices()
Device* Device*
ChoicePage::selectedDevice() ChoicePage::selectedDevice()
{ {
Device* const currentDevice = m_core->deviceModel()->deviceForIndex( m_core->deviceModel()->index( m_drivesCombo->currentIndex() ) ); Device* const currentDevice
= m_core->deviceModel()->deviceForIndex( m_core->deviceModel()->index( m_drivesCombo->currentIndex() ) );
return currentDevice; return currentDevice;
} }
@ -1031,7 +1033,7 @@ ChoicePage::updateActionChoicePreview( InstallChoice choice )
if ( m_enableEncryptionWidget ) if ( m_enableEncryptionWidget )
{ {
m_encryptWidget->show(); m_encryptWidget->show();
if ( m_config->preCheckEncryption() && ! m_preCheckActivated ) if ( m_config->preCheckEncryption() && !m_preCheckActivated )
{ {
m_encryptWidget->setEncryptionCheckbox( true ); m_encryptWidget->setEncryptionCheckbox( true );
m_preCheckActivated = true; m_preCheckActivated = true;
@ -1091,7 +1093,7 @@ ChoicePage::updateActionChoicePreview( InstallChoice choice )
if ( shouldShowEncryptWidget( choice ) ) if ( shouldShowEncryptWidget( choice ) )
{ {
m_encryptWidget->show(); m_encryptWidget->show();
if ( m_config->preCheckEncryption() && ! m_preCheckActivated ) if ( m_config->preCheckEncryption() && !m_preCheckActivated )
{ {
m_encryptWidget->setEncryptionCheckbox( true ); m_encryptWidget->setEncryptionCheckbox( true );
m_preCheckActivated = true; m_preCheckActivated = true;

View File

@ -16,6 +16,7 @@
#include "GlobalStorage.h" #include "GlobalStorage.h"
#include "JobQueue.h" #include "JobQueue.h"
#include "ViewManager.h" #include "ViewManager.h"
#include "compat/CheckBox.h"
#include "utils/Gui.h" #include "utils/Gui.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include "utils/Retranslator.h" #include "utils/Retranslator.h"
@ -32,7 +33,7 @@ TrackingPage::TrackingPage( Config* config, QWidget* parent )
ui->noneCheckBox->setChecked( true ); ui->noneCheckBox->setChecked( true );
ui->noneCheckBox->setEnabled( false ); ui->noneCheckBox->setEnabled( false );
connect( ui->noneCheckBox, &QCheckBox::stateChanged, this, &TrackingPage::buttonNoneChecked ); connect( ui->noneCheckBox, Calamares::checkBoxStateChangedSignal, this, &TrackingPage::buttonNoneChecked );
// Each "panel" of configuration has the same kind of setup, // Each "panel" of configuration has the same kind of setup,
// where the xButton and xCheckBox is connected to the xTracking // where the xButton and xCheckBox is connected to the xTracking
@ -40,9 +41,9 @@ TrackingPage::TrackingPage( Config* config, QWidget* parent )
#define trackingSetup( x ) \ #define trackingSetup( x ) \
do \ do \
{ \ { \
connect( ui->x##CheckBox, &QCheckBox::stateChanged, this, &TrackingPage::buttonChecked ); \ connect( ui->x##CheckBox, Calamares::checkBoxStateChangedSignal, this, &TrackingPage::buttonChecked ); \
connect( ui->x##CheckBox, \ connect( ui->x##CheckBox, \
&QCheckBox::stateChanged, \ Calamares::checkBoxStateChangedSignal, \
config->x##Tracking(), \ config->x##Tracking(), \
QOverload< bool >::of( &TrackingStyleConfig::setTracking ) ); \ QOverload< bool >::of( &TrackingStyleConfig::setTracking ) ); \
connect( config->x##Tracking(), \ connect( config->x##Tracking(), \

View File

@ -22,6 +22,7 @@
#include "GlobalStorage.h" #include "GlobalStorage.h"
#include "JobQueue.h" #include "JobQueue.h"
#include "Settings.h" #include "Settings.h"
#include "compat/CheckBox.h"
#include "utils/Gui.h" #include "utils/Gui.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include "utils/Retranslator.h" #include "utils/Retranslator.h"
@ -137,9 +138,10 @@ UsersPage::UsersPage( Config* config, QWidget* parent )
ui->checkBoxDoAutoLogin->setChecked( m_config->doAutoLogin() ); ui->checkBoxDoAutoLogin->setChecked( m_config->doAutoLogin() );
connect( ui->checkBoxDoAutoLogin, connect( ui->checkBoxDoAutoLogin,
&QCheckBox::stateChanged, Calamares::checkBoxStateChangedSignal,
this, this,
[ this ]( int checked ) { m_config->setAutoLogin( checked != Qt::Unchecked ); } ); [ this ]( Calamares::checkBoxStateType checked )
{ m_config->setAutoLogin( checked != Calamares::checkBoxUncheckedValue ); } );
connect( config, &Config::autoLoginChanged, ui->checkBoxDoAutoLogin, &QCheckBox::setChecked ); connect( config, &Config::autoLoginChanged, ui->checkBoxDoAutoLogin, &QCheckBox::setChecked );
ui->checkBoxReusePassword->setVisible( m_config->writeRootPassword() ); ui->checkBoxReusePassword->setVisible( m_config->writeRootPassword() );
@ -147,7 +149,7 @@ UsersPage::UsersPage( Config* config, QWidget* parent )
if ( m_config->writeRootPassword() ) if ( m_config->writeRootPassword() )
{ {
connect( config, &Config::reuseUserPasswordForRootChanged, ui->checkBoxReusePassword, &QCheckBox::setChecked ); connect( config, &Config::reuseUserPasswordForRootChanged, ui->checkBoxReusePassword, &QCheckBox::setChecked );
connect( ui->checkBoxReusePassword, &QCheckBox::stateChanged, this, &UsersPage::onReuseUserPasswordChanged ); connect( ui->checkBoxReusePassword, Calamares::checkBoxStateChangedSignal, this, &UsersPage::onReuseUserPasswordChanged );
} }
ui->checkBoxRequireStrongPassword->setVisible( m_config->permitWeakPasswords() ); ui->checkBoxRequireStrongPassword->setVisible( m_config->permitWeakPasswords() );
@ -155,7 +157,7 @@ UsersPage::UsersPage( Config* config, QWidget* parent )
if ( m_config->permitWeakPasswords() ) if ( m_config->permitWeakPasswords() )
{ {
connect( ui->checkBoxRequireStrongPassword, connect( ui->checkBoxRequireStrongPassword,
&QCheckBox::stateChanged, Calamares::checkBoxStateChangedSignal,
this, this,
[ this ]( int checked ) { m_config->setRequireStrongPasswords( checked != Qt::Unchecked ); } ); [ this ]( int checked ) { m_config->setRequireStrongPasswords( checked != Qt::Unchecked ); } );
connect( connect(