From a6afb6be7c742c28faa950fdd9e178bb001fad69 Mon Sep 17 00:00:00 2001 From: Bob van der Linden Date: Sun, 6 Mar 2022 12:33:06 +0100 Subject: [PATCH] add log widget to ExecutionViewStep --- .../viewpages/ExecutionViewStep.cpp | 48 ++++++++++++++++--- .../viewpages/ExecutionViewStep.h | 6 +++ 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/src/libcalamaresui/viewpages/ExecutionViewStep.cpp b/src/libcalamaresui/viewpages/ExecutionViewStep.cpp index cac9b28be..72c0a1f7d 100644 --- a/src/libcalamaresui/viewpages/ExecutionViewStep.cpp +++ b/src/libcalamaresui/viewpages/ExecutionViewStep.cpp @@ -30,6 +30,14 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include "utils/Logger.h" static Calamares::Slideshow* makeSlideshow( QWidget* parent ) @@ -60,23 +68,43 @@ ExecutionViewStep::ExecutionViewStep( QObject* parent ) , m_progressBar( new QProgressBar ) , m_label( new QLabel ) , m_slideshow( makeSlideshow( m_widget ) ) + , m_tab_widget( new QTabWidget ) { m_widget->setObjectName( "slideshow" ); m_progressBar->setObjectName( "exec-progress" ); m_label->setObjectName( "exec-message" ); QVBoxLayout* layout = new QVBoxLayout( m_widget ); - QVBoxLayout* innerLayout = new QVBoxLayout; + QVBoxLayout* bottomLayout = new QVBoxLayout; + QHBoxLayout* barLayout = new QHBoxLayout; m_progressBar->setMaximum( 10000 ); - layout->addWidget( m_slideshow->widget() ); - CalamaresUtils::unmarginLayout( layout ); - layout->addLayout( innerLayout ); + auto m_log_widget = new QPlainTextEdit; + m_log_widget->setReadOnly(true); + + + 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 ); + CalamaresUtils::unmarginLayout( layout ); + layout->addLayout( bottomLayout ); + + bottomLayout->addSpacing( CalamaresUtils::defaultFontHeight() / 2 ); + bottomLayout->addLayout( barLayout ); + bottomLayout->addWidget( m_label ); + + QToolBar* toolBar = new QToolBar; + auto toggleLogAction = toolBar->addAction(QIcon::fromTheme("file-icon"), "Toggle log"); + auto toggleLogButton = dynamic_cast(toolBar->widgetForAction(toggleLogAction)); + connect( toggleLogButton, &QToolButton::clicked, this, &ExecutionViewStep::toggleLog ); + + + barLayout->addWidget(m_progressBar); + barLayout->addWidget(toolBar); - innerLayout->addSpacing( CalamaresUtils::defaultFontHeight() / 2 ); - innerLayout->addWidget( m_progressBar ); - innerLayout->addWidget( m_label ); connect( JobQueue::instance(), &JobQueue::progress, this, &ExecutionViewStep::updateFromJobQueue ); } @@ -200,6 +228,12 @@ ExecutionViewStep::updateFromJobQueue( qreal percent, const QString& message ) } } +void +ExecutionViewStep::toggleLog() +{ + m_tab_widget->setCurrentIndex((m_tab_widget->currentIndex() + 1) % m_tab_widget->count()); +} + void ExecutionViewStep::onLeave() { diff --git a/src/libcalamaresui/viewpages/ExecutionViewStep.h b/src/libcalamaresui/viewpages/ExecutionViewStep.h index 26618c77f..c2652d5e5 100644 --- a/src/libcalamaresui/viewpages/ExecutionViewStep.h +++ b/src/libcalamaresui/viewpages/ExecutionViewStep.h @@ -19,6 +19,8 @@ class QLabel; class QObject; class QProgressBar; +class QTabWidget; +class QPlainTextEdit; namespace Calamares { @@ -56,10 +58,14 @@ private: QProgressBar* m_progressBar; QLabel* m_label; Slideshow* m_slideshow; + QTabWidget* m_tab_widget; + QPlainTextEdit* m_log_widget; QList< ModuleSystem::InstanceKey > m_jobInstanceKeys; void updateFromJobQueue( qreal percent, const QString& message ); + + void toggleLog(); }; } // namespace Calamares