[finished] Improve logging of restart mode
- Don't use weirdly-named mode, store named mode in page, - Log the actual mode name when setting up the restart button.
This commit is contained in:
parent
38c36e2439
commit
0c24a01eb9
@ -39,7 +39,7 @@
|
||||
FinishedPage::FinishedPage( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, ui( new Ui::FinishedPage )
|
||||
, m_restartSetUp( false )
|
||||
, m_mode( FinishedViewStep::RestartMode::UserUnchecked )
|
||||
{
|
||||
ui->setupUi( this );
|
||||
|
||||
@ -83,6 +83,8 @@ FinishedPage::setRestart( FinishedViewStep::RestartMode mode )
|
||||
{
|
||||
using Mode = FinishedViewStep::RestartMode;
|
||||
|
||||
m_mode = mode;
|
||||
|
||||
ui->restartCheckBox->setVisible( mode != Mode::Never );
|
||||
ui->restartCheckBox->setEnabled( mode != Mode::Always );
|
||||
ui->restartCheckBox->setChecked( ( mode == Mode::Always ) || ( mode == Mode::UserChecked ) );
|
||||
@ -100,18 +102,20 @@ void
|
||||
FinishedPage::setUpRestart()
|
||||
{
|
||||
cDebug() << "FinishedPage::setUpRestart(), Quit button"
|
||||
<< "setup=" << m_restartSetUp
|
||||
<< "setup=" << FinishedViewStep::modeName( m_mode )
|
||||
<< "command=" << m_restartNowCommand;
|
||||
if ( !m_restartSetUp )
|
||||
{
|
||||
connect( qApp, &QApplication::aboutToQuit,
|
||||
this, [this]
|
||||
{
|
||||
if ( ui->restartCheckBox->isVisible() &&
|
||||
ui->restartCheckBox->isChecked() )
|
||||
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 } );
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
@ -49,9 +49,8 @@ protected:
|
||||
private:
|
||||
Ui::FinishedPage* ui;
|
||||
|
||||
FinishedViewStep::RestartMode m_mode;
|
||||
QString m_restartNowCommand;
|
||||
|
||||
bool m_restartSetUp;
|
||||
};
|
||||
|
||||
#endif // FINISHEDPAGE_H
|
||||
|
@ -210,4 +210,11 @@ FinishedViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
m_notifyOnFinished = CalamaresUtils::getBool( configurationMap, "notifyOnFinished", false );
|
||||
}
|
||||
|
||||
QString FinishedViewStep::modeName(FinishedViewStep::RestartMode m)
|
||||
{
|
||||
bool ok = false;
|
||||
return modeNames().find( m, ok ); // May be QString()
|
||||
}
|
||||
|
||||
|
||||
CALAMARES_PLUGIN_FACTORY_DEFINITION( FinishedViewStepFactory, registerPlugin<FinishedViewStep>(); )
|
||||
|
@ -41,6 +41,8 @@ public:
|
||||
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 );
|
||||
|
||||
explicit FinishedViewStep( QObject* parent = nullptr );
|
||||
virtual ~FinishedViewStep() override;
|
||||
|
Loading…
Reference in New Issue
Block a user