mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 01:05:34 +08:00
refs #452 details textbox for logs
* details can be displayed en detail * feature can be switched on/off via context menu * signals in view to select message
This commit is contained in:
committed by
Mathew Sutcliffe
parent
6ca0d480d3
commit
25471730e3
@@ -13,17 +13,20 @@
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackGui;
|
||||
using namespace BlackGui::Views;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
|
||||
CLogComponent::CLogComponent(QWidget *parent) :
|
||||
QFrame(parent), ui(new Ui::CLogComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->ui->tvp_StatusMessages->setAutoResizeFrequency(3);
|
||||
connect(this->ui->tvp_StatusMessages, &CStatusMessageView::messageSelected,
|
||||
this->ui->form_StatusMessage, &CStatusMessageForm::setValue);
|
||||
this->ui->tvp_StatusMessages->setCustomMenu(new CLogMenu(this));
|
||||
}
|
||||
|
||||
CLogComponent::~CLogComponent()
|
||||
@@ -45,5 +48,17 @@ namespace BlackGui
|
||||
if (statusMessage.isEmpty()) return;
|
||||
this->ui->tvp_StatusMessages->insert(statusMessage);
|
||||
}
|
||||
|
||||
void CLogComponent::CLogMenu::customMenu(QMenu &menu) const
|
||||
{
|
||||
CLogComponent *logComp = qobject_cast<CLogComponent *>(this->parent());
|
||||
Q_ASSERT_X(logComp, Q_FUNC_INFO, "Missing parent");
|
||||
|
||||
bool v = logComp->ui->form_StatusMessage->isVisible();
|
||||
QString formString(v ? "Hide details" : "Show details");
|
||||
QAction *a = menu.addAction(BlackMisc::CIcons::databaseTable16(), formString, logComp->ui->form_StatusMessage, SLOT(toggleVisibility()));
|
||||
a->setCheckable(true);
|
||||
a->setChecked(v);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "enableforruntime.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
|
||||
#include "blackgui/menudelegate.h"
|
||||
#include <QFrame>
|
||||
#include <QScopedPointer>
|
||||
|
||||
@@ -25,7 +25,6 @@ namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
|
||||
//! GUI displaying log and status messages
|
||||
class BLACKGUI_EXPORT CLogComponent :
|
||||
public QFrame,
|
||||
@@ -52,7 +51,19 @@ namespace BlackGui
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CLogComponent> ui;
|
||||
|
||||
//! Custom menu for the log component
|
||||
class CLogMenu : public BlackGui::IMenuDelegate
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CLogMenu(CLogComponent *parent) : IMenuDelegate(parent) {}
|
||||
|
||||
//! \copydoc IMenuDelegate::customMenu
|
||||
virtual void customMenu(QMenu &menu) const override;
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
#endif // guard
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<width>262</width>
|
||||
<height>313</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
@@ -55,7 +55,7 @@
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="vl_StatusPageMessages">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
@@ -82,6 +82,34 @@
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="BlackGui::CStatusMessageForm" name="form_StatusMessage">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="pg_LogConsole">
|
||||
@@ -139,6 +167,12 @@
|
||||
<extends>QTableView</extends>
|
||||
<header>blackgui/views/statusmessageview.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::CStatusMessageForm</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/statusmessageform.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
41
src/blackgui/statusmessageform.cpp
Normal file
41
src/blackgui/statusmessageform.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/* Copyright (C) 2014
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "statusmessageform.h"
|
||||
#include "ui_statusmessageform.h"
|
||||
#include <QLabel>
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
CStatusMessageForm::CStatusMessageForm(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
ui(new Ui::CStatusMessageForm)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
CStatusMessageForm::~CStatusMessageForm()
|
||||
{ }
|
||||
|
||||
void CStatusMessageForm::setValue(const BlackMisc::CStatusMessage &message)
|
||||
{
|
||||
if (!this->isVisible()) { return; }
|
||||
ui->te_Message->setPlainText(message.getMessage());
|
||||
ui->lbl_SeverityIcon->setPixmap(message.toPixmap());
|
||||
ui->le_Categories->setText(message.getCategories().toQString(true));
|
||||
ui->le_Severity->setText(message.getSeverityAsString());
|
||||
ui->le_Timestamp->setText(message.getFormattedUtcTimestampYmdhms());
|
||||
}
|
||||
|
||||
void CStatusMessageForm::toggleVisibility()
|
||||
{
|
||||
this->setVisible(!isVisible());
|
||||
}
|
||||
|
||||
} // ns
|
||||
49
src/blackgui/statusmessageform.h
Normal file
49
src/blackgui/statusmessageform.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_STATUSMESSAGEFORM_H
|
||||
#define BLACKGUI_STATUSMESSAGEFORM_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include <QFrame>
|
||||
|
||||
namespace Ui { class CStatusMessageForm; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
/*!
|
||||
* Display details about a single status message
|
||||
*/
|
||||
class BLACKGUI_EXPORT CStatusMessageForm : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CStatusMessageForm(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CStatusMessageForm();
|
||||
|
||||
public slots:
|
||||
//! Set message
|
||||
void setValue(const BlackMisc::CStatusMessage &message);
|
||||
|
||||
//! Toggle visibility
|
||||
void toggleVisibility();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CStatusMessageForm> ui;
|
||||
};
|
||||
|
||||
} // ns
|
||||
#endif // guard
|
||||
103
src/blackgui/statusmessageform.ui
Normal file
103
src/blackgui/statusmessageform.ui
Normal file
@@ -0,0 +1,103 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CStatusMessageForm</class>
|
||||
<widget class="QFrame" name="CStatusMessageForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>407</width>
|
||||
<height>129</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Frame</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_StatusMessageForm">
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLineEdit" name="le_Severity">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="5">
|
||||
<widget class="QPlainTextEdit" name="te_Message">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="lbl_Severity">
|
||||
<property name="text">
|
||||
<string>Severity:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3" colspan="3">
|
||||
<widget class="QLineEdit" name="le_Categories">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="lbl_SeverityIcon">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../blackmisc/blackmisc.qrc">:/diagona/icons/diagona/icons/question.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Timestamp:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<widget class="QLineEdit" name="le_Timestamp">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QLabel" name="lbl_Categories">
|
||||
<property name="text">
|
||||
<string>Categories:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../blackmisc/blackmisc.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -18,13 +18,24 @@ namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
/*
|
||||
* Constructor
|
||||
*/
|
||||
CStatusMessageView::CStatusMessageView(QWidget *parent) : CViewBase(parent)
|
||||
{
|
||||
m_withMenuItemClear = true;
|
||||
this->standardInit(new CStatusMessageListModel(this));
|
||||
connect(this, &CStatusMessageView::clicked, this, &CStatusMessageView::ps_messageSelected);
|
||||
}
|
||||
|
||||
void CStatusMessageView::setMode(CStatusMessageListModel::Mode mode)
|
||||
{
|
||||
this->derivedModel()->setMode(mode);
|
||||
}
|
||||
|
||||
void CStatusMessageView::ps_messageSelected(const QModelIndex &index)
|
||||
{
|
||||
if (!index.isValid()) { return; }
|
||||
emit messageSelected(
|
||||
this->at(index)
|
||||
);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -21,13 +21,26 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Status message view
|
||||
class BLACKGUI_EXPORT CStatusMessageView : public CViewBase<Models::CStatusMessageListModel, BlackMisc::CStatusMessageList, BlackMisc::CStatusMessage>
|
||||
class BLACKGUI_EXPORT CStatusMessageView :
|
||||
public CViewBase<Models::CStatusMessageListModel, BlackMisc::CStatusMessageList, BlackMisc::CStatusMessage>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CStatusMessageView(QWidget *parent = nullptr);
|
||||
|
||||
//! Set mode
|
||||
void setMode(BlackGui::Models::CStatusMessageListModel::Mode mode);
|
||||
|
||||
signals:
|
||||
//! Message has been selected
|
||||
void messageSelected(const BlackMisc::CStatusMessage &statusMessage);
|
||||
|
||||
private:
|
||||
//! Message selected
|
||||
void ps_messageSelected(const QModelIndex &index);
|
||||
};
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
#endif // guard
|
||||
|
||||
Reference in New Issue
Block a user