Merge branch 'master' of https://github.com/calamares/calamares into development

This commit is contained in:
Philip Müller 2019-08-17 04:04:38 -04:00
commit 43820c920e
64 changed files with 714 additions and 862 deletions

14
CHANGES
View File

@ -6,6 +6,8 @@ website will have to do for older versions.
# 3.2.13 (unreleased) # # 3.2.13 (unreleased) #
This release contains contributions from (alphabetically by first name): This release contains contributions from (alphabetically by first name):
- Arnaud Ferraris
- Arnaud Rebillout
## Core ## ## Core ##
@ -13,9 +15,21 @@ This release contains contributions from (alphabetically by first name):
has had a few updates and has now been consistently applied across has had a few updates and has now been consistently applied across
the core codebase (e.g. libcalamares, libcalamaresui, calamares, but the core codebase (e.g. libcalamares, libcalamaresui, calamares, but
not the modules). not the modules).
- *KCoreAddons* is now a required dependency. This lets us drop a chunk
of code that was copied from KCoreAddons years ago, and use the
(maintained!) upstream version instead. It also gives us KMacroExpander
everywhere, which will simplify code for handling substitutions
in configuration files.
## Modules ## ## Modules ##
- The *partition* module now understands the units *KB*, *MB*, *GB* which
are powers-of-ten sizes, alongside the powers-of-two sizes that it already
used. (thanks to Arnaud)
- The *welcome* module now supports a *Donate* button if *showDonateUrl*
is set to a non-empty URL. #1197
- The *welcome* module can have URLs for the various buttons configured
directly in the module configuration (rather than in `branding.desc`).
# 3.2.12 (2019-08-07) # # 3.2.12 (2019-08-07) #

View File

@ -261,6 +261,8 @@ if( Qt5_VERSION VERSION_GREATER 5.12.1 )
list( APPEND _tx_ok "eo" ) list( APPEND _tx_ok "eo" )
endif() endif()
endif() endif()
# Optional Qt parts
find_package( Qt5DBus CONFIG )
find_package( YAMLCPP ${YAMLCPP_VERSION} REQUIRED ) find_package( YAMLCPP ${YAMLCPP_VERSION} REQUIRED )
if( INSTALL_POLKIT ) if( INSTALL_POLKIT )
@ -291,7 +293,14 @@ if( ECM_FOUND )
include(KDEInstallDirs) include(KDEInstallDirs)
endif() endif()
find_package( KF5 COMPONENTS CoreAddons Crash ) find_package( KF5 QUIET COMPONENTS CoreAddons Crash )
set_package_properties(
KF5::CoreAddons PROPERTIES
TYPE REQUIRED
DESCRIPTION "Classes built on QtCore for About Data"
URL "https://api.kde.org/frameworks/kcoreaddons/"
PURPOSE "About Calamares"
)
if( NOT KF5Crash_FOUND ) if( NOT KF5Crash_FOUND )
set( WITH_KF5Crash OFF ) set( WITH_KF5Crash OFF )
endif() endif()
@ -590,10 +599,25 @@ add_custom_target( uninstall
### CMAKE SUMMARY REPORT ### CMAKE SUMMARY REPORT
# #
feature_summary(WHAT ALL)
get_directory_property( SKIPPED_MODULES get_directory_property( SKIPPED_MODULES
DIRECTORY src/modules DIRECTORY src/modules
DEFINITION LIST_SKIPPED_MODULES DEFINITION LIST_SKIPPED_MODULES
) )
calamares_explain_skipped_modules( ${SKIPPED_MODULES} ) calamares_explain_skipped_modules( ${SKIPPED_MODULES} )
feature_summary(
WHAT DISABLED_FEATURES
DESCRIPTION "The following features have been disabled:"
QUIET_ON_EMPTY
)
feature_summary(
WHAT OPTIONAL_PACKAGES_NOT_FOUND
DESCRIPTION "The following OPTIONAL packages were not found:"
QUIET_ON_EMPTY
)
feature_summary(
WHAT REQUIRED_PACKAGES_NOT_FOUND
FATAL_ON_MISSING_REQUIRED_PACKAGES
DESCRIPTION "The following REQUIRED packages were not found:"
QUIET_ON_EMPTY
)

View File

@ -13,28 +13,23 @@
### Dependencies ### Dependencies
Main: Main:
* Compiler with C++11 support: GCC >= 4.9.0 or Clang >= 3.5.1 * Compiler with C++14 support: GCC >= 5 or Clang >= 3.5.1
* CMake >= 3.2 * CMake >= 3.3
* Qt >= 5.7 * Qt >= 5.9
* yaml-cpp >= 0.5.1 * yaml-cpp >= 0.5.1
* Python >= 3.3 (required for some modules) * Python >= 3.3 (required for some modules)
* Boost.Python >= 1.55.0 (recommended, or PythonQt; one is required for some modules) * Boost.Python >= 1.55.0 (required for some modules)
* PythonQt (recommended, or Boost.Python; one is required for some modules) * KDE extra-cmake-modules >= 5.18 (recommended; required for some modules;
* extra-cmake-modules >= 5.18 (recommended; required for some modules) required for some tests)
* KDE Frameworks KCoreAddons (>= 5.58 recommended)
* PythonQt (optional, deprecated)
Modules: Modules:
* welcome: * Individual modules may have their own requirements;
* NetworkManager these are listed in CMake output. Particular requirements (not complete):
* UPower (optional, runtime) * *fsresizer* KPMCore >= 3.3
* partition: * *partition* KPMCore >= 3.3
* extra-cmake-modules * *users* LibPWQuality (optional)
* KF5: KCoreAddons, KConfig, KI18n, KService, KWidgetsAddons
* KPMcore >= 3.3
* bootloader:
* systemd-boot or GRUB
* unpackfs:
* squashfs-tools
* rsync
### Building ### Building

View File

@ -0,0 +1,18 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
<defs
id="defs3051">
<style
type="text/css"
id="current-color-scheme">
.ColorScheme-Text {
color:#4d4d4d;
}
</style>
</defs>
<path
style="fill:currentColor;fill-opacity:1;stroke:none"
d="m 5,9 0,1 -1,0 0,12 1,0 0,1 22,0 0,-1 1,0 0,-12 -1,0 0,-1 z m 1,1 20,0 a 1,1 0 0 0 1,1 l 0,10 a 1,1 0 0 0 -1,1 L 6,22 A 1,1 0 0 0 5,21 L 5,11 a 1,1 0 0 0 1,-1 m 10,2 a 4,4 0 0 0 -4,4 4,4 0 0 0 4,4 4,4 0 0 0 4,-4 4,4 0 0 0 -4,-4 m 0,1 a 3,3 0 0 1 3,3 3,3 0 0 1 -3,3 3,3 0 0 1 -3,-3 3,3 0 0 1 3,-3"
id="path76"
class="ColorScheme-Text"
/>
</svg>

After

Width:  |  Height:  |  Size: 675 B

View File

@ -56,6 +56,10 @@ windowSize: 800px,520px
# Note that ANSI_COLOR and CPE_NAME don't make sense here, and # Note that ANSI_COLOR and CPE_NAME don't make sense here, and
# are not supported (the rest are). Remember to quote the string # are not supported (the rest are). Remember to quote the string
# if it contains substitutions, or you'll get YAML exceptions. # if it contains substitutions, or you'll get YAML exceptions.
#
# The *Url* entries are used on the welcome page, and they
# are visible as buttons there if the corresponding *show* keys
# are set to "true" (they can also be overridden).
strings: strings:
productName: "@{NAME}" productName: "@{NAME}"
shortProductName: Generic shortProductName: Generic
@ -84,7 +88,7 @@ strings:
# the window. Use `welcomeExpandingLogo` to make it non-scaled. # the window. Use `welcomeExpandingLogo` to make it non-scaled.
# Recommended size is 320x150. # Recommended size is 320x150.
# #
# These strings can also use substitutions from os-release (see above). # These filenames can also use substitutions from os-release (see above).
images: images:
productLogo: "squid.png" productLogo: "squid.png"
productIcon: "squid.png" productIcon: "squid.png"

View File

@ -46,11 +46,11 @@ target_link_libraries( calamares_bin
calamaresui calamaresui
Qt5::Core Qt5::Core
Qt5::Widgets Qt5::Widgets
KF5::CoreAddons
) )
if( WITH_KF5Crash ) if( WITH_KF5Crash )
target_link_libraries( calamares_bin target_link_libraries( calamares_bin
PRIVATE PRIVATE
KF5::CoreAddons
KF5::Crash KF5::Crash
) )
target_compile_definitions( calamares_bin PRIVATE WITH_KF5Crash ) target_compile_definitions( calamares_bin PRIVATE WITH_KF5Crash )

View File

@ -14,4 +14,4 @@
#cmakedefine CALAMARES_TRANSLATION_LANGUAGES "${CALAMARES_TRANSLATION_LANGUAGES}" #cmakedefine CALAMARES_TRANSLATION_LANGUAGES "${CALAMARES_TRANSLATION_LANGUAGES}"
#endif // CALAMARES_VERSION_H #endif // CALAMARES_VERSION_H

View File

@ -26,8 +26,8 @@
#include "3rdparty/kdsingleapplicationguard/kdsingleapplicationguard.h" #include "3rdparty/kdsingleapplicationguard/kdsingleapplicationguard.h"
#ifdef WITH_KF5Crash
#include <KF5/KCoreAddons/KAboutData> #include <KF5/KCoreAddons/KAboutData>
#ifdef WITH_KF5Crash
#include <KF5/KCrash/KCrash> #include <KF5/KCrash/KCrash>
#endif #endif
@ -93,7 +93,6 @@ main( int argc, char* argv[] )
{ {
CalamaresApplication a( argc, argv ); CalamaresApplication a( argc, argv );
#ifdef WITH_KF5Crash
KAboutData aboutData( "calamares", KAboutData aboutData( "calamares",
"Calamares", "Calamares",
a.applicationVersion(), a.applicationVersion(),
@ -104,12 +103,14 @@ main( int argc, char* argv[] )
"https://calamares.io", "https://calamares.io",
"https://github.com/calamares/calamares/issues" ); "https://github.com/calamares/calamares/issues" );
KAboutData::setApplicationData( aboutData ); KAboutData::setApplicationData( aboutData );
a.setApplicationDisplayName( QString() ); // To avoid putting an extra "Calamares/" into the log-file
#ifdef WITH_KF5Crash
KCrash::initialize(); KCrash::initialize();
// KCrash::setCrashHandler(); // KCrash::setCrashHandler();
KCrash::setDrKonqiEnabled( true ); KCrash::setDrKonqiEnabled( true );
KCrash::setFlags( KCrash::SaferDialog | KCrash::AlwaysDirectly ); KCrash::setFlags( KCrash::SaferDialog | KCrash::AlwaysDirectly );
// TODO: umount anything in /tmp/calamares-... as an emergency save function // TODO: umount anything in /tmp/calamares-... as an emergency save function
a.setApplicationDisplayName( QString() );
#endif #endif
handle_args( a ); handle_args( a );

View File

@ -76,10 +76,9 @@ ProgressTreeView::setModel( QAbstractItemModel* model )
QTreeView::setModel( model ); QTreeView::setModel( model );
expandAll(); expandAll();
connect( connect( Calamares::ViewManager::instance(),
Calamares::ViewManager::instance(), &Calamares::ViewManager::currentStepChanged,
&Calamares::ViewManager::currentStepChanged, this,
this, [this]() { viewport()->update(); },
[this]() { viewport()->update(); }, Qt::UniqueConnection );
Qt::UniqueConnection );
} }

View File

@ -120,6 +120,7 @@ target_link_libraries( calamares
LINK_PUBLIC LINK_PUBLIC
${YAMLCPP_LIBRARY} ${YAMLCPP_LIBRARY}
Qt5::Core Qt5::Core
KF5::CoreAddons
${OPTIONAL_PUBLIC_LIBRARIES} ${OPTIONAL_PUBLIC_LIBRARIES}
) )

View File

@ -52,6 +52,9 @@ variantToPyObject( const QVariant& variant )
case QVariant::Int: case QVariant::Int:
return bp::object( variant.toInt() ); return bp::object( variant.toInt() );
case QVariant::LongLong:
return bp::object( variant.toLongLong() );
case QVariant::Double: case QVariant::Double:
return bp::object( variant.toDouble() ); return bp::object( variant.toDouble() );

View File

