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

This commit is contained in:
Philip Müller 2019-01-16 23:04:34 +01:00
commit 25d1022c4c
11 changed files with 259 additions and 86 deletions

View File

@ -27,7 +27,8 @@ This release contains contributions from (alphabetically by first name):
configuration files). configuration files).
* The *branding* file now contains settings that control the size * The *branding* file now contains settings that control the size
and resize behavior of Calamares. See the branding file for and resize behavior of Calamares. See the branding file for
more documentation. more documentation. In particular, the setting *windowExpanding*
can be set to *normal*, *fullscreen* or *noexpand*.
## Modules ## ## Modules ##

View File

@ -17,7 +17,7 @@ welcomeExpandingLogo: true
# Size and expansion policy for Calamares. # Size and expansion policy for Calamares.
# - "normal" or unset, expand as needed, use *windowSize* # - "normal" or unset, expand as needed, use *windowSize*
# - "fullscreen", start as large as possible, ignore *windowSize* # - "fullscreen", start as large as possible, ignore *windowSize*
# - "noexpand", never expand, use *windowSize* # - "noexpand", don't expand automatically, use *windowSize*
windowExpanding: normal windowExpanding: normal
# Size of Calamares window, expressed as w,h. Both w and h # Size of Calamares window, expressed as w,h. Both w and h

View File

