[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 ) );
|
||||
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
|
||||
{
|
||||
.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 {
|
||||
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 ) );
|
||||
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>" ) );
|
||||
}
|
||||
)
|
||||
.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() )
|
||||
{
|
||||
cDebug() << "Running restart command" << m_restartNowCommand;
|
||||
QProcess::execute( "/bin/sh", { "-c", m_restartNowCommand } );
|
||||
}
|
||||
}
|
||||
);
|
||||
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( message ) );
|
||||
.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( message ) );
|
||||
.arg( branding->versionedName() )
|
||||
.arg( message ) );
|
||||
setRestart( FinishedViewStep::RestartMode::Never );
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public slots:
|
||||
void onInstallationFailed( const QString& message, const QString& details );
|
||||
|
||||
protected:
|
||||
void focusInEvent( QFocusEvent* e ) override; //choose the child widget to focus
|
||||
void focusInEvent( QFocusEvent* e ) override; //choose the child widget to focus
|
||||
|
||||
private:
|
||||
Ui::FinishedPage* ui;
|
||||
@ -53,4 +53,4 @@ private:
|
||||
QString m_restartNowCommand;
|
||||
};
|
||||
|
||||
#endif // FINISHEDPAGE_H
|
||||
#endif // FINISHEDPAGE_H
|
||||
|
@ -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 },
|
||||
{ QStringLiteral( "user-unchecked" ), Mode::UserUnchecked },
|
||||
{ QStringLiteral( "user-checked" ), Mode::UserChecked },
|
||||
{ QStringLiteral( "always" ), Mode::Always }
|
||||
} ;
|
||||
static const NamedEnumTable< Mode > names { { QStringLiteral( "never" ), Mode::Never },
|
||||
{ QStringLiteral( "user-unchecked" ), Mode::UserUnchecked },
|
||||
{ QStringLiteral( "user-checked" ), Mode::UserChecked },
|
||||
{ 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,7 +64,9 @@ FinishedViewStep::FinishedViewStep( QObject* parent )
|
||||
FinishedViewStep::~FinishedViewStep()
|
||||
{
|
||||
if ( m_widget && m_widget->parent() == nullptr )
|
||||
{
|
||||
m_widget->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -119,30 +117,36 @@ 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",
|
||||
QString( "Calamares" ),
|
||||
QVariant( 0U ),
|
||||
QString( "calamares" ),
|
||||
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 ),
|
||||
QStringList(),
|
||||
QVariantMap(),
|
||||
QVariant( 0 )
|
||||
);
|
||||
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( "The setup of %1 is complete." ).arg( branding->versionedName() )
|
||||
: tr( "The installation of %1 is complete." ).arg( branding->versionedName() ),
|
||||
QStringList(),
|
||||
QVariantMap(),
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -152,7 +156,9 @@ FinishedViewStep::onActivate()
|
||||
m_widget->setUpRestart();
|
||||
|
||||
if ( m_notifyOnFinished )
|
||||
{
|
||||
sendNotification();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -179,22 +185,30 @@ 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,18 +217,21 @@ 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()
|
||||
}
|
||||
|
||||
|
||||
CALAMARES_PLUGIN_FACTORY_DEFINITION( FinishedViewStepFactory, registerPlugin<FinishedViewStep>(); )
|
||||
CALAMARES_PLUGIN_FACTORY_DEFINITION( FinishedViewStepFactory, registerPlugin< FinishedViewStep >(); )
|
||||
|
@ -36,10 +36,10 @@ class PLUGINDLLEXPORT FinishedViewStep : public Calamares::ViewStep
|
||||
public:
|
||||
enum class RestartMode
|
||||
{
|
||||
Never=0, ///< @brief Don't show button, just exit
|
||||
UserUnchecked, ///< @brief Show button, starts unchecked
|
||||
UserChecked, ///< @brief Show button, starts checked
|
||||
Always ///< @brief Show button, can't change, checked
|
||||
Never = 0, ///< @brief Don't show button, just exit
|
||||
UserUnchecked, ///< @brief Show button, starts unchecked
|
||||
UserChecked, ///< @brief Show button, starts checked
|
||||
Always ///< @brief Show button, can't change, checked
|
||||
};
|
||||
/// @brief Returns the config-name of the given restart-mode @p m
|
||||
static QString modeName( RestartMode m );
|
||||
|
Loading…
Reference in New Issue
Block a user