[libcalamaresui] Run clang-format

This commit is contained in:
Artem Grinev 2021-12-06 02:37:11 +04:00
parent 2dd77ee828
commit 2f2a418cc4
3 changed files with 91 additions and 78 deletions

View File

@ -17,6 +17,7 @@
#include "JobQueue.h" #include "JobQueue.h"
#include "Settings.h" #include "Settings.h"
#include "utils/ErrorDialog/ErrorDialog.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include "utils/Paste.h" #include "utils/Paste.h"
#include "utils/Retranslator.h" #include "utils/Retranslator.h"
@ -25,15 +26,14 @@
#include "viewpages/ExecutionViewStep.h" #include "viewpages/ExecutionViewStep.h"
#include "viewpages/ViewStep.h" #include "viewpages/ViewStep.h"
#include "widgets/TranslationFix.h" #include "widgets/TranslationFix.h"
#include "utils/ErrorDialog/ErrorDialog.h"
#include <QApplication> #include <QApplication>
#include <QBoxLayout> #include <QBoxLayout>
#include <QClipboard> #include <QClipboard>
#include <QDialogButtonBox>
#include <QFile> #include <QFile>
#include <QMessageBox> #include <QMessageBox>
#include <QMetaObject> #include <QMetaObject>
#include <QDialogButtonBox>
#define UPDATE_BUTTON_PROPERTY( name, value ) \ #define UPDATE_BUTTON_PROPERTY( name, value ) \
do \ do \
@ -161,24 +161,27 @@ ViewManager::onInstallationFailed( const QString& message, const QString& detail
cDebug() << Logger::SubEntry << "- details:" << Logger::NoQuote << details; cDebug() << Logger::SubEntry << "- details:" << Logger::NoQuote << details;
QString heading 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* errorDialog = new ErrorDialog();
errorDialog->setWindowTitle( tr( "Error" ) ); errorDialog->setWindowTitle( tr( "Error" ) );
errorDialog->setHeading( "<strong>" + heading + "</strong>" ); errorDialog->setHeading( "<strong>" + heading + "</strong>" );
errorDialog->setInformativeText( message ); errorDialog->setInformativeText( message );
errorDialog->setShouldOfferWebPaste(shouldOfferWebPaste); errorDialog->setShouldOfferWebPaste( shouldOfferWebPaste );
errorDialog->setDetails(details); errorDialog->setDetails( details );
errorDialog->show(); errorDialog->show();
cDebug() << "Calamares will quit when the dialog closes."; cDebug() << "Calamares will quit when the dialog closes.";
connect( errorDialog, &QDialog::finished, [errorDialog]( int result ) { connect( errorDialog,
if ( result == QDialog::Accepted && errorDialog->shouldOfferWebPaste() ) &QDialog::finished,
{ [ errorDialog ]( int result )
CalamaresUtils::Paste::doLogUploadUI( errorDialog ); {
} if ( result == QDialog::Accepted && errorDialog->shouldOfferWebPaste() )
QApplication::quit(); {
} ); CalamaresUtils::Paste::doLogUploadUI( errorDialog );
}
QApplication::quit();
} );
} }

View File