@ -29,12 +29,22 @@ namespace Partition
static const NamedEnumTable< SizeUnit >& static const NamedEnumTable< SizeUnit >&
unitSuffixes() unitSuffixes()
{ {
// *INDENT-OFF*
// clang-format off
static const NamedEnumTable< SizeUnit > names { static const NamedEnumTable< SizeUnit > names {
{ QStringLiteral( "%" ), SizeUnit::Percent }, { QStringLiteral( "K" ), SizeUnit::KiB }, { QStringLiteral( "%" ), SizeUnit::Percent },
{ QStringLiteral( "KiB" ), SizeUnit::KiB }, { QStringLiteral( "M" ), SizeUnit::MiB }, { QStringLiteral( "K" ), SizeUnit::KiB },
{ QStringLiteral( "MiB" ), SizeUnit::MiB }, { QStringLiteral( "G" ), SizeUnit::GiB }, { QStringLiteral( "KiB" ), SizeUnit::KiB },
{ QStringLiteral( "GiB" ), SizeUnit::GiB } { QStringLiteral( "M" ), SizeUnit::MiB },
{ QStringLiteral( "MiB" ), SizeUnit::MiB },
{ QStringLiteral( "G" ), SizeUnit::GiB },
{ QStringLiteral( "GiB" ), SizeUnit::GiB },
{ QStringLiteral( "KB" ), SizeUnit::KB },
{ QStringLiteral( "MB" ), SizeUnit::MB },
{ QStringLiteral( "GB" ), SizeUnit::GB }
}; };
// clang-format on
// *INDENT-ON*
return names; return names;
} }
@ -50,7 +60,7 @@ PartitionSize::PartitionSize( const QString& s )
if ( m_unit == SizeUnit::None ) if ( m_unit == SizeUnit::None )
{ {
m_value = s.toInt(); m_value = s.toLongLong();
if ( m_value > 0 ) if ( m_value > 0 )
{ {
m_unit = SizeUnit::Byte; m_unit = SizeUnit::Byte;
@ -90,8 +100,11 @@ PartitionSize::toSectors( qint64 totalSectors, qint64 sectorSize ) const
return totalSectors * value() / 100; return totalSectors * value() / 100;
} }
case SizeUnit::Byte: case SizeUnit::Byte:
case SizeUnit::KB:
case SizeUnit::KiB: case SizeUnit::KiB:
case SizeUnit::MB:
case SizeUnit::MiB: case SizeUnit::MiB:
case SizeUnit::GB:
case SizeUnit::GiB: case SizeUnit::GiB:
return CalamaresUtils::bytesToSectors( toBytes(), sectorSize ); return CalamaresUtils::bytesToSectors( toBytes(), sectorSize );
} }
@ -125,8 +138,11 @@ PartitionSize::toBytes( qint64 totalSectors, qint64 sectorSize ) const
return totalSectors * value() / 100; return totalSectors * value() / 100;
} }
case SizeUnit::Byte: case SizeUnit::Byte:
case SizeUnit::KB:
case SizeUnit::KiB: case SizeUnit::KiB:
case SizeUnit::MB:
case SizeUnit::MiB: case SizeUnit::MiB:
case SizeUnit::GB:
case SizeUnit::GiB: case SizeUnit::GiB:
return toBytes(); return toBytes();
} }
@ -161,8 +177,11 @@ PartitionSize::toBytes( qint64 totalBytes ) const
return totalBytes * value() / 100; return totalBytes * value() / 100;
} }
case SizeUnit::Byte: case SizeUnit::Byte:
case SizeUnit::KB:
case SizeUnit::KiB: case SizeUnit::KiB:
case SizeUnit::MB:
case SizeUnit::MiB: case SizeUnit::MiB:
case SizeUnit::GB:
case SizeUnit::GiB: case SizeUnit::GiB:
return toBytes(); return toBytes();
} }
@ -186,10 +205,16 @@ PartitionSize::toBytes() const
return -1; return -1;
case SizeUnit::Byte: case SizeUnit::Byte:
return value(); return value();
case SizeUnit::KB:
return CalamaresUtils::KBtoBytes( static_cast< unsigned long long >( value() ) );
case SizeUnit::KiB: case SizeUnit::KiB:
return CalamaresUtils::KiBtoBytes( static_cast< unsigned long long >( value() ) ); return CalamaresUtils::KiBtoBytes( static_cast< unsigned long long >( value() ) );
case SizeUnit::MB:
return CalamaresUtils::MBtoBytes( static_cast< unsigned long long >( value() ) );
case SizeUnit::MiB: case SizeUnit::MiB:
return CalamaresUtils::MiBtoBytes( static_cast< unsigned long long >( value() ) ); return CalamaresUtils::MiBtoBytes( static_cast< unsigned long long >( value() ) );
case SizeUnit::GB:
return CalamaresUtils::GBtoBytes( static_cast< unsigned long long >( value() ) );
case SizeUnit::GiB: case SizeUnit::GiB:
return CalamaresUtils::GiBtoBytes( static_cast< unsigned long long >( value() ) ); return CalamaresUtils::GiBtoBytes( static_cast< unsigned long long >( value() ) );
} }
@ -211,8 +236,11 @@ PartitionSize::operator<( const PartitionSize& other ) const
case SizeUnit::Percent: case SizeUnit::Percent:
return ( m_value < other.m_value ); return ( m_value < other.m_value );
case SizeUnit::Byte: case SizeUnit::Byte:
case SizeUnit::KB:
case SizeUnit::KiB: case SizeUnit::KiB:
case SizeUnit::MB:
case SizeUnit::MiB: case SizeUnit::MiB:
case SizeUnit::GB:
case SizeUnit::GiB: case SizeUnit::GiB:
return ( toBytes() < other.toBytes() ); return ( toBytes() < other.toBytes() );
} }
@ -234,8 +262,11 @@ PartitionSize::operator>( const PartitionSize& other ) const
case SizeUnit::Percent: case SizeUnit::Percent:
return ( m_value > other.m_value ); return ( m_value > other.m_value );
case SizeUnit::Byte: case SizeUnit::Byte:
case SizeUnit::KB:
case SizeUnit::KiB: case SizeUnit::KiB:
case SizeUnit::MB:
case SizeUnit::MiB: case SizeUnit::MiB:
case SizeUnit::GB:
case SizeUnit::GiB: case SizeUnit::GiB:
return ( toBytes() > other.toBytes() ); return ( toBytes() > other.toBytes() );
} }
@ -257,8 +288,11 @@ PartitionSize::operator==( const PartitionSize& other ) const
case SizeUnit::Percent: case SizeUnit::Percent:
return ( m_value == other.m_value ); return ( m_value == other.m_value );
case SizeUnit::Byte: case SizeUnit::Byte:
case SizeUnit::KB:
case SizeUnit::KiB: case SizeUnit::KiB:
case SizeUnit::MB:
case SizeUnit::MiB: case SizeUnit::MiB:
case SizeUnit::GB:
case SizeUnit::GiB: case SizeUnit::GiB:
return ( toBytes() == other.toBytes() ); return ( toBytes() == other.toBytes() );
} }

View File

@ -36,8 +36,11 @@ enum class SizeUnit
None, None,
Percent, Percent,
Byte, Byte,
KB,
KiB, KiB,
MB,
MiB, MiB,
GB,
GiB GiB
}; };

View File

@ -58,7 +58,7 @@ public:
} }
/** @brief Specific value and unit. */ /** @brief Specific value and unit. */
NamedSuffix( int value, unit_t unit ) NamedSuffix( qint64 value, unit_t unit )
: m_value( value ) : m_value( value )
, m_unit( unit ) , m_unit( unit )
{ {
@ -75,7 +75,7 @@ public:
for ( const auto& suffix : table.table ) for ( const auto& suffix : table.table )
if ( s.endsWith( suffix.first ) ) if ( s.endsWith( suffix.first ) )
{ {
m_value = s.left( s.length() - suffix.first.length() ).toInt(); m_value = s.left( s.length() - suffix.first.length() ).toLongLong();
m_unit = suffix.second; m_unit = suffix.second;
break; break;
} }
@ -89,7 +89,7 @@ public:
*/ */
NamedSuffix( const QString& s ); NamedSuffix( const QString& s );
int value() const { return m_value; } qint64 value() const { return m_value; }
unit_t unit() const { return m_unit; } unit_t unit() const { return m_unit; }
/** @brief Check that a value-unit combination is valid. /** @brief Check that a value-unit combination is valid.
@ -100,7 +100,7 @@ public:
bool isValid() const; bool isValid() const;
protected: protected:
int m_value; qint64 m_value;
unit_t m_unit; unit_t m_unit;
}; };

View File

@ -1,127 +1,9 @@
/* === This file is part of Calamares - <https://github.com/calamares> === /* === This file is part of Calamares - <https://github.com/calamares> ===
* *
* Copyright 2015, Teo Mrnjavac <teo@kde.org> * Copyright 2019, Adriaan de Groot <groot@kde.org>
* Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
* *
* Based on KPluginFactory from KCoreAddons, KDE project
* Copyright 2007, Matthias Kretz <kretz@kde.org>
* Copyright 2007, Bernhard Loos <nhuh.put@web.de>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "PluginFactory.h" #include "PluginFactory.h"
#include "PluginFactory_p.h"
#include <QDebug> CalamaresPluginFactory::~CalamaresPluginFactory() {}
#include <QObjectCleanupHandler>
// *INDENT-OFF*
// clang-format off
Q_GLOBAL_STATIC( QObjectCleanupHandler, factorycleanup )
namespace Calamares
{
PluginFactory::PluginFactory()
: pd_ptr( new PluginFactoryPrivate )
{
pd_ptr->q_ptr = this;
factorycleanup()->add( this );
}
PluginFactory::PluginFactory( PluginFactoryPrivate& d )
: pd_ptr( &d )
{
factorycleanup()->add( this );
}
PluginFactory::~PluginFactory()
{
delete pd_ptr;
}
void PluginFactory::doRegisterPlugin( const QString& keyword, const QMetaObject* metaObject, CreateInstanceFunction instanceFunction )
{
Q_ASSERT( metaObject );
// we allow different interfaces to be registered without keyword
if ( !keyword.isEmpty() )
{
if ( pd_ptr->createInstanceHash.contains( keyword ) )
qWarning() << "A plugin with the keyword" << keyword << "was already registered. A keyword must be unique!";
pd_ptr->createInstanceHash.insert( keyword, PluginFactoryPrivate::Plugin( metaObject, instanceFunction ) );
}
else
{
const QList<PluginFactoryPrivate::Plugin> clashes( pd_ptr->createInstanceHash.values( keyword ) );
const QMetaObject* superClass = metaObject->superClass();
if ( superClass )
{
for ( const PluginFactoryPrivate::Plugin& plugin : clashes )
{
for ( const QMetaObject* otherSuper = plugin.first->superClass(); otherSuper;
otherSuper = otherSuper->superClass() )
{
if ( superClass == otherSuper )
qWarning() << "Two plugins with the same interface(" << superClass->className() << ") were registered. Use keywords to identify the plugins.";
}
}
}
for ( const PluginFactoryPrivate::Plugin& plugin : clashes )
{
superClass = plugin.first->superClass();
if ( superClass )
{
for ( const QMetaObject* otherSuper = metaObject->superClass(); otherSuper;
otherSuper = otherSuper->superClass() )
{
if ( superClass == otherSuper )
qWarning() << "Two plugins with the same interface(" << superClass->className() << ") were registered. Use keywords to identify the plugins.";
}
}
}
pd_ptr->createInstanceHash.insertMulti( keyword, PluginFactoryPrivate::Plugin( metaObject, instanceFunction ) );
}
}
QObject* PluginFactory::create( const char* iface, QWidget* parentWidget, QObject* parent, const QString& keyword )
{
QObject* obj = nullptr;
const QList<PluginFactoryPrivate::Plugin> candidates( pd_ptr->createInstanceHash.values( keyword ) );
// for !keyword.isEmpty() candidates.count() is 0 or 1
for ( const PluginFactoryPrivate::Plugin& plugin : candidates )
{
for ( const QMetaObject* current = plugin.first; current; current = current->superClass() )
{
if ( 0 == qstrcmp( iface, current->className() ) )
{
if ( obj )
qWarning() << "ambiguous interface requested from a DSO containing more than one plugin";
obj = plugin.second( parentWidget, parent );
break;
}
}
}
if ( obj )
emit objectCreated( obj );
return obj;
}
}

View File

@ -24,298 +24,84 @@
#ifndef UTILS_PLUGINFACTORY_H #ifndef UTILS_PLUGINFACTORY_H
#define UTILS_PLUGINFACTORY_H #define UTILS_PLUGINFACTORY_H
#include "DllMacro.h" #include <KF5/KCoreAddons/KPluginFactory>
#include <QtCore/QObject>
#include <QtCore/QStringList>
#include <QtCore/QVariant>
// *INDENT-OFF*
// clang-format off
namespace Calamares
{
class PluginFactoryPrivate;
}
#define CalamaresPluginFactory_iid "io.calamares.PluginFactory" #define CalamaresPluginFactory_iid "io.calamares.PluginFactory"
/** /** @brief Plugin factory for Calamares
* \relates PluginFactory
* *
* CALAMARES_PLUGIN_FACTORY_DECLARATION declares the PluginFactory subclass. This macro * Try to re-use KPluginFactory as much as possible (since the
* can be used in a header file. * old code for PluginFactory was a fork of an old version of
* exactly that).
* *
* \param name The name of the PluginFactory derived class. * The current createInstance() method passes more arguments
* * to the job and viewstep constructors than we want; chasing
* \see CALAMARES_PLUGIN_FACTORY * that change means modifying each Calamares module. This class
* \see CALAMARES_PLUGIN_FACTORY_DEFINITION * implements a version of createInstance() with fewer arguments
* and overloads registerPlugin() to use that.
*/ */
#define CALAMARES_PLUGIN_FACTORY_DECLARATION(name) \ class CalamaresPluginFactory : public KPluginFactory
class name : public Calamares::PluginFactory \
{ \
Q_OBJECT \
Q_INTERFACES(Calamares::PluginFactory) \
Q_PLUGIN_METADATA(IID CalamaresPluginFactory_iid) \
public: \
explicit name(); \
~name(); \
private: \
void init(); \
};
/**
* \relates PluginFactory
* CALAMARES_PLUGIN_FACTORY_DEFINITION defines the PluginFactory subclass. This macro
* can <b>not</b> be used in a header file.
*
* \param name The name of the PluginFactory derived class.
*
* \param pluginRegistrations Code to be inserted into the constructor of the
* class. Usually a series of registerPlugin() calls.
*
* \see CALAMARES_PLUGIN_FACTORY
* \see CALAMARES_PLUGIN_FACTORY_DECLARATION
*/
#define CALAMARES_PLUGIN_FACTORY_DEFINITION(name, pluginRegistrations) \
name::name() \
{ \
pluginRegistrations \
} \
name::~name() {}
namespace Calamares
{
/**
* \class PluginFactory PluginFactory.h <PluginFactory.h>
*
* PluginFactory provides a convenient way to provide factory-style plugins.
* Qt plugins provide a singleton object, but a common pattern is for plugins
* to generate as many objects of a particular type as the application requires.
* By using PluginFactory, you can avoid implementing the factory pattern
* yourself.
*
* PluginFactory also allows plugins to provide multiple different object
* types, indexed by keywords.
*
* The objects created by PluginFactory must inherit QObject, and must have a
* standard constructor pattern:
* \li if the object is a KPart::Part, it must be of the form
* \code
* T(QWidget *parentWidget, QObject *parent, const QVariantList &args)
* \endcode
* \li if it is a QWidget, it must be of the form
* \code
* T(QWidget *parent, const QVariantList &args)
* \endcode
* \li otherwise it must be of the form
* \code
* T(QObject *parent, const QVariantList &args)
* \endcode
*
* You should typically use CALAMARES_PLUGIN_FACTORY_DEFINITION() in your plugin code to
* create the factory. The pattern is
*
* \code
* #include "utils/PluginFactory.h"
*
* class MyPlugin : public PluginInterface
* {
* public:
* MyPlugin(QObject *parent, const QVariantList &args)
* : PluginInterface(parent)
* {}
* };
*
* CALAMARES_PLUGIN_FACTORY_DEFINITION(MyPluginFactory,
* registerPlugin<MyPlugin>();
* )
* \endcode
*
* If you want to load a library use KPluginLoader.
* The application that wants to instantiate plugin classes can do the following:
* \code
* PluginFactory *factory = KPluginLoader("libraryname").factory();
* if (factory) {
* PluginInterface *p1 = factory->create<PluginInterface>(parent);
* OtherInterface *p2 = factory->create<OtherInterface>(parent);
* NextInterface *p3 = factory->create<NextInterface>("keyword1", parent);
* NextInterface *p3 = factory->create<NextInterface>("keyword2", parent);
* }
* \endcode
*
* \author Matthias Kretz <kretz\@kde.org>
* \author Bernhard Loos <nhuh.put\@web.de>
*/
class DLLEXPORT PluginFactory : public QObject
{ {
Q_OBJECT Q_OBJECT
friend class PluginFactoryPrivate;
public: public:
/** explicit CalamaresPluginFactory()
* This constructor creates a factory for a plugin. : KPluginFactory()
*/
explicit PluginFactory();
/**
* This destroys the PluginFactory.
*/
virtual ~PluginFactory();
/**
* Use this method to create an object. It will try to create an object which inherits
* \p T. If it has multiple choices, you will get a fatal error (kFatal()), so be careful
* to request a unique interface or use keywords.
*
* \tparam T The interface for which an object should be created. The object will inherit \p T.
* \param parent The parent of the object. If \p parent is a widget type, it will also passed
* to the parentWidget argument of the CreateInstanceFunction for the object.
* \returns A pointer to the created object is returned, or 0 if an error occurred.
*/
template<typename T>
T* create( QObject* parent = nullptr );
/**
* Use this method to create an object. It will try to create an object which inherits
* \p T and was registered with \p keyword.
*
* \tparam T The interface for which an object should be created. The object will inherit \p T.
* \param keyword The keyword of the object.
* \param parent The parent of the object. If \p parent is a widget type, it will also passed
* to the parentWidget argument of the CreateInstanceFunction for the object.
* \returns A pointer to the created object is returned, or 0 if an error occurred.
*/
template<typename T>
T* create( const QString& keyword, QObject* parent = nullptr );
Q_SIGNALS:
void objectCreated( QObject* object );
protected:
/**
* Function pointer type to a function that instantiates a plugin.
*/
typedef QObject* ( *CreateInstanceFunction )( QWidget*, QObject* );
/**
* This is used to detect the arguments need for the constructor of plugin classes.
* You can inherit it, if you want to add new classes and still keep support for the old ones.
*/
template<class impl>
struct InheritanceChecker
{ {
CreateInstanceFunction createInstanceFunction( QWidget* )
{
return &createInstance<impl, QWidget>;
}
CreateInstanceFunction createInstanceFunction( ... )
{
return &createInstance<impl, QObject>;
}
};
explicit PluginFactory( PluginFactoryPrivate& dd );
/**
* Registers a plugin with the factory. Call this function from the constructor of the
* PluginFactory subclass to make the create function able to instantiate the plugin when asked
* for an interface the plugin implements.
*
* \tparam T the name of the plugin class
*
* \param keyword An optional keyword as unique identifier for the plugin. This allows you to
* put more than one plugin with the same interface into the same library using the same
* factory. X-KDE-PluginKeyword is a convenient way to specify the keyword in a desktop file.
*
* \param instanceFunction A function pointer to a function that creates an instance of the
* plugin. The default function that will be used depends on the type of interface. If the
* interface inherits from
* \li \c KParts::Part the function will call
* \code
* new T(QWidget *parentWidget, QObject *parent)
* \endcode
* \li \c QWidget the function will call
* \code
* new T(QWidget *parent)
* \endcode
* \li else the function will call
* \code
* new T(QObject *parent)
* \endcode
*/
template<class T>
void registerPlugin( const QString& keyword = QString(),
CreateInstanceFunction instanceFunction
= InheritanceChecker<T>().createInstanceFunction( reinterpret_cast<T*>( 0 ) ) )
{
doRegisterPlugin( keyword, &T::staticMetaObject, instanceFunction );
} }
~CalamaresPluginFactory() override;
PluginFactoryPrivate* const pd_ptr; /** @brief Create an object from the factory.
/**
* This function is called when the factory asked to create an Object.
* *
* You may reimplement it to provide a very flexible factory. This is especially useful to * Ignores all the @p args since they are not used. Calls
* provide generic factories for plugins implemeted using a scripting language. * Calamares constructors for the Jobs and ViewSteps.
*
* \param iface The staticMetaObject::className() string identifying the plugin interface that
* was requested. E.g. for KCModule plugins this string will be "KCModule".
* \param parentWidget Only used if the requested plugin is a KPart.
* \param parent The parent object for the plugin object.
* \param keyword A string that uniquely identifies the plugin. If a KService is used this
* keyword is read from the X-KDE-PluginKeyword entry in the .desktop file.
*/ */
virtual QObject* create( const char* iface, QWidget* parentWidget, QObject* parent, const QString& keyword ); template < class impl, class ParentType >
static QObject* createInstance( QWidget* parentWidget, QObject* parent, const QVariantList& args )
template<class impl, class ParentType>
static QObject* createInstance( QWidget* parentWidget, QObject* parent )
{ {
Q_UNUSED( parentWidget ) Q_UNUSED( parentWidget );
Q_UNUSED( args );
ParentType* p = nullptr; ParentType* p = nullptr;
if ( parent ) if ( parent )
{ {
p = qobject_cast<ParentType*>( parent ); p = qobject_cast< ParentType* >( parent );
Q_ASSERT( p ); Q_ASSERT( p );
} }
return new impl( p ); return new impl( p );
} }
private: /** @brief register a plugin
void doRegisterPlugin( const QString& keyword, const QMetaObject* metaObject, CreateInstanceFunction instanceFunction ); *
* The Calamares version doesn't accept keywords, and uses
* the Calamares createInstance() version which ignores
* the QVariantList of arguments.
*/
template < class T >
void registerPlugin()
{
KPluginFactory::registerPlugin< T >( QString(), &createInstance< T, QObject > );
}
}; };
template<typename T> /** @brief declare a Calamares Plugin Factory
inline T* PluginFactory::create( QObject* parent ) *
{ * This would be defined as K_PLUGIN_FACTORY_DECLARATION_WITH_BASEFACTORY,
QObject* o = create( T::staticMetaObject.className(), * except that does not actually use the base factory class that is
parent && parent->isWidgetType() ? reinterpret_cast<QWidget*>( parent ) : nullptr, * passed in.
parent, */
QString() ); #define CALAMARES_PLUGIN_FACTORY_DECLARATION( name ) \
class name : public CalamaresPluginFactory \
{ \
Q_OBJECT \
Q_INTERFACES( KPluginFactory ) \
Q_PLUGIN_METADATA( IID CalamaresPluginFactory_iid ) \
public: \
explicit name(); \
~name(); \
};
#define CALAMARES_PLUGIN_FACTORY_DEFINITION( name, pluginRegistrations ) \
K_PLUGIN_FACTORY_DEFINITION_WITH_BASEFACTORY( name, CalamaresPluginFactory, pluginRegistrations )
T* t = qobject_cast<T*>( o );
if ( !t )
delete o;
return t;
}
template<typename T> // Q_DECLARE_INTERFACE( Calamares::PluginFactory, CalamaresPluginFactory_iid )
inline T* PluginFactory::create( const QString& keyword, QObject* parent )
{
QObject* o = create( T::staticMetaObject.className(),
parent && parent->isWidgetType() ? reinterpret_cast<QWidget*>( parent ) : nullptr,
parent,
keyword );
T* t = qobject_cast<T*>( o );
if ( !t )
delete o;
return t;
}
} // namespace
Q_DECLARE_INTERFACE( Calamares::PluginFactory, CalamaresPluginFactory_iid )
#endif #endif

