From 5593be125fecc7c99f32265b8f20e0a0ba27b0bf Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 2 Jan 2018 13:58:29 +0100 Subject: [PATCH 1/3] [calamares] Reduce font-related debug output on startup. --- src/calamares/CalamaresApplication.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/calamares/CalamaresApplication.cpp b/src/calamares/CalamaresApplication.cpp index 6389a2806..f1062e942 100644 --- a/src/calamares/CalamaresApplication.cpp +++ b/src/calamares/CalamaresApplication.cpp @@ -55,14 +55,7 @@ CalamaresApplication::CalamaresApplication( int& argc, char* argv[] ) QFont f = font(); - cDebug() << "Default font =====" - << "\nPixel size: " << f.pixelSize() - << "\nPoint size: " << f.pointSize() - << "\nPoint sizeF: " << f.pointSizeF() - << "\nFont family: " << f.family() - << "\nMetric height:" << QFontMetrics( f ).height(); - // The following line blocks for 15s on Qt 5.1.0 - cDebug() << "Font height:" << QFontMetrics( f ).height(); + cDebug() << "Default font size" << f.pointSize() << ';' << f.pixelSize() << "px"; CalamaresUtils::setDefaultFontSize( f.pointSize() ); cDebug() << "Available languages:" << QString( CALAMARES_TRANSLATION_LANGUAGES ).split( ';' ); From 41e6f0e06cd8fa4c8f8032880daea744eb113ba1 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 2 Jan 2018 13:59:38 +0100 Subject: [PATCH 2/3] [calamares] Allow WM close button - remove hide-close-button hack - refactor code in viewmanager for confirming quit - hook up confirm-and-quit to WM close button - also works for alt-F4 and other quit methods - while here, update copyright year FIXES #870 --- src/calamares/CalamaresWindow.cpp | 25 ++++++++++----- src/calamares/CalamaresWindow.h | 9 ++++-- src/libcalamaresui/ViewManager.cpp | 50 +++++++++++++++--------------- src/libcalamaresui/ViewManager.h | 9 +++++- 4 files changed, 58 insertions(+), 35 deletions(-) diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index ab24b6db2..df5274598 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -1,7 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2015, Teo Mrnjavac - * Copyright 2017, Adriaan de Groot + * Copyright 2017-2018, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -37,10 +38,8 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) : QWidget( parent ) , m_debugWindow( nullptr ) + , m_viewManager( nullptr ) { - // Hide close button - setWindowFlags( Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint ); - CALAMARES_RETRANSLATE( setWindowTitle( tr( "%1 Installer" ) .arg( *Calamares::Branding::ProductName ) ); @@ -139,10 +138,10 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) CalamaresUtils::unmarginLayout( sideLayout ); CalamaresUtils::unmarginLayout( mainLayout ); - Calamares::ViewManager* vm = Calamares::ViewManager::instance( this ); - connect( vm, &Calamares::ViewManager::enlarge, this, &CalamaresWindow::enlarge ); + m_viewManager = Calamares::ViewManager::instance( this ); + connect( m_viewManager, &Calamares::ViewManager::enlarge, this, &CalamaresWindow::enlarge ); - mainLayout->addWidget( vm->centralWidget() ); + mainLayout->addWidget( m_viewManager->centralWidget() ); } void @@ -156,3 +155,15 @@ CalamaresWindow::enlarge( QSize enlarge ) resize( w, h ); } + +void +CalamaresWindow::closeEvent( QCloseEvent* event ) +{ + if ( ( !m_viewManager ) || m_viewManager->confirmCancelInstallation() ) + { + event->accept(); + qApp->quit(); + } + else + event->ignore(); +} diff --git a/src/calamares/CalamaresWindow.h b/src/calamares/CalamaresWindow.h index 00f790f5a..92b6da834 100644 --- a/src/calamares/CalamaresWindow.h +++ b/src/calamares/CalamaresWindow.h @@ -1,7 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2015, Teo Mrnjavac - * Copyright 2017, Adriaan de Groot + * Copyright 2017-2018, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,6 +26,7 @@ namespace Calamares { class DebugWindow; +class ViewManager; } /** @@ -46,8 +47,12 @@ public slots: */ void enlarge( QSize enlarge ); +protected: + virtual void closeEvent( QCloseEvent* e ) override; + private: - QPointer< Calamares::DebugWindow > m_debugWindow; + QPointer< Calamares::DebugWindow > m_debugWindow; // Managed by self + Calamares::ViewManager* m_viewManager; }; #endif //CALAMARESWINDOW_H diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index 7b5df155b..7b5921f6b 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -1,7 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2015, Teo Mrnjavac - * Copyright 2017, Adriaan de Groot + * Copyright 2017-2018, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -88,30 +88,8 @@ ViewManager::ViewManager( QObject* parent ) connect( m_back, &QPushButton::clicked, this, &ViewManager::back ); m_back->setEnabled( false ); - connect( m_quit, &QPushButton::clicked, - this, [this]() - { - // 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() ) ) - { - QMessageBox mb( QMessageBox::Question, - 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, - m_widget ); - mb.setDefaultButton( QMessageBox::No ); - mb.button( QMessageBox::Yes )->setText( tr( "&Yes" ) ); - mb.button( QMessageBox::No )->setText( tr( "&No" ) ); - int response = mb.exec(); - if ( response == QMessageBox::Yes ) - qApp->quit(); - } - else // Means we're at the end, no need to confirm. - qApp->quit(); - } ); - + 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, @@ -302,4 +280,26 @@ ViewManager::back() } } +bool ViewManager::confirmCancelInstallation() +{ + // 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() ) ) + { + QMessageBox mb( QMessageBox::Question, + 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, + 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; } + +} // namespace diff --git a/src/libcalamaresui/ViewManager.h b/src/libcalamaresui/ViewManager.h index 38ddda70a..fe56509c0 100644 --- a/src/libcalamaresui/ViewManager.h +++ b/src/libcalamaresui/ViewManager.h @@ -1,7 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2015, Teo Mrnjavac - * Copyright 2017, Adriaan de Groot + * Copyright 2017-2018, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -86,6 +86,13 @@ public: */ int currentStepIndex() const; + /** + * @ brief Called when "Cancel" is clicked; asks for confirmation. + * Other means of closing Calamares also call this method, e.g. alt-F4. + * At the end of installation, no confirmation is asked. Returns true + * if the user confirms closing the window. + */ + bool confirmCancelInstallation(); public slots: /** From b3f0932ff9772d482308366c197326a236efb81b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 2 Jan 2018 15:37:36 +0100 Subject: [PATCH 3/3] CMake: bump version number --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a43d3205..5da78c5b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -176,7 +176,7 @@ set( CALAMARES_TRANSLATION_LANGUAGES ar ast bg ca cs_CZ da de el en en_GB es_MX ### Bump version here set( CALAMARES_VERSION_MAJOR 3 ) set( CALAMARES_VERSION_MINOR 1 ) -set( CALAMARES_VERSION_PATCH 11 ) +set( CALAMARES_VERSION_PATCH 12 ) set( CALAMARES_VERSION_RC 0 ) set( CALAMARES_VERSION ${CALAMARES_VERSION_MAJOR}.${CALAMARES_VERSION_MINOR}.${CALAMARES_VERSION_PATCH} )