From 32da51b44cae6fe560f860172da574aeda6ad661 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Dec 2021 14:48:14 +0100 Subject: [PATCH 01/12] [libcalamares] Avoid warnings in Boost::Python macros --- src/libcalamares/PythonJob.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/libcalamares/PythonJob.cpp b/src/libcalamares/PythonJob.cpp index 291adbc54..b1373f5f3 100644 --- a/src/libcalamares/PythonJob.cpp +++ b/src/libcalamares/PythonJob.cpp @@ -23,6 +23,11 @@ static const char* s_preScript = nullptr; namespace bp = boost::python; +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdisabled-macro-expansion" +#endif + BOOST_PYTHON_FUNCTION_OVERLOADS( mount_overloads, CalamaresPython::mount, 2, 4 ); BOOST_PYTHON_FUNCTION_OVERLOADS( target_env_call_str_overloads, CalamaresPython::target_env_call, 1, 3 ); BOOST_PYTHON_FUNCTION_OVERLOADS( target_env_call_list_overloads, CalamaresPython::target_env_call, 1, 3 ); @@ -42,6 +47,10 @@ BOOST_PYTHON_FUNCTION_OVERLOADS( target_env_process_output_overloads, 4 ); BOOST_PYTHON_FUNCTION_OVERLOADS( host_env_process_output_overloads, CalamaresPython::host_env_process_output, 1, 4 ); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + BOOST_PYTHON_MODULE( libcalamares ) { bp::object package = bp::scope(); From eda85c176afe2781bc9ef0d5566d3d1fd7cc26f3 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Dec 2021 15:01:29 +0100 Subject: [PATCH 02/12] [tracking] Avoid unused-deprecated-methods warnings - these are internal classes, with no real Qt machinery; remove the Q_OBJECT macros. - replace the tr() calls with calls with an explicit context, so that translations do not change. --- src/modules/tracking/TrackingJobs.cpp | 54 +++++++++++++++------------ 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/src/modules/tracking/TrackingJobs.cpp b/src/modules/tracking/TrackingJobs.cpp index 5e3cd12b5..7430bd57b 100644 --- a/src/modules/tracking/TrackingJobs.cpp +++ b/src/modules/tracking/TrackingJobs.cpp @@ -19,6 +19,8 @@ #include +#include + #include @@ -37,7 +39,6 @@ namespace */ class TrackingInstallJob : public Calamares::Job { - Q_OBJECT public: TrackingInstallJob( const QString& url ); ~TrackingInstallJob() override; @@ -58,7 +59,6 @@ private: */ class TrackingMachineUpdateManagerJob : public Calamares::Job { - Q_OBJECT public: ~TrackingMachineUpdateManagerJob() override; @@ -75,7 +75,6 @@ public: */ class TrackingKUserFeedbackJob : public Calamares::Job { - Q_OBJECT public: TrackingKUserFeedbackJob( const QString& username, const QStringList& areas ); ~TrackingKUserFeedbackJob() override; @@ -99,13 +98,13 @@ TrackingInstallJob::~TrackingInstallJob() {} QString TrackingInstallJob::prettyName() const { - return tr( "Installation feedback" ); + return QCoreApplication::translate( "TrackingInstallJob", "Installation feedback" ); } QString TrackingInstallJob::prettyStatusMessage() const { - return tr( "Sending installation feedback." ); + return QCoreApplication::translate( "TrackingInstallJob", "Sending installation feedback." ); } Calamares::JobResult @@ -122,8 +121,9 @@ TrackingInstallJob::exec() if ( result.status == RequestStatus::Timeout ) { cWarning() << "install-tracking request timed out."; - return Calamares::JobResult::error( tr( "Internal error in install-tracking." ), - tr( "HTTP request timed out." ) ); + return Calamares::JobResult::error( + QCoreApplication::translate( "TrackingInstallJob", "Internal error in install-tracking." ), + QCoreApplication::translate( "TrackingInstallJob", "HTTP request timed out." ) ); } return Calamares::JobResult::ok(); } @@ -133,13 +133,13 @@ TrackingMachineUpdateManagerJob::~TrackingMachineUpdateManagerJob() {} QString TrackingMachineUpdateManagerJob::prettyName() const { - return tr( "Machine feedback" ); + return QCoreApplication::translate( "TrackingMachineUpdateManagerJob", "Machine feedback" ); } QString TrackingMachineUpdateManagerJob::prettyStatusMessage() const { - return tr( "Configuring machine feedback." ); + return QCoreApplication::translate( "TrackingMachineUpdateManagerJob", "Configuring machine feedback." ); } Calamares::JobResult @@ -162,14 +162,20 @@ TrackingMachineUpdateManagerJob::exec() else if ( r > 0 ) { return Calamares::JobResult::error( - tr( "Error in machine feedback configuration." ), - tr( "Could not configure machine feedback correctly, script error %1." ).arg( r ) ); + QCoreApplication::translate( "TrackingMachineUpdateManagerJob", + "Error in machine feedback configuration." ), + QCoreApplication::translate( "TrackingMachineUpdateManagerJob", + "Could not configure machine feedback correctly, script error %1." ) + .arg( r ) ); } else { return Calamares::JobResult::error( - tr( "Error in machine feedback configuration." ), - tr( "Could not configure machine feedback correctly, Calamares error %1." ).arg( r ) ); + QCoreApplication::translate( "TrackingMachineUpdateManagerJob", + "Error in machine feedback configuration." ), + QCoreApplication::translate( "TrackingMachineUpdateManagerJob", + "Could not configure machine feedback correctly, Calamares error %1." ) + .arg( r ) ); } } @@ -184,13 +190,13 @@ TrackingKUserFeedbackJob::~TrackingKUserFeedbackJob() {} QString TrackingKUserFeedbackJob::prettyName() const { - return tr( "KDE user feedback" ); + return QCoreApplication::translate( "TrackingKUserFeedbackJob", "KDE user feedback" ); } QString TrackingKUserFeedbackJob::prettyStatusMessage() const { - return tr( "Configuring KDE user feedback." ); + return QCoreApplication::translate( "TrackingKUserFeedbackJob", "Configuring KDE user feedback." ); } Calamares::JobResult @@ -212,21 +218,25 @@ FeedbackLevel=16 if ( r > 0 ) { return Calamares::JobResult::error( - tr( "Error in KDE user feedback configuration." ), - tr( "Could not configure KDE user feedback correctly, script error %1." ).arg( r ) ); + QCoreApplication::translate( "TrackingKUserFeedbackJob", "Error in KDE user feedback configuration." ), + QCoreApplication::translate( "TrackingKUserFeedbackJob", + "Could not configure KDE user feedback correctly, script error %1." ) + .arg( r ) ); } else if ( r < 0 ) { return Calamares::JobResult::error( - tr( "Error in KDE user feedback configuration." ), - tr( "Could not configure KDE user feedback correctly, Calamares error %1." ).arg( r ) ); + QCoreApplication::translate( "TrackingKUserFeedbackJob", "Error in KDE user feedback configuration." ), + QCoreApplication::translate( "TrackingKUserFeedbackJob", + "Could not configure KDE user feedback correctly, Calamares error %1." ) + .arg( r ) ); } } return Calamares::JobResult::ok(); } -} // namespace +} // namespace void addJob( Calamares::JobList& list, InstallTrackingConfig* config ) @@ -290,7 +300,3 @@ addJob( Calamares::JobList& list, UserTrackingConfig* config ) } } } - -#include "utils/moc-warnings.h" - -#include "TrackingJobs.moc" From 5b0511035164e17c2da787f1183370b4892a8bac Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Dec 2021 15:29:02 +0100 Subject: [PATCH 03/12] [partition] Add convenience function formatByteSize We want to use the KPMCore function consistently, but Calamares uses a qint64 most of the time. Centralize the cast to double in one place in the code. --- src/modules/partition/core/SizeUtils.h | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/modules/partition/core/SizeUtils.h diff --git a/src/modules/partition/core/SizeUtils.h b/src/modules/partition/core/SizeUtils.h new file mode 100644 index 000000000..d474656c9 --- /dev/null +++ b/src/modules/partition/core/SizeUtils.h @@ -0,0 +1,27 @@ +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2021 Adriaan de Groot + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Calamares is Free Software: see the License-Identifier above. + * + */ + +#ifndef PARTITION_CORE_SIZEUTILS_H +#define PARTITION_CORE_SIZEUTILS_H + +#include + +/** @brief Helper function for printing sizes consistently. + * + * Most of Calamares uses a qint64 for partition sizes, so use that + * parameter type. However, the human-visible formatting doesn't need + * to bother with one-byte accuracy (and anyway, a double has at least 50 bits + * at which point we're printing giga (or gibi) bytes). + */ +static inline QString formatByteSize( qint64 sizeValue ) +{ + return Capacity::formatByteSize( static_cast< double >( sizeValue ) ); +} + +#endif // PARTITION_CORE_SIZEUTILS_H From bb3f4442f5f5e203a3c0ce673cd362aadb02882c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Dec 2021 15:30:21 +0100 Subject: [PATCH 04/12] [partition] Warnings-reduction - use consistent size-formatting - needs an out-of-line virtual function --- src/modules/partition/gui/ListPhysicalVolumeWidgetItem.cpp | 7 ++++--- src/modules/partition/gui/ListPhysicalVolumeWidgetItem.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modules/partition/gui/ListPhysicalVolumeWidgetItem.cpp b/src/modules/partition/gui/ListPhysicalVolumeWidgetItem.cpp index 1e8a9e573..8eeafcbf4 100644 --- a/src/modules/partition/gui/ListPhysicalVolumeWidgetItem.cpp +++ b/src/modules/partition/gui/ListPhysicalVolumeWidgetItem.cpp @@ -9,11 +9,10 @@ #include "ListPhysicalVolumeWidgetItem.h" -#include +#include "core/SizeUtils.h" ListPhysicalVolumeWidgetItem::ListPhysicalVolumeWidgetItem( const Partition* partition, bool checked ) - : QListWidgetItem( - QString( "%1 | %2" ).arg( partition->deviceNode(), Capacity::formatByteSize( partition->capacity() ) ) ) + : QListWidgetItem( QString( "%1 | %2" ).arg( partition->deviceNode(), formatByteSize( partition->capacity() ) ) ) , m_partition( partition ) { setToolTip( partition->deviceNode() ); @@ -26,3 +25,5 @@ ListPhysicalVolumeWidgetItem::partition() const { return m_partition; } + +ListPhysicalVolumeWidgetItem::~ListPhysicalVolumeWidgetItem() {} diff --git a/src/modules/partition/gui/ListPhysicalVolumeWidgetItem.h b/src/modules/partition/gui/ListPhysicalVolumeWidgetItem.h index 6e0b1c85a..5d7fdcb76 100644 --- a/src/modules/partition/gui/ListPhysicalVolumeWidgetItem.h +++ b/src/modules/partition/gui/ListPhysicalVolumeWidgetItem.h @@ -18,6 +18,7 @@ class ListPhysicalVolumeWidgetItem : public QListWidgetItem { public: ListPhysicalVolumeWidgetItem( const Partition* partition, bool checked ); + ~ListPhysicalVolumeWidgetItem() override; const Partition* partition() const; From 09a03fbbc0356f1fdd24de28715f4b8dc183d236 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Dec 2021 15:31:49 +0100 Subject: [PATCH 05/12] [partition] Warnings--: we don't care about one-byte-in-10^12 --- src/modules/partition/gui/ReplaceWidget.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/partition/gui/ReplaceWidget.cpp b/src/modules/partition/gui/ReplaceWidget.cpp index 94f527646..2e5675a11 100644 --- a/src/modules/partition/gui/ReplaceWidget.cpp +++ b/src/modules/partition/gui/ReplaceWidget.cpp @@ -212,7 +212,8 @@ ReplaceWidget::onPartitionSelected() } } - if ( partition->capacity() < requiredSpaceB ) + // The loss of precision is ok; we're not going to fall over from a single byte + if ( static_cast< double >( partition->capacity() ) < requiredSpaceB ) { updateStatus( CalamaresUtils::Fail, tr( "%4