View File

@ -1,55 +0,0 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2015, Teo Mrnjavac <teo@kde.org>
*
* Based on KPluginFactory from KCoreAddons, KDE project
* Copyright 2007, Matthias Kretz <kretz@kde.org>
* Copyright 2007, Bernhard Loos <nhuh.put@web.de>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UTILS_PLUGINFACTORY_P_H
#define UTILS_PLUGINFACTORY_P_H
#include "PluginFactory.h"
#include <QtCore/QHash>
namespace Calamares
{
class PluginFactoryPrivate
{
Q_DECLARE_PUBLIC( PluginFactory )
protected:
typedef QPair< const QMetaObject*, PluginFactory::CreateInstanceFunction > Plugin;
PluginFactoryPrivate()
: catalogInitialized( false )
, q_ptr( nullptr )
{
}
~PluginFactoryPrivate() {}
QHash< QString, Plugin > createInstanceHash;
QString catalogName;
bool catalogInitialized;
PluginFactory* q_ptr;
};
} // namespace Calamares
#endif

View File

@ -25,54 +25,108 @@
namespace CalamaresUtils namespace CalamaresUtils
{ {
/** User defined literals, 1_KB is 1 KiloByte (= 10^3 bytes) */
constexpr qint64 operator""_KB( unsigned long long m )
{
return qint64( m ) * 1000;
}
/** User defined literals, 1_KiB is 1 KibiByte (= 2^10 bytes) */ /** User defined literals, 1_KiB is 1 KibiByte (= 2^10 bytes) */
constexpr qint64 operator""_KiB( unsigned long long m ) constexpr qint64 operator""_KiB( unsigned long long m )
{ {
return qint64( m ) * 1024; return qint64( m ) * 1024;
} }
/** User defined literals, 1_MB is 1 MegaByte (= 10^6 bytes) */
constexpr qint64 operator""_MB( unsigned long long m )
{
return operator""_KB(m)*1000;
}
/** User defined literals, 1_MiB is 1 MibiByte (= 2^20 bytes) */ /** User defined literals, 1_MiB is 1 MibiByte (= 2^20 bytes) */
constexpr qint64 operator""_MiB( unsigned long long m ) constexpr qint64 operator""_MiB( unsigned long long m )
{ {
return operator""_KiB(m)*1024; return operator""_KiB(m)*1024;
} }
/** User defined literals, 1_GB is 1 GigaByte (= 10^9 bytes) */
constexpr qint64 operator""_GB( unsigned long long m )
{
return operator""_MB(m)*1000;
}
/** User defined literals, 1_GiB is 1 GibiByte (= 2^30 bytes) */ /** User defined literals, 1_GiB is 1 GibiByte (= 2^30 bytes) */
constexpr qint64 operator""_GiB( unsigned long long m ) constexpr qint64 operator""_GiB( unsigned long long m )
{ {
return operator""_MiB(m)*1024; return operator""_MiB(m)*1024;
} }
constexpr qint64
KBtoBytes( unsigned long long m )
{
return operator""_KB( m );
}
constexpr qint64 constexpr qint64
KiBtoBytes( unsigned long long m ) KiBtoBytes( unsigned long long m )
{ {
return operator""_KiB( m ); return operator""_KiB( m );
} }
constexpr qint64
MBtoBytes( unsigned long long m )
{
return operator""_MB( m );
}
constexpr qint64 constexpr qint64
MiBtoBytes( unsigned long long m ) MiBtoBytes( unsigned long long m )
{ {
return operator""_MiB( m ); return operator""_MiB( m );
} }
constexpr qint64
GBtoBytes( unsigned long long m )
{
return operator""_GB( m );
}
constexpr qint64 constexpr qint64
GiBtoBytes( unsigned long long m ) GiBtoBytes( unsigned long long m )
{ {
return operator""_GiB( m ); return operator""_GiB( m );
} }
constexpr qint64
KBtoBytes( double m )
{
return qint64( m * 1000 );
}
constexpr qint64 constexpr qint64
KiBtoBytes( double m ) KiBtoBytes( double m )
{ {
return qint64( m * 1024 ); return qint64( m * 1024 );
} }
constexpr qint64
MBtoBytes( double m )
{
return qint64( m * 1000 * 1000 );
}
constexpr qint64 constexpr qint64
MiBtoBytes( double m ) MiBtoBytes( double m )
{ {
return qint64( m * 1024 * 1024 ); return qint64( m * 1024 * 1024 );
} }
constexpr qint64
GBtoBytes( double m )
{
return qint64( m * 1000 * 1000 * 1000 );
}
constexpr qint64 constexpr qint64
GiBtoBytes( double m ) GiBtoBytes( double m )
{ {

View File

@ -61,10 +61,10 @@ getString( const QVariantMap& map, const QString& key )
return QString(); return QString();
} }
int qint64
getInteger( const QVariantMap& map, const QString& key, int d ) getInteger( const QVariantMap& map, const QString& key, qint64 d )
{ {
int result = d; qint64 result = d;
if ( map.contains( key ) ) if ( map.contains( key ) )
{ {
auto v = map.value( key ); auto v = map.value( key );
@ -72,6 +72,10 @@ getInteger( const QVariantMap& map, const QString& key, int d )
{ {
result = v.toInt(); result = v.toInt();
} }
else if ( v.type() == QVariant::LongLong )
{
result = v.toLongLong();
}
} }
return result; return result;

View File

@ -41,7 +41,7 @@ DLLEXPORT QString getString( const QVariantMap& map, const QString& key );
/** /**
* Get an integer value from a mapping; returns @p d if no value. * Get an integer value from a mapping; returns @p d if no value.
*/ */
DLLEXPORT int getInteger( const QVariantMap& map, const QString& key, int d ); DLLEXPORT qint64 getInteger( const QVariantMap& map, const QString& key, qint64 d );
/** /**
* Get a double value from a mapping (integers are converted); returns @p d if no value. * Get a double value from a mapping (integers are converted); returns @p d if no value.

View File

@ -79,7 +79,7 @@ yamlScalarToVariant( const YAML::Node& scalarNode )
} }
if ( QRegExp( "[-+]?\\d+" ).exactMatch( scalarString ) ) if ( QRegExp( "[-+]?\\d+" ).exactMatch( scalarString ) )
{ {
return QVariant( scalarString.toInt() ); return QVariant( scalarString.toLongLong() );
} }
if ( QRegExp( "[-+]?\\d*\\.?\\d+" ).exactMatch( scalarString ) ) if ( QRegExp( "[-+]?\\d*\\.?\\d+" ).exactMatch( scalarString ) )
{ {

View File

@ -52,6 +52,8 @@ Branding::instance()
} }
// *INDENT-OFF*
// clang-format off
const QStringList Branding::s_stringEntryStrings = const QStringList Branding::s_stringEntryStrings =
{ {
"productName", "productName",
@ -82,15 +84,21 @@ const QStringList Branding::s_styleEntryStrings =
"sidebarTextSelect", "sidebarTextSelect",
"sidebarTextHighlight" "sidebarTextHighlight"
}; };
// clang-format on
// *INDENT-ON*
const NamedEnumTable<Branding::WindowDimensionUnit>& const NamedEnumTable<Branding::WindowDimensionUnit>&
Branding::WindowDimension::suffixes() Branding::WindowDimension::suffixes()
{ {
using Unit = Branding::WindowDimensionUnit; using Unit = Branding::WindowDimensionUnit;
// *INDENT-OFF*
// clang-format off
static const NamedEnumTable<Unit> names{ static const NamedEnumTable<Unit> names{
{"px", Unit::Pixies}, {"px", Unit::Pixies},
{"em", Unit::Fonties} {"em", Unit::Fonties}
}; };
// clang-format on
// *INDENT-ON*
return names; return names;
} }

View File

@ -25,13 +25,13 @@
#include "utils/NamedSuffix.h" #include "utils/NamedSuffix.h"
#include <QMap>
#include <QObject> #include <QObject>
#include <QStringList> #include <QStringList>
#include <QMap>
namespace YAML namespace YAML
{ {
class Node; class Node;
} }
namespace Calamares namespace Calamares
@ -79,27 +79,39 @@ public:
}; };
/** @brief Setting for how much the main window may expand. */ /** @brief Setting for how much the main window may expand. */
enum class WindowExpansion { Normal, Fullscreen, Fixed } ; enum class WindowExpansion
{
Normal,
Fullscreen,
Fixed
};
/** @brief Setting for the main window size. /** @brief Setting for the main window size.
* *
* The units are pixels (Pixies) or something-based-on-fontsize (Fonties), which * The units are pixels (Pixies) or something-based-on-fontsize (Fonties), which
* we suffix as "em", e.g. "600px" or "32em". * we suffix as "em", e.g. "600px" or "32em".
*/ */
enum class WindowDimensionUnit { None, Pixies, Fonties }; enum class WindowDimensionUnit
class WindowDimension : public NamedSuffix<WindowDimensionUnit, WindowDimensionUnit::None> {
None,
Pixies,
Fonties
};
class WindowDimension : public NamedSuffix< WindowDimensionUnit, WindowDimensionUnit::None >
{ {
public: public:
static const NamedEnumTable< WindowDimensionUnit >& suffixes(); static const NamedEnumTable< WindowDimensionUnit >& suffixes();
bool isValid() const; bool isValid() const;
using NamedSuffix::NamedSuffix; using NamedSuffix::NamedSuffix;
WindowDimension( const QString& s ) : NamedSuffix( suffixes(), s ) {} WindowDimension( const QString& s )
} ; : NamedSuffix( suffixes(), s )
{
}
};
static Branding* instance(); static Branding* instance();
explicit Branding( const QString& brandingFilePath, explicit Branding( const QString& brandingFilePath, QObject* parent = nullptr );
QObject* parent = nullptr );
/** @brief Complete path of the branding descriptor file. */ /** @brief Complete path of the branding descriptor file. */
QString descriptorPath() const { return m_descriptorPath; } QString descriptorPath() const { return m_descriptorPath; }
@ -184,11 +196,14 @@ private:
WindowExpansion m_windowExpansion; WindowExpansion m_windowExpansion;
WindowDimension m_windowHeight, m_windowWidth; WindowDimension m_windowHeight, m_windowWidth;
}; };
template<typename U> inline QString operator*(U e) { return Branding::instance()->string( e ); } template < typename U >
inline QString operator*( U e )
{
return Branding::instance()->string( e );
} }
#endif // BRANDING_H } // namespace Calamares
#endif // BRANDING_H

View File

@ -75,8 +75,6 @@ calamares_add_library( calamaresui
VERSION ${CALAMARES_VERSION_SHORT} VERSION ${CALAMARES_VERSION_SHORT}
) )
find_package( KF5CoreAddons 5.58 QUIET ) # If it's really new if ( KF5CoreAddons_FOUND AND KF5CoreAddons_VERSION VERSION_GREATER_EQUAL 5.58 )
if ( KF5CoreAddons_FOUND )
target_compile_definitions( calamaresui PRIVATE WITH_KOSRelease ) target_compile_definitions( calamaresui PRIVATE WITH_KOSRelease )
target_link_libraries( calamaresui PRIVATE KF5::CoreAddons )
endif() endif()

