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