" From 6e715205d785f63a997d48aaa59d9be6de44705b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Dec 2021 15:36:11 +0100 Subject: [PATCH 06/12] [partition] Warnings-- by calling formatting consistently --- src/modules/partition/core/DeviceModel.cpp | 8 +++----- src/modules/partition/core/PartitionModel.cpp | 10 ++++------ src/modules/partition/gui/PartitionLabelsView.cpp | 5 ++--- src/modules/partition/gui/VolumeGroupBaseDialog.cpp | 7 +++---- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/modules/partition/core/DeviceModel.cpp b/src/modules/partition/core/DeviceModel.cpp index 33aae20c0..25bdbff6c 100644 --- a/src/modules/partition/core/DeviceModel.cpp +++ b/src/modules/partition/core/DeviceModel.cpp @@ -8,9 +8,10 @@ * Calamares is Free Software: see the License-Identifier above. * */ -#include "core/DeviceModel.h" +#include "DeviceModel.h" #include "core/PartitionModel.h" +#include "core/SizeUtils.h" #include "utils/CalamaresUtilsGui.h" #include "utils/Logger.h" @@ -18,9 +19,6 @@ // KPMcore #include -// KF5 -#include - #include #include @@ -83,7 +81,7 @@ DeviceModel::data( const QModelIndex& index, int role ) const //: device[name] - size[number] (device-node[name]) return tr( "%1 - %2 (%3)" ) .arg( device->name() ) - .arg( KFormat().formatByteSize( device->capacity() ) ) + .arg( formatByteSize( device->capacity() ) ) .arg( device->deviceNode() ); } else diff --git a/src/modules/partition/core/PartitionModel.cpp b/src/modules/partition/core/PartitionModel.cpp index e310eee5e..19dbcd076 100644 --- a/src/modules/partition/core/PartitionModel.cpp +++ b/src/modules/partition/core/PartitionModel.cpp @@ -8,11 +8,12 @@ * */ -#include "core/PartitionModel.h" +#include "PartitionModel.h" #include "core/ColorUtils.h" #include "core/KPMHelpers.h" #include "core/PartitionInfo.h" +#include "core/SizeUtils.h" #include "partition/FileSystem.h" #include "partition/PartitionQuery.h" @@ -24,9 +25,6 @@ #include #include -// KF5 -#include - // Qt #include @@ -178,7 +176,7 @@ PartitionModel::data( const QModelIndex& index, int role ) const if ( col == SizeColumn ) { qint64 size = ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSize(); - return KFormat().formatByteSize( size ); + return formatByteSize( size ); } cDebug() << "Unknown column" << col; return QVariant(); @@ -210,7 +208,7 @@ PartitionModel::data( const QModelIndex& index, int role ) const QString prettyFileSystem = CalamaresUtils::Partition::prettyNameForFileSystemType( partition->fileSystem().type() ); qint64 size = ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSize(); - QString prettySize = KFormat().formatByteSize( size ); + QString prettySize = formatByteSize( size ); return QVariant( name + " " + prettyFileSystem + " " + prettySize ); } case SizeRole: diff --git a/src/modules/partition/gui/PartitionLabelsView.cpp b/src/modules/partition/gui/PartitionLabelsView.cpp index 5803d59a2..e73d7f4af 100644 --- a/src/modules/partition/gui/PartitionLabelsView.cpp +++ b/src/modules/partition/gui/PartitionLabelsView.cpp @@ -12,6 +12,7 @@ #include "core/ColorUtils.h" #include "core/PartitionModel.h" +#include "core/SizeUtils.h" #include "utils/CalamaresUtilsGui.h" #include "utils/Logger.h" @@ -20,8 +21,6 @@ #include #include -#include - // Qt #include #include @@ -39,7 +38,7 @@ static QStringList buildUnknownDisklabelTexts( Device* dev ) { QStringList texts = { QObject::tr( "Unpartitioned space or unknown partition table" ), - KFormat().formatByteSize( dev->totalLogical() * dev->logicalSize() ) }; + formatByteSize( dev->totalLogical() * dev->logicalSize() ) }; return texts; } diff --git a/src/modules/partition/gui/VolumeGroupBaseDialog.cpp b/src/modules/partition/gui/VolumeGroupBaseDialog.cpp index 6277c30e5..48b44f68d 100644 --- a/src/modules/partition/gui/VolumeGroupBaseDialog.cpp +++ b/src/modules/partition/gui/VolumeGroupBaseDialog.cpp @@ -10,10 +10,9 @@ #include "VolumeGroupBaseDialog.h" #include "ui_VolumeGroupBaseDialog.h" +#include "core/SizeUtils.h" #include "gui/ListPhysicalVolumeWidgetItem.h" -#include - #include #include #include @@ -100,7 +99,7 @@ VolumeGroupBaseDialog::setUsedSizeValue( qint64 usedSize ) { m_usedSizeValue = usedSize; - ui->usedSize->setText( Capacity::formatByteSize( m_usedSizeValue ) ); + ui->usedSize->setText( formatByteSize( m_usedSizeValue ) ); } void @@ -121,7 +120,7 @@ VolumeGroupBaseDialog::updateTotalSize() % ( ui->peSize->value() * Capacity::unitFactor( Capacity::Unit::Byte, Capacity::Unit::MiB ) ); } - ui->totalSize->setText( Capacity::formatByteSize( m_totalSizeValue ) ); + ui->totalSize->setText( formatByteSize( m_totalSizeValue ) ); updateTotalSectors(); } From 4611545f93a2aafe8aea927a547c0df59c1f804c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Dec 2021 15:42:14 +0100 Subject: [PATCH 07/12] [libcalamares] Warnings-- on switch() - some switch statements handle a bunch of items explicitly, then default the rest. Clang complains about that. Turn off the warning for these specific switches, since there's dozens of values that simply do not need to be handled. --- src/libcalamares/PythonHelper.cpp | 8 ++++++++ src/libcalamares/partition/FileSystem.cpp | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/libcalamares/PythonHelper.cpp b/src/libcalamares/PythonHelper.cpp index d6e61b3aa..ca004ab5f 100644 --- a/src/libcalamares/PythonHelper.cpp +++ b/src/libcalamares/PythonHelper.cpp @@ -26,6 +26,11 @@ namespace CalamaresPython boost::python::object variantToPyObject( const QVariant& variant ) { +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wswitch-enum" +#endif + // 49 enumeration values not handled switch ( variant.type() ) { case QVariant::Map: @@ -62,6 +67,9 @@ variantToPyObject( const QVariant& variant ) default: return bp::object(); } +#ifdef __clang__ +#pragma clang diagnostic pop +#endif } diff --git a/src/libcalamares/partition/FileSystem.cpp b/src/libcalamares/partition/FileSystem.cpp index ad4df31ed..0dcd6fd32 100644 --- a/src/libcalamares/partition/FileSystem.cpp +++ b/src/libcalamares/partition/FileSystem.cpp @@ -22,6 +22,11 @@ namespace Partition QString prettyNameForFileSystemType( FileSystem::Type t ) { +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wswitch-enum" +#endif + // 13 enumeration values not handled switch ( t ) { case FileSystem::Unknown: @@ -60,11 +65,19 @@ prettyNameForFileSystemType( FileSystem::Type t ) default: return FileSystem::nameForType( t ); } +#ifdef __clang__ +#pragma clang diagnostic pop +#endif } QString untranslatedFS( FileSystem::Type t ) { +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wswitch-enum" +#endif + // 34 enumeration values not handled switch ( t ) { case FileSystem::Type::ReiserFS: @@ -72,6 +85,9 @@ untranslatedFS( FileSystem::Type t ) default: return FileSystem::nameForType( t, { QStringLiteral( "C" ) } ); } +#ifdef __clang__ +#pragma clang diagnostic pop +#endif } } // namespace Partition From 09f47b576285001ca2fabb7e034d66b5a5404b91 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Dec 2021 15:51:45 +0100 Subject: [PATCH 08/12] [partition] Build tests with consistent flags (in particular, KPMCore4-API flags) --- src/modules/partition/tests/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/partition/tests/CMakeLists.txt b/src/modules/partition/tests/CMakeLists.txt index 2839270fb..da017d96f 100644 --- a/src/modules/partition/tests/CMakeLists.txt +++ b/src/modules/partition/tests/CMakeLists.txt @@ -61,6 +61,7 @@ calamares_add_test( SOURCES ${PartitionModule_SOURCE_DIR}/jobs/AutoMountManagementJob.cpp AutoMountTests.cpp + DEFINITIONS ${_partition_defs} ) calamares_add_test( @@ -70,4 +71,5 @@ calamares_add_test( ${PartitionModule_SOURCE_DIR}/core/DeviceList.cpp LIBRARIES kpmcore + DEFINITIONS ${_partition_defs} ) From 1197d8c750ad20bedf7d3a9ed3c55c77ec7bf13a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Dec 2021 18:19:32 +0100 Subject: [PATCH 09/12] [interactiveterminal] Warnings-- with KF5 5.86-or-later --- .../InteractiveTerminalPage.cpp | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/modules/interactiveterminal/InteractiveTerminalPage.cpp b/src/modules/interactiveterminal/InteractiveTerminalPage.cpp index afd39936b..ea30c21ef 100644 --- a/src/modules/interactiveterminal/InteractiveTerminalPage.cpp +++ b/src/modules/interactiveterminal/InteractiveTerminalPage.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -41,8 +42,10 @@ InteractiveTerminalPage::InteractiveTerminalPage( QWidget* parent ) void InteractiveTerminalPage::errorKonsoleNotInstalled() { - QMessageBox mb(QMessageBox::Critical, - tr( "Konsole not installed" ), tr( "Please install KDE Konsole and try again!" ), QMessageBox::Ok ); + QMessageBox mb( QMessageBox::Critical, + tr( "Konsole not installed" ), + tr( "Please install KDE Konsole and try again!" ), + QMessageBox::Ok ); Calamares::fixButtonLabels( &mb ); mb.exec(); } @@ -54,20 +57,30 @@ InteractiveTerminalPage::onActivate() { return; } - // For whatever reason, instead of simply linking against a library we - // need to do a runtime query to KService just to get a sodding terminal - // widget. + +#if KCOREADDONS_VERSION_MAJOR != 5 +#error Incompatible with not-KF5 +#endif +#if KCOREADDONS_VERSION_MINOR >= 86 + // 5.86 deprecated a bunch of KService and PluginFactory and related methods + auto md = KPluginMetaData::findPluginById( QString(), "konsolepart" ); + if ( !md.isValid() ) + { + errorKonsoleNotInstalled(); + return; + } + auto* p = KPluginFactory::instantiatePlugin< KParts::ReadOnlyPart >( md, this ).plugin; +#else KService::Ptr service = KService::serviceByDesktopName( "konsolepart" ); if ( !service ) { - // And all of this hoping the Konsole application is installed. If not, - // tough cookies. errorKonsoleNotInstalled(); return; } // Create one instance of konsolepart. KParts::ReadOnlyPart* p = service->createInstance< KParts::ReadOnlyPart >( this, this, {} ); +#endif if ( !p ) { // One more opportunity for the loading operation to fail. @@ -91,7 +104,6 @@ InteractiveTerminalPage::onActivate() m_termHostWidget = p->widget(); m_layout->addWidget( m_termHostWidget ); - cDebug() << "Part widget ought to be" << m_termHostWidget->metaObject()->className(); t->showShellInDir( QDir::home().path() ); t->sendInput( QString( "%1\n" ).arg( m_command ) ); From 13700b18c8ecf5f7ee44e266ef5b45e0eb750243 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 8 Dec 2021 00:06:17 +0100 Subject: [PATCH 10/12] [partition] Warnings-- - remove superfluous `break` - massage types around partition sizes --- src/modules/partition/PartitionViewStep.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/modules/partition/PartitionViewStep.cpp b/src/modules/partition/PartitionViewStep.cpp index a6b5e1dd8..18f10d629 100644 --- a/src/modules/partition/PartitionViewStep.cpp +++ b/src/modules/partition/PartitionViewStep.cpp @@ -146,15 +146,12 @@ modeDescription( Config::InstallChoice choice ) case Config::InstallChoice::Alongside: return QCoreApplication::translate( context, "Install %1 alongside another operating system." ) .arg( branding->shortVersionedName() ); - break; case Config::InstallChoice::Erase: return QCoreApplication::translate( context, "Erase disk and install %1." ) .arg( branding->shortVersionedName() ); - break; case Config::InstallChoice::Replace: return QCoreApplication::translate( context, "Replace a partition with %1." ) .arg( branding->shortVersionedName() ); - break; case Config::InstallChoice::NoChoice: case Config::InstallChoice::Manual: return QCoreApplication::translate( context, "Manual partitioning." ); @@ -187,21 +184,18 @@ diskDescription( int listLength, const PartitionCoreModule::SummaryInfo& info, C .arg( branding->shortVersionedName() ) .arg( info.deviceNode ) .arg( info.deviceName ); - break; case Config::Erase: return QCoreApplication::translate( context, "Erase disk %2 (%3) and install %1." ) .arg( branding->shortVersionedName() ) .arg( info.deviceNode ) .arg( info.deviceName ); - break; case Config::Replace: return QCoreApplication::translate( context, "Replace a partition on disk %2 (%3) with %1." ) .arg( branding->shortVersionedName() ) .arg( info.deviceNode ) .arg( info.deviceName ); - break; case Config::NoChoice: case Config::Manual: return QCoreApplication::translate( @@ -558,7 +552,7 @@ PartitionViewStep::onLeave() if ( !okSize ) { cDebug() << o << "ESP too small"; - const auto atLeastBytes = PartUtils::efiFilesystemMinimumSize(); + const qint64 atLeastBytes = static_cast< qint64 >( PartUtils::efiFilesystemMinimumSize() ); const auto atLeastMiB = CalamaresUtils::BytesToMiB( atLeastBytes ); description.append( ' ' ); description.append( tr( "The filesystem must be at least %1 MiB in size." ).arg( atLeastMiB ) ); From e8ca298712461c694269300422964905ed944af1 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 8 Dec 2021 00:15:01 +0100 Subject: [PATCH 11/12] [partition] Reduce warnings --- src/modules/partition/core/PartUtils.cpp | 8 ++++++-- src/modules/partition/core/PartitionActions.cpp | 6 +++--- src/modules/partition/core/PartitionLayout.cpp | 3 +++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/modules/partition/core/PartUtils.cpp b/src/modules/partition/core/PartUtils.cpp index 507330a80..cb7c8a01d 100644 --- a/src/modules/partition/core/PartUtils.cpp +++ b/src/modules/partition/core/PartUtils.cpp @@ -451,6 +451,8 @@ isEfiFilesystemSuitableType( const Partition* candidate ) { auto type = candidate->fileSystem().type(); + QT_WARNING_PUSH + QT_WARNING_DISABLE_CLANG( "-Wswitch-enum" ) switch ( type ) { case FileSystem::Type::Fat32: @@ -465,6 +467,7 @@ isEfiFilesystemSuitableType( const Partition* candidate ) cWarning() << "EFI boot partition must be FAT32"; return false; } + QT_WARNING_POP } bool @@ -526,14 +529,15 @@ efiFilesystemMinimumSize() { using CalamaresUtils::Units::operator""_MiB; - auto uefisys_part_sizeB = 300_MiB; + size_t uefisys_part_sizeB = 300_MiB; // The default can be overridden; the key used here comes // from the partition module Config.cpp auto* gs = Calamares::JobQueue::instance()->globalStorage(); if ( gs->contains( "efiSystemPartitionSize_i" ) ) { - uefisys_part_sizeB = gs->value( "efiSystemPartitionSize_i" ).toLongLong(); + qint64 v = gs->value( "efiSystemPartitionSize_i" ).toLongLong(); + uefisys_part_sizeB = v > 0 ? static_cast< size_t >( v ) : 0; } // There is a lower limit of what can be configured if ( uefisys_part_sizeB < 32_MiB ) diff --git a/src/modules/partition/core/PartitionActions.cpp b/src/modules/partition/core/PartitionActions.cpp index 8514bbe2c..8226499b4 100644 --- a/src/modules/partition/core/PartitionActions.cpp +++ b/src/modules/partition/core/PartitionActions.cpp @@ -71,15 +71,15 @@ swapSuggestion( const qint64 availableSpaceB, Config::SwapChoice swap ) // Allow for a fudge factor - suggestedSwapSizeB *= overestimationFactor; + suggestedSwapSizeB = qRound( suggestedSwapSizeB * overestimationFactor ); // don't use more than 10% of available space if ( !ensureSuspendToDisk ) { - suggestedSwapSizeB = qMin( suggestedSwapSizeB, qint64( 0.10 * availableSpaceB ) ); + suggestedSwapSizeB = qMin( suggestedSwapSizeB, availableSpaceB / 10 /* 10% is 0.1 */ ); } - cDebug() << "Suggested swap size:" << suggestedSwapSizeB / 1024. / 1024. / 1024. << "GiB"; + cDebug() << "Suggested swap size:" << CalamaresUtils::BytesToGiB( suggestedSwapSizeB ) << "GiB"; return suggestedSwapSizeB; } diff --git a/src/modules/partition/core/PartitionLayout.cpp b/src/modules/partition/core/PartitionLayout.cpp index f60952643..3813207ef 100644 --- a/src/modules/partition/core/PartitionLayout.cpp +++ b/src/modules/partition/core/PartitionLayout.cpp @@ -141,6 +141,8 @@ void PartitionLayout::setDefaultFsType( FileSystem::Type defaultFsType ) { using FileSystem = FileSystem::Type; + QT_WARNING_PUSH + QT_WARNING_DISABLE_CLANG( "-Wswitch-enum" ) switch ( defaultFsType ) { case FileSystem::Unknown: @@ -196,6 +198,7 @@ PartitionLayout::setDefaultFsType( FileSystem::Type defaultFsType ) << "Using ext4 instead."; defaultFsType = FileSystem::Ext4; } + QT_WARNING_POP m_defaultFsType = defaultFsType; } From f0eb7ffbda5f6844c864ee0d5269a54445bbab6e Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 8 Dec 2021 00:59:20 +0100 Subject: [PATCH 12/12] [partition Untangle, Warnings-- The translations apply to labels and a tooltip, which depends on the partition-table type. Move the strings together and make the whole range of the switch explicitly. --- .../partition/gui/DeviceInfoWidget.cpp | 83 ++++++++++--------- 1 file changed, 46 insertions(+), 37 deletions(-) diff --git a/src/modules/partition/gui/DeviceInfoWidget.cpp b/src/modules/partition/gui/DeviceInfoWidget.cpp index bbc8ce74c..05a8c4b63 100644 --- a/src/modules/partition/gui/DeviceInfoWidget.cpp +++ b/src/modules/partition/gui/DeviceInfoWidget.cpp @@ -68,7 +68,8 @@ DeviceInfoWidget::setPartitionTableType( PartitionTable::TableType type ) void DeviceInfoWidget::retranslateUi() { - QString typeString = PartitionTable::tableTypeToName( m_tableType ).toUpper(); + QString typeString; + QString toolTipString; // fix up if the name shouldn't be uppercase: switch ( m_tableType ) @@ -76,38 +77,32 @@ DeviceInfoWidget::retranslateUi() case PartitionTable::msdos: case PartitionTable::msdos_sectorbased: typeString = "MBR"; + toolTipString += tr( "

