Merge branch 'master' into usertracking

This commit is contained in:
Adriaan de Groot 2017-11-07 07:49:13 -05:00
commit 28315db43b
34 changed files with 323 additions and 88 deletions

26
AUTHORS
View File

@ -1,2 +1,24 @@
Teo Mrnjavac <teo@kde.org> # MAINTAINER
Adriaan de Groot <groot@kde.org>
Teo Mrnjavac <teo@kde.org> (maintainer -2017)
Adriaan de Groot <groot@kde.org> (maintainer 2017-)
# CONTRIBUTORS
Alf Gaida
Allen Welkie
Andrius Štikonas
Bernhard Landauer
Bezzy1999
bill-auger
crispg72
demmm
Gabriel Craciunescu
Kai Dohmen
Kevin Kofler
Kyle Robertze
Lisa Vitolo
n3rdopolis
Philip Müller
Ramon Buldó
Rohan Garg

View File

@ -9,6 +9,20 @@ if(NOT PYTHONLIBS_FOUND)
message(FATAL_ERROR "error: Python is required to build PythonQt") message(FATAL_ERROR "error: Python is required to build PythonQt")
endif() endif()
# Cut X.Y[.Z] down to just X.Y
string(REGEX REPLACE
"^([0-9][0-9]*)\.([0-9][0-9]*)"
"\\1.\\2@"
_PYTHONLIBS_MAJMIN
${PYTHONLIBS_VERSION_STRING}
)
string(REGEX REPLACE
"@.*"
""
PYTHONLIBS_MAJMIN
${_PYTHONLIBS_MAJMIN}
)
if(NOT EXISTS "${PYTHONQT_INSTALL_DIR}") if(NOT EXISTS "${PYTHONQT_INSTALL_DIR}")
find_path(PYTHONQT_INSTALL_DIR include/PythonQt/PythonQt.h DOC "Directory where PythonQt was installed.") find_path(PYTHONQT_INSTALL_DIR include/PythonQt/PythonQt.h DOC "Directory where PythonQt was installed.")
endif() endif()
@ -22,17 +36,58 @@ find_path(PYTHONQT_INCLUDE_DIR PythonQt.h
"${PYTHONQT_INSTALL_DIR}/src" "${PYTHONQT_INSTALL_DIR}/src"
DOC "Path to the PythonQt include directory") DOC "Path to the PythonQt include directory")
# Minimum v3.1 is needed if ( NOT PythonQt_FIND_QUIETLY )
find_library(PYTHONQT_LIBRARY_RELEASE PythonQt PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "The PythonQt library.") message( STATUS "Searching for PythonQt (PythonLibs ${PYTHONLIBS_MAJMIN}) .." )
find_library(PYTHONQT_LIBRARY_DEBUG NAMES PythonQt${CTK_CMAKE_DEBUG_POSTFIX} PythonQt${CMAKE_DEBUG_POSTFIX} PythonQt PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "The PythonQt library.") if ( PYTHONQT_INCLUDE_DIR )
find_library(PYTHONQT_QTALL_LIBRARY_RELEASE PythonQt_QtAll PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "Full Qt bindings for the PythonQt library.") message( STATUS " .. found include ${PYTHONQT_INCLUDE_DIR}" )
find_library(PYTHONQT_QTALL_LIBRARY_DEBUG NAMES PythonQt_QtAll${CTK_CMAKE_DEBUG_POSTFIX} PythonQt_QtAll${CMAKE_DEBUG_POSTFIX} PythonQt_QtAll PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "Full Qt bindings for the PythonQt library.") endif()
endif()
# Also check for v3.2+ # Minimum v3.1 is needed
find_library(PYTHONQT_LIBRARY_RELEASE PythonQt-Qt5-Python3 PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "The PythonQt library.") find_library(PYTHONQT_LIBRARY_RELEASE
find_library(PYTHONQT_LIBRARY_DEBUG NAMES PythonQt-Qt5-Python3${CTK_CMAKE_DEBUG_POSTFIX} PythonQt-Qt5-Python3${CMAKE_DEBUG_POSTFIX} PythonQt-Qt5-Python3 PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "The PythonQt library.") NAMES
find_library(PYTHONQT_QTALL_LIBRARY_RELEASE PythonQt_QtAll-Qt5-Python3 PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "Full Qt bindings for the PythonQt library.") PythonQt-Qt5-Python${PYTHONLIBS_MAJMIN}
find_library(PYTHONQT_QTALL_LIBRARY_DEBUG NAMES PythonQt_QtAll-Qt5-Python3${CTK_CMAKE_DEBUG_POSTFIX} PythonQt_QtAll-Qt5-Python3${CMAKE_DEBUG_POSTFIX} PythonQt_QtAll-Qt5-Python3 PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "Full Qt bindings for the PythonQt library.") PythonQt-Qt5-Python3
PythonQt
PATHS "${PYTHONQT_INSTALL_DIR}/lib"
DOC "The PythonQt library."
)
find_library(PYTHONQT_LIBRARY_DEBUG
NAMES
PythonQt-Qt5-Python${PYTHONLIBS_MAJMIN}JMIN${CTK_CMAKE_DEBUG_POSTFIX}
PythonQt-Qt5-Python${PYTHONLIBS_MAJMIN}${CMAKE_DEBUG_POSTFIX}
PythonQt-Qt5-Python${PYTHONLIBS_MAJMIN}
PythonQt-Qt5-Python3${CTK_CMAKE_DEBUG_POSTFIX}
PythonQt-Qt5-Python3${CMAKE_DEBUG_POSTFIX}
PythonQt-Qt5-Python3
PythonQt${CTK_CMAKE_DEBUG_POSTFIX}
PythonQt${CMAKE_DEBUG_POSTFIX}
PythonQt
PATHS "${PYTHONQT_INSTALL_DIR}/lib"
DOC "The PythonQt library (debug build)."
)
find_library(PYTHONQT_QTALL_LIBRARY_RELEASE
NAMES
PythonQt_QtAll-Qt5-Python${PYTHONLIBS_MAJMIN}
PythonQt_QtAll-Qt5-Python3
PythonQt_QtAll
PATHS "${PYTHONQT_INSTALL_DIR}/lib"
DOC "Full Qt bindings for the PythonQt library."
)
find_library(PYTHONQT_QTALL_LIBRARY_DEBUG
NAMES
PythonQt_QtAll-Qt5-Python${PYTHONLIBS_MAJMIN}${CTK_CMAKE_DEBUG_POSTFIX}
PythonQt_QtAll-Qt5-Python${PYTHONLIBS_MAJMIN}${CMAKE_DEBUG_POSTFIX}
PythonQt_QtAll-Qt5-Python${PYTHONLIBS_MAJMIN}
PythonQt_QtAll-Qt5-Python3${CTK_CMAKE_DEBUG_POSTFIX}
PythonQt_QtAll-Qt5-Python3${CMAKE_DEBUG_POSTFIX}
PythonQt_QtAll-Qt5-Python3
PythonQt_QtAll${CTK_CMAKE_DEBUG_POSTFIX}
PythonQt_QtAll${CMAKE_DEBUG_POSTFIX}
PythonQt_QtAll
PATHS "${PYTHONQT_INSTALL_DIR}/lib"
DOC "Full Qt bindings for the PythonQt library (debug build)."
)
set(PYTHONQT_LIBRARY) set(PYTHONQT_LIBRARY)
if(PYTHONQT_LIBRARY_RELEASE) if(PYTHONQT_LIBRARY_RELEASE)
@ -50,6 +105,16 @@ if(PYTHONQT_QTALL_LIBRARY_DEBUG)
list(APPEND PYTHONQT_QTALL_LIBRARY debug ${PYTHONQT_QTALL_LIBRARY_DEBUG}) list(APPEND PYTHONQT_QTALL_LIBRARY debug ${PYTHONQT_QTALL_LIBRARY_DEBUG})
endif() endif()
if ( NOT PythonQt_FIND_QUIETLY )
if ( PYTHONQT_LIBRARY )
message( STATUS " .. found library ${PYTHONQT_LIBRARY}" )
endif()
if ( PYTHONQT_QTALL_LIBRARY )
message( STATUS " .. found qtall ${PYTHONQT_QTALL_LIBRARY}" )
endif()
endif()
mark_as_advanced(PYTHONQT_INSTALL_DIR) mark_as_advanced(PYTHONQT_INSTALL_DIR)
mark_as_advanced(PYTHONQT_INCLUDE_DIR) mark_as_advanced(PYTHONQT_INCLUDE_DIR)
mark_as_advanced(PYTHONQT_LIBRARY_RELEASE) mark_as_advanced(PYTHONQT_LIBRARY_RELEASE)

