diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp
index b1334ecfa..bb39f325a 100644
--- a/src/libcalamaresui/ViewManager.cpp
+++ b/src/libcalamaresui/ViewManager.cpp
@@ -112,9 +112,7 @@ ViewManager::ViewManager( QObject* parent )
m_next = makeButton( m_widget, "go-next" );
m_quit = makeButton( m_widget, "dialog-cancel" );
- CALAMARES_RETRANSLATE(
- updateButtonLabels();
- )
+ CALAMARES_RETRANSLATE( updateButtonLabels(); )
QBoxLayout* bottomLayout = new QHBoxLayout;
mainLayout->addLayout( bottomLayout );
@@ -128,15 +126,19 @@ ViewManager::ViewManager( QObject* parent )
connect( m_back, &QPushButton::clicked, this, &ViewManager::back );
m_back->setEnabled( false );
- connect( m_quit, &QPushButton::clicked, this,
- [this]() { if ( this->confirmCancelInstallation() ) qApp->quit(); } );
- connect( JobQueue::instance(), &JobQueue::failed,
- this, &ViewManager::onInstallationFailed );
- connect( JobQueue::instance(), &JobQueue::finished,
- this, &ViewManager::next );
+ connect( m_quit, &QPushButton::clicked, this, [this]() {
+ if ( this->confirmCancelInstallation() )
+ {
+ qApp->quit();
+ }
+ } );
+ connect( JobQueue::instance(), &JobQueue::failed, this, &ViewManager::onInstallationFailed );
+ connect( JobQueue::instance(), &JobQueue::finished, this, &ViewManager::next );
- if (Calamares::Settings::instance()->disableCancel())
+ if ( Calamares::Settings::instance()->disableCancel() )
+ {
m_quit->setVisible( false );
+ }
}
@@ -160,7 +162,9 @@ ViewManager::addViewStep( ViewStep* step )
insertViewStep( m_steps.size(), step );
// If this is the first inserted view step, update status of "Next" button
if ( m_steps.count() == 1 )
+ {
m_next->setEnabled( step->isNextEnabled() );
+ }
}
@@ -170,18 +174,20 @@ ViewManager::insertViewStep( int before, ViewStep* step )
m_steps.insert( before, step );
QLayout* layout = step->widget()->layout();
if ( layout )
+ {
layout->setContentsMargins( 0, 0, 0, 0 );
+ }
m_stack->insertWidget( before, step->widget() );
connect( step, &ViewStep::enlarge, this, &ViewManager::enlarge );
- connect( step, &ViewStep::nextStatusChanged,
- this, [this]( bool status )
- {
+ connect( step, &ViewStep::nextStatusChanged, this, [this]( bool status ) {
ViewStep* vs = qobject_cast< ViewStep* >( sender() );
if ( vs )
{
if ( vs == m_steps.at( m_currentStep ) )
+ {
m_next->setEnabled( status );
+ }
}
} );
@@ -193,21 +199,24 @@ ViewManager::insertViewStep( int before, ViewStep* step )
void
ViewManager::onInstallationFailed( const QString& message, const QString& details )
{
- bool shouldOfferWebPaste = true; // TODO: config var
+ bool shouldOfferWebPaste = true; // TODO: config var
cError() << "Installation failed:";
cDebug() << "- message:" << message;
cDebug() << "- details:" << details;
- QString heading = Calamares::Settings::instance()->isSetupMode()
- ? tr( "Setup Failed" )
- : tr( "Installation Failed" );
+ QString heading
+ = Calamares::Settings::instance()->isSetupMode() ? tr( "Setup Failed" ) : tr( "Installation Failed" );
QString pasteMsg = tr( "Would you like to paste the install log to the web?" );
QString text = "
" + message + "
";
if ( !details.isEmpty() )
+ {
text += "" + details + "
";
+ }
if ( shouldOfferWebPaste )
+ {
text += "" + pasteMsg + "
";
+ }
QMessageBox* msgBox = new QMessageBox();
msgBox->setIcon( QMessageBox::Critical );
@@ -230,9 +239,7 @@ ViewManager::onInstallationFailed( const QString& message, const QString& detail
msgBox->show();
cDebug() << "Calamares will quit when the dialog closes.";
- connect( msgBox, &QMessageBox::buttonClicked,
- [msgBox] ( QAbstractButton* button )
- {
+ connect( msgBox, &QMessageBox::buttonClicked, [msgBox]( QAbstractButton* button ) {
if ( button->text() != tr( "&Yes" ) )
{
QApplication::quit();
@@ -250,33 +257,36 @@ ViewManager::onInstallationFailed( const QString& message, const QString& detail
QMessageBox* pasteUrlMsgBox = new QMessageBox();
pasteUrlMsgBox->setIcon( QMessageBox::Critical );
- pasteUrlMsgBox->setWindowTitle( pasteUrlTitle );
+ pasteUrlMsgBox->setWindowTitle( pasteUrlTitle );
pasteUrlMsgBox->setStandardButtons( QMessageBox::Close );
pasteUrlMsgBox->setText( pasteUrlMsg );
pasteUrlMsgBox->show();
connect( pasteUrlMsgBox, &QMessageBox::buttonClicked, qApp, &QApplication::quit );
- });
+ } );
}
void
-ViewManager::onInitFailed( const QStringList& modules)
+ViewManager::onInitFailed( const QStringList& modules )
{
// Because this means the installer / setup program is broken by the distributor,
// don't bother being precise about installer / setup wording.
QString title( tr( "Calamares Initialization Failed" ) );
- QString description( tr( "%1 can not be installed. Calamares was unable to load all of the configured modules. This is a problem with the way Calamares is being used by the distribution." ) );
+ QString description( tr( "%1 can not be installed. Calamares was unable to load all of the configured modules. "
+ "This is a problem with the way Calamares is being used by the distribution." ) );
QString detailString;
if ( modules.count() > 0 )
{
description.append( tr( "
The following modules could not be loaded:" ) );
QStringList details;
- details << QLatin1Literal("");
- for( const auto& m : modules )
- details << QLatin1Literal("- ") << m << QLatin1Literal("
");
- details << QLatin1Literal("
");
+ details << QLatin1Literal( "" );
+ for ( const auto& m : modules )
+ {
+ details << QLatin1Literal( "- " ) << m << QLatin1Literal( "
" );
+ }
+ details << QLatin1Literal( "
" );
detailString = details.join( QString() );
}
@@ -311,10 +321,8 @@ ViewManager::currentStepIndex() const
static inline bool
stepIsExecute( const ViewStepList& steps, int index )
{
- return
- ( 0 <= index ) &&
- ( index < steps.count() ) &&
- ( qobject_cast< ExecutionViewStep* >( steps.at( index ) ) != nullptr );
+ return ( 0 <= index ) && ( index < steps.count() )
+ && ( qobject_cast< ExecutionViewStep* >( steps.at( index ) ) != nullptr );
}
void
@@ -329,11 +337,10 @@ ViewManager::next()
// Special case when the user clicks next on the very last page in a view phase
// and right before switching to an execution phase.
// Depending on Calamares::Settings, we show an "are you sure" prompt or not.
- if ( settings->showPromptBeforeExecution() && stepIsExecute( m_steps, m_currentStep+1 ) )
+ if ( settings->showPromptBeforeExecution() && stepIsExecute( m_steps, m_currentStep + 1 ) )
{
- QString title = settings->isSetupMode()
- ? tr( "Continue with setup?" )
- : tr( "Continue with installation?" );
+ QString title
+ = settings->isSetupMode() ? tr( "Continue with setup?" ) : tr( "Continue with installation?" );
QString question = settings->isSetupMode()
? tr( "The %1 setup program is about to make changes to your "
"disk in order to set up %2.
You will not be able "
@@ -341,21 +348,21 @@ ViewManager::next()
: tr( "The %1 installer is about to make changes to your "
"disk in order to install %2.
You will not be able "
"to undo these changes." );
- QString confirm = settings->isSetupMode()
- ? tr( "&Set up now" )
- : tr( "&Install now" );
+ QString confirm = settings->isSetupMode() ? tr( "&Set up now" ) : tr( "&Install now" );
- int reply =
- QMessageBox::question( m_widget,
- title,
- question.arg( *Calamares::Branding::ShortProductName, *Calamares::Branding::ShortVersionedName ),
- confirm,
- tr( "Go &back" ),
- QString(),
- 0,
- 1 );
+ int reply = QMessageBox::question(
+ m_widget,
+ title,
+ question.arg( *Calamares::Branding::ShortProductName, *Calamares::Branding::ShortVersionedName ),
+ confirm,
+ tr( "Go &back" ),
+ QString(),
+ 0,
+ 1 );
if ( reply == 1 )
+ {
return;
+ }
}
m_currentStep++;
@@ -376,7 +383,7 @@ ViewManager::next()
m_next->setEnabled( false );
m_back->setEnabled( false );
}
- updateCancelEnabled( !settings->disableCancel() && !(executing && settings->disableCancelDuringExec() ) );
+ updateCancelEnabled( !settings->disableCancel() && !( executing && settings->disableCancelDuringExec() ) );
}
else
{
@@ -397,9 +404,7 @@ ViewManager::updateButtonLabels()
{
const auto* const settings = Calamares::Settings::instance();
- QString nextIsInstallationStep = settings->isSetupMode()
- ? tr( "&Set up" )
- : tr( "&Install" );
+ QString nextIsInstallationStep = settings->isSetupMode() ? tr( "&Set up" ) : tr( "&Install" );
QString quitOnCompleteTooltip = settings->isSetupMode()
? tr( "Setup is complete. Close the setup program." )
: tr( "The installation is complete. Close the installer." );
@@ -408,7 +413,7 @@ ViewManager::updateButtonLabels()
: tr( "Cancel installation without changing the system." );
// If we're going into the execution step / install phase, other message
- if ( stepIsExecute( m_steps, m_currentStep+1 ) )
+ if ( stepIsExecute( m_steps, m_currentStep + 1 ) )
{
m_next->setText( nextIsInstallationStep );
setButtonIcon( m_next, "run-install" );
@@ -434,8 +439,11 @@ ViewManager::updateButtonLabels()
else
{
if ( settings->disableCancel() )
+ {
m_quit->setVisible( false ); // In case we went back from final
- updateCancelEnabled( !settings->disableCancel() && !( stepIsExecute( m_steps, m_currentStep ) && settings->disableCancelDuringExec() ) );
+ }
+ updateCancelEnabled( !settings->disableCancel()
+ && !( stepIsExecute( m_steps, m_currentStep ) && settings->disableCancelDuringExec() ) );
m_quit->setText( tr( "&Cancel" ) );
m_quit->setToolTip( cancelBeforeInstallationTooltip );
@@ -456,46 +464,53 @@ ViewManager::back()
emit currentStepChanged();
}
else if ( !step->isAtBeginning() )
+ {
step->back();
- else return;
+ }
+ else
+ {
+ return;
+ }
m_next->setEnabled( m_steps.at( m_currentStep )->isNextEnabled() );
m_back->setEnabled( m_steps.at( m_currentStep )->isBackEnabled() );
if ( m_currentStep == 0 && m_steps.first()->isAtBeginning() )
+ {
m_back->setEnabled( false );
+ }
updateButtonLabels();
}
-bool ViewManager::confirmCancelInstallation()
+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 ( isAtVeryEnd() )
+ {
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;
+ }
// 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 );
+ 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" ) );
@@ -510,4 +525,4 @@ ViewManager::updateCancelEnabled( bool enabled )
emit cancelEnabled( enabled );
}
-} // namespace
+} // namespace Calamares
diff --git a/src/libcalamaresui/ViewManager.h b/src/libcalamaresui/ViewManager.h
index c9f554ee8..fca74a367 100644
--- a/src/libcalamaresui/ViewManager.h
+++ b/src/libcalamaresui/ViewManager.h
@@ -133,7 +133,8 @@ private:
bool isAtVeryEnd() const
{
- return ( m_currentStep >= m_steps.count() ) || ( m_currentStep == m_steps.count() - 1 && m_steps.last()->isAtEnd() );
+ return ( m_currentStep >= m_steps.count() )
+ || ( m_currentStep == m_steps.count() - 1 && m_steps.last()->isAtEnd() );
}
static ViewManager* s_instance;
@@ -148,6 +149,6 @@ private:
QPushButton* m_quit;
};
-}
+} // namespace Calamares
-#endif // VIEWMANAGER_H
+#endif // VIEWMANAGER_H