Merge branch 'refactor-libcalamares'
This commit is contained in:
commit
6d073b6757
9
CHANGES
9
CHANGES
@ -5,6 +5,10 @@ website will have to do for older versions.
|
|||||||
|
|
||||||
# 3.2.8 (unreleased) #
|
# 3.2.8 (unreleased) #
|
||||||
|
|
||||||
|
This is a **source-incompatible** release of Calamares. Include files
|
||||||
|
have been shuffled around, so third-party C++ modules will need
|
||||||
|
adjustment to the changed names.
|
||||||
|
|
||||||
This release contains contributions from (alphabetically by first name):
|
This release contains contributions from (alphabetically by first name):
|
||||||
|
|
||||||
## Core ##
|
## Core ##
|
||||||
@ -12,6 +16,11 @@ This release contains contributions from (alphabetically by first name):
|
|||||||
- *libcalamares* (accidentally) linked with Qt's GUI libraries when
|
- *libcalamares* (accidentally) linked with Qt's GUI libraries when
|
||||||
PythonQt was found. This led to the odd situation where the non-GUI
|
PythonQt was found. This led to the odd situation where the non-GUI
|
||||||
Calamares library depends on a bunch of GUI libraries.
|
Calamares library depends on a bunch of GUI libraries.
|
||||||
|
- *libcalamares* The `utils/` subdirectory has been hugely refactored,
|
||||||
|
with functionality split out into separate files. C++ modules will
|
||||||
|
need to have their `#include` names updated. Basically, users of
|
||||||
|
`utils/CalamaresUtils.h` will need to include the header file for
|
||||||
|
the functionality that is actually used.
|
||||||
|
|
||||||
## Modules ##
|
## Modules ##
|
||||||
|
|
||||||
|
@ -28,7 +28,9 @@
|
|||||||
#include "modulesystem/ModuleManager.h"
|
#include "modulesystem/ModuleManager.h"
|
||||||
#include "utils/CalamaresUtilsGui.h"
|
#include "utils/CalamaresUtilsGui.h"
|
||||||
#include "utils/CalamaresUtilsSystem.h"
|
#include "utils/CalamaresUtilsSystem.h"
|
||||||
|
#include "utils/Dirs.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
#include "utils/Retranslator.h"
|
||||||
#include "JobQueue.h"
|
#include "JobQueue.h"
|
||||||
#include "Branding.h"
|
#include "Branding.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "CalamaresConfig.h"
|
#include "CalamaresConfig.h"
|
||||||
#include "kdsingleapplicationguard/kdsingleapplicationguard.h"
|
#include "kdsingleapplicationguard/kdsingleapplicationguard.h"
|
||||||
#include "utils/CalamaresUtils.h"
|
#include "utils/Dirs.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "CalamaresConfig.h"
|
#include "CalamaresConfig.h"
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/YamlUtils.h"
|
#include "utils/Yaml.h"
|
||||||
#include "modulesystem/Module.h"
|
#include "modulesystem/Module.h"
|
||||||
|
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
|
@ -20,14 +20,16 @@ set( libSources
|
|||||||
Settings.cpp
|
Settings.cpp
|
||||||
)
|
)
|
||||||
set( utilsSources
|
set( utilsSources
|
||||||
utils/CalamaresUtils.cpp
|
|
||||||
utils/CalamaresUtilsSystem.cpp
|
utils/CalamaresUtilsSystem.cpp
|
||||||
utils/CommandList.cpp
|
utils/CommandList.cpp
|
||||||
|
utils/Dirs.cpp
|
||||||
utils/LocaleLabel.cpp
|
utils/LocaleLabel.cpp
|
||||||
utils/Logger.cpp
|
utils/Logger.cpp
|
||||||
utils/PluginFactory.cpp
|
utils/PluginFactory.cpp
|
||||||
utils/Retranslator.cpp
|
utils/Retranslator.cpp
|
||||||
utils/YamlUtils.cpp
|
utils/String.cpp
|
||||||
|
utils/Variant.cpp
|
||||||
|
utils/Yaml.cpp
|
||||||
)
|
)
|
||||||
set( kdsagSources
|
set( kdsagSources
|
||||||
kdsingleapplicationguard/kdsingleapplicationguard.cpp
|
kdsingleapplicationguard/kdsingleapplicationguard.cpp
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include "JobQueue.h"
|
#include "JobQueue.h"
|
||||||
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/YamlUtils.h"
|
#include "utils/Yaml.h"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include "PythonHelper.h"
|
#include "PythonHelper.h"
|
||||||
|
|
||||||
#include "utils/CalamaresUtils.h"
|
#include "utils/Dirs.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include "PythonHelper.h"
|
#include "PythonHelper.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/CalamaresUtilsSystem.h"
|
#include "utils/CalamaresUtilsSystem.h"
|
||||||
#include "utils/CalamaresUtils.h"
|
#include "utils/String.h"
|
||||||
|
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
#include "JobQueue.h"
|
#include "JobQueue.h"
|
||||||
|
@ -21,9 +21,10 @@
|
|||||||
|
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
|
||||||
#include "utils/CalamaresUtils.h"
|
// #include "utils/CalamaresUtils.h"
|
||||||
|
#include "utils/Dirs.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/YamlUtils.h"
|
#include "utils/Yaml.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
@ -275,7 +276,7 @@ Settings::disableCancel() const
|
|||||||
{
|
{
|
||||||
return m_disableCancel;
|
return m_disableCancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Settings::dontCancel() const
|
Settings::dontCancel() const
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include "Tests.h"
|
#include "Tests.h"
|
||||||
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/YamlUtils.h"
|
#include "utils/Yaml.h"
|
||||||
|
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
|
|
||||||
|
@ -1,464 +0,0 @@
|
|||||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
|
||||||
*
|
|
||||||
* Copyright 2013-2016, Teo Mrnjavac <teo@kde.org>
|
|
||||||
* Copyright 2018, Adriaan de Groot <groot@kde.org>
|
|
||||||
*
|
|
||||||
* Originally from Tomahawk, portions:
|
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
|
||||||
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
|
||||||
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
|
|
||||||
*
|
|
||||||
* Calamares is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Calamares is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "CalamaresUtils.h"
|
|
||||||
|
|
||||||
#include "CalamaresConfig.h"
|
|
||||||
#include "Logger.h"
|
|
||||||
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QLocale>
|
|
||||||
#include <QStandardPaths>
|
|
||||||
#include <QTranslator>
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
using std::cerr;
|
|
||||||
|
|
||||||
namespace CalamaresUtils
|
|
||||||
{
|
|
||||||
|
|
||||||
static QDir s_appDataDir( CMAKE_INSTALL_FULL_DATADIR );
|
|
||||||
static QDir s_qmlModulesDir( QString( CMAKE_INSTALL_FULL_DATADIR ) + "/qml" );
|
|
||||||
static bool s_isAppDataDirOverridden = false;
|
|
||||||
|
|
||||||
static QTranslator* s_brandingTranslator = nullptr;
|
|
||||||
static QTranslator* s_translator = nullptr;
|
|
||||||
static QString s_translatorLocaleName;
|
|
||||||
|
|
||||||
static bool s_haveExtraDirs = false;
|
|
||||||
static QStringList s_extraConfigDirs;
|
|
||||||
static QStringList s_extraDataDirs;
|
|
||||||
|
|
||||||
static bool
|
|
||||||
isWritableDir( const QDir& dir )
|
|
||||||
{
|
|
||||||
// We log with cerr here because we might be looking for the log dir
|
|
||||||
QString path = dir.absolutePath();
|
|
||||||
if ( !dir.exists() )
|
|
||||||
{
|
|
||||||
if ( !dir.mkpath( "." ) )
|
|
||||||
{
|
|
||||||
cerr << "warning: failed to create " << qPrintable( path ) << '\n';
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
QFileInfo info( path );
|
|
||||||
if ( !info.isDir() )
|
|
||||||
{
|
|
||||||
cerr << "warning: " << qPrintable( path ) << " is not a dir\n";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if ( !info.isWritable() )
|
|
||||||
{
|
|
||||||
cerr << "warning: " << qPrintable( path ) << " is not writable\n";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QDir
|
|
||||||
qmlModulesDir()
|
|
||||||
{
|
|
||||||
return s_qmlModulesDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
setAppDataDir( const QDir& dir )
|
|
||||||
{
|
|
||||||
s_appDataDir = dir;
|
|
||||||
s_isAppDataDirOverridden = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Split $ENV{@p name} on :, append to @p l, making sure each ends in / */
|
|
||||||
static void
|
|
||||||
mungeEnvironment( QStringList& l, const char* name, const char* defaultDirs )
|
|
||||||
{
|
|
||||||
static const QString calamaresSubdir = QStringLiteral( "calamares/" );
|
|
||||||
|
|
||||||
QStringList dirs = QString( qgetenv( name ) ).split( ':' );
|
|
||||||
if ( dirs.isEmpty() )
|
|
||||||
dirs = QString( defaultDirs ).split( ':' );
|
|
||||||
|
|
||||||
for ( auto s : dirs )
|
|
||||||
{
|
|
||||||
if ( s.isEmpty() )
|
|
||||||
continue;
|
|
||||||
if ( s.endsWith( '/' ) )
|
|
||||||
l << ( s + calamaresSubdir ) << s;
|
|
||||||
else
|
|
||||||
l << ( s + '/' + calamaresSubdir ) << ( s + '/' );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
setXdgDirs()
|
|
||||||
{
|
|
||||||
mungeEnvironment( s_extraConfigDirs, "XDG_CONFIG_DIRS", "/etc/xdg" );
|
|
||||||
mungeEnvironment( s_extraDataDirs, "XDG_DATA_DIRS", "/usr/local/share/:/usr/share/" );
|
|
||||||
|
|
||||||
s_haveExtraDirs = !( s_extraConfigDirs.isEmpty() && s_extraDataDirs.isEmpty() );
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList
|
|
||||||
extraConfigDirs()
|
|
||||||
{
|
|
||||||
if ( s_haveExtraDirs )
|
|
||||||
return s_extraConfigDirs;
|
|
||||||
return QStringList();
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList
|
|
||||||
extraDataDirs()
|
|
||||||
{
|
|
||||||
if ( s_haveExtraDirs )
|
|
||||||
return s_extraDataDirs;
|
|
||||||
return QStringList();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
haveExtraDirs()
|
|
||||||
{
|
|
||||||
return s_haveExtraDirs && ( !s_extraConfigDirs.isEmpty() || !s_extraDataDirs.isEmpty() );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
isAppDataDirOverridden()
|
|
||||||
{
|
|
||||||
return s_isAppDataDirOverridden;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QDir
|
|
||||||
appDataDir()
|
|
||||||
{
|
|
||||||
return s_appDataDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QDir
|
|
||||||
systemLibDir()
|
|
||||||
{
|
|
||||||
QDir path( CMAKE_INSTALL_FULL_LIBDIR );
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QDir
|
|
||||||
appLogDir()
|
|
||||||
{
|
|
||||||
QString path = QStandardPaths::writableLocation( QStandardPaths::CacheLocation );
|
|
||||||
QDir dir( path );
|
|
||||||
if ( isWritableDir( dir ) )
|
|
||||||
return dir;
|
|
||||||
|
|
||||||
cerr << "warning: Could not find a standard writable location for log dir, falling back to $HOME\n";
|
|
||||||
dir = QDir::home();
|
|
||||||
if ( isWritableDir( dir ) )
|
|
||||||
return dir;
|
|
||||||
|
|
||||||
cerr << "warning: Found no writable location for log dir, falling back to the temp dir\n";
|
|
||||||
return QDir::temp();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
installTranslator( const QLocale& locale,
|
|
||||||
const QString& brandingTranslationsPrefix,
|
|
||||||
QObject* parent )
|
|
||||||
{
|
|
||||||
QString localeName = locale.name();
|
|
||||||
localeName.replace( "-", "_" );
|
|
||||||
|
|
||||||
if ( localeName == "C" )
|
|
||||||
localeName = "en";
|
|
||||||
|
|
||||||
// Special case of sr@latin
|
|
||||||
//
|
|
||||||
// See top-level CMakeLists.txt about special cases for translation loading.
|
|
||||||
if ( locale.language() == QLocale::Language::Serbian && locale.script() == QLocale::Script::LatinScript )
|
|
||||||
localeName = QStringLiteral( "sr@latin" );
|
|
||||||
|
|
||||||
cDebug() << "Looking for translations for" << localeName;
|
|
||||||
|
|
||||||
QTranslator* translator = nullptr;
|
|
||||||
|
|
||||||
// Branding translations
|
|
||||||
if ( !brandingTranslationsPrefix.isEmpty() )
|
|
||||||
{
|
|
||||||
QString brandingTranslationsDirPath( brandingTranslationsPrefix );
|
|
||||||
brandingTranslationsDirPath.truncate( brandingTranslationsPrefix.lastIndexOf(
|
|
||||||
QDir::separator() ) );
|
|
||||||
QDir brandingTranslationsDir( brandingTranslationsDirPath );
|
|
||||||
if ( brandingTranslationsDir.exists() )
|
|
||||||
{
|
|
||||||
QString filenameBase( brandingTranslationsPrefix );
|
|
||||||
filenameBase.remove( 0, brandingTranslationsPrefix.lastIndexOf(
|
|
||||||
QDir::separator() ) + 1 );
|
|
||||||
translator = new QTranslator( parent );
|
|
||||||
if ( translator->load( locale,
|
|
||||||
filenameBase,
|
|
||||||
"_",
|
|
||||||
brandingTranslationsDir.absolutePath() ) )
|
|
||||||
{
|
|
||||||
cDebug() << Logger::SubEntry << "Branding using locale:" << localeName;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cDebug() << Logger::SubEntry << "Branding using default, system locale not found:" << localeName;
|
|
||||||
translator->load( brandingTranslationsPrefix + "en" );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( s_brandingTranslator )
|
|
||||||
{
|
|
||||||
QCoreApplication::removeTranslator( s_brandingTranslator );
|
|
||||||
delete s_brandingTranslator;
|
|
||||||
}
|
|
||||||
|
|
||||||
QCoreApplication::installTranslator( translator );
|
|
||||||
s_brandingTranslator = translator;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calamares translations
|
|
||||||
translator = new QTranslator( parent );
|
|
||||||
if ( translator->load( QString( ":/lang/calamares_" ) + localeName ) )
|
|
||||||
{
|
|
||||||
cDebug() << Logger::SubEntry << "Calamares using locale:" << localeName;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cDebug() << Logger::SubEntry << "Calamares using default, system locale not found:" << localeName;
|
|
||||||
translator->load( QString( ":/lang/calamares_en" ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( s_translator )
|
|
||||||
{
|
|
||||||
QCoreApplication::removeTranslator( s_translator );
|
|
||||||
delete s_translator;
|
|
||||||
}
|
|
||||||
|
|
||||||
QCoreApplication::installTranslator( translator );
|
|
||||||
s_translator = translator;
|
|
||||||
|
|
||||||
s_translatorLocaleName = localeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString
|
|
||||||
translatorLocaleName()
|
|
||||||
{
|
|
||||||
return s_translatorLocaleName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
setQmlModulesDir( const QDir& dir )
|
|
||||||
{
|
|
||||||
s_qmlModulesDir = dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString
|
|
||||||
removeDiacritics( const QString& string )
|
|
||||||
{
|
|
||||||
const QString diacriticLetters = QString::fromUtf8(
|
|
||||||
"ŠŒŽšœžŸ¥µÀ"
|
|
||||||
"ÁÂÃÄÅÆÇÈÉÊ"
|
|
||||||
"ËÌÍÎÏÐÑÒÓÔ"
|
|
||||||
"ÕÖØÙÚÛÜÝßà"
|
|
||||||
"áâãäåæçèéê"
|
|
||||||
"ëìíîïðñòóô"
|
|
||||||
"õöøùúûüýÿÞ"
|
|
||||||
"þČčĆćĐ𩹮"
|
|
||||||
"žŞşĞğİıȚțȘ"
|
|
||||||
"șĂăŐőŰűŘřĀ"
|
|
||||||
"āĒēĪīŌōŪūŢ"
|
|
||||||
"ţẀẁẂẃŴŵŶŷĎ"
|
|
||||||
"ďĚěŇňŤťŮůŔ"
|
|
||||||
"ॹĘꣳŃńŚ"
|
|
||||||
"śŹźŻż"
|
|
||||||
);
|
|
||||||
const QStringList noDiacriticLetters = {
|
|
||||||
"S", "OE", "Z", "s", "oe", "z", "Y", "Y", "u", "A",
|
|
||||||
"A", "A", "A", "A", "AA", "AE", "C", "E", "E", "E",
|
|
||||||
"E", "I", "I", "I", "I", "D", "N", "O", "O", "O",
|
|
||||||
"O", "E", "OE", "U", "U", "U", "E", "Y", "s", "a",
|
|
||||||
"a", "a", "a", "e", "aa", "ae", "c", "e", "e", "e",
|
|
||||||
"e", "i", "i", "i", "i", "d", "n", "o", "o", "o",
|
|
||||||
"o", "e", "oe", "u", "u", "u", "e", "y", "y", "TH",
|
|
||||||
"th", "C", "c", "C", "c", "DJ", "dj", "S", "s", "Z",
|
|
||||||
"z", "S", "s", "G", "g", "I", "i", "T", "t", "S",
|
|
||||||
"s", "A", "a", "O", "o", "U", "u", "R", "r", "A",
|
|
||||||
"a", "E", "e", "I", "i", "O", "o", "U", "u", "T",
|
|
||||||
"t", "W", "w", "W", "w", "W", "w", "Y", "y", "D",
|
|
||||||
"d", "E", "e", "N", "n", "T", "t", "U", "u", "R",
|
|
||||||
"r", "A", "a", "E", "e", "L", "l", "N", "n", "S",
|
|
||||||
"s", "Z", "z", "Z", "z"
|
|
||||||
};
|
|
||||||
|
|
||||||
QString output;
|
|
||||||
for ( const QChar &c : string )
|
|
||||||
{
|
|
||||||
int i = diacriticLetters.indexOf( c );
|
|
||||||
if ( i < 0 )
|
|
||||||
{
|
|
||||||
output.append( c );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QString replacement = noDiacriticLetters[ i ];
|
|
||||||
output.append( replacement );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Function CalamaresUtils::obscure based on KStringHandler::obscure,
|
|
||||||
// part of KDElibs by KDE, file kstringhandler.cpp.
|
|
||||||
// Original copyright statement follows.
|
|
||||||
/* This file is part of the KDE libraries
|
|
||||||
Copyright (C) 1999 Ian Zepp (icszepp@islc.net)
|
|
||||||
Copyright (C) 2006 by Dominic Battre <dominic@battre.de>
|
|
||||||
Copyright (C) 2006 by Martin Pool <mbp@canonical.com>
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library 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
|
|
||||||
Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with this library; see the file COPYING.LIB. If not, write to
|
|
||||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
QString
|
|
||||||
obscure( const QString& string )
|
|
||||||
{
|
|
||||||
QString result;
|
|
||||||
const QChar *unicode = string.unicode();
|
|
||||||
for ( int i = 0; i < string.length(); ++i )
|
|
||||||
// yes, no typo. can't encode ' ' or '!' because
|
|
||||||
// they're the unicode BOM. stupid scrambling. stupid.
|
|
||||||
result += ( unicode[ i ].unicode() <= 0x21 ) ?
|
|
||||||
unicode[ i ] :
|
|
||||||
QChar( 0x1001F - unicode[ i ].unicode() );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
crash()
|
|
||||||
{
|
|
||||||
volatile int* a = nullptr;
|
|
||||||
*a = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
getBool( const QVariantMap& map, const QString& key, bool d )
|
|
||||||
{
|
|
||||||
bool result = d;
|
|
||||||
if ( map.contains( key ) )
|
|
||||||
{
|
|
||||||
auto v = map.value( key );
|
|
||||||
if ( v.type() == QVariant::Bool )
|
|
||||||
result = v.toBool();
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString
|
|
||||||
getString(const QVariantMap& map, const QString& key)
|
|
||||||
{
|
|
||||||
if ( map.contains( key ) )
|
|
||||||
{
|
|
||||||
auto v = map.value( key );
|
|
||||||
if ( v.type() == QVariant::String )
|
|
||||||
return v.toString();
|
|
||||||
}
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
getInteger( const QVariantMap& map, const QString& key, int d )
|
|
||||||
{
|
|
||||||
int result = d;
|
|
||||||
if ( map.contains( key ) )
|
|
||||||
{
|
|
||||||
auto v = map.value( key );
|
|
||||||
if ( v.type() == QVariant::Int )
|
|
||||||
result = v.toInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
double
|
|
||||||
getDouble( const QVariantMap& map, const QString& key, double d )
|
|
||||||
{
|
|
||||||
double result = d;
|
|
||||||
if ( map.contains( key ) )
|
|
||||||
{
|
|
||||||
auto v = map.value( key );
|
|
||||||
if ( v.type() == QVariant::Int )
|
|
||||||
result = v.toInt();
|
|
||||||
else if ( v.type() == QVariant::Double )
|
|
||||||
result = v.toDouble();
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariantMap
|
|
||||||
getSubMap( const QVariantMap& map, const QString& key, bool& success )
|
|
||||||
{
|
|
||||||
success = false;
|
|
||||||
|
|
||||||
if ( map.contains( key ) )
|
|
||||||
{
|
|
||||||
auto v = map.value( key );
|
|
||||||
if ( v.type() == QVariant::Map )
|
|
||||||
{
|
|
||||||
success = true;
|
|
||||||
return v.toMap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return QVariantMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,144 +0,0 @@
|
|||||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
|
||||||
*
|
|
||||||
* Copyright 2013-2016, Teo Mrnjavac <teo@kde.org>
|
|
||||||
* Copyright 2018, Adriaan de Groot <groot@kde.org>
|
|
||||||
*
|
|
||||||
* Originally from Tomahawk, portions:
|
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
|
||||||
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
|
||||||
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
|
|
||||||
*
|
|
||||||
* Calamares is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Calamares is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef CALAMARESUTILS_H
|
|
||||||
#define CALAMARESUTILS_H
|
|
||||||
|
|
||||||
#include "DllMacro.h"
|
|
||||||
|
|
||||||
#include <QLocale>
|
|
||||||
|
|
||||||
#define RESPATH ":/data/"
|
|
||||||
|
|
||||||
class QDir;
|
|
||||||
class QObject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The CalamaresUtils namespace contains utility functions.
|
|
||||||
*/
|
|
||||||
namespace CalamaresUtils
|
|
||||||
{
|
|
||||||
DLLEXPORT QDir qmlModulesDir();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief appDataDir returns the directory with common application data.
|
|
||||||
* Defaults to CMAKE_INSTALL_FULL_DATADIR (usually /usr/share/calamares).
|
|
||||||
*/
|
|
||||||
DLLEXPORT QDir appDataDir();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief appLogDir returns the directory for Calamares logs.
|
|
||||||
* Defaults to QStandardPaths::CacheLocation (usually ~/.cache/Calamares).
|
|
||||||
*/
|
|
||||||
DLLEXPORT QDir appLogDir();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief systemLibDir returns the system's lib directory.
|
|
||||||
* Defaults to CMAKE_INSTALL_FULL_LIBDIR (usually /usr/lib64 or /usr/lib).
|
|
||||||
*/
|
|
||||||
DLLEXPORT QDir systemLibDir();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief installTranslator changes the application language.
|
|
||||||
* @param locale the new locale.
|
|
||||||
* @param brandingTranslationsPrefix the branding path prefix, from Calamares::Branding.
|
|
||||||
* @param parent the parent QObject.
|
|
||||||
*/
|
|
||||||
DLLEXPORT void installTranslator( const QLocale& locale,
|
|
||||||
const QString& brandingTranslationsPrefix,
|
|
||||||
QObject* parent );
|
|
||||||
|
|
||||||
DLLEXPORT QString translatorLocaleName();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Override app data dir. Only for testing purposes.
|
|
||||||
*/
|
|
||||||
DLLEXPORT void setAppDataDir( const QDir& dir );
|
|
||||||
DLLEXPORT bool isAppDataDirOverridden();
|
|
||||||
|
|
||||||
DLLEXPORT void setQmlModulesDir( const QDir& dir );
|
|
||||||
|
|
||||||
/** @brief Setup extra config and data dirs from the XDG variables.
|
|
||||||
*/
|
|
||||||
DLLEXPORT void setXdgDirs();
|
|
||||||
/** @brief Are any extra directories configured? */
|
|
||||||
DLLEXPORT bool haveExtraDirs();
|
|
||||||
/** @brief XDG_CONFIG_DIRS, each guaranteed to end with / */
|
|
||||||
DLLEXPORT QStringList extraConfigDirs();
|
|
||||||
/** @brief XDG_DATA_DIRS, each guaranteed to end with / */
|
|
||||||
DLLEXPORT QStringList extraDataDirs();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief removeDiacritics replaces letters with diacritics and ligatures with
|
|
||||||
* alternative forms and digraphs.
|
|
||||||
* @param string the string to transform.
|
|
||||||
* @return the output string with plain characters.
|
|
||||||
*/
|
|
||||||
DLLEXPORT QString removeDiacritics( const QString& string );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief obscure is a bidirectional obfuscation function, from KStringHandler.
|
|
||||||
* @param string the input string.
|
|
||||||
* @return the obfuscated string.
|
|
||||||
*/
|
|
||||||
DLLEXPORT QString obscure( const QString& string );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief crash makes Calamares crash immediately.
|
|
||||||
*/
|
|
||||||
DLLEXPORT void crash();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a bool value from a mapping with a given key; returns the default
|
|
||||||
* if no value is stored in the map.
|
|
||||||
*/
|
|
||||||
DLLEXPORT bool getBool( const QVariantMap& map, const QString& key, bool d );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a string value from a mapping; returns empty QString if no value.
|
|
||||||
*/
|
|
||||||
DLLEXPORT QString getString( const QVariantMap& map, const QString& key );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get an integer value from a mapping; returns @p d if no value.
|
|
||||||
*/
|
|
||||||
DLLEXPORT int getInteger( const QVariantMap& map, const QString& key, int d );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a double value from a mapping (integers are converted); returns @p d if no value.
|
|
||||||
*/
|
|
||||||
DLLEXPORT double getDouble( const QVariantMap& map, const QString& key, double d );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a sub-map (i.e. a nested map) from the given mapping with the
|
|
||||||
* given key. @p success is set to true if the @p key exists
|
|
||||||
* in @p map and converts to a map, false otherwise.
|
|
||||||
*
|
|
||||||
* Returns an empty map if there is no such key or it is not a map-value.
|
|
||||||
* (e.g. if @p success is false).
|
|
||||||
*/
|
|
||||||
DLLEXPORT QVariantMap getSubMap( const QVariantMap& map, const QString& key, bool& success );
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // CALAMARESUTILS_H
|
|
@ -16,8 +16,8 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef CALAMARESUTILSSYSTEM_H
|
#ifndef UTILS_CALAMARESUTILSSYSTEM_H
|
||||||
#define CALAMARESUTILSSYSTEM_H
|
#define UTILS_CALAMARESUTILSSYSTEM_H
|
||||||
|
|
||||||
#include "DllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
@ -235,6 +235,6 @@ private:
|
|||||||
bool m_doChroot;
|
bool m_doChroot;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
#endif // CALAMARESUTILSSYSTEM_H
|
#endif
|
||||||
|
@ -21,9 +21,10 @@
|
|||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
#include "JobQueue.h"
|
#include "JobQueue.h"
|
||||||
|
|
||||||
#include "utils/CalamaresUtils.h"
|
// #include "utils/CalamaresUtils.h"
|
||||||
#include "utils/CalamaresUtilsSystem.h"
|
#include "utils/CalamaresUtilsSystem.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
#include "utils/Variant.h"
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QVariantList>
|
#include <QVariantList>
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef COMMANDLIST_H
|
#ifndef UTILS_COMMANDLIST_H
|
||||||
#define COMMANDLIST_H
|
#define UTILS_COMMANDLIST_H
|
||||||
|
|
||||||
#include "Job.h"
|
#include "Job.h"
|
||||||
|
|
||||||
@ -110,4 +110,4 @@ private:
|
|||||||
} ;
|
} ;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
#endif // COMMANDLIST_H
|
#endif
|
||||||
|
194
src/libcalamares/utils/Dirs.cpp
Normal file
194
src/libcalamares/utils/Dirs.cpp
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
|
*
|
||||||
|
* Copyright 2013-2016, Teo Mrnjavac <teo@kde.org>
|
||||||
|
* Copyright 2018, Adriaan de Groot <groot@kde.org>
|
||||||
|
*
|
||||||
|
* Originally from Tomahawk, portions:
|
||||||
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
|
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||||
|
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
|
||||||
|
*
|
||||||
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Calamares is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Dirs.h"
|
||||||
|
|
||||||
|
#include "CalamaresConfig.h"
|
||||||
|
#include "Logger.h"
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QLocale>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
#include <QTranslator>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using std::cerr;
|
||||||
|
|
||||||
|
namespace CalamaresUtils
|
||||||
|
{
|
||||||
|
|
||||||
|
static QDir s_appDataDir( CMAKE_INSTALL_FULL_DATADIR );
|
||||||
|
static QDir s_qmlModulesDir( QString( CMAKE_INSTALL_FULL_DATADIR ) + "/qml" );
|
||||||
|
static bool s_isAppDataDirOverridden = false;
|
||||||
|
|
||||||
|
static bool s_haveExtraDirs = false;
|
||||||
|
static QStringList s_extraConfigDirs;
|
||||||
|
static QStringList s_extraDataDirs;
|
||||||
|
|
||||||
|
static bool
|
||||||
|
isWritableDir( const QDir& dir )
|
||||||
|
{
|
||||||
|
// We log with cerr here because we might be looking for the log dir
|
||||||
|
QString path = dir.absolutePath();
|
||||||
|
if ( !dir.exists() )
|
||||||
|
{
|
||||||
|
if ( !dir.mkpath( "." ) )
|
||||||
|
{
|
||||||
|
cerr << "warning: failed to create " << qPrintable( path ) << '\n';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFileInfo info( path );
|
||||||
|
if ( !info.isDir() )
|
||||||
|
{
|
||||||
|
cerr << "warning: " << qPrintable( path ) << " is not a dir\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ( !info.isWritable() )
|
||||||
|
{
|
||||||
|
cerr << "warning: " << qPrintable( path ) << " is not writable\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QDir
|
||||||
|
qmlModulesDir()
|
||||||
|
{
|
||||||
|
return s_qmlModulesDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
setAppDataDir( const QDir& dir )
|
||||||
|
{
|
||||||
|
s_appDataDir = dir;
|
||||||
|
s_isAppDataDirOverridden = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Split $ENV{@p name} on :, append to @p l, making sure each ends in / */
|
||||||
|
static void
|
||||||
|
mungeEnvironment( QStringList& l, const char* name, const char* defaultDirs )
|
||||||
|
{
|
||||||
|
static const QString calamaresSubdir = QStringLiteral( "calamares/" );
|
||||||
|
|
||||||
|
QStringList dirs = QString( qgetenv( name ) ).split( ':' );
|
||||||
|
if ( dirs.isEmpty() )
|
||||||
|
dirs = QString( defaultDirs ).split( ':' );
|
||||||
|
|
||||||
|
for ( auto s : dirs )
|
||||||
|
{
|
||||||
|
if ( s.isEmpty() )
|
||||||
|
continue;
|
||||||
|
if ( s.endsWith( '/' ) )
|
||||||
|
l << ( s + calamaresSubdir ) << s;
|
||||||
|
else
|
||||||
|
l << ( s + '/' + calamaresSubdir ) << ( s + '/' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
setXdgDirs()
|
||||||
|
{
|
||||||
|
mungeEnvironment( s_extraConfigDirs, "XDG_CONFIG_DIRS", "/etc/xdg" );
|
||||||
|
mungeEnvironment( s_extraDataDirs, "XDG_DATA_DIRS", "/usr/local/share/:/usr/share/" );
|
||||||
|
|
||||||
|
s_haveExtraDirs = !( s_extraConfigDirs.isEmpty() && s_extraDataDirs.isEmpty() );
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList
|
||||||
|
extraConfigDirs()
|
||||||
|
{
|
||||||
|
if ( s_haveExtraDirs )
|
||||||
|
return s_extraConfigDirs;
|
||||||
|
return QStringList();
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList
|
||||||
|
extraDataDirs()
|
||||||
|
{
|
||||||
|
if ( s_haveExtraDirs )
|
||||||
|
return s_extraDataDirs;
|
||||||
|
return QStringList();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
haveExtraDirs()
|
||||||
|
{
|
||||||
|
return s_haveExtraDirs && ( !s_extraConfigDirs.isEmpty() || !s_extraDataDirs.isEmpty() );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
isAppDataDirOverridden()
|
||||||
|
{
|
||||||
|
return s_isAppDataDirOverridden;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QDir
|
||||||
|
appDataDir()
|
||||||
|
{
|
||||||
|
return s_appDataDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QDir
|
||||||
|
systemLibDir()
|
||||||
|
{
|
||||||
|
QDir path( CMAKE_INSTALL_FULL_LIBDIR );
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QDir
|
||||||
|
appLogDir()
|
||||||
|
{
|
||||||
|
QString path = QStandardPaths::writableLocation( QStandardPaths::CacheLocation );
|
||||||
|
QDir dir( path );
|
||||||
|
if ( isWritableDir( dir ) )
|
||||||
|
return dir;
|
||||||
|
|
||||||
|
cerr << "warning: Could not find a standard writable location for log dir, falling back to $HOME\n";
|
||||||
|
dir = QDir::home();
|
||||||
|
if ( isWritableDir( dir ) )
|
||||||
|
return dir;
|
||||||
|
|
||||||
|
cerr << "warning: Found no writable location for log dir, falling back to the temp dir\n";
|
||||||
|
return QDir::temp();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
setQmlModulesDir( const QDir& dir )
|
||||||
|
{
|
||||||
|
s_qmlModulesDir = dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
73
src/libcalamares/utils/Dirs.h
Normal file
73
src/libcalamares/utils/Dirs.h
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
|
*
|
||||||
|
* Copyright 2013-2016, Teo Mrnjavac <teo@kde.org>
|
||||||
|
* Copyright 2018, Adriaan de Groot <groot@kde.org>
|
||||||
|
*
|
||||||
|
* Originally from Tomahawk, portions:
|
||||||
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
|
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||||
|
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
|
||||||
|
*
|
||||||
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Calamares is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef UTILS_DIRS_H
|
||||||
|
#define UTILS_DIRS_H
|
||||||
|
|
||||||
|
#include "DllMacro.h"
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
namespace CalamaresUtils
|
||||||
|
{
|
||||||
|
DLLEXPORT QDir qmlModulesDir();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief appDataDir returns the directory with common application data.
|
||||||
|
* Defaults to CMAKE_INSTALL_FULL_DATADIR (usually /usr/share/calamares).
|
||||||
|
*/
|
||||||
|
DLLEXPORT QDir appDataDir();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief appLogDir returns the directory for Calamares logs.
|
||||||
|
* Defaults to QStandardPaths::CacheLocation (usually ~/.cache/Calamares).
|
||||||
|
*/
|
||||||
|
DLLEXPORT QDir appLogDir();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief systemLibDir returns the system's lib directory.
|
||||||
|
* Defaults to CMAKE_INSTALL_FULL_LIBDIR (usually /usr/lib64 or /usr/lib).
|
||||||
|
*/
|
||||||
|
DLLEXPORT QDir systemLibDir();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override app data dir. Only for testing purposes.
|
||||||
|
*/
|
||||||
|
DLLEXPORT void setAppDataDir( const QDir& dir );
|
||||||
|
DLLEXPORT bool isAppDataDirOverridden();
|
||||||
|
|
||||||
|
DLLEXPORT void setQmlModulesDir( const QDir& dir );
|
||||||
|
|
||||||
|
/** @brief Setup extra config and data dirs from the XDG variables.
|
||||||
|
*/
|
||||||
|
DLLEXPORT void setXdgDirs();
|
||||||
|
/** @brief Are any extra directories configured? */
|
||||||
|
DLLEXPORT bool haveExtraDirs();
|
||||||
|
/** @brief XDG_CONFIG_DIRS, each guaranteed to end with / */
|
||||||
|
DLLEXPORT QStringList extraConfigDirs();
|
||||||
|
/** @brief XDG_DATA_DIRS, each guaranteed to end with / */
|
||||||
|
DLLEXPORT QStringList extraDataDirs();
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif
|
@ -17,8 +17,8 @@
|
|||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LIBCALAMARES_LOCALELABEL_H
|
#ifndef UTILS_LOCALELABEL_H
|
||||||
#define LIBCALAMARES_LOCALELABEL_H
|
#define UTILS_LOCALELABEL_H
|
||||||
|
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@ -41,7 +41,7 @@ public:
|
|||||||
|
|
||||||
/** @brief Empty locale. This uses the system-default locale. */
|
/** @brief Empty locale. This uses the system-default locale. */
|
||||||
LocaleLabel();
|
LocaleLabel();
|
||||||
|
|
||||||
/** @brief Construct from a locale name.
|
/** @brief Construct from a locale name.
|
||||||
*
|
*
|
||||||
* The @p localeName should be one that Qt recognizes, e.g. en_US or ar_EY.
|
* The @p localeName should be one that Qt recognizes, e.g. en_US or ar_EY.
|
||||||
@ -100,7 +100,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setLabels( const QString& name, LabelFormat format );
|
void setLabels( const QString& name, LabelFormat format );
|
||||||
|
|
||||||
QLocale m_locale;
|
QLocale m_locale;
|
||||||
QString m_localeId; // the locale identifier, e.g. "en_GB"
|
QString m_localeId; // the locale identifier, e.g. "en_GB"
|
||||||
QString m_label; // the native name of the locale
|
QString m_label; // the native name of the locale
|
||||||
@ -108,6 +108,6 @@ protected:
|
|||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
} // namespace CalamaresUtils
|
} // namespace
|
||||||
|
|
||||||
#endif // LIBCALAMARES_LOCALELABEL_H
|
#endif
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
#include "utils/CalamaresUtils.h"
|
#include "utils/Dirs.h"
|
||||||
#include "CalamaresVersion.h"
|
#include "CalamaresVersion.h"
|
||||||
|
|
||||||
#define LOGFILE_SIZE 1024 * 256
|
#define LOGFILE_SIZE 1024 * 256
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CALAMARES_LOGGER_H
|
#ifndef UTILS_LOGGER_H
|
||||||
#define CALAMARES_LOGGER_H
|
#define UTILS_LOGGER_H
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
@ -186,10 +186,10 @@ namespace Logger
|
|||||||
s << Continuation << it.key().toUtf8().constData() << ':' << ' ' << toString( it.value() ).toUtf8().constData();
|
s << Continuation << it.key().toUtf8().constData() << ':' << ' ' << toString( it.value() ).toUtf8().constData();
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
#define cDebug Logger::CDebug
|
#define cDebug Logger::CDebug
|
||||||
#define cWarning() Logger::CDebug(Logger::LOGWARNING)
|
#define cWarning() Logger::CDebug(Logger::LOGWARNING)
|
||||||
#define cError() Logger::CDebug(Logger::LOGERROR)
|
#define cError() Logger::CDebug(Logger::LOGERROR)
|
||||||
|
|
||||||
#endif // CALAMARES_LOGGER_H
|
#endif
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
* in printing integer (underlying) values of an enum.
|
* in printing integer (underlying) values of an enum.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LIBCALAMARES_NAMEDENUM_H
|
#ifndef UTILS_NAMEDENUM_H
|
||||||
#define LIBCALAMARES_NAMEDENUM_H
|
#define UTILS_NAMEDENUM_H
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
@ -108,5 +108,4 @@ constexpr typename std::underlying_type<E>::type smash( const E e )
|
|||||||
return static_cast<typename std::underlying_type<E>::type>( e );
|
return static_cast<typename std::underlying_type<E>::type>( e );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -36,8 +36,8 @@
|
|||||||
* } ;
|
* } ;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LIBCALAMARES_NAMEDSUFFIX_H
|
#ifndef UTILS_NAMEDSUFFIX_H
|
||||||
#define LIBCALAMARES_NAMEDSUFFIX_H
|
#define UTILS_NAMEDSUFFIX_H
|
||||||
|
|
||||||
#include "NamedEnum.h"
|
#include "NamedEnum.h"
|
||||||
|
|
||||||
@ -104,5 +104,4 @@ protected:
|
|||||||
unit_t m_unit;
|
unit_t m_unit;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CALAMARESPLUGINFACTORY_H
|
#ifndef UTILS_PLUGINFACTORY_H
|
||||||
#define CALAMARESPLUGINFACTORY_H
|
#define UTILS_PLUGINFACTORY_H
|
||||||
|
|
||||||
#include "DllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
@ -311,8 +311,8 @@ inline T* PluginFactory::create( const QString& keyword, QObject* parent )
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
Q_DECLARE_INTERFACE( Calamares::PluginFactory, CalamaresPluginFactory_iid )
|
Q_DECLARE_INTERFACE( Calamares::PluginFactory, CalamaresPluginFactory_iid )
|
||||||
|
|
||||||
#endif // CALAMARESPLUGINFACTORY_H
|
#endif
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CALAMARESPLUGINFACTORY_P_H
|
#ifndef UTILS_PLUGINFACTORY_P_H
|
||||||
#define CALAMARESPLUGINFACTORY_P_H
|
#define UTILS_PLUGINFACTORY_P_H
|
||||||
|
|
||||||
#include "PluginFactory.h"
|
#include "PluginFactory.h"
|
||||||
|
|
||||||
@ -49,6 +49,6 @@ protected:
|
|||||||
PluginFactory *q_ptr;
|
PluginFactory *q_ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
#endif // CALAMARESPLUGINFACTORY_P_H
|
#endif
|
||||||
|
@ -18,11 +18,107 @@
|
|||||||
|
|
||||||
#include "Retranslator.h"
|
#include "Retranslator.h"
|
||||||
|
|
||||||
|
#include "Logger.h"
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QDir>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
|
#include <QTranslator>
|
||||||
|
|
||||||
|
|
||||||
namespace CalamaresUtils {
|
namespace CalamaresUtils {
|
||||||
|
static QTranslator* s_brandingTranslator = nullptr;
|
||||||
|
static QTranslator* s_translator = nullptr;
|
||||||
|
static QString s_translatorLocaleName;
|
||||||
|
|
||||||
|
void
|
||||||
|
installTranslator( const QLocale& locale,
|
||||||
|
const QString& brandingTranslationsPrefix,
|
||||||
|
QObject* parent )
|
||||||
|
{
|
||||||
|
QString localeName = locale.name();
|
||||||
|
localeName.replace( "-", "_" );
|
||||||
|
|
||||||
|
if ( localeName == "C" )
|
||||||
|
localeName = "en";
|
||||||
|
|
||||||
|
// Special case of sr@latin
|
||||||
|
//
|
||||||
|
// See top-level CMakeLists.txt about special cases for translation loading.
|
||||||
|
if ( locale.language() == QLocale::Language::Serbian && locale.script() == QLocale::Script::LatinScript )
|
||||||
|
localeName = QStringLiteral( "sr@latin" );
|
||||||
|
|
||||||
|
cDebug() << "Looking for translations for" << localeName;
|
||||||
|
|
||||||
|
QTranslator* translator = nullptr;
|
||||||
|
|
||||||
|
// Branding translations
|
||||||
|
if ( !brandingTranslationsPrefix.isEmpty() )
|
||||||
|
{
|
||||||
|
QString brandingTranslationsDirPath( brandingTranslationsPrefix );
|
||||||
|
brandingTranslationsDirPath.truncate( brandingTranslationsPrefix.lastIndexOf(
|
||||||
|
QDir::separator() ) );
|
||||||
|
QDir brandingTranslationsDir( brandingTranslationsDirPath );
|
||||||
|
if ( brandingTranslationsDir.exists() )
|
||||||
|
{
|
||||||
|
QString filenameBase( brandingTranslationsPrefix );
|
||||||
|
filenameBase.remove( 0, brandingTranslationsPrefix.lastIndexOf(
|
||||||
|
QDir::separator() ) + 1 );
|
||||||
|
translator = new QTranslator( parent );
|
||||||
|
if ( translator->load( locale,
|
||||||
|
filenameBase,
|
||||||
|
"_",
|
||||||
|
brandingTranslationsDir.absolutePath() ) )
|
||||||
|
{
|
||||||
|
cDebug() << Logger::SubEntry << "Branding using locale:" << localeName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cDebug() << Logger::SubEntry << "Branding using default, system locale not found:" << localeName;
|
||||||
|
translator->load( brandingTranslationsPrefix + "en" );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( s_brandingTranslator )
|
||||||
|
{
|
||||||
|
QCoreApplication::removeTranslator( s_brandingTranslator );
|
||||||
|
delete s_brandingTranslator;
|
||||||
|
}
|
||||||
|
|
||||||
|
QCoreApplication::installTranslator( translator );
|
||||||
|
s_brandingTranslator = translator;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calamares translations
|
||||||
|
translator = new QTranslator( parent );
|
||||||
|
if ( translator->load( QString( ":/lang/calamares_" ) + localeName ) )
|
||||||
|
{
|
||||||
|
cDebug() << Logger::SubEntry << "Calamares using locale:" << localeName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cDebug() << Logger::SubEntry << "Calamares using default, system locale not found:" << localeName;
|
||||||
|
translator->load( QString( ":/lang/calamares_en" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( s_translator )
|
||||||
|
{
|
||||||
|
QCoreApplication::removeTranslator( s_translator );
|
||||||
|
delete s_translator;
|
||||||
|
}
|
||||||
|
|
||||||
|
QCoreApplication::installTranslator( translator );
|
||||||
|
s_translator = translator;
|
||||||
|
|
||||||
|
s_translatorLocaleName = localeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
translatorLocaleName()
|
||||||
|
{
|
||||||
|
return s_translatorLocaleName;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Retranslator::attachRetranslator( QObject* parent,
|
Retranslator::attachRetranslator( QObject* parent,
|
||||||
|
@ -16,18 +16,33 @@
|
|||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CALAMARESUTILS_RETRANSLATOR_H
|
#ifndef UTILS_RETRANSLATOR_H
|
||||||
#define CALAMARESUTILS_RETRANSLATOR_H
|
#define UTILS_RETRANSLATOR_H
|
||||||
|
|
||||||
|
#include "DllMacro.h"
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
class QEvent;
|
class QEvent;
|
||||||
|
class QLocale;
|
||||||
|
|
||||||
namespace CalamaresUtils
|
namespace CalamaresUtils
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @brief installTranslator changes the application language.
|
||||||
|
* @param locale the new locale.
|
||||||
|
* @param brandingTranslationsPrefix the branding path prefix, from Calamares::Branding.
|
||||||
|
* @param parent the parent QObject.
|
||||||
|
*/
|
||||||
|
DLLEXPORT void installTranslator( const QLocale& locale,
|
||||||
|
const QString& brandingTranslationsPrefix,
|
||||||
|
QObject* parent );
|
||||||
|
|
||||||
|
DLLEXPORT QString translatorLocaleName();
|
||||||
|
|
||||||
class Retranslator : public QObject
|
class Retranslator : public QObject
|
||||||
{
|
{
|
||||||
@ -48,11 +63,11 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace CalamaresUtils
|
} // namespace
|
||||||
|
|
||||||
#define CALAMARES_RETRANSLATE(body) \
|
#define CALAMARES_RETRANSLATE(body) \
|
||||||
CalamaresUtils::Retranslator::attachRetranslator( this, [=] { body } );
|
CalamaresUtils::Retranslator::attachRetranslator( this, [=] { body } );
|
||||||
#define CALAMARES_RETRANSLATE_WIDGET(widget,body) \
|
#define CALAMARES_RETRANSLATE_WIDGET(widget,body) \
|
||||||
CalamaresUtils::Retranslator::attachRetranslator( widget, [=] { body } );
|
CalamaresUtils::Retranslator::attachRetranslator( widget, [=] { body } );
|
||||||
|
|
||||||
#endif // CALAMARESUTILS_RETRANSLATOR_H
|
#endif
|
||||||
|
125
src/libcalamares/utils/String.cpp
Normal file
125
src/libcalamares/utils/String.cpp
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
|
*
|
||||||
|
* Copyright 2013-2016, Teo Mrnjavac <teo@kde.org>
|
||||||
|
* Copyright 2018, Adriaan de Groot <groot@kde.org>
|
||||||
|
*
|
||||||
|
* Originally from Tomahawk, portions:
|
||||||
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
|
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||||
|
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
|
||||||
|
*
|
||||||
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Calamares is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "String.h"
|
||||||
|
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
namespace CalamaresUtils
|
||||||
|
{
|
||||||
|
QString
|
||||||
|
removeDiacritics( const QString& string )
|
||||||
|
{
|
||||||
|
static const QString diacriticLetters = QString::fromUtf8(
|
||||||
|
"ŠŒŽšœžŸ¥µÀ"
|
||||||
|
"ÁÂÃÄÅÆÇÈÉÊ"
|
||||||
|
"ËÌÍÎÏÐÑÒÓÔ"
|
||||||
|
"ÕÖØÙÚÛÜÝßà"
|
||||||
|
"áâãäåæçèéê"
|
||||||
|
"ëìíîïðñòóô"
|
||||||
|
"õöøùúûüýÿÞ"
|
||||||
|
"þČčĆćĐ𩹮"
|
||||||
|
"žŞşĞğİıȚțȘ"
|
||||||
|
"șĂăŐőŰűŘřĀ"
|
||||||
|
"āĒēĪīŌōŪūŢ"
|
||||||
|
"ţẀẁẂẃŴŵŶŷĎ"
|
||||||
|
"ďĚěŇňŤťŮůŔ"
|
||||||
|
"ॹĘꣳŃńŚ"
|
||||||
|
"śŹźŻż"
|
||||||
|
);
|
||||||
|
static const QStringList noDiacriticLetters = {
|
||||||
|
"S", "OE", "Z", "s", "oe", "z", "Y", "Y", "u", "A",
|
||||||
|
"A", "A", "A", "A", "AA", "AE", "C", "E", "E", "E",
|
||||||
|
"E", "I", "I", "I", "I", "D", "N", "O", "O", "O",
|
||||||
|
"O", "E", "OE", "U", "U", "U", "E", "Y", "s", "a",
|
||||||
|
"a", "a", "a", "e", "aa", "ae", "c", "e", "e", "e",
|
||||||
|
"e", "i", "i", "i", "i", "d", "n", "o", "o", "o",
|
||||||
|
"o", "e", "oe", "u", "u", "u", "e", "y", "y", "TH",
|
||||||
|
"th", "C", "c", "C", "c", "DJ", "dj", "S", "s", "Z",
|
||||||
|
"z", "S", "s", "G", "g", "I", "i", "T", "t", "S",
|
||||||
|
"s", "A", "a", "O", "o", "U", "u", "R", "r", "A",
|
||||||
|
"a", "E", "e", "I", "i", "O", "o", "U", "u", "T",
|
||||||
|
"t", "W", "w", "W", "w", "W", "w", "Y", "y", "D",
|
||||||
|
"d", "E", "e", "N", "n", "T", "t", "U", "u", "R",
|
||||||
|
"r", "A", "a", "E", "e", "L", "l", "N", "n", "S",
|
||||||
|
"s", "Z", "z", "Z", "z"
|
||||||
|
};
|
||||||
|
|
||||||
|
QString output;
|
||||||
|
for ( const QChar &c : string )
|
||||||
|
{
|
||||||
|
int i = diacriticLetters.indexOf( c );
|
||||||
|
if ( i < 0 )
|
||||||
|
{
|
||||||
|
output.append( c );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QString replacement = noDiacriticLetters[ i ];
|
||||||
|
output.append( replacement );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Function CalamaresUtils::obscure based on KStringHandler::obscure,
|
||||||
|
// part of KDElibs by KDE, file kstringhandler.cpp.
|
||||||
|
// Original copyright statement follows.
|
||||||
|
/* This file is part of the KDE libraries
|
||||||
|
Copyright (C) 1999 Ian Zepp (icszepp@islc.net)
|
||||||
|
Copyright (C) 2006 by Dominic Battre <dominic@battre.de>
|
||||||
|
Copyright (C) 2006 by Martin Pool <mbp@canonical.com>
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library 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
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public License
|
||||||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||||||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
QString
|
||||||
|
obscure( const QString& string )
|
||||||
|
{
|
||||||
|
QString result;
|
||||||
|
const QChar *unicode = string.unicode();
|
||||||
|
for ( int i = 0; i < string.length(); ++i )
|
||||||
|
// yes, no typo. can't encode ' ' or '!' because
|
||||||
|
// they're the unicode BOM. stupid scrambling. stupid.
|
||||||
|
result += ( unicode[ i ].unicode() <= 0x21 ) ?
|
||||||
|
unicode[ i ] :
|
||||||
|
QChar( 0x1001F - unicode[ i ].unicode() );
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
53
src/libcalamares/utils/String.h
Normal file
53
src/libcalamares/utils/String.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
|
*
|
||||||
|
* Copyright 2013-2016, Teo Mrnjavac <teo@kde.org>
|
||||||
|
* Copyright 2018, Adriaan de Groot <groot@kde.org>
|
||||||
|
*
|
||||||
|
* Originally from Tomahawk, portions:
|
||||||
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
|
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||||
|
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
|
||||||
|
*
|
||||||
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Calamares is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef UTILS_STRING_H
|
||||||
|
#define UTILS_STRING_H
|
||||||
|
|
||||||
|
#include "DllMacro.h"
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The CalamaresUtils namespace contains utility functions.
|
||||||
|
*/
|
||||||
|
namespace CalamaresUtils
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief removeDiacritics replaces letters with diacritics and ligatures with
|
||||||
|
* alternative forms and digraphs.
|
||||||
|
* @param string the string to transform.
|
||||||
|
* @return the output string with plain characters.
|
||||||
|
*/
|
||||||
|
DLLEXPORT QString removeDiacritics( const QString& string );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief obscure is a bidirectional obfuscation function, from KStringHandler.
|
||||||
|
* @param string the input string.
|
||||||
|
* @return the obfuscated string.
|
||||||
|
*/
|
||||||
|
DLLEXPORT QString obscure( const QString& string );
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif
|
@ -17,8 +17,8 @@
|
|||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LIBCALAMARES_UTILS_UNITS_H
|
#ifndef UTILS_UNITS_H
|
||||||
#define LIBCALAMARES_UTILS_UNITS_H
|
#define UTILS_UNITS_H
|
||||||
|
|
||||||
#include <QtCore/QIntegerForSize>
|
#include <QtCore/QIntegerForSize>
|
||||||
|
|
||||||
|
107
src/libcalamares/utils/Variant.cpp
Normal file
107
src/libcalamares/utils/Variant.cpp
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
|
*
|
||||||
|
* Copyright 2013-2016, Teo Mrnjavac <teo@kde.org>
|
||||||
|
* Copyright 2018, Adriaan de Groot <groot@kde.org>
|
||||||
|
*
|
||||||
|
* Originally from Tomahawk, portions:
|
||||||
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
|
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||||
|
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
|
||||||
|
*
|
||||||
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Calamares is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Variant.h"
|
||||||
|
|
||||||
|
#include "Logger.h"
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QVariantMap>
|
||||||
|
|
||||||
|
namespace CalamaresUtils
|
||||||
|
{
|
||||||
|
bool
|
||||||
|
getBool( const QVariantMap& map, const QString& key, bool d )
|
||||||
|
{
|
||||||
|
bool result = d;
|
||||||
|
if ( map.contains( key ) )
|
||||||
|
{
|
||||||
|
auto v = map.value( key );
|
||||||
|
if ( v.type() == QVariant::Bool )
|
||||||
|
result = v.toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
getString(const QVariantMap& map, const QString& key)
|
||||||
|
{
|
||||||
|
if ( map.contains( key ) )
|
||||||
|
{
|
||||||
|
auto v = map.value( key );
|
||||||
|
if ( v.type() == QVariant::String )
|
||||||
|
return v.toString();
|
||||||
|
}
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
getInteger( const QVariantMap& map, const QString& key, int d )
|
||||||
|
{
|
||||||
|
int result = d;
|
||||||
|
if ( map.contains( key ) )
|
||||||
|
{
|
||||||
|
auto v = map.value( key );
|
||||||
|
if ( v.type() == QVariant::Int )
|
||||||
|
result = v.toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
getDouble( const QVariantMap& map, const QString& key, double d )
|
||||||
|
{
|
||||||
|
double result = d;
|
||||||
|
if ( map.contains( key ) )
|
||||||
|
{
|
||||||
|
auto v = map.value( key );
|
||||||
|
if ( v.type() == QVariant::Int )
|
||||||
|
result = v.toInt();
|
||||||
|
else if ( v.type() == QVariant::Double )
|
||||||
|
result = v.toDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantMap
|
||||||
|
getSubMap( const QVariantMap& map, const QString& key, bool& success )
|
||||||
|
{
|
||||||
|
success = false;
|
||||||
|
|
||||||
|
if ( map.contains( key ) )
|
||||||
|
{
|
||||||
|
auto v = map.value( key );
|
||||||
|
if ( v.type() == QVariant::Map )
|
||||||
|
{
|
||||||
|
success = true;
|
||||||
|
return v.toMap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QVariantMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
62
src/libcalamares/utils/Variant.h
Normal file
62
src/libcalamares/utils/Variant.h
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
|
*
|
||||||
|
* Copyright 2013-2016, Teo Mrnjavac <teo@kde.org>
|
||||||
|
* Copyright 2018, Adriaan de Groot <groot@kde.org>
|
||||||
|
*
|
||||||
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Calamares is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef UTILS_VARIANT_H
|
||||||
|
#define UTILS_VARIANT_H
|
||||||
|
|
||||||
|
#include "DllMacro.h"
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QVariantMap>
|
||||||
|
|
||||||
|
namespace CalamaresUtils
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get a bool value from a mapping with a given key; returns the default
|
||||||
|
* if no value is stored in the map.
|
||||||
|
*/
|
||||||
|
DLLEXPORT bool getBool( const QVariantMap& map, const QString& key, bool d );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a string value from a mapping; returns empty QString if no value.
|
||||||
|
*/
|
||||||
|
DLLEXPORT QString getString( const QVariantMap& map, const QString& key );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an integer value from a mapping; returns @p d if no value.
|
||||||
|
*/
|
||||||
|
DLLEXPORT int getInteger( const QVariantMap& map, const QString& key, int d );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a double value from a mapping (integers are converted); returns @p d if no value.
|
||||||
|
*/
|
||||||
|
DLLEXPORT double getDouble( const QVariantMap& map, const QString& key, double d );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a sub-map (i.e. a nested map) from the given mapping with the
|
||||||
|
* given key. @p success is set to true if the @p key exists
|
||||||
|
* in @p map and converts to a map, false otherwise.
|
||||||
|
*
|
||||||
|
* Returns an empty map if there is no such key or it is not a map-value.
|
||||||
|
* (e.g. if @p success is false).
|
||||||
|
*/
|
||||||
|
DLLEXPORT QVariantMap getSubMap( const QVariantMap& map, const QString& key, bool& success );
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif
|
@ -16,7 +16,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "YamlUtils.h"
|
#include "Yaml.h"
|
||||||
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
|
@ -17,8 +17,8 @@
|
|||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef YAMLUTILS_H
|
#ifndef UTILS_YAML_H
|
||||||
#define YAMLUTILS_H
|
#define UTILS_YAML_H
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
@ -77,6 +77,6 @@ void explainYamlException( const YAML::Exception& e, const QByteArray& data, con
|
|||||||
void explainYamlException( const YAML::Exception& e, const QByteArray& data, const QString& label );
|
void explainYamlException( const YAML::Exception& e, const QByteArray& data, const QString& label );
|
||||||
void explainYamlException( const YAML::Exception& e, const QByteArray& data );
|
void explainYamlException( const YAML::Exception& e, const QByteArray& data );
|
||||||
|
|
||||||
} //ns
|
} // namespace
|
||||||
|
|
||||||
#endif // YAMLUTILS_H
|
#endif
|
@ -21,12 +21,11 @@
|
|||||||
#include "Branding.h"
|
#include "Branding.h"
|
||||||
|
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
#include "utils/CalamaresUtils.h"
|
|
||||||
#include "utils/CalamaresUtilsGui.h"
|
#include "utils/CalamaresUtilsGui.h"
|
||||||
#include "utils/ImageRegistry.h"
|
#include "utils/ImageRegistry.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/NamedEnum.h"
|
#include "utils/NamedEnum.h"
|
||||||
#include "utils/YamlUtils.h"
|
#include "utils/Yaml.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
@ -26,10 +26,12 @@
|
|||||||
#include "modulesystem/Module.h"
|
#include "modulesystem/Module.h"
|
||||||
#include "modulesystem/ModuleManager.h"
|
#include "modulesystem/ModuleManager.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
#include "ViewManager.h"
|
||||||
|
|
||||||
#include "utils/CalamaresUtilsGui.h"
|
#include "utils/CalamaresUtilsGui.h"
|
||||||
|
#include "utils/Dirs.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/Retranslator.h"
|
#include "utils/Retranslator.h"
|
||||||
#include "ViewManager.h"
|
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
@ -19,14 +19,15 @@
|
|||||||
|
|
||||||
#include "Module.h"
|
#include "Module.h"
|
||||||
|
|
||||||
#include "ProcessJobModule.h"
|
|
||||||
#include "CppJobModule.h"
|
|
||||||
#include "ViewModule.h"
|
|
||||||
#include "utils/CalamaresUtils.h"
|
|
||||||
#include "utils/YamlUtils.h"
|
|
||||||
#include "utils/Logger.h"
|
|
||||||
#include "Settings.h"
|
|
||||||
#include "CalamaresConfig.h"
|
#include "CalamaresConfig.h"
|
||||||
|
#include "CppJobModule.h"
|
||||||
|
#include "ProcessJobModule.h"
|
||||||
|
#include "Settings.h"
|
||||||
|
#include "ViewModule.h"
|
||||||
|
|
||||||
|
#include "utils/Dirs.h"
|
||||||
|
#include "utils/Logger.h"
|
||||||
|
#include "utils/Yaml.h"
|
||||||
|
|
||||||
#ifdef WITH_PYTHON
|
#ifdef WITH_PYTHON
|
||||||
#include "PythonJobModule.h"
|
#include "PythonJobModule.h"
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include "ViewManager.h"
|
#include "ViewManager.h"
|
||||||
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/YamlUtils.h"
|
#include "utils/Yaml.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
#include <QPen>
|
#include <QPen>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
#define RESPATH ":/data/"
|
||||||
|
|
||||||
namespace CalamaresUtils
|
namespace CalamaresUtils
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#ifndef CALAMARESUTILSGUI_H
|
#ifndef CALAMARESUTILSGUI_H
|
||||||
#define CALAMARESUTILSGUI_H
|
#define CALAMARESUTILSGUI_H
|
||||||
|
|
||||||
#include "utils/CalamaresUtils.h"
|
|
||||||
#include "UiDllMacro.h"
|
#include "UiDllMacro.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "DebugWindow.h"
|
#include "DebugWindow.h"
|
||||||
#include "utils/CalamaresUtils.h"
|
|
||||||
#include "utils/Retranslator.h"
|
#include "utils/Retranslator.h"
|
||||||
#include "utils/qjsonmodel.h"
|
#include "utils/qjsonmodel.h"
|
||||||
#include "JobQueue.h"
|
#include "JobQueue.h"
|
||||||
@ -37,6 +36,17 @@
|
|||||||
#include <QStringListModel>
|
#include <QStringListModel>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief crash makes Calamares crash immediately.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
crash()
|
||||||
|
{
|
||||||
|
volatile int* a = nullptr;
|
||||||
|
*a = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace Calamares {
|
namespace Calamares {
|
||||||
|
|
||||||
DebugWindow::DebugWindow()
|
DebugWindow::DebugWindow()
|
||||||
@ -172,10 +182,7 @@ DebugWindow::DebugWindow()
|
|||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
connect( crashButton, &QPushButton::clicked,
|
connect( crashButton, &QPushButton::clicked, this, [] { ::crash(); } );
|
||||||
this, [] {
|
|
||||||
CalamaresUtils::crash();
|
|
||||||
} );
|
|
||||||
|
|
||||||
CALAMARES_RETRANSLATE(
|
CALAMARES_RETRANSLATE(
|
||||||
retranslateUi( this );
|
retranslateUi( this );
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
#include "PythonQtUtilsWrapper.h"
|
#include "PythonQtUtilsWrapper.h"
|
||||||
|
|
||||||
#include "utils/CalamaresUtilsSystem.h"
|
#include "utils/CalamaresUtilsSystem.h"
|
||||||
#include "utils/CalamaresUtils.h"
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
#include "utils/String.h"
|
||||||
|
|
||||||
#include <PythonQt.h>
|
#include <PythonQt.h>
|
||||||
|
|
||||||
|
@ -26,9 +26,9 @@
|
|||||||
#include "JobQueue.h"
|
#include "JobQueue.h"
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
|
|
||||||
#include "utils/CalamaresUtils.h"
|
|
||||||
#include "utils/CommandList.h"
|
#include "utils/CommandList.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
#include "utils/Variant.h"
|
||||||
|
|
||||||
struct ValueCheck : public QPair<QString, CalamaresUtils::CommandList*>
|
struct ValueCheck : public QPair<QString, CalamaresUtils::CommandList*>
|
||||||
{
|
{
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "ContextualProcessJob.h"
|
#include "ContextualProcessJob.h"
|
||||||
|
|
||||||
#include "utils/CommandList.h"
|
#include "utils/CommandList.h"
|
||||||
#include "utils/YamlUtils.h"
|
#include "utils/Yaml.h"
|
||||||
|
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
|
|
||||||
|
@ -33,9 +33,9 @@
|
|||||||
#include "JobQueue.h"
|
#include "JobQueue.h"
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
|
|
||||||
#include "utils/CalamaresUtils.h"
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/Units.h"
|
#include "utils/Units.h"
|
||||||
|
#include "utils/Variant.h"
|
||||||
|
|
||||||
#include "modules/partition/core/PartitionIterator.h"
|
#include "modules/partition/core/PartitionIterator.h"
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/YamlUtils.h"
|
#include "utils/Yaml.h"
|
||||||
|
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
|
|
||||||
|
@ -28,11 +28,11 @@
|
|||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
#include "ViewManager.h"
|
#include "ViewManager.h"
|
||||||
|
|
||||||
#include "utils/CalamaresUtils.h"
|
|
||||||
#include "utils/CalamaresUtilsGui.h"
|
#include "utils/CalamaresUtilsGui.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/NamedEnum.h"
|
#include "utils/NamedEnum.h"
|
||||||
#include "utils/Retranslator.h"
|
#include "utils/Retranslator.h"
|
||||||
|
#include "utils/Variant.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
|
|
||||||
#include "GeoIPJSON.h"
|
#include "GeoIPJSON.h"
|
||||||
|
|
||||||
#include "utils/CalamaresUtils.h"
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/YamlUtils.h"
|
#include "utils/Variant.h"
|
||||||
|
#include "utils/Yaml.h"
|
||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
|
||||||
|
@ -31,10 +31,10 @@
|
|||||||
#include "timezonewidget/localeglobal.h"
|
#include "timezonewidget/localeglobal.h"
|
||||||
#include "widgets/WaitingWidget.h"
|
#include "widgets/WaitingWidget.h"
|
||||||
|
|
||||||
#include "utils/CalamaresUtils.h"
|
|
||||||
#include "utils/CalamaresUtilsGui.h"
|
#include "utils/CalamaresUtilsGui.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/YamlUtils.h"
|
#include "utils/Variant.h"
|
||||||
|
#include "utils/Yaml.h"
|
||||||
|
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/Retranslator.h"
|
#include "utils/Retranslator.h"
|
||||||
#include "utils/YamlUtils.h"
|
#include "utils/Yaml.h"
|
||||||
|
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
#include "JobQueue.h"
|
#include "JobQueue.h"
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
|
|
||||||
#include "utils/CalamaresUtils.h"
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
#include "utils/Variant.h"
|
||||||
|
|
||||||
#include "NetInstallPage.h"
|
#include "NetInstallPage.h"
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include "PackageModel.h"
|
#include "PackageModel.h"
|
||||||
|
|
||||||
#include "utils/YamlUtils.h"
|
#include "utils/Yaml.h"
|
||||||
|
|
||||||
PackageModel::PackageModel( const YAML::Node& data, QObject* parent ) :
|
PackageModel::PackageModel( const YAML::Node& data, QObject* parent ) :
|
||||||
QAbstractItemModel( parent ),
|
QAbstractItemModel( parent ),
|
||||||
|
@ -44,7 +44,8 @@
|
|||||||
#include "jobs/ResizePartitionJob.h"
|
#include "jobs/ResizePartitionJob.h"
|
||||||
#include "jobs/ResizeVolumeGroupJob.h"
|
#include "jobs/ResizeVolumeGroupJob.h"
|
||||||
#include "jobs/SetPartitionFlagsJob.h"
|
#include "jobs/SetPartitionFlagsJob.h"
|
||||||
#include "utils/CalamaresUtils.h"
|
|
||||||
|
#include "utils/Variant.h"
|
||||||
|
|
||||||
#ifdef DEBUG_PARTITION_LAME
|
#ifdef DEBUG_PARTITION_LAME
|
||||||
#include "JobExample.h"
|
#include "JobExample.h"
|
||||||
|
@ -33,16 +33,19 @@
|
|||||||
#include "gui/PartitionBarsView.h"
|
#include "gui/PartitionBarsView.h"
|
||||||
#include "gui/PartitionLabelsView.h"
|
#include "gui/PartitionLabelsView.h"
|
||||||
|
|
||||||
|
#include "Branding.h"
|
||||||
#include "CalamaresVersion.h"
|
#include "CalamaresVersion.h"
|
||||||
|
#include "GlobalStorage.h"
|
||||||
|
#include "Job.h"
|
||||||
|
#include "JobQueue.h"
|
||||||
|
|
||||||
#include "utils/CalamaresUtilsGui.h"
|
#include "utils/CalamaresUtilsGui.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/NamedEnum.h"
|
#include "utils/NamedEnum.h"
|
||||||
#include "utils/Retranslator.h"
|
#include "utils/Retranslator.h"
|
||||||
|
#include "utils/Variant.h"
|
||||||
#include "widgets/WaitingWidget.h"
|
#include "widgets/WaitingWidget.h"
|
||||||
#include "GlobalStorage.h"
|
|
||||||
#include "JobQueue.h"
|
|
||||||
#include "Job.h"
|
|
||||||
#include "Branding.h"
|
|
||||||
|
|
||||||
#include <kpmcore/core/device.h>
|
#include <kpmcore/core/device.h>
|
||||||
#include <kpmcore/core/partition.h>
|
#include <kpmcore/core/partition.h>
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
#include "PlasmaLnfPage.h"
|
#include "PlasmaLnfPage.h"
|
||||||
#include "ThemeInfo.h"
|
#include "ThemeInfo.h"
|
||||||
|
|
||||||
#include "utils/CalamaresUtils.h"
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
#include "utils/Variant.h"
|
||||||
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include "JobQueue.h"
|
#include "JobQueue.h"
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
|
|
||||||
#include "utils/CalamaresUtils.h"
|
|
||||||
#include "utils/CalamaresUtilsSystem.h"
|
#include "utils/CalamaresUtilsSystem.h"
|
||||||
#include "utils/CommandList.h"
|
#include "utils/CommandList.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
@ -113,7 +112,7 @@ copy_file( const QString& source, const QString& dest )
|
|||||||
|
|
||||||
sourcef.close();
|
sourcef.close();
|
||||||
destf.close();
|
destf.close();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,22 +150,22 @@ Calamares::JobResult PreserveFiles::exec()
|
|||||||
if ( it.perm.isValid() )
|
if ( it.perm.isValid() )
|
||||||
{
|
{
|
||||||
auto s_p = CalamaresUtils::System::instance();
|
auto s_p = CalamaresUtils::System::instance();
|
||||||
|
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
r = s_p->targetEnvCall( QStringList{ "chown", it.perm.username(), bare_dest } );
|
r = s_p->targetEnvCall( QStringList{ "chown", it.perm.username(), bare_dest } );
|
||||||
if ( r )
|
if ( r )
|
||||||
cWarning() << "Could not chown target" << bare_dest;
|
cWarning() << "Could not chown target" << bare_dest;
|
||||||
|
|
||||||
r = s_p->targetEnvCall( QStringList{ "chgrp", it.perm.group(), bare_dest } );
|
r = s_p->targetEnvCall( QStringList{ "chgrp", it.perm.group(), bare_dest } );
|
||||||
if ( r )
|
if ( r )
|
||||||
cWarning() << "Could not chgrp target" << bare_dest;
|
cWarning() << "Could not chgrp target" << bare_dest;
|
||||||
|
|
||||||
r = s_p->targetEnvCall( QStringList{ "chmod", it.perm.octal(), bare_dest } );
|
r = s_p->targetEnvCall( QStringList{ "chmod", it.perm.octal(), bare_dest } );
|
||||||
if ( r )
|
if ( r )
|
||||||
cWarning() << "Could not chmod target" << bare_dest;
|
cWarning() << "Could not chmod target" << bare_dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -195,7 +194,7 @@ void PreserveFiles::setConfigurationMap(const QVariantMap& configurationMap)
|
|||||||
QString defaultPermissions = configurationMap[ "perm" ].toString();
|
QString defaultPermissions = configurationMap[ "perm" ].toString();
|
||||||
if ( defaultPermissions.isEmpty() )
|
if ( defaultPermissions.isEmpty() )
|
||||||
defaultPermissions = QStringLiteral( "root:root:0400" );
|
defaultPermissions = QStringLiteral( "root:root:0400" );
|
||||||
|
|
||||||
QVariantList l = files.toList();
|
QVariantList l = files.toList();
|
||||||
unsigned int c = 0;
|
unsigned int c = 0;
|
||||||
for ( const auto& li : l )
|
for ( const auto& li : l )
|
||||||
|
@ -26,10 +26,9 @@
|
|||||||
#include "JobQueue.h"
|
#include "JobQueue.h"
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
|
|
||||||
#include "utils/CalamaresUtils.h"
|
|
||||||
#include "utils/CalamaresUtilsSystem.h"
|
|
||||||
#include "utils/CommandList.h"
|
#include "utils/CommandList.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
#include "utils/Variant.h"
|
||||||
|
|
||||||
ShellProcessJob::ShellProcessJob( QObject* parent )
|
ShellProcessJob::ShellProcessJob( QObject* parent )
|
||||||
: Calamares::CppJob( parent )
|
: Calamares::CppJob( parent )
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include "utils/CommandList.h"
|
#include "utils/CommandList.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/YamlUtils.h"
|
#include "utils/Yaml.h"
|
||||||
|
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
* shipped with each module for correctness -- well, for parseability.
|
* shipped with each module for correctness -- well, for parseability.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "utils/YamlUtils.h"
|
#include "utils/Yaml.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -16,15 +16,17 @@
|
|||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "JobQueue.h"
|
#include "TrackingViewStep.h"
|
||||||
#include "GlobalStorage.h"
|
|
||||||
#include "utils/Logger.h"
|
|
||||||
#include "utils/CalamaresUtils.h"
|
|
||||||
#include "utils/CalamaresUtilsSystem.h"
|
|
||||||
|
|
||||||
#include "TrackingJobs.h"
|
#include "TrackingJobs.h"
|
||||||
#include "TrackingPage.h"
|
#include "TrackingPage.h"
|
||||||
#include "TrackingViewStep.h"
|
|
||||||
|
#include "JobQueue.h"
|
||||||
|
#include "GlobalStorage.h"
|
||||||
|
|
||||||
|
#include "utils/Logger.h"
|
||||||
|
#include "utils/CalamaresUtilsSystem.h"
|
||||||
|
#include "utils/Variant.h"
|
||||||
|
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
|
@ -23,17 +23,22 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UsersPage.h"
|
#include "UsersPage.h"
|
||||||
|
|
||||||
#include "ui_page_usersetup.h"
|
#include "ui_page_usersetup.h"
|
||||||
|
|
||||||
#include "CreateUserJob.h"
|
#include "CreateUserJob.h"
|
||||||
#include "SetPasswordJob.h"
|
#include "SetPasswordJob.h"
|
||||||
#include "SetHostNameJob.h"
|
#include "SetHostNameJob.h"
|
||||||
#include "JobQueue.h"
|
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
#include "utils/Logger.h"
|
#include "JobQueue.h"
|
||||||
#include "utils/CalamaresUtilsGui.h"
|
|
||||||
#include "utils/Retranslator.h"
|
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
|
||||||
|
#include "utils/CalamaresUtilsGui.h"
|
||||||
|
#include "utils/Logger.h"
|
||||||
|
#include "utils/Retranslator.h"
|
||||||
|
#include "utils/String.h"
|
||||||
|
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
@ -22,8 +22,9 @@
|
|||||||
|
|
||||||
#include "UsersPage.h"
|
#include "UsersPage.h"
|
||||||
|
|
||||||
#include "utils/CalamaresUtils.h"
|
// #include "utils/CalamaresUtils.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
#include "utils/Variant.h"
|
||||||
|
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
#include "JobQueue.h"
|
#include "JobQueue.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user