mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 19:05:31 +08:00
Improved status message filtering
* avoid re-init of widget if already initialized * allow icons instead of text for severity radio buttons * changing severity filter directly triggers new filtering * use icon for new button * init this->showFilterBar() as default (otherwise not functional) * widths for filter bar buttons
This commit is contained in:
committed by
Mathew Sutcliffe
parent
3575eed37b
commit
6825524025
@@ -55,6 +55,7 @@ namespace BlackGui
|
||||
ui->tvp_StatusMessages->setAutoResizeFrequency(3);
|
||||
ui->tvp_StatusMessages->setCustomMenu(new CLogMenu(this));
|
||||
ui->tvp_StatusMessages->menuAddItems(CStatusMessageView::MenuSave);
|
||||
this->showFilterBar(); // default
|
||||
}
|
||||
|
||||
CLogComponent::~CLogComponent()
|
||||
@@ -89,6 +90,11 @@ namespace BlackGui
|
||||
ui->filter_LogMessages->show();
|
||||
}
|
||||
|
||||
void CLogComponent::filterUseRadioButtonDescriptiveIcons(bool oneCharacterText)
|
||||
{
|
||||
ui->filter_LogMessages->useRadioButtonDescriptiveIcons(oneCharacterText);
|
||||
}
|
||||
|
||||
void CLogComponent::clear()
|
||||
{
|
||||
ui->tvp_StatusMessages->clear();
|
||||
|
||||
@@ -75,6 +75,9 @@ namespace BlackGui
|
||||
//! Show a filter bar
|
||||
void showFilterBar();
|
||||
|
||||
//! Set fi
|
||||
void filterUseRadioButtonDescriptiveIcons(bool oneLetterText);
|
||||
|
||||
//! Clear
|
||||
void clear();
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace BlackGui
|
||||
connect(ui->tb_ClearForm, &QToolButton::clicked, this, &CFilterBarButtons::ps_buttonClicked);
|
||||
connect(ui->tb_Filter, &QToolButton::clicked, this, &CFilterBarButtons::ps_buttonClicked);
|
||||
connect(ui->tb_RemoveFilter, &QToolButton::clicked, this, &CFilterBarButtons::ps_buttonClicked);
|
||||
connect(ui->pb_New, &QToolButton::clicked, this, &CFilterBarButtons::ps_buttonClicked);
|
||||
connect(ui->tb_New, &QToolButton::clicked, this, &CFilterBarButtons::ps_buttonClicked);
|
||||
}
|
||||
|
||||
CFilterBarButtons::~CFilterBarButtons()
|
||||
@@ -43,7 +43,7 @@ namespace BlackGui
|
||||
if (sender == ui->tb_ClearForm) { emit buttonClicked(ClearForm); }
|
||||
else if (sender == ui->tb_Filter) { emit buttonClicked(Filter); }
|
||||
else if (sender == ui->tb_RemoveFilter) { emit buttonClicked(RemoveFilter); }
|
||||
else if (sender == ui->pb_New)
|
||||
else if (sender == ui->tb_New)
|
||||
{
|
||||
emit buttonClicked(RemoveFilter);
|
||||
emit buttonClicked(ClearForm);
|
||||
|
||||
@@ -2,9 +2,17 @@
|
||||
<ui version="4.0">
|
||||
<class>CFilterBarButtons</class>
|
||||
<widget class="QFrame" name="CFilterBarButtons">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>211</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>140</width>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
@@ -31,13 +39,13 @@
|
||||
<widget class="QLineEdit" name="le_Count">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<width>30</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<width>75</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
@@ -49,7 +57,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<item>
|
||||
<widget class="QToolButton" name="tb_Filter">
|
||||
<property name="toolTip">
|
||||
<string>filter</string>
|
||||
@@ -63,7 +71,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<item>
|
||||
<widget class="QToolButton" name="tb_RemoveFilter">
|
||||
<property name="toolTip">
|
||||
<string>remove filter</string>
|
||||
@@ -77,7 +85,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<item>
|
||||
<widget class="QToolButton" name="tb_ClearForm">
|
||||
<property name="toolTip">
|
||||
<string>clear form</string>
|
||||
@@ -95,16 +103,17 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_New">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
<widget class="QToolButton" name="tb_New">
|
||||
<property name="toolTip">
|
||||
<string>new (clear + remove filter)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>new</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../blackmisc/blackmisc.qrc">
|
||||
<normaloff>:/diagona/icons/diagona/icons/cross-button.png</normaloff>:/diagona/icons/diagona/icons/cross-button.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@@ -112,9 +121,6 @@
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>10</width>
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace BlackGui
|
||||
{
|
||||
CFilterWidget::CFilterWidget(QWidget *parent) : QFrame(parent)
|
||||
{
|
||||
Q_ASSERT_X(sGui, Q_FUNC_INFO, "sGui missing");
|
||||
this->setWindowTitle("Filter widget");
|
||||
ps_onStyleSheetChanged();
|
||||
connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CFilterWidget::ps_onStyleSheetChanged);
|
||||
|
||||
@@ -29,6 +29,10 @@ namespace BlackGui
|
||||
connect(ui->le_Category, &QLineEdit::returnPressed, this, &CFilterWidget::triggerFilter);
|
||||
connect(ui->le_MessageText, &QLineEdit::returnPressed, this, &CFilterWidget::triggerFilter);
|
||||
|
||||
connect(ui->rb_Error, &QRadioButton::released, this, &CStatusMessageFilterBar::radioButtonChanged);
|
||||
connect(ui->rb_Info, &QRadioButton::released, this, &CStatusMessageFilterBar::radioButtonChanged);
|
||||
connect(ui->rb_Warning, &QRadioButton::released, this, &CStatusMessageFilterBar::radioButtonChanged);
|
||||
|
||||
ui->le_Category->setCompleter(new QCompleter(CLogPattern::allHumanReadableNames(), this));
|
||||
|
||||
// reset form
|
||||
@@ -43,6 +47,25 @@ namespace BlackGui
|
||||
CStatusMessageFilterBar::~CStatusMessageFilterBar()
|
||||
{ }
|
||||
|
||||
void CStatusMessageFilterBar::useRadioButtonDescriptiveIcons(bool oneCharacterText)
|
||||
{
|
||||
CStatusMessage msg;
|
||||
msg.setSeverity(CStatusMessage::SeverityError);
|
||||
ui->rb_Error->setIcon(msg.toIcon().toQIcon());
|
||||
ui->rb_Error->setToolTip(msg.getSeverityAsString());
|
||||
ui->rb_Error->setText(oneCharacterText ? msg.getSeverityAsString().left(1) : "");
|
||||
|
||||
msg.setSeverity(CStatusMessage::SeverityWarning);
|
||||
ui->rb_Warning->setIcon(msg.toIcon().toQIcon());
|
||||
ui->rb_Warning->setToolTip(msg.getSeverityAsString());
|
||||
ui->rb_Warning->setText(oneCharacterText ? msg.getSeverityAsString().left(1) : "");
|
||||
|
||||
msg.setSeverity(CStatusMessage::SeverityInfo);
|
||||
ui->rb_Info->setIcon(msg.toIcon().toQIcon());
|
||||
ui->rb_Info->setToolTip(msg.getSeverityAsString());
|
||||
ui->rb_Info->setText(oneCharacterText ? msg.getSeverityAsString().left(1) : "");
|
||||
}
|
||||
|
||||
std::unique_ptr<BlackGui::Models::IModelFilter<BlackMisc::CStatusMessageList> > CStatusMessageFilterBar::createModelFilter() const
|
||||
{
|
||||
return std::make_unique<CStatusMessageFilter>(
|
||||
@@ -64,6 +87,11 @@ namespace BlackGui
|
||||
ui->rb_Info->setChecked(true);
|
||||
}
|
||||
|
||||
void CStatusMessageFilterBar::radioButtonChanged()
|
||||
{
|
||||
this->triggerFilter();
|
||||
}
|
||||
|
||||
CStatusMessage::StatusSeverity CStatusMessageFilterBar::getSelectedSeverity() const
|
||||
{
|
||||
if (ui->rb_Error->isChecked()) { return CStatusMessage::SeverityError; }
|
||||
|
||||
@@ -41,6 +41,9 @@ namespace BlackGui
|
||||
//! Destructor
|
||||
virtual ~CStatusMessageFilterBar();
|
||||
|
||||
//! Use icons with radio buttons
|
||||
void useRadioButtonDescriptiveIcons(bool oneCharacterText);
|
||||
|
||||
//! \copydoc Models::IModelFilterProvider::createModelFilter
|
||||
virtual std::unique_ptr<BlackGui::Models::IModelFilter<BlackMisc::CStatusMessageList>> createModelFilter() const override;
|
||||
|
||||
@@ -55,6 +58,9 @@ namespace BlackGui
|
||||
private:
|
||||
QScopedPointer<Ui::CStatusMessageFilterBar> ui;
|
||||
|
||||
//! Radio button was changed
|
||||
void radioButtonChanged();
|
||||
|
||||
//! Get the selected severity
|
||||
BlackMisc::CStatusMessage::StatusSeverity getSelectedSeverity() const;
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>324</width>
|
||||
<width>359</width>
|
||||
<height>58</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -33,7 +33,7 @@
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
@@ -75,16 +75,10 @@
|
||||
<widget class="BlackGui::Filters::CFilterBarButtons" name="filter_Buttons">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<width>75</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
|
||||
@@ -136,6 +136,8 @@ namespace BlackGui
|
||||
|
||||
void CViewBaseNonTemplate::setFilterWidgetImpl(QWidget *filterWidget)
|
||||
{
|
||||
if (filterWidget == this->m_filterWidget) { return; }
|
||||
|
||||
// dialog or filter widget
|
||||
if (this->m_filterWidget)
|
||||
{
|
||||
@@ -154,6 +156,7 @@ namespace BlackGui
|
||||
|
||||
void CViewBaseNonTemplate::setFilterDialog(CFilterDialog *filterDialog)
|
||||
{
|
||||
if (filterDialog == this->m_filterWidget) { return; }
|
||||
this->setFilterWidgetImpl(filterDialog);
|
||||
if (filterDialog)
|
||||
{
|
||||
@@ -165,6 +168,7 @@ namespace BlackGui
|
||||
|
||||
void CViewBaseNonTemplate::setFilterWidget(CFilterWidget *filterWidget)
|
||||
{
|
||||
if (filterWidget == this->m_filterWidget) { return; }
|
||||
this->setFilterWidgetImpl(filterWidget);
|
||||
if (filterWidget)
|
||||
{
|
||||
|
||||
@@ -128,7 +128,7 @@ void CSwiftLauncher::ps_displayLatestNews(QNetworkReply *reply)
|
||||
{
|
||||
const QString html = nwReply->readAll().trimmed();
|
||||
if (html.isEmpty()) { return; }
|
||||
ui->tbr_LatestNews->setHtml(html);
|
||||
ui->tbr_LatestNews->setHtml(html); // causes QFSFileEngine::open: No file name specified
|
||||
constexpr qint64 newNews = 72 * 3600 * 1000;
|
||||
const qint64 deltaT = CNetworkUtils::lastModifiedSinceNow(nwReply.data());
|
||||
if (deltaT > 0 && deltaT < newNews)
|
||||
@@ -149,7 +149,7 @@ void CSwiftLauncher::init()
|
||||
|
||||
m_mwaOverlayFrame = ui->fr_SwiftLauncherMain;
|
||||
m_mwaStatusBar = nullptr;
|
||||
m_mwaLogComponent = ui->fr_SwiftLauncherLog;
|
||||
m_mwaLogComponent = ui->comp_SwiftLauncherLog;
|
||||
|
||||
ui->lbl_NewVersionUrl->setTextFormat(Qt::RichText);
|
||||
ui->lbl_NewVersionUrl->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||
@@ -231,6 +231,9 @@ void CSwiftLauncher::initLogDisplay()
|
||||
CLogPattern().withSeverityAtOrAbove(CStatusMessage::SeverityInfo)
|
||||
);
|
||||
logHandler->subscribe(this, &CSwiftLauncher::ps_appendLogMessage);
|
||||
|
||||
ui->comp_SwiftLauncherLog->showFilterBar();
|
||||
ui->comp_SwiftLauncherLog->filterUseRadioButtonDescriptiveIcons(false);
|
||||
}
|
||||
|
||||
void CSwiftLauncher::startSwiftCore()
|
||||
@@ -495,7 +498,7 @@ void CSwiftLauncher::ps_showStatusMessage(const CStatusMessage &msg)
|
||||
|
||||
void CSwiftLauncher::ps_appendLogMessage(const CStatusMessage &message)
|
||||
{
|
||||
ui->fr_SwiftLauncherLog->appendStatusMessageToList(message);
|
||||
ui->comp_SwiftLauncherLog->appendStatusMessageToList(message);
|
||||
if (message.getSeverity() == CStatusMessage::SeverityError)
|
||||
{
|
||||
this->ps_showStatusMessage(message);
|
||||
@@ -504,7 +507,7 @@ void CSwiftLauncher::ps_appendLogMessage(const CStatusMessage &message)
|
||||
|
||||
void CSwiftLauncher::ps_appendLogMessages(const CStatusMessageList &messages)
|
||||
{
|
||||
ui->fr_SwiftLauncherLog->appendStatusMessagesToList(messages);
|
||||
ui->comp_SwiftLauncherLog->appendStatusMessagesToList(messages);
|
||||
if (messages.hasErrorMessages())
|
||||
{
|
||||
this->ps_showStatusMessage(messages.getErrorMessages().toSingleMessage());
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="pg_SwiftLauncherMain">
|
||||
<layout class="QVBoxLayout" name="wl_SwiftLauncherMainPage">
|
||||
@@ -879,7 +879,7 @@ p, li { white-space: pre-wrap; }
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CLogComponent" name="fr_SwiftLauncherLog">
|
||||
<widget class="BlackGui::Components::CLogComponent" name="comp_SwiftLauncherLog">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
@@ -935,8 +935,8 @@ p, li { white-space: pre-wrap; }
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="swiftlauncher.qrc"/>
|
||||
<include location="../blackmisc/blackmisc.qrc"/>
|
||||
<include location="swiftlauncher.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
<buttongroups>
|
||||
|
||||
Reference in New Issue
Block a user