Matching log can be enabled from login screen

* own enable UI component
* adjusted login and matcher UI component
This commit is contained in:
Klaus Basan
2018-08-17 01:41:32 +02:00
parent a230f65f19
commit 418769ccf8
7 changed files with 348 additions and 158 deletions

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>275</width>
<height>677</height>
<width>273</width>
<height>622</height>
</rect>
</property>
<property name="windowTitle">
@@ -29,6 +29,37 @@
<property name="bottomMargin">
<number>1</number>
</property>
<item>
<widget class="QGroupBox" name="gb_MatchingLog">
<property name="title">
<string>Matching logging</string>
</property>
<layout class="QVBoxLayout" name="vl_MatchingLog">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="BlackGui::Components::CModelMatcherLogEnable" name="comp_MatchingLogEnabled">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gb_Network">
<property name="title">
@@ -236,37 +267,6 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gb_PilotsDetails">
<property name="title">
<string>Pilot's info</string>
</property>
<layout class="QVBoxLayout" name="vl_PilotIngoGroupBox">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item alignment="Qt::AlignTop">
<widget class="BlackGui::Editors::CPilotForm" name="editor_Pilot">
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item alignment="Qt::AlignTop">
<widget class="QGroupBox" name="gb_OwnAircraft">
<property name="title">
@@ -507,6 +507,37 @@
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QGroupBox" name="gb_PilotsDetails">
<property name="title">
<string>Pilot's info</string>
</property>
<layout class="QVBoxLayout" name="vl_PilotIngoGroupBox">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item alignment="Qt::AlignTop">
<widget class="BlackGui::Editors::CPilotForm" name="editor_Pilot">
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item alignment="Qt::AlignTop">
<widget class="QGroupBox" name="gb_CurrentLogin">
<property name="title">
@@ -680,6 +711,12 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::Components::CModelMatcherLogEnable</class>
<extends>QFrame</extends>
<header>blackgui/components/modelmatcherlogenable.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::CTickLabel</class>
<extends>QLabel</extends>

View File

@@ -33,42 +33,13 @@ namespace BlackGui
ui(new Ui::CModelMatcherLogComponent)
{
ui->setupUi(this);
this->initGui();
m_text.setDefaultStyleSheet(CStatusMessageList::htmlStyleSheet());
connect(ui->comp_CallsignCompleter, &CCallsignCompleter::validCallsignEntered, this, &CModelMatcherLogComponent::callsignEntered);
connect(ui->cb_LogReverseLookup, &QCheckBox::toggled, this, &CModelMatcherLogComponent::enabledCheckboxChanged);
connect(ui->cb_LogMatchingMessages, &QCheckBox::toggled, this, &CModelMatcherLogComponent::enabledCheckboxChanged);
if (this->hasContexts())
{
connect(sGui->getIContextSimulator(), &IContextSimulator::changedLogOrDebugSettings, this, &CModelMatcherLogComponent::valuesChanged, Qt::QueuedConnection);
connect(sGui->getIContextNetwork(), &IContextNetwork::changedLogOrDebugSettings, this, &CModelMatcherLogComponent::valuesChanged, Qt::QueuedConnection);
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CModelMatcherLogComponent::connectionStatusChanged, Qt::QueuedConnection);
}
}
CModelMatcherLogComponent::~CModelMatcherLogComponent()
{ }
void CModelMatcherLogComponent::initGui()
{
if (sGui)
{
// avoid signal roundtrips
bool c = sGui->getIContextNetwork()->isReverseLookupMessagesEnabled();
if (c != ui->cb_LogReverseLookup->isChecked())
{
ui->cb_LogReverseLookup->setChecked(c);
}
c = sGui->getIContextSimulator()->isMatchingMessagesEnabled();
if (c != ui->cb_LogMatchingMessages->isChecked())
{
ui->cb_LogMatchingMessages->setChecked(c);
}
}
}
bool CModelMatcherLogComponent::hasContexts() const
{
return sGui && sGui->getIContextSimulator() && sGui->getIContextNetwork();
@@ -76,7 +47,7 @@ namespace BlackGui
bool CModelMatcherLogComponent::enabledMessages() const
{
return this->hasContexts() && (ui->cb_LogMatchingMessages->isChecked() || ui->cb_LogReverseLookup->isChecked());
return this->hasContexts() && (ui->comp_EnableLog->isMatchingLogEnabled() || ui->comp_EnableLog->isReverseLookupLogEnabled());
}
void CModelMatcherLogComponent::callsignEntered()
@@ -94,33 +65,5 @@ namespace BlackGui
m_text.setHtml(html);
ui->te_Messages->setDocument(&m_text);
}
void CModelMatcherLogComponent::valuesChanged()
{
this->initGui();
}
void CModelMatcherLogComponent::enabledCheckboxChanged(bool enabled)
{
if (!sGui || !sGui->getIContextNetwork() || !sGui->getIContextSimulator()) { return; }
const QObject *sender = QObject::sender();
if (sender == ui->cb_LogReverseLookup)
{
sGui->getIContextNetwork()->enableReverseLookupMessages(enabled);
}
else if (sender == ui->cb_LogMatchingMessages)
{
sGui->getIContextSimulator()->enableMatchingMessages(enabled);
}
}
void CModelMatcherLogComponent::connectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to)
{
Q_UNUSED(from);
if (to == INetwork::Connected || to == INetwork::Disconnected)
{
this->initGui();
}
}
} // ns
} // ns

