From de406cef2250f897294de9618e0674cf42f20b08 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Wed, 28 Jan 2015 15:24:32 +0100 Subject: [PATCH] The Quit button is now Cancel, except on the last page. --- src/libcalamaresui/ViewManager.cpp | 31 +++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index 46a8c2903..550d2213c 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -1,6 +1,6 @@ /* === This file is part of Calamares - === * - * Copyright 2014, Teo Mrnjavac + * Copyright 2014-2015, Teo Mrnjavac * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -54,7 +54,7 @@ ViewManager::ViewManager( QObject* parent ) m_back = new QPushButton( tr( "&Back" ), m_widget ); m_next = new QPushButton( tr( "&Next" ), m_widget ); - m_quit = new QPushButton( tr( "&Quit" ), m_widget ); + m_quit = new QPushButton( tr( "&Cancel" ), m_widget ); QBoxLayout* bottomLayout = new QHBoxLayout; mainLayout->addLayout( bottomLayout ); @@ -64,7 +64,24 @@ ViewManager::ViewManager( QObject* parent ) bottomLayout->addSpacing( 12 ); bottomLayout->addWidget( m_quit ); - connect( m_quit, &QPushButton::clicked, qApp, &QApplication::quit ); + connect( m_quit, &QPushButton::clicked, + this, [this]() + { + if ( m_currentStep == m_steps.count() -1 && + m_steps.last()->isAtEnd() ) + qApp->quit(); + else + { + int response = QMessageBox::question( m_widget, + tr( "Cancel installation?" ), + tr( "Do you really want to cancel the current install process?\n" + "The installer will quit and all changes will be lost." ), + QMessageBox::Yes | QMessageBox::No, + QMessageBox::No ); + if ( response == QMessageBox::Yes ) + qApp->quit(); + } + } ); connect( m_next, &QPushButton::clicked, this, &ViewManager::next ); connect( m_back, &QPushButton::clicked, this, &ViewManager::back ); m_back->setEnabled( false ); @@ -204,6 +221,10 @@ ViewManager::next() m_next->setEnabled( !installing && m_steps.at( m_currentStep )->isNextEnabled() ); m_back->setEnabled( !installing ); + + if ( m_currentStep == m_steps.count() -1 && + m_steps.last()->isAtEnd() ) + m_quit->setText( tr( "&Quit" ) ); } @@ -228,6 +249,10 @@ ViewManager::back() m_next->setEnabled( m_steps.at( m_currentStep )->isNextEnabled() ); if ( m_currentStep == 0 && m_steps.first()->isAtBeginning() ) m_back->setEnabled( false ); + + if ( !( m_currentStep == m_steps.count() -1 && + m_steps.last()->isAtEnd() ) ) + m_quit->setText( tr( "&Cancel" ) ); } }