This partition table type is only advisable on older " + "systems which start from a BIOS boot " + "environment. GPT is recommended in most other cases.

" + "Warning: the MBR partition table " + "is an obsolete MS-DOS era standard.
" + "Only 4 primary partitions may be created, and of " + "those 4, one can be an extended partition, which " + "may in turn contain many logical partitions." ); + break; + case PartitionTable::gpt: + // TypeString is ok + toolTipString += tr( "

This is the recommended partition table type for modern " + "systems which start from an EFI boot " + "environment." ); break; case PartitionTable::loop: typeString = "loop"; - break; - case PartitionTable::mac: - typeString = "Mac"; - break; - case PartitionTable::amiga: - typeString = "Amiga"; - break; - case PartitionTable::sun: - typeString = "Sun"; - break; - case PartitionTable::unknownTableType: - typeString = " ? "; - } - - - QString toolTipString = tr( "This device has a %1 partition " - "table." ) - .arg( typeString ); - - switch ( m_tableType ) - { - case PartitionTable::loop: toolTipString = tr( "This is a loop " "device.

" "It is a pseudo-device with no partition table " "that makes a file accessible as a block device. " "This kind of setup usually only contains a single filesystem." ); break; + case PartitionTable::none: case PartitionTable::unknownTableType: + typeString = " ? "; toolTipString = tr( "This installer cannot detect a partition table on the " "selected storage device.