View File

@ -23,10 +23,10 @@
#include "Branding.h" #include "Branding.h"
#include "Job.h" #include "Job.h"
#include "JobQueue.h" #include "JobQueue.h"
#include "modulesystem/Module.h"
#include "modulesystem/ModuleManager.h"
#include "Settings.h" #include "Settings.h"
#include "ViewManager.h" #include "ViewManager.h"
#include "modulesystem/Module.h"
#include "modulesystem/ModuleManager.h"
#include "utils/CalamaresUtilsGui.h" #include "utils/CalamaresUtilsGui.h"
#include "utils/Dirs.h" #include "utils/Dirs.h"
@ -56,7 +56,7 @@ callQMLFunction( QQuickItem* qmlObject, const char* method )
QByteArray methodSignature( method ); QByteArray methodSignature( method );
methodSignature.append( "()" ); methodSignature.append( "()" );
if ( qmlObject && qmlObject->metaObject()->indexOfMethod( methodSignature ) >= 0 ) if ( qmlObject && qmlObject->metaObject()->indexOfMethod( methodSignature ) >= 0 )
{ {
QVariant returnValue; QVariant returnValue;
QMetaObject::invokeMethod( qmlObject, method, Q_RETURN_ARG( QVariant, returnValue ) ); QMetaObject::invokeMethod( qmlObject, method, Q_RETURN_ARG( QVariant, returnValue ) );
@ -117,9 +117,7 @@ ExecutionViewStep::ExecutionViewStep( QObject* parent )
QString QString
ExecutionViewStep::prettyName() const ExecutionViewStep::prettyName() const
{ {
return Calamares::Settings::instance()->isSetupMode() return Calamares::Settings::instance()->isSetupMode() ? tr( "Set up" ) : tr( "Install" );
? tr( "Set up" )
: tr( "Install" );
} }
@ -176,8 +174,7 @@ ExecutionViewStep::loadQmlV2()
{ {
m_qmlComponent = new QQmlComponent( m_qmlShow->engine(), m_qmlComponent = new QQmlComponent( m_qmlShow->engine(),
QUrl::fromLocalFile( Calamares::Branding::instance()->slideshowPath() ), QUrl::fromLocalFile( Calamares::Branding::instance()->slideshowPath() ),
QQmlComponent::CompilationMode::Asynchronous QQmlComponent::CompilationMode::Asynchronous );
);
connect( m_qmlComponent, &QQmlComponent::statusChanged, this, &ExecutionViewStep::loadQmlV2Complete ); connect( m_qmlComponent, &QQmlComponent::statusChanged, this, &ExecutionViewStep::loadQmlV2Complete );
} }
} }
@ -194,14 +191,17 @@ ExecutionViewStep::loadQmlV2Complete()
QObject* o = m_qmlComponent->create(); QObject* o = m_qmlComponent->create();
m_qmlObject = qobject_cast< QQuickItem* >( o ); m_qmlObject = qobject_cast< QQuickItem* >( o );
if ( !m_qmlObject ) if ( !m_qmlObject )
{
delete o; delete o;
}
else else
{ {
// setContent() is public API, but not documented publicly. // setContent() is public API, but not documented publicly.
// It is marked \internal in the Qt sources, but does exactly // It is marked \internal in the Qt sources, but does exactly
// what is needed: sets up visual parent by replacing the root // what is needed: sets up visual parent by replacing the root
// item, and handling resizes. // item, and handling resizes.
m_qmlShow->setContent( QUrl::fromLocalFile( Calamares::Branding::instance()->slideshowPath() ), m_qmlComponent, m_qmlObject ); m_qmlShow->setContent(
QUrl::fromLocalFile( Calamares::Branding::instance()->slideshowPath() ), m_qmlComponent, m_qmlObject );
if ( ViewManager::instance()->currentStep() == this ) if ( ViewManager::instance()->currentStep() == this )
{ {
// We're alreay visible! Must have been slow QML loading, and we // We're alreay visible! Must have been slow QML loading, and we
@ -235,8 +235,10 @@ ExecutionViewStep::onActivate()
auto jl = module->jobs(); auto jl = module->jobs();
if ( module->isEmergency() ) if ( module->isEmergency() )
{ {
for( auto& j : jl ) for ( auto& j : jl )
{
j->setEmergency( true ); j->setEmergency( true );
}
} }
queue->enqueue( jl ); queue->enqueue( jl );
} }
@ -279,4 +281,4 @@ ExecutionViewStep::onLeave()
} }
} }
} // namespace } // namespace Calamares

View File

@ -77,6 +77,6 @@ private:
void updateFromJobQueue( qreal percent, const QString& message ); void updateFromJobQueue( qreal percent, const QString& message );
}; };
} } // namespace Calamares
#endif /* EXECUTIONVIEWSTEP_H */ #endif /* EXECUTIONVIEWSTEP_H */

View File

@ -22,11 +22,11 @@
#include <QtCore/qglobal.h> #include <QtCore/qglobal.h>
#ifndef UIDLLEXPORT #ifndef UIDLLEXPORT
# if defined (UIDLLEXPORT_PRO) #if defined( UIDLLEXPORT_PRO )
# define UIDLLEXPORT Q_DECL_EXPORT #define UIDLLEXPORT Q_DECL_EXPORT
# else #else
# define UIDLLEXPORT Q_DECL_IMPORT #define UIDLLEXPORT Q_DECL_IMPORT
# endif #endif
#endif #endif
#endif #endif

View File

@ -7,6 +7,7 @@
<file alias="images/bugs.svg">../../data/images/bugs.svg</file> <file alias="images/bugs.svg">../../data/images/bugs.svg</file>
<file alias="images/help.svg">../../data/images/help.svg</file> <file alias="images/help.svg">../../data/images/help.svg</file>
<file alias="images/release.svg">../../data/images/release.svg</file> <file alias="images/release.svg">../../data/images/release.svg</file>
<file alias="images/donate.svg">../../data/images/help-donate.svg</file>
<file alias="images/partition-disk.svg">../../data/images/partition-disk.svg</file> <file alias="images/partition-disk.svg">../../data/images/partition-disk.svg</file>
<file alias="images/partition-partition.svg">../../data/images/partition-partition.svg</file> <file alias="images/partition-partition.svg">../../data/images/partition-partition.svg</file>
<file alias="images/partition-alongside.svg">../../data/images/partition-alongside.svg</file> <file alias="images/partition-alongside.svg">../../data/images/partition-alongside.svg</file>

View File

@ -49,7 +49,7 @@ CppJobModule::loadSelf()
{ {
if ( m_loader ) if ( m_loader )
{ {
PluginFactory* pf = qobject_cast< PluginFactory* >( m_loader->instance() ); CalamaresPluginFactory* pf = qobject_cast< CalamaresPluginFactory* >( m_loader->instance() );
if ( !pf ) if ( !pf )
{ {
cDebug() << Q_FUNC_INFO << m_loader->errorString(); cDebug() << Q_FUNC_INFO << m_loader->errorString();

View File

@ -77,7 +77,9 @@ ProcessJobModule::initFrom( const QVariantMap& moduleDescriptor )
{ {
int sec = moduleDescriptor.value( "timeout" ).toInt(); int sec = moduleDescriptor.value( "timeout" ).toInt();
if ( sec < 0 ) if ( sec < 0 )
{
sec = 0; sec = 0;
}
m_secondsTimeout = std::chrono::seconds( sec ); m_secondsTimeout = std::chrono::seconds( sec );
} }

View File

@ -151,8 +151,7 @@ RequirementsChecker::reportProgress()
m_progressTimeouts++; m_progressTimeouts++;
QStringList remainingNames; QStringList remainingNames;
auto remaining = std::count_if( m_watchers.cbegin(), m_watchers.cend(), auto remaining = std::count_if( m_watchers.cbegin(), m_watchers.cend(), [&]( const Watcher* w ) {
[&]( const Watcher* w ) {
if ( w && !w->isFinished() ) if ( w && !w->isFinished() )
{ {
remainingNames << w->objectName(); remainingNames << w->objectName();

View File

@ -50,7 +50,7 @@ ViewModule::loadSelf()
{ {
if ( m_loader ) if ( m_loader )
{ {
PluginFactory* pf = qobject_cast< PluginFactory* >( m_loader->instance() ); CalamaresPluginFactory* pf = qobject_cast< CalamaresPluginFactory* >( m_loader->instance() );
if ( !pf ) if ( !pf )
{ {
cWarning() << Q_FUNC_INFO << "No factory:" << m_loader->errorString(); cWarning() << Q_FUNC_INFO << "No factory:" << m_loader->errorString();

View File

@ -34,11 +34,10 @@
namespace CalamaresUtils namespace CalamaresUtils
{ {
static int s_defaultFontSize = 0; static int s_defaultFontSize = 0;
static int s_defaultFontHeight = 0; static int s_defaultFontHeight = 0;
QPixmap QPixmap
defaultPixmap( ImageType type, ImageMode mode, const QSize& size ) defaultPixmap( ImageType type, ImageMode mode, const QSize& size )
{ {
@ -75,6 +74,10 @@ defaultPixmap( ImageType type, ImageMode mode, const QSize& size )
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/release.svg", size ); pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/release.svg", size );
break; break;
case Donate:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/donate.svg", size );
break;
case PartitionDisk: case PartitionDisk:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/partition-disk.svg", size ); pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/partition-disk.svg", size );
break; break;
@ -152,11 +155,15 @@ createRoundedImage( const QPixmap& pixmap, const QSize& size, float frameWidthPc
} }
if ( !height || !width ) if ( !height || !width )
{
return QPixmap(); return QPixmap();
}
QPixmap scaledAvatar = pixmap.scaled( width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ); QPixmap scaledAvatar = pixmap.scaled( width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
if ( frameWidthPct == 0.00f ) if ( frameWidthPct == 0.00f )
{
return scaledAvatar; return scaledAvatar;
}
QPixmap frame( width, height ); QPixmap frame( width, height );
frame.fill( Qt::transparent ); frame.fill( Qt::transparent );
@ -172,7 +179,8 @@ createRoundedImage( const QPixmap& pixmap, const QSize& size, float frameWidthPc
painter.setBrush( brush ); painter.setBrush( brush );
painter.setPen( pen ); painter.setPen( pen );
painter.drawRoundedRect( outerRect, qreal( frameWidthPct ) * 100.0, qreal( frameWidthPct ) * 100.0, Qt::RelativeSize ); painter.drawRoundedRect(
outerRect, qreal( frameWidthPct ) * 100.0, qreal( frameWidthPct ) * 100.0, Qt::RelativeSize );
return frame; return frame;
} }
@ -189,7 +197,9 @@ unmarginLayout( QLayout* layout )
{ {
QLayout* childLayout = layout->itemAt( i )->layout(); QLayout* childLayout = layout->itemAt( i )->layout();
if ( childLayout ) if ( childLayout )
{
unmarginLayout( childLayout ); unmarginLayout( childLayout );
}
} }
} }
@ -255,13 +265,17 @@ clearLayout( QLayout* layout )
while ( QLayoutItem* item = layout->takeAt( 0 ) ) while ( QLayoutItem* item = layout->takeAt( 0 ) )
{ {
if ( QWidget* widget = item->widget() ) if ( QWidget* widget = item->widget() )
{
widget->deleteLater(); widget->deleteLater();
}
if ( QLayout* childLayout = item->layout() ) if ( QLayout* childLayout = item->layout() )
{
clearLayout( childLayout ); clearLayout( childLayout );
}
delete item; delete item;
} }
} }
} // namespace } // namespace CalamaresUtils

View File

@ -47,6 +47,7 @@ enum ImageType : int
Bugs, Bugs,
Help, Help,
Release, Release,
Donate,
PartitionDisk, PartitionDisk,
PartitionPartition, PartitionPartition,
PartitionAlongside, PartitionAlongside,
@ -56,7 +57,7 @@ enum ImageType : int
PartitionTable, PartitionTable,
BootEnvironment, BootEnvironment,
Squid, Squid,
StatusOk, // Icons for the requirements checker StatusOk, // Icons for the requirements checker
StatusWarning, StatusWarning,
StatusError StatusError
}; };
@ -94,9 +95,7 @@ UIDLLEXPORT QPixmap defaultPixmap( ImageType type,
* @return the transformed pixmap. * @return the transformed pixmap.
* This one is currently unused. * This one is currently unused.
*/ */
UIDLLEXPORT QPixmap createRoundedImage( const QPixmap& avatar, UIDLLEXPORT QPixmap createRoundedImage( const QPixmap& avatar, const QSize& size, float frameWidthPct = 0.20f );
const QSize& size,
float frameWidthPct = 0.20f );
/** /**
* @brief unmarginLayout recursively walks the QLayout tree and removes all margins. * @brief unmarginLayout recursively walks the QLayout tree and removes all margins.
@ -112,8 +111,8 @@ UIDLLEXPORT void unmarginLayout( QLayout* layout );
UIDLLEXPORT void clearLayout( QLayout* layout ); UIDLLEXPORT void clearLayout( QLayout* layout );
UIDLLEXPORT void setDefaultFontSize( int points ); UIDLLEXPORT void setDefaultFontSize( int points );
UIDLLEXPORT int defaultFontSize(); // in points UIDLLEXPORT int defaultFontSize(); // in points
UIDLLEXPORT int defaultFontHeight(); // in pixels, DPI-specific UIDLLEXPORT int defaultFontHeight(); // in pixels, DPI-specific
UIDLLEXPORT QFont defaultFont(); UIDLLEXPORT QFont defaultFont();
UIDLLEXPORT QFont largeFont(); UIDLLEXPORT QFont largeFont();
UIDLLEXPORT QSize defaultIconSize(); UIDLLEXPORT QSize defaultIconSize();
@ -128,4 +127,4 @@ constexpr int windowPreferredHeight = 520;
} // namespace CalamaresUtils } // namespace CalamaresUtils
#endif // CALAMARESUTILSGUI_H #endif // CALAMARESUTILSGUI_H

View File

@ -2,7 +2,7 @@
* *
* SPDX-License-Identifier: GPLv3+ * SPDX-License-Identifier: GPLv3+
* License-Filename: LICENSES/GPLv3+-ImageRegistry * License-Filename: LICENSES/GPLv3+-ImageRegistry
* *
* Copyright 2019, Adriaan de Groot <groot@kde.org> * Copyright 2019, Adriaan de Groot <groot@kde.org>
*/ */

View File

@ -2,7 +2,7 @@
* *
* SPDX-License-Identifier: GPLv3+ * SPDX-License-Identifier: GPLv3+
* License-Filename: LICENSES/GPLv3+-ImageRegistry * License-Filename: LICENSES/GPLv3+-ImageRegistry
* *
* Copyright 2019, Adriaan de Groot <groot@kde.org> * Copyright 2019, Adriaan de Groot <groot@kde.org>
*/ */

View File

@ -34,11 +34,13 @@ lookupAndCall( PyObject* object,
{ {
PythonQtObjectPtr callable = PythonQt::self()->lookupCallable( object, name ); PythonQtObjectPtr callable = PythonQt::self()->lookupCallable( object, name );
if ( callable ) if ( callable )
{
return callable.call( args, kwargs ); return callable.call( args, kwargs );
}
} }
// If we haven't found a callable with the given names, we force an error: // If we haven't found a callable with the given names, we force an error:
return PythonQt::self()->call( object, candidateNames.first(), args, kwargs ); return PythonQt::self()->call( object, candidateNames.first(), args, kwargs );
} }
} } // namespace CalamaresUtils

View File

@ -33,6 +33,6 @@ QVariant lookupAndCall( PyObject* object,
const QVariantList& args = QVariantList(), const QVariantList& args = QVariantList(),
const QVariantMap& kwargs = QVariantMap() ); const QVariantMap& kwargs = QVariantMap() );
} //ns } // namespace CalamaresUtils
#endif // PYTHONQTUTILS_H #endif // PYTHONQTUTILS_H

View File

@ -26,7 +26,10 @@
namespace Calamares namespace Calamares
{ {
BlankViewStep::BlankViewStep( const QString& title, const QString& description, const QString& details, QObject* parent) BlankViewStep::BlankViewStep( const QString& title,
const QString& description,
const QString& details,
QObject* parent )
: Calamares::ViewStep( parent ) : Calamares::ViewStep( parent )
, m_widget( new QWidget() ) , m_widget( new QWidget() )
{ {
@ -54,14 +57,12 @@ BlankViewStep::BlankViewStep( const QString& title, const QString& description,
layout->addWidget( label ); layout->addWidget( label );
} }
layout->addStretch( 1 ); // Push the rest to the top layout->addStretch( 1 ); // Push the rest to the top
m_widget->setLayout( layout ); m_widget->setLayout( layout );
} }
BlankViewStep::~BlankViewStep() BlankViewStep::~BlankViewStep() {}
{
}
QString QString
BlankViewStep::prettyName() const BlankViewStep::prettyName() const
@ -115,4 +116,4 @@ BlankViewStep::jobs() const
return JobList(); return JobList();
} }
} // namespace } // namespace Calamares

View File

@ -39,7 +39,10 @@ class BlankViewStep : public Calamares::ViewStep
Q_OBJECT Q_OBJECT
public: public:
explicit BlankViewStep( const QString& title, const QString& description, const QString& details = QString(), QObject* parent = nullptr ); explicit BlankViewStep( const QString& title,
const QString& description,
const QString& details = QString(),
QObject* parent = nullptr );
virtual ~BlankViewStep() override; virtual ~BlankViewStep() override;
QString prettyName() const override; QString prettyName() const override;
@ -61,5 +64,5 @@ private:
QWidget* m_widget; QWidget* m_widget;
}; };
} // namespace } // namespace Calamares
#endif // BLANKVIEWSTEP_H #endif // BLANKVIEWSTEP_H

View File

@ -24,7 +24,8 @@
GlobalStorage::GlobalStorage( Calamares::GlobalStorage* gs ) GlobalStorage::GlobalStorage( Calamares::GlobalStorage* gs )
: QObject( gs ) : QObject( gs )
, m_gs( gs ) , m_gs( gs )
{} {
}
bool bool

View File

@ -54,4 +54,4 @@ private:
Calamares::GlobalStorage* m_gs; Calamares::GlobalStorage* m_gs;
}; };
#endif // PYTHONQTGLOBALSTORAGEWRAPPER_H #endif // PYTHONQTGLOBALSTORAGEWRAPPER_H

View File

@ -20,34 +20,26 @@
#include "utils/PythonQtUtils.h" #include "utils/PythonQtUtils.h"
PythonQtJob::PythonQtJob( PythonQtObjectPtr cxt, PythonQtJob::PythonQtJob( PythonQtObjectPtr cxt, PythonQtObjectPtr pyJob, QObject* parent )
PythonQtObjectPtr pyJob,
QObject* parent )
: Calamares::Job( parent ) : Calamares::Job( parent )
, m_cxt( cxt ) , m_cxt( cxt )
, m_pyJob( pyJob ) , m_pyJob( pyJob )
{ {
} }
QString QString
PythonQtJob::prettyName() const PythonQtJob::prettyName() const
{ {
return CalamaresUtils::lookupAndCall( m_pyJob, return CalamaresUtils::lookupAndCall( m_pyJob, { "prettyName", "prettyname", "pretty_name" } ).toString();
{ "prettyName",
"prettyname",
"pretty_name" } ).toString();
} }
QString QString
PythonQtJob::prettyDescription() const PythonQtJob::prettyDescription() const
{ {
return CalamaresUtils::lookupAndCall( m_pyJob, return CalamaresUtils::lookupAndCall( m_pyJob, { "prettyDescription", "prettydescription", "pretty_description" } )
{ "prettyDescription", .toString();
"prettydescription",
"pretty_description" } ).toString();
} }
@ -55,9 +47,8 @@ QString
PythonQtJob::prettyStatusMessage() const PythonQtJob::prettyStatusMessage() const
{ {
return CalamaresUtils::lookupAndCall( m_pyJob, return CalamaresUtils::lookupAndCall( m_pyJob,
{ "prettyStatusMessage", { "prettyStatusMessage", "prettystatusmessage", "pretty_status_message" } )
"prettystatusmessage", .toString();
"pretty_status_message" } ).toString();
} }
@ -66,12 +57,15 @@ PythonQtJob::exec()
{ {
QVariant response = m_pyJob.call( "exec" ); QVariant response = m_pyJob.call( "exec" );
if ( response.isNull() ) if ( response.isNull() )
{
return Calamares::JobResult::ok(); return Calamares::JobResult::ok();
}
QVariantMap map = response.toMap(); QVariantMap map = response.toMap();
if ( map.isEmpty() || map.value( "ok" ).toBool() ) if ( map.isEmpty() || map.value( "ok" ).toBool() )
{
return Calamares::JobResult::ok(); return Calamares::JobResult::ok();
}
return Calamares::JobResult::error( map.value( "message" ).toString(), return Calamares::JobResult::error( map.value( "message" ).toString(), map.value( "details" ).toString() );
map.value( "details" ).toString() );
} }

View File

@ -32,12 +32,11 @@ class PythonQtJobResult : public QObject, public Calamares::JobResult
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit PythonQtJobResult( bool ok, explicit PythonQtJobResult( bool ok, const QString& message, const QString& details )
const QString& message,
const QString& details )
: QObject( nullptr ) : QObject( nullptr )
, Calamares::JobResult( message, details, ok ? 0 : Calamares::JobResult::GenericError ) , Calamares::JobResult( message, details, ok ? 0 : Calamares::JobResult::GenericError )
{} {
}
}; };
@ -53,13 +52,11 @@ public:
Calamares::JobResult exec() override; Calamares::JobResult exec() override;
private: private:
explicit PythonQtJob( PythonQtObjectPtr cxt, explicit PythonQtJob( PythonQtObjectPtr cxt, PythonQtObjectPtr pyJob, QObject* parent = nullptr );
PythonQtObjectPtr pyJob, friend class Calamares::PythonQtViewStep; // only this one can call the ctor
QObject* parent = nullptr );
friend class Calamares::PythonQtViewStep; // only this one can call the ctor
PythonQtObjectPtr m_cxt; PythonQtObjectPtr m_cxt;
PythonQtObjectPtr m_pyJob; PythonQtObjectPtr m_pyJob;
}; };
#endif // PYTHONQTJOB_H #endif // PYTHONQTJOB_H