View File

@ -1,9 +1,15 @@
Hacking on Calamares Hacking on Calamares
==================== ====================
These are the guidelines for hacking on Calamares. Except for the licensing,
which **must** be GPLv3+, these are guidelines and -- like PEP8 -- the most
important thing is to know when you can ignore them.
Licensing Licensing
--------- ---------
Calamares is released under the terms of the GNU GPL, version 3 or later. Every source file must have a license header, with a list of copyright holders and years. Calamares is released under the terms of the GNU GPL, version 3 or later.
Every source file must have a license header, with a list of copyright holders and years.
Example: Example:
``` ```
@ -34,9 +40,9 @@ organization, etc.
Please add your name to files you touch when making any contribution (even if Please add your name to files you touch when making any contribution (even if
it's just a typo-fix which might not be copyrightable in all jurisdictions). it's just a typo-fix which might not be copyrightable in all jurisdictions).
Formatting
----------
Formatting C++
--------------
This formatting guide applies to C++ code only; for Python modules, we use This formatting guide applies to C++ code only; for Python modules, we use
[pycodestyle][https://github.com/PyCQA/pycodestyle] to apply a check of [pycodestyle][https://github.com/PyCQA/pycodestyle] to apply a check of
some PEP8 guidelines. some PEP8 guidelines.
@ -48,10 +54,10 @@ some PEP8 guidelines.
* No space before brackets, except for keywords, for example `function( argument )` but * No space before brackets, except for keywords, for example `function( argument )` but
`if ( condition )`. `if ( condition )`.
* For pointer and reference variable declarations, put a space before the variable name * For pointer and reference variable declarations, put a space before the variable name
and no space between the type and the `*` or `&`. and no space between the type and the `*` or `&`, e.g. `int* p`.
* `for`, `if`, `else`, `while` and similar statements put the brackets on the next line, * `for`, `if`, `else`, `while` and similar statements put the braces on the next line,
although brackets are not needed for single statements. if the following block is more than one statement. Use no braces for single statements.
* Function and class definitions have their brackets on separate lines. * Function and class definitions have their braces on separate lines.
* A function implementation's return type is on its own line. * A function implementation's return type is on its own line.
* `CamelCase.{cpp,h}` style file names. * `CamelCase.{cpp,h}` style file names.
@ -63,8 +69,9 @@ MyClass::myMethod( QStringList list, const QString& name )
if ( list.isEmpty() ) if ( list.isEmpty() )
return false; return false;
cDebug() << "Items in list ..";
foreach ( const QString& string, list ) foreach ( const QString& string, list )
cDebug() << "Current string is " << string; cDebug() << " .." << string;
switch ( m_enumValue ) switch ( m_enumValue )
{ {
@ -77,7 +84,7 @@ MyClass::myMethod( QStringList list, const QString& name )
} }
``` ```
You can use the `hacking/calamaresstyle` script to run You can use the `ci/calamaresstyle` script to run
[astyle](http://astyle.sf.net) on your code and have it formatted the right [astyle](http://astyle.sf.net) on your code and have it formatted the right
way. way.
@ -85,6 +92,7 @@ way.
order to take advantage of this functionality you will need to acquire the order to take advantage of this functionality you will need to acquire the
[EditorConfig](http://editorconfig.org/#download) plug-in for your editor. [EditorConfig](http://editorconfig.org/#download) plug-in for your editor.
Naming Naming
------ ------
* Use CamelCase for everything. * Use CamelCase for everything.
@ -97,6 +105,7 @@ Naming
* If it's a getter for a boolean, prefix with 'is', so `isCondition()`. * If it's a getter for a boolean, prefix with 'is', so `isCondition()`.
* A setter is `setVariable( arg )`. * A setter is `setVariable( arg )`.
Includes Includes
-------- --------
Header includes should be listed in the following order: Header includes should be listed in the following order:
@ -109,8 +118,9 @@ Header includes should be listed in the following order:
They should also be sorted alphabetically for ease of locating them. They should also be sorted alphabetically for ease of locating them.
Includes in a header file should be kept to the absolute minimum, as to keep compile times short. This can be achieved by using forward declarations instead of includes, Includes in a header file should be kept to the absolute minimum, as to keep
like `class QListView;`. compile times short. This can be achieved by using forward declarations
instead of includes, like `class QListView;`.
Example: Example:
``` ```
@ -129,6 +139,7 @@ Example:
Use include guards, not `#pragma once`. Use include guards, not `#pragma once`.
C++ tips C++ tips
-------- --------
All C++11 features are acceptable, and the use of new C++11 features is encouraged when All C++11 features are acceptable, and the use of new C++11 features is encouraged when
@ -160,10 +171,31 @@ connect( m_moduleManager, &Calamares::ModuleManager::modulesLoaded, [this]
}); });
``` ```
Debugging
---------
Use `cDebug()` and `cLog()` from `utils/Logger.h`.
[1]: http://blog.qt.digia.com/blog/2011/05/26/cpp0x-in-qt/ [1]: http://blog.qt.digia.com/blog/2011/05/26/cpp0x-in-qt/
[2]: http://qt-project.org/wiki/New_Signal_Slot_Syntax [2]: http://qt-project.org/wiki/New_Signal_Slot_Syntax
Debugging
---------
Use `cDebug()` and `cLog()` from `utils/Logger.h`. You can pass a debug-level to
either macro (1 is debugging, higher is less important). Use `cLog()` for warning
messages. It is recommended to add *WARNING* as the first part of a warning
message.
For log messages that are continued across multiple calls to `cDebug()`,
in particular listing things, conventional formatting is as follows:
* End the first debug message with ` ..`
* Indent following lines with ` ..`
Commit Messages
---------------
Keep commit messages short(-ish) and try to describe what is being changed
*as well as why*. Use the commit keywords for GitHub, especially *FIXES:*
to auto-close issues when they are resolved.
For functional changes to Calamares modules or libraries, try to put
*[modulename]* in front of the first line of the commit message.
For non-functional changes to infrastructure, try to label the change
with the kind of change, e.g. *CMake* or *i18n* or *Documentation*.

View File

@ -46,7 +46,7 @@ public:
#endif #endif
} }
void setJobs( const QList< job_ptr >& jobs ) void setJobs( const JobList& jobs )
{ {
m_jobs = jobs; m_jobs = jobs;
} }
@ -73,7 +73,7 @@ public:
} }
private: private:
QList< job_ptr > m_jobs; JobList m_jobs;
JobQueue* m_queue; JobQueue* m_queue;
int m_jobIndex; int m_jobIndex;
@ -164,7 +164,7 @@ JobQueue::enqueue( const job_ptr& job )
void void
JobQueue::enqueue( const QList< job_ptr >& jobs ) JobQueue::enqueue( const JobList& jobs )
{ {
Q_ASSERT( !m_thread->isRunning() ); Q_ASSERT( !m_thread->isRunning() );
m_jobs.append( jobs ); m_jobs.append( jobs );

View File

@ -42,11 +42,11 @@ public:
GlobalStorage* globalStorage() const; GlobalStorage* globalStorage() const;
void enqueue( const job_ptr& job ); void enqueue( const job_ptr& job );
void enqueue( const QList< job_ptr >& jobs ); void enqueue( const JobList& jobs );
void start(); void start();
signals: signals:
void queueChanged( const QList< job_ptr >& jobs ); void queueChanged( const JobList& jobs );
void progress( qreal percent, const QString& prettyName ); void progress( qreal percent, const QString& prettyName );
void finished(); void finished();
void failed( const QString& message, const QString& details ); void failed( const QString& message, const QString& details );
@ -54,7 +54,7 @@ signals:
private: private:
static JobQueue* s_instance; static JobQueue* s_instance;
QList< job_ptr > m_jobs; JobList m_jobs;
JobThread* m_thread; JobThread* m_thread;
GlobalStorage* m_storage; GlobalStorage* m_storage;
}; };

