From c8fd11b103b10d2b1a78ee7bde3dd8cc7ebee869 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 16 Sep 2017 07:01:47 -0400 Subject: [PATCH 01/30] Replace scandir with listdir, simplify loop FIXES: ?? --- src/modules/displaymanager/main.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/modules/displaymanager/main.py b/src/modules/displaymanager/main.py index fbed64def..e5c7155d4 100644 --- a/src/modules/displaymanager/main.py +++ b/src/modules/displaymanager/main.py @@ -480,12 +480,9 @@ def run(): ) if (os.path.exists(greeter_path)): - greeter_configured = False - # configure first found lightdm-greeter - for entry in os.scandir(greeter_path): - if entry.name.endswith('.desktop') \ - and not greeter_configured: + for entry in os.listdir(greeter_path): + if entry.name.endswith('.desktop'): greeter = entry.name.split('.')[0] libcalamares.utils.debug( "found greeter {!s}".format(greeter) @@ -500,9 +497,8 @@ def run(): libcalamares.utils.debug( "{!s} configured as greeter.".format(greeter) ) - greeter_configured = True - - if not greeter_configured: + break + else: return ("No lightdm greeter installed.") else: libcalamares.utils.debug("lightdm selected but not installed") From 706ac47111737db6ab5da0c90a86aac524ca72a4 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 16 Sep 2017 09:35:07 -0400 Subject: [PATCH 02/30] Clang: reduce warning settings - turn off warnings for missing prototypes (for now) because of MOC - turn off warnings about docs --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 74f69a8a7..1c095f475 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,7 @@ if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) set( CMAKE_C_FLAGS_RELEASE "-O4 -DNDEBUG" ) set( CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g" ) - set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded -Wno-undefined-reinterpret-cast -Wno-global-constructors -Wno-exit-time-destructors" ) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded -Wno-undefined-reinterpret-cast -Wno-global-constructors -Wno-exit-time-destructors -Wno-missing-prototypes -Wno-documentation-unknown-command") set( CMAKE_CXX_FLAGS_DEBUG "-g" ) set( CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG" ) set( CMAKE_CXX_FLAGS_RELEASE "-O4 -DNDEBUG" ) From e5b59d472e6ba790c1f1eb31c53bf088d7994ed2 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 16 Sep 2017 09:36:31 -0400 Subject: [PATCH 03/30] Clang: warnings-- --- src/modules/dummycpp/DummyCppJob.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/dummycpp/DummyCppJob.h b/src/modules/dummycpp/DummyCppJob.h index 2b2a51a75..6f5f234f5 100644 --- a/src/modules/dummycpp/DummyCppJob.h +++ b/src/modules/dummycpp/DummyCppJob.h @@ -34,7 +34,7 @@ class PLUGINDLLEXPORT DummyCppJob : public Calamares::CppJob public: explicit DummyCppJob( QObject* parent = nullptr ); - virtual ~DummyCppJob(); + virtual ~DummyCppJob() override; QString prettyName() const override; From a266ecb1331eadd9b80c0784f35ad000d39487a0 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 17 Sep 2017 06:48:07 -0400 Subject: [PATCH 04/30] CMake: simplify definitions, distinguish kinds of sources --- src/libcalamares/CMakeLists.txt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index cdd31b782..826e9f627 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -1,9 +1,11 @@ project( libcalamares ) -add_definitions( ${QT_DEFINITIONS} ) -add_definitions( -DQT_SHARED ) -add_definitions( -DQT_SHAREDPOINTER_TRACK_POINTERS ) -add_definitions( -DDLLEXPORT_PRO ) +add_definitions( + ${QT_DEFINITIONS} + -DQT_SHARED + -DQT_SHAREDPOINTER_TRACK_POINTERS + -DDLLEXPORT_PRO +) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/CalamaresConfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/CalamaresConfig.h ) @@ -16,12 +18,14 @@ set( libSources Job.cpp JobQueue.cpp ProcessJob.cpp - +) +set( kdsagSources kdsingleapplicationguard/kdsingleapplicationguard.cpp kdsingleapplicationguard/kdsharedmemorylocker.cpp kdsingleapplicationguard/kdtoolsglobal.cpp kdsingleapplicationguard/kdlockedsharedmemorypointer.cpp - +) +set( utilSources utils/CalamaresUtils.cpp utils/CalamaresUtilsSystem.cpp utils/Logger.cpp @@ -32,7 +36,6 @@ set( libSources include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} - ${QT_INCLUDE_DIR} ) @@ -73,7 +76,7 @@ if( WITH_PYTHONQT ) endif() -add_library( calamares SHARED ${libSources} ) +add_library( calamares SHARED ${libSources} ${kdsagSources} ${utilSources} ) set_target_properties( calamares PROPERTIES AUTOMOC TRUE From 5f213c0ec46b795ab6c7598f2445a12385f95bdd Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 17 Sep 2017 07:01:59 -0400 Subject: [PATCH 05/30] CMake: tidy way of adding Clang warnings --- CMakeLists.txt | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c095f475..71ff93c4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,23 @@ if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) set( CMAKE_C_FLAGS_RELEASE "-O4 -DNDEBUG" ) set( CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g" ) - set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded -Wno-undefined-reinterpret-cast -Wno-global-constructors -Wno-exit-time-destructors -Wno-missing-prototypes -Wno-documentation-unknown-command") + # Clang warnings: doing *everything* is counter-productive, since it warns + # about things which we can't fix (e.g. C++98 incompatibilities, but + # Calaares is C++14). + foreach( CLANG_WARNINGS + -Weverything + -Wno-c++98-compat + -Wno-c++98-compat-pedantic + -Wno-padded + -Wno-undefined-reinterpret-cast + -Wno-global-constructors + -Wno-exit-time-destructors + -Wno-missing-prototypes + -Wno-documentation-unknown-command + ) + string( APPEND CMAKE_CXX_FLAGS " ${CLANG_WARNINGS}" ) + endforeach() + set( CMAKE_CXX_FLAGS_DEBUG "-g" ) set( CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG" ) set( CMAKE_CXX_FLAGS_RELEASE "-O4 -DNDEBUG" ) From ddf7b7fc90f8bfdf2c39879a8eab8db3de1d8b6e Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 18 Sep 2017 12:12:10 +0200 Subject: [PATCH 06/30] CMake: remove superfluous indirection --- src/libcalamaresui/CMakeLists.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libcalamaresui/CMakeLists.txt b/src/libcalamaresui/CMakeLists.txt index 0648807b8..562c167e7 100644 --- a/src/libcalamaresui/CMakeLists.txt +++ b/src/libcalamaresui/CMakeLists.txt @@ -1,6 +1,6 @@ -set( CALAMARESUI_LIBRARY_TARGET calamaresui ) +project( libcalamaresui CXX ) -list( APPEND ${CALAMARESUI_LIBRARY_TARGET}_SOURCES +list( APPEND calamaresui_SOURCES modulesystem/CppJobModule.cpp modulesystem/Module.cpp modulesystem/ModuleManager.cpp @@ -29,12 +29,12 @@ list( APPEND ${CALAMARESUI_LIBRARY_TARGET}_SOURCES ViewManager.cpp ) -list( APPEND ${CALAMARESUI_LIBRARY_TARGET}_UI +list( APPEND calamaresui_UI utils/DebugWindow.ui ) if( WITH_PYTHON ) - list( APPEND ${CALAMARESUI_LIBRARY_TARGET}_SOURCES + list( APPEND calamaresui_SOURCES modulesystem/PythonJobModule.cpp ) endif() @@ -43,7 +43,7 @@ if( WITH_PYTHONQT ) include_directories(${PYTHON_INCLUDE_DIRS}) include_directories(${PYTHONQT_INCLUDE_DIR}) - list( APPEND ${CALAMARESUI_LIBRARY_TARGET}_SOURCES + list( APPEND calamaresui_SOURCES modulesystem/PythonQtViewModule.cpp utils/PythonQtUtils.cpp viewpages/PythonQtJob.cpp @@ -58,9 +58,9 @@ if( WITH_PYTHONQT ) ) endif() -calamares_add_library( ${CALAMARESUI_LIBRARY_TARGET} - SOURCES ${${CALAMARESUI_LIBRARY_TARGET}_SOURCES} - UI ${${CALAMARESUI_LIBRARY_TARGET}_UI} +calamares_add_library( calamaresui + SOURCES ${calamaresui_SOURCES} + UI ${calamaresui_UI} EXPORT_MACRO UIDLLEXPORT_PRO LINK_PRIVATE_LIBRARIES ${YAMLCPP_LIBRARY} From eede92646dc870d4d350e783c2a76d7e7981a3c5 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 18 Sep 2017 12:32:37 +0200 Subject: [PATCH 07/30] CMake: shuffle includes, drop useless (empty) QT_INCLUDE_DIR --- src/CMakeLists.txt | 15 ++++++++------- src/libcalamares/CMakeLists.txt | 1 - 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4ef6afcbb..c6483b940 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,17 +3,18 @@ include( CalamaresAddModuleSubdirectory ) include( CalamaresAddLibrary ) include( CalamaresAddBrandingSubdirectory ) -include_directories( ${CMAKE_CURRENT_BINARY_DIR}/libcalamares ) -include_directories( ${CMAKE_CURRENT_LIST_DIR}/libcalamares ) - -include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) -include_directories( ${CMAKE_CURRENT_LIST_DIR} ) +include_directories( + ${CMAKE_CURRENT_LIST_DIR} + ${CMAKE_CURRENT_LIST_DIR}/libcalamares + ${CMAKE_CURRENT_LIST_DIR}/libcalamaresui + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/libcalamares + ${CMAKE_CURRENT_BINARY_DIR}/libcalamaresui +) # library add_subdirectory( libcalamares ) -include_directories( ${CMAKE_CURRENT_BINARY_DIR}/libcalamaresui ) -include_directories( ${CMAKE_CURRENT_LIST_DIR}/libcalamaresui ) add_subdirectory( libcalamaresui ) # all things qml diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index 826e9f627..1f91e0050 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -36,7 +36,6 @@ set( utilSources include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} - ${QT_INCLUDE_DIR} ) From 49304849318241258ae7159cf38f32b708fe63c2 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 18 Sep 2017 14:59:53 +0200 Subject: [PATCH 08/30] CMake: massage build of libcalamares - Build also two OBJECT libraries, - Allow changing Clang warnings for third-party code. --- src/libcalamares/CMakeLists.txt | 43 ++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index 1f91e0050..c97e35ada 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -1,4 +1,4 @@ -project( libcalamares ) +project( libcalamares CXX ) add_definitions( ${QT_DEFINITIONS} @@ -19,24 +19,40 @@ set( libSources JobQueue.cpp ProcessJob.cpp ) -set( kdsagSources - kdsingleapplicationguard/kdsingleapplicationguard.cpp - kdsingleapplicationguard/kdsharedmemorylocker.cpp - kdsingleapplicationguard/kdtoolsglobal.cpp - kdsingleapplicationguard/kdlockedsharedmemorypointer.cpp + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} ) -set( utilSources + +# Build subdirs as their own separate OBJECT libraries, +# to allow changing compiler warnings on their code. +set( utilsSources utils/CalamaresUtils.cpp utils/CalamaresUtilsSystem.cpp utils/Logger.cpp utils/PluginFactory.cpp utils/Retranslator.cpp ) - -include_directories( - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} +add_library( utilsLib OBJECT ${utilsSources} ) +target_compile_options( utilsLib PUBLIC -fPIC ) +target_include_directories( utilsLib PUBLIC + $ ) +set_target_properties( utilsLib PROPERTIES AUTOMOC TRUE ) + +set( kdsagSources + kdsingleapplicationguard/kdsingleapplicationguard.cpp + kdsingleapplicationguard/kdsharedmemorylocker.cpp + kdsingleapplicationguard/kdtoolsglobal.cpp + kdsingleapplicationguard/kdlockedsharedmemorypointer.cpp +) +add_library( kdsagLib OBJECT ${kdsagSources} ) +target_compile_options( kdsagLib PUBLIC -fPIC ) +target_include_directories( kdsagLib PUBLIC + $ +) +set_target_properties( kdsagLib PROPERTIES AUTOMOC TRUE ) if( WITH_PYTHON ) @@ -75,7 +91,10 @@ if( WITH_PYTHONQT ) endif() -add_library( calamares SHARED ${libSources} ${kdsagSources} ${utilSources} ) +add_library( calamares SHARED ${libSources} + $ + $ +) set_target_properties( calamares PROPERTIES AUTOMOC TRUE From a14e98ce9543703288417a78689cbcfe95a69be8 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 18 Sep 2017 15:02:35 +0200 Subject: [PATCH 09/30] Crashreporter: remove further reference to removed lib --- CMakeLists.txt | 6 ------ src/CMakeLists.txt | 4 ---- 2 files changed, 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 71ff93c4e..ac5d5b820 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,7 +77,6 @@ find_package( YAMLCPP 0.5.1 REQUIRED ) find_package( PolkitQt5-1 REQUIRED ) option( WITH_PYTHON "Enable Python modules API (requires Boost.Python)." ON ) -# option( WITH_CRASHREPORTER "Build with CrashReporter" OFF ) option( INSTALL_CONFIG "Install configuration files" ON ) option( WITH_PYTHONQT "Enable next generation Python modules API (experimental, requires PythonQt)." OFF ) option( BUILD_TESTING "Build the testing tree." ON ) @@ -86,11 +85,6 @@ if( BUILD_TESTING ) enable_testing() endif () -# if( CMAKE_SYSTEM_PROCESSOR MATCHES "arm" OR NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libcrashreporter-qt/CMakeLists.txt" ) -# message( STATUS "Build of crashreporter disabled." ) -# set( WITH_CRASHREPORTER OFF ) -# endif() - find_package( PythonLibs 3.3 ) set_package_properties( PYTHONLIBS PROPERTIES diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c6483b940..c29a866d8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -28,7 +28,3 @@ add_subdirectory( modules ) # branding components add_subdirectory( branding ) - -if( WITH_CRASHREPORTER ) - add_subdirectory( crashreporter ) -endif() From ddb6455365d9376f1b926a42f3b891ac645abdc9 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 18 Sep 2017 15:10:13 +0200 Subject: [PATCH 10/30] Revert be2338ff0 (intended just to reduce warnings) - keep the calamaresstyle formatting changes, - drop shadowing and nullptr changes. FIXES #805 --- src/libcalamares/ProcessJob.h | 2 +- src/libcalamares/utils/PluginFactory.cpp | 95 ++++++++++--------- src/libcalamares/utils/PluginFactory.h | 12 +-- .../modulesystem/CppJobModule.h | 5 +- .../modulesystem/ProcessJobModule.h | 5 +- src/libcalamaresui/modulesystem/ViewModule.h | 5 +- 6 files changed, 67 insertions(+), 57 deletions(-) diff --git a/src/libcalamares/ProcessJob.h b/src/libcalamares/ProcessJob.h index 1ac7f7f08..ba6e650f6 100644 --- a/src/libcalamares/ProcessJob.h +++ b/src/libcalamares/ProcessJob.h @@ -32,7 +32,7 @@ public: bool runInChroot = false, int secondsTimeout = 30, QObject* parent = nullptr ); - virtual ~ProcessJob() override; + virtual ~ProcessJob(); QString prettyName() const override; QString prettyStatusMessage() const override; diff --git a/src/libcalamares/utils/PluginFactory.cpp b/src/libcalamares/utils/PluginFactory.cpp index ff6c9913f..710633866 100644 --- a/src/libcalamares/utils/PluginFactory.cpp +++ b/src/libcalamares/utils/PluginFactory.cpp @@ -26,7 +26,7 @@ #include #include -Q_GLOBAL_STATIC(QObjectCleanupHandler, factorycleanup) +Q_GLOBAL_STATIC( QObjectCleanupHandler, factorycleanup ) extern int kLibraryDebugArea(); @@ -34,89 +34,96 @@ namespace Calamares { PluginFactory::PluginFactory() - : d_ptr_p(new PluginFactoryPrivate) + : d_ptr( new PluginFactoryPrivate ) { - Q_D(PluginFactory); + Q_D( PluginFactory ); d->q_ptr = this; - factorycleanup()->add(this); + factorycleanup()->add( this ); } -PluginFactory::PluginFactory(PluginFactoryPrivate &d) - : d_ptr_p(&d) +PluginFactory::PluginFactory( PluginFactoryPrivate& d ) + : d_ptr( &d ) { - factorycleanup()->add(this); + factorycleanup()->add( this ); } PluginFactory::~PluginFactory() { - delete d_ptr_p; + delete d_ptr; } -void PluginFactory::doRegisterPlugin(const QString &keyword, const QMetaObject *metaObject, CreateInstanceFunction instanceFunction) +void PluginFactory::doRegisterPlugin( const QString& keyword, const QMetaObject* metaObject, CreateInstanceFunction instanceFunction ) { - Q_D(PluginFactory); + Q_D( PluginFactory ); - Q_ASSERT(metaObject); + Q_ASSERT( metaObject ); // we allow different interfaces to be registered without keyword - if (!keyword.isEmpty()) { - if (d->createInstanceHash.contains(keyword)) { + if ( !keyword.isEmpty() ) + { + if ( d->createInstanceHash.contains( keyword ) ) qWarning() << "A plugin with the keyword" << keyword << "was already registered. A keyword must be unique!"; - } - d->createInstanceHash.insert(keyword, PluginFactoryPrivate::Plugin(metaObject, instanceFunction)); - } else { - const QList clashes(d->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) { + d->createInstanceHash.insert( keyword, PluginFactoryPrivate::Plugin( metaObject, instanceFunction ) ); + } + else + { + const QList clashes( d->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) { + 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) { + 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."; - } } } } - d->createInstanceHash.insertMulti(keyword, PluginFactoryPrivate::Plugin(metaObject, instanceFunction)); + d->createInstanceHash.insertMulti( keyword, PluginFactoryPrivate::Plugin( metaObject, instanceFunction ) ); } } -QObject *PluginFactory::create(const char *iface, QWidget *parentWidget, QObject *parent, const QString &keyword) +QObject* PluginFactory::create( const char* iface, QWidget* parentWidget, QObject* parent, const QString& keyword ) { - Q_D(PluginFactory); + Q_D( PluginFactory ); - QObject *obj( nullptr ); + QObject* obj = 0; - const QList candidates(d->createInstanceHash.values(keyword)); + const QList candidates( d->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) { + 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); + obj = plugin.second( parentWidget, parent ); break; } } } - if (obj) { - emit objectCreated(obj); - } + if ( obj ) + emit objectCreated( obj ); return obj; } diff --git a/src/libcalamares/utils/PluginFactory.h b/src/libcalamares/utils/PluginFactory.h index d7dc61783..a1f1597b5 100644 --- a/src/libcalamares/utils/PluginFactory.h +++ b/src/libcalamares/utils/PluginFactory.h @@ -222,7 +222,7 @@ public: * \returns A pointer to the created object is returned, or 0 if an error occurred. */ template - T* create( QObject* parent = nullptr ); + T* create( QObject* parent = 0 ); /** * Use this method to create an object. It will try to create an object which inherits @@ -235,7 +235,7 @@ public: * \returns A pointer to the created object is returned, or 0 if an error occurred. */ template - T* create( const QString& keyword, QObject* parent = nullptr ); + T* create( const QString& keyword, QObject* parent = 0 ); Q_SIGNALS: void objectCreated( QObject* object ); @@ -300,7 +300,7 @@ protected: doRegisterPlugin( keyword, &T::staticMetaObject, instanceFunction ); } - PluginFactoryPrivate* const d_ptr_p; + PluginFactoryPrivate* const d_ptr; /** * This function is called when the factory asked to create an Object. @@ -321,7 +321,7 @@ protected: static QObject* createInstance( QWidget* parentWidget, QObject* parent ) { Q_UNUSED( parentWidget ); - ParentType* p( nullptr ); + ParentType* p = 0; if ( parent ) { p = qobject_cast( parent ); @@ -338,7 +338,7 @@ template inline T* PluginFactory::create( QObject* parent ) { QObject* o = create( T::staticMetaObject.className(), - parent && parent->isWidgetType() ? reinterpret_cast( parent ) : nullptr, + parent && parent->isWidgetType() ? reinterpret_cast( parent ) : 0, parent, QString() ); @@ -352,7 +352,7 @@ template inline T* PluginFactory::create( const QString& keyword, QObject* parent ) { QObject* o = create( T::staticMetaObject.className(), - parent && parent->isWidgetType() ? reinterpret_cast( parent ) : nullptr, + parent && parent->isWidgetType() ? reinterpret_cast( parent ) : 0, parent, keyword ); diff --git a/src/libcalamaresui/modulesystem/CppJobModule.h b/src/libcalamaresui/modulesystem/CppJobModule.h index 92c4224d3..9ec8a6eaa 100644 --- a/src/libcalamaresui/modulesystem/CppJobModule.h +++ b/src/libcalamaresui/modulesystem/CppJobModule.h @@ -25,7 +25,8 @@ class QPluginLoader; -namespace Calamares { +namespace Calamares +{ class UIDLLEXPORT CppJobModule : public Module { @@ -42,7 +43,7 @@ protected: private: friend class Module; //so only the superclass can instantiate explicit CppJobModule(); - virtual ~CppJobModule() override; + virtual ~CppJobModule(); QPluginLoader* m_loader; job_ptr m_job; diff --git a/src/libcalamaresui/modulesystem/ProcessJobModule.h b/src/libcalamaresui/modulesystem/ProcessJobModule.h index 5bb1699be..7809d0d2f 100644 --- a/src/libcalamaresui/modulesystem/ProcessJobModule.h +++ b/src/libcalamaresui/modulesystem/ProcessJobModule.h @@ -23,7 +23,8 @@ #include "UiDllMacro.h" -namespace Calamares { +namespace Calamares +{ class UIDLLEXPORT ProcessJobModule : public Module { @@ -40,7 +41,7 @@ protected: private: friend class Module; explicit ProcessJobModule(); - virtual ~ProcessJobModule() override; + virtual ~ProcessJobModule(); QString m_command; QString m_workingPath; diff --git a/src/libcalamaresui/modulesystem/ViewModule.h b/src/libcalamaresui/modulesystem/ViewModule.h index bfbbdadf3..d36b58db9 100644 --- a/src/libcalamaresui/modulesystem/ViewModule.h +++ b/src/libcalamaresui/modulesystem/ViewModule.h @@ -24,7 +24,8 @@ class QPluginLoader; -namespace Calamares { +namespace Calamares +{ class ViewStep; @@ -43,7 +44,7 @@ protected: private: friend class Module; //so only the superclass can instantiate explicit ViewModule(); - virtual ~ViewModule() override; + virtual ~ViewModule(); QPluginLoader* m_loader; ViewStep* m_viewStep = nullptr; From f309e777c7d3bf4fb4607846bfc3efaed68ba771 Mon Sep 17 00:00:00 2001 From: Calamares CI Date: Mon, 18 Sep 2017 15:19:24 +0200 Subject: [PATCH 11/30] [core] Automatic merge of Transifex translations --- lang/calamares_gl.ts | 134 ++++++++++++++++++++-------------------- lang/calamares_is.ts | 8 +-- lang/calamares_pl.ts | 4 +- lang/calamares_pt_BR.ts | 4 +- lang/calamares_tr_TR.ts | 4 +- 5 files changed, 77 insertions(+), 77 deletions(-) diff --git a/lang/calamares_gl.ts b/lang/calamares_gl.ts index c6151588b..8e0de1ee5 100644 --- a/lang/calamares_gl.ts +++ b/lang/calamares_gl.ts @@ -71,18 +71,18 @@ Type: - + Tipo: none - + Non Interface: - + Interface @@ -241,7 +241,7 @@ Saída: Cancel installation without changing the system. - + Cancela-la instalación sen cambia-lo sistema @@ -258,17 +258,17 @@ O instalador pecharase e perderanse todos os cambios. &Yes - + &Si &No - + &Non &Close - + &Pechar @@ -293,12 +293,12 @@ O instalador pecharase e perderanse todos os cambios. &Done - + &Feito The installation is complete. Close the installer. - + Completouse a instalacion. Peche o instalador @@ -554,7 +554,7 @@ O instalador pecharase e perderanse todos os cambios. MiB - + MiB @@ -614,7 +614,7 @@ O instalador pecharase e perderanse todos os cambios. Mountpoint already in use. Please select another one. - + Punto de montaxe xa en uso. Faga o favor de escoller outro @@ -827,32 +827,32 @@ O instalador pecharase e perderanse todos os cambios. The type of <strong>partition table</strong> on the selected storage device.<br><br>The only way to change the partition table type is to erase and recreate the partition table from scratch, which destroys all data on the storage device.<br>This installer will keep the current partition table unless you explicitly choose otherwise.<br>If unsure, on modern systems GPT is preferred. - + O tipo de <strong>táboa de partición</strong>no dispositivo de almacenamento escollido.<br><br>O único xeito de cambia-lo tipo de partición é borrar e volver a crear a táboa de partición dende o comenzo, isto destrúe todolos datos no dispositivo de almacenamento. <br> Este instalador manterá a táboa de partición actúal agás que escolla outra cousa explicitamente. <br> Se non está seguro, en sistemas modernos é preferibel GPT. This device has a <strong>%1</strong> partition table. - + O dispositivo ten <strong>%1</strong> una táboa de partición. This is a <strong>loop</strong> device.<br><br>It is a pseudo-device with no partition table that makes a file accessible as a block device. This kind of setup usually only contains a single filesystem. - + Este é un dispositivo de tipo <strong>loop</strong>. <br><br> É un pseudo-dispositivo que non ten táboa de partición que permita acceder aos ficheiros como un dispositivo de bloques. Este,modo de configuración normalmente so contén un sistema de ficheiros individual. This installer <strong>cannot detect a partition table</strong> on the selected storage device.<br><br>The device either has no partition table, or the partition table is corrupted or of an unknown type.<br>This installer can create a new partition table for you, either automatically, or through the manual partitioning page. - + Este instalador <strong>non pode detectar unha táboa de partición </strong>no sistema de almacenamento seleccionado. <br><br>O dispositivo non ten táboa de particion ou a táboa de partición está corrompida ou é dun tipo descoñecido.<br>Este instalador poder crear una táboa de partición nova por vóstede, ben automaticamente ou a través de páxina de particionamento a man. <br><br>This is the recommended partition table type for modern systems which start from an <strong>EFI</strong> boot environment. - + <br><br>Este é o tipo de táboa de partición recomendada para sistema modernos que empezan dende un sistema de arranque <strong>EFI</strong>. <br><br>This partition table type is only advisable on older systems which start from a <strong>BIOS</strong> boot environment. GPT is recommended in most other cases.<br><br><strong>Warning:</strong> the MBR partition table is an obsolete MS-DOS era standard.<br>Only 4 <em>primary</em> partitions may be created, and of those 4, one can be an <em>extended</em> partition, which may in turn contain many <em>logical</em> partitions. - + <br><br>Esta táboa de partición so é recomendabel en sistemas vellos que empezan dende un sistema de arranque <strong>BIOS</strong>. GPT é recomendabel na meirande parte dos outros casos.<br><br><strong>Atención:</strong>A táboa de partición MBR é un estándar obsoleto da época do MS-DOS.<br>So pódense crear 4 particións <em>primarias</em>, e desas 4, una pode ser unha partición<em>extensa</em>, que pode conter muitas particións <em>lóxicas</em>. @@ -868,17 +868,17 @@ O instalador pecharase e perderanse todos os cambios. Write LUKS configuration for Dracut to %1 - + Escribila configuración LUKS para Dracut en %1 Skip writing LUKS configuration for Dracut: "/" partition is not encrypted - + Saltando escribila configuración LUKS para Dracut: A partición "/" non está encriptada Failed to open %1 - + Fallou ao abrir %1 @@ -894,27 +894,27 @@ O instalador pecharase e perderanse todos os cambios. Edit Existing Partition - + Editar unha partición existente Content: - + Contido: &Keep - + &Gardar Format - + Formato Warning: Formatting the partition will erase all existing data. - + Atención: Dar formato á partición borrará tódolos datos existentes. @@ -929,22 +929,22 @@ O instalador pecharase e perderanse todos os cambios. MiB - + MiB Fi&le System: - + Sistema de Ficheiros: Flags: - + Bandeiras: Mountpoint already in use. Please select another one. - + Punto de montaxe xa en uso. Faga o favor de escoller outro. @@ -952,27 +952,27 @@ O instalador pecharase e perderanse todos os cambios. Form - + Formulario En&crypt system - + En&criptar sistema Passphrase - + Frase de contrasinal Confirm passphrase - + Confirme a frase de contrasinal Please enter the same passphrase in both boxes. - + Faga o favor de introducila a misma frase de contrasinal námbalas dúas caixas. @@ -980,37 +980,37 @@ O instalador pecharase e perderanse todos os cambios. Set partition information - + Poñela información da partición Install %1 on <strong>new</strong> %2 system partition. - + Instalar %1 nunha <strong>nova</strong> partición do sistema %2 Set up <strong>new</strong> %2 partition with mount point <strong>%1</strong>. - + Configure unha <strong>nova</strong> partición %2 con punto de montaxe <strong>%1</strong>. Install %2 on %3 system partition <strong>%1</strong>. - + Instalar %2 na partición do sistema %3 <strong>%1</strong>. Set up %3 partition <strong>%1</strong> with mount point <strong>%2</strong>. - + Configurala partición %3 <strong>%1</strong> con punto de montaxe <strong>%2</strong>. Install boot loader on <strong>%1</strong>. - + Instalar o cargador de arranque en <strong>%1</strong>. Setting up mount points. - + Configuralos puntos de montaxe. @@ -1023,17 +1023,17 @@ O instalador pecharase e perderanse todos os cambios. &Restart now - + &Reiniciar agora. <h1>All done.</h1><br/>%1 has been installed on your computer.<br/>You may now restart into your new system, or continue using the %2 Live environment. - + <h1>Todo feito.</h1><br/>%1 foi instalado na súa computadora.<br/>Agora pode reiniciar no seu novo sistema ou continuar a usalo entorno Live %2. <h1>Installation Failed</h1><br/>%1 has not been installed on your computer.<br/>The error message was: %2. - + <h1>Fallou a instalación</h1><br/>%1 non se pudo instalar na sua computadora. <br/>A mensaxe de erro foi: %2. @@ -1041,17 +1041,17 @@ O instalador pecharase e perderanse todos os cambios. Finish - + Fin Installation Complete - + Instalacion completa The installation of %1 is complete. - + Completouse a instalación de %1 @@ -1059,22 +1059,22 @@ O instalador pecharase e perderanse todos os cambios. Format partition %1 (file system: %2, size: %3 MB) on %4. - + Formato da partición %1 (sistema de ficheiros: %2, tamaño: %3 MB) en %4. Format <strong>%3MB</strong> partition <strong>%1</strong> with file system <strong>%2</strong>. - + Formato <strong>%3MB</strong> partición <strong>%1</strong> con sistema de ficheiros <strong>%2</strong>. Formatting partition %1 with file system %2. - + Dando formato a %1 con sistema de ficheiros %2. The installer failed to format partition %1 on disk '%2'. - + O instalador fallou cando formateaba a partición %1 no disco '%2'. @@ -1104,19 +1104,19 @@ O instalador pecharase e perderanse todos os cambios. Konsole not installed - + Konsole non está instalado Please install the kde konsole and try again! - + Faga o favor de instalar konsole (de kde) e probe de novo! Executing script: &nbsp;<code>%1</code> - + Executando o script: &nbsp; <code>%1</code> @@ -1132,12 +1132,12 @@ O instalador pecharase e perderanse todos os cambios. Set keyboard model to %1.<br/> - + Seleccionado modelo de teclado a %1.<br/> Set keyboard layout to %1/%2. - + Seleccionada a disposición do teclado a %1/%2. @@ -1145,7 +1145,7 @@ O instalador pecharase e perderanse todos os cambios. Keyboard - + Teclado @@ -1153,22 +1153,22 @@ O instalador pecharase e perderanse todos os cambios. System locale setting - + Configuración da localización The system locale setting affects the language and character set for some command line user interface elements.<br/>The current setting is <strong>%1</strong>. - + A configuración de localización afecta a linguaxe e o conxunto de caracteres dalgúns elementos da interface de usuario de liña de comandos. <br/>A configuración actúal é <strong>%1</strong>. &Cancel - + &Cancelar &OK - + &Ok @@ -1181,33 +1181,33 @@ O instalador pecharase e perderanse todos os cambios. I accept the terms and conditions above. - + Acepto os termos e condicións anteriores. <h1>License Agreement</h1>This setup procedure will install proprietary software that is subject to licensing terms. - + <h1>Acordo de licencia</h1>Este proceso de configuración instalará programas privativos suxeito a termos de licencia. Please review the End User License Agreements (EULAs) above.<br/>If you do not agree with the terms, the setup procedure cannot continue. - + Faga o favor de revisalos Acordos de Licencia de Usuario Final (ALUF) seguintes. <br/>De non estar dacordo cos termos non se pode seguir co proceso de configuración. <h1>License Agreement</h1>This setup procedure can install proprietary software that is subject to licensing terms in order to provide additional features and enhance the user experience. - + <h1>Acordo de licencia</h1>Este proceso de configuración pode instalar programas privativos suxeito a termos de licencia para fornecer características adicionaís e mellorala experiencia do usuario. Please review the End User License Agreements (EULAs) above.<br/>If you do not agree with the terms, proprietary software will not be installed, and open source alternatives will be used instead. - + Faga o favor de revisalos Acordos de Licencia de Usuario Final (ALUF) seguintes. <br/>De non estar dacordo cos termos non se instalará o programa privativo e no seu lugar usaranse alternativas de código aberto. <strong>%1 driver</strong><br/>by %2 %1 is an untranslatable product name, example: Creative Audigy driver - + <strong>dispositivo %1</strong><br/>por %2 diff --git a/lang/calamares_is.ts b/lang/calamares_is.ts index df3938b28..bab0ad264 100644 --- a/lang/calamares_is.ts +++ b/lang/calamares_is.ts @@ -1050,7 +1050,7 @@ Uppsetningarforritið mun hætta og allar breytingar tapast. The installation of %1 is complete. - + Uppsetningu af %1 er lokið. @@ -1162,12 +1162,12 @@ Uppsetningarforritið mun hætta og allar breytingar tapast. &Cancel - + &Hætta við &OK - + &Í lagi @@ -1857,7 +1857,7 @@ Uppsetningarforritið mun hætta og allar breytingar tapast. The screen is too small to display the installer. - + Skjárinn er of lítill til að birta uppsetningarforritið. diff --git a/lang/calamares_pl.ts b/lang/calamares_pl.ts index 519528e08..806c28a7a 100644 --- a/lang/calamares_pl.ts +++ b/lang/calamares_pl.ts @@ -1162,12 +1162,12 @@ Instalator zostanie zamknięty i wszystkie zmiany zostaną utracone. &Cancel - + &Anuluj &OK - + &OK diff --git a/lang/calamares_pt_BR.ts b/lang/calamares_pt_BR.ts index b8a0ded8b..bebf1c8b7 100644 --- a/lang/calamares_pt_BR.ts +++ b/lang/calamares_pt_BR.ts @@ -1164,12 +1164,12 @@ A instalação pode continuar, mas alguns recursos podem ser desativados. &Cancel - + &Cancelar &OK - + &OK diff --git a/lang/calamares_tr_TR.ts b/lang/calamares_tr_TR.ts index 0b4bd3f6c..ba9335279 100644 --- a/lang/calamares_tr_TR.ts +++ b/lang/calamares_tr_TR.ts @@ -1165,12 +1165,12 @@ Kuruluma devam edebilirsiniz fakat bazı özellikler devre dışı kalabilir. &Cancel - + &Vazgeç &OK - + &TAMAM From 299e7b16d5bbce5b29156834ef1cf1db4591dd0e Mon Sep 17 00:00:00 2001 From: Calamares CI Date: Mon, 18 Sep 2017 15:19:24 +0200 Subject: [PATCH 12/30] [desktop] Automatic merge of Transifex translations --- calamares.desktop | 2 ++ 1 file changed, 2 insertions(+) diff --git a/calamares.desktop b/calamares.desktop index e52d999ed..8cae765df 100644 --- a/calamares.desktop +++ b/calamares.desktop @@ -11,6 +11,8 @@ Icon=calamares Terminal=false StartupNotify=true Categories=Qt;System; + +# Translations Name[ca]=Calamares Icon[ca]=calamares GenericName[ca]=Instal·lador de sistema From 6271dd39e91dfb6cc44aaf8c101a2a043818b10f Mon Sep 17 00:00:00 2001 From: Calamares CI Date: Mon, 18 Sep 2017 15:19:25 +0200 Subject: [PATCH 13/30] [python] Automatic merge of Transifex translations --- lang/python/is/LC_MESSAGES/python.mo | Bin 692 -> 1093 bytes lang/python/is/LC_MESSAGES/python.po | 12 ++++++------ lang/python/pl/LC_MESSAGES/python.mo | Bin 795 -> 1355 bytes lang/python/pl/LC_MESSAGES/python.po | 20 ++++++++++---------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lang/python/is/LC_MESSAGES/python.mo b/lang/python/is/LC_MESSAGES/python.mo index 23ed397ae65d64ccd25a71592faaa57c8fed7565..26b8d067634f69d7abd070717e93a12fea3c7b05 100644 GIT binary patch delta 521 zcmZ{eu}Z{16h)uwMptZ9WNj=4B#$V|j8oxO#X)`Hk5 z_yZz>`U`^Ju%F;foRD?Fz{yGO-1m}a=dD+MuXL{oR}ZX%Gq4D5L3O=@W$*!3!I$+I zu5xFFXa`<{H{nBg8@_-)!9A#YX7+df()tEoBHE=#JOn7bz%D$t@BJG h?UuTJijq!?dN}|0*Y<}zPhan%m`yH4+PCr4)*q&~e=`68 delta 118 zcmX@gv4u7Bo)F7a1|VPoVi_Q|0b*7ljsap2C;(zXAT9)A5g=}c(ldbcDMki{wLlsq fU%>>C?}F0vfizH>ffS6os$-Q*`AIbmJl*frLWiLVN&mBe)R3jkp<-A*4SurAdr-lV@<@%D#Yf zB|d^1#V3%0k03sRXQmlTYrAmZ@Fn-mx%bXP?R`D}+^XCY&Kk4}T|pbr5K`wA+JxSq z9cWze8&vh`3ef>r2OHoixDVcdUWw=tRJo7xgkRt`{>v53BdX&gN1*|F;0To97(|v< zp(=zN)gYAhvH+n!(Oq<$pNKeNosQLGew&3nZcR_a%(n{ z850q=T09Uul!cqlxznC1`|_Oq)6XYE5me98uXoj}2RzAGf1o#*xw7!(7je2|*|Rc488yW diff --git a/lang/python/pl/LC_MESSAGES/python.po b/lang/python/pl/LC_MESSAGES/python.po index 23619d62d..ec6e5bbd2 100644 --- a/lang/python/pl/LC_MESSAGES/python.po +++ b/lang/python/pl/LC_MESSAGES/python.po @@ -33,26 +33,26 @@ msgstr "Krok dummy python {}" #: src/modules/packages/main.py:59 #, python-format msgid "Processing packages (%(count)d / %(total)d)" -msgstr "" +msgstr "Przetwarzanie pakietów (%(count)d / %(total)d)" #: src/modules/packages/main.py:61 #, python-format msgid "Installing one package." msgid_plural "Installing %(num)d packages." -msgstr[0] "" -msgstr[1] "" -msgstr[2] "" -msgstr[3] "" +msgstr[0] "Instalowanie jednego pakietu." +msgstr[1] "Instalowanie %(num)d pakietów." +msgstr[2] "Instalowanie %(num)d pakietów." +msgstr[3] "Instalowanie pakietów (%(num)d)." #: src/modules/packages/main.py:64 #, python-format msgid "Removing one package." msgid_plural "Removing %(num)d packages." -msgstr[0] "" -msgstr[1] "" -msgstr[2] "" -msgstr[3] "" +msgstr[0] "Usuwanie jednego pakietu." +msgstr[1] "Usuwanie %(num)d pakietów." +msgstr[2] "Usuwanie %(num)d pakietów." +msgstr[3] "Usuwanie pakietów (%(num)d)." #: src/modules/packages/main.py:68 msgid "Install packages." -msgstr "" +msgstr "Zainstaluj pakiety." From c2a69ea9436640c93137e495f2d0501cfef5d412 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 18 Sep 2017 15:42:09 +0200 Subject: [PATCH 14/30] i18n: cleanup after txpull - remove extra .desktop files created in lang/ - remove annoyingly-doubled # Translations comment --- ci/txpull.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ci/txpull.sh b/ci/txpull.sh index 772ac0e32..53a0deaa4 100755 --- a/ci/txpull.sh +++ b/ci/txpull.sh @@ -43,6 +43,14 @@ BOILERPLATE="Automatic merge of Transifex translations" git add --verbose lang/calamares*.ts git commit "$AUTHOR" --message="[core] $BOILERPLATE" | true +rm -f lang/desktop*.desktop +awk ' + BEGIN {skip=0;} + /^# Translations/ {skip=1;} + {if (!skip || (length($0)>1 && $0 != "# Translations")) { + skip=0; print $0; + }}' < calamares.desktop > calamares.desktop.new +mv calamares.desktop.new calamares.desktop git add --verbose calamares.desktop git commit "$AUTHOR" --message="[desktop] $BOILERPLATE" | true From d839f8e0b311a3312eadbbc78d7e4e9ccdbcf708 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 18 Sep 2017 16:08:21 +0200 Subject: [PATCH 15/30] Passwords: introduce password-checking - Introduce a map 'passwordRequirements' in users.conf, which is a list of named requirements. There are only two settings right now, min and max length, but additional checks can easily be added in UsersPage.cpp by defining additional lambda's to check the given password string. - Add PasswordCheck instances as needed, with functions to check acceptability and to produce messages on rejection. - Documentation in the users.conf file itself. - In passing, refactor setting of pixmaps on labels. FIXES #790 --- src/modules/users/UsersPage.cpp | 159 +++++++++++++++++++++------- src/modules/users/UsersPage.h | 43 +++++++- src/modules/users/UsersViewStep.cpp | 15 ++- src/modules/users/users.conf | 14 +++ 4 files changed, 189 insertions(+), 42 deletions(-) diff --git a/src/modules/users/UsersPage.cpp b/src/modules/users/UsersPage.cpp index 87e64deb1..7c4bb6a7d 100644 --- a/src/modules/users/UsersPage.cpp +++ b/src/modules/users/UsersPage.cpp @@ -37,7 +37,12 @@ #include #include - +/** Add a standard pixmap to a label. */ +static void +markLabel( QLabel* label, CalamaresUtils::ImageType i ) +{ + label->setPixmap( CalamaresUtils::defaultPixmap( i, CalamaresUtils::Original, label->size() ) ); +} UsersPage::UsersPage( QWidget* parent ) : QWidget( parent ) @@ -268,9 +273,7 @@ UsersPage::validateUsernameText( const QString& textRef ) } else if ( text.length() > USERNAME_MAX_LENGTH ) { - ui->labelUsername->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::No, - CalamaresUtils::Original, - ui->labelUsername->size() ) ); + markLabel( ui->labelUsername, CalamaresUtils::No ); ui->labelUsernameError->setText( tr( "Your username is too long." ) ); @@ -278,18 +281,14 @@ UsersPage::validateUsernameText( const QString& textRef ) } else if ( val.validate( text, pos ) == QValidator::Invalid ) { - ui->labelUsername->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::No, - CalamaresUtils::Original, - ui->labelUsername->size() ) ); + markLabel( ui->labelUsername, CalamaresUtils::No ); ui->labelUsernameError->setText( tr( "Your username contains invalid characters. Only lowercase letters and numbers are allowed." ) ); m_readyUsername = false; } else { - ui->labelUsername->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::Yes, - CalamaresUtils::Original, - ui->labelUsername->size() ) ); + markLabel( ui->labelUsername, CalamaresUtils::Yes ); ui->labelUsernameError->clear(); m_readyUsername = true; } @@ -322,9 +321,7 @@ UsersPage::validateHostnameText( const QString& textRef ) } else if ( text.length() < HOSTNAME_MIN_LENGTH ) { - ui->labelHostname->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::No, - CalamaresUtils::Original, - ui->labelHostname->size() ) ); + markLabel( ui->labelHostname, CalamaresUtils::No ); ui->labelHostnameError->setText( tr( "Your hostname is too short." ) ); @@ -333,9 +330,7 @@ UsersPage::validateHostnameText( const QString& textRef ) } else if ( text.length() > HOSTNAME_MAX_LENGTH ) { - ui->labelHostname->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::No, - CalamaresUtils::Original, - ui->labelHostname->size() ) ); + markLabel( ui->labelHostname, CalamaresUtils::No ); ui->labelHostnameError->setText( tr( "Your hostname is too long." ) ); @@ -344,9 +339,7 @@ UsersPage::validateHostnameText( const QString& textRef ) } else if ( val.validate( text, pos ) == QValidator::Invalid ) { - ui->labelHostname->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::No, - CalamaresUtils::Original, - ui->labelHostname->size() ) ); + markLabel( ui->labelHostname, CalamaresUtils::No ); ui->labelHostnameError->setText( tr( "Your hostname contains invalid characters. Only letters, numbers and dashes are allowed." ) ); @@ -354,9 +347,7 @@ UsersPage::validateHostnameText( const QString& textRef ) } else { - ui->labelHostname->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::Yes, - CalamaresUtils::Original, - ui->labelHostname->size() ) ); + markLabel( ui->labelHostname, CalamaresUtils::Yes ); ui->labelHostnameError->clear(); m_readyHostname = true; } @@ -364,7 +355,6 @@ UsersPage::validateHostnameText( const QString& textRef ) emit checkReady( isReady() ); } - void UsersPage::onPasswordTextChanged( const QString& ) { @@ -380,24 +370,35 @@ UsersPage::onPasswordTextChanged( const QString& ) else if ( pw1 != pw2 ) { ui->labelUserPasswordError->setText( tr( "Your passwords do not match!" ) ); - ui->labelUserPassword->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::No, - CalamaresUtils::Original, - ui->labelUserPassword->size() ) ); + markLabel( ui->labelUserPassword, CalamaresUtils::No ); m_readyPassword = false; } else { - ui->labelUserPasswordError->clear(); - ui->labelUserPassword->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::Yes, - CalamaresUtils::Original, - ui->labelUserPassword->size() ) ); - m_readyPassword = true; + bool ok = true; + for ( auto pc : m_passwordChecks ) + { + QString s = pc.filter( pw1 ); + if ( !s.isEmpty() ) + { + ui->labelUserPasswordError->setText( s ); + markLabel( ui->labelUserPassword, CalamaresUtils::No ); + ok = false; + m_readyPassword = false; + } + } + + if ( ok ) + { + ui->labelUserPasswordError->clear(); + markLabel( ui->labelUserPassword, CalamaresUtils::Yes ); + m_readyPassword = true; + } } emit checkReady( isReady() ); } - void UsersPage::onRootPasswordTextChanged( const QString& ) { @@ -413,18 +414,30 @@ UsersPage::onRootPasswordTextChanged( const QString& ) else if ( pw1 != pw2 ) { ui->labelRootPasswordError->setText( tr( "Your passwords do not match!" ) ); - ui->labelRootPassword->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::No, - CalamaresUtils::Original, - ui->labelRootPassword->size() ) ); + markLabel( ui->labelRootPassword, CalamaresUtils::No ); m_readyRootPassword = false; } else { - ui->labelRootPasswordError->clear(); - ui->labelRootPassword->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::Yes, - CalamaresUtils::Original, - ui->labelRootPassword->size() ) ); - m_readyRootPassword = true; + bool ok = true; + for ( auto pc : m_passwordChecks ) + { + QString s = pc.filter( pw1 ); + if ( !s.isEmpty() ) + { + ui->labelRootPasswordError->setText( s ); + markLabel( ui->labelRootPassword, CalamaresUtils::No ); + ok = false; + m_readyRootPassword = false; + } + } + + if ( ok ) + { + ui->labelRootPasswordError->clear(); + markLabel( ui->labelRootPassword, CalamaresUtils::Yes ); + m_readyRootPassword = true; + } } emit checkReady( isReady() ); @@ -444,3 +457,69 @@ UsersPage::setReusePasswordDefault( bool checked ) ui->checkBoxReusePassword->setChecked( checked ); emit checkReady( isReady() ); } + +UsersPage::PasswordCheck::PasswordCheck() + : m_message() + , m_accept( []( const QString& s ) +{ + return true; +} ) +{ +} + +UsersPage::PasswordCheck::PasswordCheck( const QString& m, AcceptFunc a ) + : m_message( [m](){ return m; } ) + , m_accept( a ) +{ +} + +UsersPage::PasswordCheck::PasswordCheck( MessageFunc m, AcceptFunc a ) + : m_message( m ) + , m_accept( a ) +{ +} + +void +UsersPage::addPasswordCheck( const QString& key, const QVariant& value ) +{ + if ( key == "minLength" ) + { + int minLength = -1; + if ( value.canConvert( QVariant::Int ) ) + minLength = value.toInt(); + if ( minLength > 0 ) + { + cDebug() << key << " .. set to" << minLength; + m_passwordChecks.push_back( + PasswordCheck( + []() + { + return tr( "Password is too short" ); + }, + [minLength]( const QString& s ) + { + return s.length() >= minLength; + } ) ); + } + } + else if ( key == "maxLength" ) + { + int maxLength = -1; + if ( value.canConvert( QVariant::Int ) ) + maxLength = value.toInt(); + if ( maxLength > 0 ) + { + cDebug() << key << " .. set to" << maxLength; + m_passwordChecks.push_back( + PasswordCheck( []() + { + return tr( "Password is too long" ); + }, [maxLength]( const QString& s ) + { + return s.length() <= maxLength; + } ) ); + } + } + else + cDebug() << "WARNING: Unknown password-check key" << '"' << key << '"'; +} diff --git a/src/modules/users/UsersPage.h b/src/modules/users/UsersPage.h index 0f328f46c..5a72e11de 100644 --- a/src/modules/users/UsersPage.h +++ b/src/modules/users/UsersPage.h @@ -28,7 +28,10 @@ #include -namespace Ui { +#include + +namespace Ui +{ class Page_UserSetup; } @@ -49,6 +52,8 @@ public: void setAutologinDefault( bool checked ); void setReusePasswordDefault( bool checked ); + void addPasswordCheck( const QString& key, const QVariant& value ); + protected slots: void onFullNameTextEdited( const QString& ); void fillSuggestions(); @@ -65,6 +70,42 @@ signals: private: Ui::Page_UserSetup* ui; + /** + * Support for (dynamic) checks on the password's validity. + * This can be used to implement password requirements like + * "at least 6 characters". Function addPasswordCheck() + * instantiates these and adds them to the list of checks. + */ + class PasswordCheck + { + public: + /** Return true if the string is acceptable. */ + using AcceptFunc = std::function; + using MessageFunc = std::function; + + /** Generate a @p message if @p filter returns true */ + PasswordCheck( MessageFunc message, AcceptFunc filter ); + /** Yields @p message if @p filter returns true */ + PasswordCheck( const QString& message, AcceptFunc filter ); + /** Null check, always returns empty */ + PasswordCheck(); + + /** Applies this check to the given password string @p s + * and returns an empty string if the password is ok + * according to this filter. Returns a message describing + * what is wrong if not. + */ + QString filter( const QString& s ) const + { + return m_accept( s ) ? QString() : m_message(); + } + + private: + MessageFunc m_message; + AcceptFunc m_accept; + } ; + QVector m_passwordChecks; + const QRegExp USERNAME_RX = QRegExp( "^[a-z_][a-z0-9_-]*[$]?$" ); const QRegExp HOSTNAME_RX = QRegExp( "^[a-zA-Z0-9][-a-zA-Z0-9_]*$" ); const int USERNAME_MAX_LENGTH = 31; diff --git a/src/modules/users/UsersViewStep.cpp b/src/modules/users/UsersViewStep.cpp index d601014ae..25b4dee84 100644 --- a/src/modules/users/UsersViewStep.cpp +++ b/src/modules/users/UsersViewStep.cpp @@ -20,6 +20,7 @@ #include "UsersPage.h" +#include "utils/Logger.h" #include "JobQueue.h" #include "GlobalStorage.h" @@ -159,11 +160,23 @@ UsersViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { m_widget->setAutologinDefault( configurationMap.value( "doAutologin" ).toBool() ); } - + if ( configurationMap.contains( "doReusePassword" ) && configurationMap.value( "doReusePassword" ).type() == QVariant::Bool ) { m_widget->setReusePasswordDefault( configurationMap.value( "doReusePassword" ).toBool() ); } + + if ( configurationMap.contains( "passwordRequirements" ) && + configurationMap.value( "passwordRequirements" ).type() == QVariant::Map ) + { + auto pr_checks( configurationMap.value( "passwordRequirements" ).toMap() ); + + for (decltype(pr_checks)::const_iterator i = pr_checks.constBegin(); + i != pr_checks.constEnd(); ++i) + { + m_widget->addPasswordCheck( i.key(), i.value() ); + } + } } diff --git a/src/modules/users/users.conf b/src/modules/users/users.conf index dea0ba999..d5466c62f 100644 --- a/src/modules/users/users.conf +++ b/src/modules/users/users.conf @@ -27,3 +27,17 @@ sudoersGroup: wheel setRootPassword: true doReusePassword: true + +# These are optional password-requirements that a distro can enforce +# on the user. The values given in this sample file disable each check, +# as if the check was not listed at all. +# +# Checks may be listed multiple times; each is checked separately, +# and no effort is done to ensure that the checks are consistent +# (e.g. specifying a maximum length less than the minimum length +# will annoy users). +# +# (additional checks may be implemented in UsersPage.cpp) +passwordRequirements: + minLength: -1 # Password at least this many characters + maxLength: -1 # Password at most this many characters From 1c52f961a629a82903ef67ade7de33efa3016864 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 19 Sep 2017 09:41:28 +0200 Subject: [PATCH 16/30] Refactor password-errors-indication (again) - set message and status icon in one go - only check until an error is found - Mark TODO for passwordRequirements --- src/modules/users/UsersPage.cpp | 82 ++++++++++++++++----------------- 1 file changed, 39 insertions(+), 43 deletions(-) diff --git a/src/modules/users/UsersPage.cpp b/src/modules/users/UsersPage.cpp index 7c4bb6a7d..f3796e7dd 100644 --- a/src/modules/users/UsersPage.cpp +++ b/src/modules/users/UsersPage.cpp @@ -37,11 +37,20 @@ #include #include -/** Add a standard pixmap to a label. */ -static void -markLabel( QLabel* label, CalamaresUtils::ImageType i ) +/** Add an error message and pixmap to a label. */ +static inline void +labelError( QLabel* pix, QLabel* label, const QString& message ) { - label->setPixmap( CalamaresUtils::defaultPixmap( i, CalamaresUtils::Original, label->size() ) ); + label->setText( message ); + pix->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::No, CalamaresUtils::Original, label->size() ) ); +} + +/** Clear error, indicate OK on a label. */ +static inline void +labelOk( QLabel* pix, QLabel* label ) +{ + label->clear(); + pix->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::Yes, CalamaresUtils::Original, label->size() ) ); } UsersPage::UsersPage( QWidget* parent ) @@ -273,23 +282,19 @@ UsersPage::validateUsernameText( const QString& textRef ) } else if ( text.length() > USERNAME_MAX_LENGTH ) { - markLabel( ui->labelUsername, CalamaresUtils::No ); - ui->labelUsernameError->setText( - tr( "Your username is too long." ) ); - + labelError( ui->labelUsername, ui->labelUsernameError, + tr( "Your username is too long." ) ); m_readyUsername = false; } else if ( val.validate( text, pos ) == QValidator::Invalid ) { - markLabel( ui->labelUsername, CalamaresUtils::No ); - ui->labelUsernameError->setText( - tr( "Your username contains invalid characters. Only lowercase letters and numbers are allowed." ) ); - + labelError( ui->labelUsername, ui->labelUsernameError, + tr( "Your username contains invalid characters. Only lowercase letters and numbers are allowed." ) ); m_readyUsername = false; } - else { - markLabel( ui->labelUsername, CalamaresUtils::Yes ); - ui->labelUsernameError->clear(); + else + { + labelOk( ui->labelUsername, ui->labelUsernameError ); m_readyUsername = true; } @@ -321,34 +326,25 @@ UsersPage::validateHostnameText( const QString& textRef ) } else if ( text.length() < HOSTNAME_MIN_LENGTH ) { - markLabel( ui->labelHostname, CalamaresUtils::No ); - ui->labelHostnameError->setText( - tr( "Your hostname is too short." ) ); - + labelError( ui->labelHostname, ui->labelHostnameError, + tr( "Your hostname is too short." ) ); m_readyHostname = false; - } else if ( text.length() > HOSTNAME_MAX_LENGTH ) { - markLabel( ui->labelHostname, CalamaresUtils::No ); - ui->labelHostnameError->setText( - tr( "Your hostname is too long." ) ); - + labelError( ui->labelHostname, ui->labelHostnameError, + tr( "Your hostname is too long." ) ); m_readyHostname = false; - } else if ( val.validate( text, pos ) == QValidator::Invalid ) { - markLabel( ui->labelHostname, CalamaresUtils::No ); - ui->labelHostnameError->setText( - tr( "Your hostname contains invalid characters. Only letters, numbers and dashes are allowed." ) ); - + labelError( ui->labelHostname, ui->labelHostnameError, + tr( "Your hostname contains invalid characters. Only letters, numbers and dashes are allowed." ) ); m_readyHostname = false; } else { - markLabel( ui->labelHostname, CalamaresUtils::Yes ); - ui->labelHostnameError->clear(); + labelOk( ui->labelHostname, ui->labelHostnameError ); m_readyHostname = true; } @@ -361,6 +357,7 @@ UsersPage::onPasswordTextChanged( const QString& ) QString pw1 = ui->textBoxUserPassword->text(); QString pw2 = ui->textBoxUserVerifiedPassword->text(); + // TODO: 3.3: remove empty-check and leave it to passwordRequirements if ( pw1.isEmpty() && pw2.isEmpty() ) { ui->labelUserPasswordError->clear(); @@ -369,8 +366,8 @@ UsersPage::onPasswordTextChanged( const QString& ) } else if ( pw1 != pw2 ) { - ui->labelUserPasswordError->setText( tr( "Your passwords do not match!" ) ); - markLabel( ui->labelUserPassword, CalamaresUtils::No ); + labelError( ui->labelUserPassword, ui->labelUserPasswordError, + tr( "Your passwords do not match!" ) ); m_readyPassword = false; } else @@ -381,17 +378,16 @@ UsersPage::onPasswordTextChanged( const QString& ) QString s = pc.filter( pw1 ); if ( !s.isEmpty() ) { - ui->labelUserPasswordError->setText( s ); - markLabel( ui->labelUserPassword, CalamaresUtils::No ); + labelError( ui->labelUserPassword, ui->labelUserPasswordError, s ); ok = false; m_readyPassword = false; + break; } } if ( ok ) { - ui->labelUserPasswordError->clear(); - markLabel( ui->labelUserPassword, CalamaresUtils::Yes ); + labelOk( ui->labelUserPassword, ui->labelUserPasswordError ); m_readyPassword = true; } } @@ -405,6 +401,7 @@ UsersPage::onRootPasswordTextChanged( const QString& ) QString pw1 = ui->textBoxRootPassword->text(); QString pw2 = ui->textBoxVerifiedRootPassword->text(); + // TODO: 3.3: remove empty-check and leave it to passwordRequirements if ( pw1.isEmpty() && pw2.isEmpty() ) { ui->labelRootPasswordError->clear(); @@ -413,8 +410,8 @@ UsersPage::onRootPasswordTextChanged( const QString& ) } else if ( pw1 != pw2 ) { - ui->labelRootPasswordError->setText( tr( "Your passwords do not match!" ) ); - markLabel( ui->labelRootPassword, CalamaresUtils::No ); + labelError( ui->labelRootPassword, ui->labelRootPasswordError, + tr( "Your passwords do not match!" ) ); m_readyRootPassword = false; } else @@ -425,17 +422,16 @@ UsersPage::onRootPasswordTextChanged( const QString& ) QString s = pc.filter( pw1 ); if ( !s.isEmpty() ) { - ui->labelRootPasswordError->setText( s ); - markLabel( ui->labelRootPassword, CalamaresUtils::No ); + labelError( ui->labelRootPassword, ui->labelRootPasswordError, s ); ok = false; m_readyRootPassword = false; + break; } } if ( ok ) { - ui->labelRootPasswordError->clear(); - markLabel( ui->labelRootPassword, CalamaresUtils::Yes ); + labelOk( ui->labelRootPassword, ui->labelRootPasswordError ); m_readyRootPassword = true; } } From 6d880b56310b5b5881a0623ffe8e48e5c5ae3e96 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 19 Sep 2017 10:52:37 +0200 Subject: [PATCH 17/30] Replace memory-size detection. - drop use of dmidecode to determine exact physical memory size - use sysinfo() to find memory size (assumes linux 2.3.48 or later) --- .../utils/CalamaresUtilsSystem.cpp | 58 +++++++++---------- 1 file changed, 26 insertions(+), 32 deletions(-) diff --git a/src/libcalamares/utils/CalamaresUtilsSystem.cpp b/src/libcalamares/utils/CalamaresUtilsSystem.cpp index c38d398e6..634366e3a 100644 --- a/src/libcalamares/utils/CalamaresUtilsSystem.cpp +++ b/src/libcalamares/utils/CalamaresUtilsSystem.cpp @@ -26,6 +26,15 @@ #include #include +#ifdef Q_OS_LINUX +#include +#endif + +#ifdef Q_OS_FREEBSD +#include +#include +#endif + namespace CalamaresUtils { @@ -224,47 +233,32 @@ System::targetEnvOutput( const QString& command, qint64 System::getPhysicalMemoryB() { - QProcess p; - p.start( "dmidecode", { "-t", "17" } ); - p.waitForFinished(); - QStringList lines = QString::fromLocal8Bit( p.readAllStandardOutput() ).split( '\n' ); - lines = lines.filter( QRegularExpression( "^\\W*Size:\\W\\d*\\WMB" ) ); - if ( !lines.isEmpty() ) - return 0; - - qint64 availableRamMb = 0; - foreach( const QString& line, lines ) - { - bool ok = false; - availableRamMb += line.simplified() - .split( ' ' ) - .value( 1 ) - .toInt( &ok ); - if ( !ok ) - return 0; - } - qint64 availableRam = availableRamMb * 1024 * 1024; - return availableRam; + return 0; } qint64 System::getTotalMemoryB() { - // A line in meminfo looks like this, with {print $2} we grab the second column. - // MemTotal: 8133432 kB +#ifdef Q_OS_LINUX + struct sysinfo i; + int r = sysinfo( &i ); - QProcess p; - p.start( "awk", { "/MemTotal/ {print $2}", "/proc/meminfo" } ); - p.waitForFinished(); - QString memoryLine = p.readAllStandardOutput().simplified(); - - bool ok = false; - qint64 availableRam = memoryLine.toLongLong( &ok ) * 1024; - if ( !ok ) + if (r) return 0; - return availableRam; + return qint64( i.mem_unit ) * i.totalram; +#elif defined( Q_OS_FREEBSD ) + unsigned long memsize; + size_t s = sizeof(memsize); + + int r = sysctlbyname("vm.kmem_size", &memsize, &s, NULL, 0); + if (r) + return 0; + + return memsize; +#endif + return 0; // Unsupported } From 13807ceabfdcffefa8e924898237796333be596c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 19 Sep 2017 11:11:46 +0200 Subject: [PATCH 18/30] Licensing: add self - to all the files I've touched recently - to (very incomplete) AUTHORS list Licensing: add license info to top-level CMakeLists.txt --- AUTHORS | 1 + CMakeLists.txt | 20 ++++++++++++++++++- .../progresstree/ProgressTreeModel.cpp | 1 + .../progresstree/ProgressTreeModel.h | 1 + src/calamares/progresstree/ProgressTreeView.h | 1 + src/libcalamares/ProcessJob.h | 1 + .../utils/CalamaresUtilsSystem.cpp | 1 + src/libcalamares/utils/PluginFactory.cpp | 1 + src/libcalamares/utils/PluginFactory.h | 1 + .../modulesystem/CppJobModule.h | 1 + .../modulesystem/ProcessJobModule.h | 1 + src/libcalamaresui/modulesystem/ViewModule.h | 1 + src/libcalamaresui/viewpages/ViewStep.cpp | 1 + src/libcalamaresui/widgets/ClickableLabel.h | 1 + .../widgets/FixedAspectRatioLabel.cpp | 1 + src/modules/displaymanager/main.py | 1 + src/modules/dracutlukscfg/DracutLuksCfgJob.h | 1 + src/modules/dummycpp/DummyCppJob.h | 1 + .../InteractiveTerminalViewStep.h | 1 + src/modules/keyboard/KeyboardViewStep.h | 1 + src/modules/netinstall/NetInstallViewStep.h | 1 + src/modules/netinstall/PackageModel.cpp | 1 + src/modules/netinstall/PackageModel.h | 1 + src/modules/netinstall/PackageTreeItem.cpp | 1 + src/modules/netinstall/PackageTreeItem.h | 1 + src/modules/partition/core/DeviceModel.h | 1 + src/modules/partition/core/PartitionModel.h | 1 + src/modules/partition/gui/PartitionBarsView.h | 1 + .../partition/gui/PartitionLabelsView.h | 1 + src/modules/partition/gui/PartitionViewStep.h | 1 + .../partition/jobs/CreatePartitionJob.cpp | 1 + .../jobs/CreatePartitionTableJob.cpp | 1 + .../partition/jobs/DeletePartitionJob.cpp | 1 + .../partition/jobs/FillGlobalStorageJob.cpp | 1 + src/modules/users/UsersPage.cpp | 1 + src/modules/users/UsersViewStep.cpp | 1 + src/modules/users/UsersViewStep.h | 1 + src/modules/webview/WebViewStep.h | 1 + 38 files changed, 56 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index d9814373e..f39b579f4 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1 +1,2 @@ Teo Mrnjavac +Adriaan de Groot diff --git a/CMakeLists.txt b/CMakeLists.txt index ac5d5b820..3f0a3c3e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,22 @@ -### CMakeLists.txt for Calamares +# === This file is part of Calamares - === +# +# 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 . +# +# SPDX-License-Identifier: GPL-3.0+ +# License-Filename: LICENSE +# +### # # Generally, this CMakeLists.txt will find all the dependencies for Calamares # and complain appropriately. See below (later in this file) for CMake-level diff --git a/src/calamares/progresstree/ProgressTreeModel.cpp b/src/calamares/progresstree/ProgressTreeModel.cpp index 33e985809..50a1b6e50 100644 --- a/src/calamares/progresstree/ProgressTreeModel.cpp +++ b/src/calamares/progresstree/ProgressTreeModel.cpp @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2015, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/calamares/progresstree/ProgressTreeModel.h b/src/calamares/progresstree/ProgressTreeModel.h index 0311a28a0..80ce6dc6b 100644 --- a/src/calamares/progresstree/ProgressTreeModel.h +++ b/src/calamares/progresstree/ProgressTreeModel.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/calamares/progresstree/ProgressTreeView.h b/src/calamares/progresstree/ProgressTreeView.h index 9e735ef2d..11738b193 100644 --- a/src/calamares/progresstree/ProgressTreeView.h +++ b/src/calamares/progresstree/ProgressTreeView.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/libcalamares/ProcessJob.h b/src/libcalamares/ProcessJob.h index ba6e650f6..259f97308 100644 --- a/src/libcalamares/ProcessJob.h +++ b/src/libcalamares/ProcessJob.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/libcalamares/utils/CalamaresUtilsSystem.cpp b/src/libcalamares/utils/CalamaresUtilsSystem.cpp index 634366e3a..3936852ab 100644 --- a/src/libcalamares/utils/CalamaresUtilsSystem.cpp +++ b/src/libcalamares/utils/CalamaresUtilsSystem.cpp @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/libcalamares/utils/PluginFactory.cpp b/src/libcalamares/utils/PluginFactory.cpp index 710633866..c22c90ff7 100644 --- a/src/libcalamares/utils/PluginFactory.cpp +++ b/src/libcalamares/utils/PluginFactory.cpp @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2015, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Based on KPluginFactory from KCoreAddons, KDE project * Copyright 2007, Matthias Kretz diff --git a/src/libcalamares/utils/PluginFactory.h b/src/libcalamares/utils/PluginFactory.h index a1f1597b5..945a3eaaf 100644 --- a/src/libcalamares/utils/PluginFactory.h +++ b/src/libcalamares/utils/PluginFactory.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2015, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Based on KPluginFactory from KCoreAddons, KDE project * Copyright 2007, Matthias Kretz diff --git a/src/libcalamaresui/modulesystem/CppJobModule.h b/src/libcalamaresui/modulesystem/CppJobModule.h index 9ec8a6eaa..875f30785 100644 --- a/src/libcalamaresui/modulesystem/CppJobModule.h +++ b/src/libcalamaresui/modulesystem/CppJobModule.h @@ -2,6 +2,7 @@ * * Copyright 2014, Teo Mrnjavac * Copyright 2016, Kevin Kofler + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/libcalamaresui/modulesystem/ProcessJobModule.h b/src/libcalamaresui/modulesystem/ProcessJobModule.h index 7809d0d2f..9d30ec235 100644 --- a/src/libcalamaresui/modulesystem/ProcessJobModule.h +++ b/src/libcalamaresui/modulesystem/ProcessJobModule.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/libcalamaresui/modulesystem/ViewModule.h b/src/libcalamaresui/modulesystem/ViewModule.h index d36b58db9..32b0e8a1f 100644 --- a/src/libcalamaresui/modulesystem/ViewModule.h +++ b/src/libcalamaresui/modulesystem/ViewModule.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/libcalamaresui/viewpages/ViewStep.cpp b/src/libcalamaresui/viewpages/ViewStep.cpp index a81787673..96d80cb5f 100644 --- a/src/libcalamaresui/viewpages/ViewStep.cpp +++ b/src/libcalamaresui/viewpages/ViewStep.cpp @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/libcalamaresui/widgets/ClickableLabel.h b/src/libcalamaresui/widgets/ClickableLabel.h index 7a6556e3f..42af076f5 100644 --- a/src/libcalamaresui/widgets/ClickableLabel.h +++ b/src/libcalamaresui/widgets/ClickableLabel.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/libcalamaresui/widgets/FixedAspectRatioLabel.cpp b/src/libcalamaresui/widgets/FixedAspectRatioLabel.cpp index 99d3d51f4..f07491bcd 100644 --- a/src/libcalamaresui/widgets/FixedAspectRatioLabel.cpp +++ b/src/libcalamaresui/widgets/FixedAspectRatioLabel.cpp @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2015, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/modules/displaymanager/main.py b/src/modules/displaymanager/main.py index e5c7155d4..814a0cf3c 100644 --- a/src/modules/displaymanager/main.py +++ b/src/modules/displaymanager/main.py @@ -8,6 +8,7 @@ # Copyright 2014, Kevin Kofler # Copyright 2017, Alf Gaida # Copyright 2017, Bernhard Landauer +# Copyright 2017, Adriaan de Groot # # Calamares is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/src/modules/dracutlukscfg/DracutLuksCfgJob.h b/src/modules/dracutlukscfg/DracutLuksCfgJob.h index 71994e2b6..2d438fa0b 100644 --- a/src/modules/dracutlukscfg/DracutLuksCfgJob.h +++ b/src/modules/dracutlukscfg/DracutLuksCfgJob.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2016, Kevin Kofler + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/modules/dummycpp/DummyCppJob.h b/src/modules/dummycpp/DummyCppJob.h index 6f5f234f5..fecc2699b 100644 --- a/src/modules/dummycpp/DummyCppJob.h +++ b/src/modules/dummycpp/DummyCppJob.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2016, Kevin Kofler + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/modules/interactiveterminal/InteractiveTerminalViewStep.h b/src/modules/interactiveterminal/InteractiveTerminalViewStep.h index 025c6cec3..1c95a229a 100644 --- a/src/modules/interactiveterminal/InteractiveTerminalViewStep.h +++ b/src/modules/interactiveterminal/InteractiveTerminalViewStep.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2015, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/modules/keyboard/KeyboardViewStep.h b/src/modules/keyboard/KeyboardViewStep.h index 39f3f56a7..64ce2bb75 100644 --- a/src/modules/keyboard/KeyboardViewStep.h +++ b/src/modules/keyboard/KeyboardViewStep.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2015, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/modules/netinstall/NetInstallViewStep.h b/src/modules/netinstall/NetInstallViewStep.h index 651c53266..d9853f26f 100644 --- a/src/modules/netinstall/NetInstallViewStep.h +++ b/src/modules/netinstall/NetInstallViewStep.h @@ -1,6 +1,7 @@ /* * Copyright 2016, Luca Giambonini * Copyright 2016, Lisa Vitolo + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/modules/netinstall/PackageModel.cpp b/src/modules/netinstall/PackageModel.cpp index 8a2025b0e..9fe8305a7 100644 --- a/src/modules/netinstall/PackageModel.cpp +++ b/src/modules/netinstall/PackageModel.cpp @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright (c) 2017, Kyle Robbertze + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/modules/netinstall/PackageModel.h b/src/modules/netinstall/PackageModel.h index ef2bc1794..148bd99ab 100644 --- a/src/modules/netinstall/PackageModel.h +++ b/src/modules/netinstall/PackageModel.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright (c) 2017, Kyle Robbertze + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/modules/netinstall/PackageTreeItem.cpp b/src/modules/netinstall/PackageTreeItem.cpp index bbd7f792f..77ca07a9c 100644 --- a/src/modules/netinstall/PackageTreeItem.cpp +++ b/src/modules/netinstall/PackageTreeItem.cpp @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright (c) 2017, Kyle Robbertze + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/modules/netinstall/PackageTreeItem.h b/src/modules/netinstall/PackageTreeItem.h index a95a4fe31..e9bbcf59c 100644 --- a/src/modules/netinstall/PackageTreeItem.h +++ b/src/modules/netinstall/PackageTreeItem.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright (c) 2017, Kyle Robbertze + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/modules/partition/core/DeviceModel.h b/src/modules/partition/core/DeviceModel.h index 5c07586e0..32c557d9e 100644 --- a/src/modules/partition/core/DeviceModel.h +++ b/src/modules/partition/core/DeviceModel.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014, Aurélien Gâteau + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/modules/partition/core/PartitionModel.h b/src/modules/partition/core/PartitionModel.h index 7437efa79..71764d8e9 100644 --- a/src/modules/partition/core/PartitionModel.h +++ b/src/modules/partition/core/PartitionModel.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014, Aurélien Gâteau + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/modules/partition/gui/PartitionBarsView.h b/src/modules/partition/gui/PartitionBarsView.h index ccdb5d36a..e384ed5db 100644 --- a/src/modules/partition/gui/PartitionBarsView.h +++ b/src/modules/partition/gui/PartitionBarsView.h @@ -2,6 +2,7 @@ * * Copyright 2014, Aurélien Gâteau * Copyright 2015-2016, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/modules/partition/gui/PartitionLabelsView.h b/src/modules/partition/gui/PartitionLabelsView.h index 363d54cc7..d6c86a5dc 100644 --- a/src/modules/partition/gui/PartitionLabelsView.h +++ b/src/modules/partition/gui/PartitionLabelsView.h @@ -2,6 +2,7 @@ * * Copyright 2014, Aurélien Gâteau * Copyright 2015-2016, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/modules/partition/gui/PartitionViewStep.h b/src/modules/partition/gui/PartitionViewStep.h index c1217c5a2..1aa8190f9 100644 --- a/src/modules/partition/gui/PartitionViewStep.h +++ b/src/modules/partition/gui/PartitionViewStep.h @@ -2,6 +2,7 @@ * * Copyright 2014, Aurélien Gâteau * Copyright 2014-2016, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/modules/partition/jobs/CreatePartitionJob.cpp b/src/modules/partition/jobs/CreatePartitionJob.cpp index cff4ae1cf..aab032a87 100644 --- a/src/modules/partition/jobs/CreatePartitionJob.cpp +++ b/src/modules/partition/jobs/CreatePartitionJob.cpp @@ -2,6 +2,7 @@ * * Copyright 2014, Aurélien Gâteau * Copyright 2015, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/modules/partition/jobs/CreatePartitionTableJob.cpp b/src/modules/partition/jobs/CreatePartitionTableJob.cpp index eaa2fe712..e4430134f 100644 --- a/src/modules/partition/jobs/CreatePartitionTableJob.cpp +++ b/src/modules/partition/jobs/CreatePartitionTableJob.cpp @@ -2,6 +2,7 @@ * * Copyright 2014, Aurélien Gâteau * Copyright 2015, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/modules/partition/jobs/DeletePartitionJob.cpp b/src/modules/partition/jobs/DeletePartitionJob.cpp index 43f2d94c6..bceffd133 100644 --- a/src/modules/partition/jobs/DeletePartitionJob.cpp +++ b/src/modules/partition/jobs/DeletePartitionJob.cpp @@ -2,6 +2,7 @@ * * Copyright 2014, Aurélien Gâteau * Copyright 2015, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/modules/partition/jobs/FillGlobalStorageJob.cpp b/src/modules/partition/jobs/FillGlobalStorageJob.cpp index f8194f2b3..443eb8b9e 100644 --- a/src/modules/partition/jobs/FillGlobalStorageJob.cpp +++ b/src/modules/partition/jobs/FillGlobalStorageJob.cpp @@ -2,6 +2,7 @@ * * Copyright 2014, Aurélien Gâteau * Copyright 2015-2016, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/modules/users/UsersPage.cpp b/src/modules/users/UsersPage.cpp index f3796e7dd..453d1eae7 100644 --- a/src/modules/users/UsersPage.cpp +++ b/src/modules/users/UsersPage.cpp @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2017, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Portions from the Manjaro Installation Framework * by Roland Singer diff --git a/src/modules/users/UsersViewStep.cpp b/src/modules/users/UsersViewStep.cpp index 25b4dee84..73dc98ddc 100644 --- a/src/modules/users/UsersViewStep.cpp +++ b/src/modules/users/UsersViewStep.cpp @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2015, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/modules/users/UsersViewStep.h b/src/modules/users/UsersViewStep.h index c7e0f447d..a529ad4ea 100644 --- a/src/modules/users/UsersViewStep.h +++ b/src/modules/users/UsersViewStep.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2015, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/modules/webview/WebViewStep.h b/src/modules/webview/WebViewStep.h index 5b8a85049..105eea4b3 100644 --- a/src/modules/webview/WebViewStep.h +++ b/src/modules/webview/WebViewStep.h @@ -2,6 +2,7 @@ * * Copyright 2015, Rohan Garg * Copyright 2016, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From e5c0854e6613c607ad1209bd826ef75b657a0c9a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 19 Sep 2017 14:24:05 +0200 Subject: [PATCH 19/30] Licensing: re-import GPLv3 version of QJsonItem - include full license headers, - copied from - repo: https://github.com/dridk/QJsonmodel - rev: fbd4fb3b1c1311f69cd8ada9bbb7a89fd6fe171e --- LICENSES/GPLv3+-QJsonModel | 18 ++++++++++ src/libcalamaresui/utils/qjsonitem.cpp | 42 ++++++++++------------ src/libcalamaresui/utils/qjsonitem.h | 25 ++----------- src/libcalamaresui/utils/qjsonmodel.cpp | 48 ++++++++++++------------- src/libcalamaresui/utils/qjsonmodel.h | 23 +----------- 5 files changed, 63 insertions(+), 93 deletions(-) create mode 100644 LICENSES/GPLv3+-QJsonModel diff --git a/LICENSES/GPLv3+-QJsonModel b/LICENSES/GPLv3+-QJsonModel new file mode 100644 index 000000000..8a8e272c0 --- /dev/null +++ b/LICENSES/GPLv3+-QJsonModel @@ -0,0 +1,18 @@ +/*********************************************** + Copyright (C) 2014 Schutz Sacha + This file is part of QJsonModel (https://github.com/dridk/QJsonmodel). + + QJsonModel 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. + + QJsonModel 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 QJsonModel. If not, see . + +**********************************************/ diff --git a/src/libcalamaresui/utils/qjsonitem.cpp b/src/libcalamaresui/utils/qjsonitem.cpp index 35c9725dd..b278913b4 100644 --- a/src/libcalamaresui/utils/qjsonitem.cpp +++ b/src/libcalamaresui/utils/qjsonitem.cpp @@ -1,27 +1,25 @@ -/* === This file is part of Calamares - === - * - * Originally from QJsonModel - * Copyright 2015, Sacha Schutz - * - * 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 . - */ +/*********************************************** + Copyright (C) 2014 Schutz Sacha + This file is part of QJsonModel (https://github.com/dridk/QJsonmodel). + QJsonModel 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. + + QJsonModel 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 QJsonModel. If not, see . + +**********************************************/ #include "qjsonitem.h" QJsonTreeItem::QJsonTreeItem(QJsonTreeItem *parent) - : mType( QJsonValue::Null ) { mParent = parent; @@ -104,8 +102,7 @@ QJsonTreeItem* QJsonTreeItem::load(const QJsonValue& value, QJsonTreeItem* paren { //Get all QJsonValue childs - const auto keys = value.toObject().keys(); - for (const QString &key : keys){ + foreach (QString key , value.toObject().keys()){ QJsonValue v = value.toObject().value(key); QJsonTreeItem * child = load(v,rootItem); child->setKey(key); @@ -120,8 +117,7 @@ QJsonTreeItem* QJsonTreeItem::load(const QJsonValue& value, QJsonTreeItem* paren { //Get all QJsonValue childs int index = 0; - const auto valueArray = value.toArray(); - for (const QJsonValue &v : valueArray) { + foreach (QJsonValue v , value.toArray()){ QJsonTreeItem * child = load(v,rootItem); child->setKey(QString::number(index)); diff --git a/src/libcalamaresui/utils/qjsonitem.h b/src/libcalamaresui/utils/qjsonitem.h index 1dfa5c65e..6e030c656 100644 --- a/src/libcalamaresui/utils/qjsonitem.h +++ b/src/libcalamaresui/utils/qjsonitem.h @@ -1,22 +1,3 @@ -/* === This file is part of Calamares - === - * - * Originally from QJsonModel - * Copyright 2015, Sacha Schutz - * - * 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 . - */ - #ifndef JSONITEM_H #define JSONITEM_H #include @@ -26,8 +7,8 @@ class QJsonTreeItem { public: - QJsonTreeItem(QJsonTreeItem * parent = nullptr); - virtual ~QJsonTreeItem(); + QJsonTreeItem(QJsonTreeItem * parent = 0); + ~QJsonTreeItem(); void appendChild(QJsonTreeItem * item); QJsonTreeItem *child(int row); QJsonTreeItem *parent(); @@ -41,7 +22,7 @@ public: QJsonValue::Type type() const; - static QJsonTreeItem* load(const QJsonValue& value, QJsonTreeItem * parent = nullptr); + static QJsonTreeItem* load(const QJsonValue& value, QJsonTreeItem * parent = 0); protected: diff --git a/src/libcalamaresui/utils/qjsonmodel.cpp b/src/libcalamaresui/utils/qjsonmodel.cpp index 3d427d0fb..45086b7c6 100644 --- a/src/libcalamaresui/utils/qjsonmodel.cpp +++ b/src/libcalamaresui/utils/qjsonmodel.cpp @@ -1,22 +1,21 @@ -/* === This file is part of Calamares - === - * - * Originally from QJsonModel - * Copyright 2015, Sacha Schutz - * - * 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 . - */ +/*********************************************** + Copyright (C) 2014 Schutz Sacha + This file is part of QJsonModel (https://github.com/dridk/QJsonmodel). + QJsonModel 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. + + QJsonModel 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 QJsonModel. If not, see . + +**********************************************/ #include "qjsonmodel.h" #include @@ -36,13 +35,6 @@ QJsonModel::QJsonModel(QObject *parent) : } - -QJsonModel::~QJsonModel() -{ - delete mRootItem; -} - - bool QJsonModel::load(const QString &fileName) { QFile file(fileName); @@ -68,7 +60,11 @@ bool QJsonModel::loadJson(const QByteArray &json) if (!mDocument.isNull()) { beginResetModel(); - mRootItem = QJsonTreeItem::load(QJsonValue(mDocument.object())); + if (mDocument.isArray()) { + mRootItem = QJsonTreeItem::load(QJsonValue(mDocument.array())); + } else { + mRootItem = QJsonTreeItem::load(QJsonValue(mDocument.object())); + } endResetModel(); return true; } diff --git a/src/libcalamaresui/utils/qjsonmodel.h b/src/libcalamaresui/utils/qjsonmodel.h index 0bf8f5dab..cdb6caf86 100644 --- a/src/libcalamaresui/utils/qjsonmodel.h +++ b/src/libcalamaresui/utils/qjsonmodel.h @@ -1,23 +1,3 @@ -/* === This file is part of Calamares - === - * - * Originally from QJsonModel - * Copyright 2015, Sacha Schutz - * - * 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 . - */ - - #ifndef QJSONMODEL_H #define QJSONMODEL_H @@ -30,8 +10,7 @@ class QJsonModel : public QAbstractItemModel { Q_OBJECT public: - explicit QJsonModel(QObject *parent = nullptr); - virtual ~QJsonModel(); + explicit QJsonModel(QObject *parent = 0); bool load(const QString& fileName); bool load(QIODevice * device); bool loadJson(const QByteArray& json); From 24f26ee7c8ffc2c6bd9fc47cba9014a5d1d25c60 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 19 Sep 2017 14:27:39 +0200 Subject: [PATCH 20/30] Licensing: add header to QJsonModel copyright - mention that this is shipped as part of Calamares - SPDX info --- src/libcalamaresui/utils/qjsonitem.cpp | 6 ++++++ src/libcalamaresui/utils/qjsonitem.h | 6 ++++++ src/libcalamaresui/utils/qjsonmodel.cpp | 6 ++++++ src/libcalamaresui/utils/qjsonmodel.h | 6 ++++++ 4 files changed, 24 insertions(+) diff --git a/src/libcalamaresui/utils/qjsonitem.cpp b/src/libcalamaresui/utils/qjsonitem.cpp index b278913b4..24494f0fd 100644 --- a/src/libcalamaresui/utils/qjsonitem.cpp +++ b/src/libcalamaresui/utils/qjsonitem.cpp @@ -1,3 +1,9 @@ +/* === This file is part of Calamares - === + * + * SPDX-License-Identifier: GPL-3.0+ + * License-Filename: LICENSES/GPLv3+-QJsonModel + */ + /*********************************************** Copyright (C) 2014 Schutz Sacha This file is part of QJsonModel (https://github.com/dridk/QJsonmodel). diff --git a/src/libcalamaresui/utils/qjsonitem.h b/src/libcalamaresui/utils/qjsonitem.h index 6e030c656..5a8b2134f 100644 --- a/src/libcalamaresui/utils/qjsonitem.h +++ b/src/libcalamaresui/utils/qjsonitem.h @@ -1,3 +1,9 @@ +/* === This file is part of Calamares - === + * + * SPDX-License-Identifier: GPL-3.0+ + * License-Filename: LICENSES/GPLv3+-QJsonModel + */ + #ifndef JSONITEM_H #define JSONITEM_H #include diff --git a/src/libcalamaresui/utils/qjsonmodel.cpp b/src/libcalamaresui/utils/qjsonmodel.cpp index 45086b7c6..5ce0cd695 100644 --- a/src/libcalamaresui/utils/qjsonmodel.cpp +++ b/src/libcalamaresui/utils/qjsonmodel.cpp @@ -1,3 +1,9 @@ +/* === This file is part of Calamares - === + * + * SPDX-License-Identifier: GPL-3.0+ + * License-Filename: LICENSES/GPLv3+-QJsonModel + */ + /*********************************************** Copyright (C) 2014 Schutz Sacha This file is part of QJsonModel (https://github.com/dridk/QJsonmodel). diff --git a/src/libcalamaresui/utils/qjsonmodel.h b/src/libcalamaresui/utils/qjsonmodel.h index cdb6caf86..6a2399287 100644 --- a/src/libcalamaresui/utils/qjsonmodel.h +++ b/src/libcalamaresui/utils/qjsonmodel.h @@ -1,3 +1,9 @@ +/* === This file is part of Calamares - === + * + * SPDX-License-Identifier: GPL-3.0+ + * License-Filename: LICENSES/GPLv3+-QJsonModel + */ + #ifndef QJSONMODEL_H #define QJSONMODEL_H From 553a66b326d0378fba523b09c416bf751ca806cb Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 19 Sep 2017 12:58:35 +0200 Subject: [PATCH 21/30] Licensing: re-import QtWaitingSpinner - include full license headers, - copied from - repo: https://github.com/snowwlex/QtWaitingSpinner - rev: bb8f8987ca19406dc75704eb382ab52e981b773f This revision *does not build* because the files have been renamed. --- LICENSES/MIT-QtWaitingSpinner | 21 ++ .../widgets/QtWaitingSpinner.cpp | 176 ----------- src/libcalamaresui/widgets/QtWaitingSpinner.h | 82 ------ .../widgets/waitingspinnerwidget.cpp | 277 ++++++++++++++++++ .../widgets/waitingspinnerwidget.h | 114 +++++++ 5 files changed, 412 insertions(+), 258 deletions(-) create mode 100644 LICENSES/MIT-QtWaitingSpinner delete mode 100644 src/libcalamaresui/widgets/QtWaitingSpinner.cpp delete mode 100644 src/libcalamaresui/widgets/QtWaitingSpinner.h create mode 100644 src/libcalamaresui/widgets/waitingspinnerwidget.cpp create mode 100644 src/libcalamaresui/widgets/waitingspinnerwidget.h diff --git a/LICENSES/MIT-QtWaitingSpinner b/LICENSES/MIT-QtWaitingSpinner new file mode 100644 index 000000000..c85c97aeb --- /dev/null +++ b/LICENSES/MIT-QtWaitingSpinner @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Original Work Copyright (c) 2012-2015 Alexander Turkin +Modified 2014 by William Hallatt + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/src/libcalamaresui/widgets/QtWaitingSpinner.cpp b/src/libcalamaresui/widgets/QtWaitingSpinner.cpp deleted file mode 100644 index 18c6264bd..000000000 --- a/src/libcalamaresui/widgets/QtWaitingSpinner.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* === This file is part of Calamares - === - * - * Copyright 2014, Teo Mrnjavac - * - * Originally from https://github.com/snowwlex/QtWaitingSpinner - * Copyright 2012, Alex Turkin - * - * 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 . - */ - -#include -#include - -#include - -#include "QtWaitingSpinner.h" - -QtWaitingSpinner::QtWaitingSpinner(int linesNumber, int length, int width, int radius, QWidget* parent) : QWidget(parent), - myLinesNumber(linesNumber), - myLength(length + width), - myWidth(width), - myRadius(radius), - myRoundness(70.0), - myColor(Qt::black), - mySpeed(1), - myTrail(70), - myOpacity(15) -{ - myCurrentCounter = 0; - myTimer = new QTimer(this); - connect(myTimer,SIGNAL(timeout()), this, SLOT(rotate())); - updateSize(); - updateTimer(); - this->hide(); -} - -void QtWaitingSpinner::paintEvent(QPaintEvent* /*ev*/) { - QPainter painter(this); - painter.fillRect(this->rect(), Qt::transparent); - painter.setRenderHint(QPainter::Antialiasing, true); - - if (myCurrentCounter >= myLinesNumber) { - myCurrentCounter = 0; - } - painter.setPen(Qt::NoPen); - for (int i = 0; i < myLinesNumber; ++i) { - painter.save(); - painter.translate(myRadius + myLength, myRadius + myLength); - qreal rotateAngle = 360.0 * qreal(i) / qreal(myLinesNumber); - painter.rotate(rotateAngle); - painter.translate(myRadius, 0); - int distance = lineDistance(i, myCurrentCounter, myLinesNumber); - QColor color = countTrailColor(distance, myLinesNumber, myTrail, myOpacity, myColor); - painter.setBrush(color); - //TODO improve the way rounded rect is painted - painter.drawRoundedRect(QRect(0, -myWidth/2, myLength, myWidth), myRoundness, myRoundness, Qt::RelativeSize); - painter.restore(); - } -} - -void QtWaitingSpinner::start() { - this->show(); - if (!myTimer->isActive()) { - myTimer->start(); - myCurrentCounter = 0; - } -} - -void QtWaitingSpinner::finish() { - this->hide(); - if (myTimer->isActive()) { - myTimer->stop(); - myCurrentCounter = 0; - } -} - -void QtWaitingSpinner::setLinesNumber(int linesNumber) { - myLinesNumber = linesNumber; - myCurrentCounter = 0; - updateTimer(); -} - -void QtWaitingSpinner::setLength(int length){ - myLength = length; - updateSize(); -} - -void QtWaitingSpinner::setWidth(int width) { - myWidth = width; - updateSize(); -} - -void QtWaitingSpinner::setRadius(int radius) { - myRadius = radius; - updateSize(); -} - -void QtWaitingSpinner::setRoundness(qreal roundness) { - myRoundness = std::max(0.0, std::min(100.0, roundness)); -} - -void QtWaitingSpinner::setColor(QColor color) { - myColor = color; -} - -void QtWaitingSpinner::setSpeed(qreal speed) { - mySpeed = speed; - updateTimer(); -} - -void QtWaitingSpinner::setTrail(int trail) { - myTrail = trail; -} - -void QtWaitingSpinner::setOpacity(int minOpacity) { - myOpacity = minOpacity; -} - -void QtWaitingSpinner::rotate() { - ++myCurrentCounter; - if (myCurrentCounter >= myLinesNumber) { - myCurrentCounter = 0; - } - update(); -} - -void QtWaitingSpinner::updateSize() { - int size = (myRadius + myLength) * 2; - setFixedSize(size, size); -} - -void QtWaitingSpinner::updateTimer() { - myTimer->setInterval(countTimeout(myLinesNumber, mySpeed)); -} - -int QtWaitingSpinner::countTimeout(int lines, qreal speed) { - return int( 1000.0 / (lines * speed) ); -} - -int QtWaitingSpinner::lineDistance(int from, int to, int lines) { - int result = to - from; - if (result < 0) { - result += lines; - } - return result; -} - -QColor QtWaitingSpinner::countTrailColor(int distance, int lines, int trail, int minOpacity, QColor color) { - if (distance == 0) { - return color; - } - const qreal minAlphaF = qreal(minOpacity) / 100.0; - int distanceThreshold = int( ceil( (lines - 1) * qreal(trail) / 100.0) ); - if (distance > distanceThreshold) { - color.setAlphaF(minAlphaF); - return color; - } - qreal alphaDiff = color.alphaF() - minAlphaF; - qreal gradation = alphaDiff / qreal(distanceThreshold + 1); - qreal resultAlpha = color.alphaF() - gradation * distance; - resultAlpha = std::min(1.0, std::max(0.0, resultAlpha)); //if alpha is out of bound, force it to bounds - color.setAlphaF(resultAlpha); - return color; -} - diff --git a/src/libcalamaresui/widgets/QtWaitingSpinner.h b/src/libcalamaresui/widgets/QtWaitingSpinner.h deleted file mode 100644 index 1c1b3eb10..000000000 --- a/src/libcalamaresui/widgets/QtWaitingSpinner.h +++ /dev/null @@ -1,82 +0,0 @@ -/* === This file is part of Calamares - === - * - * Copyright 2014, Teo Mrnjavac - * - * Originally from https://github.com/snowwlex/QtWaitingSpinner - * Copyright 2012, Alex Turkin - * - * 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 . - */ - -#ifndef QTWAITINGSPINNER_H -#define QTWAITINGSPINNER_H - -#include "UiDllMacro.h" - -#include - -#include -#include - -class UIDLLEXPORT QtWaitingSpinner : public QWidget { - Q_OBJECT - -public: - explicit QtWaitingSpinner(int linesNumber = 12, int length = 7, int width = 5, int radius = 10, QWidget* parent = nullptr); - -public Q_SLOTS: - void start(); - void finish(); - -public: - void setLinesNumber(int linesNumber); - void setLength(int length); - void setWidth(int width); - void setRadius(int radius); - void setRoundness(qreal roundness); - void setColor(QColor color); - void setSpeed(qreal speed); - void setTrail(int trail); - void setOpacity(int minOpacity); - -private Q_SLOTS: - void rotate(); - void updateSize(); - void updateTimer(); - -protected: - void paintEvent(QPaintEvent* ev); - -private: - static int countTimeout(int lines, qreal speed); - static int lineDistance(int from, int to, int lines); - static QColor countTrailColor(int distance, int lines, int trail, int minOpacity, QColor color); - -private: - int myLinesNumber; - int myLength; - int myWidth; - int myRadius; - qreal myRoundness; //0..100 - QColor myColor; - qreal mySpeed; // in rounds per second - int myTrail; - int myOpacity; - -private: - QTimer* myTimer; - int myCurrentCounter; -}; - -#endif // QTWAITINGSPINNER_H diff --git a/src/libcalamaresui/widgets/waitingspinnerwidget.cpp b/src/libcalamaresui/widgets/waitingspinnerwidget.cpp new file mode 100644 index 000000000..0ef03a0ba --- /dev/null +++ b/src/libcalamaresui/widgets/waitingspinnerwidget.cpp @@ -0,0 +1,277 @@ +/* Original Work Copyright (c) 2012-2014 Alexander Turkin + Modified 2014 by William Hallatt + Modified 2015 by Jacob Dawid + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +// Own includes +#include "waitingspinnerwidget.h" + +// Standard includes +#include +#include + +// Qt includes +#include +#include + +WaitingSpinnerWidget::WaitingSpinnerWidget(QWidget *parent, + bool centerOnParent, + bool disableParentWhenSpinning) + : QWidget(parent), + _centerOnParent(centerOnParent), + _disableParentWhenSpinning(disableParentWhenSpinning) { + initialize(); +} + +WaitingSpinnerWidget::WaitingSpinnerWidget(Qt::WindowModality modality, + QWidget *parent, + bool centerOnParent, + bool disableParentWhenSpinning) + : QWidget(parent, Qt::Dialog | Qt::FramelessWindowHint), + _centerOnParent(centerOnParent), + _disableParentWhenSpinning(disableParentWhenSpinning){ + initialize(); + + // We need to set the window modality AFTER we've hidden the + // widget for the first time since changing this property while + // the widget is visible has no effect. + setWindowModality(modality); + setAttribute(Qt::WA_TranslucentBackground); +} + +void WaitingSpinnerWidget::initialize() { + _color = Qt::black; + _roundness = 100.0; + _minimumTrailOpacity = 3.14159265358979323846; + _trailFadePercentage = 80.0; + _revolutionsPerSecond = 1.57079632679489661923; + _numberOfLines = 20; + _lineLength = 10; + _lineWidth = 2; + _innerRadius = 10; + _currentCounter = 0; + _isSpinning = false; + + _timer = new QTimer(this); + connect(_timer, SIGNAL(timeout()), this, SLOT(rotate())); + updateSize(); + updateTimer(); + hide(); +} + +void WaitingSpinnerWidget::paintEvent(QPaintEvent *) { + updatePosition(); + QPainter painter(this); + painter.fillRect(this->rect(), Qt::transparent); + painter.setRenderHint(QPainter::Antialiasing, true); + + if (_currentCounter >= _numberOfLines) { + _currentCounter = 0; + } + + painter.setPen(Qt::NoPen); + for (int i = 0; i < _numberOfLines; ++i) { + painter.save(); + painter.translate(_innerRadius + _lineLength, + _innerRadius + _lineLength); + qreal rotateAngle = + static_cast(360 * i) / static_cast(_numberOfLines); + painter.rotate(rotateAngle); + painter.translate(_innerRadius, 0); + int distance = + lineCountDistanceFromPrimary(i, _currentCounter, _numberOfLines); + QColor color = + currentLineColor(distance, _numberOfLines, _trailFadePercentage, + _minimumTrailOpacity, _color); + painter.setBrush(color); + // TODO improve the way rounded rect is painted + painter.drawRoundedRect( + QRect(0, -_lineWidth / 2, _lineLength, _lineWidth), _roundness, + _roundness, Qt::RelativeSize); + painter.restore(); + } +} + +void WaitingSpinnerWidget::start() { + updatePosition(); + _isSpinning = true; + show(); + + if(parentWidget() && _disableParentWhenSpinning) { + parentWidget()->setEnabled(false); + } + + if (!_timer->isActive()) { + _timer->start(); + _currentCounter = 0; + } +} + +void WaitingSpinnerWidget::stop() { + _isSpinning = false; + hide(); + + if(parentWidget() && _disableParentWhenSpinning) { + parentWidget()->setEnabled(true); + } + + if (_timer->isActive()) { + _timer->stop(); + _currentCounter = 0; + } +} + +void WaitingSpinnerWidget::setNumberOfLines(int lines) { + _numberOfLines = lines; + _currentCounter = 0; + updateTimer(); +} + +void WaitingSpinnerWidget::setLineLength(int length) { + _lineLength = length; + updateSize(); +} + +void WaitingSpinnerWidget::setLineWidth(int width) { + _lineWidth = width; + updateSize(); +} + +void WaitingSpinnerWidget::setInnerRadius(int radius) { + _innerRadius = radius; + updateSize(); +} + +QColor WaitingSpinnerWidget::color() { + return _color; +} + +qreal WaitingSpinnerWidget::roundness() { + return _roundness; +} + +qreal WaitingSpinnerWidget::minimumTrailOpacity() { + return _minimumTrailOpacity; +} + +qreal WaitingSpinnerWidget::trailFadePercentage() { + return _trailFadePercentage; +} + +qreal WaitingSpinnerWidget::revolutionsPersSecond() { + return _revolutionsPerSecond; +} + +int WaitingSpinnerWidget::numberOfLines() { + return _numberOfLines; +} + +int WaitingSpinnerWidget::lineLength() { + return _lineLength; +} + +int WaitingSpinnerWidget::lineWidth() { + return _lineWidth; +} + +int WaitingSpinnerWidget::innerRadius() { + return _innerRadius; +} + +bool WaitingSpinnerWidget::isSpinning() const { + return _isSpinning; +} + +void WaitingSpinnerWidget::setRoundness(qreal roundness) { + _roundness = std::max(0.0, std::min(100.0, roundness)); +} + +void WaitingSpinnerWidget::setColor(QColor color) { + _color = color; +} + +void WaitingSpinnerWidget::setRevolutionsPerSecond(qreal revolutionsPerSecond) { + _revolutionsPerSecond = revolutionsPerSecond; + updateTimer(); +} + +void WaitingSpinnerWidget::setTrailFadePercentage(qreal trail) { + _trailFadePercentage = trail; +} + +void WaitingSpinnerWidget::setMinimumTrailOpacity(qreal minimumTrailOpacity) { + _minimumTrailOpacity = minimumTrailOpacity; +} + +void WaitingSpinnerWidget::rotate() { + ++_currentCounter; + if (_currentCounter >= _numberOfLines) { + _currentCounter = 0; + } + update(); +} + +void WaitingSpinnerWidget::updateSize() { + int size = (_innerRadius + _lineLength) * 2; + setFixedSize(size, size); +} + +void WaitingSpinnerWidget::updateTimer() { + _timer->setInterval(1000 / (_numberOfLines * _revolutionsPerSecond)); +} + +void WaitingSpinnerWidget::updatePosition() { + if (parentWidget() && _centerOnParent) { + move(parentWidget()->width() / 2 - width() / 2, + parentWidget()->height() / 2 - height() / 2); + } +} + +int WaitingSpinnerWidget::lineCountDistanceFromPrimary(int current, int primary, + int totalNrOfLines) { + int distance = primary - current; + if (distance < 0) { + distance += totalNrOfLines; + } + return distance; +} + +QColor WaitingSpinnerWidget::currentLineColor(int countDistance, int totalNrOfLines, + qreal trailFadePerc, qreal minOpacity, + QColor color) { + if (countDistance == 0) { + return color; + } + const qreal minAlphaF = minOpacity / 100.0; + int distanceThreshold = + static_cast(ceil((totalNrOfLines - 1) * trailFadePerc / 100.0)); + if (countDistance > distanceThreshold) { + color.setAlphaF(minAlphaF); + } else { + qreal alphaDiff = color.alphaF() - minAlphaF; + qreal gradient = alphaDiff / static_cast(distanceThreshold + 1); + qreal resultAlpha = color.alphaF() - gradient * countDistance; + + // If alpha is out of bounds, clip it. + resultAlpha = std::min(1.0, std::max(0.0, resultAlpha)); + color.setAlphaF(resultAlpha); + } + return color; +} diff --git a/src/libcalamaresui/widgets/waitingspinnerwidget.h b/src/libcalamaresui/widgets/waitingspinnerwidget.h new file mode 100644 index 000000000..8129718a5 --- /dev/null +++ b/src/libcalamaresui/widgets/waitingspinnerwidget.h @@ -0,0 +1,114 @@ +/* Original Work Copyright (c) 2012-2014 Alexander Turkin + Modified 2014 by William Hallatt + Modified 2015 by Jacob Dawid +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#pragma once + +// Qt includes +#include +#include +#include + +class WaitingSpinnerWidget : public QWidget { + Q_OBJECT +public: + /*! Constructor for "standard" widget behaviour - use this + * constructor if you wish to, e.g. embed your widget in another. */ + WaitingSpinnerWidget(QWidget *parent = 0, + bool centerOnParent = true, + bool disableParentWhenSpinning = true); + + /*! Constructor - use this constructor to automatically create a modal + * ("blocking") spinner on top of the calling widget/window. If a valid + * parent widget is provided, "centreOnParent" will ensure that + * QtWaitingSpinner automatically centres itself on it, if not, + * "centreOnParent" is ignored. */ + WaitingSpinnerWidget(Qt::WindowModality modality, + QWidget *parent = 0, + bool centerOnParent = true, + bool disableParentWhenSpinning = true); + +public slots: + void start(); + void stop(); + +public: + void setColor(QColor color); + void setRoundness(qreal roundness); + void setMinimumTrailOpacity(qreal minimumTrailOpacity); + void setTrailFadePercentage(qreal trail); + void setRevolutionsPerSecond(qreal revolutionsPerSecond); + void setNumberOfLines(int lines); + void setLineLength(int length); + void setLineWidth(int width); + void setInnerRadius(int radius); + void setText(QString text); + + QColor color(); + qreal roundness(); + qreal minimumTrailOpacity(); + qreal trailFadePercentage(); + qreal revolutionsPersSecond(); + int numberOfLines(); + int lineLength(); + int lineWidth(); + int innerRadius(); + + bool isSpinning() const; + +private slots: + void rotate(); + +protected: + void paintEvent(QPaintEvent *paintEvent); + +private: + static int lineCountDistanceFromPrimary(int current, int primary, + int totalNrOfLines); + static QColor currentLineColor(int distance, int totalNrOfLines, + qreal trailFadePerc, qreal minOpacity, + QColor color); + + void initialize(); + void updateSize(); + void updateTimer(); + void updatePosition(); + +private: + QColor _color; + qreal _roundness; // 0..100 + qreal _minimumTrailOpacity; + qreal _trailFadePercentage; + qreal _revolutionsPerSecond; + int _numberOfLines; + int _lineLength; + int _lineWidth; + int _innerRadius; + +private: + WaitingSpinnerWidget(const WaitingSpinnerWidget&); + WaitingSpinnerWidget& operator=(const WaitingSpinnerWidget&); + + QTimer *_timer; + bool _centerOnParent; + bool _disableParentWhenSpinning; + int _currentCounter; + bool _isSpinning; +}; From d2d59e6206b9291b4cf5f5341eb3841ce4aea06a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 19 Sep 2017 15:39:57 +0200 Subject: [PATCH 22/30] Licensing: add header to QtWaitingSpinner copyright - mention that this is shipped as part of Calamares - SPDX info --- src/libcalamaresui/widgets/waitingspinnerwidget.cpp | 6 ++++++ src/libcalamaresui/widgets/waitingspinnerwidget.h | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/libcalamaresui/widgets/waitingspinnerwidget.cpp b/src/libcalamaresui/widgets/waitingspinnerwidget.cpp index 0ef03a0ba..317d83807 100644 --- a/src/libcalamaresui/widgets/waitingspinnerwidget.cpp +++ b/src/libcalamaresui/widgets/waitingspinnerwidget.cpp @@ -1,3 +1,9 @@ +/* === This file is part of Calamares - === + * + * SPDX-License-Identifier: MIT + * License-Filename: LICENSES/MIT-QtWaitingSpinner + */ + /* Original Work Copyright (c) 2012-2014 Alexander Turkin Modified 2014 by William Hallatt Modified 2015 by Jacob Dawid diff --git a/src/libcalamaresui/widgets/waitingspinnerwidget.h b/src/libcalamaresui/widgets/waitingspinnerwidget.h index 8129718a5..0ed8e69d3 100644 --- a/src/libcalamaresui/widgets/waitingspinnerwidget.h +++ b/src/libcalamaresui/widgets/waitingspinnerwidget.h @@ -1,3 +1,9 @@ +/* === This file is part of Calamares - === + * + * SPDX-License-Identifier: MIT + * License-Filename: LICENSES/MIT-QtWaitingSpinner + */ + /* Original Work Copyright (c) 2012-2014 Alexander Turkin Modified 2014 by William Hallatt Modified 2015 by Jacob Dawid From d23818b27cfb6faff46b2d7ec2759a55592322cc Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 19 Sep 2017 15:56:29 +0200 Subject: [PATCH 23/30] Fix code using re-imported spinner --- src/libcalamaresui/CMakeLists.txt | 2 +- src/libcalamaresui/widgets/WaitingWidget.cpp | 11 ++++++----- src/modules/partition/gui/ScanningDialog.cpp | 5 +++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/libcalamaresui/CMakeLists.txt b/src/libcalamaresui/CMakeLists.txt index 562c167e7..0021fbbfd 100644 --- a/src/libcalamaresui/CMakeLists.txt +++ b/src/libcalamaresui/CMakeLists.txt @@ -20,7 +20,7 @@ list( APPEND calamaresui_SOURCES widgets/ClickableLabel.cpp widgets/FixedAspectRatioLabel.cpp - widgets/QtWaitingSpinner.cpp + widgets/waitingspinnerwidget.cpp widgets/WaitingWidget.cpp ExecutionViewStep.cpp diff --git a/src/libcalamaresui/widgets/WaitingWidget.cpp b/src/libcalamaresui/widgets/WaitingWidget.cpp index 55471eff3..03c977691 100644 --- a/src/libcalamaresui/widgets/WaitingWidget.cpp +++ b/src/libcalamaresui/widgets/WaitingWidget.cpp @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,7 +20,7 @@ #include "WaitingWidget.h" #include "utils/CalamaresUtilsGui.h" -#include "QtWaitingSpinner.h" +#include "waitingspinnerwidget.h" #include #include @@ -34,7 +35,7 @@ WaitingWidget::WaitingWidget( const QString& text, QWidget* parent ) waitingLayout->addLayout( pbLayout ); pbLayout->addStretch(); - QtWaitingSpinner* spnr = new QtWaitingSpinner(); + WaitingSpinnerWidget* spnr = new WaitingSpinnerWidget(); pbLayout->addWidget( spnr ); pbLayout->addStretch(); @@ -43,9 +44,9 @@ WaitingWidget::WaitingWidget( const QString& text, QWidget* parent ) int spnrSize = m_waitingLabel->fontMetrics().height() * 4; spnr->setFixedSize( spnrSize, spnrSize ); - spnr->setRadius( spnrSize / 2 ); - spnr->setLength( spnrSize / 2 ); - spnr->setWidth( spnrSize / 8 ); + spnr->setInnerRadius( spnrSize / 2 ); + spnr->setLineLength( spnrSize / 2 ); + spnr->setLineWidth( spnrSize / 8 ); spnr->start(); m_waitingLabel->setAlignment( Qt::AlignCenter ); diff --git a/src/modules/partition/gui/ScanningDialog.cpp b/src/modules/partition/gui/ScanningDialog.cpp index 76a1bc55f..85c0cb734 100644 --- a/src/modules/partition/gui/ScanningDialog.cpp +++ b/src/modules/partition/gui/ScanningDialog.cpp @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2015, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,7 +19,7 @@ #include "ScanningDialog.h" -#include "widgets/QtWaitingSpinner.h" +#include "widgets/waitingspinnerwidget.h" #include #include @@ -37,7 +38,7 @@ ScanningDialog::ScanningDialog( const QString& text, QHBoxLayout* dialogLayout = new QHBoxLayout; setLayout( dialogLayout ); - QtWaitingSpinner* spinner = new QtWaitingSpinner; + WaitingSpinnerWidget* spinner = new WaitingSpinnerWidget(); dialogLayout->addWidget( spinner ); spinner->start(); From a65bc7d756bf200d27aca1b7186d31a669b3b651 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 19 Sep 2017 16:08:30 +0200 Subject: [PATCH 24/30] Licensing: re-import ImageRegistry - include full license headers, - copied from - repo: https://github.com/tomahawk-player/tomahawk/ - rev: 00f602e10203b76fc28b4615868c567e6bd4ced4 - path: src/libtomahawk/utils/ImageRegistry.cpp --- LICENSES/GPLv3+-ImageRegistry | 16 ++++ src/libcalamaresui/utils/ImageRegistry.cpp | 93 +++++++++++----------- src/libcalamaresui/utils/ImageRegistry.h | 48 +++++------ 3 files changed, 85 insertions(+), 72 deletions(-) create mode 100644 LICENSES/GPLv3+-ImageRegistry diff --git a/LICENSES/GPLv3+-ImageRegistry b/LICENSES/GPLv3+-ImageRegistry new file mode 100644 index 000000000..362e89766 --- /dev/null +++ b/LICENSES/GPLv3+-ImageRegistry @@ -0,0 +1,16 @@ +/* + * Copyright 2012, Christian Muehlhaeuser + + This program 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. + + This program 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 this program. If not, see . +*/ diff --git a/src/libcalamaresui/utils/ImageRegistry.cpp b/src/libcalamaresui/utils/ImageRegistry.cpp index 9ed646e50..a8c4aa209 100644 --- a/src/libcalamaresui/utils/ImageRegistry.cpp +++ b/src/libcalamaresui/utils/ImageRegistry.cpp @@ -1,35 +1,30 @@ -/* === This file is part of Calamares - === - * - * Copyright 2014, Teo Mrnjavac - * Copyright 2017, Adriaan de Groot - * - * Originally from Tomahawk, +/* * Copyright 2012, Christian Muehlhaeuser - * - * 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 . - */ + + This program 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. + + This program 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 this program. If not, see . +*/ #include "ImageRegistry.h" #include #include -#include +#include #include "utils/Logger.h" static QHash< QString, QHash< int, QHash< qint64, QPixmap > > > s_cache; -ImageRegistry* ImageRegistry::s_instance = nullptr; +ImageRegistry* ImageRegistry::s_instance = 0; ImageRegistry* @@ -46,22 +41,28 @@ ImageRegistry::ImageRegistry() QIcon -ImageRegistry::icon( const QString& image, CalamaresUtils::ImageMode mode ) +ImageRegistry::icon( const QString& image, TomahawkUtils::ImageMode mode ) { - return pixmap( image, CalamaresUtils::defaultIconSize(), mode ); + return pixmap( image, TomahawkUtils::defaultIconSize(), mode ); } qint64 -ImageRegistry::cacheKey( const QSize& size, qreal opacity, QColor tint ) +ImageRegistry::cacheKey( const QSize& size, float opacity, QColor tint ) { - return size.width() * 100 + size.height() * 10 + int( opacity * 100.0 ) + tint.value(); + return size.width() * 100 + size.height() * 10 + ( opacity * 100.0 ) + tint.value(); } QPixmap -ImageRegistry::pixmap( const QString& image, const QSize& size, CalamaresUtils::ImageMode mode, qreal opacity, QColor tint ) +ImageRegistry::pixmap( const QString& image, const QSize& size, TomahawkUtils::ImageMode mode, float opacity, QColor tint ) { + if ( size.width() < 0 || size.height() < 0 ) + { + Q_ASSERT( false ); + return QPixmap(); + } + QHash< qint64, QPixmap > subsubcache; QHash< int, QHash< qint64, QPixmap > > subcache; @@ -83,11 +84,10 @@ ImageRegistry::pixmap( const QString& image, const QSize& size, CalamaresUtils:: // Image not found in cache. Let's load it. QPixmap pixmap; - if ( image.toLower().endsWith( ".svg" ) || - image.toLower().endsWith( ".svgz" ) ) + if ( image.toLower().endsWith( ".svg" ) ) { QSvgRenderer svgRenderer( image ); - QPixmap p( size.isNull() ? svgRenderer.defaultSize() : size ); + QPixmap p( size.isNull() || size.height() == 0 || size.width() == 0 ? svgRenderer.defaultSize() : size ); p.fill( Qt::transparent ); QPainter pixPainter( &p ); @@ -96,17 +96,7 @@ ImageRegistry::pixmap( const QString& image, const QSize& size, CalamaresUtils:: pixPainter.end(); if ( tint.alpha() > 0 ) - { - QImage resultImage( p.size(), QImage::Format_ARGB32_Premultiplied ); - QPainter painter( &resultImage ); - painter.drawPixmap( 0, 0, p ); - painter.setCompositionMode( QPainter::CompositionMode_Screen ); - painter.fillRect( resultImage.rect(), tint ); - painter.end(); - - resultImage.setAlphaChannel( p.toImage().alphaChannel() ); - p = QPixmap::fromImage( resultImage ); - } + p = TomahawkUtils::tinted( p, tint ); pixmap = p; } @@ -117,8 +107,8 @@ ImageRegistry::pixmap( const QString& image, const QSize& size, CalamaresUtils:: { switch ( mode ) { - case CalamaresUtils::RoundedCorners: - pixmap = CalamaresUtils::createRoundedImage( pixmap, size ); + case TomahawkUtils::RoundedCorners: + pixmap = TomahawkUtils::createRoundedImage( pixmap, size ); break; default: @@ -126,7 +116,18 @@ ImageRegistry::pixmap( const QString& image, const QSize& size, CalamaresUtils:: } if ( !size.isNull() && pixmap.size() != size ) - pixmap = pixmap.scaled( size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ); + { + if ( size.width() == 0 ) + { + pixmap = pixmap.scaledToHeight( size.height(), Qt::SmoothTransformation ); + } + else if ( size.height() == 0 ) + { + pixmap = pixmap.scaledToWidth( size.width(), Qt::SmoothTransformation ); + } + else + pixmap = pixmap.scaled( size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ); + } putInCache( image, size, mode, opacity, pixmap, tint ); } @@ -136,9 +137,9 @@ ImageRegistry::pixmap( const QString& image, const QSize& size, CalamaresUtils:: void -ImageRegistry::putInCache( const QString& image, const QSize& size, CalamaresUtils::ImageMode mode, qreal opacity, const QPixmap& pixmap, QColor tint ) +ImageRegistry::putInCache( const QString& image, const QSize& size, TomahawkUtils::ImageMode mode, float opacity, const QPixmap& pixmap, QColor tint ) { -// cDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Adding to image cache:" << image << size << mode; + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Adding to image cache:" << image << size << mode; QHash< qint64, QPixmap > subsubcache; QHash< int, QHash< qint64, QPixmap > > subcache; diff --git a/src/libcalamaresui/utils/ImageRegistry.h b/src/libcalamaresui/utils/ImageRegistry.h index 4909b0183..880fa546a 100644 --- a/src/libcalamaresui/utils/ImageRegistry.h +++ b/src/libcalamaresui/utils/ImageRegistry.h @@ -1,45 +1,41 @@ -/* === This file is part of Calamares - === - * - * Copyright 2014, Teo Mrnjavac - * - * Originally from Tomahawk, +/* * Copyright 2012, Christian Muehlhaeuser - * - * 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 . - */ + + This program 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. + + This program 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 this program. If not, see . +*/ #ifndef IMAGE_REGISTRY_H #define IMAGE_REGISTRY_H #include -#include "utils/CalamaresUtilsGui.h" -#include "UiDllMacro.h" +#include "utils/TomahawkUtilsGui.h" +#include "DllMacro.h" -class UIDLLEXPORT ImageRegistry +class DLLEXPORT ImageRegistry { public: static ImageRegistry* instance(); explicit ImageRegistry(); - QIcon icon( const QString& image, CalamaresUtils::ImageMode mode = CalamaresUtils::Original ); - QPixmap pixmap( const QString& image, const QSize& size, CalamaresUtils::ImageMode mode = CalamaresUtils::Original, qreal opacity = 1.0, QColor tint = QColor( 0, 0, 0, 0 ) ); + QIcon icon( const QString& image, TomahawkUtils::ImageMode mode = TomahawkUtils::Original ); + QPixmap pixmap( const QString& image, const QSize& size, TomahawkUtils::ImageMode mode = TomahawkUtils::Original, float opacity = 1.0, QColor tint = QColor( 0, 0, 0, 0 ) ); private: - qint64 cacheKey( const QSize& size, qreal opacity, QColor tint ); - void putInCache( const QString& image, const QSize& size, CalamaresUtils::ImageMode mode, qreal opacity, const QPixmap& pixmap, QColor tint ); + qint64 cacheKey( const QSize& size, float opacity, QColor tint ); + void putInCache( const QString& image, const QSize& size, TomahawkUtils::ImageMode mode, float opacity, const QPixmap& pixmap, QColor tint ); static ImageRegistry* s_instance; }; From 6010805935837d63eac735571c2a0cbb02f911cb Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 19 Sep 2017 16:12:00 +0200 Subject: [PATCH 25/30] Licensing: add header to imageregistry copyright - mention that this is shipped as part of Calamares - SPDX info --- src/libcalamaresui/utils/ImageRegistry.cpp | 6 ++++++ src/libcalamaresui/utils/ImageRegistry.h | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/libcalamaresui/utils/ImageRegistry.cpp b/src/libcalamaresui/utils/ImageRegistry.cpp index a8c4aa209..5e871c884 100644 --- a/src/libcalamaresui/utils/ImageRegistry.cpp +++ b/src/libcalamaresui/utils/ImageRegistry.cpp @@ -1,3 +1,9 @@ +/* === This file is part of Calamares - === + * + * SPDX-License-Identifier: GPLv3+ + * License-Filename: LICENSES/GPLv3+-ImageRegistry + */ + /* * Copyright 2012, Christian Muehlhaeuser diff --git a/src/libcalamaresui/utils/ImageRegistry.h b/src/libcalamaresui/utils/ImageRegistry.h index 880fa546a..091127187 100644 --- a/src/libcalamaresui/utils/ImageRegistry.h +++ b/src/libcalamaresui/utils/ImageRegistry.h @@ -1,3 +1,9 @@ +/* === This file is part of Calamares - === + * + * SPDX-License-Identifier: GPLv3+ + * License-Filename: LICENSES/GPLv3+-ImageRegistry + */ + /* * Copyright 2012, Christian Muehlhaeuser From b04a8907989e85e97abaa2903963dddefca7b82b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 19 Sep 2017 16:22:59 +0200 Subject: [PATCH 26/30] Fix code using re-imported imageregistry --- src/libcalamaresui/utils/ImageRegistry.cpp | 28 +++++++++++++--------- src/libcalamaresui/utils/ImageRegistry.h | 12 +++++----- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/libcalamaresui/utils/ImageRegistry.cpp b/src/libcalamaresui/utils/ImageRegistry.cpp index 5e871c884..442017048 100644 --- a/src/libcalamaresui/utils/ImageRegistry.cpp +++ b/src/libcalamaresui/utils/ImageRegistry.cpp @@ -27,8 +27,6 @@ #include #include -#include "utils/Logger.h" - static QHash< QString, QHash< int, QHash< qint64, QPixmap > > > s_cache; ImageRegistry* ImageRegistry::s_instance = 0; @@ -47,9 +45,9 @@ ImageRegistry::ImageRegistry() QIcon -ImageRegistry::icon( const QString& image, TomahawkUtils::ImageMode mode ) +ImageRegistry::icon( const QString& image, CalamaresUtils::ImageMode mode ) { - return pixmap( image, TomahawkUtils::defaultIconSize(), mode ); + return pixmap( image, CalamaresUtils::defaultIconSize(), mode ); } @@ -61,7 +59,7 @@ ImageRegistry::cacheKey( const QSize& size, float opacity, QColor tint ) QPixmap -ImageRegistry::pixmap( const QString& image, const QSize& size, TomahawkUtils::ImageMode mode, float opacity, QColor tint ) +ImageRegistry::pixmap( const QString& image, const QSize& size, CalamaresUtils::ImageMode mode, float opacity, QColor tint ) { if ( size.width() < 0 || size.height() < 0 ) { @@ -102,7 +100,17 @@ ImageRegistry::pixmap( const QString& image, const QSize& size, TomahawkUtils::I pixPainter.end(); if ( tint.alpha() > 0 ) - p = TomahawkUtils::tinted( p, tint ); + { + QImage resultImage( p.size(), QImage::Format_ARGB32_Premultiplied ); + QPainter painter( &resultImage ); + painter.drawPixmap( 0, 0, p ); + painter.setCompositionMode( QPainter::CompositionMode_Screen ); + painter.fillRect( resultImage.rect(), tint ); + painter.end(); + + resultImage.setAlphaChannel( p.toImage().alphaChannel() ); + p = QPixmap::fromImage( resultImage ); + } pixmap = p; } @@ -113,8 +121,8 @@ ImageRegistry::pixmap( const QString& image, const QSize& size, TomahawkUtils::I { switch ( mode ) { - case TomahawkUtils::RoundedCorners: - pixmap = TomahawkUtils::createRoundedImage( pixmap, size ); + case CalamaresUtils::RoundedCorners: + pixmap = CalamaresUtils::createRoundedImage( pixmap, size ); break; default: @@ -143,10 +151,8 @@ ImageRegistry::pixmap( const QString& image, const QSize& size, TomahawkUtils::I void -ImageRegistry::putInCache( const QString& image, const QSize& size, TomahawkUtils::ImageMode mode, float opacity, const QPixmap& pixmap, QColor tint ) +ImageRegistry::putInCache( const QString& image, const QSize& size, CalamaresUtils::ImageMode mode, float opacity, const QPixmap& pixmap, QColor tint ) { - tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Adding to image cache:" << image << size << mode; - QHash< qint64, QPixmap > subsubcache; QHash< int, QHash< qint64, QPixmap > > subcache; diff --git a/src/libcalamaresui/utils/ImageRegistry.h b/src/libcalamaresui/utils/ImageRegistry.h index 091127187..e35eaf74a 100644 --- a/src/libcalamaresui/utils/ImageRegistry.h +++ b/src/libcalamaresui/utils/ImageRegistry.h @@ -26,22 +26,22 @@ #include -#include "utils/TomahawkUtilsGui.h" -#include "DllMacro.h" +#include "utils/CalamaresUtilsGui.h" +#include "UiDllMacro.h" -class DLLEXPORT ImageRegistry +class UIDLLEXPORT ImageRegistry { public: static ImageRegistry* instance(); explicit ImageRegistry(); - QIcon icon( const QString& image, TomahawkUtils::ImageMode mode = TomahawkUtils::Original ); - QPixmap pixmap( const QString& image, const QSize& size, TomahawkUtils::ImageMode mode = TomahawkUtils::Original, float opacity = 1.0, QColor tint = QColor( 0, 0, 0, 0 ) ); + QIcon icon( const QString& image, CalamaresUtils::ImageMode mode = CalamaresUtils::Original ); + QPixmap pixmap( const QString& image, const QSize& size, CalamaresUtils::ImageMode mode = CalamaresUtils::Original, float opacity = 1.0, QColor tint = QColor( 0, 0, 0, 0 ) ); private: qint64 cacheKey( const QSize& size, float opacity, QColor tint ); - void putInCache( const QString& image, const QSize& size, TomahawkUtils::ImageMode mode, float opacity, const QPixmap& pixmap, QColor tint ); + void putInCache( const QString& image, const QSize& size, CalamaresUtils::ImageMode mode, float opacity, const QPixmap& pixmap, QColor tint ); static ImageRegistry* s_instance; }; From 0c129f2460683815b0704696c9e5f0f465235e07 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 19 Sep 2017 16:46:55 +0200 Subject: [PATCH 27/30] Reduce third-part warnings a better way. Thanks to Kevin Kofler for pointing out what I'd forgotten about source-file flags. While at it, introduce a generic mechanism for suppressing warnings in third-party code. Mostly reverts 49304849318241258ae7159cf38f32b708fe63c2 --- CMakeLists.txt | 9 +++++++++ src/libcalamares/CMakeLists.txt | 32 +++++++------------------------- 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f0a3c3e4..da33793c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,13 @@ if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) string( APPEND CMAKE_CXX_FLAGS " ${CLANG_WARNINGS}" ) endforeach() + # Third-party code where we don't care so much about compiler warnings + # (because it's uncomfortable to patch) get different flags; use + # set_source_files_properties( + # PROPERTIES COMPILE_FLAGS "${SUPPRESS_3RDPARTY_WARNINGS}" ) + # to switch off warnings for those sources. + set( SUPPRESS_3RDPARTY_WARNINGS "-Wno-everything" ) + set( CMAKE_CXX_FLAGS_DEBUG "-g" ) set( CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG" ) set( CMAKE_CXX_FLAGS_RELEASE "-O4 -DNDEBUG" ) @@ -76,6 +83,8 @@ if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) else() set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--no-undefined" ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--fatal-warnings -Wnon-virtual-dtor -Woverloaded-virtual -Werror=return-type" ) + + set( SUPPRESS_3RDPARTY_WARNINGS "" ) endif() if( CMAKE_COMPILER_IS_GNUCXX ) diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index c97e35ada..ba10fcc70 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -19,14 +19,6 @@ set( libSources JobQueue.cpp ProcessJob.cpp ) - -include_directories( - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} -) - -# Build subdirs as their own separate OBJECT libraries, -# to allow changing compiler warnings on their code. set( utilsSources utils/CalamaresUtils.cpp utils/CalamaresUtilsSystem.cpp @@ -34,26 +26,19 @@ set( utilsSources utils/PluginFactory.cpp utils/Retranslator.cpp ) -add_library( utilsLib OBJECT ${utilsSources} ) -target_compile_options( utilsLib PUBLIC -fPIC ) -target_include_directories( utilsLib PUBLIC - $ -) -set_target_properties( utilsLib PROPERTIES AUTOMOC TRUE ) - set( kdsagSources kdsingleapplicationguard/kdsingleapplicationguard.cpp kdsingleapplicationguard/kdsharedmemorylocker.cpp kdsingleapplicationguard/kdtoolsglobal.cpp kdsingleapplicationguard/kdlockedsharedmemorypointer.cpp ) -add_library( kdsagLib OBJECT ${kdsagSources} ) -target_compile_options( kdsagLib PUBLIC -fPIC ) -target_include_directories( kdsagLib PUBLIC - $ -) -set_target_properties( kdsagLib PROPERTIES AUTOMOC TRUE ) +set_source_files_properties( ${kdsagSources} + PROPERTIES COMPILE_FLAGS "${SUPPRESS_3RDPARTY_WARNINGS}" ) +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} +) if( WITH_PYTHON ) set( libSources @@ -91,10 +76,7 @@ if( WITH_PYTHONQT ) endif() -add_library( calamares SHARED ${libSources} - $ - $ -) +add_library( calamares SHARED ${libSources} ${kdsagSources} ${utilsSources} ) set_target_properties( calamares PROPERTIES AUTOMOC TRUE From 9693d7a5bd23248e3c88b53aab99b52035fb5505 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 20 Sep 2017 08:22:39 -0400 Subject: [PATCH 28/30] Memory: clean up interface used to get memory (RAM) size --- .../utils/CalamaresUtilsSystem.cpp | 20 +++++-------- src/libcalamares/utils/CalamaresUtilsSystem.h | 14 +++++++-- .../partition/core/PartitionActions.cpp | 30 ++++++++++--------- .../welcome/checker/RequirementsChecker.cpp | 6 ++-- 4 files changed, 38 insertions(+), 32 deletions(-) diff --git a/src/libcalamares/utils/CalamaresUtilsSystem.cpp b/src/libcalamares/utils/CalamaresUtilsSystem.cpp index 3936852ab..656a57c10 100644 --- a/src/libcalamares/utils/CalamaresUtilsSystem.cpp +++ b/src/libcalamares/utils/CalamaresUtilsSystem.cpp @@ -231,14 +231,7 @@ System::targetEnvOutput( const QString& command, } -qint64 -System::getPhysicalMemoryB() -{ - return 0; -} - - -qint64 +QPair System::getTotalMemoryB() { #ifdef Q_OS_LINUX @@ -246,20 +239,21 @@ System::getTotalMemoryB() int r = sysinfo( &i ); if (r) - return 0; + return qMakePair(0, 0.0); - return qint64( i.mem_unit ) * i.totalram; + return qMakePair(quint64( i.mem_unit ) * quint64( i.totalram ), 1.1); #elif defined( Q_OS_FREEBSD ) unsigned long memsize; size_t s = sizeof(memsize); int r = sysctlbyname("vm.kmem_size", &memsize, &s, NULL, 0); if (r) - return 0; + return qMakePair(0, 0.0); - return memsize; + return qMakePair(memsize, 1.01); +#else + return qMakePair(0, 0.0); // Unsupported #endif - return 0; // Unsupported } diff --git a/src/libcalamares/utils/CalamaresUtilsSystem.h b/src/libcalamares/utils/CalamaresUtilsSystem.h index bf3acb41c..1ccdfb516 100644 --- a/src/libcalamares/utils/CalamaresUtilsSystem.h +++ b/src/libcalamares/utils/CalamaresUtilsSystem.h @@ -100,9 +100,19 @@ public: /** * @brief getTotalMemoryB returns the total main memory, in bytes. + * + * Since it is difficult to get the RAM memory size exactly -- either + * by reading information from the DIMMs, which may fail on virtual hosts + * or from asking the kernel, which doesn't report some memory areas -- + * this returns a pair of guessed-size (in bytes) and a "guesstimate factor" + * which says how good the guess is. Generally, assume the *real* memory + * available is size * guesstimate. + * + * If nothing can be found, returns a 0 size and 0 guesstimate. + * + * @return size, guesstimate-factor */ - DLLEXPORT qint64 getTotalMemoryB(); //Always underguessed, but always works on Linux - DLLEXPORT qint64 getPhysicalMemoryB(); //Better guess, doesn't work in VirualBox + DLLEXPORT QPair getTotalMemoryB(); private: static System* s_instance; diff --git a/src/modules/partition/core/PartitionActions.cpp b/src/modules/partition/core/PartitionActions.cpp index 9567661b2..1c2363845 100644 --- a/src/modules/partition/core/PartitionActions.cpp +++ b/src/modules/partition/core/PartitionActions.cpp @@ -45,19 +45,21 @@ using CalamaresUtils::operator""_MiB; qint64 swapSuggestion( const qint64 availableSpaceB ) { - // swap(mem) = max(2, 2 * mem), if mem < 2 GiB - // = mem, if 2 GiB <= mem < 8 GiB - // = mem / 2, if 8 GIB <= mem < 64 GiB - // = 4 GiB, if mem >= 64 GiB - + /* If suspend-to-disk is demanded, then we always need enough + * swap to write the whole memory to disk -- between 2GB and 8GB + * RAM give proportionally more swap, and from 8GB RAM keep + * swap = RAM. + * + * If suspend-to-disk is not demanded, then ramp up more slowly, + * to 8GB swap at 16GB memory, and then drop to 4GB for "large + * memory" machines, on the assumption that those don't need swap + * because they have tons of memory (or whatever they are doing, + * had better not run into swap). + */ qint64 suggestedSwapSizeB = 0; - qint64 availableRamB = CalamaresUtils::System::instance()->getPhysicalMemoryB(); - qreal overestimationFactor = 1.01; - if ( !availableRamB ) - { - availableRamB = CalamaresUtils::System::instance()->getTotalMemoryB(); - overestimationFactor = 1.10; - } + auto memory = CalamaresUtils::System::instance()->getTotalMemoryB(); + qint64 availableRamB = memory.first; + qreal overestimationFactor = memory.second; bool ensureSuspendToDisk = Calamares::JobQueue::instance()->globalStorage()-> @@ -80,8 +82,8 @@ swapSuggestion( const qint64 availableSpaceB ) suggestedSwapSizeB = qMax( 2_GiB, availableRamB * 2 ); else if ( availableRamB >= 2_GiB && availableRamB < 8_GiB ) suggestedSwapSizeB = availableRamB; - else if ( availableRamB >= 8_GiB && availableRamB < 64_GiB ) - suggestedSwapSizeB = availableRamB / 2; + else if ( availableRamB >= 8_GiB && availableRamB < 16_GiB ) + suggestedSwapSizeB = 8_GiB; else suggestedSwapSizeB = 4_GiB; diff --git a/src/modules/welcome/checker/RequirementsChecker.cpp b/src/modules/welcome/checker/RequirementsChecker.cpp index ac5f5088b..720c17955 100644 --- a/src/modules/welcome/checker/RequirementsChecker.cpp +++ b/src/modules/welcome/checker/RequirementsChecker.cpp @@ -310,9 +310,9 @@ RequirementsChecker::checkEnoughStorage( qint64 requiredSpace ) bool RequirementsChecker::checkEnoughRam( qint64 requiredRam ) { - qint64 availableRam = CalamaresUtils::System::instance()->getPhysicalMemoryB(); - if ( !availableRam ) - availableRam = CalamaresUtils::System::instance()->getTotalMemoryB(); + // Ignore the guesstimate-factor; we get an under-estimate + // which is probably the usable RAM for programs. + quint64 availableRam = CalamaresUtils::System::instance()->getTotalMemoryB().first; return availableRam >= requiredRam * 0.95; // because MemTotal is variable } From 337903db09c4196ea17313386933d4e1f19e7492 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 20 Sep 2017 08:24:28 -0400 Subject: [PATCH 29/30] Clang: reduce warnings about overriden destructors --- src/libcalamares/ProcessJob.h | 2 +- src/libcalamaresui/modulesystem/CppJobModule.h | 2 +- src/libcalamaresui/modulesystem/ProcessJobModule.h | 2 +- src/libcalamaresui/modulesystem/ViewModule.h | 2 +- src/modules/finished/FinishedViewStep.h | 2 +- src/modules/license/LicenseViewStep.h | 4 ++-- src/modules/locale/LocaleViewStep.h | 2 +- src/modules/partition/core/BootLoaderModel.h | 2 +- src/modules/summary/SummaryViewStep.h | 2 +- src/modules/welcome/WelcomeViewStep.h | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/libcalamares/ProcessJob.h b/src/libcalamares/ProcessJob.h index 259f97308..43fdf254e 100644 --- a/src/libcalamares/ProcessJob.h +++ b/src/libcalamares/ProcessJob.h @@ -33,7 +33,7 @@ public: bool runInChroot = false, int secondsTimeout = 30, QObject* parent = nullptr ); - virtual ~ProcessJob(); + virtual ~ProcessJob() override; QString prettyName() const override; QString prettyStatusMessage() const override; diff --git a/src/libcalamaresui/modulesystem/CppJobModule.h b/src/libcalamaresui/modulesystem/CppJobModule.h index 875f30785..46d27bf8b 100644 --- a/src/libcalamaresui/modulesystem/CppJobModule.h +++ b/src/libcalamaresui/modulesystem/CppJobModule.h @@ -44,7 +44,7 @@ protected: private: friend class Module; //so only the superclass can instantiate explicit CppJobModule(); - virtual ~CppJobModule(); + virtual ~CppJobModule() override; QPluginLoader* m_loader; job_ptr m_job; diff --git a/src/libcalamaresui/modulesystem/ProcessJobModule.h b/src/libcalamaresui/modulesystem/ProcessJobModule.h index 9d30ec235..af9a46bd5 100644 --- a/src/libcalamaresui/modulesystem/ProcessJobModule.h +++ b/src/libcalamaresui/modulesystem/ProcessJobModule.h @@ -42,7 +42,7 @@ protected: private: friend class Module; explicit ProcessJobModule(); - virtual ~ProcessJobModule(); + virtual ~ProcessJobModule() override; QString m_command; QString m_workingPath; diff --git a/src/libcalamaresui/modulesystem/ViewModule.h b/src/libcalamaresui/modulesystem/ViewModule.h index 32b0e8a1f..6b2e381a2 100644 --- a/src/libcalamaresui/modulesystem/ViewModule.h +++ b/src/libcalamaresui/modulesystem/ViewModule.h @@ -45,7 +45,7 @@ protected: private: friend class Module; //so only the superclass can instantiate explicit ViewModule(); - virtual ~ViewModule(); + virtual ~ViewModule() override; QPluginLoader* m_loader; ViewStep* m_viewStep = nullptr; diff --git a/src/modules/finished/FinishedViewStep.h b/src/modules/finished/FinishedViewStep.h index cb3656046..6a11dc8a3 100644 --- a/src/modules/finished/FinishedViewStep.h +++ b/src/modules/finished/FinishedViewStep.h @@ -34,7 +34,7 @@ class PLUGINDLLEXPORT FinishedViewStep : public Calamares::ViewStep public: explicit FinishedViewStep( QObject* parent = nullptr ); - virtual ~FinishedViewStep(); + virtual ~FinishedViewStep() override; QString prettyName() const override; diff --git a/src/modules/license/LicenseViewStep.h b/src/modules/license/LicenseViewStep.h index 6229853ba..07824a5e3 100644 --- a/src/modules/license/LicenseViewStep.h +++ b/src/modules/license/LicenseViewStep.h @@ -36,7 +36,7 @@ class PLUGINDLLEXPORT LicenseViewStep : public Calamares::ViewStep public: explicit LicenseViewStep( QObject* parent = nullptr ); - virtual ~LicenseViewStep(); + virtual ~LicenseViewStep() override; QString prettyName() const override; @@ -52,7 +52,7 @@ public: bool isAtEnd() const override; QList< Calamares::job_ptr > jobs() const override; - + void setConfigurationMap( const QVariantMap& configurationMap ) override; private: diff --git a/src/modules/locale/LocaleViewStep.h b/src/modules/locale/LocaleViewStep.h index 2785f3d4a..402fb7ce9 100644 --- a/src/modules/locale/LocaleViewStep.h +++ b/src/modules/locale/LocaleViewStep.h @@ -37,7 +37,7 @@ class PLUGINDLLEXPORT LocaleViewStep : public Calamares::ViewStep public: explicit LocaleViewStep( QObject* parent = nullptr ); - virtual ~LocaleViewStep(); + virtual ~LocaleViewStep() override; QString prettyName() const override; QString prettyStatus() const override; diff --git a/src/modules/partition/core/BootLoaderModel.h b/src/modules/partition/core/BootLoaderModel.h index 27684e326..2ef175e84 100644 --- a/src/modules/partition/core/BootLoaderModel.h +++ b/src/modules/partition/core/BootLoaderModel.h @@ -39,7 +39,7 @@ public: }; BootLoaderModel( QObject* parent = 0 ); - ~BootLoaderModel(); + ~BootLoaderModel() override; /** * Init the model with the list of devices. Does *not* take ownership of the diff --git a/src/modules/summary/SummaryViewStep.h b/src/modules/summary/SummaryViewStep.h index b7197b71b..e1a8df89b 100644 --- a/src/modules/summary/SummaryViewStep.h +++ b/src/modules/summary/SummaryViewStep.h @@ -34,7 +34,7 @@ class PLUGINDLLEXPORT SummaryViewStep : public Calamares::ViewStep public: explicit SummaryViewStep( QObject* parent = nullptr ); - virtual ~SummaryViewStep(); + virtual ~SummaryViewStep() override; QString prettyName() const override; diff --git a/src/modules/welcome/WelcomeViewStep.h b/src/modules/welcome/WelcomeViewStep.h index db33a89bd..fbcbd8ded 100644 --- a/src/modules/welcome/WelcomeViewStep.h +++ b/src/modules/welcome/WelcomeViewStep.h @@ -37,7 +37,7 @@ class PLUGINDLLEXPORT WelcomeViewStep : public Calamares::ViewStep public: explicit WelcomeViewStep( QObject* parent = nullptr ); - virtual ~WelcomeViewStep(); + virtual ~WelcomeViewStep() override; QString prettyName() const override; From 34761c4214e95d877f0f1b2f29d479169885d646 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 20 Sep 2017 09:16:15 -0400 Subject: [PATCH 30/30] Clang: reduce 0-as-nullptr warnings --- src/libcalamares/utils/PluginFactory.cpp | 2 +- src/libcalamares/utils/PluginFactory.h | 10 +++++----- src/modules/welcome/checker/RequirementsChecker.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libcalamares/utils/PluginFactory.cpp b/src/libcalamares/utils/PluginFactory.cpp index c22c90ff7..b1c3a0793 100644 --- a/src/libcalamares/utils/PluginFactory.cpp +++ b/src/libcalamares/utils/PluginFactory.cpp @@ -104,7 +104,7 @@ QObject* PluginFactory::create( const char* iface, QWidget* parentWidget, QObjec { Q_D( PluginFactory ); - QObject* obj = 0; + QObject* obj = nullptr; const QList candidates( d->createInstanceHash.values( keyword ) ); // for !keyword.isEmpty() candidates.count() is 0 or 1 diff --git a/src/libcalamares/utils/PluginFactory.h b/src/libcalamares/utils/PluginFactory.h index 945a3eaaf..55c44249c 100644 --- a/src/libcalamares/utils/PluginFactory.h +++ b/src/libcalamares/utils/PluginFactory.h @@ -223,7 +223,7 @@ public: * \returns A pointer to the created object is returned, or 0 if an error occurred. */ template - T* create( QObject* parent = 0 ); + T* create( QObject* parent = nullptr ); /** * Use this method to create an object. It will try to create an object which inherits @@ -236,7 +236,7 @@ public: * \returns A pointer to the created object is returned, or 0 if an error occurred. */ template - T* create( const QString& keyword, QObject* parent = 0 ); + T* create( const QString& keyword, QObject* parent = nullptr ); Q_SIGNALS: void objectCreated( QObject* object ); @@ -322,7 +322,7 @@ protected: static QObject* createInstance( QWidget* parentWidget, QObject* parent ) { Q_UNUSED( parentWidget ); - ParentType* p = 0; + ParentType* p = nullptr; if ( parent ) { p = qobject_cast( parent ); @@ -339,7 +339,7 @@ template inline T* PluginFactory::create( QObject* parent ) { QObject* o = create( T::staticMetaObject.className(), - parent && parent->isWidgetType() ? reinterpret_cast( parent ) : 0, + parent && parent->isWidgetType() ? reinterpret_cast( parent ) : nullptr, parent, QString() ); @@ -353,7 +353,7 @@ template inline T* PluginFactory::create( const QString& keyword, QObject* parent ) { QObject* o = create( T::staticMetaObject.className(), - parent && parent->isWidgetType() ? reinterpret_cast( parent ) : 0, + parent && parent->isWidgetType() ? reinterpret_cast( parent ) : nullptr, parent, keyword ); diff --git a/src/modules/welcome/checker/RequirementsChecker.cpp b/src/modules/welcome/checker/RequirementsChecker.cpp index 720c17955..3d4e394c4 100644 --- a/src/modules/welcome/checker/RequirementsChecker.cpp +++ b/src/modules/welcome/checker/RequirementsChecker.cpp @@ -357,7 +357,7 @@ RequirementsChecker::checkHasPower() QDBusInterface upowerIntf( UPOWER_SVC_NAME, UPOWER_PATH, UPOWER_INTF_NAME, - QDBusConnection::systemBus(), 0 ); + QDBusConnection::systemBus() ); bool onBattery = upowerIntf.property( "OnBattery" ).toBool();