View File

@ -25,7 +25,7 @@
#include <PythonQt.h> #include <PythonQt.h>
Utils::Utils(QObject* parent) Utils::Utils( QObject* parent )
: QObject( parent ) : QObject( parent )
, m_exceptionCxt( PythonQt::self()->createUniqueModule() ) , m_exceptionCxt( PythonQt::self()->createUniqueModule() )
{ {
@ -34,7 +34,7 @@ Utils::Utils(QObject* parent)
void void
Utils::debug(const QString& s) const Utils::debug( const QString& s ) const
{ {
cDebug() << "PythonQt DBG>" << s; cDebug() << "PythonQt DBG>" << s;
} }
@ -46,35 +46,28 @@ Utils::mount( const QString& device_path,
const QString& filesystem_name, const QString& filesystem_name,
const QString& options ) const const QString& options ) const
{ {
return CalamaresUtils::System::instance()-> return CalamaresUtils::System::instance()->mount( device_path, mount_point, filesystem_name, options );
mount( device_path, mount_point, filesystem_name, options );
} }
int int
Utils::target_env_call( const QString& command, Utils::target_env_call( const QString& command, const QString& stdin, int timeout ) const
const QString& stdin,
int timeout ) const
{ {
return CalamaresUtils::System::instance()-> return CalamaresUtils::System::instance()->targetEnvCall(
targetEnvCall( command, QString(), stdin, std::chrono::seconds( timeout > 0 ? timeout : 0 ) ); command, QString(), stdin, std::chrono::seconds( timeout > 0 ? timeout : 0 ) );
} }
int int
Utils::target_env_call( const QStringList& args, Utils::target_env_call( const QStringList& args, const QString& stdin, int timeout ) const
const QString& stdin,
int timeout ) const
{ {
return CalamaresUtils::System::instance()-> return CalamaresUtils::System::instance()->targetEnvCall(
targetEnvCall( args, QString(), stdin, std::chrono::seconds( timeout > 0 ? timeout : 0 ) ); args, QString(), stdin, std::chrono::seconds( timeout > 0 ? timeout : 0 ) );
} }
int int
Utils::check_target_env_call( const QString& command, Utils::check_target_env_call( const QString& command, const QString& stdin, int timeout ) const
const QString& stdin,
int timeout ) const
{ {
int ec = target_env_call( command, stdin, timeout ); int ec = target_env_call( command, stdin, timeout );
return _handle_check_target_env_call_error( ec, command ); return _handle_check_target_env_call_error( ec, command );
@ -82,9 +75,7 @@ Utils::check_target_env_call( const QString& command,
int int
Utils::check_target_env_call( const QStringList& args, Utils::check_target_env_call( const QStringList& args, const QString& stdin, int timeout ) const
const QString& stdin,
int timeout) const
{ {
int ec = target_env_call( args, stdin, timeout ); int ec = target_env_call( args, stdin, timeout );
return _handle_check_target_env_call_error( ec, args.join( ' ' ) ); return _handle_check_target_env_call_error( ec, args.join( ' ' ) );
@ -92,34 +83,22 @@ Utils::check_target_env_call( const QStringList& args,
QString QString
Utils::check_target_env_output( const QString& command, Utils::check_target_env_output( const QString& command, const QString& stdin, int timeout ) const
const QString& stdin,
int timeout ) const
{ {
QString output; QString output;
int ec = CalamaresUtils::System::instance()-> int ec = CalamaresUtils::System::instance()->targetEnvOutput(
targetEnvOutput( command, command, output, QString(), stdin, std::chrono::seconds( timeout > 0 ? timeout : 0 ) );
output,
QString(),
stdin,
std::chrono::seconds( timeout > 0 ? timeout : 0 ) );
_handle_check_target_env_call_error( ec, command ); _handle_check_target_env_call_error( ec, command );
return output; return output;
} }
QString QString
Utils::check_target_env_output( const QStringList& args, Utils::check_target_env_output( const QStringList& args, const QString& stdin, int timeout ) const
const QString& stdin,
int timeout ) const
{ {
QString output; QString output;
int ec = CalamaresUtils::System::instance()-> int ec = CalamaresUtils::System::instance()->targetEnvOutput(
targetEnvOutput( args, args, output, QString(), stdin, std::chrono::seconds( timeout > 0 ? timeout : 0 ) );
output,
QString(),
stdin,
std::chrono::seconds( timeout > 0 ? timeout : 0 ) );
_handle_check_target_env_call_error( ec, args.join( ' ' ) ); _handle_check_target_env_call_error( ec, args.join( ' ' ) );
return output; return output;
} }
@ -133,13 +112,11 @@ Utils::obscure( const QString& string ) const
int int
Utils::_handle_check_target_env_call_error( int ec, const QString& cmd) const Utils::_handle_check_target_env_call_error( int ec, const QString& cmd ) const
{ {
if ( ec ) if ( ec )
{ {
QString raise = QString( "raise subprocess.CalledProcessError(%1,\"%2\")" ) QString raise = QString( "raise subprocess.CalledProcessError(%1,\"%2\")" ).arg( ec ).arg( cmd );
.arg( ec )
.arg( cmd );
PythonQt::self()->evalScript( m_exceptionCxt, raise ); PythonQt::self()->evalScript( m_exceptionCxt, raise );
} }
return ec; return ec;

View File

@ -43,29 +43,17 @@ public slots:
const QString& filesystem_name, const QString& filesystem_name,
const QString& options ) const; const QString& options ) const;
int target_env_call( const QString& command, int target_env_call( const QString& command, const QString& stdin = QString(), int timeout = 0 ) const;
const QString& stdin = QString(),
int timeout = 0 ) const;
int target_env_call( const QStringList& args, int target_env_call( const QStringList& args, const QString& stdin = QString(), int timeout = 0 ) const;
const QString& stdin = QString(),
int timeout = 0 ) const;
int check_target_env_call( const QString& command, int check_target_env_call( const QString& command, const QString& stdin = QString(), int timeout = 0 ) const;
const QString& stdin = QString(),
int timeout = 0 ) const;
int check_target_env_call( const QStringList& args, int check_target_env_call( const QStringList& args, const QString& stdin = QString(), int timeout = 0 ) const;
const QString& stdin = QString(),
int timeout = 0 ) const;
QString check_target_env_output( const QString& command, QString check_target_env_output( const QString& command, const QString& stdin = QString(), int timeout = 0 ) const;
const QString& stdin = QString(),
int timeout = 0 ) const;
QString check_target_env_output( const QStringList& args, QString check_target_env_output( const QStringList& args, const QString& stdin = QString(), int timeout = 0 ) const;
const QString& stdin = QString(),
int timeout = 0 ) const;
QString obscure( const QString& string ) const; QString obscure( const QString& string ) const;
@ -75,4 +63,4 @@ private:
PythonQtObjectPtr m_exceptionCxt; PythonQtObjectPtr m_exceptionCxt;
}; };
#endif // PYTHONQTUTILSWRAPPER_H #endif // PYTHONQTUTILSWRAPPER_H

View File

@ -18,8 +18,8 @@
*/ */
#include "PythonQtViewStep.h" #include "PythonQtViewStep.h"
#include "utils/Logger.h"
#include "utils/CalamaresUtilsGui.h" #include "utils/CalamaresUtilsGui.h"
#include "utils/Logger.h"
#include "utils/PythonQtUtils.h" #include "utils/PythonQtUtils.h"
#include "utils/Retranslator.h" #include "utils/Retranslator.h"
#include "viewpages/PythonQtJob.h" #include "viewpages/PythonQtJob.h"
@ -33,8 +33,7 @@
namespace Calamares namespace Calamares
{ {
PythonQtViewStep::PythonQtViewStep( PythonQtObjectPtr cxt, PythonQtViewStep::PythonQtViewStep( PythonQtObjectPtr cxt, QObject* parent )
QObject* parent )
: ViewStep( parent ) : ViewStep( parent )
, m_widget( new QWidget() ) , m_widget( new QWidget() )
, m_cxt( cxt ) , m_cxt( cxt )
@ -48,32 +47,26 @@ PythonQtViewStep::PythonQtViewStep( PythonQtObjectPtr cxt,
// Instantiate an object of the class marked with @calamares_module and // Instantiate an object of the class marked with @calamares_module and
// store it as _calamares_module. // store it as _calamares_module.
pq->evalScript( m_cxt, QString( "_calamares_module = %1()" ) pq->evalScript( m_cxt, QString( "_calamares_module = %1()" ).arg( className ) );
.arg( className ) );
m_obj = pq->lookupObject( m_cxt, "_calamares_module" ); m_obj = pq->lookupObject( m_cxt, "_calamares_module" );
Q_ASSERT( !m_obj.isNull() ); // no entry point, no party Q_ASSERT( !m_obj.isNull() ); // no entry point, no party
// Prepare the base widget for the module's pages // Prepare the base widget for the module's pages
m_widget->setLayout( new QVBoxLayout ); m_widget->setLayout( new QVBoxLayout );
CalamaresUtils::unmarginLayout( m_widget->layout() ); CalamaresUtils::unmarginLayout( m_widget->layout() );
m_cxt.addObject( "_calamares_module_basewidget", m_widget ); m_cxt.addObject( "_calamares_module_basewidget", m_widget );
CALAMARES_RETRANSLATE_WIDGET( m_widget, CALAMARES_RETRANSLATE_WIDGET(
CalamaresUtils::lookupAndCall( m_obj, m_widget,
{ "retranslate" }, CalamaresUtils::lookupAndCall( m_obj, { "retranslate" }, { CalamaresUtils::translatorLocaleName() } ); )
{ CalamaresUtils::translatorLocaleName() } );
)
} }
QString QString
PythonQtViewStep::prettyName() const PythonQtViewStep::prettyName() const
{ {
return CalamaresUtils::lookupAndCall( m_obj, return CalamaresUtils::lookupAndCall( m_obj, { "prettyName", "prettyname", "pretty_name" } ).toString();
{ "prettyName",
"prettyname",
"pretty_name" } ).toString();
} }
@ -82,12 +75,14 @@ PythonQtViewStep::widget()
{ {
if ( m_widget->layout()->count() > 1 ) if ( m_widget->layout()->count() > 1 )
cWarning() << "PythonQtViewStep wrapper widget has more than 1 child. " cWarning() << "PythonQtViewStep wrapper widget has more than 1 child. "
"This should never happen."; "This should never happen.";
bool nothingChanged = m_cxt.evalScript( bool nothingChanged
"_calamares_module.widget() in _calamares_module_basewidget.children()" ).toBool(); = m_cxt.evalScript( "_calamares_module.widget() in _calamares_module_basewidget.children()" ).toBool();
if ( nothingChanged ) if ( nothingChanged )
{
return m_widget; return m_widget;
}
// Else, we either don't have a child widget, or we have a child widget that // Else, we either don't have a child widget, or we have a child widget that
// was previously set and doesn't apply any more since the Python module // was previously set and doesn't apply any more since the Python module
@ -97,10 +92,11 @@ PythonQtViewStep::widget()
// We only remove from the layout and not delete because Python is in charge // We only remove from the layout and not delete because Python is in charge
// of memory management for these widgets. // of memory management for these widgets.
while ( m_widget->layout()->itemAt( 0 ) ) while ( m_widget->layout()->itemAt( 0 ) )
{
m_widget->layout()->takeAt( 0 ); m_widget->layout()->takeAt( 0 );
}
m_cxt.evalScript( m_cxt.evalScript( "_calamares_module_basewidget.layout().addWidget(_calamares_module.widget())" );
"_calamares_module_basewidget.layout().addWidget(_calamares_module.widget())" );
return m_widget; return m_widget;
} }
@ -123,58 +119,40 @@ PythonQtViewStep::back()
bool bool
PythonQtViewStep::isNextEnabled() const PythonQtViewStep::isNextEnabled() const
{ {
return CalamaresUtils::lookupAndCall( m_obj, return CalamaresUtils::lookupAndCall( m_obj, { "isNextEnabled", "isnextenabled", "is_next_enabled" } ).toBool();
{ "isNextEnabled",
"isnextenabled",
"is_next_enabled" } ).toBool();
} }
bool bool
PythonQtViewStep::isBackEnabled() const PythonQtViewStep::isBackEnabled() const
{ {
return CalamaresUtils::lookupAndCall( m_obj, return CalamaresUtils::lookupAndCall( m_obj, { "isBackEnabled", "isbackenabled", "is_back_enabled" } ).toBool();
{ "isBackEnabled",
"isbackenabled",
"is_back_enabled" } ).toBool();
} }
bool bool
PythonQtViewStep::isAtBeginning() const PythonQtViewStep::isAtBeginning() const
{ {
return CalamaresUtils::lookupAndCall( m_obj, return CalamaresUtils::lookupAndCall( m_obj, { "isAtBeginning", "isatbeginning", "is_at_beginning" } ).toBool();
{ "isAtBeginning",
"isatbeginning",
"is_at_beginning" } ).toBool();
} }
bool bool
PythonQtViewStep::isAtEnd() const PythonQtViewStep::isAtEnd() const
{ {
return CalamaresUtils::lookupAndCall( m_obj, return CalamaresUtils::lookupAndCall( m_obj, { "isAtEnd", "isatend", "is_at_end" } ).toBool();
{ "isAtEnd",
"isatend",
"is_at_end" } ).toBool();
} }
void void
PythonQtViewStep::onActivate() PythonQtViewStep::onActivate()
{ {
CalamaresUtils::lookupAndCall( m_obj, CalamaresUtils::lookupAndCall( m_obj, { "onActivate", "onactivate", "on_activate" } );
{ "onActivate",
"onactivate",
"on_activate" });
} }
void void
PythonQtViewStep::onLeave() PythonQtViewStep::onLeave()
{ {
CalamaresUtils::lookupAndCall( m_obj, CalamaresUtils::lookupAndCall( m_obj, { "onLeave", "onleave", "on_leave" } );
{ "onLeave",
"onleave",
"on_leave" });
} }
@ -185,21 +163,29 @@ PythonQtViewStep::jobs() const
PythonQtObjectPtr jobsCallable = PythonQt::self()->lookupCallable( m_obj, "jobs" ); PythonQtObjectPtr jobsCallable = PythonQt::self()->lookupCallable( m_obj, "jobs" );
if ( jobsCallable.isNull() ) if ( jobsCallable.isNull() )
{
return jobs; return jobs;
}
PythonQtObjectPtr response = PythonQt::self()->callAndReturnPyObject( jobsCallable ); PythonQtObjectPtr response = PythonQt::self()->callAndReturnPyObject( jobsCallable );
if ( response.isNull() ) if ( response.isNull() )
{
return jobs; return jobs;
}
PythonQtObjectPtr listPopCallable = PythonQt::self()->lookupCallable( response, "pop" ); PythonQtObjectPtr listPopCallable = PythonQt::self()->lookupCallable( response, "pop" );
if ( listPopCallable.isNull() ) if ( listPopCallable.isNull() )
{
return jobs; return jobs;
}
forever forever
{ {
PythonQtObjectPtr aJob = PythonQt::self()->callAndReturnPyObject( listPopCallable, { 0 } ); PythonQtObjectPtr aJob = PythonQt::self()->callAndReturnPyObject( listPopCallable, { 0 } );
if ( aJob.isNull() ) if ( aJob.isNull() )
{
break; break;
}
jobs.append( Calamares::job_ptr( new PythonQtJob( m_cxt, aJob ) ) ); jobs.append( Calamares::job_ptr( new PythonQtJob( m_cxt, aJob ) ) );
} }
@ -219,9 +205,8 @@ QWidget*
PythonQtViewStep::createScriptingConsole() PythonQtViewStep::createScriptingConsole()
{ {
PythonQtScriptingConsole* console = new PythonQtScriptingConsole( nullptr, m_cxt ); PythonQtScriptingConsole* console = new PythonQtScriptingConsole( nullptr, m_cxt );
console->setProperty( "classname", console->setProperty( "classname", m_cxt.getVariable( "_calamares_module_typename" ).toString() );
m_cxt.getVariable( "_calamares_module_typename" ).toString() );
return console; return console;
} }
} } // namespace Calamares

View File

@ -30,8 +30,7 @@ class PythonQtViewStep : public Calamares::ViewStep
{ {
Q_OBJECT Q_OBJECT
public: public:
PythonQtViewStep( PythonQtObjectPtr cxt, PythonQtViewStep( PythonQtObjectPtr cxt, QObject* parent = nullptr );
QObject* parent = nullptr );
QString prettyName() const override; QString prettyName() const override;
@ -62,6 +61,6 @@ private:
PythonQtObjectPtr m_obj; PythonQtObjectPtr m_obj;
}; };
} } // namespace Calamares
#endif // PYTHONQTVIEWSTEP_H #endif // PYTHONQTVIEWSTEP_H

View File

@ -24,11 +24,11 @@ namespace Calamares
ViewStep::ViewStep( QObject* parent ) ViewStep::ViewStep( QObject* parent )
: QObject( parent ) : QObject( parent )
{} {
}
ViewStep::~ViewStep() ViewStep::~ViewStep() {}
{}
QString QString
@ -45,20 +45,24 @@ ViewStep::createSummaryWidget() const
void void
ViewStep::onActivate() ViewStep::onActivate()
{} {
}
void void
ViewStep::onLeave() ViewStep::onLeave()
{} {
}
void void
ViewStep::next() ViewStep::next()
{} {
}
void void
ViewStep::back() ViewStep::back()
{} {
}
void void
@ -69,10 +73,7 @@ ViewStep::setModuleInstanceKey( const QString& instanceKey )
void void
ViewStep::setConfigurationMap( const QVariantMap& configurationMap ) ViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { Q_UNUSED( configurationMap ) }
{
Q_UNUSED( configurationMap )
}
RequirementsList ViewStep::checkRequirements() RequirementsList ViewStep::checkRequirements()
@ -80,4 +81,4 @@ RequirementsList ViewStep::checkRequirements()
return RequirementsList(); return RequirementsList();
} }
} } // namespace Calamares