View File

@ -19,6 +19,7 @@
#ifndef TYPEDEFS_H #ifndef TYPEDEFS_H
#define TYPEDEFS_H #define TYPEDEFS_H
#include <QList>
#include <QSharedPointer> #include <QSharedPointer>
namespace Calamares namespace Calamares
@ -26,6 +27,7 @@ namespace Calamares
class Job; class Job;
typedef QSharedPointer< Job > job_ptr; typedef QSharedPointer< Job > job_ptr;
using JobList = QList< job_ptr >;
enum ModuleAction : char enum ModuleAction : char
{ {

View File

@ -326,5 +326,35 @@ crash()
*a = 1; *a = 1;
} }
bool
getBool( const QVariantMap& map, const QString& key, bool d )
{
bool result = d;
if ( map.contains( key ) )
{
auto v = map.value( key );
if ( v.type() == QVariant::Bool )
result = v.toBool();
}
return result;
}
QVariantMap
getSubMap( const QVariantMap& map, const QString& key, bool& success )
{
success = false;
if ( map.contains( key ) )
{
auto v = map.value( key );
if ( v.type() == QVariant::Map )
{
success = true;
return v.toMap();
}
}
return QVariantMap();
}
} }

View File

@ -97,6 +97,22 @@ namespace CalamaresUtils
* @brief crash makes Calamares crash immediately. * @brief crash makes Calamares crash immediately.
*/ */
DLLEXPORT void crash(); DLLEXPORT void crash();
/**
* Get a bool value from a mapping with a given key; returns the default
* if no value is stored in the map.
*/
DLLEXPORT bool getBool( const QVariantMap& map, const QString& key, bool d );
/**
* Returns a sub-map (i.e. a nested map) from the given mapping with the
* given key. @p success is set to true if the @p key exists
* in @p map and converts to a map, false otherwise.
*
* Returns an empty map if there is no such key or it is not a map-value.
* (e.g. if @p success is false).
*/
DLLEXPORT QVariantMap getSubMap( const QVariantMap& map, const QString& key, bool& success );
} }
#endif // CALAMARESUTILS_H #endif // CALAMARESUTILS_H