@ -1,19 +1,20 @@
#include "ErrorDialog.h" #include "ErrorDialog.h"
#include "ui_ErrorDialog.h" #include "ui_ErrorDialog.h"
#include <QIcon>
#include <QDialogButtonBox>
#include "widgets/TranslationFix.h" #include "widgets/TranslationFix.h"
#include <QDialogButtonBox>
#include <QIcon>
namespace Calamares { namespace Calamares
ErrorDialog::ErrorDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::ErrorDialog)
{ {
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->detailsWidget->hide();
ui->offerWebPasteLabel->hide(); ui->offerWebPasteLabel->hide();
} }
@ -24,68 +25,75 @@ ErrorDialog::~ErrorDialog()
} }
QString ErrorDialog::heading() const QString
ErrorDialog::heading() const
{ {
return ui->headingLabel->text(); return ui->headingLabel->text();
} }
QString ErrorDialog::informativeText() const QString
ErrorDialog::informativeText() const
{ {
return ui->informativeTextLabel->text(); return ui->informativeTextLabel->text();
} }
QString ErrorDialog::details() const QString
ErrorDialog::details() const
{ {
return ui->detailsBrowser->toPlainText(); 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; return;
ui->headingLabel->setText(newHeading); ui->headingLabel->setText( newHeading );
emit headingChanged(); 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; return;
ui->informativeTextLabel->setText(newInformativeText); ui->informativeTextLabel->setText( newInformativeText );
emit informativeTextChanged(); emit informativeTextChanged();
} }
void ErrorDialog::setDetails(const QString &newDetails) void
ErrorDialog::setDetails( const QString& newDetails )
{ {
if (ui->detailsBrowser->toPlainText() == newDetails) if ( ui->detailsBrowser->toPlainText() == newDetails )
return; return;
ui->detailsBrowser->setPlainText(newDetails); ui->detailsBrowser->setPlainText( newDetails );
ui->detailsWidget->setVisible(!ui->detailsBrowser->toPlainText().trimmed().isEmpty()); ui->detailsWidget->setVisible( !ui->detailsBrowser->toPlainText().trimmed().isEmpty() );
emit detailsChanged(); emit detailsChanged();
} }
bool ErrorDialog::shouldOfferWebPaste() const bool
ErrorDialog::shouldOfferWebPaste() const
{ {
return m_shouldOfferWebPaste; return m_shouldOfferWebPaste;
} }
void ErrorDialog::setShouldOfferWebPaste(bool newShouldOfferWebPaste) void
ErrorDialog::setShouldOfferWebPaste( bool newShouldOfferWebPaste )
{ {
if (m_shouldOfferWebPaste == newShouldOfferWebPaste) if ( m_shouldOfferWebPaste == newShouldOfferWebPaste )
return; return;
m_shouldOfferWebPaste = newShouldOfferWebPaste; m_shouldOfferWebPaste = newShouldOfferWebPaste;
ui->offerWebPasteLabel->setVisible(m_shouldOfferWebPaste); ui->offerWebPasteLabel->setVisible( m_shouldOfferWebPaste );
ui->buttonBox->setStandardButtons( m_shouldOfferWebPaste ui->buttonBox->setStandardButtons( m_shouldOfferWebPaste ? ( QDialogButtonBox::Yes | QDialogButtonBox::No )
? (QDialogButtonBox::Yes | QDialogButtonBox::No) : QDialogButtonBox::Close );
: QDialogButtonBox::Close );
fixButtonLabels( ui->buttonBox );
fixButtonLabels(ui->buttonBox);
emit shouldOfferWebPasteChanged(); emit shouldOfferWebPasteChanged();
} }
} // namespace Calamares } // namespace Calamares

View File

@ -4,7 +4,8 @@
#include <QDialog> #include <QDialog>
namespace Ui { namespace Ui
{
class ErrorDialog; class ErrorDialog;
} }
class QDialogButtonBox; class QDialogButtonBox;
@ -13,45 +14,46 @@ namespace Calamares
class ErrorDialog : public QDialog class ErrorDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QString heading READ heading WRITE setHeading NOTIFY headingChanged) Q_PROPERTY( QString heading READ heading WRITE setHeading NOTIFY headingChanged )
Q_PROPERTY(QString informativeText READ informativeText WRITE setInformativeText NOTIFY informativeTextChanged) Q_PROPERTY( QString informativeText READ informativeText WRITE setInformativeText NOTIFY informativeTextChanged )
Q_PROPERTY(QString details READ details WRITE setDetails NOTIFY detailsChanged) Q_PROPERTY( QString details READ details WRITE setDetails NOTIFY detailsChanged )
Q_PROPERTY(bool shouldOfferWebPaste READ shouldOfferWebPaste WRITE setShouldOfferWebPaste NOTIFY shouldOfferWebPasteChanged) Q_PROPERTY( bool shouldOfferWebPaste READ shouldOfferWebPaste WRITE setShouldOfferWebPaste NOTIFY
shouldOfferWebPasteChanged )
public: public:
explicit ErrorDialog(QWidget *parent = nullptr); explicit ErrorDialog( QWidget* parent = nullptr );
~ErrorDialog(); ~ErrorDialog();
QString heading() const; QString heading() const;
QString informativeText() const; QString informativeText() const;
QString details() const; QString details() const;
void setHeading(const QString &newHeading); void setHeading( const QString& newHeading );
void setInformativeText(const QString &newInformativeText); void setInformativeText( const QString& newInformativeText );
void setDetails(const QString &newDetails); void setDetails( const QString& newDetails );
bool shouldOfferWebPaste() const; bool shouldOfferWebPaste() const;
void setShouldOfferWebPaste(bool newShouldOfferWebPaste); void setShouldOfferWebPaste( bool newShouldOfferWebPaste );
signals: signals:
void headingChanged(); void headingChanged();
void informativeTextChanged(); void informativeTextChanged();
void detailsChanged(); void detailsChanged();
void shouldOfferWebPasteChanged(); void shouldOfferWebPasteChanged();
private: private:
Ui::ErrorDialog *ui; Ui::ErrorDialog* ui;
bool m_shouldOfferWebPaste = false; bool m_shouldOfferWebPaste = false;
}; };
}; // namespace Calamares }; // namespace Calamares
#endif // ERRORDIALOG_H #endif // ERRORDIALOG_H