[calamares] Migrate the about-dialog to the debug (meta) window manager

- DebugWindowManager already manages not-really-Calamares windows
  like the Debug window, add About-Dialog to its responsibilities.
- Make about() accessible to the QML progress panel.
This commit is contained in:
Adriaan de Groot 2022-05-29 15:54:03 +02:00
parent 00898b18d6
commit d34f593562
4 changed files with 60 additions and 31 deletions

View File

@ -14,9 +14,7 @@
#include "CalamaresWindow.h"
#include "Branding.h"
#include "CalamaresAbout.h"
#include "CalamaresConfig.h"
#include "CalamaresVersion.h"
#include "DebugWindow.h"
#include "Settings.h"
#include "ViewManager.h"
@ -25,7 +23,6 @@
#include "utils/Logger.h"
#include "utils/Qml.h"
#include "utils/Retranslator.h"
#include "widgets/TranslationFix.h"
#include <QApplication>
#include <QBoxLayout>
@ -34,7 +31,6 @@
#include <QFile>
#include <QFileInfo>
#include <QLabel>
#include <QMessageBox>
#ifdef WITH_QML
#include <QQmlContext>
#include <QQmlEngine>
@ -91,30 +87,6 @@ setButtonIcon( QPushButton* button, const QString& name )
}
}
static void
showAboutBox()
{
QString title = Calamares::Settings::instance()->isSetupMode()
? QCoreApplication::translate( "WelcomePage", "About %1 setup" )
: QCoreApplication::translate( "WelcomePage", "About %1 installer" );
QMessageBox mb( QMessageBox::Information,
title.arg( CALAMARES_APPLICATION_NAME ),
Calamares::aboutString().arg( Calamares::Branding::instance()->versionedName() ),
QMessageBox::Ok,
nullptr );
Calamares::fixButtonLabels( &mb );
mb.setIconPixmap( CalamaresUtils::defaultPixmap(
CalamaresUtils::Squid,
CalamaresUtils::Original,
QSize( CalamaresUtils::defaultFontHeight() * 6, CalamaresUtils::defaultFontHeight() * 6 ) ) );
QGridLayout* layout = reinterpret_cast< QGridLayout* >( mb.layout() );
if ( layout )
{
layout->setColumnMinimumWidth( 2, CalamaresUtils::defaultFontHeight() * 24 );
}
mb.exec();
}
static QWidget*
getWidgetSidebar( Calamares::DebugWindowManager* debug,
Calamares::ViewManager* viewManager,
@ -177,7 +149,7 @@ getWidgetSidebar( Calamares::DebugWindowManager* debug,
extraButtons->addWidget( aboutDialog );
aboutDialog->setFlat( true );
aboutDialog->setCheckable( true );
QObject::connect( aboutDialog, &QPushButton::clicked, []() { showAboutBox(); } );
QObject::connect( aboutDialog, &QPushButton::clicked, debug, &Calamares::DebugWindowManager::about );
}
if ( debug && debug->enabled() )
{

View File

@ -12,6 +12,8 @@
#include "ui_DebugWindow.h"
#include "Branding.h"
#include "CalamaresAbout.h"
#include "CalamaresVersion.h"
#include "GlobalStorage.h"
#include "Job.h"
#include "JobQueue.h"
@ -19,9 +21,11 @@
#include "VariantModel.h"
#include "modulesystem/Module.h"
#include "modulesystem/ModuleManager.h"
#include "utils/CalamaresUtilsGui.h"
#include "utils/Logger.h"
#include "utils/Paste.h"
#include "utils/Retranslator.h"
#include "widgets/TranslationFix.h"
#ifdef WITH_PYTHONQT
#include "ViewManager.h"
@ -30,6 +34,7 @@
#include <gui/PythonQtScriptingConsole.h>
#endif
#include <QMessageBox>
#include <QSplitter>
#include <QStringListModel>
#include <QTreeView>
@ -307,5 +312,28 @@ DebugWindowManager::toggle()
show( !m_visible );
}
void
DebugWindowManager::about()
{
QString title = Calamares::Settings::instance()->isSetupMode()
? QCoreApplication::translate( "WelcomePage", "About %1 setup" )
: QCoreApplication::translate( "WelcomePage", "About %1 installer" );
QMessageBox mb( QMessageBox::Information,
title.arg( CALAMARES_APPLICATION_NAME ),
Calamares::aboutString().arg( Calamares::Branding::instance()->versionedName() ),
QMessageBox::Ok,
nullptr );
Calamares::fixButtonLabels( &mb );
mb.setIconPixmap( CalamaresUtils::defaultPixmap(
CalamaresUtils::Squid,
CalamaresUtils::Original,
QSize( CalamaresUtils::defaultFontHeight() * 6, CalamaresUtils::defaultFontHeight() * 6 ) ) );
QGridLayout* layout = reinterpret_cast< QGridLayout* >( mb.layout() );
if ( layout )
{
layout->setColumnMinimumWidth( 2, CalamaresUtils::defaultFontHeight() * 24 );
}
mb.exec();
}
} // namespace Calamares

View File

@ -49,11 +49,13 @@ private:
std::unique_ptr< VariantModel > m_module_model;
};
/** @brief Manager for the (single) DebugWindow
/** @brief Manager for meta-windows (Debug and About windows)
*
* Only one DebugWindow is expected to be around. This class manages
* (exactly one) DebugWindow and can create and destroy it as needed.
* It is available to the Calamares panels as object `DebugWindow`.
*
* The about() method shows a modal pop-up about Calamares.
*/
class DebugWindowManager : public QObject
{
@ -79,6 +81,8 @@ public Q_SLOTS:
void show( bool visible );
void toggle();
void about();
signals:
void visibleChanged( bool visible );

View File

@ -62,6 +62,31 @@ Rectangle {
}
Rectangle {
id: aboutArea
Layout.fillWidth: true;
height: 35
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
color: Branding.styleString( mouseArea.containsMouse ? Branding.SidebarTextHighlight : Branding.SidebarBackground);
visible: true;
MouseArea {
id: mouseAreaAbout
anchors.fill: parent;
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
Text {
anchors.verticalCenter: parent.verticalCenter;
x: parent.x + 4;
text: qsTr("About Calamares")
color: Branding.styleString( mouseArea.containsMouse ? Branding.SidebarTextSelect : Branding.SidebarBackground );
font.pointSize : 9
}
onClicked: debug.about()
}
}
Rectangle {
id: debugArea
Layout.fillWidth: true;
height: 35
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
@ -69,7 +94,7 @@ Rectangle {
visible: debug.enabled
MouseArea {
id: mouseArea
id: mouseAreaDebug
anchors.fill: parent;
cursorShape: Qt.PointingHandCursor
hoverEnabled: true