@ -348,7 +348,13 @@ void
CalamaresApplication::initViewSteps() CalamaresApplication::initViewSteps()
{ {
cDebug() << "STARTUP: loadModules for all modules done"; cDebug() << "STARTUP: loadModules for all modules done";
m_mainwindow->show(); if ( Calamares::Branding::instance()->windowMaximize() )
{
m_mainwindow->setWindowFlag( Qt::FramelessWindowHint );
m_mainwindow->showMaximized();
}
else
m_mainwindow->show();
ProgressTreeModel* m = new ProgressTreeModel( nullptr ); ProgressTreeModel* m = new ProgressTreeModel( nullptr );
ProgressTreeView::instance()->setModel( m ); ProgressTreeView::instance()->setModel( m );
cDebug() << "STARTUP: Window now visible and ProgressTreeView populated"; cDebug() << "STARTUP: Window now visible and ProgressTreeView populated";

View File

@ -35,6 +35,18 @@
#include <QLabel> #include <QLabel>
#include <QTreeView> #include <QTreeView>
static inline int
windowDimensionToPixels( const Calamares::Branding::WindowDimension& u )
{
if ( !u.isValid() )
return 0;
if ( u.unit() == Calamares::Branding::WindowDimensionUnit::Pixies )
return u.value();
if ( u.unit() == Calamares::Branding::WindowDimensionUnit::Fonties )
return u.value() * CalamaresUtils::defaultFontHeight();
return 0;
}
CalamaresWindow::CalamaresWindow( QWidget* parent ) CalamaresWindow::CalamaresWindow( QWidget* parent )
: QWidget( parent ) : QWidget( parent )
, m_debugWindow( nullptr ) , m_debugWindow( nullptr )
@ -45,24 +57,24 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
.arg( *Calamares::Branding::ProductName ) ); .arg( *Calamares::Branding::ProductName ) );
) )
const Calamares::Branding* const branding = Calamares::Branding::instance();
using CalamaresUtils::windowMinimumHeight; using CalamaresUtils::windowMinimumHeight;
using CalamaresUtils::windowMinimumWidth; using CalamaresUtils::windowMinimumWidth;
using CalamaresUtils::windowPreferredHeight; using CalamaresUtils::windowPreferredHeight;
using CalamaresUtils::windowPreferredWidth; using CalamaresUtils::windowPreferredWidth;
QSize availableSize = qApp->desktop()->availableGeometry( this ).size(); QSize availableSize = qApp->desktop()->availableGeometry( this ).size();
cDebug() << "Available size" << availableSize;
if ( ( availableSize.width() < windowPreferredWidth ) || ( availableSize.height() < windowPreferredHeight ) )
cDebug() << " Small screen detected.";
QSize minimumSize( qBound( windowMinimumWidth, availableSize.width(), windowPreferredWidth ), QSize minimumSize( qBound( windowMinimumWidth, availableSize.width(), windowPreferredWidth ),
qBound( windowMinimumHeight, availableSize.height(), windowPreferredHeight ) ); qBound( windowMinimumHeight, availableSize.height(), windowPreferredHeight ) );
setMinimumSize( minimumSize ); setMinimumSize( minimumSize );
cDebug() << "Available desktop" << availableSize << "minimum size" << minimumSize;
int w = qBound( minimumSize.width(), CalamaresUtils::defaultFontHeight() * 60, availableSize.width() ); auto brandingSizes = branding->windowSize();
int h = qBound( minimumSize.height(), CalamaresUtils::defaultFontHeight() * 36, availableSize.height() );
int w = qBound( minimumSize.width(), windowDimensionToPixels( brandingSizes.first ), availableSize.width() );
int h = qBound( minimumSize.height(), windowDimensionToPixels( brandingSizes.second ), availableSize.height() );
cDebug() << " Proposed window size:" << w << h; cDebug() << " Proposed window size:" << w << h;
resize( w, h ); resize( w, h );
@ -85,18 +97,14 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
{ {
QPalette plt = sideBox->palette(); QPalette plt = sideBox->palette();
sideBox->setAutoFillBackground( true ); sideBox->setAutoFillBackground( true );
plt.setColor( sideBox->backgroundRole(), Calamares::Branding::instance()-> plt.setColor( sideBox->backgroundRole(),branding->styleString( Calamares::Branding::SidebarBackground ) );
styleString( Calamares::Branding::SidebarBackground ) ); plt.setColor( sideBox->foregroundRole(), branding->styleString( Calamares::Branding::SidebarText ) );
plt.setColor( sideBox->foregroundRole(), Calamares::Branding::instance()->
styleString( Calamares::Branding::SidebarText ) );
sideBox->setPalette( plt ); sideBox->setPalette( plt );
logoLabel->setPalette( plt ); logoLabel->setPalette( plt );
} }
logoLabel->setAlignment( Qt::AlignCenter ); logoLabel->setAlignment( Qt::AlignCenter );
logoLabel->setFixedSize( 80, 80 ); logoLabel->setFixedSize( 80, 80 );
logoLabel->setPixmap( Calamares::Branding::instance()-> logoLabel->setPixmap( branding->image( Calamares::Branding::ProductLogo, logoLabel->size() ) );
image( Calamares::Branding::ProductLogo,
logoLabel->size() ) );
logoLayout->addWidget( logoLabel ); logoLayout->addWidget( logoLabel );
logoLayout->addStretch(); logoLayout->addStretch();
@ -139,7 +147,8 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
CalamaresUtils::unmarginLayout( mainLayout ); CalamaresUtils::unmarginLayout( mainLayout );
m_viewManager = Calamares::ViewManager::instance( this ); m_viewManager = Calamares::ViewManager::instance( this );
connect( m_viewManager, &Calamares::ViewManager::enlarge, this, &CalamaresWindow::enlarge ); if ( branding->windowExpands() )
connect( m_viewManager, &Calamares::ViewManager::enlarge, this, &CalamaresWindow::enlarge );
mainLayout->addWidget( m_viewManager->centralWidget() ); mainLayout->addWidget( m_viewManager->centralWidget() );
} }

View File

