[finished] Chase Branding API change
- while here, also apply coding style
This commit is contained in:
parent
dc1a4fab8e
commit
da82adeeee
@ -20,12 +20,12 @@
|
||||
|
||||
#include "FinishedPage.h"
|
||||
|
||||
#include "ui_FinishedPage.h"
|
||||
#include "CalamaresVersion.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/CalamaresUtilsGui.h"
|
||||
#include "utils/Retranslator.h"
|
||||
#include "ViewManager.h"
|
||||
#include "ui_FinishedPage.h"
|
||||
#include "utils/CalamaresUtilsGui.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/Retranslator.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QBoxLayout>
|
||||
@ -48,33 +48,29 @@ FinishedPage::FinishedPage( QWidget* parent )
|
||||
ui->mainText->setOpenExternalLinks( true );
|
||||
|
||||
CALAMARES_RETRANSLATE(
|
||||
ui->retranslateUi( this );
|
||||
if ( Calamares::Settings::instance()->isSetupMode() )
|
||||
{
|
||||
const auto* branding = Calamares::Branding::instance(); ui->retranslateUi( this );
|
||||
if ( Calamares::Settings::instance()->isSetupMode() ) {
|
||||
ui->mainText->setText( tr( "<h1>All done.</h1><br/>"
|
||||
"%1 has been set up on your computer.<br/>"
|
||||
"You may now start using your new system." )
|
||||
.arg( *Calamares::Branding::VersionedName ) );
|
||||
.arg( branding->versionedName() ) );
|
||||
ui->restartCheckBox->setToolTip( tr( "<html><head/><body>"
|
||||
"<p>When this box is checked, your system will "
|
||||
"restart immediately when you click on "
|
||||
"<span style=\"font-style:italic;\">Done</span> "
|
||||
"or close the setup program.</p></body></html>" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ui->mainText->setText( tr( "<h1>All done.</h1><br/>"
|
||||
"%1 has been installed on your computer.<br/>"
|
||||
"You may now restart into your new system, or continue "
|
||||
"using the %2 Live environment." )
|
||||
.arg( *Calamares::Branding::VersionedName, *Calamares::Branding::ProductName ) );
|
||||
.arg( branding->versionedName(), branding->productName() ) );
|
||||
ui->restartCheckBox->setToolTip( tr( "<html><head/><body>"
|
||||
"<p>When this box is checked, your system will "
|
||||
"restart immediately when you click on "
|
||||
"<span style=\"font-style:italic;\">Done</span> "
|
||||
"or close the installer.</p></body></html>" ) );
|
||||
}
|
||||
)
|
||||
} )
|
||||
}
|
||||
|
||||
|
||||
@ -102,20 +98,15 @@ void
|
||||
FinishedPage::setUpRestart()
|
||||
{
|
||||
cDebug() << "FinishedPage::setUpRestart(), Quit button"
|
||||
<< "setup=" << FinishedViewStep::modeName( m_mode )
|
||||
<< "command=" << m_restartNowCommand;
|
||||
<< "setup=" << FinishedViewStep::modeName( m_mode ) << "command=" << m_restartNowCommand;
|
||||
|
||||
connect( qApp, &QApplication::aboutToQuit,
|
||||
[this]()
|
||||
{
|
||||
if ( ui->restartCheckBox->isVisible() &&
|
||||
ui->restartCheckBox->isChecked() )
|
||||
connect( qApp, &QApplication::aboutToQuit, [ this ]() {
|
||||
if ( ui->restartCheckBox->isVisible() && ui->restartCheckBox->isChecked() )
|
||||
{
|
||||
cDebug() << "Running restart command" << m_restartNowCommand;
|
||||
QProcess::execute( "/bin/sh", { "-c", m_restartNowCommand } );
|
||||
}
|
||||
}
|
||||
);
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
@ -128,18 +119,19 @@ FinishedPage::focusInEvent( QFocusEvent* e )
|
||||
void
|
||||
FinishedPage::onInstallationFailed( const QString& message, const QString& details )
|
||||
{
|
||||
const auto* branding = Calamares::Branding::instance();
|
||||
Q_UNUSED( details )
|
||||
if ( Calamares::Settings::instance()->isSetupMode() )
|
||||
ui->mainText->setText( tr( "<h1>Setup Failed</h1><br/>"
|
||||
"%1 has not been set up on your computer.<br/>"
|
||||
"The error message was: %2." )
|
||||
.arg( *Calamares::Branding::VersionedName )
|
||||
.arg( branding->versionedName() )
|
||||
.arg( message ) );
|
||||
else
|
||||
ui->mainText->setText( tr( "<h1>Installation Failed</h1><br/>"
|
||||
"%1 has not been installed on your computer.<br/>"
|
||||
"The error message was: %2." )
|
||||
.arg( *Calamares::Branding::VersionedName )
|
||||
.arg( branding->versionedName() )
|
||||
.arg( message ) );
|
||||
setRestart( FinishedViewStep::RestartMode::Never );
|
||||
}
|
||||
|
@ -29,22 +29,20 @@
|
||||
#include "utils/NamedEnum.h"
|
||||
#include "utils/Variant.h"
|
||||
|
||||
#include <QVariantMap>
|
||||
#include <QtDBus/QDBusConnection>
|
||||
#include <QtDBus/QDBusInterface>
|
||||
#include <QtDBus/QDBusReply>
|
||||
#include <QVariantMap>
|
||||
|
||||
static const NamedEnumTable< FinishedViewStep::RestartMode >&
|
||||
modeNames()
|
||||
{
|
||||
using Mode = FinishedViewStep::RestartMode;
|
||||
|
||||
static const NamedEnumTable< Mode > names{
|
||||
{ QStringLiteral( "never" ), Mode::Never },
|
||||
static const NamedEnumTable< Mode > names { { QStringLiteral( "never" ), Mode::Never },
|
||||
{ QStringLiteral( "user-unchecked" ), Mode::UserUnchecked },
|
||||
{ QStringLiteral( "user-checked" ), Mode::UserChecked },
|
||||
{ QStringLiteral( "always" ), Mode::Always }
|
||||
} ;
|
||||
{ QStringLiteral( "always" ), Mode::Always } };
|
||||
|
||||
return names;
|
||||
}
|
||||
@ -56,10 +54,8 @@ FinishedViewStep::FinishedViewStep( QObject* parent )
|
||||
, m_notifyOnFinished( false )
|
||||
{
|
||||
auto jq = Calamares::JobQueue::instance();
|
||||
connect( jq, &Calamares::JobQueue::failed,
|
||||
m_widget, &FinishedPage::onInstallationFailed );
|
||||
connect( jq, &Calamares::JobQueue::failed,
|
||||
this, &FinishedViewStep::onInstallationFailed );
|
||||
connect( jq, &Calamares::JobQueue::failed, m_widget, &FinishedPage::onInstallationFailed );
|
||||
connect( jq, &Calamares::JobQueue::failed, this, &FinishedViewStep::onInstallationFailed );
|
||||
|
||||
emit nextStatusChanged( true );
|
||||
}
|
||||
@ -68,8 +64,10 @@ FinishedViewStep::FinishedViewStep( QObject* parent )
|
||||
FinishedViewStep::~FinishedViewStep()
|
||||
{
|
||||
if ( m_widget && m_widget->parent() == nullptr )
|
||||
{
|
||||
m_widget->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
@ -119,31 +117,37 @@ FinishedViewStep::sendNotification()
|
||||
// If the installation failed, don't send notification popup;
|
||||
// there's a (modal) dialog popped up with the failure notice.
|
||||
if ( installFailed )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QDBusInterface notify( "org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications" );
|
||||
QDBusInterface notify(
|
||||
"org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications" );
|
||||
if ( notify.isValid() )
|
||||
{
|
||||
QDBusReply<uint> r = notify.call( "Notify",
|
||||
const auto* branding = Calamares::Branding::instance();
|
||||
QDBusReply< uint > r = notify.call(
|
||||
"Notify",
|
||||
QString( "Calamares" ),
|
||||
QVariant( 0U ),
|
||||
QString( "calamares" ),
|
||||
Calamares::Settings::instance()->isSetupMode() ? tr( "Setup Complete" ) : tr( "Installation Complete" ),
|
||||
Calamares::Settings::instance()->isSetupMode()
|
||||
? tr( "Setup Complete" )
|
||||
: tr( "Installation Complete" ),
|
||||
Calamares::Settings::instance()->isSetupMode()
|
||||
? tr( "The setup of %1 is complete." ).arg( *Calamares::Branding::VersionedName )
|
||||
: tr( "The installation of %1 is complete." ).arg( *Calamares::Branding::VersionedName ),
|
||||
? tr( "The setup of %1 is complete." ).arg( branding->versionedName() )
|
||||
: tr( "The installation of %1 is complete." ).arg( branding->versionedName() ),
|
||||
QStringList(),
|
||||
QVariantMap(),
|
||||
QVariant( 0 )
|
||||
);
|
||||
QVariant( 0 ) );
|
||||
if ( !r.isValid() )
|
||||
{
|
||||
cWarning() << "Could not call org.freedesktop.Notifications.Notify at end of installation." << r.error();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cWarning() << "Could not get dbus interface for notifications at end of installation." << notify.lastError();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
@ -152,8 +156,10 @@ FinishedViewStep::onActivate()
|
||||
m_widget->setUpRestart();
|
||||
|
||||
if ( m_notifyOnFinished )
|
||||
{
|
||||
sendNotification();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Calamares::JobList
|
||||
@ -179,23 +185,31 @@ FinishedViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
if ( restartMode.isEmpty() )
|
||||
{
|
||||
if ( configurationMap.contains( "restartNowEnabled" ) )
|
||||
{
|
||||
cWarning() << "Configuring the finished module with deprecated restartNowEnabled settings";
|
||||
}
|
||||
|
||||
bool restartNowEnabled = CalamaresUtils::getBool( configurationMap, "restartNowEnabled", false );
|
||||
bool restartNowChecked = CalamaresUtils::getBool( configurationMap, "restartNowChecked", false );
|
||||
|
||||
if ( !restartNowEnabled )
|
||||
{
|
||||
mode = RestartMode::Never;
|
||||
}
|
||||
else
|
||||
{
|
||||
mode = restartNowChecked ? RestartMode::UserChecked : RestartMode::UserUnchecked;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool ok = false;
|
||||
mode = modeNames().find( restartMode, ok );
|
||||
if ( !ok )
|
||||
{
|
||||
cWarning() << "Configuring the finished module with bad restartNowMode" << restartMode;
|
||||
}
|
||||
}
|
||||
|
||||
m_widget->setRestart( mode );
|
||||
|
||||
@ -203,14 +217,17 @@ FinishedViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
{
|
||||
QString restartNowCommand = CalamaresUtils::getString( configurationMap, "restartNowCommand" );
|
||||
if ( restartNowCommand.isEmpty() )
|
||||
{
|
||||
restartNowCommand = QStringLiteral( "shutdown -r now" );
|
||||
}
|
||||
m_widget->setRestartNowCommand( restartNowCommand );
|
||||
}
|
||||
|
||||
m_notifyOnFinished = CalamaresUtils::getBool( configurationMap, "notifyOnFinished", false );
|
||||
}
|
||||
|
||||
QString FinishedViewStep::modeName(FinishedViewStep::RestartMode m)
|
||||
QString
|
||||
FinishedViewStep::modeName( FinishedViewStep::RestartMode m )
|
||||
{
|
||||
bool ok = false;
|
||||
return modeNames().find( m, ok ); // May be QString()
|
||||
|
Loading…
Reference in New Issue
Block a user