Merge branch 'master' of https://github.com/calamares/calamares into development

This commit is contained in:
Philip 2018-01-03 03:55:57 -05:00
commit c857568b7a
8 changed files with 127 additions and 61 deletions

View File

@ -3,15 +3,27 @@ include( CalamaresAddTranslations )
set( MODULE_DATA_DESTINATION share/calamares/modules ) set( MODULE_DATA_DESTINATION share/calamares/modules )
# Convenience function to indicate that a module has been skipped
# (optionally also why). Call this in the module's CMakeLists.txt
macro( calamares_skip_module )
set( SKIPPED_MODULES ${SKIPPED_MODULES} ${ARGV} PARENT_SCOPE )
endmacro()
function( calamares_add_module_subdirectory ) function( calamares_add_module_subdirectory )
set( SUBDIRECTORY ${ARGV0} ) set( SUBDIRECTORY ${ARGV0} )
set( SKIPPED_MODULES )
set( MODULE_CONFIG_FILES "" ) set( MODULE_CONFIG_FILES "" )
# If this subdirectory has a CMakeLists.txt, we add_subdirectory it... # If this subdirectory has a CMakeLists.txt, we add_subdirectory it...
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/CMakeLists.txt" ) if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/CMakeLists.txt" )
add_subdirectory( ${SUBDIRECTORY} ) add_subdirectory( ${SUBDIRECTORY} )
file( GLOB MODULE_CONFIG_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY} "${SUBDIRECTORY}/*.conf" ) file( GLOB MODULE_CONFIG_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY} "${SUBDIRECTORY}/*.conf" )
# Module has indicated it should be skipped, show that in
# the calling CMakeLists (which is src/modules/CMakeLists.txt normally).
if ( SKIPPED_MODULES )
set( SKIPPED_MODULES ${SKIPPED_MODULES} PARENT_SCOPE )
endif()
# ...otherwise, we look for a module.desc. # ...otherwise, we look for a module.desc.
elseif( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/module.desc" ) elseif( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/module.desc" )
set( MODULES_DIR ${CMAKE_INSTALL_LIBDIR}/calamares/modules ) set( MODULES_DIR ${CMAKE_INSTALL_LIBDIR}/calamares/modules )

View File

@ -55,14 +55,7 @@ CalamaresApplication::CalamaresApplication( int& argc, char* argv[] )
QFont f = font(); QFont f = font();
cDebug() << "Default font =====" cDebug() << "Default font size" << f.pointSize() << ';' << f.pixelSize() << "px";
<< "\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();
CalamaresUtils::setDefaultFontSize( f.pointSize() ); CalamaresUtils::setDefaultFontSize( f.pointSize() );
cDebug() << "Available languages:" << QString( CALAMARES_TRANSLATION_LANGUAGES ).split( ';' ); cDebug() << "Available languages:" << QString( CALAMARES_TRANSLATION_LANGUAGES ).split( ';' );

View File

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> === /* === This file is part of Calamares - <https://github.com/calamares> ===
* *
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org> * Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2017, Adriaan de Groot <groot@kde.org> * Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -30,6 +30,7 @@
#include <QApplication> #include <QApplication>
#include <QBoxLayout> #include <QBoxLayout>
#include <QCloseEvent>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QLabel> #include <QLabel>
#include <QTreeView> #include <QTreeView>
@ -37,10 +38,8 @@
CalamaresWindow::CalamaresWindow( QWidget* parent ) CalamaresWindow::CalamaresWindow( QWidget* parent )
: QWidget( parent ) : QWidget( parent )
, m_debugWindow( nullptr ) , m_debugWindow( nullptr )
, m_viewManager( nullptr )
{ {
// Hide close button
setWindowFlags( Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint );
CALAMARES_RETRANSLATE( CALAMARES_RETRANSLATE(
setWindowTitle( tr( "%1 Installer" ) setWindowTitle( tr( "%1 Installer" )
.arg( *Calamares::Branding::ProductName ) ); .arg( *Calamares::Branding::ProductName ) );
@ -139,10 +138,10 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
CalamaresUtils::unmarginLayout( sideLayout ); CalamaresUtils::unmarginLayout( sideLayout );
CalamaresUtils::unmarginLayout( mainLayout ); CalamaresUtils::unmarginLayout( mainLayout );
Calamares::ViewManager* vm = Calamares::ViewManager::instance( this ); m_viewManager = Calamares::ViewManager::instance( this );
connect( vm, &Calamares::ViewManager::enlarge, this, &CalamaresWindow::enlarge ); connect( m_viewManager, &Calamares::ViewManager::enlarge, this, &CalamaresWindow::enlarge );
mainLayout->addWidget( vm->centralWidget() ); mainLayout->addWidget( m_viewManager->centralWidget() );
} }
void void
@ -156,3 +155,15 @@ CalamaresWindow::enlarge( QSize enlarge )
resize( w, h ); resize( w, h );
} }
void
CalamaresWindow::closeEvent( QCloseEvent* event )
{
if ( ( !m_viewManager ) || m_viewManager->confirmCancelInstallation() )
{
event->accept();
qApp->quit();
}
else
event->ignore();
}

View File

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> === /* === This file is part of Calamares - <https://github.com/calamares> ===
* *
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org> * Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2017, Adriaan de Groot <groot@kde.org> * Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -26,6 +26,7 @@
namespace Calamares namespace Calamares
{ {
class DebugWindow; class DebugWindow;
class ViewManager;
} }
/** /**
@ -46,8 +47,12 @@ public slots:
*/ */
void enlarge( QSize enlarge ); void enlarge( QSize enlarge );
protected:
virtual void closeEvent( QCloseEvent* e ) override;
private: private:
QPointer< Calamares::DebugWindow > m_debugWindow; QPointer< Calamares::DebugWindow > m_debugWindow; // Managed by self
Calamares::ViewManager* m_viewManager;
}; };
#endif //CALAMARESWINDOW_H #endif //CALAMARESWINDOW_H