@ -40,7 +40,7 @@ struct NamedEnumTable
using string_t = QString; using string_t = QString;
using enum_t = T; using enum_t = T;
using pair_t = std::pair< string_t, enum_t >; using pair_t = std::pair< string_t, enum_t >;
using type = std::initializer_list< pair_t >; using type = std::vector< pair_t >;
type table; type table;
@ -51,7 +51,7 @@ struct NamedEnumTable
* *
* static const NamedEnumTable<Colors> c{ {"red", Colors::Red } }; * static const NamedEnumTable<Colors> c{ {"red", Colors::Red } };
*/ */
NamedEnumTable( type v ) : table( v ) { /* static_assert( v.size() > 0 ); */ }; NamedEnumTable( const std::initializer_list< pair_t >& v ) : table( v ) { /* static_assert( v.size() > 0 ); */ };
/** @brief Find a name @p s in the table. /** @brief Find a name @p s in the table.
* *

View File

@ -0,0 +1,108 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2019, Adriaan de Groot <groot@kde.org>
*
* 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/>.
*/
/** @brief Support for unit-suffixed values.
*
* This combines a value with an (enum) unit indicating what kind
* of value it is, e.g. 10 meters, or 64 pixels. Includes simple
* parsing support for the values written as strings like <value><unit>,
* e.g. "10m" or "64px".
*
* When a suffixed unit value needs validation, define an isValid()
* method; similarly for simple construction from a string (with a fixed
* table of suffixes). Typical use then looks like:
*
* class MyUnit : public NamedSuffix<MyUnitEnum, MyUnitEnum::None>
* {
* public:
* using NamedSuffix::NamedSuffix; // Keep existing constructors
* MyUnit( const QString& s );
* bool isValid() const;
* } ;
*/
#ifndef LIBCALAMARES_NAMEDSUFFIX_H
#define LIBCALAMARES_NAMEDSUFFIX_H
#include "NamedEnum.h"
/** @brief Template that takes the enum type to work with and a special none-enum. */
template<typename T, T _none>
class NamedSuffix
{
public:
using unit_t = T;
static constexpr unit_t none = _none;
/** @brief Empty value. */
NamedSuffix()
: m_value(0)
, m_unit( none )
{
}
/** @brief Specific value and unit. */
NamedSuffix( int value, unit_t unit )
: m_value( value )
, m_unit( unit )
{
}
/** @brief Construct value and unit from string.
*
* This parses the given string @p s by comparing with the suffixes
* in @p table and uses the first matching suffix as the unit.
*/
NamedSuffix( const NamedEnumTable<T>& table, const QString& s )
: NamedSuffix()
{
for( const auto suffix : table.table )
if ( s.endsWith( suffix.first ) )
{
m_value = s.left( s.length() - suffix.first.length() ).toInt();
m_unit = suffix.second;
break;
}
}
/** @brief Construct value from string.
*
* This is not defined in the template, because it should probably
* delegate to the constructor above with a fixed table.
*/
NamedSuffix( const QString& s );
int value() const { return m_value; }
unit_t unit() const { return m_unit; }
/** @brief Check that a value-unit combination is valid.
*
* This is not defined in the template, because validity (e.g.
* range of acceptable values) depends on the kind of unit.
*/
bool isValid() const;
protected:
int m_value;
unit_t m_unit;
};
#endif

View File

