From c56fc65fc13db133e4e7190d638cad608e3b7579 Mon Sep 17 00:00:00 2001 From: cui-gaoleng <562344211@qq.com> Date: Fri, 8 Nov 2024 01:04:06 +0800 Subject: [PATCH 1/4] =?UTF-8?q?calamares=E6=96=87=E4=BB=B6=E5=A4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/calamares/CalamaresApplication.cpp | 605 ++++++++++--------- src/calamares/CalamaresApplication.h | 128 ++-- src/calamares/CalamaresWindow.cpp | 88 +-- src/calamares/CalamaresWindow.h | 100 +-- src/calamares/DebugWindow.cpp | 14 +- src/calamares/DebugWindow.ui | 314 +++++----- src/calamares/calamares-3.3.7.code-workspace | 11 + 7 files changed, 646 insertions(+), 614 deletions(-) create mode 100644 src/calamares/calamares-3.3.7.code-workspace diff --git a/src/calamares/CalamaresApplication.cpp b/src/calamares/CalamaresApplication.cpp index 09d3bfc..a07edad 100644 --- a/src/calamares/CalamaresApplication.cpp +++ b/src/calamares/CalamaresApplication.cpp @@ -1,302 +1,303 @@ -/* === This file is part of Calamares - === - * - * SPDX-FileCopyrightText: 2014-2015 Teo Mrnjavac - * SPDX-FileCopyrightText: 2018 Adriaan de Groot - * SPDX-License-Identifier: GPL-3.0-or-later - * - * Calamares is Free Software: see the License-Identifier above. - * - */ -#include "CalamaresApplication.h" - -#include "CalamaresConfig.h" -#include "CalamaresVersionX.h" -#include "CalamaresWindow.h" -#include "progresstree/ProgressTreeView.h" - -#include "Branding.h" -#include "JobQueue.h" -#include "Settings.h" -#include "ViewManager.h" -#include "locale/TranslationsModel.h" -#include "modulesystem/ModuleManager.h" -#include "utils/Dirs.h" -#include "utils/Gui.h" -#include "utils/Logger.h" -#include "utils/System.h" -#ifdef WITH_QML -#include "utils/Qml.h" -#endif -#include "utils/Retranslator.h" -#include "viewpages/ViewStep.h" - -#include -#include -#include -#include - -/// @brief Convenience for "are the settings in debug mode" -static bool -isDebug() -{ - return Calamares::Settings::instance() && Calamares::Settings::instance()->debugMode(); -} - -CalamaresApplication::CalamaresApplication( int& argc, char* argv[] ) - : QApplication( argc, argv ) - , m_mainwindow( nullptr ) - , m_moduleManager( nullptr ) -{ - // Setting the organization name makes the default cache - // directory -- where Calamares stores logs, for instance -- - // //, so we end up with ~/.cache/Calamares/calamares/ - // which is excessively squidly. - // - // setOrganizationName( QStringLiteral( CALAMARES_ORGANIZATION_NAME ) ); - setOrganizationDomain( QStringLiteral( CALAMARES_ORGANIZATION_DOMAIN ) ); - setApplicationName( QStringLiteral( CALAMARES_APPLICATION_NAME ) ); - setApplicationVersion( QStringLiteral( CALAMARES_VERSION ) ); - - QFont f = font(); - Calamares::setDefaultFontSize( f.pointSize() ); -} - -void -CalamaresApplication::init() -{ - Logger::setupLogfile(); - cDebug() << "Calamares version:" << CALAMARES_VERSION; - cDebug() << Logger::SubEntry << "Using Qt version:" << qVersion(); - cDebug() << Logger::SubEntry << "Build type:" << CMAKE_BUILD_TYPE; -#ifdef WITH_PYBIND11 - cDebug() << Logger::SubEntry << "Using PyBind11"; -#endif -#ifdef WITH_BOOST_PYTHON - cDebug() << Logger::SubEntry << "Using Boost Python"; -#endif - cDebug() << Logger::SubEntry << "Using settings:" << Calamares::Settings::instance()->path(); - cDebug() << Logger::SubEntry << "Using log file:" << Logger::logFile(); - cDebug() << Logger::SubEntry << "Languages:" << Calamares::Locale::availableLanguages(); - - if ( !Calamares::Settings::instance() ) - { - cError() << "Must create Calamares::Settings before the application."; - ::exit( 1 ); - } - initQmlPath(); - initBranding(); - - Calamares::installTranslator(); - - setQuitOnLastWindowClosed( false ); - setWindowIcon( QIcon( Calamares::Branding::instance()->imagePath( Calamares::Branding::ProductIcon ) ) ); - - cDebug() << Logger::SubEntry << "STARTUP: initSettings, initQmlPath, initBranding done"; - - initModuleManager(); //also shows main window - - cDebug() << Logger::SubEntry << "STARTUP: initModuleManager: module init started"; -} - -CalamaresApplication::~CalamaresApplication() -{ - Logger::CDebug( Logger::LOGVERBOSE ) << "Shutting down Calamares..."; - Logger::CDebug( Logger::LOGVERBOSE ) << Logger::SubEntry << "Finished shutdown."; -} - -CalamaresApplication* -CalamaresApplication::instance() -{ - return qobject_cast< CalamaresApplication* >( QApplication::instance() ); -} - -CalamaresWindow* -CalamaresApplication::mainWindow() -{ - return m_mainwindow; -} - -static QStringList -brandingFileCandidates( bool assumeBuilddir, const QString& brandingFilename ) -{ - QStringList brandingPaths; - if ( Calamares::isAppDataDirOverridden() ) - { - brandingPaths << Calamares::appDataDir().absoluteFilePath( brandingFilename ); - } - else - { - if ( assumeBuilddir ) - { - brandingPaths << ( QDir::currentPath() + QStringLiteral( "/src/" ) + brandingFilename ); - } - if ( Calamares::haveExtraDirs() ) - { - for ( auto s : Calamares::extraDataDirs() ) - { - brandingPaths << ( s + brandingFilename ); - } - } - brandingPaths << QDir( CMAKE_INSTALL_FULL_SYSCONFDIR "/calamares/" ).absoluteFilePath( brandingFilename ); - brandingPaths << Calamares::appDataDir().absoluteFilePath( brandingFilename ); - } - - return brandingPaths; -} - -void -CalamaresApplication::initQmlPath() -{ -#ifdef WITH_QML - if ( !Calamares::initQmlModulesDir() ) - { - ::exit( EXIT_FAILURE ); - } -#endif -} - -void -CalamaresApplication::initBranding() -{ - QString brandingComponentName = Calamares::Settings::instance()->brandingComponentName(); - if ( brandingComponentName.simplified().isEmpty() ) - { - cError() << "FATAL: branding component not set in settings.conf"; - ::exit( EXIT_FAILURE ); - } - - QString brandingDescriptorSubpath = QString( "branding/%1/branding.desc" ).arg( brandingComponentName ); - QStringList brandingFileCandidatesByPriority = brandingFileCandidates( isDebug(), brandingDescriptorSubpath ); - - QFileInfo brandingFile; - bool found = false; - - foreach ( const QString& path, brandingFileCandidatesByPriority ) - { - QFileInfo pathFi( path ); - if ( pathFi.exists() && pathFi.isReadable() ) - { - brandingFile = pathFi; - found = true; - break; - } - } - - if ( !found || !brandingFile.exists() || !brandingFile.isReadable() ) - { - cError() << "Cowardly refusing to continue startup without branding." - << Logger::DebugList( brandingFileCandidatesByPriority ); - if ( Calamares::isAppDataDirOverridden() ) - { - cError() << "FATAL: explicitly configured application data directory is missing" << brandingComponentName; - } - else - { - cError() << "FATAL: none of the expected branding descriptor file paths exist."; - } - ::exit( EXIT_FAILURE ); - } - - new Calamares::Branding( brandingFile.absoluteFilePath(), this, devicePixelRatio() ); -} - -void -CalamaresApplication::initModuleManager() -{ - m_moduleManager = new Calamares::ModuleManager( Calamares::Settings::instance()->modulesSearchPaths(), this ); - connect( m_moduleManager, &Calamares::ModuleManager::initDone, this, &CalamaresApplication::initView ); - m_moduleManager->init(); -} - -/** @brief centers the widget @p w on (a) screen - * - * This tries to duplicate the (deprecated) qApp->desktop()->availableGeometry() - * placement by iterating over screens and putting Calamares in the first - * one where it fits; this is *generally* the primary screen. - * - * With debugging, it would look something like this (2 screens attached, - * primary at +1080+240 because I have a very strange X setup). Before - * being mapped, the Calamares window is at +0+0 but does have a size. - * The first screen's geometry includes the offset from the origin in - * screen coordinates. - * - * Proposed window size: 1024 520 - * Window QRect(0,0 1024x520) - * Screen QRect(1080,240 2560x1440) - * Moving QPoint(1848,700) - * Screen QRect(0,0 1080x1920) - * - */ -static void -centerWindowOnScreen( QWidget* w ) -{ - QList< QScreen* > screens = qApp->screens(); - QPoint windowCenter = w->rect().center(); - QSize windowSize = w->rect().size(); - - for ( const auto* screen : screens ) - { - QSize screenSize = screen->availableGeometry().size(); - if ( ( screenSize.width() >= windowSize.width() ) && ( screenSize.height() >= windowSize.height() ) ) - { - w->move( screen->availableGeometry().center() - windowCenter ); - break; - } - } -} - -void -CalamaresApplication::initView() -{ - cDebug() << "STARTUP: initModuleManager: all modules init done"; - initJobQueue(); - cDebug() << "STARTUP: initJobQueue done"; - - m_mainwindow = new CalamaresWindow(); //also creates ViewManager - - connect( m_moduleManager, &Calamares::ModuleManager::modulesLoaded, this, &CalamaresApplication::initViewSteps ); - connect( m_moduleManager, &Calamares::ModuleManager::modulesFailed, this, &CalamaresApplication::initFailed ); - - QTimer::singleShot( 0, m_moduleManager, &Calamares::ModuleManager::loadModules ); - - if ( Calamares::Branding::instance() && Calamares::Branding::instance()->windowPlacementCentered() ) - { - centerWindowOnScreen( m_mainwindow ); - } - cDebug() << "STARTUP: CalamaresWindow created; loadModules started"; -} - -void -CalamaresApplication::initViewSteps() -{ - cDebug() << "STARTUP: loadModules for all modules done"; - m_moduleManager->checkRequirements(); - if ( Calamares::Branding::instance()->windowMaximize() ) - { - m_mainwindow->setWindowFlag( Qt::FramelessWindowHint ); - m_mainwindow->showMaximized(); - } - else - { - m_mainwindow->show(); - } - - cDebug() << "STARTUP: Window now visible and ProgressTreeView populated"; - cDebug() << Logger::SubEntry << Calamares::ViewManager::instance()->viewSteps().count() << "view steps loaded."; - Calamares::ViewManager::instance()->onInitComplete(); -} - -void -CalamaresApplication::initFailed( const QStringList& l ) -{ - cError() << "STARTUP: failed modules are" << l; - m_mainwindow->show(); -} - -void -CalamaresApplication::initJobQueue() -{ - Calamares::JobQueue* jobQueue = new Calamares::JobQueue( this ); - new Calamares::System( Calamares::Settings::instance()->doChroot(), this ); - Calamares::Branding::instance()->setGlobals( jobQueue->globalStorage() ); -} +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2014-2015 Teo Mrnjavac + * SPDX-FileCopyrightText: 2018 Adriaan de Groot + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Calamares is Free Software: see the License-Identifier above. + * + */ +#include "CalamaresApplication.h" + +#include "CalamaresConfig.h" +#include "CalamaresVersionX.h" +#include "CalamaresWindow.h" +#include "progresstree/ProgressTreeView.h" + +#include "Branding.h" +#include "JobQueue.h" +#include "Settings.h" +#include "ViewManager.h" +#include "locale/TranslationsModel.h" +#include "modulesystem/ModuleManager.h" +#include "utils/Dirs.h" +#include "utils/Gui.h" +#include "utils/Logger.h" +#include "utils/System.h" +#ifdef WITH_QML +#include "utils/Qml.h" +#endif +#include "utils/Retranslator.h" +#include "viewpages/ViewStep.h" + +#include +#include +#include +#include + +/// @brief Convenience for "are the settings in debug mode" +static bool +isDebug() +{ + return Calamares::Settings::instance() && Calamares::Settings::instance()->debugMode(); +} + +CalamaresApplication::CalamaresApplication( int& argc, char* argv[] ) + : QApplication( argc, argv ) + , m_mainwindow( nullptr ) + , m_moduleManager( nullptr ) +{ + // Setting the organization name makes the default cache + // directory -- where Calamares stores logs, for instance -- + // //, so we end up with ~/.cache/Calamares/calamares/ + // which is excessively squidly. + // + // setOrganizationName( QStringLiteral( CALAMARES_ORGANIZATION_NAME ) ); + setOrganizationDomain( QStringLiteral( CALAMARES_ORGANIZATION_DOMAIN ) ); + setApplicationName( QStringLiteral( CALAMARES_APPLICATION_NAME ) ); + setApplicationVersion( QStringLiteral( CALAMARES_VERSION ) ); + + QFont f = font(); + Calamares::setDefaultFontSize( f.pointSize() ); +} + +void +CalamaresApplication::init() +{ + Logger::setupLogfile(); + cDebug() << "Calamares version:" << CALAMARES_VERSION; + cDebug() << Logger::SubEntry << "Using Qt version:" << qVersion(); + cDebug() << Logger::SubEntry << "Build type:" << CMAKE_BUILD_TYPE; +#ifdef WITH_PYBIND11 + cDebug() << Logger::SubEntry << "Using PyBind11"; +#endif +#ifdef WITH_BOOST_PYTHON + cDebug() << Logger::SubEntry << "Using Boost Python"; +#endif + cDebug() << Logger::SubEntry << "Using settings:" << Calamares::Settings::instance()->path(); + cDebug() << Logger::SubEntry << "Using log file:" << Logger::logFile(); + cDebug() << Logger::SubEntry << "Languages:" << Calamares::Locale::availableLanguages(); + + if ( !Calamares::Settings::instance() ) + { + cError() << "Must create Calamares::Settings before the application."; + ::exit( 1 ); + } + initQmlPath(); + initBranding(); + + Calamares::installTranslator(); + + setQuitOnLastWindowClosed( false ); + setWindowIcon( QIcon( Calamares::Branding::instance()->imagePath( Calamares::Branding::ProductIcon ) ) ); + + cDebug() << Logger::SubEntry << "STARTUP: initSettings, initQmlPath, initBranding done"; + + initModuleManager(); //also shows main window + + cDebug() << Logger::SubEntry << "STARTUP: initModuleManager: module init started"; +} + +CalamaresApplication::~CalamaresApplication() +{ + Logger::CDebug( Logger::LOGVERBOSE ) << "Shutting down Calamares..."; + Logger::CDebug( Logger::LOGVERBOSE ) << Logger::SubEntry << "Finished shutdown."; +} + +CalamaresApplication* +CalamaresApplication::instance() +{ + return qobject_cast< CalamaresApplication* >( QApplication::instance() ); +} + +CalamaresWindow* +CalamaresApplication::mainWindow() +{ + return m_mainwindow; +} + +static QStringList +brandingFileCandidates( bool assumeBuilddir, const QString& brandingFilename ) +{ + QStringList brandingPaths; + if ( Calamares::isAppDataDirOverridden() ) + { + brandingPaths << Calamares::appDataDir().absoluteFilePath( brandingFilename ); + } + else + { + if ( assumeBuilddir ) + { + brandingPaths << ( QDir::currentPath() + QStringLiteral( "/src/" ) + brandingFilename ); + } + if ( Calamares::haveExtraDirs() ) + { + for ( auto s : Calamares::extraDataDirs() ) + { + brandingPaths << ( s + brandingFilename ); + } + } + brandingPaths << QDir( CMAKE_INSTALL_FULL_SYSCONFDIR "/calamares/" ).absoluteFilePath( brandingFilename ); + brandingPaths << Calamares::appDataDir().absoluteFilePath( brandingFilename ); + } + + return brandingPaths; +} + +void +CalamaresApplication::initQmlPath() +{ +#ifdef WITH_QML + if ( !Calamares::initQmlModulesDir() ) + { + ::exit( EXIT_FAILURE ); + } +#endif +} + +void +CalamaresApplication::initBranding() +{ + QString brandingComponentName = Calamares::Settings::instance()->brandingComponentName(); + if ( brandingComponentName.simplified().isEmpty() ) + { + cError() << "FATAL: branding component not set in settings.conf"; + ::exit( EXIT_FAILURE ); + } + + QString brandingDescriptorSubpath = QString( "branding/%1/branding.desc" ).arg( brandingComponentName ); + QStringList brandingFileCandidatesByPriority = brandingFileCandidates( isDebug(), brandingDescriptorSubpath ); + cDebug() << "brandingFileCandidatesByPriority" << brandingFileCandidatesByPriority; + + QFileInfo brandingFile; + bool found = false; + + foreach ( const QString& path, brandingFileCandidatesByPriority ) + { + QFileInfo pathFi( path ); + if ( pathFi.exists() && pathFi.isReadable() ) + { + brandingFile = pathFi; + found = true; + break; + } + } + + if ( !found || !brandingFile.exists() || !brandingFile.isReadable() ) + { + cError() << "Cowardly refusing to continue startup without branding." + << Logger::DebugList( brandingFileCandidatesByPriority ); + if ( Calamares::isAppDataDirOverridden() ) + { + cError() << "FATAL: explicitly configured application data directory is missing" << brandingComponentName; + } + else + { + cError() << "FATAL: none of the expected branding descriptor file paths exist."; + } + ::exit( EXIT_FAILURE ); + } + + new Calamares::Branding( brandingFile.absoluteFilePath(), this, devicePixelRatio() ); +} + +void +CalamaresApplication::initModuleManager() +{ + m_moduleManager = new Calamares::ModuleManager( Calamares::Settings::instance()->modulesSearchPaths(), this ); + connect( m_moduleManager, &Calamares::ModuleManager::initDone, this, &CalamaresApplication::initView ); + m_moduleManager->init(); +} + +/** @brief centers the widget @p w on (a) screen + * + * This tries to duplicate the (deprecated) qApp->desktop()->availableGeometry() + * placement by iterating over screens and putting Calamares in the first + * one where it fits; this is *generally* the primary screen. + * + * With debugging, it would look something like this (2 screens attached, + * primary at +1080+240 because I have a very strange X setup). Before + * being mapped, the Calamares window is at +0+0 but does have a size. + * The first screen's geometry includes the offset from the origin in + * screen coordinates. + * + * Proposed window size: 1024 520 + * Window QRect(0,0 1024x520) + * Screen QRect(1080,240 2560x1440) + * Moving QPoint(1848,700) + * Screen QRect(0,0 1080x1920) + * + */ +static void +centerWindowOnScreen( QWidget* w ) +{ + QList< QScreen* > screens = qApp->screens(); + QPoint windowCenter = w->rect().center(); + QSize windowSize = w->rect().size(); + + for ( const auto* screen : screens ) + { + QSize screenSize = screen->availableGeometry().size(); + if ( ( screenSize.width() >= windowSize.width() ) && ( screenSize.height() >= windowSize.height() ) ) + { + w->move( screen->availableGeometry().center() - windowCenter ); + break; + } + } +} + +void +CalamaresApplication::initView() +{ + cDebug() << "STARTUP: initModuleManager: all modules init done"; + initJobQueue(); + cDebug() << "STARTUP: initJobQueue done"; + + m_mainwindow = new CalamaresWindow(); //also creates ViewManager + + connect( m_moduleManager, &Calamares::ModuleManager::modulesLoaded, this, &CalamaresApplication::initViewSteps ); + connect( m_moduleManager, &Calamares::ModuleManager::modulesFailed, this, &CalamaresApplication::initFailed ); + + QTimer::singleShot( 0, m_moduleManager, &Calamares::ModuleManager::loadModules ); + + if ( Calamares::Branding::instance() && Calamares::Branding::instance()->windowPlacementCentered() ) + { + centerWindowOnScreen( m_mainwindow ); + } + cDebug() << "STARTUP: CalamaresWindow created; loadModules started"; +} + +void +CalamaresApplication::initViewSteps() +{ + cDebug() << "STARTUP: loadModules for all modules done"; + m_moduleManager->checkRequirements(); + if ( Calamares::Branding::instance()->windowMaximize() ) + { + m_mainwindow->setWindowFlag( Qt::FramelessWindowHint ); + m_mainwindow->showMaximized(); + } + else + { + m_mainwindow->show(); + } + + cDebug() << "STARTUP: Window now visible and ProgressTreeView populated"; + cDebug() << Logger::SubEntry << Calamares::ViewManager::instance()->viewSteps().count() << "view steps loaded."; + Calamares::ViewManager::instance()->onInitComplete(); +} + +void +CalamaresApplication::initFailed( const QStringList& l ) +{ + cError() << "STARTUP: failed modules are" << l; + m_mainwindow->show(); +} + +void +CalamaresApplication::initJobQueue() +{ + Calamares::JobQueue* jobQueue = new Calamares::JobQueue( this ); + new Calamares::System( Calamares::Settings::instance()->doChroot(), this ); + Calamares::Branding::instance()->setGlobals( jobQueue->globalStorage() ); +} diff --git a/src/calamares/CalamaresApplication.h b/src/calamares/CalamaresApplication.h index 77cf3a0..0a99d26 100644 --- a/src/calamares/CalamaresApplication.h +++ b/src/calamares/CalamaresApplication.h @@ -1,64 +1,64 @@ -/* === This file is part of Calamares - === - * - * SPDX-FileCopyrightText: 2014-2015 Teo Mrnjavac - * SPDX-FileCopyrightText: 2018-2019 Adriaan de Groot - * SPDX-License-Identifier: GPL-3.0-or-later - * - * Calamares is Free Software: see the License-Identifier above. - * - */ - -#ifndef CALAMARESAPPLICATION_H -#define CALAMARESAPPLICATION_H - -#include - -class CalamaresWindow; - -namespace Calamares -{ -class ModuleManager; -} // namespace Calamares - - -/** - * @brief The CalamaresApplication class extends QApplication to handle - * Calamares startup and lifetime of main components. - */ -class CalamaresApplication : public QApplication -{ - Q_OBJECT -public: - CalamaresApplication( int& argc, char* argv[] ); - ~CalamaresApplication() override; - - /** - * @brief init handles the first part of Calamares application startup. - * After the main window shows up, the latter part of the startup sequence - * (including modules loading) happens asynchronously. - */ - void init(); - static CalamaresApplication* instance(); - - /** - * @brief mainWindow returns the Calamares application main window. - */ - CalamaresWindow* mainWindow(); - -private slots: - void initView(); - void initViewSteps(); - void initFailed( const QStringList& l ); - -private: - // Initialization steps happen in this order - void initQmlPath(); - void initBranding(); - void initModuleManager(); - void initJobQueue(); - - CalamaresWindow* m_mainwindow; - Calamares::ModuleManager* m_moduleManager; -}; - -#endif // CALAMARESAPPLICATION_H +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2014-2015 Teo Mrnjavac + * SPDX-FileCopyrightText: 2018-2019 Adriaan de Groot + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Calamares is Free Software: see the License-Identifier above. + * + */ + +#ifndef CALAMARESAPPLICATION_H +#define CALAMARESAPPLICATION_H + +#include + +class CalamaresWindow; + +namespace Calamares +{ +class ModuleManager; +} // namespace Calamares + + +/** + * @brief The CalamaresApplication class extends QApplication to handle + * Calamares startup and lifetime of main components. + */ +class CalamaresApplication : public QApplication +{ + Q_OBJECT +public: + CalamaresApplication( int& argc, char* argv[] ); + ~CalamaresApplication() override; + + /** + * @brief init handles the first part of Calamares application startup. + * After the main window shows up, the latter part of the startup sequence + * (including modules loading) happens asynchronously. + */ + void init(); + static CalamaresApplication* instance(); + + /** + * @brief mainWindow returns the Calamares application main window. + */ + CalamaresWindow* mainWindow(); + +private slots: + void initView(); + void initViewSteps(); + void initFailed( const QStringList& l ); + +private: + // Initialization steps happen in this order + void initQmlPath(); + void initBranding(); + void initModuleManager(); + void initJobQueue(); + + CalamaresWindow* m_mainwindow; + Calamares::ModuleManager* m_moduleManager; +}; + +#endif // CALAMARESAPPLICATION_H diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index e1892e7..4721cb9 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -104,20 +104,23 @@ getWidgetSidebar( Calamares::DebugWindowManager* debug, Calamares::ViewManager* viewManager, QWidget* parent, Qt::Orientation, - int desiredWidth ) + int desiredWidth + ) { const Calamares::Branding* const branding = Calamares::Branding::instance(); - + QWidget* sideBox = new QWidget( parent ); sideBox->setObjectName( "sidebarApp" ); - QBoxLayout* sideLayout = new QVBoxLayout; + QBoxLayout* sideLayout = new QHBoxLayout; + sideLayout->addSpacing(10); sideBox->setLayout( sideLayout ); // Set this attribute into qss file sideBox->setFixedWidth( desiredWidth ); + sideBox->setFixedHeight( parent->height()*0.13 ); sideBox->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - QHBoxLayout* logoLayout = new QHBoxLayout; + QBoxLayout* logoLayout = new QVBoxLayout; sideLayout->addLayout( logoLayout ); logoLayout->addStretch(); QLabel* logoLabel = new QLabel( sideBox ); @@ -132,19 +135,19 @@ getWidgetSidebar( Calamares::DebugWindowManager* debug, logoLabel->setPalette( plt ); } logoLabel->setAlignment( Qt::AlignCenter ); - logoLabel->setFixedSize( 80, 80 ); + logoLabel->setFixedSize( 388*0.3, 96*0.3 ); logoLabel->setPixmap( branding->image( Calamares::Branding::ProductLogo, logoLabel->size() ) ); - logoLayout->addWidget( logoLabel ); + logoLayout->addWidget( logoLabel ,2); logoLayout->addStretch(); - + sideLayout->addSpacing(10); ProgressTreeView* tv = new ProgressTreeView( sideBox ); tv->setModel( viewManager ); tv->setFocusPolicy( Qt::NoFocus ); - sideLayout->addWidget( tv ); - - QHBoxLayout* extraButtons = new QHBoxLayout; - sideLayout->addLayout( extraButtons ); + sideLayout->addWidget( tv ,20); + QBoxLayout* extraButtons = new QVBoxLayout; + sideLayout->addLayout( extraButtons ,1); + sideLayout->addSpacing(15); const int defaultFontHeight = Calamares::defaultFontHeight(); if ( /* About-Calamares Button enabled */ true ) @@ -154,13 +157,17 @@ getWidgetSidebar( Calamares::DebugWindowManager* debug, aboutDialog->setIcon( Calamares::defaultPixmap( Calamares::Information, Calamares::Original, 2 * QSize( defaultFontHeight, defaultFontHeight ) ) ); CALAMARES_RETRANSLATE_FOR( - aboutDialog, aboutDialog->setText( QCoreApplication::translate( "calamares-sidebar", "About", "@button" ) ); + aboutDialog, aboutDialog->setText( QCoreApplication::translate( "calamares-sidebar", "", "@button" ) ); aboutDialog->setToolTip( - QCoreApplication::translate( "calamares-sidebar", "Show information about Calamares", "@tooltip" ) ); ); + QCoreApplication::translate( "calamares-sidebar", "Show information about easysoftware", "@tooltip" ) ); ); extraButtons->addWidget( aboutDialog ); aboutDialog->setFlat( true ); aboutDialog->setCheckable( true ); - QObject::connect( aboutDialog, &QPushButton::clicked, debug, &Calamares::DebugWindowManager::about ); + QObject::connect( aboutDialog, &QPushButton::clicked, [aboutDialog,debug](){ + aboutDialog->setDown(false); + aboutDialog->setChecked(false); + debug->about(); + } ); } if ( debug && debug->enabled() ) { @@ -182,6 +189,7 @@ getWidgetSidebar( Calamares::DebugWindowManager* debug, } Calamares::unmarginLayout( sideLayout ); + return sideBox; } @@ -246,7 +254,8 @@ getWidgetNavigation( Calamares::DebugWindowManager*, bottomLayout->addWidget( quit ); } - bottomLayout->setContentsMargins( 0, 0, 6, 6 ); + + bottomLayout->setContentsMargins( 0, 0,40,40 ); navigation->setLayout( bottomLayout ); return navigation; } @@ -271,7 +280,7 @@ setDimension( QQuickWidget* w, Qt::Orientation o, int desiredWidth ) // Bound between (16, 64) with a default of 48. qreal minimumHeight = qBound( qreal( 16 ), w->rootObject() ? w->rootObject()->height() : 48, qreal( 64 ) ); w->setMinimumHeight( int( minimumHeight ) ); - w->setFixedHeight( int( minimumHeight ) ); + w->setFixedHeight( int( minimumHeight )); } w->setResizeMode( QQuickWidget::SizeRootObjectToView ); } @@ -417,7 +426,7 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) // Needs to match what's checked in DebugWindow this->setObjectName( "mainApp" ); - + this->setWindowFlags(Qt::FramelessWindowHint); QSize availableSize = desktopSize( this ); QSize minimumSize( qBound( windowMinimumWidth, availableSize.width(), windowPreferredWidth ), qBound( windowMinimumHeight, availableSize.height(), windowPreferredHeight ) ); @@ -429,26 +438,26 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) int w = qBound( minimumSize.width(), windowDimensionToPixels( brandingSizes.first ), availableSize.width() ); int h = qBound( minimumSize.height(), windowDimensionToPixels( brandingSizes.second ), availableSize.height() ); - - cDebug() << Logger::SubEntry << "Proposed window size:" << w << h; - resize( w, h ); - - QWidget* baseWidget = this; - if ( !( branding->imagePath( ImageEntry::ProductWallpaper ).isEmpty() ) ) - { - QWidget* label = new QWidget( this ); - QVBoxLayout* l = new QVBoxLayout; - Calamares::unmarginLayout( l ); - l->addWidget( label ); - setLayout( l ); - label->setObjectName( "backgroundWidget" ); - label->setStyleSheet( - QStringLiteral( "#backgroundWidget { background-image: url(%1); background-repeat: repeat-xy; }" ) + + cDebug() << Logger::SubEntry << "Proposed window size:" << w << h; + //resize( availableSize.width(), availableSize.height() );//通用桌面大小作为窗口大小 + resize( w, h );//通用桌面大小作为窗口大小 + QWidget* baseWidget = this; + if ( !( branding->imagePath( ImageEntry::ProductWallpaper ).isEmpty() ) ) + { + QWidget* label = new QWidget( this ); + QVBoxLayout* l = new QVBoxLayout; + Calamares::unmarginLayout( l ); + l->addWidget( label ); + setLayout( l ); + label->setObjectName( "backgroundWidget" ); + label->setFixedSize(availableSize.width(),h); + label->setStyleSheet( + QStringLiteral( "#backgroundWidget { background-image: url(%1); background-repeat: No repeat; }" ) .arg( branding->imagePath( ImageEntry::ProductWallpaper ) ) ); - + baseWidget = label; } - m_viewManager = Calamares::ViewManager::instance( baseWidget ); if ( branding->windowExpands() ) { @@ -463,7 +472,7 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) // is too annoying. Instead, leave it up to ignoring-the-quit- // event, which is also the ViewManager's responsibility. - QBoxLayout* mainLayout = new QHBoxLayout; + QBoxLayout* mainLayout = new QVBoxLayout; QBoxLayout* contentsLayout = new QVBoxLayout; contentsLayout->setSpacing( 0 ); @@ -474,7 +483,7 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) baseWidget, ::getWidgetSidebar, ::getQmlSidebar, - qBound( 100, Calamares::defaultFontHeight() * 12, w < windowPreferredWidth ? 100 : 190 ) ); + qBound( w, Calamares::defaultFontHeight() * 12, w < windowPreferredWidth ? 200 : 290 )); QWidget* navigation = flavoredWidget( branding->navigationFlavor(), ::orientation( branding->navigationSide() ), m_debugManager, @@ -482,9 +491,9 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) ::getWidgetNavigation, ::getQmlNavigation, 64 ); - // Build up the contentsLayout (a VBox) top-to-bottom // .. note that the bottom is mirrored wrt. the top + sideBox->resize(availableSize.width(),300); insertIf( contentsLayout, PanelSide::Top, sideBox, branding->sidebarSide() ); insertIf( contentsLayout, PanelSide::Top, navigation, branding->navigationSide() ); contentsLayout->addWidget( m_viewManager->centralWidget() ); @@ -497,7 +506,7 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) mainLayout->addLayout( contentsLayout ); insertIf( mainLayout, PanelSide::Right, navigation, branding->navigationSide() ); insertIf( mainLayout, PanelSide::Right, sideBox, branding->sidebarSide() ); - + connect(m_viewManager, &Calamares::ViewManager::currentStepChanged, [ = ]( int currentStep ) { sideBox->setVisible(currentStep > 0); } ); // layout->count() returns number of things in it; above we have put // at **least** the central widget, which comes from the view manager, // both vertically and horizontally -- so if there's a panel along @@ -510,6 +519,9 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) Calamares::unmarginLayout( contentsLayout ); baseWidget->setLayout( mainLayout ); setStyleSheet( Calamares::Branding::instance()->stylesheet() ); + cDebug()<<"<---------------------------WindowWindowSize-------------------------------------->"<size(); + cDebug()<< "<--------------------sideBox->size()-------------------->"<< sideBox->size(); + this->setFixedSize(this->size()); } void diff --git a/src/calamares/CalamaresWindow.h b/src/calamares/CalamaresWindow.h index f5dd7fe..e2a0fea 100644 --- a/src/calamares/CalamaresWindow.h +++ b/src/calamares/CalamaresWindow.h @@ -1,50 +1,50 @@ -/* === This file is part of Calamares - === - * - * SPDX-FileCopyrightText: 2014-2015 Teo Mrnjavac - * SPDX-FileCopyrightText: 2017-2018 Adriaan de Groot - * SPDX-License-Identifier: GPL-3.0-or-later - * - * Calamares is Free Software: see the License-Identifier above. - * - */ - -#ifndef CALAMARESWINDOW_H -#define CALAMARESWINDOW_H - -#include - -#include - -namespace Calamares -{ -class DebugWindowManager; -class ViewManager; -} // namespace Calamares - -/** - * @brief The CalamaresWindow class represents the main window of the Calamares UI. - */ -class CalamaresWindow : public QWidget -{ - Q_OBJECT -public: - CalamaresWindow( QWidget* parent = nullptr ); - ~CalamaresWindow() override {} - -public Q_SLOTS: - /** - * This asks the main window to grow to accomodate @p size pixels, to accomodate - * larger-than-expected window contents. The enlargement may be silently - * ignored. - */ - void ensureSize( QSize size ); - -protected: - virtual void closeEvent( QCloseEvent* e ) override; - -private: - Calamares::DebugWindowManager* m_debugManager = nullptr; - Calamares::ViewManager* m_viewManager = nullptr; -}; - -#endif // CALAMARESWINDOW_H +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2014-2015 Teo Mrnjavac + * SPDX-FileCopyrightText: 2017-2018 Adriaan de Groot + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Calamares is Free Software: see the License-Identifier above. + * + */ + +#ifndef CALAMARESWINDOW_H +#define CALAMARESWINDOW_H + +#include + +#include + +namespace Calamares +{ +class DebugWindowManager; +class ViewManager; +} // namespace Calamares + +/** + * @brief The CalamaresWindow class represents the main window of the Calamares UI. + */ +class CalamaresWindow : public QWidget +{ + Q_OBJECT +public: + CalamaresWindow( QWidget* parent = nullptr ); + ~CalamaresWindow() override {} + +public Q_SLOTS: + /** + * This asks the main window to grow to accomodate @p size pixels, to accomodate + * larger-than-expected window contents. The enlargement may be silently + * ignored. + */ + void ensureSize( QSize size ); + +protected: + virtual void closeEvent( QCloseEvent* e ) override; + +private: + Calamares::DebugWindowManager* m_debugManager = nullptr; + Calamares::ViewManager* m_viewManager = nullptr; +}; + +#endif // CALAMARESWINDOW_H diff --git a/src/calamares/DebugWindow.cpp b/src/calamares/DebugWindow.cpp index 51b3fca..b28661e 100644 --- a/src/calamares/DebugWindow.cpp +++ b/src/calamares/DebugWindow.cpp @@ -242,10 +242,18 @@ DebugWindowManager::about() QMessageBox::Ok, nullptr ); Calamares::fixButtonLabels( &mb ); + mb.setStyleSheet( + "QMessageBox {" + "border: 1px solid hsl(240,2%,79%);" + "border-radius: 5px;" + "background-color: #FFFFFF;" // 设置对话框背景颜色 + "}" + ); + mb.setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog); mb.setIconPixmap( - Calamares::defaultPixmap( Calamares::Squid, - Calamares::Original, - QSize( Calamares::defaultFontHeight() * 6, Calamares::defaultFontHeight() * 6 ) ) ); + Calamares::defaultPixmap( Calamares::BigLogo,//Biglogo.svg + Calamares::Original, + QSize( 321/1.9, 297/2 ) ) ); QGridLayout* layout = reinterpret_cast< QGridLayout* >( mb.layout() ); if ( layout ) { diff --git a/src/calamares/DebugWindow.ui b/src/calamares/DebugWindow.ui index 16cc4a4..649915e 100644 --- a/src/calamares/DebugWindow.ui +++ b/src/calamares/DebugWindow.ui @@ -1,157 +1,157 @@ - - - -SPDX-FileCopyrightText: 2015 Teo Mrnjavac <teo@kde.org> -SPDX-License-Identifier: GPL-3.0-or-later - - Calamares::DebugWindow - - - - 0 - 0 - 962 - 651 - - - - Form - - - - - - 0 - - - - GlobalStorage - - - - - - - - - - JobQueue - - - - - - - - - - Modules - - - - - - - - - - - - - Type: - - - - - - - none - - - - - - - Interface: - - - - - - - none - - - - - - - - - - - - - - - - - - - - Crashes Calamares, so that Dr. Konqi can look at it. - - - Crash now - - - - - - - - - - Reloads the stylesheet from the branding directory. - - - Reload Stylesheet - - - - - - - - - - Displays the tree of widget names in the log (for stylesheet debugging). - - - Widget Tree - - - - - - - - - - Uploads the session log to the configured pastebin. - - - Send Session Log - - - - - - - - - - - - - + + + +SPDX-FileCopyrightText: 2015 Teo Mrnjavac <teo@kde.org> +SPDX-License-Identifier: GPL-3.0-or-later + + Calamares::DebugWindow + + + + 0 + 0 + 962 + 651 + + + + Form + + + + + + 0 + + + + GlobalStorage + + + + + + + + + + JobQueue + + + + + + + + + + Modules + + + + + + + + + + + + + Type: + + + + + + + none + + + + + + + Interface: + + + + + + + none + + + + + + + + + + + + + + + + + + + + Crashes Calamares, so that Dr. Konqi can look at it. + + + Crash now + + + + + + + + + + Reloads the stylesheet from the branding directory. + + + Reload Stylesheet + + + + + + + + + + Displays the tree of widget names in the log (for stylesheet debugging). + + + Widget Tree + + + + + + + + + + Uploads the session log to the configured pastebin. + + + Send Session Log + + + + + + + + + + + + + diff --git a/src/calamares/calamares-3.3.7.code-workspace b/src/calamares/calamares-3.3.7.code-workspace new file mode 100644 index 0000000..100afc6 --- /dev/null +++ b/src/calamares/calamares-3.3.7.code-workspace @@ -0,0 +1,11 @@ +{ + "folders": [ + { + "path": "../../../calamares-3.3.7" + }, + { + "path": "../.." + } + ], + "settings": {} +} \ No newline at end of file -- 2.43.0