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 74f69a8a7..da33793c7 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 @@ -30,7 +48,30 @@ 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" ) + # 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() + + # 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" ) @@ -42,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 ) @@ -61,7 +104,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 ) @@ -70,11 +112,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/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/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/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/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 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 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 diff --git a/lang/python/is/LC_MESSAGES/python.mo b/lang/python/is/LC_MESSAGES/python.mo index 23ed397ae..26b8d0676 100644 Binary files a/lang/python/is/LC_MESSAGES/python.mo and b/lang/python/is/LC_MESSAGES/python.mo differ diff --git a/lang/python/is/LC_MESSAGES/python.po b/lang/python/is/LC_MESSAGES/python.po index cd098fddb..226a8deb3 100644 --- a/lang/python/is/LC_MESSAGES/python.po +++ b/lang/python/is/LC_MESSAGES/python.po @@ -33,22 +33,22 @@ msgstr "Dummy python step {}" #: src/modules/packages/main.py:59 #, python-format msgid "Processing packages (%(count)d / %(total)d)" -msgstr "" +msgstr "Vinnslupakkar (%(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[0] "Setja upp einn pakka." +msgstr[1] "Setur upp %(num)d pakka." #: src/modules/packages/main.py:64 #, python-format msgid "Removing one package." msgid_plural "Removing %(num)d packages." -msgstr[0] "" -msgstr[1] "" +msgstr[0] "Fjarlægi einn pakka." +msgstr[1] "Fjarlægi %(num)d pakka." #: src/modules/packages/main.py:68 msgid "Install packages." -msgstr "" +msgstr "Setja upp pakka." diff --git a/lang/python/pl/LC_MESSAGES/python.mo b/lang/python/pl/LC_MESSAGES/python.mo index 60aa4f6ac..fca89320a 100644 Binary files a/lang/python/pl/LC_MESSAGES/python.mo and b/lang/python/pl/LC_MESSAGES/python.mo differ 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." diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4ef6afcbb..c29a866d8 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 @@ -27,7 +28,3 @@ add_subdirectory( modules ) # branding components add_subdirectory( branding ) - -if( WITH_CRASHREPORTER ) - add_subdirectory( crashreporter ) -endif() 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/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index cdd31b782..ba10fcc70 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -1,9 +1,11 @@ -project( libcalamares ) +project( libcalamares CXX ) -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,27 +18,28 @@ set( libSources Job.cpp JobQueue.cpp ProcessJob.cpp - - kdsingleapplicationguard/kdsingleapplicationguard.cpp - kdsingleapplicationguard/kdsharedmemorylocker.cpp - kdsingleapplicationguard/kdtoolsglobal.cpp - kdsingleapplicationguard/kdlockedsharedmemorypointer.cpp - +) +set( utilsSources utils/CalamaresUtils.cpp utils/CalamaresUtilsSystem.cpp utils/Logger.cpp utils/PluginFactory.cpp utils/Retranslator.cpp ) +set( kdsagSources + kdsingleapplicationguard/kdsingleapplicationguard.cpp + kdsingleapplicationguard/kdsharedmemorylocker.cpp + kdsingleapplicationguard/kdtoolsglobal.cpp + kdsingleapplicationguard/kdlockedsharedmemorypointer.cpp +) +set_source_files_properties( ${kdsagSources} + PROPERTIES COMPILE_FLAGS "${SUPPRESS_3RDPARTY_WARNINGS}" ) include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} - - ${QT_INCLUDE_DIR} ) - if( WITH_PYTHON ) set( libSources ${libSources} @@ -73,7 +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 diff --git a/src/libcalamares/ProcessJob.h b/src/libcalamares/ProcessJob.h index 1ac7f7f08..43fdf254e 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 c38d398e6..656a57c10 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 @@ -26,6 +27,15 @@ #include #include +#ifdef Q_OS_LINUX +#include +#endif + +#ifdef Q_OS_FREEBSD +#include +#include +#endif + namespace CalamaresUtils { @@ -221,50 +231,29 @@ 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; -} - - -qint64 +QPair 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(); + if (r) + return qMakePair(0, 0.0); - bool ok = false; - qint64 availableRam = memoryLine.toLongLong( &ok ) * 1024; - if ( !ok ) - return 0; + return qMakePair(quint64( i.mem_unit ) * quint64( i.totalram ), 1.1); +#elif defined( Q_OS_FREEBSD ) + unsigned long memsize; + size_t s = sizeof(memsize); - return availableRam; + int r = sysctlbyname("vm.kmem_size", &memsize, &s, NULL, 0); + if (r) + return qMakePair(0, 0.0); + + return qMakePair(memsize, 1.01); +#else + return qMakePair(0, 0.0); // Unsupported +#endif } 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/libcalamares/utils/PluginFactory.cpp b/src/libcalamares/utils/PluginFactory.cpp index ff6c9913f..b1c3a0793 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 @@ -26,7 +27,7 @@ #include #include -Q_GLOBAL_STATIC(QObjectCleanupHandler, factorycleanup) +Q_GLOBAL_STATIC( QObjectCleanupHandler, factorycleanup ) extern int kLibraryDebugArea(); @@ -34,89 +35,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 = nullptr; - 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..55c44249c 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 @@ -300,7 +301,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 +322,7 @@ protected: static QObject* createInstance( QWidget* parentWidget, QObject* parent ) { Q_UNUSED( parentWidget ); - ParentType* p( nullptr ); + ParentType* p = nullptr; if ( parent ) { p = qobject_cast( parent ); diff --git a/src/libcalamaresui/CMakeLists.txt b/src/libcalamaresui/CMakeLists.txt index 0648807b8..0021fbbfd 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 @@ -20,7 +20,7 @@ list( APPEND ${CALAMARESUI_LIBRARY_TARGET}_SOURCES widgets/ClickableLabel.cpp widgets/FixedAspectRatioLabel.cpp - widgets/QtWaitingSpinner.cpp + widgets/waitingspinnerwidget.cpp widgets/WaitingWidget.cpp ExecutionViewStep.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} diff --git a/src/libcalamaresui/modulesystem/CppJobModule.h b/src/libcalamaresui/modulesystem/CppJobModule.h index 92c4224d3..46d27bf8b 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 @@ -25,7 +26,8 @@ class QPluginLoader; -namespace Calamares { +namespace Calamares +{ class UIDLLEXPORT CppJobModule : public Module { diff --git a/src/libcalamaresui/modulesystem/ProcessJobModule.h b/src/libcalamaresui/modulesystem/ProcessJobModule.h index 5bb1699be..af9a46bd5 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 @@ -23,7 +24,8 @@ #include "UiDllMacro.h" -namespace Calamares { +namespace Calamares +{ class UIDLLEXPORT ProcessJobModule : public Module { diff --git a/src/libcalamaresui/modulesystem/ViewModule.h b/src/libcalamaresui/modulesystem/ViewModule.h index bfbbdadf3..6b2e381a2 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 @@ -24,7 +25,8 @@ class QPluginLoader; -namespace Calamares { +namespace Calamares +{ class ViewStep; diff --git a/src/libcalamaresui/utils/ImageRegistry.cpp b/src/libcalamaresui/utils/ImageRegistry.cpp index 9ed646e50..442017048 100644 --- a/src/libcalamaresui/utils/ImageRegistry.cpp +++ b/src/libcalamaresui/utils/ImageRegistry.cpp @@ -1,35 +1,34 @@ -/* === This file is part of Calamares - === +/* === 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 . + * SPDX-License-Identifier: GPLv3+ + * License-Filename: LICENSES/GPLv3+-ImageRegistry */ +/* + * 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 . +*/ + #include "ImageRegistry.h" #include #include -#include - -#include "utils/Logger.h" +#include static QHash< QString, QHash< int, QHash< qint64, QPixmap > > > s_cache; -ImageRegistry* ImageRegistry::s_instance = nullptr; +ImageRegistry* ImageRegistry::s_instance = 0; ImageRegistry* @@ -53,15 +52,21 @@ ImageRegistry::icon( const QString& image, CalamaresUtils::ImageMode 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, CalamaresUtils::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 +88,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 ); @@ -106,7 +110,7 @@ ImageRegistry::pixmap( const QString& image, const QSize& size, CalamaresUtils:: resultImage.setAlphaChannel( p.toImage().alphaChannel() ); p = QPixmap::fromImage( resultImage ); - } + } pixmap = p; } @@ -126,7 +130,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,10 +151,8 @@ 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, CalamaresUtils::ImageMode mode, float opacity, const QPixmap& pixmap, QColor tint ) { -// cDebug( 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..e35eaf74a 100644 --- a/src/libcalamaresui/utils/ImageRegistry.h +++ b/src/libcalamaresui/utils/ImageRegistry.h @@ -1,24 +1,26 @@ -/* === This file is part of Calamares - === +/* === 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 . + * SPDX-License-Identifier: GPLv3+ + * License-Filename: LICENSES/GPLv3+-ImageRegistry */ +/* + * 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 . +*/ + #ifndef IMAGE_REGISTRY_H #define IMAGE_REGISTRY_H @@ -35,11 +37,11 @@ public: 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 ) ); + 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, 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, CalamaresUtils::ImageMode mode, float opacity, const QPixmap& pixmap, QColor tint ); static ImageRegistry* s_instance; }; diff --git a/src/libcalamaresui/utils/qjsonitem.cpp b/src/libcalamaresui/utils/qjsonitem.cpp index 35c9725dd..24494f0fd 100644 --- a/src/libcalamaresui/utils/qjsonitem.cpp +++ b/src/libcalamaresui/utils/qjsonitem.cpp @@ -1,27 +1,31 @@ -/* === This file is part of Calamares - === +/* === 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 . + * 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). + + 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 +108,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 +123,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..5a8b2134f 100644 --- a/src/libcalamaresui/utils/qjsonitem.h +++ b/src/libcalamaresui/utils/qjsonitem.h @@ -1,20 +1,7 @@ -/* === This file is part of Calamares - === +/* === 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 . + * SPDX-License-Identifier: GPL-3.0+ + * License-Filename: LICENSES/GPLv3+-QJsonModel */ #ifndef JSONITEM_H @@ -26,8 +13,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 +28,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..5ce0cd695 100644 --- a/src/libcalamaresui/utils/qjsonmodel.cpp +++ b/src/libcalamaresui/utils/qjsonmodel.cpp @@ -1,22 +1,27 @@ -/* === This file is part of Calamares - === +/* === 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 . + * 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). + + 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 +41,6 @@ QJsonModel::QJsonModel(QObject *parent) : } - -QJsonModel::~QJsonModel() -{ - delete mRootItem; -} - - bool QJsonModel::load(const QString &fileName) { QFile file(fileName); @@ -68,7 +66,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..6a2399287 100644 --- a/src/libcalamaresui/utils/qjsonmodel.h +++ b/src/libcalamaresui/utils/qjsonmodel.h @@ -1,23 +1,9 @@ -/* === This file is part of Calamares - === +/* === 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 . + * SPDX-License-Identifier: GPL-3.0+ + * License-Filename: LICENSES/GPLv3+-QJsonModel */ - #ifndef QJSONMODEL_H #define QJSONMODEL_H @@ -30,8 +16,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); 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/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/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/libcalamaresui/widgets/waitingspinnerwidget.cpp b/src/libcalamaresui/widgets/waitingspinnerwidget.cpp new file mode 100644 index 000000000..317d83807 --- /dev/null +++ b/src/libcalamaresui/widgets/waitingspinnerwidget.cpp @@ -0,0 +1,283 @@ +/* === 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 + +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..0ed8e69d3 --- /dev/null +++ b/src/libcalamaresui/widgets/waitingspinnerwidget.h @@ -0,0 +1,120 @@ +/* === 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 +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; +}; diff --git a/src/modules/displaymanager/main.py b/src/modules/displaymanager/main.py index 99a25ad4a..e16184d93 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 @@ -484,12 +485,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) @@ -504,9 +502,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") 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 2b2a51a75..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 @@ -34,7 +35,7 @@ class PLUGINDLLEXPORT DummyCppJob : public Calamares::CppJob public: explicit DummyCppJob( QObject* parent = nullptr ); - virtual ~DummyCppJob(); + virtual ~DummyCppJob() override; QString prettyName() const override; 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/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/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/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/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/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/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/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/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(); 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/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/users/UsersPage.h b/src/modules/users/UsersPage.h deleted file mode 100644 index 0f328f46c..000000000 --- a/src/modules/users/UsersPage.h +++ /dev/null @@ -1,85 +0,0 @@ -/* === This file is part of Calamares - === - * - * Copyright 2014-2015, Teo Mrnjavac - * Copyright 2017, Adriaan de Groot - * - * Portions from the Manjaro Installation Framework - * by Roland Singer - * Copyright (C) 2007 Free Software Foundation, Inc. - * - * 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 USERSPAGE_H -#define USERSPAGE_H - -#include "Typedefs.h" - -#include - -namespace Ui { -class Page_UserSetup; -} - -class UsersPage : public QWidget -{ - Q_OBJECT -public: - explicit UsersPage( QWidget* parent = nullptr ); - virtual ~UsersPage(); - - bool isReady(); - - QList< Calamares::job_ptr > createJobs( const QStringList& defaultGroupsList ); - - void onActivate(); - - void setWriteRootPassword( bool show ); - void setAutologinDefault( bool checked ); - void setReusePasswordDefault( bool checked ); - -protected slots: - void onFullNameTextEdited( const QString& ); - void fillSuggestions(); - void onUsernameTextEdited( const QString& ); - void validateUsernameText( const QString& ); - void onHostnameTextEdited( const QString& ); - void validateHostnameText( const QString& ); - void onPasswordTextChanged( const QString& ); - void onRootPasswordTextChanged( const QString& ); - -signals: - void checkReady( bool ); - -private: - Ui::Page_UserSetup* ui; - - 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; - const int HOSTNAME_MIN_LENGTH = 2; - const int HOSTNAME_MAX_LENGTH = 63; - - bool m_readyFullName; - bool m_readyUsername; - bool m_customUsername; - bool m_readyHostname; - bool m_customHostname; - bool m_readyPassword; - bool m_readyRootPassword; - - bool m_writeRootPassword; -}; - -#endif // USERSPAGE_H diff --git a/src/modules/users/UsersViewStep.cpp b/src/modules/users/UsersViewStep.cpp index 609e9d8d4..100cfe256 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 @@ -20,6 +21,7 @@ #include "gui/UsersPage.h" +#include "utils/Logger.h" #include "JobQueue.h" #include "GlobalStorage.h" #include "utils/Logger.h" @@ -172,9 +174,26 @@ UsersViewStep::setConfigurationMap( const QVariantMap& configurationMap ) m_widget->setAvailableShells(shells); } +<<<<<<< HEAD if ( configurationMap.contains( "avatarFilePath" ) && configurationMap.value( "avatarFilePath").type() == QVariant::String ) +======= + if ( configurationMap.contains( "doReusePassword" ) && + configurationMap.value( "doReusePassword" ).type() == QVariant::Bool ) +>>>>>>> 34761c4214e95d877f0f1b2f29d479169885d646 { m_widget->setAvatarFilePath( configurationMap.value( "avatarFilePath" ).toString() ); } + + 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/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/users/users.conf b/src/modules/users/users.conf index 009c0183e..ed1043432 100644 --- a/src/modules/users/users.conf +++ b/src/modules/users/users.conf @@ -25,5 +25,24 @@ doAutologin: false # remove the following line to avoid creating /etc/sudoers.d/10-installer sudoersGroup: wheel +<<<<<<< HEAD setRootPassword: false availableShells: /bin/bash, /bin/zsh +======= +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 +>>>>>>> 34761c4214e95d877f0f1b2f29d479169885d646 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 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; diff --git a/src/modules/welcome/checker/RequirementsChecker.cpp b/src/modules/welcome/checker/RequirementsChecker.cpp index ac5f5088b..3d4e394c4 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 } @@ -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();