@ -21,6 +21,7 @@
#include "GlobalStorage.h" #include "GlobalStorage.h"
#include "utils/CalamaresUtils.h" #include "utils/CalamaresUtils.h"
#include "utils/CalamaresUtilsGui.h"
#include "utils/ImageRegistry.h" #include "utils/ImageRegistry.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include "utils/NamedEnum.h" #include "utils/NamedEnum.h"
@ -77,6 +78,17 @@ const QStringList Branding::s_styleEntryStrings =
"sidebarTextHighlight" "sidebarTextHighlight"
}; };
static const NamedEnumTable<Branding::WindowDimensionUnit>&
windowDimensions()
{
using Unit = Branding::WindowDimensionUnit;
static const NamedEnumTable<Unit> names{
{"px", Unit::Pixies},
{"em", Unit::Fonties}
};
return names;
}
Branding::Branding( const QString& brandingFilePath, Branding::Branding( const QString& brandingFilePath,
QObject* parent ) QObject* parent )
@ -287,23 +299,57 @@ Branding::setGlobals( GlobalStorage* globalStorage ) const
globalStorage->insert( "branding", brandingMap ); globalStorage->insert( "branding", brandingMap );
} }
bool
Branding::WindowDimension::isValid() const
{
return ( unit() != none ) && ( value() > 0 );
}
/// @brief Guard against cases where the @p key doesn't exist in @p doc
static inline QString
getString( const YAML::Node& doc, const char* key )
{
if ( doc[key] )
return QString::fromStdString( doc[key].as< std::string >() );
return QString();
}
void void
Branding::initSimpleSettings( const YAML::Node& doc ) Branding::initSimpleSettings( const YAML::Node& doc )
{ {
static const NamedEnumTable< WindowExpansion > weNames{ static const NamedEnumTable< WindowExpansion > expansionNames{
{ QStringLiteral( "normal" ), WindowExpansion::Normal }, { QStringLiteral( "normal" ), WindowExpansion::Normal },
{ QStringLiteral( "fullscreen" ), WindowExpansion::Fullscreen }, { QStringLiteral( "fullscreen" ), WindowExpansion::Fullscreen },
{ QStringLiteral( "noexpand" ), WindowExpansion::Fixed } { QStringLiteral( "noexpand" ), WindowExpansion::Fixed }
}; };
static const NamedEnumTable< WindowDimensionUnit > dimensionNames{
{ QStringLiteral( "px" ), WindowDimensionUnit::Pixies },
{ QStringLiteral( "em" ), WindowDimensionUnit::Fonties }
};
bool ok = false; bool ok = false;
m_welcomeStyleCalamares = doc[ "welcomeStyleCalamares" ].as< bool >( false ); m_welcomeStyleCalamares = doc[ "welcomeStyleCalamares" ].as< bool >( false );
m_welcomeExpandingLogo = doc[ "welcomeExpandingLogo" ].as< bool >( true ); m_welcomeExpandingLogo = doc[ "welcomeExpandingLogo" ].as< bool >( true );
m_windowExpansion = weNames.find( QString::fromStdString( doc[ "windowExpanding" ].as< std::string >() ), ok ); m_windowExpansion = expansionNames.find( getString( doc, "windowExpanding" ), ok );
if ( !ok ) if ( !ok )
cWarning() << "Branding module-setting *windowExpanding* interpreted as" << weNames.find( m_windowExpansion, ok ); cWarning() << "Branding module-setting *windowExpanding* interpreted as" << expansionNames.find( m_windowExpansion, ok );
QString windowSize = getString( doc, "windowSize" );
if ( !windowSize.isEmpty() )
{
auto l = windowSize.split( ',' );
if ( l.count() == 2 )
{
m_windowWidth = WindowDimension( dimensionNames, l[0] );
m_windowHeight = WindowDimension( dimensionNames, l[1] );
}
}
if ( !m_windowWidth.isValid() )
m_windowWidth = WindowDimension( CalamaresUtils::windowPreferredWidth, WindowDimensionUnit::Pixies );
if ( !m_windowHeight.isValid() )
m_windowHeight = WindowDimension( CalamaresUtils::windowPreferredHeight, WindowDimensionUnit::Pixies );
} }

View File