View File

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> === /* === This file is part of Calamares - <https://github.com/calamares> ===
* *
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org> * Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2017, Adriaan de Groot <groot@kde.org> * Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * 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 ); connect( m_back, &QPushButton::clicked, this, &ViewManager::back );
m_back->setEnabled( false ); m_back->setEnabled( false );
connect( m_quit, &QPushButton::clicked, connect( m_quit, &QPushButton::clicked, this,
this, [this]() [this]() { if ( this->confirmCancelInstallation() ) qApp->quit(); } );
{
// 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( JobQueue::instance(), &JobQueue::failed, connect( JobQueue::instance(), &JobQueue::failed,
this, &ViewManager::onInstallationFailed ); this, &ViewManager::onInstallationFailed );
connect( JobQueue::instance(), &JobQueue::finished, 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

View File

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> === /* === This file is part of Calamares - <https://github.com/calamares> ===
* *
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org> * Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2017, Adriaan de Groot <groot@kde.org> * Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -86,6 +86,13 @@ public:
*/ */
int currentStepIndex() const; 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: public slots:
/** /**

View File

@ -1,5 +1,11 @@
include( CMakeColors ) include( CMakeColors )
# The variable SKIP_MODULES can be set to skip particular modules;
# individual modules can also decide they must be skipped (e.g. OS-specific
# modules, or ones with unmet dependencies). Collect the skipped modules
# in this list.
set( LIST_SKIPPED_MODULES "" )
if( BUILD_TESTING ) if( BUILD_TESTING )
add_executable( test_conf test_conf.cpp ) add_executable( test_conf test_conf.cpp )
target_link_libraries( test_conf ${YAMLCPP_LIBRARY} ) target_link_libraries( test_conf ${YAMLCPP_LIBRARY} )
@ -14,11 +20,24 @@ foreach( SUBDIRECTORY ${SUBDIRECTORIES} )
if( NOT DO_SKIP EQUAL -1 ) if( NOT DO_SKIP EQUAL -1 )
message( "${ColorReset}-- Skipping module ${BoldRed}${SUBDIRECTORY}${ColorReset}." ) message( "${ColorReset}-- Skipping module ${BoldRed}${SUBDIRECTORY}${ColorReset}." )
message( "" ) message( "" )
list( APPEND LIST_SKIPPED_MODULES "${SUBDIRECTORY} (user request)" )
elseif( ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}" ) AND elseif( ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}" ) AND
( DO_SKIP EQUAL -1 ) ) ( DO_SKIP EQUAL -1 ) )
set( SKIPPED_MODULES )
calamares_add_module_subdirectory( ${SUBDIRECTORY} ) calamares_add_module_subdirectory( ${SUBDIRECTORY} )
if ( SKIPPED_MODULES )
list( APPEND LIST_SKIPPED_MODULES "${SKIPPED_MODULES}" )
endif()
endif() endif()
endforeach() endforeach()
if ( LIST_SKIPPED_MODULES )
message( "${ColorReset}-- Skipped modules:" )
foreach( SUBDIRECTORY ${LIST_SKIPPED_MODULES} )
message( "${ColorReset}-- Skipped ${BoldRed}${SUBDIRECTORY}${ColorReset}." )
endforeach()
message( "" )
endif()
include( CalamaresAddTranslations ) include( CalamaresAddTranslations )
add_calamares_python_translations( ${CALAMARES_TRANSLATION_LANGUAGES} ) add_calamares_python_translations( ${CALAMARES_TRANSLATION_LANGUAGES} )

View File

@ -1,8 +1,24 @@
find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE) find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE)
find_package( KF5 5.29 REQUIRED CoreAddons Plasma Package ) # Requires a sufficiently recent Plasma framework, but also
# needs a runtime support component (which we don't test for).
set( lnf_ver 5.41 )
calamares_add_plugin( plasmalnf find_package( KF5Plasma ${lnf_ver} )
find_package( KF5Package ${lnf_ver} )
set_package_properties(
KF5Plasma PROPERTIES
PURPOSE "For Plasma Look-and-Feel selection"
)
set_package_properties(
KF5Package PROPERTIES
PURPOSE "For Plasma Look-and-Feel selection"
)
if ( KF5Plasma_FOUND AND KF5Package_FOUND )
find_package( KF5 ${lnf_ver} REQUIRED CoreAddons Plasma Package )
calamares_add_plugin( plasmalnf
TYPE viewmodule TYPE viewmodule
EXPORT_MACRO PLUGINDLLEXPORT_PRO EXPORT_MACRO PLUGINDLLEXPORT_PRO
SOURCES SOURCES
@ -19,4 +35,7 @@ calamares_add_plugin( plasmalnf
KF5::Package KF5::Package
KF5::Plasma KF5::Plasma
SHARED_LIB SHARED_LIB
) )
else()
calamares_skip_module( "plasmalnf (missing requirements)" )
endif()