From 19787d771ea35c5aacf124ec7098103741220f2b Mon Sep 17 00:00:00 2001 From: Matthias Puchner <github@mpuchner.de> Date: Thu, 2 Dec 2021 15:50:22 +0100 Subject: [PATCH] simplify overdone job message panel implementation --- GUI/View/Fit/JobMessagePanel.cpp | 39 ++++++++-------------------- GUI/View/Fit/JobMessagePanel.h | 9 ++----- GUI/View/Job/JobView.cpp | 3 --- GUI/View/Tool/mainwindow_constants.h | 1 - 4 files changed, 13 insertions(+), 39 deletions(-) diff --git a/GUI/View/Fit/JobMessagePanel.cpp b/GUI/View/Fit/JobMessagePanel.cpp index 97b2887b0f0..f7af65c2f04 100644 --- a/GUI/View/Fit/JobMessagePanel.cpp +++ b/GUI/View/Fit/JobMessagePanel.cpp @@ -13,11 +13,8 @@ // ************************************************************************************************ #include "GUI/View/Fit/JobMessagePanel.h" -#include "GUI/View/Tool/mainwindow_constants.h" #include <QScrollBar> -#include <QStackedWidget> #include <QTextEdit> -#include <QVBoxLayout> namespace { @@ -43,37 +40,23 @@ QColor color(FitLogLevel level) } // namespace -JobMessagePanel::JobMessagePanel(QWidget* parent) - : InfoPanel(parent), m_log(nullptr), m_plainLog(new QTextEdit) +JobMessagePanel::JobMessagePanel(QWidget* parent) : QTextEdit(parent), m_log(nullptr) { - setWindowTitle(GUI::Constants::JobMessagePanelName); - setObjectName("JobMessagePanel"); - - m_plainLog->setReadOnly(true); - // m_plainLog->setMaximumBlockCount(100000); - m_plainLog->setFont(QFont("Courier")); - - m_stackedWidget->addWidget(m_plainLog); - - setContentVisible(false); -} - -void JobMessagePanel::onClearLog() -{ - m_plainLog->clear(); + setWindowTitle("Message Panel"); + setReadOnly(true); + setFont(QFont("Courier")); } void JobMessagePanel::appendMessage(const FitLog::Message& message) { - QScrollBar* scrollbar = m_plainLog->verticalScrollBar(); + QScrollBar* scrollbar = verticalScrollBar(); bool autoscroll = scrollbar->value() == scrollbar->maximum(); - // m_plainLog->appendPlainText(message); - m_plainLog->setTextColor(color(message.level)); - m_plainLog->append(QString::fromStdString(message.text)); + setTextColor(color(message.level)); + append(QString::fromStdString(message.text)); if (autoscroll) { - QTextCursor c = m_plainLog->textCursor(); + QTextCursor c = textCursor(); c.movePosition(QTextCursor::End); - m_plainLog->setTextCursor(c); + setTextCursor(c); } } @@ -82,11 +65,11 @@ void JobMessagePanel::setLog(FitLog* log) if (m_log) m_log->disconnect(this); m_log = log; - m_plainLog->clear(); + clear(); if (m_log) { for (const auto& record : m_log->messages()) appendMessage(record); - connect(m_log, &FitLog::cleared, this, &JobMessagePanel::onClearLog); + connect(m_log, &FitLog::cleared, this, &JobMessagePanel::clear); connect(m_log, &FitLog::messageAppended, this, &JobMessagePanel::appendMessage); } } diff --git a/GUI/View/Fit/JobMessagePanel.h b/GUI/View/Fit/JobMessagePanel.h index 28f1c8b47d6..c14a65ea7bb 100644 --- a/GUI/View/Fit/JobMessagePanel.h +++ b/GUI/View/Fit/JobMessagePanel.h @@ -15,28 +15,23 @@ #ifndef BORNAGAIN_GUI_VIEW_FIT_JOBMESSAGEPANEL_H #define BORNAGAIN_GUI_VIEW_FIT_JOBMESSAGEPANEL_H -#include "GUI/View/Common/InfoPanel.h" #include "GUI/View/Fit/FitLog.h" #include <QColor> - -class QTextEdit; +#include <QTextEdit> //! The JobMessagePanel class shows log messages from FitActivityPanel at the //! bottom part of JobView. -class JobMessagePanel : public InfoPanel { +class JobMessagePanel : public QTextEdit { Q_OBJECT public: JobMessagePanel(QWidget* parent = nullptr); -public slots: - void onClearLog(); void appendMessage(const FitLog::Message& message); void setLog(FitLog* log); private: FitLog* m_log; - QTextEdit* m_plainLog; }; #endif // BORNAGAIN_GUI_VIEW_FIT_JOBMESSAGEPANEL_H diff --git a/GUI/View/Job/JobView.cpp b/GUI/View/Job/JobView.cpp index 8f5a2e72509..3e5a9bf476f 100644 --- a/GUI/View/Job/JobView.cpp +++ b/GUI/View/Job/JobView.cpp @@ -109,9 +109,6 @@ void JobView::createSubWindows() m_docks->addWidget(JobViewFlags::FIT_PANEL_DOCK, m_fitActivityPanel, Qt::RightDockWidgetArea); m_docks->addWidget(JobViewFlags::JOB_MESSAGE_DOCK, m_jobMessagePanel, Qt::BottomDockWidgetArea); - connect(m_jobMessagePanel, &JobMessagePanel::widgetHeightRequest, m_docks, - &DocksController::setDockHeightForWidget); - m_fitActivityPanel->setRealTimeWidget(m_jobRealTimeWidget); setCentralWidget(m_jobResultsPresenter); diff --git a/GUI/View/Tool/mainwindow_constants.h b/GUI/View/Tool/mainwindow_constants.h index b278003ba7e..1dbac7aaa9a 100644 --- a/GUI/View/Tool/mainwindow_constants.h +++ b/GUI/View/Tool/mainwindow_constants.h @@ -53,7 +53,6 @@ const QString JobRealTimeWidgetName = "Job Real Time"; const QString JobPropertiesWidgetName = "Job Properties"; const QString JobFitPanelName = "Fit Panel"; const QString JobSelectorWidgetName = "Job Selector"; -const QString JobMessagePanelName = "Message Panel"; const QString JobViewActivityName = "Job View Activity"; const QString JobRealTimeActivityName = "Real Time Activity"; -- GitLab