@ -23,6 +23,8 @@
#include "UiDllMacro.h" #include "UiDllMacro.h"
#include "Typedefs.h" #include "Typedefs.h"
#include "utils/NamedSuffix.h"
#include <QObject> #include <QObject>
#include <QStringList> #include <QStringList>
#include <QMap> #include <QMap>
@ -78,6 +80,18 @@ 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.
*
* The units are pixels (Pixies) or something-based-on-fontsize (Fonties), which
* we suffix as "em", e.g. "600px" or "32em".
*/
enum class WindowDimensionUnit { None, Pixies, Fonties };
class WindowDimension : public NamedSuffix<WindowDimensionUnit, WindowDimensionUnit::None>
{
public:
using NamedSuffix::NamedSuffix;
bool isValid() const;
} ;
static Branding* instance(); static Branding* instance();
@ -97,6 +111,12 @@ public:
bool welcomeStyleCalamares() const { return m_welcomeStyleCalamares; } bool welcomeStyleCalamares() const { return m_welcomeStyleCalamares; }
bool welcomeExpandingLogo() const { return m_welcomeExpandingLogo; } bool welcomeExpandingLogo() const { return m_welcomeExpandingLogo; }
bool windowMaximize() const { return m_windowExpansion == WindowExpansion::Fullscreen; }
bool windowExpands() const { return m_windowExpansion != WindowExpansion::Fixed; }
QPair< WindowDimension, WindowDimension > windowSize() const
{
return QPair< WindowDimension, WindowDimension >( m_windowWidth, m_windowHeight );
}
/** /**
* Creates a map called "branding" in the global storage, and inserts an * Creates a map called "branding" in the global storage, and inserts an
@ -128,6 +148,9 @@ private:
bool m_welcomeStyleCalamares; bool m_welcomeStyleCalamares;
bool m_welcomeExpandingLogo; bool m_welcomeExpandingLogo;
WindowExpansion m_windowExpansion; WindowExpansion m_windowExpansion;
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 ); }

View File

@ -39,46 +39,32 @@
#include "modules/partition/core/PartitionIterator.h" #include "modules/partition/core/PartitionIterator.h"
ResizeFSJob::RelativeSize::RelativeSize()
: m_value( 0 ) static const NamedEnumTable<ResizeFSJob::RelativeUnit>&
, m_unit( None ) unitSuffixes()
{ {
using Unit = ResizeFSJob::RelativeUnit;
static const NamedEnumTable<Unit> names{
{ QStringLiteral( "%" ), Unit::Percent },
{ QStringLiteral( "MiB" ), Unit::Absolute }
};
return names;
} }
template<int N>
void matchUnitSuffix(
const QString& s,
const char ( &suffix )[N],
ResizeFSJob::RelativeSize::Unit matchedUnit,
int& value,
ResizeFSJob::RelativeSize::Unit& unit
)
{
if ( s.endsWith( suffix ) )
{
value = s.left( s.length() - N + 1 ).toInt();
unit = matchedUnit;
}
}
ResizeFSJob::RelativeSize::RelativeSize( const QString& s ) ResizeFSJob::RelativeSize::RelativeSize( const QString& s )
: m_value( 0 ) : NamedSuffix( unitSuffixes(), s )
, m_unit( None )
{ {
matchUnitSuffix( s, "%", Percent, m_value, m_unit ); if ( ( unit() == RelativeUnit::Percent ) && ( value() > 100 ) )
matchUnitSuffix( s, "MiB", Absolute, m_value, m_unit );
if ( ( unit() == Percent ) && ( value() > 100 ) )
{ {
cDebug() << "Percent value" << value() << "is not valid."; cDebug() << "Percent value" << value() << "is not valid.";
m_value = 0; m_value = 0;
m_unit = None; m_unit = RelativeUnit::None;
} }
if ( !m_value ) if ( !m_value )
m_unit = None; m_unit = RelativeUnit::None;
} }
qint64 qint64
@ -91,11 +77,11 @@ ResizeFSJob::RelativeSize::apply( qint64 totalSectors, qint64 sectorSize )
switch ( m_unit ) switch ( m_unit )
{ {
case None: case unit_t::None:
return -1; return -1;
case Absolute: case unit_t::Absolute:
return CalamaresUtils::MiBtoBytes( value() ) / sectorSize; return CalamaresUtils::MiBtoBytes( value() ) / sectorSize;
case Percent: case unit_t::Percent:
if ( value() == 100 ) if ( value() == 100 )
return totalSectors; // Common-case, avoid futzing around return totalSectors; // Common-case, avoid futzing around
else else

View File

@ -24,7 +24,8 @@
#include <CppJob.h> #include <CppJob.h>
#include <utils/PluginFactory.h> #include "utils/NamedSuffix.h"
#include "utils/PluginFactory.h"
#include <PluginDllMacro.h> #include <PluginDllMacro.h>
@ -37,31 +38,28 @@ class PLUGINDLLEXPORT ResizeFSJob : public Calamares::CppJob
Q_OBJECT Q_OBJECT
public: public:
enum class RelativeUnit
{
None,
Percent,
Absolute
};
/** @brief Size expressions /** @brief Size expressions
* *
* Sizes can be specified in MiB or percent (of the device they * Sizes can be specified in MiB or percent (of the device they
* are on). This class handles parsing of such strings from the * are on). This class handles parsing of such strings from the
* config file. * config file.
*/ */
class RelativeSize class RelativeSize : public NamedSuffix<RelativeUnit, RelativeUnit::None>
{ {
public: public:
RelativeSize(); RelativeSize() : NamedSuffix() { };
RelativeSize( const QString& ); RelativeSize( const QString& );
enum Unit
{
None,
Percent,
Absolute
};
int value() const { return m_value; }
Unit unit() const { return m_unit; }
bool isValid() const bool isValid() const
{ {
return ( unit() != None ) && ( value() > 0 ); return ( unit() != RelativeUnit::None ) && ( value() > 0 );
} }
/** @brief Apply this size to the number of sectors @p totalSectors . /** @brief Apply this size to the number of sectors @p totalSectors .
@ -80,10 +78,6 @@ public:
* Equivalent to apply( d->totalLogical(), d->logicalSize() ) * Equivalent to apply( d->totalLogical(), d->logicalSize() )
*/ */
qint64 apply( Device* d ); qint64 apply( Device* d );
private:
int m_value;
Unit m_unit;
} ; } ;
explicit ResizeFSJob( QObject* parent = nullptr ); explicit ResizeFSJob( QObject* parent = nullptr );

