diff --git a/src/modules/prepare/CMakeLists.txt b/src/modules/prepare/CMakeLists.txt deleted file mode 100644 index c9bad0181..000000000 --- a/src/modules/prepare/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui ) -set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules ) -find_package( LIBPARTED REQUIRED ) -find_package( Qt5 ${QT_VERSION} CONFIG REQUIRED DBus ) - -set_source_files_properties( partman_devices.c PROPERTIES LANGUAGE CXX ) - -calamares_add_plugin( prepare - TYPE viewmodule - EXPORT_MACRO PLUGINDLLEXPORT_PRO - SOURCES - PrepareCheckWidget.cpp - PreparePage.cpp - PrepareViewStep.cpp - partman_devices.c - UI - LINK_LIBRARIES - calamaresui - ${LIBPARTED_LIBS} - Qt5::DBus - SHARED_LIB -) diff --git a/src/modules/prepare/module.desc b/src/modules/prepare/module.desc deleted file mode 100644 index 4c7a9fcc1..000000000 --- a/src/modules/prepare/module.desc +++ /dev/null @@ -1,5 +0,0 @@ ---- -type: "view" #core or view -name: "prepare" #the module name. must be unique and same as the parent directory -interface: "qtplugin" #can be: qtplugin, python, process, ... -load: "libcalamares_viewmodule_prepare.so" diff --git a/src/modules/prepare/prepare.conf b/src/modules/prepare/prepare.conf deleted file mode 100644 index de87c602a..000000000 --- a/src/modules/prepare/prepare.conf +++ /dev/null @@ -1,11 +0,0 @@ ---- -requiredStorage: 5.5 -requiredRam: 1.0 -check: - - storage - - ram - - power - - internet -required: - - storage - - ram diff --git a/src/modules/welcome/CMakeLists.txt b/src/modules/welcome/CMakeLists.txt index 5fe5236b2..b8d2af27d 100644 --- a/src/modules/welcome/CMakeLists.txt +++ b/src/modules/welcome/CMakeLists.txt @@ -1,13 +1,32 @@ include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui ) +set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules ) +find_package( LIBPARTED REQUIRED ) +find_package( Qt5 ${QT_VERSION} CONFIG REQUIRED DBus ) + +set_source_files_properties( checker/partman_devices.c PROPERTIES LANGUAGE CXX ) + +set( CHECKER_SOURCES + checker/CheckItemWidget.cpp + checker/CheckerWidget.cpp + checker/RequirementsChecker.cpp + checker/partman_devices.c +) +set( CHECKER_LINK_LIBRARIES + ${LIBPARTED_LIBS} + Qt5::DBus +) + calamares_add_plugin( welcome TYPE viewmodule EXPORT_MACRO PLUGINDLLEXPORT_PRO SOURCES + ${CHECKER_SOURCES} WelcomeViewStep.cpp WelcomePage.cpp UI WelcomePage.ui LINK_LIBRARIES calamaresui + ${CHECKER_LINK_LIBRARIES} SHARED_LIB ) diff --git a/src/modules/prepare/CMakeModules/FindLIBPARTED.cmake b/src/modules/welcome/CMakeModules/FindLIBPARTED.cmake similarity index 100% rename from src/modules/prepare/CMakeModules/FindLIBPARTED.cmake rename to src/modules/welcome/CMakeModules/FindLIBPARTED.cmake diff --git a/src/modules/prepare/PrepareCheckWidget.cpp b/src/modules/welcome/checker/CheckItemWidget.cpp similarity index 89% rename from src/modules/prepare/PrepareCheckWidget.cpp rename to src/modules/welcome/checker/CheckItemWidget.cpp index ceeb1d25e..5c0d8ec95 100644 --- a/src/modules/prepare/PrepareCheckWidget.cpp +++ b/src/modules/welcome/checker/CheckItemWidget.cpp @@ -1,6 +1,6 @@ /* === This file is part of Calamares - === * - * Copyright 2014, Teo Mrnjavac + * Copyright 2014-2015, Teo Mrnjavac * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,15 +16,15 @@ * along with Calamares. If not, see . */ -#include "PrepareCheckWidget.h" +#include "CheckItemWidget.h" #include "utils/CalamaresUtilsGui.h" #include "utils/Logger.h" #include -PrepareCheckWidget::PrepareCheckWidget( bool checked, - QWidget* parent ) +CheckItemWidget::CheckItemWidget( bool checked, + QWidget* parent ) : QWidget( parent ) { QBoxLayout* mainLayout = new QHBoxLayout; @@ -51,7 +51,7 @@ PrepareCheckWidget::PrepareCheckWidget( bool checked, void -PrepareCheckWidget::setText( const QString& text ) +CheckItemWidget::setText( const QString& text ) { m_textLabel->setText( text ); } diff --git a/src/modules/prepare/PrepareCheckWidget.h b/src/modules/welcome/checker/CheckItemWidget.h similarity index 75% rename from src/modules/prepare/PrepareCheckWidget.h rename to src/modules/welcome/checker/CheckItemWidget.h index ac7769675..dea24712a 100644 --- a/src/modules/prepare/PrepareCheckWidget.h +++ b/src/modules/welcome/checker/CheckItemWidget.h @@ -1,6 +1,6 @@ /* === This file is part of Calamares - === * - * Copyright 2014, Teo Mrnjavac + * Copyright 2014-2015, Teo Mrnjavac * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,17 +16,17 @@ * along with Calamares. If not, see . */ -#ifndef PREPARECHECKWIDGET_H -#define PREPARECHECKWIDGET_H +#ifndef CHECKITEMWIDGET_H +#define CHECKITEMWIDGET_H #include -class PrepareCheckWidget : public QWidget +class CheckItemWidget : public QWidget { Q_OBJECT public: - explicit PrepareCheckWidget( bool checked, - QWidget* parent = nullptr ); + explicit CheckItemWidget( bool checked, + QWidget* parent = nullptr ); void setText( const QString& text ); private: @@ -34,4 +34,4 @@ private: QLabel* m_iconLabel; }; -#endif // PREPARECHECKWIDGET_H +#endif // CHECKITEMWIDGET_H diff --git a/src/modules/prepare/PreparePage.cpp b/src/modules/welcome/checker/CheckerWidget.cpp similarity index 90% rename from src/modules/prepare/PreparePage.cpp rename to src/modules/welcome/checker/CheckerWidget.cpp index 3d1d64608..8bfe3c716 100644 --- a/src/modules/prepare/PreparePage.cpp +++ b/src/modules/welcome/checker/CheckerWidget.cpp @@ -1,6 +1,6 @@ /* === This file is part of Calamares - === * - * Copyright 2014, Teo Mrnjavac + * Copyright 2014-2015, Teo Mrnjavac * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,9 +16,9 @@ * along with Calamares. If not, see . */ -#include "PreparePage.h" +#include "CheckerWidget.h" -#include "PrepareCheckWidget.h" +#include "CheckItemWidget.h" #include "utils/CalamaresUtilsGui.h" #include "utils/Retranslator.h" @@ -28,7 +28,7 @@ #include -PreparePage::PreparePage( QWidget* parent ) +CheckerWidget::CheckerWidget( QWidget* parent ) : QWidget() { QBoxLayout* mainLayout = new QVBoxLayout; @@ -52,17 +52,17 @@ PreparePage::PreparePage( QWidget* parent ) void -PreparePage::init( const QList< PrepareEntry >& checkEntries ) +CheckerWidget::init( const QList< PrepareEntry >& checkEntries ) { bool allChecked = true; bool requirementsSatisfied = true; for ( const PrepareEntry& entry : checkEntries ) { - PrepareCheckWidget* pcw = new PrepareCheckWidget( entry.checked ); - CALAMARES_RETRANSLATE( pcw->setText( entry.text() ); ) - m_entriesLayout->addWidget( pcw ); - pcw->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); + CheckItemWidget* ciw = new CheckItemWidget( entry.checked ); + CALAMARES_RETRANSLATE( ciw->setText( entry.text() ); ) + m_entriesLayout->addWidget( ciw ); + ciw->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); if ( !entry.checked ) { diff --git a/src/modules/prepare/PreparePage.h b/src/modules/welcome/checker/CheckerWidget.h similarity index 78% rename from src/modules/prepare/PreparePage.h rename to src/modules/welcome/checker/CheckerWidget.h index 1751f0bbd..2fc50edbd 100644 --- a/src/modules/prepare/PreparePage.h +++ b/src/modules/welcome/checker/CheckerWidget.h @@ -1,6 +1,6 @@ /* === This file is part of Calamares - === * - * Copyright 2014, Teo Mrnjavac + * Copyright 2014-2015, Teo Mrnjavac * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,19 +16,19 @@ * along with Calamares. If not, see . */ -#ifndef PREPAREPAGE_H -#define PREPAREPAGE_H +#ifndef CHECKERWIDGET_H +#define CHECKERWIDGET_H -#include "PrepareViewStep.h" +#include "RequirementsChecker.h" #include #include -class PreparePage : public QWidget +class CheckerWidget : public QWidget { Q_OBJECT public: - explicit PreparePage( QWidget* parent = nullptr ); + explicit CheckerWidget( QWidget* parent = nullptr ); void init( const QList< PrepareEntry >& checkEntries ); @@ -36,4 +36,4 @@ private: QBoxLayout* m_entriesLayout; }; -#endif // PREPAREPAGE_H +#endif // CHECKERWIDGET_H diff --git a/src/modules/prepare/PrepareViewStep.cpp b/src/modules/welcome/checker/RequirementsChecker.cpp similarity index 87% rename from src/modules/prepare/PrepareViewStep.cpp rename to src/modules/welcome/checker/RequirementsChecker.cpp index 096e25cf3..93fe7c94c 100644 --- a/src/modules/prepare/PrepareViewStep.cpp +++ b/src/modules/welcome/checker/RequirementsChecker.cpp @@ -16,9 +16,9 @@ * along with Calamares. If not, see . */ -#include "PrepareViewStep.h" +#include "RequirementsChecker.h" -#include "PreparePage.h" +#include "CheckerWidget.h" #include "partman_devices.h" #include "widgets/WaitingWidget.h" @@ -38,11 +38,11 @@ #include #include -PrepareViewStep::PrepareViewStep( QObject* parent ) - : Calamares::ViewStep( parent ) +RequirementsChecker::RequirementsChecker( QObject* parent ) + : QObject( parent ) , m_widget( new QWidget() ) - , m_actualWidget( new PreparePage() ) - , m_nextEnabled( false ) + , m_actualWidget( new CheckerWidget() ) + , m_verdict( false ) , m_requiredStorageGB( -1 ) { QBoxLayout* mainLayout = new QHBoxLayout; @@ -131,8 +131,8 @@ PrepareViewStep::PrepareViewStep( QObject* parent ) break; } } - m_nextEnabled = canGoNext; - emit nextStatusChanged( m_nextEnabled ); + m_verdict = canGoNext; + emit verdictChanged( m_verdict ); if ( canGoNext ) detectFirmwareType(); @@ -141,86 +141,26 @@ PrepareViewStep::PrepareViewStep( QObject* parent ) } ); timer->start( 0 ); - emit nextStatusChanged( true ); + emit verdictChanged( true ); } -PrepareViewStep::~PrepareViewStep() +RequirementsChecker::~RequirementsChecker() { if ( m_widget && m_widget->parent() == nullptr ) m_widget->deleteLater(); } -QString -PrepareViewStep::prettyName() const -{ - return tr( "Prepare" ); -} - - QWidget* -PrepareViewStep::widget() +RequirementsChecker::widget() const { return m_widget; } void -PrepareViewStep::next() -{ - emit done(); -} - - -void -PrepareViewStep::back() -{} - - -bool -PrepareViewStep::isNextEnabled() const -{ - return m_nextEnabled; -} - - -bool -PrepareViewStep::isBackEnabled() const -{ - return true; -} - - -bool -PrepareViewStep::isAtBeginning() const -{ - return true; -} - - -bool -PrepareViewStep::isAtEnd() const -{ - return true; -} - - -QList< Calamares::job_ptr > -PrepareViewStep::jobs() const -{ - return QList< Calamares::job_ptr >(); -} - - -void -PrepareViewStep::onLeave() -{ -} - - -void -PrepareViewStep::setConfigurationMap( const QVariantMap& configurationMap ) +RequirementsChecker::setConfigurationMap( const QVariantMap& configurationMap ) { if ( configurationMap.contains( "requiredStorage" ) && configurationMap.value( "requiredStorage" ).type() == QVariant::Double ) @@ -267,14 +207,21 @@ PrepareViewStep::setConfigurationMap( const QVariantMap& configurationMap ) bool -PrepareViewStep::checkEnoughStorage( qint64 requiredSpace ) +RequirementsChecker::verdict() const +{ + return m_verdict; +} + + +bool +RequirementsChecker::checkEnoughStorage( qint64 requiredSpace ) { return check_big_enough( requiredSpace ); } bool -PrepareViewStep::checkEnoughRam( qint64 requiredRam ) +RequirementsChecker::checkEnoughRam( qint64 requiredRam ) { // A line in meminfo looks like this, with {print $2} we grab the second column. // MemTotal: 8133432 kB @@ -290,7 +237,7 @@ PrepareViewStep::checkEnoughRam( qint64 requiredRam ) bool -PrepareViewStep::checkBatteryExists() +RequirementsChecker::checkBatteryExists() { const QFileInfo basePath( "/sys/class/power_supply" ); @@ -317,7 +264,7 @@ PrepareViewStep::checkBatteryExists() bool -PrepareViewStep::checkHasPower() +RequirementsChecker::checkHasPower() { const QString UPOWER_SVC_NAME( "org.freedesktop.UPower" ); const QString UPOWER_INTF_NAME( "org.freedesktop.UPower" ); @@ -348,7 +295,7 @@ PrepareViewStep::checkHasPower() bool -PrepareViewStep::checkHasInternet() +RequirementsChecker::checkHasInternet() { const QString NM_SVC_NAME( "org.freedesktop.NetworkManager" ); const QString NM_INTF_NAME( "org.freedesktop.NetworkManager" ); @@ -376,7 +323,7 @@ PrepareViewStep::checkHasInternet() void -PrepareViewStep::detectFirmwareType() +RequirementsChecker::detectFirmwareType() { QString fwType = QFile::exists( "/sys/firmware/efi/efivars" ) ? "efi" : "bios"; Calamares::JobQueue::instance()->globalStorage()->insert( "firmwareType", fwType ); diff --git a/src/modules/prepare/PrepareViewStep.h b/src/modules/welcome/checker/RequirementsChecker.h similarity index 62% rename from src/modules/prepare/PrepareViewStep.h rename to src/modules/welcome/checker/RequirementsChecker.h index fe4b73fea..3fab5f708 100644 --- a/src/modules/prepare/PrepareViewStep.h +++ b/src/modules/welcome/checker/RequirementsChecker.h @@ -16,18 +16,16 @@ * along with Calamares. If not, see . */ -#ifndef PREPAREPAGEPLUGIN_H -#define PREPAREPAGEPLUGIN_H - -#include "viewpages/ViewStep.h" -#include "PluginDllMacro.h" +#ifndef REQUIREMENTSCHECKER_H +#define REQUIREMENTSCHECKER_H #include #include #include -class PreparePage; +class CheckerWidget; +class QWidget; struct PrepareEntry { @@ -37,35 +35,21 @@ struct PrepareEntry bool required; }; -class PLUGINDLLEXPORT PrepareViewStep : public Calamares::ViewStep +class RequirementsChecker : public QObject { Q_OBJECT - Q_PLUGIN_METADATA( IID "calamares.ViewModule/1.0" ) - - Q_INTERFACES( Calamares::ViewStep ) - public: - explicit PrepareViewStep( QObject* parent = nullptr ); - virtual ~PrepareViewStep(); + explicit RequirementsChecker( QObject* parent = nullptr ); + virtual ~RequirementsChecker(); - QString prettyName() const override; + QWidget* widget() const; - QWidget* widget() override; + void setConfigurationMap( const QVariantMap& configurationMap ); - void next() override; - void back() override; + bool verdict() const; - bool isNextEnabled() const override; - bool isBackEnabled() const override; - - bool isAtBeginning() const override; - bool isAtEnd() const override; - - QList< Calamares::job_ptr > jobs() const override; - - void onLeave() override; - - void setConfigurationMap( const QVariantMap& configurationMap ) override; +signals: + void verdictChanged( bool ); private: QStringList m_entriesToCheck; @@ -82,8 +66,8 @@ private: qreal m_requiredStorageGB; qreal m_requiredRamGB; - PreparePage* m_actualWidget; - bool m_nextEnabled; + CheckerWidget* m_actualWidget; + bool m_verdict; }; -#endif // PREPAREPAGEPLUGIN_H +#endif // REQUIREMENTSCHECKER_H diff --git a/src/modules/prepare/partman_devices.c b/src/modules/welcome/checker/partman_devices.c similarity index 100% rename from src/modules/prepare/partman_devices.c rename to src/modules/welcome/checker/partman_devices.c diff --git a/src/modules/prepare/partman_devices.h b/src/modules/welcome/checker/partman_devices.h similarity index 100% rename from src/modules/prepare/partman_devices.h rename to src/modules/welcome/checker/partman_devices.h