commit
447a39d71d
@ -367,36 +367,35 @@ bool ViewManager::confirmCancelInstallation()
|
||||
{
|
||||
const auto* const settings = Calamares::Settings::instance();
|
||||
|
||||
// When we're at the very end, then it's always OK to exit.
|
||||
if ( m_currentStep == m_steps.count() -1 && m_steps.last()->isAtEnd() )
|
||||
return true;
|
||||
|
||||
// Not at the very end, cancel/quit might be disabled
|
||||
if ( settings->disableCancel() )
|
||||
return false;
|
||||
if ( settings->disableCancelDuringExec() && stepIsExecute( m_steps, m_currentStep ) )
|
||||
return false;
|
||||
|
||||
// If it's NOT the last page of the last step, we ask for confirmation
|
||||
if ( !( m_currentStep == m_steps.count() -1 &&
|
||||
m_steps.last()->isAtEnd() ) )
|
||||
{
|
||||
QString title = settings->isSetupMode()
|
||||
? tr( "Cancel setup?" )
|
||||
: tr( "Cancel installation?" );
|
||||
QString question = settings->isSetupMode()
|
||||
? tr( "Do you really want to cancel the current setup process?\n"
|
||||
"The setup program will quit and all changes will be lost." )
|
||||
: tr( "Do you really want to cancel the current install process?\n"
|
||||
"The installer will quit and all changes will be lost." );
|
||||
QMessageBox mb( QMessageBox::Question,
|
||||
title,
|
||||
question,
|
||||
QMessageBox::Yes | QMessageBox::No,
|
||||
m_widget );
|
||||
mb.setDefaultButton( QMessageBox::No );
|
||||
mb.button( QMessageBox::Yes )->setText( tr( "&Yes" ) );
|
||||
mb.button( QMessageBox::No )->setText( tr( "&No" ) );
|
||||
int response = mb.exec();
|
||||
return response == QMessageBox::Yes;
|
||||
}
|
||||
else // Means we're at the end, no need to confirm.
|
||||
return true;
|
||||
// Otherwise, confirm cancel/quit.
|
||||
QString title = settings->isSetupMode()
|
||||
? tr( "Cancel setup?" )
|
||||
: tr( "Cancel installation?" );
|
||||
QString question = settings->isSetupMode()
|
||||
? tr( "Do you really want to cancel the current setup process?\n"
|
||||
"The setup program will quit and all changes will be lost." )
|
||||
: tr( "Do you really want to cancel the current install process?\n"
|
||||
"The installer will quit and all changes will be lost." );
|
||||
QMessageBox mb( QMessageBox::Question,
|
||||
title,
|
||||
question,
|
||||
QMessageBox::Yes | QMessageBox::No,
|
||||
m_widget );
|
||||
mb.setDefaultButton( QMessageBox::No );
|
||||
mb.button( QMessageBox::Yes )->setText( tr( "&Yes" ) );
|
||||
mb.button( QMessageBox::No )->setText( tr( "&No" ) );
|
||||
int response = mb.exec();
|
||||
return response == QMessageBox::Yes;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -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 ) );
|
||||
@ -99,17 +101,21 @@ FinishedPage::setRestartNowCommand( const QString& command )
|
||||
void
|
||||
FinishedPage::setUpRestart()
|
||||
{
|
||||
cDebug() << "FinishedPage::setUpRestart()";
|
||||
if ( !m_restartSetUp )
|
||||
{
|
||||
connect( qApp, &QApplication::aboutToQuit,
|
||||
this, [this]
|
||||
{
|
||||
if ( ui->restartCheckBox->isVisible() &&
|
||||
ui->restartCheckBox->isChecked() )
|
||||
QProcess::execute( "/bin/sh", { "-c", m_restartNowCommand } );
|
||||
} );
|
||||
}
|
||||
cDebug() << "FinishedPage::setUpRestart(), Quit button"
|
||||
<< "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 } );
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
@ -49,9 +49,8 @@ protected:
|
||||
private:
|
||||
Ui::FinishedPage* ui;
|
||||
|
||||
FinishedViewStep::RestartMode m_mode;
|
||||
QString m_restartNowCommand;
|
||||
|
||||
bool m_restartSetUp;
|
||||
};
|
||||
|
||||
#endif // FINISHEDPAGE_H
|
||||
|
@ -156,10 +156,10 @@ FinishedViewStep::onActivate()
|
||||
}
|
||||
|
||||
|
||||
QList< Calamares::job_ptr >
|
||||
Calamares::JobList
|
||||
FinishedViewStep::jobs() const
|
||||
{
|
||||
return QList< Calamares::job_ptr >();
|
||||
return Calamares::JobList();
|
||||
}
|
||||
|
||||
void
|
||||
@ -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;
|
||||
@ -57,7 +59,7 @@ public:
|
||||
|
||||
void onActivate() override;
|
||||
|
||||
QList< Calamares::job_ptr > jobs() const override;
|
||||
Calamares::JobList jobs() const override;
|
||||
|
||||
void setConfigurationMap( const QVariantMap& configurationMap ) override;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user