refactor: Remove build-in console

The console feature was not documented very well and was only used for a
few messages.
This commit is contained in:
Lars Toenning
2024-10-06 19:15:03 +02:00
parent 7cdec8eeb6
commit c9ef304ec9
24 changed files with 12 additions and 203 deletions

View File

@@ -97,10 +97,6 @@ namespace BlackCore
//! \note Used for hotkey action, do not use directly
void remoteHotkeyAction(const QString &action, bool argument, const BlackMisc::CIdentifier &origin);
//! Request a message to be displayed on console, whatever the console is
//! \note no guarantee it is really written to console
void requestDisplayOnConsole(const QString &message);
public slots:
//! Ratify some settings changed by another process
//! \note Not pure because it can be called from the base class constructor.

View File

@@ -45,8 +45,6 @@ namespace BlackCore::Context
s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(),
"remoteHotkeyAction", this, SIGNAL(remoteHotkeyAction(QString, bool, BlackMisc::CIdentifier)));
Q_ASSERT(s);
s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(),
"requestDisplayOnConsole", this, SIGNAL(requestDisplayOnConsole(QString)));
Q_UNUSED(s);
this->relayBaseClassSignals(serviceName, connection, IContextApplication::ObjectPath(), IContextApplication::InterfaceName());
}

View File

@@ -149,9 +149,6 @@ namespace BlackCore::Context
//! Relevant simulator messages to be explicitly displayed
void driverMessages(const BlackMisc::CStatusMessageList &messages);
//! Request a console message (whatever the console maybe)
void requestUiConsoleMessage(const QString &driverMessage, bool clear);
//! Validated model set
void validatedModelSet(const BlackMisc::Simulation::CSimulatorInfo &simulator,
const BlackMisc::Simulation::CAircraftModelList &valid, const BlackMisc::Simulation::CAircraftModelList &invalid,

View File

@@ -515,8 +515,6 @@ namespace BlackCore::Context
Q_ASSERT(c);
c = connect(simulator, &ISimulator::driverMessages, this, &IContextSimulator::driverMessages);
Q_ASSERT(c);
c = connect(simulator, &ISimulator::requestUiConsoleMessage, this, &IContextSimulator::requestUiConsoleMessage);
Q_ASSERT(c);
c = connect(simulator, &ISimulator::autoPublishDataWritten, this, &IContextSimulator::autoPublishDataWritten);
Q_ASSERT(c);
@@ -1074,14 +1072,6 @@ namespace BlackCore::Context
{
CInterpolationAndRenderingSetupGlobal rs = this->getInterpolationAndRenderingSetupGlobal();
const QString p1 = parser.part(1);
if (p1 == "show")
{
if (this->getIContextApplication())
{
emit this->getIContextApplication()->requestDisplayOnConsole(rs.toQString(true));
}
return true;
}
if (!parser.hasPart(2)) { return false; }
const bool on = stringToBool(parser.part(2));
if (p1 == "debug") { rs.setSimulatorDebuggingMessages(on); }

View File

@@ -270,7 +270,6 @@ namespace BlackCore
{
if (BlackMisc::CSimpleCommandParser::registered("BlackCore::CContextSimulator")) { return; }
BlackMisc::CSimpleCommandParser::registerCommand({ ".ris", "rendering/interpolation setup (global setup)" });
BlackMisc::CSimpleCommandParser::registerCommand({ ".ris show", "display rendering/interpolation setup on console (global setup)" });
BlackMisc::CSimpleCommandParser::registerCommand({ ".ris debug on|off", "rendering/interpolation debug messages (global setup)" });
BlackMisc::CSimpleCommandParser::registerCommand({ ".ris parts on|off", "aircraft parts (global setup)" });
}

View File

@@ -91,9 +91,6 @@ namespace BlackCore::Context
"driverMessages", this, SIGNAL(driverMessages(BlackMisc::CStatusMessageList)));
Q_ASSERT(s);
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
"requestUiConsoleMessage", this, SIGNAL(requestUiConsoleMessage(QString, bool)));
Q_ASSERT(s);
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
"validatedModelSet", this, SIGNAL(validatedModelSet(BlackMisc::Simulation::CSimulatorInfo, BlackMisc::Simulation::CAircraftModelList, BlackMisc::Simulation::CAircraftModelList, bool, BlackMisc::CStatusMessageList)));
Q_ASSERT(s);

