From 6bf0da7230260ddcf3f6afd6ec5820da87bb466c Mon Sep 17 00:00:00 2001 From: Artem Grinev Date: Sun, 5 Dec 2021 04:50:13 +0400 Subject: [PATCH 1/7] [libcalamaresui] Initial rework of error dialog --- src/libcalamaresui/CMakeLists.txt | 3 + src/libcalamaresui/ViewManager.cpp | 47 ++----- .../utils/ErrorDialog/ErrorDialog.cpp | 89 +++++++++++++ .../utils/ErrorDialog/ErrorDialog.h | 57 +++++++++ .../utils/ErrorDialog/ErrorDialog.ui | 120 ++++++++++++++++++ 5 files changed, 282 insertions(+), 34 deletions(-) create mode 100644 src/libcalamaresui/utils/ErrorDialog/ErrorDialog.cpp create mode 100644 src/libcalamaresui/utils/ErrorDialog/ErrorDialog.h create mode 100644 src/libcalamaresui/utils/ErrorDialog/ErrorDialog.ui diff --git a/src/libcalamaresui/CMakeLists.txt b/src/libcalamaresui/CMakeLists.txt index a704b7484..e745681f3 100644 --- a/src/libcalamaresui/CMakeLists.txt +++ b/src/libcalamaresui/CMakeLists.txt @@ -20,6 +20,7 @@ set( calamaresui_SOURCES utils/CalamaresUtilsGui.cpp utils/ImageRegistry.cpp utils/Paste.cpp + utils/ErrorDialog/ErrorDialog.cpp viewpages/BlankViewStep.cpp viewpages/ExecutionViewStep.cpp @@ -75,6 +76,8 @@ calamares_add_library( calamaresui Qt5::Svg RESOURCES libcalamaresui.qrc EXPORT Calamares + UI + utils/ErrorDialog/ErrorDialog.ui VERSION ${CALAMARES_VERSION_SHORT} ) target_link_libraries( calamaresui PRIVATE yamlcpp::yamlcpp ) diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index 57570ad64..ee521a02c 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -25,6 +25,7 @@ #include "viewpages/ExecutionViewStep.h" #include "viewpages/ViewStep.h" #include "widgets/TranslationFix.h" +#include "utils/ErrorDialog/ErrorDialog.h" #include #include @@ -32,6 +33,7 @@ #include #include #include +#include #define UPDATE_BUTTON_PROPERTY( name, value ) \ do \ @@ -159,44 +161,21 @@ ViewManager::onInstallationFailed( const QString& message, const QString& detail cDebug() << Logger::SubEntry << "- details:" << Logger::NoQuote << details; QString heading - = Calamares::Settings::instance()->isSetupMode() ? tr( "Setup Failed" ) : tr( "Installation Failed" ); - QString pasteMsg = tr( "Would you like to paste the install log to the web?" ); - QString text = "

" + message + "

"; - if ( !details.isEmpty() ) - { - text += "

" - + CalamaresUtils::truncateMultiLine( details, CalamaresUtils::LinesStartEnd { 6, 2 } ) - .replace( '\n', QStringLiteral( "
" ) ) - + "

"; - } - if ( shouldOfferWebPaste ) - { - text += "

" + pasteMsg + "

"; - } + = Calamares::Settings::instance()->isSetupMode() ? tr( "Setup Failed" ) : tr( "Installation Failed" ); - QMessageBox* msgBox = new QMessageBox(); - msgBox->setIcon( QMessageBox::Critical ); - msgBox->setWindowTitle( tr( "Error" ) ); - msgBox->setText( "" + heading + "" ); - msgBox->setInformativeText( text ); - if ( shouldOfferWebPaste ) - { - msgBox->setStandardButtons( QMessageBox::Yes | QMessageBox::No ); - msgBox->setDefaultButton( QMessageBox::No ); - } - else - { - msgBox->setStandardButtons( QMessageBox::Close ); - msgBox->setDefaultButton( QMessageBox::Close ); - } - Calamares::fixButtonLabels( msgBox ); - msgBox->show(); + ErrorDialog* errorDialog = new ErrorDialog(); + errorDialog->setWindowTitle( tr( "Error" ) ); + errorDialog->setHeading( "" + heading + "" ); + errorDialog->setInformativeText( message ); + errorDialog->setShouldOfferWebPaste(shouldOfferWebPaste); + errorDialog->setDetails(details); + errorDialog->show(); cDebug() << "Calamares will quit when the dialog closes."; - connect( msgBox, &QMessageBox::buttonClicked, [msgBox]( QAbstractButton* button ) { - if ( msgBox->buttonRole( button ) == QMessageBox::ButtonRole::YesRole ) + connect( errorDialog, &QDialog::finished, [errorDialog]( int result ) { + if ( result == QDialog::Accepted && errorDialog->shouldOfferWebPaste() ) { - CalamaresUtils::Paste::doLogUploadUI( msgBox ); + CalamaresUtils::Paste::doLogUploadUI( errorDialog ); } QApplication::quit(); } ); diff --git a/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.cpp b/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.cpp new file mode 100644 index 000000000..080ff2115 --- /dev/null +++ b/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.cpp @@ -0,0 +1,89 @@ +#include "ErrorDialog.h" +#include "ui_ErrorDialog.h" + +#include +#include + +namespace Calamares { + + +ErrorDialog::ErrorDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::ErrorDialog) +{ + ui->setupUi(this); + ui->iconLabel->setPixmap(QIcon::fromTheme("dialog-error").pixmap(64)); + ui->detailsWidget->hide(); + ui->offerWebPasteLabel->hide(); +} + +ErrorDialog::~ErrorDialog() +{ + delete ui; +} + + +QString ErrorDialog::heading() const +{ + return ui->headingLabel->text(); +} + +QString ErrorDialog::informativeText() const +{ + return ui->informativeTextLabel->text(); +} + +QString ErrorDialog::details() const +{ + return ui->detailsBrowser->toPlainText(); +} + +void ErrorDialog::setHeading(const QString &newHeading) +{ + if (ui->headingLabel->text() == newHeading) + return; + ui->headingLabel->setText(newHeading); + emit headingChanged(); +} + +void ErrorDialog::setInformativeText(const QString &newInformativeText) +{ + if (ui->informativeTextLabel->text() == newInformativeText) + return; + ui->informativeTextLabel->setText(newInformativeText); + emit informativeTextChanged(); +} + +void ErrorDialog::setDetails(const QString &newDetails) +{ + if (ui->detailsBrowser->toPlainText() == newDetails) + return; + ui->detailsBrowser->setPlainText(newDetails); + + ui->detailsWidget->setVisible(!ui->detailsBrowser->toPlainText().trimmed().isEmpty()); + + emit detailsChanged(); +} + +bool ErrorDialog::shouldOfferWebPaste() const +{ + return m_shouldOfferWebPaste; +} + +void ErrorDialog::setShouldOfferWebPaste(bool newShouldOfferWebPaste) +{ + if (m_shouldOfferWebPaste == newShouldOfferWebPaste) + return; + m_shouldOfferWebPaste = newShouldOfferWebPaste; + + ui->offerWebPasteLabel->setVisible(m_shouldOfferWebPaste); + + ui->buttonBox->setStandardButtons( m_shouldOfferWebPaste + ? (QDialogButtonBox::Yes | QDialogButtonBox::No) + : QDialogButtonBox::Close ); + + + emit shouldOfferWebPasteChanged(); +} + +} // namespace Calamares diff --git a/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.h b/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.h new file mode 100644 index 000000000..8962c3e99 --- /dev/null +++ b/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.h @@ -0,0 +1,57 @@ +#ifndef ERRORDIALOG_H +#define ERRORDIALOG_H + +#include + + +namespace Ui { +class ErrorDialog; +} +class QDialogButtonBox; +namespace Calamares +{ +class ErrorDialog : public QDialog +{ + Q_OBJECT + + Q_PROPERTY(QString heading READ heading WRITE setHeading NOTIFY headingChanged) + Q_PROPERTY(QString informativeText READ informativeText WRITE setInformativeText NOTIFY informativeTextChanged) + Q_PROPERTY(QString details READ details WRITE setDetails NOTIFY detailsChanged) + Q_PROPERTY(bool shouldOfferWebPaste READ shouldOfferWebPaste WRITE setShouldOfferWebPaste NOTIFY shouldOfferWebPasteChanged) + +public: + explicit ErrorDialog(QWidget *parent = nullptr); + ~ErrorDialog(); + + QString heading() const; + + QString informativeText() const; + + QString details() const; + + void setHeading(const QString &newHeading); + + void setInformativeText(const QString &newInformativeText); + + void setDetails(const QString &newDetails); + + bool shouldOfferWebPaste() const; + void setShouldOfferWebPaste(bool newShouldOfferWebPaste); + +signals: + void headingChanged(); + + void informativeTextChanged(); + + void detailsChanged(); + + void shouldOfferWebPasteChanged(); + +private: + Ui::ErrorDialog *ui; + bool m_shouldOfferWebPaste; +}; + +}; // namespace Calamares + +#endif // ERRORDIALOG_H diff --git a/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.ui b/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.ui new file mode 100644 index 000000000..2632af617 --- /dev/null +++ b/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.ui @@ -0,0 +1,120 @@ + + + ErrorDialog + + + + 0 + 0 + 425 + 262 + + + + Dialog + + + + + + + 0 + 0 + + + + + + + + + + + + + + Details: + + + + + + + + + + + + + + 0 + 0 + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + + Would you like to paste the install log to the web? + + + + + + + + + buttonBox + accepted() + ErrorDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + ErrorDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + From 32c5e18db0e75833e9ad599694edc0d040c9ae22 Mon Sep 17 00:00:00 2001 From: Artem Grinev Date: Mon, 6 Dec 2021 02:26:13 +0400 Subject: [PATCH 2/7] [libcalamaresui] Add QDialogButtonBox translation fix --- src/libcalamaresui/widgets/TranslationFix.cpp | 35 +++++++++++++------ src/libcalamaresui/widgets/TranslationFix.h | 3 ++ 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/libcalamaresui/widgets/TranslationFix.cpp b/src/libcalamaresui/widgets/TranslationFix.cpp index 1262fceb5..b73bd0e16 100644 --- a/src/libcalamaresui/widgets/TranslationFix.cpp +++ b/src/libcalamaresui/widgets/TranslationFix.cpp @@ -10,21 +10,16 @@ #include "TranslationFix.h" #include +#include #include #include +#include namespace Calamares { -void -fixButtonLabels( QMessageBox* box ) -{ - if ( !box ) - { - return; - } - - static std::pair< decltype( QMessageBox::Ok ), const char* > maps[] = { +//Using QMessageBox's StandardButton enum here but according to headers they should be kept in-sync between multiple classes. +static std::pair< decltype( QMessageBox::Ok ), const char* > maps[] = { { QMessageBox::Ok, QT_TRANSLATE_NOOP( "StandardButtons", "&OK" ) }, { QMessageBox::Yes, QT_TRANSLATE_NOOP( "StandardButtons", "&Yes" ) }, { QMessageBox::No, QT_TRANSLATE_NOOP( "StandardButtons", "&No" ) }, @@ -32,9 +27,17 @@ fixButtonLabels( QMessageBox* box ) { QMessageBox::Close, QT_TRANSLATE_NOOP( "StandardButtons", "&Close" ) }, }; +template +void fixButtonLabels ( TButtonBox* box ) +{ + if ( !box ) + { + return; + } + for ( auto [ sb, label ] : maps ) { - auto* button = box->button( sb ); + auto* button = box->button( static_cast(int(sb)) ); if ( button ) { button->setText( QCoreApplication::translate( "StandardButtons", label ) ); @@ -42,4 +45,16 @@ fixButtonLabels( QMessageBox* box ) } } +void +fixButtonLabels( QMessageBox* box ) +{ + fixButtonLabels(box); +} + +void +fixButtonLabels(QDialogButtonBox *box) +{ + fixButtonLabels(box); +} + } // namespace Calamares diff --git a/src/libcalamaresui/widgets/TranslationFix.h b/src/libcalamaresui/widgets/TranslationFix.h index 107dad67d..89ee9a51a 100644 --- a/src/libcalamaresui/widgets/TranslationFix.h +++ b/src/libcalamaresui/widgets/TranslationFix.h @@ -13,6 +13,7 @@ #include "DllMacro.h" class QMessageBox; +class QDialogButtonBox; namespace Calamares { @@ -26,6 +27,8 @@ namespace Calamares * guess the context. */ void UIDLLEXPORT fixButtonLabels( QMessageBox* ); + +void UIDLLEXPORT fixButtonLabels( QDialogButtonBox* ); } // namespace Calamares #endif From bfa7b9a7927b05ad2fcabc3ce460d640bc786d97 Mon Sep 17 00:00:00 2001 From: Artem Grinev Date: Mon, 6 Dec 2021 02:27:18 +0400 Subject: [PATCH 3/7] [libcalamaresui] Use translation fix for Error Dialog --- src/libcalamaresui/utils/ErrorDialog/ErrorDialog.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.cpp b/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.cpp index 080ff2115..29da42e4d 100644 --- a/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.cpp +++ b/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.cpp @@ -3,6 +3,7 @@ #include #include +#include "widgets/TranslationFix.h" namespace Calamares { @@ -81,7 +82,8 @@ void ErrorDialog::setShouldOfferWebPaste(bool newShouldOfferWebPaste) ui->buttonBox->setStandardButtons( m_shouldOfferWebPaste ? (QDialogButtonBox::Yes | QDialogButtonBox::No) : QDialogButtonBox::Close ); - + + fixButtonLabels(ui->buttonBox); emit shouldOfferWebPasteChanged(); } From 2dd77ee828f5df31460535abc85ef9c2489287d1 Mon Sep 17 00:00:00 2001 From: Artem Grinev Date: Mon, 6 Dec 2021 02:31:05 +0400 Subject: [PATCH 4/7] [libcalamaresui] Initialize Error Dialog field --- src/libcalamaresui/utils/ErrorDialog/ErrorDialog.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.h b/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.h index 8962c3e99..4196f6a7f 100644 --- a/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.h +++ b/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.h @@ -49,7 +49,7 @@ signals: private: Ui::ErrorDialog *ui; - bool m_shouldOfferWebPaste; + bool m_shouldOfferWebPaste = false; }; }; // namespace Calamares From 2f2a418cc42fa6b9bf3e2c68ab5f569e06e21e32 Mon Sep 17 00:00:00 2001 From: Artem Grinev Date: Mon, 6 Dec 2021 02:37:11 +0400 Subject: [PATCH 5/7] [libcalamaresui] Run clang-format --- src/libcalamaresui/ViewManager.cpp | 27 +++--- .../utils/ErrorDialog/ErrorDialog.cpp | 86 ++++++++++--------- .../utils/ErrorDialog/ErrorDialog.h | 56 ++++++------ 3 files changed, 91 insertions(+), 78 deletions(-) diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index ee521a02c..87024ea6b 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -17,6 +17,7 @@ #include "JobQueue.h" #include "Settings.h" +#include "utils/ErrorDialog/ErrorDialog.h" #include "utils/Logger.h" #include "utils/Paste.h" #include "utils/Retranslator.h" @@ -25,15 +26,14 @@ #include "viewpages/ExecutionViewStep.h" #include "viewpages/ViewStep.h" #include "widgets/TranslationFix.h" -#include "utils/ErrorDialog/ErrorDialog.h" #include #include #include +#include #include #include #include -#include #define UPDATE_BUTTON_PROPERTY( name, value ) \ do \ @@ -161,24 +161,27 @@ ViewManager::onInstallationFailed( const QString& message, const QString& detail cDebug() << Logger::SubEntry << "- details:" << Logger::NoQuote << details; QString heading - = Calamares::Settings::instance()->isSetupMode() ? tr( "Setup Failed" ) : tr( "Installation Failed" ); + = Calamares::Settings::instance()->isSetupMode() ? tr( "Setup Failed" ) : tr( "Installation Failed" ); ErrorDialog* errorDialog = new ErrorDialog(); errorDialog->setWindowTitle( tr( "Error" ) ); errorDialog->setHeading( "" + heading + "" ); errorDialog->setInformativeText( message ); - errorDialog->setShouldOfferWebPaste(shouldOfferWebPaste); - errorDialog->setDetails(details); + errorDialog->setShouldOfferWebPaste( shouldOfferWebPaste ); + errorDialog->setDetails( details ); errorDialog->show(); cDebug() << "Calamares will quit when the dialog closes."; - connect( errorDialog, &QDialog::finished, [errorDialog]( int result ) { - if ( result == QDialog::Accepted && errorDialog->shouldOfferWebPaste() ) - { - CalamaresUtils::Paste::doLogUploadUI( errorDialog ); - } - QApplication::quit(); - } ); + connect( errorDialog, + &QDialog::finished, + [ errorDialog ]( int result ) + { + if ( result == QDialog::Accepted && errorDialog->shouldOfferWebPaste() ) + { + CalamaresUtils::Paste::doLogUploadUI( errorDialog ); + } + QApplication::quit(); + } ); } diff --git a/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.cpp b/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.cpp index 29da42e4d..ca88031f6 100644 --- a/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.cpp +++ b/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.cpp @@ -1,19 +1,20 @@ #include "ErrorDialog.h" #include "ui_ErrorDialog.h" -#include -#include #include "widgets/TranslationFix.h" +#include +#include -namespace Calamares { - - -ErrorDialog::ErrorDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::ErrorDialog) +namespace Calamares { - ui->setupUi(this); - ui->iconLabel->setPixmap(QIcon::fromTheme("dialog-error").pixmap(64)); + + +ErrorDialog::ErrorDialog( QWidget* parent ) + : QDialog( parent ) + , ui( new Ui::ErrorDialog ) +{ + ui->setupUi( this ); + ui->iconLabel->setPixmap( QIcon::fromTheme( "dialog-error" ).pixmap( 64 ) ); ui->detailsWidget->hide(); ui->offerWebPasteLabel->hide(); } @@ -24,68 +25,75 @@ ErrorDialog::~ErrorDialog() } -QString ErrorDialog::heading() const +QString +ErrorDialog::heading() const { return ui->headingLabel->text(); } -QString ErrorDialog::informativeText() const +QString +ErrorDialog::informativeText() const { return ui->informativeTextLabel->text(); } -QString ErrorDialog::details() const +QString +ErrorDialog::details() const { return ui->detailsBrowser->toPlainText(); } -void ErrorDialog::setHeading(const QString &newHeading) +void +ErrorDialog::setHeading( const QString& newHeading ) { - if (ui->headingLabel->text() == newHeading) + if ( ui->headingLabel->text() == newHeading ) return; - ui->headingLabel->setText(newHeading); + ui->headingLabel->setText( newHeading ); emit headingChanged(); } -void ErrorDialog::setInformativeText(const QString &newInformativeText) +void +ErrorDialog::setInformativeText( const QString& newInformativeText ) { - if (ui->informativeTextLabel->text() == newInformativeText) + if ( ui->informativeTextLabel->text() == newInformativeText ) return; - ui->informativeTextLabel->setText(newInformativeText); + ui->informativeTextLabel->setText( newInformativeText ); emit informativeTextChanged(); } -void ErrorDialog::setDetails(const QString &newDetails) +void +ErrorDialog::setDetails( const QString& newDetails ) { - if (ui->detailsBrowser->toPlainText() == newDetails) - return; - ui->detailsBrowser->setPlainText(newDetails); - - ui->detailsWidget->setVisible(!ui->detailsBrowser->toPlainText().trimmed().isEmpty()); - + if ( ui->detailsBrowser->toPlainText() == newDetails ) + return; + ui->detailsBrowser->setPlainText( newDetails ); + + ui->detailsWidget->setVisible( !ui->detailsBrowser->toPlainText().trimmed().isEmpty() ); + emit detailsChanged(); } -bool ErrorDialog::shouldOfferWebPaste() const +bool +ErrorDialog::shouldOfferWebPaste() const { return m_shouldOfferWebPaste; } -void ErrorDialog::setShouldOfferWebPaste(bool newShouldOfferWebPaste) +void +ErrorDialog::setShouldOfferWebPaste( bool newShouldOfferWebPaste ) { - if (m_shouldOfferWebPaste == newShouldOfferWebPaste) + if ( m_shouldOfferWebPaste == newShouldOfferWebPaste ) return; m_shouldOfferWebPaste = newShouldOfferWebPaste; - - ui->offerWebPasteLabel->setVisible(m_shouldOfferWebPaste); - - ui->buttonBox->setStandardButtons( m_shouldOfferWebPaste - ? (QDialogButtonBox::Yes | QDialogButtonBox::No) - : QDialogButtonBox::Close ); - - fixButtonLabels(ui->buttonBox); - + + ui->offerWebPasteLabel->setVisible( m_shouldOfferWebPaste ); + + ui->buttonBox->setStandardButtons( m_shouldOfferWebPaste ? ( QDialogButtonBox::Yes | QDialogButtonBox::No ) + : QDialogButtonBox::Close ); + + fixButtonLabels( ui->buttonBox ); + emit shouldOfferWebPasteChanged(); } -} // namespace Calamares +} // namespace Calamares diff --git a/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.h b/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.h index 4196f6a7f..0c700f8d3 100644 --- a/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.h +++ b/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.h @@ -4,7 +4,8 @@ #include -namespace Ui { +namespace Ui +{ class ErrorDialog; } class QDialogButtonBox; @@ -13,45 +14,46 @@ namespace Calamares class ErrorDialog : public QDialog { Q_OBJECT - - Q_PROPERTY(QString heading READ heading WRITE setHeading NOTIFY headingChanged) - Q_PROPERTY(QString informativeText READ informativeText WRITE setInformativeText NOTIFY informativeTextChanged) - Q_PROPERTY(QString details READ details WRITE setDetails NOTIFY detailsChanged) - Q_PROPERTY(bool shouldOfferWebPaste READ shouldOfferWebPaste WRITE setShouldOfferWebPaste NOTIFY shouldOfferWebPasteChanged) - + + Q_PROPERTY( QString heading READ heading WRITE setHeading NOTIFY headingChanged ) + Q_PROPERTY( QString informativeText READ informativeText WRITE setInformativeText NOTIFY informativeTextChanged ) + Q_PROPERTY( QString details READ details WRITE setDetails NOTIFY detailsChanged ) + Q_PROPERTY( bool shouldOfferWebPaste READ shouldOfferWebPaste WRITE setShouldOfferWebPaste NOTIFY + shouldOfferWebPasteChanged ) + public: - explicit ErrorDialog(QWidget *parent = nullptr); + explicit ErrorDialog( QWidget* parent = nullptr ); ~ErrorDialog(); - + QString heading() const; - + QString informativeText() const; - + QString details() const; - - void setHeading(const QString &newHeading); - - void setInformativeText(const QString &newInformativeText); - - void setDetails(const QString &newDetails); - + + void setHeading( const QString& newHeading ); + + void setInformativeText( const QString& newInformativeText ); + + void setDetails( const QString& newDetails ); + bool shouldOfferWebPaste() const; - void setShouldOfferWebPaste(bool newShouldOfferWebPaste); - + void setShouldOfferWebPaste( bool newShouldOfferWebPaste ); + signals: void headingChanged(); - + void informativeTextChanged(); - + void detailsChanged(); - + void shouldOfferWebPasteChanged(); - + private: - Ui::ErrorDialog *ui; + Ui::ErrorDialog* ui; bool m_shouldOfferWebPaste = false; }; -}; // namespace Calamares +}; // namespace Calamares -#endif // ERRORDIALOG_H +#endif // ERRORDIALOG_H From d9f7726f7db3db97955fed876d37a80af7006a96 Mon Sep 17 00:00:00 2001 From: Artem Grinev Date: Mon, 6 Dec 2021 02:41:17 +0400 Subject: [PATCH 6/7] [libcalamaresui] Add SPDX-header for Error Dialog files --- src/libcalamaresui/utils/ErrorDialog/ErrorDialog.cpp | 9 +++++++++ src/libcalamaresui/utils/ErrorDialog/ErrorDialog.h | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.cpp b/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.cpp index ca88031f6..4ffe20384 100644 --- a/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.cpp +++ b/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.cpp @@ -1,3 +1,12 @@ +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2021 Artem Grinev + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Calamares is Free Software: see the License-Identifier above. + * + */ + #include "ErrorDialog.h" #include "ui_ErrorDialog.h" diff --git a/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.h b/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.h index 0c700f8d3..a0126c2ce 100644 --- a/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.h +++ b/src/libcalamaresui/utils/ErrorDialog/ErrorDialog.h @@ -1,3 +1,12 @@ +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2021 Artem Grinev + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Calamares is Free Software: see the License-Identifier above. + * + */ + #ifndef ERRORDIALOG_H #define ERRORDIALOG_H From aa332477fd1858603f528a5f036925624446249a Mon Sep 17 00:00:00 2001 From: Artem Grinev Date: Mon, 6 Dec 2021 03:11:16 +0400 Subject: [PATCH 7/7] [libcalamaresui] Run clang-format on TranslationFix.cpp --- src/libcalamaresui/widgets/TranslationFix.cpp | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/libcalamaresui/widgets/TranslationFix.cpp b/src/libcalamaresui/widgets/TranslationFix.cpp index b73bd0e16..dbfd0bd83 100644 --- a/src/libcalamaresui/widgets/TranslationFix.cpp +++ b/src/libcalamaresui/widgets/TranslationFix.cpp @@ -10,34 +10,35 @@ #include "TranslationFix.h" #include -#include #include -#include #include +#include +#include namespace Calamares { //Using QMessageBox's StandardButton enum here but according to headers they should be kept in-sync between multiple classes. static std::pair< decltype( QMessageBox::Ok ), const char* > maps[] = { - { QMessageBox::Ok, QT_TRANSLATE_NOOP( "StandardButtons", "&OK" ) }, - { QMessageBox::Yes, QT_TRANSLATE_NOOP( "StandardButtons", "&Yes" ) }, - { QMessageBox::No, QT_TRANSLATE_NOOP( "StandardButtons", "&No" ) }, - { QMessageBox::Cancel, QT_TRANSLATE_NOOP( "StandardButtons", "&Cancel" ) }, - { QMessageBox::Close, QT_TRANSLATE_NOOP( "StandardButtons", "&Close" ) }, - }; + { QMessageBox::Ok, QT_TRANSLATE_NOOP( "StandardButtons", "&OK" ) }, + { QMessageBox::Yes, QT_TRANSLATE_NOOP( "StandardButtons", "&Yes" ) }, + { QMessageBox::No, QT_TRANSLATE_NOOP( "StandardButtons", "&No" ) }, + { QMessageBox::Cancel, QT_TRANSLATE_NOOP( "StandardButtons", "&Cancel" ) }, + { QMessageBox::Close, QT_TRANSLATE_NOOP( "StandardButtons", "&Close" ) }, +}; -template -void fixButtonLabels ( TButtonBox* box ) +template < typename TButtonBox > +void +fixButtonLabels( TButtonBox* box ) { if ( !box ) { return; } - + for ( auto [ sb, label ] : maps ) { - auto* button = box->button( static_cast(int(sb)) ); + auto* button = box->button( static_cast< typename TButtonBox::StandardButton >( int( sb ) ) ); if ( button ) { button->setText( QCoreApplication::translate( "StandardButtons", label ) ); @@ -48,13 +49,13 @@ void fixButtonLabels ( TButtonBox* box ) void fixButtonLabels( QMessageBox* box ) { - fixButtonLabels(box); + fixButtonLabels< QMessageBox >( box ); } void -fixButtonLabels(QDialogButtonBox *box) +fixButtonLabels( QDialogButtonBox* box ) { - fixButtonLabels(box); + fixButtonLabels< QDialogButtonBox >( box ); } } // namespace Calamares