" "The device either has no partition " @@ -117,21 +112,35 @@ DeviceInfoWidget::retranslateUi() "either automatically, or through the manual partitioning " "page." ); break; - case PartitionTable::gpt: - toolTipString += tr( "

This is the recommended partition table type for modern " - "systems which start from an EFI boot " - "environment." ); + // The next ones need to have the name adjusted, but the default tooltip is OK + case PartitionTable::mac: + typeString = "Mac"; break; - case PartitionTable::msdos: - case PartitionTable::msdos_sectorbased: - toolTipString += tr( "

This partition table type is only advisable on older " - "systems which start from a BIOS boot " - "environment. GPT is recommended in most other cases.

" - "Warning: the MBR partition table " - "is an obsolete MS-DOS era standard.
" - "Only 4 primary partitions may be created, and of " - "those 4, one can be an extended partition, which " - "may in turn contain many logical partitions." ); + case PartitionTable::amiga: + typeString = "Amiga"; + break; + case PartitionTable::sun: + typeString = "Sun"; + break; + // Peculiar tables, do nothing and use default type and tooltip strings + case PartitionTable::aix: + case PartitionTable::bsd: + case PartitionTable::dasd: + case PartitionTable::dvh: + case PartitionTable::pc98: + case PartitionTable::vmd: + break; + } + + if ( typeString.isEmpty() ) + { + typeString = PartitionTable::tableTypeToName( m_tableType ).toUpper(); + } + if ( toolTipString.isEmpty() ) + { + toolTipString = tr( "This device has a %1 partition " + "table." ) + .arg( typeString ); } m_ptLabel->setText( typeString );