View File

@ -130,10 +130,7 @@ public:
virtual JobList jobs() const = 0; virtual JobList jobs() const = 0;
void setModuleInstanceKey( const QString& instanceKey ); void setModuleInstanceKey( const QString& instanceKey );
QString moduleInstanceKey() const QString moduleInstanceKey() const { return m_instanceKey; }
{
return m_instanceKey;
}
virtual void setConfigurationMap( const QVariantMap& configurationMap ); virtual void setConfigurationMap( const QVariantMap& configurationMap );
@ -161,6 +158,6 @@ protected:
}; };
using ViewStepList = QList< ViewStep* >; using ViewStepList = QList< ViewStep* >;
} } // namespace Calamares
#endif // VIEWSTEP_H #endif // VIEWSTEP_H

View File

@ -23,16 +23,17 @@
ClickableLabel::ClickableLabel( QWidget* parent ) ClickableLabel::ClickableLabel( QWidget* parent )
: QLabel( parent ) : QLabel( parent )
{} {
}
ClickableLabel::ClickableLabel( const QString& text, QWidget* parent ) ClickableLabel::ClickableLabel( const QString& text, QWidget* parent )
: QLabel( text, parent ) : QLabel( text, parent )
{} {
}
ClickableLabel::~ClickableLabel() ClickableLabel::~ClickableLabel() {}
{}
void void
@ -48,5 +49,7 @@ ClickableLabel::mouseReleaseEvent( QMouseEvent* event )
{ {
QLabel::mouseReleaseEvent( event ); QLabel::mouseReleaseEvent( event );
if ( m_time.elapsed() < qApp->doubleClickInterval() ) if ( m_time.elapsed() < qApp->doubleClickInterval() )
{
emit clicked(); emit clicked();
}
} }

View File

@ -42,4 +42,4 @@ private:
QTime m_time; QTime m_time;
}; };
#endif // CLICKABLELABEL_H #endif // CLICKABLELABEL_H

View File

@ -22,21 +22,18 @@
FixedAspectRatioLabel::FixedAspectRatioLabel( QWidget* parent ) FixedAspectRatioLabel::FixedAspectRatioLabel( QWidget* parent )
: QLabel( parent ) : QLabel( parent )
{} {
}
FixedAspectRatioLabel::~FixedAspectRatioLabel() FixedAspectRatioLabel::~FixedAspectRatioLabel() {}
{}
void void
FixedAspectRatioLabel::setPixmap( const QPixmap& pixmap ) FixedAspectRatioLabel::setPixmap( const QPixmap& pixmap )
{ {
m_pixmap = pixmap; m_pixmap = pixmap;
QLabel::setPixmap( pixmap.scaled( QLabel::setPixmap( pixmap.scaled( contentsRect().size(), Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
contentsRect().size(),
Qt::KeepAspectRatio,
Qt::SmoothTransformation ) );
} }
@ -44,9 +41,5 @@ void
FixedAspectRatioLabel::resizeEvent( QResizeEvent* event ) FixedAspectRatioLabel::resizeEvent( QResizeEvent* event )
{ {
Q_UNUSED( event ) Q_UNUSED( event )
QLabel::setPixmap( m_pixmap.scaled( QLabel::setPixmap( m_pixmap.scaled( contentsRect().size(), Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
contentsRect().size(),
Qt::KeepAspectRatio,
Qt::SmoothTransformation ) );
} }

View File

@ -31,11 +31,11 @@ public:
virtual ~FixedAspectRatioLabel() override; virtual ~FixedAspectRatioLabel() override;
public slots: public slots:
void setPixmap( const QPixmap &pixmap ); void setPixmap( const QPixmap& pixmap );
void resizeEvent( QResizeEvent* event ) override; void resizeEvent( QResizeEvent* event ) override;
private: private:
QPixmap m_pixmap; QPixmap m_pixmap;
}; };
#endif // FIXEDASPECTRATIOLABEL_H #endif // FIXEDASPECTRATIOLABEL_H

View File

@ -35,4 +35,4 @@ private:
QLabel* m_waitingLabel; QLabel* m_waitingLabel;
}; };
#endif // WAITINGWIDGET_H #endif // WAITINGWIDGET_H

View File

