diff --git a/src/blackgui/components/logincomponent.ui b/src/blackgui/components/logincomponent.ui index 042dfe89f..a6406b386 100644 --- a/src/blackgui/components/logincomponent.ui +++ b/src/blackgui/components/logincomponent.ui @@ -6,8 +6,8 @@ 0 0 - 275 - 677 + 273 + 622 @@ -29,6 +29,37 @@ 1 + + + + Matching logging + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + @@ -236,37 +267,6 @@ - - - - Pilot's info - - - - 2 - - - 2 - - - 2 - - - 2 - - - - - - 0 - 50 - - - - - - - @@ -507,6 +507,37 @@ 5 + + + + Pilot's info + + + + 2 + + + 2 + + + 2 + + + 2 + + + + + + 0 + 50 + + + + + + + @@ -680,6 +711,12 @@ + + BlackGui::Components::CModelMatcherLogEnable + QFrame +
blackgui/components/modelmatcherlogenable.h
+ 1 +
BlackGui::CTickLabel QLabel diff --git a/src/blackgui/components/modelmatcherlogcomponent.cpp b/src/blackgui/components/modelmatcherlogcomponent.cpp index fcad93716..bb3b242eb 100644 --- a/src/blackgui/components/modelmatcherlogcomponent.cpp +++ b/src/blackgui/components/modelmatcherlogcomponent.cpp @@ -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 diff --git a/src/blackgui/components/modelmatcherlogcomponent.h b/src/blackgui/components/modelmatcherlogcomponent.h index 1242ca47a..1ba3bf76a 100644 --- a/src/blackgui/components/modelmatcherlogcomponent.h +++ b/src/blackgui/components/modelmatcherlogcomponent.h @@ -12,7 +12,6 @@ #ifndef BLACKGUI_COMPONENT_MODELMATCHERLOGCOMPONENT_H #define BLACKGUI_COMPONENT_MODELMATCHERLOGCOMPONENT_H -#include "blackcore/network.h" #include #include #include @@ -41,9 +40,6 @@ namespace BlackGui QScopedPointer 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 diff --git a/src/blackgui/components/modelmatcherlogcomponent.ui b/src/blackgui/components/modelmatcherlogcomponent.ui index fc2dec85c..ebefeae18 100644 --- a/src/blackgui/components/modelmatcherlogcomponent.ui +++ b/src/blackgui/components/modelmatcherlogcomponent.ui @@ -6,8 +6,8 @@ 0 0 - 320 - 256 + 264 + 245
@@ -55,27 +55,16 @@
- - - QFrame::StyledPanel - - - QFrame::Raised - - + - - - - Enables / disables future message logging + + + + + 0 + 15 + - - Enable: - - - - - 0 @@ -89,39 +78,6 @@ 0 - - - - enable logging of reverse lookup messages - - - rev. lookup msgs. - - - - - - - enable matching messages - - - matching msgs. - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - @@ -150,6 +106,12 @@
blackgui/components/callsigncompleter.h
1 + + BlackGui::Components::CModelMatcherLogEnable + QFrame +
blackgui/components/modelmatcherlogenable.h
+ 1 +
diff --git a/src/blackgui/components/modelmatcherlogenable.cpp b/src/blackgui/components/modelmatcherlogenable.cpp new file mode 100644 index 000000000..ab15ffb62 --- /dev/null +++ b/src/blackgui/components/modelmatcherlogenable.cpp @@ -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 +#include + +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 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 diff --git a/src/blackgui/components/modelmatcherlogenable.h b/src/blackgui/components/modelmatcherlogenable.h new file mode 100644 index 000000000..22089961d --- /dev/null +++ b/src/blackgui/components/modelmatcherlogenable.h @@ -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 +#include + +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; + + //! 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 diff --git a/src/blackgui/components/modelmatcherlogenable.ui b/src/blackgui/components/modelmatcherlogenable.ui new file mode 100644 index 000000000..dedcc71d6 --- /dev/null +++ b/src/blackgui/components/modelmatcherlogenable.ui @@ -0,0 +1,83 @@ + + + CModelMatcherLogEnable + + + + 0 + 0 + 276 + 20 + + + + Frame + + + + 10 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Enables / disables future message logging + + + Enable: + + + + + + + enable logging of reverse lookup messages + + + rev. lookup msgs. + + + + + + + enable matching messages + + + matching msgs. + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + cb_LogReverseLookup + cb_LogMatchingMessages + + + +