View File

@ -148,10 +148,10 @@ ExecutionViewStep::onActivate()
} }
QList< Calamares::job_ptr > JobList
ExecutionViewStep::jobs() const ExecutionViewStep::jobs() const
{ {
return QList< Calamares::job_ptr >(); return JobList();
} }

View File

@ -52,7 +52,7 @@ public:
void onActivate() override; void onActivate() override;
QList< job_ptr > jobs() const override; JobList jobs() const override;
void appendJobModuleInstanceKey( const QString& instanceKey ); void appendJobModuleInstanceKey( const QString& instanceKey );

View File

@ -75,10 +75,10 @@ CppJobModule::loadSelf()
} }
QList< job_ptr > JobList
CppJobModule::jobs() const CppJobModule::jobs() const
{ {
return QList< job_ptr >() << m_job; return JobList() << m_job;
} }

View File

@ -36,7 +36,7 @@ public:
Interface interface() const override; Interface interface() const override;
void loadSelf() override; void loadSelf() override;
QList< job_ptr > jobs() const override; JobList jobs() const override;
protected: protected:
void initFrom( const QVariantMap& moduleDescriptor ) override; void initFrom( const QVariantMap& moduleDescriptor ) override;

View File

@ -70,7 +70,6 @@ public:
ProcessInterface, ProcessInterface,
PythonQtInterface PythonQtInterface
}; };
virtual ~Module();
/** /**
* @brief fromDescriptor creates a new Module object of the correct type. * @brief fromDescriptor creates a new Module object of the correct type.
@ -84,6 +83,7 @@ public:
const QString& instanceId, const QString& instanceId,
const QString& configFileName, const QString& configFileName,
const QString& moduleDirectory ); const QString& moduleDirectory );
virtual ~Module();
/** /**
* @brief name returns the name of this module. * @brief name returns the name of this module.
@ -159,7 +159,7 @@ public:
* @brief jobs returns any jobs exposed by this module. * @brief jobs returns any jobs exposed by this module.
* @return a list of jobs (can be empty). * @return a list of jobs (can be empty).
*/ */
virtual QList< job_ptr > jobs() const = 0; virtual JobList jobs() const = 0;
/** /**
* @brief configurationMap returns the contents of the configuration file for * @brief configurationMap returns the contents of the configuration file for

View File

@ -53,10 +53,10 @@ ProcessJobModule::loadSelf()
} }
QList< job_ptr > JobList
ProcessJobModule::jobs() const ProcessJobModule::jobs() const
{ {
return QList< job_ptr >() << m_job; return JobList() << m_job;
} }

View File

@ -34,7 +34,7 @@ public:
Interface interface() const override; Interface interface() const override;
void loadSelf() override; void loadSelf() override;
QList< job_ptr > jobs() const override; JobList jobs() const override;
protected: protected:
void initFrom( const QVariantMap& moduleDescriptor ) override; void initFrom( const QVariantMap& moduleDescriptor ) override;

View File

@ -53,10 +53,10 @@ PythonJobModule::loadSelf()
} }
QList< job_ptr > JobList
PythonJobModule::jobs() const PythonJobModule::jobs() const
{ {
return QList< job_ptr >() << m_job; return JobList() << m_job;
} }

View File

@ -32,7 +32,7 @@ public:
Interface interface() const override; Interface interface() const override;
void loadSelf() override; void loadSelf() override;
QList< job_ptr > jobs() const override; JobList jobs() const override;
protected: protected:
void initFrom( const QVariantMap& moduleDescriptor ) override; void initFrom( const QVariantMap& moduleDescriptor ) override;

View File

@ -171,7 +171,7 @@ PythonQtViewModule::loadSelf()
} }
QList< job_ptr > JobList
PythonQtViewModule::jobs() const PythonQtViewModule::jobs() const
{ {
return m_viewStep->jobs(); return m_viewStep->jobs();

View File

@ -33,7 +33,7 @@ public:
Interface interface() const override; Interface interface() const override;
void loadSelf() override; void loadSelf() override;
QList< job_ptr > jobs() const override; JobList jobs() const override;
protected: protected:
void initFrom( const QVariantMap& moduleDescriptor ) override; void initFrom( const QVariantMap& moduleDescriptor ) override;

View File

@ -76,7 +76,7 @@ ViewModule::loadSelf()
} }
QList< job_ptr > JobList
ViewModule::jobs() const ViewModule::jobs() const
{ {
return m_viewStep->jobs(); return m_viewStep->jobs();

View File

@ -37,7 +37,7 @@ public:
Interface interface() const override; Interface interface() const override;
void loadSelf() override; void loadSelf() override;
QList< job_ptr > jobs() const override; JobList jobs() const override;
protected: protected:
void initFrom( const QVariantMap& moduleDescriptor ) override; void initFrom( const QVariantMap& moduleDescriptor ) override;

View File

@ -62,7 +62,7 @@ DebugWindow::DebugWindow()
// JobQueue page // JobQueue page
jobQueueText->setReadOnly( true ); jobQueueText->setReadOnly( true );
connect( JobQueue::instance(), &JobQueue::queueChanged, connect( JobQueue::instance(), &JobQueue::queueChanged,
this, [ this ]( const QList< Calamares::job_ptr >& jobs ) this, [ this ]( const JobList& jobs )
{ {
QStringList text; QStringList text;
for ( const auto &job : jobs ) for ( const auto &job : jobs )

View File

@ -159,10 +159,10 @@ PythonQtViewStep::isAtEnd() const
} }
QList< Calamares::job_ptr > JobList
PythonQtViewStep::jobs() const PythonQtViewStep::jobs() const
{ {
QList< Calamares::job_ptr > jobs; JobList jobs;
PythonQtObjectPtr jobsCallable = PythonQt::self()->lookupCallable( m_obj, "jobs" ); PythonQtObjectPtr jobsCallable = PythonQt::self()->lookupCallable( m_obj, "jobs" );
if ( jobsCallable.isNull() ) if ( jobsCallable.isNull() )

View File

@ -46,7 +46,7 @@ public:
bool isAtBeginning() const override; bool isAtBeginning() const override;
bool isAtEnd() const override; bool isAtEnd() const override;
QList< Calamares::job_ptr > jobs() const override; JobList jobs() const override;
void setConfigurationMap( const QVariantMap& configurationMap ) override; void setConfigurationMap( const QVariantMap& configurationMap ) override;

View File

@ -91,7 +91,7 @@ public:
*/ */
virtual void onLeave(); virtual void onLeave();
virtual QList< job_ptr > jobs() const = 0; virtual JobList jobs() const = 0;
void setModuleInstanceKey( const QString& instanceKey ); void setModuleInstanceKey( const QString& instanceKey );
QString moduleInstanceKey() const QString moduleInstanceKey() const

