diff --git a/src/libcalamaresui/viewpages/ExecutionViewStep.cpp b/src/libcalamaresui/viewpages/ExecutionViewStep.cpp index 1ab1a7a3a..4cf9a06a0 100644 --- a/src/libcalamaresui/viewpages/ExecutionViewStep.cpp +++ b/src/libcalamaresui/viewpages/ExecutionViewStep.cpp @@ -27,17 +27,17 @@ #include "utils/Retranslator.h" #include "widgets/LogWidget.h" -#include -#include -#include -#include -#include -#include #include -#include -#include +#include +#include +#include #include +#include #include +#include +#include +#include +#include static Calamares::Slideshow* makeSlideshow( QWidget* parent ) @@ -81,8 +81,8 @@ ExecutionViewStep::ExecutionViewStep( QObject* parent ) m_progressBar->setMaximum( 10000 ); - m_tab_widget->addTab(m_slideshow->widget(), "Slideshow"); - m_tab_widget->addTab(m_log_widget, "Log"); + m_tab_widget->addTab( m_slideshow->widget(), "Slideshow" ); + m_tab_widget->addTab( m_log_widget, "Log" ); m_tab_widget->tabBar()->hide(); layout->addWidget( m_tab_widget ); @@ -94,13 +94,13 @@ ExecutionViewStep::ExecutionViewStep( QObject* parent ) bottomLayout->addWidget( m_label ); QToolBar* toolBar = new QToolBar; - auto toggleLogAction = toolBar->addAction(QIcon::fromTheme("utilities-terminal"), "Toggle log"); - auto toggleLogButton = dynamic_cast(toolBar->widgetForAction(toggleLogAction)); + auto toggleLogAction = toolBar->addAction( QIcon::fromTheme( "utilities-terminal" ), "Toggle log" ); + auto toggleLogButton = dynamic_cast< QToolButton* >( toolBar->widgetForAction( toggleLogAction ) ); connect( toggleLogButton, &QToolButton::clicked, this, &ExecutionViewStep::toggleLog ); - barLayout->addWidget(m_progressBar); - barLayout->addWidget(toolBar); + barLayout->addWidget( m_progressBar ); + barLayout->addWidget( toolBar ); connect( JobQueue::instance(), &JobQueue::progress, this, &ExecutionViewStep::updateFromJobQueue ); @@ -176,7 +176,7 @@ ExecutionViewStep::onActivate() const auto instanceDescriptor = std::find_if( instanceDescriptors.constBegin(), instanceDescriptors.constEnd(), - [=]( const Calamares::InstanceDescription& d ) { return d.key() == instanceKey; } ); + [ = ]( const Calamares::InstanceDescription& d ) { return d.key() == instanceKey; } ); int weight = moduleDescriptor.weight(); if ( instanceDescriptor != instanceDescriptors.constEnd() && instanceDescriptor->explicitWeight() ) { @@ -228,7 +228,7 @@ ExecutionViewStep::updateFromJobQueue( qreal percent, const QString& message ) void ExecutionViewStep::toggleLog() { - m_tab_widget->setCurrentIndex((m_tab_widget->currentIndex() + 1) % m_tab_widget->count()); + m_tab_widget->setCurrentIndex( ( m_tab_widget->currentIndex() + 1 ) % m_tab_widget->count() ); } void @@ -239,4 +239,3 @@ ExecutionViewStep::onLeave() } // namespace Calamares - diff --git a/src/libcalamaresui/widgets/LogWidget.cpp b/src/libcalamaresui/widgets/LogWidget.cpp index 18642f089..7a253b78c 100644 --- a/src/libcalamaresui/widgets/LogWidget.cpp +++ b/src/libcalamaresui/widgets/LogWidget.cpp @@ -1,16 +1,16 @@ #include "LogWidget.h" -#include #include "utils/Logger.h" +#include +#include #include #include -#include namespace Calamares { -LogThread::LogThread(QObject *parent) - : QThread(parent) { - +LogThread::LogThread( QObject* parent ) + : QThread( parent ) +{ } LogThread::~LogThread() @@ -20,63 +20,65 @@ LogThread::~LogThread() wait(); } -void LogThread::run() +void +LogThread::run() { - auto filePath = Logger::logFile(); + const auto filePath = Logger::logFile(); qint64 lastPosition = 0; - while (!QThread::currentThread()->isInterruptionRequested()) { - auto filePath = Logger::logFile(); - QFile file(filePath); + while ( !QThread::currentThread()->isInterruptionRequested() ) + { + QFile file( filePath ); qint64 fileSize = file.size(); // Check whether the file size has changed since last time // we read the file. - if (lastPosition != fileSize && file.open(QFile::ReadOnly | QFile::Text)) { + if ( lastPosition != fileSize && file.open( QFile::ReadOnly | QFile::Text ) ) + { // Start reading at the position we ended up last time we read the file. - file.seek(lastPosition); + file.seek( lastPosition ); - QTextStream in(&file); + QTextStream in( &file ); auto chunk = in.readAll(); qint64 newPosition = in.pos(); lastPosition = newPosition; - onLogChunk(chunk); + Q_EMIT onLogChunk( chunk ); } - QThread::msleep(100); + QThread::msleep( 100 ); } } -LogWidget::LogWidget(QWidget *parent) - : QWidget(parent) +LogWidget::LogWidget( QWidget* parent ) + : QWidget( parent ) , m_text( new QPlainTextEdit ) , m_log_thread( this ) { - auto layout = new QStackedLayout(this); - setLayout(layout); + auto layout = new QStackedLayout( this ); + setLayout( layout ); - m_text->setReadOnly(true); + m_text->setReadOnly( true ); - QFont monospaceFont("monospace"); - monospaceFont.setStyleHint(QFont::Monospace); - m_text->setFont(monospaceFont); + QFont monospaceFont( "monospace" ); + monospaceFont.setStyleHint( QFont::Monospace ); + m_text->setFont( monospaceFont ); - layout->addWidget(m_text); + layout->addWidget( m_text ); - connect(&m_log_thread, &LogThread::onLogChunk, this, &LogWidget::handleLogChunk); + connect( &m_log_thread, &LogThread::onLogChunk, this, &LogWidget::handleLogChunk ); m_log_thread.start(); } void -LogWidget::handleLogChunk(const QString &logChunk) +LogWidget::handleLogChunk( const QString& logChunk ) { - m_text->appendPlainText(logChunk); - m_text->moveCursor(QTextCursor::End); + m_text->appendPlainText( logChunk ); + m_text->moveCursor( QTextCursor::End ); m_text->ensureCursorVisible(); } -} +} // namespace Calamares diff --git a/src/libcalamaresui/widgets/LogWidget.h b/src/libcalamaresui/widgets/LogWidget.h index c51e64393..2d0ef9ab5 100644 --- a/src/libcalamaresui/widgets/LogWidget.h +++ b/src/libcalamaresui/widgets/LogWidget.h @@ -1,9 +1,9 @@ #ifndef LIBCALAMARESUI_LOGWIDGET_H #define LIBCALAMARESUI_LOGWIDGET_H -#include #include #include +#include namespace Calamares { @@ -15,11 +15,11 @@ class LogThread : public QThread void run() override; public: - explicit LogThread(QObject *parent = nullptr); + explicit LogThread( QObject* parent = nullptr ); ~LogThread() override; signals: - void onLogChunk(const QString &logChunk); + void onLogChunk( const QString& logChunk ); }; class LogWidget : public QWidget @@ -28,11 +28,12 @@ class LogWidget : public QWidget QPlainTextEdit* m_text; LogThread m_log_thread; -public: - explicit LogWidget(QWidget *parent = nullptr); - void handleLogChunk(const QString &logChunk); +public: + explicit LogWidget( QWidget* parent = nullptr ); + + void handleLogChunk( const QString& logChunk ); }; -} -#endif // LOGWIDGET_H +} // namespace Calamares +#endif // LOGWIDGET_H