@ -1,11 +1,11 @@
find_package( KPMcore 3.3 ) find_package( KPMcore 3.3 )
find_package( KF5Config CONFIG )
find_package( KF5I18n CONFIG )
find_package( KF5WidgetsAddons CONFIG )
set( _partition_defs "" ) set( _partition_defs "" )
if ( KPMcore_FOUND ) if ( KPMcore_FOUND AND Qt5DBus_FOUND AND KF5CoreAddons_FOUND AND KF5Config_FOUND )
find_package( Qt5 REQUIRED DBus ) # Needed for KPMCore
find_package( KF5 REQUIRED I18n WidgetsAddons ) # Needed for KPMCore
include_directories( ${KPMCORE_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/src/modules/partition ) include_directories( ${KPMCORE_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/src/modules/partition )
if ( KPMcore_VERSION VERSION_GREATER "3.3.0") if ( KPMcore_VERSION VERSION_GREATER "3.3.0")
@ -48,5 +48,9 @@ if ( KPMcore_FOUND )
target_compile_definitions( fsresizertest PRIVATE ${_partition_defs} ) target_compile_definitions( fsresizertest PRIVATE ${_partition_defs} )
endif() endif()
else() else()
calamares_skip_module( "fsresizer (missing suitable KPMcore)" ) if ( NOT KPMcore_FOUND )
calamares_skip_module( "fsresizer (missing suitable KPMcore)" )
else()
calamares_skip_module( "fsresizer (missing dependencies for KPMcore)" )
endif()
endif() endif()

View File

@ -22,11 +22,11 @@ set_package_properties(
KPMcore PROPERTIES KPMcore PROPERTIES
PURPOSE "For partitioning module" PURPOSE "For partitioning module"
) )
find_package( KF5Config CONFIG )
find_package( KF5I18n CONFIG )
find_package( KF5WidgetsAddons CONFIG )
if ( KPMcore_FOUND ) if ( KPMcore_FOUND AND Qt5DBus_FOUND AND KF5CoreAddons_FOUND AND KF5Config_FOUND )
find_package( Qt5 REQUIRED DBus )
find_package( KF5 REQUIRED Config CoreAddons I18n WidgetsAddons )
if ( KPMcore_VERSION VERSION_GREATER "3.3.0") if ( KPMcore_VERSION VERSION_GREATER "3.3.0")
list( APPEND _partition_defs WITH_KPMCORE331API) # kpmcore > 3.3.0 with deprecations list( APPEND _partition_defs WITH_KPMCORE331API) # kpmcore > 3.3.0 with deprecations
endif() endif()
@ -106,5 +106,9 @@ if ( KPMcore_FOUND )
SHARED_LIB SHARED_LIB
) )
else() else()
calamares_skip_module( "partition (missing suitable KPMcore)" ) if ( NOT KPMcore_FOUND )
calamares_skip_module( "partition (missing suitable KPMcore)" )
else()
calamares_skip_module( "partition (missing dependencies for KPMcore)" )
endif()
endif() endif()

View File

@ -103,6 +103,7 @@ def file_copy(source, dest, progress_cb):
if not source.endswith("/"): if not source.endswith("/"):
source += "/" source += "/"
num_files_total_local = 0
num_files_copied = 0 # Gets updated through rsync output num_files_copied = 0 # Gets updated through rsync output
args = ['rsync', '-aHAXr'] args = ['rsync', '-aHAXr']

View File

@ -20,8 +20,8 @@
#include "WelcomePage.h" #include "WelcomePage.h"
#include "ui_WelcomePage.h"
#include "checker/CheckerContainer.h" #include "checker/CheckerContainer.h"
#include "ui_WelcomePage.h"
#include "Branding.h" #include "Branding.h"
#include "CalamaresVersion.h" #include "CalamaresVersion.h"
@ -32,6 +32,7 @@
#include "modulesystem/ModuleManager.h" #include "modulesystem/ModuleManager.h"
#include "utils/CalamaresUtilsGui.h" #include "utils/CalamaresUtilsGui.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include "utils/NamedEnum.h"
#include "utils/Retranslator.h" #include "utils/Retranslator.h"
#include <QApplication> #include <QApplication>
@ -48,9 +49,18 @@ WelcomePage::WelcomePage( QWidget* parent )
, m_checkingWidget( new CheckerContainer( this ) ) , m_checkingWidget( new CheckerContainer( this ) )
, m_languages( nullptr ) , m_languages( nullptr )
{ {
connect( Calamares::ModuleManager::instance(), &Calamares::ModuleManager::requirementsResult, m_checkingWidget, &CheckerContainer::requirementsChecked ); connect( Calamares::ModuleManager::instance(),
connect( Calamares::ModuleManager::instance(), &Calamares::ModuleManager::requirementsComplete, m_checkingWidget, &CheckerContainer::requirementsComplete ); &Calamares::ModuleManager::requirementsResult,
connect( Calamares::ModuleManager::instance(), &Calamares::ModuleManager::requirementsProgress, m_checkingWidget, &CheckerContainer::requirementsProgress ); m_checkingWidget,
&CheckerContainer::requirementsChecked );
connect( Calamares::ModuleManager::instance(),
&Calamares::ModuleManager::requirementsComplete,
m_checkingWidget,
&CheckerContainer::requirementsComplete );
connect( Calamares::ModuleManager::instance(),
&Calamares::ModuleManager::requirementsProgress,
m_checkingWidget,
&CheckerContainer::requirementsProgress );
ui->setupUi( this ); ui->setupUi( this );
ui->verticalLayout->insertSpacing( 1, CalamaresUtils::defaultFontHeight() * 2 ); ui->verticalLayout->insertSpacing( 1, CalamaresUtils::defaultFontHeight() * 2 );
@ -61,38 +71,33 @@ WelcomePage::WelcomePage( QWidget* parent )
ui->mainText->setOpenExternalLinks( true ); ui->mainText->setOpenExternalLinks( true );
cDebug() << "Welcome string" << Calamares::Branding::instance()->welcomeStyleCalamares() cDebug() << "Welcome string" << Calamares::Branding::instance()->welcomeStyleCalamares()
<< *Calamares::Branding::VersionedName; << *Calamares::Branding::VersionedName;
CALAMARES_RETRANSLATE( CALAMARES_RETRANSLATE(
QString message; QString message;
if ( Calamares::Settings::instance()->isSetupMode() ) if ( Calamares::Settings::instance()->isSetupMode() ) message
message = Calamares::Branding::instance()->welcomeStyleCalamares() = Calamares::Branding::instance()->welcomeStyleCalamares()
? tr( "<h1>Welcome to the Calamares setup program for %1.</h1>" ) ? tr( "<h1>Welcome to the Calamares setup program for %1.</h1>" )
: tr( "<h1>Welcome to %1 setup.</h1>" ); : tr( "<h1>Welcome to %1 setup.</h1>" );
else else message = Calamares::Branding::instance()->welcomeStyleCalamares()
message = Calamares::Branding::instance()->welcomeStyleCalamares() ? tr( "<h1>Welcome to the Calamares installer for %1.</h1>" )
? tr( "<h1>Welcome to the Calamares installer for %1.</h1>" ) : tr( "<h1>Welcome to the %1 installer.</h1>" );
: tr( "<h1>Welcome to the %1 installer.</h1>" );
ui->mainText->setText( message.arg( *Calamares::Branding::VersionedName ) ); ui->mainText->setText( message.arg( *Calamares::Branding::VersionedName ) );
ui->retranslateUi( this ); ui->retranslateUi( this );
) ui->supportButton->setText( tr( "%1 support" ).arg( *Calamares::Branding::ShortProductName ) ); )
ui->aboutButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::Information, ui->aboutButton->setIcon( CalamaresUtils::defaultPixmap(
CalamaresUtils::Original, CalamaresUtils::Information,
2*QSize( CalamaresUtils::defaultFontHeight(), CalamaresUtils::Original,
CalamaresUtils::defaultFontHeight() ) ) ); 2 * QSize( CalamaresUtils::defaultFontHeight(), CalamaresUtils::defaultFontHeight() ) ) );
connect( ui->aboutButton, &QPushButton::clicked, connect( ui->aboutButton, &QPushButton::clicked, this, [this] {
this, [ this ] QString title
{ = Calamares::Settings::instance()->isSetupMode() ? tr( "About %1 setup" ) : tr( "About %1 installer" );
QString title = Calamares::Settings::instance()->isSetupMode()
? tr( "About %1 setup" )
: tr( "About %1 installer" );
QMessageBox mb( QMessageBox::Information, QMessageBox mb( QMessageBox::Information,
title.arg( CALAMARES_APPLICATION_NAME ), title.arg( CALAMARES_APPLICATION_NAME ),
tr( tr( "<h1>%1</h1><br/>"
"<h1>%1</h1><br/>"
"<strong>%2<br/>" "<strong>%2<br/>"
"for %3</strong><br/><br/>" "for %3</strong><br/><br/>"
"Copyright 2014-2017 Teo Mrnjavac &lt;teo@kde.org&gt;<br/>" "Copyright 2014-2017 Teo Mrnjavac &lt;teo@kde.org&gt;<br/>"
@ -103,24 +108,23 @@ WelcomePage::WelcomePage( QWidget* parent )
"<a href=\"https://calamares.io/\">Calamares</a> " "<a href=\"https://calamares.io/\">Calamares</a> "
"development is sponsored by <br/>" "development is sponsored by <br/>"
"<a href=\"http://www.blue-systems.com/\">Blue Systems</a> - " "<a href=\"http://www.blue-systems.com/\">Blue Systems</a> - "
"Liberating Software." "Liberating Software." )
) .arg( CALAMARES_APPLICATION_NAME )
.arg( CALAMARES_APPLICATION_NAME ) .arg( CALAMARES_VERSION )
.arg( CALAMARES_VERSION ) .arg( *Calamares::Branding::VersionedName ),
.arg( *Calamares::Branding::VersionedName ),
QMessageBox::Ok, QMessageBox::Ok,
this ); this );
mb.setIconPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::Squid, mb.setIconPixmap( CalamaresUtils::defaultPixmap(
CalamaresUtils::Original, CalamaresUtils::Squid,
QSize( CalamaresUtils::defaultFontHeight() * 6, CalamaresUtils::Original,
CalamaresUtils::defaultFontHeight() * 6 ) ) ); QSize( CalamaresUtils::defaultFontHeight() * 6, CalamaresUtils::defaultFontHeight() * 6 ) ) );
QGridLayout* layout = reinterpret_cast<QGridLayout *>( mb.layout() ); QGridLayout* layout = reinterpret_cast< QGridLayout* >( mb.layout() );
if ( layout ) if ( layout )
layout->setColumnMinimumWidth( 2, CalamaresUtils::defaultFontHeight() * 24 ); layout->setColumnMinimumWidth( 2, CalamaresUtils::defaultFontHeight() * 24 );
mb.exec(); mb.exec();
} ); } );
ui->verticalLayout->insertWidget( 3, m_checkingWidget); ui->verticalLayout->insertWidget( 3, m_checkingWidget );
} }
@ -139,15 +143,16 @@ WelcomePage::initLanguages()
QLocale defaultLocale = QLocale( QLocale::system().name() ); QLocale defaultLocale = QLocale( QLocale::system().name() );
cDebug() << "Matching locale" << defaultLocale; cDebug() << "Matching locale" << defaultLocale;
int matchedLocaleIndex = m_languages->find( int matchedLocaleIndex = m_languages->find( [&]( const QLocale& x ) {
[&](const QLocale& x){ return x.language() == defaultLocale.language() && x.country() == defaultLocale.country(); } ); return x.language() == defaultLocale.language() && x.country() == defaultLocale.country();
} );
if ( matchedLocaleIndex < 0 ) if ( matchedLocaleIndex < 0 )
{ {
cDebug() << Logger::SubEntry << "Matching approximate locale" << defaultLocale.language(); cDebug() << Logger::SubEntry << "Matching approximate locale" << defaultLocale.language();
matchedLocaleIndex = m_languages->find( matchedLocaleIndex
[&](const QLocale& x){ return x.language() == defaultLocale.language(); } ); = m_languages->find( [&]( const QLocale& x ) { return x.language() == defaultLocale.language(); } );
} }
if ( matchedLocaleIndex < 0 ) if ( matchedLocaleIndex < 0 )
@ -159,7 +164,9 @@ WelcomePage::initLanguages()
// Now, if it matched, because we didn't match the system locale, switch to the one found // Now, if it matched, because we didn't match the system locale, switch to the one found
if ( matchedLocaleIndex >= 0 ) if ( matchedLocaleIndex >= 0 )
{
QLocale::setDefault( m_languages->locale( matchedLocaleIndex ).locale() ); QLocale::setDefault( m_languages->locale( matchedLocaleIndex ).locale() );
}
} }
if ( matchedLocaleIndex >= 0 ) if ( matchedLocaleIndex >= 0 )
@ -171,89 +178,82 @@ WelcomePage::initLanguages()
ui->languageWidget->setCurrentIndex( matchedLocaleIndex ); ui->languageWidget->setCurrentIndex( matchedLocaleIndex );
} }
else else
{
cWarning() << "No available translation matched" << defaultLocale; cWarning() << "No available translation matched" << defaultLocale;
}
connect( ui->languageWidget, connect( ui->languageWidget,
static_cast< void ( QComboBox::* )( int ) >( &QComboBox::currentIndexChanged ), static_cast< void ( QComboBox::* )( int ) >( &QComboBox::currentIndexChanged ),
this, this,
[&]( int newIndex ) [&]( int newIndex ) {
{
const auto& selectedLocale = m_languages->locale( newIndex ).locale(); const auto& selectedLocale = m_languages->locale( newIndex ).locale();
cDebug() << "Selected locale" << selectedLocale; cDebug() << "Selected locale" << selectedLocale;
QLocale::setDefault( selectedLocale ); QLocale::setDefault( selectedLocale );
CalamaresUtils::installTranslator( selectedLocale, CalamaresUtils::installTranslator(
Calamares::Branding::instance()->translationsDirectory(), selectedLocale, Calamares::Branding::instance()->translationsDirectory(), qApp );
qApp );
} ); } );
} }
void void
WelcomePage::setUpLinks( bool showSupportUrl, WelcomePage::setupButton( Button role, const QString& url )
bool showKnownIssuesUrl,
bool showReleaseNotesUrl )
{ {
using namespace Calamares; QPushButton* button = nullptr;
if ( showSupportUrl && !( *Branding::SupportUrl ).isEmpty() ) CalamaresUtils::ImageType icon = CalamaresUtils::Information;
switch ( role )
{ {
CALAMARES_RETRANSLATE( case Button::Donate:
ui->supportButton->setText( tr( "%1 support" ) button = ui->donateButton;
.arg( *Branding::ShortProductName ) ); icon = CalamaresUtils::Donate;
) break;
ui->supportButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::Help, case Button::KnownIssues:
CalamaresUtils::Original, button = ui->knownIssuesButton;
2*QSize( CalamaresUtils::defaultFontHeight(), icon = CalamaresUtils::Bugs;
CalamaresUtils::defaultFontHeight() ) ) ); break;
connect( ui->supportButton, &QPushButton::clicked, [] case Button::ReleaseNotes:
{ button = ui->releaseNotesButton;
QDesktopServices::openUrl( *Branding::SupportUrl ); icon = CalamaresUtils::Release;
} ); break;
case Button::Support:
button = ui->supportButton;
icon = CalamaresUtils::Help;
break;
} }
else if ( !button )
{ {
ui->supportButton->hide(); qWarning() << "Unknown button role" << smash( role );
return;
} }
if ( showKnownIssuesUrl && !( *Branding::KnownIssuesUrl ).isEmpty() ) if ( url.isEmpty() )
{ {
ui->knownIssuesButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::Bugs, button->hide();
CalamaresUtils::Original, return;
2*QSize( CalamaresUtils::defaultFontHeight(),
CalamaresUtils::defaultFontHeight() ) ) );
connect( ui->knownIssuesButton, &QPushButton::clicked, []
{
QDesktopServices::openUrl( *Branding::KnownIssuesUrl );
} );
}
else
{
ui->knownIssuesButton->hide();
} }
if ( showReleaseNotesUrl && !( *Branding::ReleaseNotesUrl ).isEmpty() ) QUrl u( url );
if ( u.isValid() )
{ {
ui->releaseNotesButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::Release, auto size = 2 * QSize( CalamaresUtils::defaultFontHeight(), CalamaresUtils::defaultFontHeight() );
CalamaresUtils::Original, button->setIcon( CalamaresUtils::defaultPixmap( icon, CalamaresUtils::Original, size ) );
2*QSize( CalamaresUtils::defaultFontHeight(), connect( button, &QPushButton::clicked, [u]() { QDesktopServices::openUrl( u ); } );
CalamaresUtils::defaultFontHeight() ) ) );
connect( ui->releaseNotesButton, &QPushButton::clicked, []
{
QDesktopServices::openUrl( *Branding::ReleaseNotesUrl );
} );
} }
else else
{ {
ui->releaseNotesButton->hide(); qWarning() << "Welcome button" << smash( role ) << "URL" << url << "is invalid.";
button->hide();
} }
} }
void void
WelcomePage::focusInEvent( QFocusEvent* e ) WelcomePage::focusInEvent( QFocusEvent* e )
{ {
if ( ui->languageWidget ) if ( ui->languageWidget )
{
ui->languageWidget->setFocus(); ui->languageWidget->setFocus();
}
e->accept(); e->accept();
} }
@ -267,7 +267,9 @@ void
WelcomePage::externallySelectedLanguage( int row ) WelcomePage::externallySelectedLanguage( int row )
{ {
if ( ( row >= 0 ) && ( row < ui->languageWidget->count() ) ) if ( ( row >= 0 ) && ( row < ui->languageWidget->count() ) )
{
ui->languageWidget->setCurrentIndex( row ); ui->languageWidget->setCurrentIndex( row );
}
} }
void void
@ -278,8 +280,14 @@ WelcomePage::setLanguageIcon( QPixmap i )
void void
LocaleTwoColumnDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const LocaleTwoColumnDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
{ {
QStyledItemDelegate::paint( painter, option, index ); QStyledItemDelegate::paint( painter, option, index );
option.widget->style()->drawItemText( painter, option.rect, Qt::AlignRight | Qt::AlignVCenter, option.palette, false, index.data( CalamaresUtils::Locale::LabelModel::EnglishLabelRole ).toString() ); option.widget->style()->drawItemText(
painter,
option.rect,
Qt::AlignRight | Qt::AlignVCenter,
option.palette,
false,
index.data( CalamaresUtils::Locale::LabelModel::EnglishLabelRole ).toString() );
} }