View File

@ -3,6 +3,7 @@ include( CMakeColors )
if( BUILD_TESTING ) if( BUILD_TESTING )
add_executable( test_conf test_conf.cpp ) add_executable( test_conf test_conf.cpp )
target_link_libraries( test_conf ${YAMLCPP_LIBRARY} ) target_link_libraries( test_conf ${YAMLCPP_LIBRARY} )
target_include_directories( test_conf PUBLIC ${YAMLCPP_INCLUDE_DIR} )
endif() endif()
file( GLOB SUBDIRECTORIES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*" ) file( GLOB SUBDIRECTORIES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*" )

View File

@ -120,7 +120,7 @@ LocaleViewStep::fetchGeoIpTimezone()
try try
{ {
YAML::Node doc = YAML::Load( reply->readAll() ); YAML::Node doc = YAML::Load( data );
QVariant var = CalamaresUtils::yamlToVariant( doc ); QVariant var = CalamaresUtils::yamlToVariant( doc );
if ( !var.isNull() && if ( !var.isNull() &&

View File

@ -1,7 +1,27 @@
--- ---
# This settings are used to set your default system time zone.
# Time zones are usually located under /usr/share/zoneinfo and
# provided by the 'tzdata' package of your Distribution.
#
# Distributions using systemd can list available
# time zones by using the timedatectl command.
# timedatectl list-timezones
region: "America" region: "America"
zone: "New_York" zone: "New_York"
# GeoIP settings. Leave commented out to disable GeoIP.
#localeGenPath: "/etc/locale.gen" # System locales are detected in the following order:
#
# /usr/share/i18n/SUPPORTED
# localeGenPath (defaults to /etc/locale.gen if not set)
# 'locale -a' output
# Enable only when your Distribution is using an
# custom path for locale.gen
#localeGenPath: "PATH_TO/locale.gen"
# GeoIP based Language settings:
# GeoIP need an working Internet connecion.
# This can be managed from welcome.conf by adding
# internet to the list of required conditions.
# Leave commented out to disable GeoIP.
#geoipUrl: "freegeoip.net" #geoipUrl: "freegeoip.net"

View File

@ -57,14 +57,6 @@ NetInstallPage::NetInstallPage( QWidget* parent )
ui->setupUi( this ); ui->setupUi( this );
} }
bool
NetInstallPage::isReady()
{
// nothing to wait for, the data are immediately ready
// if the user does not select any group nothing is installed
return true;
}
bool bool
NetInstallPage::readGroups( const QByteArray& yamlData ) NetInstallPage::readGroups( const QByteArray& yamlData )
{ {
@ -92,10 +84,13 @@ NetInstallPage::readGroups( const QByteArray& yamlData )
void void
NetInstallPage::dataIsHere( QNetworkReply* reply ) NetInstallPage::dataIsHere( QNetworkReply* reply )
{ {
// If m_required is *false* then we still say we're ready
// even if the reply is corrupt or missing.
if ( reply->error() != QNetworkReply::NoError ) if ( reply->error() != QNetworkReply::NoError )
{ {
cDebug() << reply->errorString(); cDebug() << reply->errorString();
ui->netinst_status->setText( tr( "Network Installation. (Disabled: Unable to fetch package lists, check your network connection)" ) ); ui->netinst_status->setText( tr( "Network Installation. (Disabled: Unable to fetch package lists, check your network connection)" ) );
emit checkReady( !m_required );
return; return;
} }
@ -104,6 +99,7 @@ NetInstallPage::dataIsHere( QNetworkReply* reply )
cDebug() << "Netinstall groups data was received, but invalid."; cDebug() << "Netinstall groups data was received, but invalid.";
ui->netinst_status->setText( tr( "Network Installation. (Disabled: Received invalid groups data)" ) ); ui->netinst_status->setText( tr( "Network Installation. (Disabled: Received invalid groups data)" ) );
reply->deleteLater(); reply->deleteLater();
emit checkReady( !m_required );
return; return;
} }
@ -112,15 +108,23 @@ NetInstallPage::dataIsHere( QNetworkReply* reply )
ui->groupswidget->header()->setSectionResizeMode( 1, QHeaderView::Stretch ); ui->groupswidget->header()->setSectionResizeMode( 1, QHeaderView::Stretch );
reply->deleteLater(); reply->deleteLater();
emit checkReady( isReady() ); emit checkReady( true );
} }
QList<PackageTreeItem::ItemData> NetInstallPage::selectedPackages() const PackageModel::PackageItemDataList
NetInstallPage::selectedPackages() const
{ {
if ( m_groups )
return m_groups->getPackages(); return m_groups->getPackages();
else
{
cDebug() << "WARNING: no netinstall groups are available.";
return PackageModel::PackageItemDataList();
}
} }
void NetInstallPage::loadGroupList() void
NetInstallPage::loadGroupList()
{ {
QString confUrl( QString confUrl(
Calamares::JobQueue::instance()->globalStorage()->value( Calamares::JobQueue::instance()->globalStorage()->value(
@ -139,7 +143,15 @@ void NetInstallPage::loadGroupList()
m_networkManager.get( request ); m_networkManager.get( request );
} }
void NetInstallPage::onActivate() void
NetInstallPage::setRequired( bool b )
{
m_required = b;
}
void
NetInstallPage::onActivate()
{ {
ui->groupswidget->setFocus(); ui->groupswidget->setFocus();
} }

View File

@ -46,17 +46,24 @@ public:
void onActivate(); void onActivate();
bool isReady();
// Retrieves the groups, with name, description and packages, from // Retrieves the groups, with name, description and packages, from
// the remote URL configured in the settings. Assumes the URL is already // the remote URL configured in the settings. Assumes the URL is already
// in the global storage. This should be called before displaying the page. // in the global storage. This should be called before displaying the page.
void loadGroupList(); void loadGroupList();
// Sets the "required" state of netinstall data. Influences whether
// corrupt or unavailable data causes checkReady() to be emitted
// true (not-required) or false.
void setRequired( bool );
bool getRequired() const
{
return m_required;
}
// Returns the list of packages belonging to groups that are // Returns the list of packages belonging to groups that are
// selected in the view in this given moment. No data is cached here, so // selected in the view in this given moment. No data is cached here, so
// this function does not have constant time. // this function does not have constant time.
QList<PackageTreeItem::ItemData> selectedPackages() const; PackageModel::PackageItemDataList selectedPackages() const;
public slots: public slots:
void dataIsHere( QNetworkReply* ); void dataIsHere( QNetworkReply* );
@ -76,6 +83,7 @@ private:
QNetworkAccessManager m_networkManager; QNetworkAccessManager m_networkManager;
PackageModel* m_groups; PackageModel* m_groups;
bool m_required;
}; };
#endif // NETINSTALLPAGE_H #endif // NETINSTALLPAGE_H

View File

@ -2,6 +2,7 @@
* Copyright 2016, Luca Giambonini <almack@chakraos.org> * Copyright 2016, Luca Giambonini <almack@chakraos.org>
* Copyright 2016, Lisa Vitolo <shainer@chakraos.org> * Copyright 2016, Lisa Vitolo <shainer@chakraos.org>
* Copyright 2017, Kyle Robbertze <krobbertze@gmail.com> * Copyright 2017, Kyle Robbertze <krobbertze@gmail.com>
* Copyright 2017, Adriaan de Groot <groot@kde.org>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -30,11 +31,11 @@ CALAMARES_PLUGIN_FACTORY_DEFINITION( NetInstallViewStepFactory, registerPlugin<N
NetInstallViewStep::NetInstallViewStep( QObject* parent ) NetInstallViewStep::NetInstallViewStep( QObject* parent )
: Calamares::ViewStep( parent ) : Calamares::ViewStep( parent )
, m_widget( new NetInstallPage() ) , m_widget( new NetInstallPage() )
, m_nextEnabled( true ) , m_nextEnabled( false )
{ {
emit nextStatusChanged( true ); emit nextStatusChanged( true );
connect( m_widget, &NetInstallPage::checkReady, connect( m_widget, &NetInstallPage::checkReady,
this, &NetInstallViewStep::nextStatusChanged ); this, &NetInstallViewStep::nextIsReady );
} }
@ -126,7 +127,7 @@ NetInstallViewStep::onLeave()
cDebug() << "Leaving netinstall, adding packages to be installed" cDebug() << "Leaving netinstall, adding packages to be installed"
<< "to global storage"; << "to global storage";
QList<PackageTreeItem::ItemData> packages = m_widget->selectedPackages(); PackageModel::PackageItemDataList packages = m_widget->selectedPackages();
QVariantList installPackages; QVariantList installPackages;
QVariantList tryInstallPackages; QVariantList tryInstallPackages;
QVariantList packageOperations; QVariantList packageOperations;
@ -178,6 +179,11 @@ NetInstallViewStep::onLeave()
void void
NetInstallViewStep::setConfigurationMap( const QVariantMap& configurationMap ) NetInstallViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{ {
m_widget->setRequired(
configurationMap.contains( "required" ) &&
configurationMap.value( "required" ).type() == QVariant::Bool &&
configurationMap.value( "required" ).toBool() );
if ( configurationMap.contains( "groupsUrl" ) && if ( configurationMap.contains( "groupsUrl" ) &&
configurationMap.value( "groupsUrl" ).type() == QVariant::String ) configurationMap.value( "groupsUrl" ).type() == QVariant::String )
{ {
@ -186,3 +192,10 @@ NetInstallViewStep::setConfigurationMap( const QVariantMap& configurationMap )
m_widget->loadGroupList(); m_widget->loadGroupList();
} }
} }
void
NetInstallViewStep::nextIsReady( bool b )
{
m_nextEnabled = b;
emit nextStatusChanged( b );
}

View File

@ -60,6 +60,9 @@ public:
void setConfigurationMap( const QVariantMap& configurationMap ) override; void setConfigurationMap( const QVariantMap& configurationMap ) override;
public slots:
void nextIsReady( bool );
private: private:
NetInstallPage* m_widget; NetInstallPage* m_widget;
bool m_nextEnabled; bool m_nextEnabled;

View File

@ -1,3 +1,4 @@
/* === This file is part of Calamares - <http://github.com/calamares> === /* === This file is part of Calamares - <http://github.com/calamares> ===
* *
* Copyright (c) 2017, Kyle Robbertze <kyle@aims.ac.za> * Copyright (c) 2017, Kyle Robbertze <kyle@aims.ac.za>
@ -28,14 +29,13 @@
#include <yaml-cpp/yaml.h> #include <yaml-cpp/yaml.h>
// Required forward declarations
class PackageTreeItem;
class PackageModel : public QAbstractItemModel class PackageModel : public QAbstractItemModel
{ {
Q_OBJECT Q_OBJECT
public: public:
using PackageItemDataList = QList< PackageTreeItem::ItemData >;
explicit PackageModel( const YAML::Node& data, QObject* parent = nullptr ); explicit PackageModel( const YAML::Node& data, QObject* parent = nullptr );
~PackageModel() override; ~PackageModel() override;
@ -52,7 +52,7 @@ public:
QModelIndex parent( const QModelIndex& index ) const override; QModelIndex parent( const QModelIndex& index ) const override;
int rowCount( const QModelIndex& parent = QModelIndex() ) const override; int rowCount( const QModelIndex& parent = QModelIndex() ) const override;
int columnCount( const QModelIndex& parent = QModelIndex() ) const override; int columnCount( const QModelIndex& parent = QModelIndex() ) const override;
QList<PackageTreeItem::ItemData> getPackages() const; PackageItemDataList getPackages() const;
QList<PackageTreeItem*> getItemPackages( PackageTreeItem* item ) const; QList<PackageTreeItem*> getItemPackages( PackageTreeItem* item ) const;
private: private:

View File

@ -1,2 +1,13 @@
--- ---
# This is the URL that is retrieved to get the netinstall groups-and-packages
# data (which should be in the format described in netinstall.yaml).
groupsUrl: http://chakraos.org/netinstall.php groupsUrl: http://chakraos.org/netinstall.php
# If the installation can proceed without netinstall (e.g. the Live CD
# can create a working installed system, but netinstall is preferred
# to bring it up-to-date or extend functionality) leave this set to
# false (the default). If set to true, the netinstall data is required.
#
# This only has an effect if the netinstall data cannot be retrieved,
# or is corrupt: having "required" set, means the install cannot proceed.
required: false