View File

@@ -1285,7 +1285,6 @@ namespace BlackCore
if (!dm.isEmpty())
{
this->displayStatusMessage(CStatusMessage(this).info(dm));
emit this->requestUiConsoleMessage(dm, true);
}
const int t = CMathUtils::randomInteger(4500, 5500); // makes sure not always using the same time difference

View File

@@ -379,9 +379,6 @@ namespace BlackCore
//! Relevant simulator messages to be explicitly displayed
void driverMessages(const BlackMisc::CStatusMessageList &messages);
//! Request a console message (whatever the console maybe)
void requestUiConsoleMessage(const QString &driverMessage, bool clear);
//! Requested elevation, call pending
void requestedElevation(const BlackMisc::Aviation::CCallsign &callsign);

View File

@@ -67,14 +67,6 @@ namespace BlackGui::Components
this->getLogComponent()->displayLog();
}
void CDataMainInfoAreaComponent::displayConsole()
{
this->selectArea(InfoAreaLog);
BLACK_VERIFY_X(this->getLogComponent(), Q_FUNC_INFO, "No log component");
if (!this->getLogComponent()) { return; }
this->getLogComponent()->displayConsole();
}
void CDataMainInfoAreaComponent::selectLog()
{
this->selectArea(InfoAreaLog);

View File

@@ -68,9 +68,6 @@ namespace BlackGui::Components
//! Display the log
void displayLog();
//! Display console
void displayConsole();
public slots:
//! Select log area
void selectLog();

View File

@@ -45,7 +45,6 @@ namespace BlackGui::Components
CLogComponent::CLogComponent(QWidget *parent) : QFrame(parent), ui(new Ui::CLogComponent), m_history(this)
{
ui->setupUi(this);
connect(ui->comp_StatusMessages, &CStatusMessagesDetail::modelDataChangedDigest, this, &CLogComponent::onStatusMessageDataChanged);
connect(&m_history, &CLogHistoryReplica::elementAdded, this, [this](const CStatusMessage &message) {
ui->comp_StatusMessages->appendStatusMessageToList(message);
@@ -66,13 +65,6 @@ namespace BlackGui::Components
void CLogComponent::displayLog(bool attention)
{
ui->tw_StatusPage->setCurrentIndex(0);
if (attention) { emit this->requestAttention(); }
}
void CLogComponent::displayConsole(bool attention)
{
ui->tw_StatusPage->setCurrentIndex(1);
if (attention) { emit this->requestAttention(); }
}
@@ -118,33 +110,11 @@ namespace BlackGui::Components
void CLogComponent::clear()
{
ui->tep_StatusPageConsole->clear();
ui->comp_StatusMessages->clear();
}
void CLogComponent::clearConsole()
{
ui->tep_StatusPageConsole->clear();
}
void CLogComponent::clearMessages()
{
ui->comp_StatusMessages->clear();
}
void CLogComponent::appendPlainTextToConsole(const QString &text)
{
ui->tep_StatusPageConsole->appendPlainText(text);
}
void CLogComponent::onStatusMessageDataChanged(int count, bool withFilter)
{
Q_UNUSED(count);
Q_UNUSED(withFilter);
const int i = ui->tw_StatusPage->indexOf(ui->pg_LogPage);
QString o = ui->tw_StatusPage->tabText(i);
const QString f = withFilter ? "F" : "";
o = CGuiUtility::replaceTabCountValue(o, ui->comp_StatusMessages->rowCount()) + f;
ui->tw_StatusPage->setTabText(i, o);
}
} // namespace

View File

@@ -55,9 +55,6 @@ namespace BlackGui::Components
//! Display log
void displayLog(bool attention = false);
//! Display console
void displayConsole(bool attention = false);
//! \copydoc BlackGui::Components::CStatusMessagesDetail::filterUseRadioButtonDescriptiveIcons
void filterUseRadioButtonDescriptiveIcons(bool oneLetterText);
@@ -85,15 +82,9 @@ namespace BlackGui::Components
//! Clear
void clear();
//! Clear
void clearConsole();
//! Clear
void clearMessages();
//! Append plain text to console
void appendPlainTextToConsole(const QString &text);
signals:
//! Make me visible
void requestAttention();
@@ -101,9 +92,6 @@ namespace BlackGui::Components
private:
QScopedPointer<Ui::CLogComponent> ui;
BlackMisc::CLogHistoryReplica m_history;
//! Status messages changed
void onStatusMessageDataChanged(int count, bool withFilter);
};
} // ns
#endif // guard

View File

@@ -22,10 +22,6 @@
<number>0</number>
</property>
<item>
<widget class="QTabWidget" name="tw_StatusPage">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="pg_LogPage">
<attribute name="title">
<string>Log</string>
@@ -51,49 +47,6 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="pg_LogConsole">
<attribute name="title">
<string>Console</string>
</attribute>
<layout class="QVBoxLayout" name="vl_StatusPageConsole">
<property name="spacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="BlackGui::Components::CConsoleTextEdit" name="tep_StatusPageConsole">
<property name="font">
<font>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
</property>
<property name="documentTitle">
<string>Console output</string>
</property>
<property name="lineWrapMode">
<enum>QPlainTextEdit::NoWrap</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>

View File

@@ -99,12 +99,6 @@ namespace BlackGui::Components
this->selectArea(InfoAreaLog);
}
void CMainInfoAreaComponent::displayConsole()
{
ui->comp_Log->displayConsole();
this->selectArea(InfoAreaLog);
}
void CMainInfoAreaComponent::selectArea(CMainInfoAreaComponent::InfoArea infoArea)
{
CInfoArea::selectArea(static_cast<int>(infoArea));

View File

@@ -110,9 +110,6 @@ namespace BlackGui::Components
//! Display the log
void displayLog();
//! Display console
void displayConsole();
//! Toggle floating of given area
void toggleFloating(InfoArea infoArea) { CInfoArea::toggleFloatingByIndex(static_cast<int>(infoArea)); }

View File

@@ -570,14 +570,6 @@ namespace BlackGui
return m->displayInOverlayWindow(html, timeOutMs);
}
bool CGuiApplication::displayTextInConsole(const QString &text)
{
IMainWindowAccess *m = mainWindowAccess();
BLACK_VERIFY_X(m, Q_FUNC_INFO, "No access interface");
if (!m) { return false; }
return m->displayTextInConsole(text);
}
void CGuiApplication::addMenuForSettingsAndCache(QMenu &menu)
{
QMenu *sm = menu.addMenu(CIcons::appSettings16(), "Settings");
@@ -597,7 +589,7 @@ namespace BlackGui
c = connect(a, &QAction::triggered, this, [=] {
if (!sGui || sGui->isShuttingDown()) { return; }
CSettingsCache::instance()->clearAllValues();
this->displayTextInConsole("Cleared all settings!");
CLogMessage(this).info(u"Cleared all settings!");
});
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
@@ -605,7 +597,7 @@ namespace BlackGui
c = connect(a, &QAction::triggered, this, [=]() {
if (!sGui || sGui->isShuttingDown()) { return; }
const QStringList files(CSettingsCache::instance()->enumerateStore());
this->displayTextInConsole(files.join("\n"));
CLogMessage(this).info(files.join("\n"));
});
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
@@ -625,7 +617,7 @@ namespace BlackGui
c = connect(a, &QAction::triggered, this, [=]() {
if (!sGui || sGui->isShuttingDown()) { return; }
const QStringList files = CApplication::clearCaches();
this->displayTextInConsole(u"Cleared caches! " % QString::number(files.size()) + " files");
CLogMessage(this).info(u"Cleared caches! " % QString::number(files.size()) + " files");
});
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
@@ -633,7 +625,7 @@ namespace BlackGui
c = connect(a, &QAction::triggered, this, [=]() {
if (!sGui || sGui->isShuttingDown()) { return; }
const QStringList files(CDataCache::instance()->enumerateStore());
this->displayTextInConsole(files.join("\n"));
CLogMessage(this).info(files.join("\n"));
});
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
@@ -659,7 +651,7 @@ namespace BlackGui
c = connect(a, &QAction::triggered, this, [=]() {
if (!sGui || sGui->isShuttingDown()) { return; }
const QString r = CNetworkUtils::createNetworkAccessManagerReport(this->getNetworkAccessManager());
this->displayTextInConsole(r);
CLogMessage(this).info(r);
});
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
Q_UNUSED(c)
@@ -725,7 +717,7 @@ namespace BlackGui
a, &QAction::triggered, this, [=]() {
if (!sGui || sGui->isShuttingDown()) { return; }
const CGlobalSetup s = this->getGlobalSetup();
this->displayTextInConsole(s.toJsonString());
CLogMessage(this).info(s.toJsonString());
},
Qt::QueuedConnection);
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
@@ -735,7 +727,7 @@ namespace BlackGui
a, &QAction::triggered, this, [=]() {
if (!sGui || sGui->isShuttingDown()) { return; }
const CUpdateInfo info = this->getUpdateInfo();
this->displayTextInConsole(info.toJsonString());
CLogMessage(this).info(info.toJsonString());
},
Qt::QueuedConnection);
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
@@ -746,8 +738,7 @@ namespace BlackGui
c = connect(
a, &QAction::triggered, this, [=]() {
if (!sGui || sGui->isShuttingDown()) { return; }
this->displayTextInConsole(this->getWebDataServices()->getReadersLog());
CLogMessage(this).info(u"Displayed services log.");
CLogMessage(this).info(this->getWebDataServices()->getReadersLog());
},
Qt::QueuedConnection);
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
@@ -758,7 +749,7 @@ namespace BlackGui
if (!sGui || sGui->isShuttingDown()) { return; }
if (!this->getWebDataServices()->getDbInfoDataReader()) { return; }
const CDbInfoList info = this->getWebDataServices()->getDbInfoDataReader()->getInfoObjects();
this->displayTextInConsole(u"DB info:\n" % info.toJsonString());
CLogMessage(this).info(u"DB info:\n" % info.toJsonString());
},
Qt::QueuedConnection);
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
@@ -769,7 +760,7 @@ namespace BlackGui
if (!sGui || sGui->isShuttingDown()) { return; }
if (!this->getWebDataServices()->getDbInfoDataReader()) { return; }
const CDbInfoList info = this->getWebDataServices()->getSharedInfoDataReader()->getInfoObjects();
this->displayTextInConsole(u"Shared info:\n" % info.toJsonString());
CLogMessage(this).info(u"Shared info:\n" % info.toJsonString());
},
Qt::QueuedConnection);
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
@@ -779,7 +770,7 @@ namespace BlackGui
c = connect(
a, &QAction::triggered, this, [=]() {
if (!sGui || sGui->isShuttingDown()) { return; }
this->displayTextInConsole(getAllUserMetatypesTypes());
CLogMessage(this).info(getAllUserMetatypesTypes());
},
Qt::QueuedConnection);
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
@@ -1030,10 +1021,7 @@ namespace BlackGui
void CGuiApplication::onCoreFacadeStarted()
{
if (this->supportsContexts())
{
connect(this->getIContextApplication(), &IContextApplication::requestDisplayOnConsole, this, &CGuiApplication::displayTextInConsole);
}
// Nothing to do here
}
void CGuiApplication::checkNewVersion(bool onlyIfNew)