View File

@ -54,13 +54,13 @@ FSResizerTests::initTestCase()
void FSResizerTests::testConfigurationRobust() void FSResizerTests::testConfigurationRobust()
{ {
ResizeFSJob j; ResizeFSJob j;
// Empty config // Empty config
j.setConfigurationMap( QVariantMap() ); j.setConfigurationMap( QVariantMap() );
QVERIFY( j.m_fsname.isEmpty() ); QVERIFY( j.m_fsname.isEmpty() );
QVERIFY( j.m_devicename.isEmpty() ); QVERIFY( j.m_devicename.isEmpty() );
QCOMPARE( j.m_size.unit(), ResizeFSJob::RelativeSize::None ); QCOMPARE( j.m_size.unit(), ResizeFSJob::RelativeUnit::None );
QCOMPARE( j.m_atleast.unit(), ResizeFSJob::RelativeSize::None ); QCOMPARE( j.m_atleast.unit(), ResizeFSJob::RelativeUnit::None );
// Config is missing fs and dev, so it isn't valid // Config is missing fs and dev, so it isn't valid
YAML::Node doc0 = YAML::Load( R"(--- YAML::Node doc0 = YAML::Load( R"(---
@ -70,17 +70,17 @@ atleast: 600MiB
j.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc0 ).toMap() ); j.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc0 ).toMap() );
QVERIFY( j.m_fsname.isEmpty() ); QVERIFY( j.m_fsname.isEmpty() );
QVERIFY( j.m_devicename.isEmpty() ); QVERIFY( j.m_devicename.isEmpty() );
QCOMPARE( j.m_size.unit(), ResizeFSJob::RelativeSize::None ); QCOMPARE( j.m_size.unit(), ResizeFSJob::RelativeUnit::None );
QCOMPARE( j.m_atleast.unit(), ResizeFSJob::RelativeSize::None ); QCOMPARE( j.m_atleast.unit(), ResizeFSJob::RelativeUnit::None );
QCOMPARE( j.m_size.value(), 0 ); QCOMPARE( j.m_size.value(), 0 );
QCOMPARE( j.m_atleast.value(), 0 ); QCOMPARE( j.m_atleast.value(), 0 );
} }
void FSResizerTests::testConfigurationValues() void FSResizerTests::testConfigurationValues()
{ {
ResizeFSJob j; ResizeFSJob j;
// Check both // Check both
YAML::Node doc0 = YAML::Load( R"(--- YAML::Node doc0 = YAML::Load( R"(---
fs: / fs: /
size: 100% size: 100%
@ -89,8 +89,8 @@ atleast: 600MiB
j.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc0 ).toMap() ); j.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc0 ).toMap() );
QVERIFY( !j.m_fsname.isEmpty() ); QVERIFY( !j.m_fsname.isEmpty() );
QVERIFY( j.m_devicename.isEmpty() ); QVERIFY( j.m_devicename.isEmpty() );
QCOMPARE( j.m_size.unit(), ResizeFSJob::RelativeSize::Percent ); QCOMPARE( j.m_size.unit(), ResizeFSJob::RelativeUnit::Percent );
QCOMPARE( j.m_atleast.unit(), ResizeFSJob::RelativeSize::Absolute ); QCOMPARE( j.m_atleast.unit(), ResizeFSJob::RelativeUnit::Absolute );
QCOMPARE( j.m_size.value(), 100 ); QCOMPARE( j.m_size.value(), 100 );
QCOMPARE( j.m_atleast.value(), 600 ); QCOMPARE( j.m_atleast.value(), 600 );
@ -104,8 +104,8 @@ atleast: 127 %
j.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc0 ).toMap() ); j.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc0 ).toMap() );
QVERIFY( !j.m_fsname.isEmpty() ); QVERIFY( !j.m_fsname.isEmpty() );
QVERIFY( !j.m_devicename.isEmpty() ); QVERIFY( !j.m_devicename.isEmpty() );
QCOMPARE( j.m_size.unit(), ResizeFSJob::RelativeSize::Absolute ); QCOMPARE( j.m_size.unit(), ResizeFSJob::RelativeUnit::Absolute );
QCOMPARE( j.m_atleast.unit(), ResizeFSJob::RelativeSize::Percent ); QCOMPARE( j.m_atleast.unit(), ResizeFSJob::RelativeUnit::Percent );
QCOMPARE( j.m_size.value(), 72 ); QCOMPARE( j.m_size.value(), 72 );
QCOMPARE( j.m_atleast.value(), 127 ); QCOMPARE( j.m_atleast.value(), 127 );
@ -119,8 +119,8 @@ size: 71MiB
j.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc0 ).toMap() ); j.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc0 ).toMap() );
QVERIFY( !j.m_fsname.isEmpty() ); QVERIFY( !j.m_fsname.isEmpty() );
QVERIFY( j.m_devicename.isEmpty() ); QVERIFY( j.m_devicename.isEmpty() );
QCOMPARE( j.m_size.unit(), ResizeFSJob::RelativeSize::Absolute ); QCOMPARE( j.m_size.unit(), ResizeFSJob::RelativeUnit::Absolute );
QCOMPARE( j.m_atleast.unit(), ResizeFSJob::RelativeSize::None ); QCOMPARE( j.m_atleast.unit(), ResizeFSJob::RelativeUnit::None );
QCOMPARE( j.m_size.value(), 71 ); QCOMPARE( j.m_size.value(), 71 );
QCOMPARE( j.m_atleast.value(), 0 ); QCOMPARE( j.m_atleast.value(), 0 );
} }