Merge branch 'master' of https://github.com/calamares/calamares into development
This commit is contained in:
commit
6af4da1db3
6
CHANGES
6
CHANGES
@ -9,10 +9,12 @@ This release contains contributions from (alphabetically by first name):
|
||||
- No external contributors yet
|
||||
|
||||
## Core ##
|
||||
- No core changes yet
|
||||
- Python job modules (such as *unpackfs* or *packages*) can now provide
|
||||
a `pretty_status_message()` function, like the existing `pretty_name()`
|
||||
function, that is used to update the status during install. #1330
|
||||
|
||||
## Modules ##
|
||||
- No module changes yet
|
||||
- *packages* now reports more details in the installation progress-bar.
|
||||
|
||||
|
||||
# 3.2.20 (2020-02-27) #
|
||||
|
@ -105,8 +105,20 @@ public:
|
||||
* how much work is (relatively) done.
|
||||
*/
|
||||
virtual qreal getJobWeight() const;
|
||||
/** @brief The human-readable name of this job
|
||||
*
|
||||
* This should be a very short statement of what the job does.
|
||||
* For status and state information, see prettyStatusMessage().
|
||||
*/
|
||||
virtual QString prettyName() const = 0;
|
||||
// TODO: Unused
|
||||
virtual QString prettyDescription() const;
|
||||
/** @brief A human-readable status for progress reporting
|
||||
*
|
||||
* This is called from the JobQueue when progress is made, and should
|
||||
* return a not-too-long description of the job's status. This
|
||||
* is made visible in the progress bar of the execution view step.
|
||||
*/
|
||||
virtual QString prettyStatusMessage() const;
|
||||
virtual JobResult exec() = 0;
|
||||
|
||||
|
@ -204,8 +204,6 @@ variantHashFromPyDict( const boost::python::dict& pyDict )
|
||||
}
|
||||
|
||||
|
||||
Helper* Helper::s_instance = nullptr;
|
||||
|
||||
static inline void
|
||||
add_if_lib_exists( const QDir& dir, const char* name, QStringList& list )
|
||||
{
|
||||
@ -221,12 +219,10 @@ add_if_lib_exists( const QDir& dir, const char* name, QStringList& list )
|
||||
}
|
||||
}
|
||||
|
||||
Helper::Helper( QObject* parent )
|
||||
: QObject( parent )
|
||||
Helper::Helper()
|
||||
: QObject( nullptr )
|
||||
{
|
||||
// Let's make extra sure we only call Py_Initialize once
|
||||
if ( !s_instance )
|
||||
{
|
||||
if ( !Py_IsInitialized() )
|
||||
{
|
||||
Py_Initialize();
|
||||
@ -249,20 +245,20 @@ Helper::Helper( QObject* parent )
|
||||
sys.attr( "path" ).attr( "append" )( dir );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Helper::~Helper() {}
|
||||
|
||||
Helper*
|
||||
Helper::instance()
|
||||
{
|
||||
cWarning() << "creating PythonHelper more than once. This is very bad.";
|
||||
return;
|
||||
}
|
||||
static Helper* s_helper = nullptr;
|
||||
|
||||
s_instance = this;
|
||||
}
|
||||
|
||||
Helper::~Helper()
|
||||
if ( !s_helper )
|
||||
{
|
||||
s_instance = nullptr;
|
||||
s_helper = new Helper;
|
||||
}
|
||||
return s_helper;
|
||||
}
|
||||
|
||||
|
||||
boost::python::dict
|
||||
Helper::createCleanNamespace()
|
||||
|
@ -50,16 +50,15 @@ class Helper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
virtual ~Helper();
|
||||
|
||||
boost::python::dict createCleanNamespace();
|
||||
|
||||
QString handleLastError();
|
||||
|
||||
static Helper* instance();
|
||||
|
||||
private:
|
||||
friend Helper* Calamares::PythonJob::helper();
|
||||
explicit Helper( QObject* parent = nullptr );
|
||||
static Helper* s_instance;
|
||||
virtual ~Helper();
|
||||
explicit Helper();
|
||||
|
||||
boost::python::object m_mainModule;
|
||||
boost::python::object m_mainNamespace;
|
||||
|
@ -165,6 +165,10 @@ BOOST_PYTHON_MODULE( libcalamares )
|
||||
namespace Calamares
|
||||
{
|
||||
|
||||
struct PythonJob::Private
|
||||
{
|
||||
bp::object m_prettyStatusMessage;
|
||||
};
|
||||
|
||||
PythonJob::PythonJob( const ModuleSystem::InstanceKey& instance,
|
||||
const QString& scriptFile,
|
||||
@ -172,6 +176,7 @@ PythonJob::PythonJob( const ModuleSystem::InstanceKey& instance,
|
||||
const QVariantMap& moduleConfiguration,
|
||||
QObject* parent )
|
||||
: Job( parent )
|
||||
, m_d( std::make_unique< Private >() )
|
||||
, m_scriptFile( scriptFile )
|
||||
, m_workingPath( workingPath )
|
||||
, m_description()
|
||||
@ -199,6 +204,7 @@ PythonJob::prettyName() const
|
||||
QString
|
||||
PythonJob::prettyStatusMessage() const
|
||||
{
|
||||
// The description is updated when progress is reported, see emitProgress()
|
||||
if ( m_description.isEmpty() )
|
||||
{
|
||||
return tr( "Running %1 operation." ).arg( QDir( m_workingPath ).dirName() );
|
||||
@ -209,6 +215,18 @@ PythonJob::prettyStatusMessage() const
|
||||
}
|
||||
}
|
||||
|
||||
static QString
|
||||
pythonStringMethod( bp::dict& script, const char* funcName )
|
||||
{
|
||||
bp::object func = script.get( funcName, bp::object() );
|
||||
if ( !func.is_none() )
|
||||
{
|
||||
bp::extract< std::string > result( func() );
|
||||
return result.check() ? QString::fromStdString( result() ).trimmed() : QString();
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
JobResult
|
||||
PythonJob::exec()
|
||||
@ -233,7 +251,7 @@ PythonJob::exec()
|
||||
|
||||
try
|
||||
{
|
||||
bp::dict scriptNamespace = helper()->createCleanNamespace();
|
||||
bp::dict scriptNamespace = CalamaresPython::Helper::instance()->createCleanNamespace();
|
||||
|
||||
bp::object calamaresModule = bp::import( "libcalamares" );
|
||||
bp::dict calamaresNamespace = bp::extract< bp::dict >( calamaresModule.attr( "__dict__" ) );
|
||||
@ -242,27 +260,13 @@ PythonJob::exec()
|
||||
calamaresNamespace[ "globalstorage" ]
|
||||
= CalamaresPython::GlobalStoragePythonWrapper( JobQueue::instance()->globalStorage() );
|
||||
|
||||
cDebug() << "Job file" << scriptFI.absoluteFilePath();
|
||||
bp::object execResult
|
||||
= bp::exec_file( scriptFI.absoluteFilePath().toLocal8Bit().data(), scriptNamespace, scriptNamespace );
|
||||
|
||||
bp::object entryPoint = scriptNamespace[ "run" ];
|
||||
bp::object prettyNameFunc = scriptNamespace.get( "pretty_name", bp::object() );
|
||||
|
||||
cDebug() << "Job file" << scriptFI.absoluteFilePath();
|
||||
if ( !prettyNameFunc.is_none() )
|
||||
{
|
||||
bp::extract< std::string > prettyNameResult( prettyNameFunc() );
|
||||
if ( prettyNameResult.check() )
|
||||
{
|
||||
m_description = QString::fromStdString( prettyNameResult() ).trimmed();
|
||||
}
|
||||
if ( !m_description.isEmpty() )
|
||||
{
|
||||
cDebug() << "Job description from pretty_name" << prettyName() << "=" << m_description;
|
||||
emit progress( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
m_d->m_prettyStatusMessage = scriptNamespace.get( "pretty_status_message", bp::object() );
|
||||
m_description = pythonStringMethod( scriptNamespace, "pretty_name" );
|
||||
if ( m_description.isEmpty() )
|
||||
{
|
||||
bp::extract< std::string > entryPoint_doc_attr( entryPoint.attr( "__doc__" ) );
|
||||
@ -275,10 +279,14 @@ PythonJob::exec()
|
||||
{
|
||||
m_description.truncate( i_newline );
|
||||
}
|
||||
cDebug() << "Job description from __doc__" << prettyName() << "=" << m_description;
|
||||
cDebug() << "Job description from __doc__" << prettyName() << '=' << m_description;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cDebug() << "Job description from pretty_name" << prettyName() << '=' << m_description;
|
||||
}
|
||||
emit progress( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
bp::object runResult = entryPoint();
|
||||
|
||||
@ -299,7 +307,7 @@ PythonJob::exec()
|
||||
QString msg;
|
||||
if ( PyErr_Occurred() )
|
||||
{
|
||||
msg = helper()->handleLastError();
|
||||
msg = CalamaresPython::Helper::instance()->handleLastError();
|
||||
}
|
||||
bp::handle_exception();
|
||||
PyErr_Clear();
|
||||
@ -312,20 +320,21 @@ PythonJob::exec()
|
||||
void
|
||||
PythonJob::emitProgress( qreal progressValue )
|
||||
{
|
||||
// This is called from the JobApi (and only from there) from the Job thread,
|
||||
// so it is safe to call into the Python interpreter. Update the description
|
||||
// as needed (don't call this from prettyStatusMessage(), which can be
|
||||
// called from other threads as well).
|
||||
if ( m_d && !m_d->m_prettyStatusMessage.is_none() )
|
||||
{
|
||||
QString r;
|
||||
bp::extract< std::string > result( m_d->m_prettyStatusMessage() );
|
||||
r = result.check() ? QString::fromStdString( result() ).trimmed() : QString();
|
||||
if ( !r.isEmpty() )
|
||||
{
|
||||
m_description = r;
|
||||
}
|
||||
}
|
||||
emit progress( progressValue );
|
||||
}
|
||||
|
||||
|
||||
CalamaresPython::Helper*
|
||||
PythonJob::helper()
|
||||
{
|
||||
auto ptr = CalamaresPython::Helper::s_instance;
|
||||
if ( !ptr )
|
||||
{
|
||||
ptr = new CalamaresPython::Helper;
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Calamares
|
||||
|
@ -53,11 +53,12 @@ public:
|
||||
virtual qreal getJobWeight() const override;
|
||||
|
||||
private:
|
||||
friend class CalamaresPython::Helper;
|
||||
struct Private;
|
||||
|
||||
friend class CalamaresPython::PythonJobInterface;
|
||||
void emitProgress( double progressValue );
|
||||
|
||||
CalamaresPython::Helper* helper();
|
||||
std::unique_ptr< Private > m_d;
|
||||
QString m_scriptFile;
|
||||
QString m_workingPath;
|
||||
QString m_description;
|
||||
|
@ -171,7 +171,7 @@ PythonJobInterface::PythonJobInterface( Calamares::PythonJob* parent )
|
||||
void
|
||||
PythonJobInterface::setprogress( qreal progress )
|
||||
{
|
||||
if ( progress >= 0 && progress <= 1 )
|
||||
if ( progress >= 0.0 && progress <= 1.0 )
|
||||
{
|
||||
m_parent->emitProgress( progress );
|
||||
}
|
||||
|
@ -26,14 +26,8 @@
|
||||
#include "JobQueue.h"
|
||||
|
||||
#include <QDir>
|
||||
// #include <QTemporaryFile>
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
// #include <fcntl.h>
|
||||
// #include <sys/stat.h>
|
||||
// #include <unistd.h>
|
||||
|
||||
class TestPaths : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -25,9 +25,9 @@
|
||||
|
||||
#include "ImageRegistry.h"
|
||||
|
||||
#include <QIcon>
|
||||
#include <QPainter>
|
||||
#include <QSvgRenderer>
|
||||
#include <qicon.h>
|
||||
|
||||
static QHash< QString, QHash< int, QHash< qint64, QPixmap > > > s_cache;
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
#ifndef EXECUTIONVIEWSTEP_H
|
||||
#define EXECUTIONVIEWSTEP_H
|
||||
|
||||
#include <viewpages/ViewStep.h>
|
||||
#include "ViewStep.h"
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
|
@ -23,11 +23,11 @@
|
||||
#include <QObject>
|
||||
#include <QVariantMap>
|
||||
|
||||
#include <CppJob.h>
|
||||
#include "CppJob.h"
|
||||
|
||||
#include <utils/PluginFactory.h>
|
||||
#include "utils/PluginFactory.h"
|
||||
|
||||
#include <DllMacro.h>
|
||||
#include "DllMacro.h"
|
||||
|
||||
class PLUGINDLLEXPORT DracutLuksCfgJob : public Calamares::CppJob
|
||||
{
|
||||
|
@ -23,11 +23,11 @@
|
||||
#include <QObject>
|
||||
#include <QVariantMap>
|
||||
|
||||
#include <CppJob.h>
|
||||
#include "CppJob.h"
|
||||
|
||||
#include <utils/PluginFactory.h>
|
||||
#include "utils/PluginFactory.h"
|
||||
|
||||
#include <DllMacro.h>
|
||||
#include "DllMacro.h"
|
||||
|
||||
class PLUGINDLLEXPORT DummyCppJob : public Calamares::CppJob
|
||||
{
|
||||
|
@ -43,6 +43,10 @@ _ = gettext.translation("calamares-python",
|
||||
def pretty_name():
|
||||
return _("Dummy python job.")
|
||||
|
||||
status = _("Dummy python step {}").format(0)
|
||||
|
||||
def pretty_status_message():
|
||||
return status
|
||||
|
||||
def run():
|
||||
"""Dummy python job."""
|
||||
@ -92,8 +96,10 @@ def run():
|
||||
except KeyError:
|
||||
configlist = ["no list"]
|
||||
|
||||
global status
|
||||
c = 1
|
||||
for k in configlist:
|
||||
status = _("Dummy python step {}").format(str(c) + ":" + repr(k))
|
||||
libcalamares.utils.debug(_("Dummy python step {}").format(str(k)))
|
||||
sleep(1)
|
||||
libcalamares.job.setprogress(c * 1.0 / len(configlist))
|
||||
|
@ -22,13 +22,13 @@
|
||||
#include <QObject>
|
||||
#include <QVariantMap>
|
||||
|
||||
#include <CppJob.h>
|
||||
#include "CppJob.h"
|
||||
|
||||
#include "partition/KPMManager.h"
|
||||
#include "partition/PartitionSize.h"
|
||||
#include "utils/PluginFactory.h"
|
||||
|
||||
#include <DllMacro.h>
|
||||
#include "DllMacro.h"
|
||||
|
||||
class CoreBackend; // From KPMCore
|
||||
class Device; // From KPMCore
|
||||
|
@ -23,9 +23,9 @@
|
||||
#include "utils/CalamaresUtilsGui.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
#include <KF5/KService/kservice.h>
|
||||
#include <KF5/KParts/kde_terminal_interface.h>
|
||||
#include <KF5/KParts/kparts/readonlypart.h>
|
||||
#include <KService>
|
||||
#include <KParts/kde_terminal_interface.h>
|
||||
#include <KParts/ReadOnlyPart>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
|
@ -22,10 +22,10 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <utils/PluginFactory.h>
|
||||
#include <viewpages/ViewStep.h>
|
||||
#include "utils/PluginFactory.h"
|
||||
#include "viewpages/ViewStep.h"
|
||||
|
||||
#include <DllMacro.h>
|
||||
#include "DllMacro.h"
|
||||
|
||||
class InteractiveTerminalPage;
|
||||
|
||||
|
@ -22,10 +22,10 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <utils/PluginFactory.h>
|
||||
#include <viewpages/ViewStep.h>
|
||||
#include "utils/PluginFactory.h"
|
||||
#include "viewpages/ViewStep.h"
|
||||
|
||||
#include <DllMacro.h>
|
||||
#include "DllMacro.h"
|
||||
|
||||
class KeyboardPage;
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <SetKeyboardLayoutJob.h>
|
||||
#include "SetKeyboardLayoutJob.h"
|
||||
|
||||
#include "JobQueue.h"
|
||||
#include "GlobalStorage.h"
|
||||
|
@ -20,7 +20,7 @@
|
||||
#ifndef SETKEYBOARDLAYOUTJOB_H
|
||||
#define SETKEYBOARDLAYOUTJOB_H
|
||||
|
||||
#include <Job.h>
|
||||
#include "Job.h"
|
||||
|
||||
|
||||
class SetKeyboardLayoutJob : public Calamares::Job
|
||||
|
@ -20,9 +20,9 @@
|
||||
#ifndef LICENSEPAGEPLUGIN_H
|
||||
#define LICENSEPAGEPLUGIN_H
|
||||
|
||||
#include <DllMacro.h>
|
||||
#include <utils/PluginFactory.h>
|
||||
#include <viewpages/ViewStep.h>
|
||||
#include "DllMacro.h"
|
||||
#include "utils/PluginFactory.h"
|
||||
#include "viewpages/ViewStep.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QUrl>
|
||||
|
@ -17,7 +17,7 @@
|
||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <SetTimezoneJob.h>
|
||||
#include "SetTimezoneJob.h"
|
||||
|
||||
#include "GlobalStorage.h"
|
||||
#include "JobQueue.h"
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef SETTIMEZONEJOB_H
|
||||
#define SETTIMEZONEJOB_H
|
||||
|
||||
#include <Job.h>
|
||||
#include "Job.h"
|
||||
|
||||
|
||||
class SetTimezoneJob : public Calamares::Job
|
||||
|
@ -22,11 +22,11 @@
|
||||
#include <QObject>
|
||||
#include <QVariantMap>
|
||||
|
||||
#include <CppJob.h>
|
||||
#include "CppJob.h"
|
||||
|
||||
#include <utils/PluginFactory.h>
|
||||
#include "utils/PluginFactory.h"
|
||||
|
||||
#include <DllMacro.h>
|
||||
#include "DllMacro.h"
|
||||
|
||||
class PLUGINDLLEXPORT MachineIdJob : public Calamares::CppJob
|
||||
{
|
||||
|
@ -19,10 +19,10 @@
|
||||
#ifndef OEMVIEWSTEP_H
|
||||
#define OEMVIEWSTEP_H
|
||||
|
||||
#include <utils/PluginFactory.h>
|
||||
#include <viewpages/ViewStep.h>
|
||||
#include "utils/PluginFactory.h"
|
||||
#include "viewpages/ViewStep.h"
|
||||
|
||||
#include <DllMacro.h>
|
||||
#include "DllMacro.h"
|
||||
|
||||
#include <QVariantMap>
|
||||
|
||||
|
@ -56,6 +56,10 @@ def _change_mode(mode):
|
||||
|
||||
|
||||
def pretty_name():
|
||||
return _("Install packages.")
|
||||
|
||||
|
||||
def pretty_status_message():
|
||||
if not group_packages:
|
||||
if (total_packages > 0):
|
||||
# Outside the context of an operation
|
||||
@ -332,19 +336,23 @@ class PMDummy(PackageManager):
|
||||
backend = "dummy"
|
||||
|
||||
def install(self, pkgs, from_local=False):
|
||||
libcalamares.utils.debug("Installing " + str(pkgs))
|
||||
from time import sleep
|
||||
libcalamares.utils.debug("Dummy backend: Installing " + str(pkgs))
|
||||
sleep(3)
|
||||
|
||||
def remove(self, pkgs):
|
||||
libcalamares.utils.debug("Removing " + str(pkgs))
|
||||
from time import sleep
|
||||
libcalamares.utils.debug("Dummy backend: Removing " + str(pkgs))
|
||||
sleep(3)
|
||||
|
||||
def update_db(self):
|
||||
libcalamares.utils.debug("Updating DB")
|
||||
libcalamares.utils.debug("Dummy backend: Updating DB")
|
||||
|
||||
def update_system(self):
|
||||
libcalamares.utils.debug("Updating System")
|
||||
libcalamares.utils.debug("Dummy backend: Updating System")
|
||||
|
||||
def run(self, script):
|
||||
libcalamares.utils.debug("Running script '" + str(script) + "'")
|
||||
libcalamares.utils.debug("Dummy backend: Running script '" + str(script) + "'")
|
||||
|
||||
|
||||
class PMPisi(PackageManager):
|
||||
@ -502,7 +510,7 @@ def run_operations(pkgman, entry):
|
||||
libcalamares.utils.warning("Unknown package-operation key {!s}".format(key))
|
||||
completed_packages += len(package_list)
|
||||
libcalamares.job.setprogress(completed_packages * 1.0 / total_packages)
|
||||
libcalamares.utils.debug(pretty_name())
|
||||
libcalamares.utils.debug("Pretty name: {!s}, setting progress..".format(pretty_name()))
|
||||
|
||||
group_packages = 0
|
||||
_change_mode(None)
|
||||
|
@ -587,19 +587,19 @@ ChoicePage::doAlongsideSetupSplitter( const QModelIndex& current,
|
||||
void
|
||||
ChoicePage::onEncryptWidgetStateChanged()
|
||||
{
|
||||
EncryptWidget::State state = m_encryptWidget->state();
|
||||
EncryptWidget::Encryption state = m_encryptWidget->state();
|
||||
if ( m_choice == Erase )
|
||||
{
|
||||
if ( state == EncryptWidget::EncryptionConfirmed ||
|
||||
state == EncryptWidget::EncryptionDisabled )
|
||||
if ( state == EncryptWidget::Encryption::Confirmed ||
|
||||
state == EncryptWidget::Encryption::Disabled )
|
||||
applyActionChoice( m_choice );
|
||||
}
|
||||
else if ( m_choice == Replace )
|
||||
{
|
||||
if ( m_beforePartitionBarsView &&
|
||||
m_beforePartitionBarsView->selectionModel()->currentIndex().isValid() &&
|
||||
( state == EncryptWidget::EncryptionConfirmed ||
|
||||
state == EncryptWidget::EncryptionDisabled ) )
|
||||
( state == EncryptWidget::Encryption::Confirmed ||
|
||||
state == EncryptWidget::Encryption::Disabled ) )
|
||||
{
|
||||
doReplaceSelectedPartition( m_beforePartitionBarsView->
|
||||
selectionModel()->
|
||||
@ -1474,7 +1474,7 @@ ChoicePage::updateNextEnabled()
|
||||
|
||||
if ( m_choice != Manual &&
|
||||
m_encryptWidget->isVisible() &&
|
||||
m_encryptWidget->state() == EncryptWidget::EncryptionUnconfirmed )
|
||||
m_encryptWidget->state() == EncryptWidget::Encryption::Unconfirmed )
|
||||
enabled = false;
|
||||
|
||||
if ( enabled == m_nextEnabled )
|
||||
|
@ -204,7 +204,7 @@ CreatePartitionDialog::createPartition()
|
||||
|
||||
Partition* partition = nullptr;
|
||||
QString luksPassphrase = m_ui->encryptWidget->passphrase();
|
||||
if ( m_ui->encryptWidget->state() == EncryptWidget::EncryptionConfirmed &&
|
||||
if ( m_ui->encryptWidget->state() == EncryptWidget::Encryption::Confirmed &&
|
||||
!luksPassphrase.isEmpty() )
|
||||
{
|
||||
partition = KPMHelpers::createNewEncryptedPartition(
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2016, Teo Mrnjavac <teo@kde.org>
|
||||
* Copyright 2020, 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
|
||||
@ -19,42 +20,45 @@
|
||||
|
||||
#include "EncryptWidget.h"
|
||||
|
||||
#include <utils/CalamaresUtilsGui.h>
|
||||
#include "ui_EncryptWidget.h"
|
||||
|
||||
#include "utils/CalamaresUtilsGui.h"
|
||||
#include "utils/Retranslator.h"
|
||||
|
||||
EncryptWidget::EncryptWidget( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, m_state( EncryptionDisabled )
|
||||
, m_ui( new Ui::EncryptWidget )
|
||||
, m_state( Encryption::Disabled )
|
||||
{
|
||||
setupUi( this );
|
||||
m_ui->setupUi( this );
|
||||
|
||||
m_iconLabel->setFixedWidth( m_iconLabel->height() );
|
||||
m_passphraseLineEdit->hide();
|
||||
m_confirmLineEdit->hide();
|
||||
m_iconLabel->hide();
|
||||
m_ui->m_iconLabel->setFixedWidth( m_ui->m_iconLabel->height() );
|
||||
m_ui->m_passphraseLineEdit->hide();
|
||||
m_ui->m_confirmLineEdit->hide();
|
||||
m_ui->m_iconLabel->hide();
|
||||
|
||||
connect( m_encryptCheckBox, &QCheckBox::stateChanged,
|
||||
this, &EncryptWidget::onCheckBoxStateChanged );
|
||||
connect( m_passphraseLineEdit, &QLineEdit::textEdited,
|
||||
this, &EncryptWidget::onPassphraseEdited );
|
||||
connect( m_confirmLineEdit, &QLineEdit::textEdited,
|
||||
this, &EncryptWidget::onPassphraseEdited );
|
||||
connect( m_ui->m_encryptCheckBox, &QCheckBox::stateChanged, this, &EncryptWidget::onCheckBoxStateChanged );
|
||||
connect( m_ui->m_passphraseLineEdit, &QLineEdit::textEdited, this, &EncryptWidget::onPassphraseEdited );
|
||||
connect( m_ui->m_confirmLineEdit, &QLineEdit::textEdited, this, &EncryptWidget::onPassphraseEdited );
|
||||
|
||||
setFixedHeight( m_passphraseLineEdit->height() ); // Avoid jumping up and down
|
||||
setFixedHeight( m_ui->m_passphraseLineEdit->height() ); // Avoid jumping up and down
|
||||
updateState();
|
||||
|
||||
CALAMARES_RETRANSLATE_SLOT( &EncryptWidget::retranslate )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
EncryptWidget::reset()
|
||||
{
|
||||
m_passphraseLineEdit->clear();
|
||||
m_confirmLineEdit->clear();
|
||||
m_ui->m_passphraseLineEdit->clear();
|
||||
m_ui->m_confirmLineEdit->clear();
|
||||
|
||||
m_encryptCheckBox->setChecked( false );
|
||||
m_ui->m_encryptCheckBox->setChecked( false );
|
||||
}
|
||||
|
||||
|
||||
EncryptWidget::State
|
||||
EncryptWidget::Encryption
|
||||
EncryptWidget::state() const
|
||||
{
|
||||
return m_state;
|
||||
@ -64,53 +68,48 @@ EncryptWidget::state() const
|
||||
void
|
||||
EncryptWidget::setText( const QString& text )
|
||||
{
|
||||
m_encryptCheckBox->setText( text );
|
||||
m_ui->m_encryptCheckBox->setText( text );
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
EncryptWidget::passphrase() const
|
||||
{
|
||||
if ( m_state == EncryptionConfirmed )
|
||||
return m_passphraseLineEdit->text();
|
||||
if ( m_state == Encryption::Confirmed )
|
||||
{
|
||||
return m_ui->m_passphraseLineEdit->text();
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
EncryptWidget::changeEvent( QEvent* e )
|
||||
EncryptWidget::retranslate()
|
||||
{
|
||||
QWidget::changeEvent( e );
|
||||
switch ( e->type() )
|
||||
{
|
||||
case QEvent::LanguageChange:
|
||||
retranslateUi( this );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
m_ui->retranslateUi( this );
|
||||
onPassphraseEdited(); // For the tooltip
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
EncryptWidget::updateState()
|
||||
{
|
||||
State newState;
|
||||
if ( m_encryptCheckBox->isChecked() )
|
||||
Encryption newState;
|
||||
if ( m_ui->m_encryptCheckBox->isChecked() )
|
||||
{
|
||||
if ( !m_passphraseLineEdit->text().isEmpty() &&
|
||||
m_passphraseLineEdit->text() == m_confirmLineEdit->text() )
|
||||
if ( !m_ui->m_passphraseLineEdit->text().isEmpty()
|
||||
&& m_ui->m_passphraseLineEdit->text() == m_ui->m_confirmLineEdit->text() )
|
||||
{
|
||||
newState = EncryptionConfirmed;
|
||||
newState = Encryption::Confirmed;
|
||||
}
|
||||
else
|
||||
{
|
||||
newState = EncryptionUnconfirmed;
|
||||
newState = Encryption::Unconfirmed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newState = EncryptionDisabled;
|
||||
newState = Encryption::Disabled;
|
||||
}
|
||||
|
||||
if ( newState != m_state )
|
||||
@ -120,35 +119,38 @@ EncryptWidget::updateState()
|
||||
}
|
||||
}
|
||||
|
||||
///@brief Give @p label the @p pixmap from the standard-pixmaps
|
||||
static void
|
||||
applyPixmap( QLabel* label, CalamaresUtils::ImageType pixmap )
|
||||
{
|
||||
label->setFixedWidth( label->height() );
|
||||
label->setPixmap( CalamaresUtils::defaultPixmap( pixmap, CalamaresUtils::Original, label->size() ) );
|
||||
}
|
||||
|
||||
void
|
||||
EncryptWidget::onPassphraseEdited()
|
||||
{
|
||||
if ( !m_iconLabel->isVisible() )
|
||||
m_iconLabel->show();
|
||||
if ( !m_ui->m_iconLabel->isVisible() )
|
||||
{
|
||||
m_ui->m_iconLabel->show();
|
||||
}
|
||||
|
||||
QString p1 = m_passphraseLineEdit->text();
|
||||
QString p2 = m_confirmLineEdit->text();
|
||||
QString p1 = m_ui->m_passphraseLineEdit->text();
|
||||
QString p2 = m_ui->m_confirmLineEdit->text();
|
||||
|
||||
m_iconLabel->setToolTip( QString() );
|
||||
m_ui->m_iconLabel->setToolTip( QString() );
|
||||
if ( p1.isEmpty() && p2.isEmpty() )
|
||||
{
|
||||
m_iconLabel->clear();
|
||||
m_ui->m_iconLabel->clear();
|
||||
}
|
||||
else if ( p1 == p2 )
|
||||
{
|
||||
m_iconLabel->setFixedWidth( m_iconLabel->height() );
|
||||
m_iconLabel->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::Yes,
|
||||
CalamaresUtils::Original,
|
||||
m_iconLabel->size() ) );
|
||||
applyPixmap( m_ui->m_iconLabel, CalamaresUtils::Yes );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_iconLabel->setFixedWidth( m_iconLabel->height() );
|
||||
m_iconLabel->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::No,
|
||||
CalamaresUtils::Original,
|
||||
m_iconLabel->size() ) );
|
||||
m_iconLabel->setToolTip( tr( "Please enter the same passphrase in both boxes." ) );
|
||||
applyPixmap( m_ui->m_iconLabel, CalamaresUtils::No );
|
||||
m_ui->m_iconLabel->setToolTip( tr( "Please enter the same passphrase in both boxes." ) );
|
||||
}
|
||||
|
||||
updateState();
|
||||
@ -156,14 +158,15 @@ EncryptWidget::onPassphraseEdited()
|
||||
|
||||
|
||||
void
|
||||
EncryptWidget::onCheckBoxStateChanged( int state )
|
||||
EncryptWidget::onCheckBoxStateChanged( int checked )
|
||||
{
|
||||
m_passphraseLineEdit->setVisible( state );
|
||||
m_confirmLineEdit->setVisible( state );
|
||||
m_iconLabel->setVisible( state );
|
||||
m_passphraseLineEdit->clear();
|
||||
m_confirmLineEdit->clear();
|
||||
m_iconLabel->clear();
|
||||
// @p checked is a Qt::CheckState, 0 is "unchecked" and 2 is "checked"
|
||||
m_ui->m_passphraseLineEdit->setVisible( checked );
|
||||
m_ui->m_confirmLineEdit->setVisible( checked );
|
||||
m_ui->m_iconLabel->setVisible( checked );
|
||||
m_ui->m_passphraseLineEdit->clear();
|
||||
m_ui->m_confirmLineEdit->clear();
|
||||
m_ui->m_iconLabel->clear();
|
||||
|
||||
updateState();
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2016, Teo Mrnjavac <teo@kde.org>
|
||||
* Copyright 2020, 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
|
||||
@ -20,41 +21,46 @@
|
||||
#ifndef ENCRYPTWIDGET_H
|
||||
#define ENCRYPTWIDGET_H
|
||||
|
||||
#include "ui_EncryptWidget.h"
|
||||
#include <QWidget>
|
||||
|
||||
class EncryptWidget : public QWidget, private Ui::EncryptWidget
|
||||
namespace Ui
|
||||
{
|
||||
class EncryptWidget;
|
||||
}
|
||||
|
||||
class EncryptWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum State : unsigned short
|
||||
enum class Encryption : unsigned short
|
||||
{
|
||||
EncryptionDisabled = 0,
|
||||
EncryptionUnconfirmed,
|
||||
EncryptionConfirmed
|
||||
Disabled = 0,
|
||||
Unconfirmed,
|
||||
Confirmed
|
||||
};
|
||||
|
||||
explicit EncryptWidget( QWidget* parent = nullptr );
|
||||
|
||||
void reset();
|
||||
|
||||
State state() const;
|
||||
Encryption state() const;
|
||||
void setText( const QString& text );
|
||||
|
||||
QString passphrase() const;
|
||||
|
||||
signals:
|
||||
void stateChanged( State );
|
||||
void retranslate();
|
||||
|
||||
protected:
|
||||
void changeEvent( QEvent* e );
|
||||
signals:
|
||||
void stateChanged( Encryption );
|
||||
|
||||
private:
|
||||
void updateState();
|
||||
void onPassphraseEdited();
|
||||
void onCheckBoxStateChanged( int state );
|
||||
void onCheckBoxStateChanged( int checked );
|
||||
|
||||
State m_state;
|
||||
Ui::EncryptWidget* m_ui;
|
||||
Encryption m_state;
|
||||
};
|
||||
|
||||
#endif // ENCRYPTWIDGET_H
|
||||
|
@ -18,16 +18,14 @@
|
||||
*/
|
||||
#include "gui/PartitionBarsView.h"
|
||||
|
||||
#include <core/PartitionModel.h>
|
||||
#include <core/ColorUtils.h>
|
||||
#include "core/PartitionModel.h"
|
||||
#include "core/ColorUtils.h"
|
||||
|
||||
#include "utils/CalamaresUtilsGui.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
#include <kpmcore/core/device.h>
|
||||
|
||||
#include <utils/CalamaresUtilsGui.h>
|
||||
#include <utils/Logger.h>
|
||||
|
||||
|
||||
// Qt
|
||||
#include <QDebug>
|
||||
#include <QGuiApplication>
|
||||
#include <QMouseEvent>
|
||||
|
@ -21,10 +21,10 @@
|
||||
#ifndef PARTITIONVIEWSTEP_H
|
||||
#define PARTITIONVIEWSTEP_H
|
||||
|
||||
#include <utils/PluginFactory.h>
|
||||
#include <viewpages/ViewStep.h>
|
||||
#include "utils/PluginFactory.h"
|
||||
#include "viewpages/ViewStep.h"
|
||||
|
||||
#include <DllMacro.h>
|
||||
#include "DllMacro.h"
|
||||
|
||||
#include "core/PartitionActions.h"
|
||||
|
||||
|
@ -18,23 +18,21 @@
|
||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <PartitionJobTests.h>
|
||||
#include "PartitionJobTests.h"
|
||||
|
||||
#include "core/KPMHelpers.h"
|
||||
#include "jobs/CreatePartitionJob.h"
|
||||
#include "jobs/CreatePartitionTableJob.h"
|
||||
#include "jobs/ResizePartitionJob.h"
|
||||
|
||||
#include "partition/KPMManager.h"
|
||||
#include "partition/PartitionQuery.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/Units.h"
|
||||
|
||||
#include <core/KPMHelpers.h>
|
||||
#include <jobs/CreatePartitionJob.h>
|
||||
#include <jobs/CreatePartitionTableJob.h>
|
||||
#include <jobs/ResizePartitionJob.h>
|
||||
|
||||
// CalaPM
|
||||
#include <backend/corebackend.h>
|
||||
#include <fs/filesystemfactory.h>
|
||||
|
||||
// Qt
|
||||
#include <QEventLoop>
|
||||
#include <QProcess>
|
||||
#include <QtTest/QtTest>
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef PARTITIONJOBTESTS_H
|
||||
#define PARTITIONJOBTESTS_H
|
||||
|
||||
#include <JobQueue.h>
|
||||
#include "JobQueue.h"
|
||||
|
||||
// CalaPM
|
||||
#include <core/device.h>
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <QObject>
|
||||
#include <QVariantMap>
|
||||
|
||||
#include <Job.h>
|
||||
#include "Job.h"
|
||||
|
||||
class PlasmaLnfJob : public Calamares::Job
|
||||
{
|
||||
|
@ -19,9 +19,9 @@
|
||||
#ifndef PLASMALNFVIEWSTEP_H
|
||||
#define PLASMALNFVIEWSTEP_H
|
||||
|
||||
#include <utils/PluginFactory.h>
|
||||
#include <viewpages/ViewStep.h>
|
||||
#include <DllMacro.h>
|
||||
#include "utils/PluginFactory.h"
|
||||
#include "viewpages/ViewStep.h"
|
||||
#include "DllMacro.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QUrl>
|
||||
|
@ -21,10 +21,10 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <utils/PluginFactory.h>
|
||||
#include <viewpages/ViewStep.h>
|
||||
#include "utils/PluginFactory.h"
|
||||
#include "viewpages/ViewStep.h"
|
||||
|
||||
#include <DllMacro.h>
|
||||
#include "DllMacro.h"
|
||||
|
||||
class SummaryPage;
|
||||
|
||||
|
@ -21,9 +21,9 @@
|
||||
|
||||
#include "TrackingType.h"
|
||||
|
||||
#include <DllMacro.h>
|
||||
#include <utils/PluginFactory.h>
|
||||
#include <viewpages/ViewStep.h>
|
||||
#include "DllMacro.h"
|
||||
#include "utils/PluginFactory.h"
|
||||
#include "viewpages/ViewStep.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QUrl>
|
||||
|
@ -17,7 +17,7 @@
|
||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <CreateUserJob.h>
|
||||
#include "CreateUserJob.h"
|
||||
|
||||
#include "GlobalStorage.h"
|
||||
#include "JobQueue.h"
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef CREATEUSERJOB_H
|
||||
#define CREATEUSERJOB_H
|
||||
|
||||
#include <Job.h>
|
||||
#include "Job.h"
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#ifndef SETHOSTNAMEJOB_CPP_H
|
||||
#define SETHOSTNAMEJOB_CPP_H
|
||||
|
||||
#include <Job.h>
|
||||
#include "Job.h"
|
||||
|
||||
class SetHostNameJob : public Calamares::Job
|
||||
{
|
||||
|
@ -17,7 +17,7 @@
|
||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <SetPasswordJob.h>
|
||||
#include "SetPasswordJob.h"
|
||||
|
||||
#include "GlobalStorage.h"
|
||||
#include "JobQueue.h"
|
||||
|
@ -20,7 +20,7 @@
|
||||
#ifndef SETPASSWORDJOB_H
|
||||
#define SETPASSWORDJOB_H
|
||||
|
||||
#include <Job.h>
|
||||
#include "Job.h"
|
||||
|
||||
|
||||
class SetPasswordJob : public Calamares::Job
|
||||
|
@ -23,10 +23,10 @@
|
||||
|
||||
#include "WebViewConfig.h"
|
||||
|
||||
#include <utils/PluginFactory.h>
|
||||
#include <viewpages/ViewStep.h>
|
||||
#include "utils/PluginFactory.h"
|
||||
#include "viewpages/ViewStep.h"
|
||||
|
||||
#include <DllMacro.h>
|
||||
#include "DllMacro.h"
|
||||
|
||||
#include <QVariantMap>
|
||||
|
||||
|
@ -19,14 +19,11 @@
|
||||
#ifndef WELCOMEPAGEPLUGIN_H
|
||||
#define WELCOMEPAGEPLUGIN_H
|
||||
|
||||
#include "DllMacro.h"
|
||||
#include "utils/PluginFactory.h"
|
||||
#include "viewpages/ViewStep.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <modulesystem/Requirement.h>
|
||||
#include <utils/PluginFactory.h>
|
||||
#include <viewpages/ViewStep.h>
|
||||
|
||||
#include <DllMacro.h>
|
||||
|
||||
#include <QVariantMap>
|
||||
|
||||
class WelcomePage;
|
||||
|
Loading…
Reference in New Issue
Block a user