View File

@@ -12,7 +12,6 @@
#ifndef BLACKGUI_COMPONENT_MODELMATCHERLOGCOMPONENT_H
#define BLACKGUI_COMPONENT_MODELMATCHERLOGCOMPONENT_H
#include "blackcore/network.h"
#include <QFrame>
#include <QTabWidget>
#include <QTimer>
@@ -41,9 +40,6 @@ namespace BlackGui
QScopedPointer<Ui::CModelMatcherLogComponent> ui;
QTextDocument m_text { this };
//! Init
void initGui();
//! Contexts available
bool hasContexts() const;
@@ -52,15 +48,6 @@ namespace BlackGui
//! Callsign was entered
void callsignEntered();
//! When values changed elsewhere
void valuesChanged();
//! Flag changed
void enabledCheckboxChanged(bool enabled);
//! Connection status changed
void connectionStatusChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to);
};
} // ns
} // ns

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>320</width>
<height>256</height>
<width>264</width>
<height>245</height>
</rect>
</property>
<property name="windowTitle">
@@ -55,27 +55,16 @@
</widget>
</item>
<item row="0" column="1">
<widget class="BlackGui::Components::CCallsignCompleter" name="comp_CallsignCompleter">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
<widget class="BlackGui::Components::CCallsignCompleter" name="comp_CallsignCompleter"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lbl_Enable">
<property name="toolTip">
<string>Enables / disables future message logging</string>
<item row="2" column="0" colspan="2">
<widget class="BlackGui::Components::CModelMatcherLogEnable" name="comp_EnableLog">
<property name="minimumSize">
<size>
<width>0</width>
<height>15</height>
</size>
</property>
<property name="text">
<string>Enable:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QWidget" name="wi_CheckBoxes" native="true">
<layout class="QHBoxLayout" name="hl_CheckBoxes">
<property name="leftMargin">
<number>0</number>
@@ -89,39 +78,6 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="cb_LogReverseLookup">
<property name="toolTip">
<string>enable logging of reverse lookup messages</string>
</property>
<property name="text">
<string>rev. lookup msgs.</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cb_LogMatchingMessages">
<property name="toolTip">
<string>enable matching messages</string>
</property>
<property name="text">
<string>matching msgs.</string>
</property>
</widget>
</item>
<item>
<spacer name="hs_CheckBoxes">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
@@ -150,6 +106,12 @@
<header>blackgui/components/callsigncompleter.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CModelMatcherLogEnable</class>
<extends>QFrame</extends>
<header>blackgui/components/modelmatcherlogenable.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@@ -0,0 +1,115 @@
/* Copyright (C) 2018
* 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 "modelmatcherlogenable.h"
#include "guiapplication.h"
#include "ui_modelmatcherlogenable.h"
#include "blackcore/context/contextnetwork.h"
#include "blackcore/context/contextsimulator.h"
#include <QPointer>
#include <QTimer>
using namespace BlackCore;
using namespace BlackCore::Context;
namespace BlackGui
{
namespace Components
{
CModelMatcherLogEnable::CModelMatcherLogEnable(QWidget *parent) :
QFrame(parent),
ui(new Ui::CModelMatcherLogEnable)
{
ui->setupUi(this);
connect(ui->cb_LogReverseLookup, &QCheckBox::toggled, this, &CModelMatcherLogEnable::enabledCheckboxChanged);
connect(ui->cb_LogMatchingMessages, &QCheckBox::toggled, this, &CModelMatcherLogEnable::enabledCheckboxChanged);
if (this->hasContexts())
{
connect(sGui->getIContextSimulator(), &IContextSimulator::changedLogOrDebugSettings, this, &CModelMatcherLogEnable::valuesChanged, Qt::QueuedConnection);
connect(sGui->getIContextNetwork(), &IContextNetwork::changedLogOrDebugSettings, this, &CModelMatcherLogEnable::valuesChanged, Qt::QueuedConnection);
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CModelMatcherLogEnable::connectionStatusChanged, Qt::QueuedConnection);
}
QPointer<CModelMatcherLogEnable> myself(this);
QTimer::singleShot(5000, this, [ = ]
{
if (!myself) { return; }
this->initGui();
});
}
CModelMatcherLogEnable::~CModelMatcherLogEnable()
{ }
bool CModelMatcherLogEnable::isReverseLookupLogEnabled() const
{
return ui->cb_LogReverseLookup->isChecked();
}
bool CModelMatcherLogEnable::isMatchingLogEnabled() const
{
return ui->cb_LogMatchingMessages->isChecked();
}
void CModelMatcherLogEnable::enabledCheckboxChanged(bool enabled)
{
if (!this->hasContexts()) { return; }
const QObject *sender = QObject::sender();
if (sender == ui->cb_LogReverseLookup)
{
sGui->getIContextNetwork()->enableReverseLookupMessages(enabled);
}
else if (sender == ui->cb_LogMatchingMessages)
{
sGui->getIContextSimulator()->enableMatchingMessages(enabled);
}
}
void CModelMatcherLogEnable::initGui()
{
if (this->hasContexts())
{
// avoid signal roundtrips
bool c = sGui->getIContextNetwork()->isReverseLookupMessagesEnabled();
if (c != ui->cb_LogReverseLookup->isChecked())
{
ui->cb_LogReverseLookup->setChecked(c);
}
c = sGui->getIContextSimulator()->isMatchingMessagesEnabled();
if (c != ui->cb_LogMatchingMessages->isChecked())
{
ui->cb_LogMatchingMessages->setChecked(c);
}
}
}
bool CModelMatcherLogEnable::hasContexts() const
{
if (!sGui || sGui->isShuttingDown()) { return false; }
return sGui->getIContextSimulator() && sGui->getIContextNetwork();
}
void CModelMatcherLogEnable::valuesChanged()
{
this->initGui();
}
void CModelMatcherLogEnable::connectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to)
{
Q_UNUSED(from);
if (to == INetwork::Connected || to == INetwork::Disconnected)
{
this->initGui();
}
}
} // ns
} // ns

View File

@@ -0,0 +1,63 @@
/* Copyright (C) 2018
* 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_COMPONENTS_MODELMATCHERLOGENABLE_H
#define BLACKGUI_COMPONENTS_MODELMATCHERLOGENABLE_H
#include "blackcore/network.h"
#include <QFrame>
#include <QScopedPointer>
namespace Ui { class CModelMatcherLogEnable; }
namespace BlackGui
{
namespace Components
{
//! Enable/disable matching logs
class CModelMatcherLogEnable : public QFrame
{
Q_OBJECT
public:
//! Constructor
explicit CModelMatcherLogEnable(QWidget *parent = nullptr);
//! Destructor
virtual ~CModelMatcherLogEnable();
//! Reverse lookup enabled?
bool isReverseLookupLogEnabled() const;
//! Matching log.enabled
bool isMatchingLogEnabled() const;
private:
QScopedPointer<Ui::CModelMatcherLogEnable> ui;
//! Flag changed
void enabledCheckboxChanged(bool enabled);
//! Init GUI
void initGui();
//! Has required context
bool hasContexts() const;
//! When values changed elsewhere
void valuesChanged();
//! Connection status has been changed
void connectionStatusChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to);
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CModelMatcherLogEnable</class>
<widget class="QFrame" name="CModelMatcherLogEnable">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>276</width>
<height>20</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<layout class="QHBoxLayout" name="hl_ModelMatcherLogEnable">
<property name="spacing">
<number>10</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="lbl_Enable">
<property name="toolTip">
<string>Enables / disables future message logging</string>
</property>
<property name="text">
<string>Enable:</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cb_LogReverseLookup">
<property name="toolTip">
<string>enable logging of reverse lookup messages</string>
</property>
<property name="text">
<string>rev. lookup msgs.</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cb_LogMatchingMessages">
<property name="toolTip">
<string>enable matching messages</string>
</property>
<property name="text">
<string>matching msgs.</string>
</property>
</widget>
</item>
<item>
<spacer name="hs_ModelMatcherLogEnable">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<tabstops>
<tabstop>cb_LogReverseLookup</tabstop>
<tabstop>cb_LogMatchingMessages</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>