View File

@@ -124,7 +124,6 @@ namespace BlackGui
//! @{
//! direct access to main application window
bool displayInStatusBar(const BlackMisc::CStatusMessage &message) override;
bool displayTextInConsole(const QString &text) override;
bool displayInOverlayWindow(const BlackMisc::CStatusMessage &message, int timeOutMs = -1) override;
bool displayInOverlayWindow(const BlackMisc::CStatusMessageList &messages, int timeOutMs = -1) override;
bool displayInOverlayWindow(const QString &html, int timeOutMs = -1) override;

View File

@@ -15,15 +15,6 @@ namespace BlackGui
// void
}
bool IMainWindowAccess::displayTextInConsole(const QString &message)
{
if (message.isEmpty()) { return false; }
if (!m_mwaLogComponent) { return false; }
m_mwaLogComponent->appendPlainTextToConsole(message);
m_mwaLogComponent->displayConsole(true);
return true;
}
bool IMainWindowAccess::displayInStatusBar(const CStatusMessage &message)
{
if (message.isEmpty()) { return false; }

View File

@@ -37,9 +37,6 @@ namespace BlackGui
//! Copy assignment operator
IMainWindowAccess &operator=(const IMainWindowAccess &) = delete;
//! Display in console
virtual bool displayTextInConsole(const QString &message);
//! Display in status bar
virtual bool displayInStatusBar(const BlackMisc::CStatusMessage &message);

View File

@@ -171,11 +171,6 @@ void CSwiftData::consolidationSettingChanged()
}
}
void CSwiftData::displayConsole()
{
ui->comp_MainInfoArea->displayConsole();
}
void CSwiftData::displayLog()
{
ui->comp_MainInfoArea->displayLog();

View File

@@ -81,7 +81,6 @@ private:
void performGracefulShutdown();
void consolidationSettingChanged();
void displayConsole();
void displayLog();
void checkMinimumVersion();

View File

@@ -409,15 +409,6 @@ void SwiftGuiStd::onChangedMainInfoAreaFloating(bool floating)
Q_UNUSED(floating)
}
void SwiftGuiStd::onRequestedConsoleMessage(const QString &logMsg, bool clear)
{
if (logMsg.isEmpty()) { return; }
CLogComponent *log = ui->comp_MainInfoArea->getLogComponent();
Q_ASSERT_X(log, Q_FUNC_INFO, "Missing log component");
if (clear) { log->clearConsole(); }
log->appendPlainTextToConsole(logMsg);
}
void SwiftGuiStd::onAudioClientFailure(const CStatusMessage &msg)
{
if (msg.isEmpty()) { return; }
@@ -545,11 +536,6 @@ void SwiftGuiStd::playNotifcationSound(CNotificationSounds::NotificationFlag not
sGui->getCContextAudioBase()->playNotification(notification, true);
}
void SwiftGuiStd::displayConsole()
{
ui->comp_MainInfoArea->displayConsole();
}
void SwiftGuiStd::displayLog()
{
ui->comp_MainInfoArea->displayLog();

View File

@@ -191,9 +191,6 @@ private:
//! Play notifcation sound
void playNotifcationSound(BlackMisc::Audio::CNotificationSounds::NotificationFlag notification) const;
//! Display console
void displayConsole();
//! Display log
void displayLog();
@@ -281,9 +278,6 @@ private:
//! Whole main info area floating
void onChangedMainInfoAreaFloating(bool floating);
//! UI Console message has been recevied
void onRequestedConsoleMessage(const QString &logMsg, bool clear);
//! Reported issue with the client
void onAudioClientFailure(const BlackMisc::CStatusMessage &msg);

View File

@@ -145,8 +145,6 @@ void SwiftGuiStd::init()
Q_ASSERT(s);
s = connect(sGui->getIContextNetwork(), &IContextNetwork::kicked, this, &SwiftGuiStd::onKickedFromNetwork, Qt::QueuedConnection);
Q_ASSERT(s);
s = connect(sGui->getIContextSimulator(), &IContextSimulator::requestUiConsoleMessage, this, &SwiftGuiStd::onRequestedConsoleMessage, Qt::QueuedConnection);
Q_ASSERT(s);
s = connect(sGui->getIContextSimulator(), &IContextSimulator::validatedModelSet, this, &SwiftGuiStd::onValidatedModelSet, Qt::QueuedConnection);
Q_ASSERT(s);
s = connect(&m_timerContextWatchdog, &QTimer::timeout, this, &SwiftGuiStd::handleTimerBasedUpdates);
@@ -177,8 +175,6 @@ void SwiftGuiStd::init()
this->initMenus();
// info
ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(sGui->swiftVersionString());
ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(CBuildConfig::compiledWithInfo());
connect(ui->comp_InfoBarStatus, &CInfoBarStatusComponent::transponderModeChanged, ui->dw_InfoBarStatus, &CDockWidgetInfoBar::reloadStyleSheet, Qt::QueuedConnection);
// Show kill button