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