View File

@ -38,10 +38,17 @@ class WelcomePage : public QWidget
public: public:
explicit WelcomePage( QWidget* parent = nullptr ); explicit WelcomePage( QWidget* parent = nullptr );
/// @brief Configure the buttons for URLs from the branding configuration enum class Button
void setUpLinks( bool showSupportUrl, {
bool showKnownIssuesUrl, Support,
bool showReleaseNotesUrl ); Donate,
KnownIssues,
ReleaseNotes
};
/// @brief Configure the button @p n, to open @p url
void setupButton( Button b, const QString& url );
/// @brief Set international language-selector icon /// @brief Set international language-selector icon
void setLanguageIcon( QPixmap ); void setLanguageIcon( QPixmap );
@ -50,8 +57,9 @@ public:
/// @brief Change the language from an external source. /// @brief Change the language from an external source.
void externallySelectedLanguage( int row ); void externallySelectedLanguage( int row );
protected: protected:
void focusInEvent( QFocusEvent* e ) override; //choose the child widget to focus void focusInEvent( QFocusEvent* e ) override; //choose the child widget to focus
private: private:
/// @brief Fill the list of languages with the available translations /// @brief Fill the list of languages with the available translations
@ -59,7 +67,7 @@ private:
Ui::WelcomePage* ui; Ui::WelcomePage* ui;
CheckerContainer* m_checkingWidget; CheckerContainer* m_checkingWidget;
CalamaresUtils::Locale::LabelModel *m_languages; CalamaresUtils::Locale::LabelModel* m_languages;
}; };
/** @brief Delegate to display language information in two columns. /** @brief Delegate to display language information in two columns.
@ -72,6 +80,6 @@ public:
using QStyledItemDelegate::QStyledItemDelegate; using QStyledItemDelegate::QStyledItemDelegate;
void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const override; void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const override;
} ; };
#endif // WELCOMEPAGE_H #endif // WELCOMEPAGE_H

View File

@ -13,9 +13,6 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<property name="toolTip">
<string>Select language</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0"> <layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0">
@ -69,7 +66,7 @@
<item> <item>
<widget class="QLabel" name="languageIcon"> <widget class="QLabel" name="languageIcon">
<property name="toolTip"> <property name="toolTip">
<string>Select language</string> <string>Select application and system language</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
@ -81,6 +78,9 @@
</item> </item>
<item> <item>
<widget class="QComboBox" name="languageWidget"> <widget class="QComboBox" name="languageWidget">
<property name="toolTip">
<string>Select application and system language</string>
</property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>2</horstretch> <horstretch>2</horstretch>
@ -134,8 +134,24 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="donateButton">
<property name="toolTip">
<string>Open donations website</string>
</property>
<property name="text">
<string>&amp;Donate</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="supportButton"> <widget class="QPushButton" name="supportButton">
<property name="toolTip">
<string>Open help and support website</string>
</property>
<property name="text"> <property name="text">
<string>&amp;Support</string> <string>&amp;Support</string>
</property> </property>
@ -146,6 +162,9 @@
</item> </item>
<item> <item>
<widget class="QPushButton" name="knownIssuesButton"> <widget class="QPushButton" name="knownIssuesButton">
<property name="toolTip">
<string>Open issues and bug-tracking website</string>
</property>
<property name="text"> <property name="text">
<string>&amp;Known issues</string> <string>&amp;Known issues</string>
</property> </property>
@ -156,6 +175,9 @@
</item> </item>
<item> <item>
<widget class="QPushButton" name="releaseNotesButton"> <widget class="QPushButton" name="releaseNotesButton">
<property name="toolTip">
<string>Open relead notes website</string>
</property>
<property name="text"> <property name="text">
<string>&amp;Release notes</string> <string>&amp;Release notes</string>
</property> </property>

View File

@ -33,13 +33,16 @@
#include <QFutureWatcher> #include <QFutureWatcher>
#include <QVariant> #include <QVariant>
CALAMARES_PLUGIN_FACTORY_DEFINITION( WelcomeViewStepFactory, registerPlugin<WelcomeViewStep>(); ) CALAMARES_PLUGIN_FACTORY_DEFINITION( WelcomeViewStepFactory, registerPlugin< WelcomeViewStep >(); )
WelcomeViewStep::WelcomeViewStep( QObject* parent ) WelcomeViewStep::WelcomeViewStep( QObject* parent )
: Calamares::ViewStep( parent ) : Calamares::ViewStep( parent )
, m_requirementsChecker( new GeneralRequirements( this ) ) , m_requirementsChecker( new GeneralRequirements( this ) )
{ {
connect( Calamares::ModuleManager::instance(), &Calamares::ModuleManager::requirementsComplete, this, &WelcomeViewStep::nextStatusChanged ); connect( Calamares::ModuleManager::instance(),
&Calamares::ModuleManager::requirementsComplete,
this,
&WelcomeViewStep::nextStatusChanged );
m_widget = new WelcomePage(); m_widget = new WelcomePage();
} }
@ -47,7 +50,9 @@ WelcomeViewStep::WelcomeViewStep( QObject* parent )
WelcomeViewStep::~WelcomeViewStep() WelcomeViewStep::~WelcomeViewStep()
{ {
if ( m_widget && m_widget->parent() == nullptr ) if ( m_widget && m_widget->parent() == nullptr )
{
m_widget->deleteLater(); m_widget->deleteLater();
}
} }
@ -100,23 +105,59 @@ WelcomeViewStep::jobs() const
} }
/** @brief Look up a URL for a button
*
* Looks up @p key in @p map; if it is a *boolean* value, then
* assume an old-style configuration, and fetch the string from
* the branding settings @p e. If it is a string, not a boolean,
* use it as-is. If not found, or a weird type, returns empty.
*
* This allows switching the showKnownIssuesUrl and similar settings
* in welcome.conf from a boolean (deferring to branding) to an
* actual string for immediate use. Empty strings, as well as
* "false" as a setting, will hide the buttons as before.
*/
static QString
jobOrBrandingSetting( Calamares::Branding::StringEntry e, const QVariantMap& map, const QString& key )
{
if ( !map.contains( key ) )
{
return QString();
}
auto v = map.value( key );
if ( v.type() == QVariant::Bool )
{
return v.toBool() ? ( *e ) : QString();
}
if ( v.type() == QVariant::String )
{
return v.toString();
}
return QString();
}
void void
WelcomeViewStep::setConfigurationMap( const QVariantMap& configurationMap ) WelcomeViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{ {
bool showSupportUrl = CalamaresUtils::getBool( configurationMap, "showSupportUrl", false ); using Calamares::Branding;
bool showKnownIssuesUrl = CalamaresUtils::getBool( configurationMap, "showKnownIssuesUrl", false );
bool showReleaseNotesUrl = CalamaresUtils::getBool( configurationMap, "showReleaseNotesUrl", false );
m_widget->setUpLinks( showSupportUrl, m_widget->setupButton( WelcomePage::Button::Support,
showKnownIssuesUrl, jobOrBrandingSetting( Branding::SupportUrl, configurationMap, "showSupportUrl" ) );
showReleaseNotesUrl ); m_widget->setupButton( WelcomePage::Button::KnownIssues,
jobOrBrandingSetting( Branding::KnownIssuesUrl, configurationMap, "showKnownIssuesUrl" ) );
m_widget->setupButton( WelcomePage::Button::ReleaseNotes,
jobOrBrandingSetting( Branding::ReleaseNotesUrl, configurationMap, "showReleaseNotesUrl" ) );
m_widget->setupButton( WelcomePage::Button::Donate, CalamaresUtils::getString( configurationMap, "showDonateUrl" ) );
if ( configurationMap.contains( "requirements" ) && if ( configurationMap.contains( "requirements" )
configurationMap.value( "requirements" ).type() == QVariant::Map ) && configurationMap.value( "requirements" ).type() == QVariant::Map )
{
m_requirementsChecker->setConfigurationMap( configurationMap.value( "requirements" ).toMap() ); m_requirementsChecker->setConfigurationMap( configurationMap.value( "requirements" ).toMap() );
}
else else
cWarning() << "no valid requirements map found in welcome " cWarning() << "no valid requirements map found in welcome "
"module configuration."; "module configuration.";
bool ok = false; bool ok = false;
QVariantMap geoip = CalamaresUtils::getSubMap( configurationMap, "geoip", ok ); QVariantMap geoip = CalamaresUtils::getSubMap( configurationMap, "geoip", ok );
@ -124,15 +165,13 @@ WelcomeViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{ {
using FWString = QFutureWatcher< QString >; using FWString = QFutureWatcher< QString >;
auto* handler = new CalamaresUtils::GeoIP::Handler( auto* handler = new CalamaresUtils::GeoIP::Handler( CalamaresUtils::getString( geoip, "style" ),
CalamaresUtils::getString( geoip, "style" ), CalamaresUtils::getString( geoip, "url" ),
CalamaresUtils::getString( geoip, "url" ), CalamaresUtils::getString( geoip, "selector" ) );
CalamaresUtils::getString( geoip, "selector" ) );
if ( handler->type() != CalamaresUtils::GeoIP::Handler::Type::None ) if ( handler->type() != CalamaresUtils::GeoIP::Handler::Type::None )
{ {
auto* future = new FWString(); auto* future = new FWString();
connect( future, &FWString::finished, [view=this, f=future, h=handler]() connect( future, &FWString::finished, [view = this, f = future, h = handler]() {
{
QString countryResult = f->future().result(); QString countryResult = f->future().result();
cDebug() << "GeoIP result for welcome=" << countryResult; cDebug() << "GeoIP result for welcome=" << countryResult;
view->setCountry( countryResult, h ); view->setCountry( countryResult, h );
@ -154,7 +193,9 @@ WelcomeViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{ {
auto icon = Calamares::Branding::instance()->image( language, QSize( 48, 48 ) ); auto icon = Calamares::Branding::instance()->image( language, QSize( 48, 48 ) );
if ( !icon.isNull() ) if ( !icon.isNull() )
{
m_widget->setLanguageIcon( icon ); m_widget->setLanguageIcon( icon );
}
} }
} }
@ -169,7 +210,8 @@ logGeoIPHandler( CalamaresUtils::GeoIP::Handler* handler )
{ {
if ( handler ) if ( handler )
{ {
cDebug() << Logger::SubEntry << "Obtained from" << handler->url() << " (" << static_cast<int>( handler->type() ) << handler->selector() << ')'; cDebug() << Logger::SubEntry << "Obtained from" << handler->url() << " ("
<< static_cast< int >( handler->type() ) << handler->selector() << ')';
} }
} }
@ -194,8 +236,12 @@ WelcomeViewStep::setCountry( const QString& countryCode, CalamaresUtils::GeoIP::
{ {
int r = CalamaresUtils::Locale::availableTranslations()->find( countryCode ); int r = CalamaresUtils::Locale::availableTranslations()->find( countryCode );
if ( r < 0 ) if ( r < 0 )
{
cDebug() << "Unusable country code" << countryCode << "(no suitable translation)"; cDebug() << "Unusable country code" << countryCode << "(no suitable translation)";
}
if ( ( r >= 0 ) && m_widget ) if ( ( r >= 0 ) && m_widget )
{
m_widget->externallySelectedLanguage( r ); m_widget->externallySelectedLanguage( r );
}
} }
} }

View File

@ -206,7 +206,7 @@ GeneralRequirements::setConfigurationMap( const QVariantMap& configurationMap )
if ( configurationMap.contains( "requiredStorage" ) && if ( configurationMap.contains( "requiredStorage" ) &&
( configurationMap.value( "requiredStorage" ).type() == QVariant::Double || ( configurationMap.value( "requiredStorage" ).type() == QVariant::Double ||
configurationMap.value( "requiredStorage" ).type() == QVariant::Int ) ) configurationMap.value( "requiredStorage" ).type() == QVariant::LongLong ) )
{ {
bool ok = false; bool ok = false;
m_requiredStorageGiB = configurationMap.value( "requiredStorage" ).toDouble( &ok ); m_requiredStorageGiB = configurationMap.value( "requiredStorage" ).toDouble( &ok );
@ -227,7 +227,7 @@ GeneralRequirements::setConfigurationMap( const QVariantMap& configurationMap )
if ( configurationMap.contains( "requiredRam" ) && if ( configurationMap.contains( "requiredRam" ) &&
( configurationMap.value( "requiredRam" ).type() == QVariant::Double || ( configurationMap.value( "requiredRam" ).type() == QVariant::Double ||
configurationMap.value( "requiredRam" ).type() == QVariant::Int ) ) configurationMap.value( "requiredRam" ).type() == QVariant::LongLong ) )
{ {
bool ok = false; bool ok = false;
m_requiredRamGiB = configurationMap.value( "requiredRam" ).toDouble( &ok ); m_requiredRamGiB = configurationMap.value( "requiredRam" ).toDouble( &ok );

View File

@ -7,10 +7,23 @@
# can check requirements for installation. # can check requirements for installation.
--- ---
# Display settings for various buttons on the welcome page. # Display settings for various buttons on the welcome page.
# The URLs themselves come from branding.desc is the setting
# here is "true". If the setting is false, the button is hidden.
# The setting can also be a full URL which will then be used
# instead of the one from the branding file, or empty or not-set
# which will hide the button.
showSupportUrl: true showSupportUrl: true
showKnownIssuesUrl: true showKnownIssuesUrl: true
showReleaseNotesUrl: true showReleaseNotesUrl: true
# If this Url is set to something non-empty, a "donate"
# button is added to the welcome page alongside the
# others (see settings, above). Clicking the button opens
# the corresponding link. (This button has no corresponding
# branding.desc string)
#
# showDonateUrl: https://kde.org/community/donations/
# Requirements checking. These are general, generic, things # Requirements checking. These are general, generic, things
# that are checked. They may not match with the actual requirements # that are checked. They may not match with the actual requirements
# imposed by other modules in the system. # imposed by other modules in the system.