1650 lines
40 KiB
C++
Executable File
1650 lines
40 KiB
C++
Executable File
|
|
|
|
|
|
#include "lts_session.h"
|
|
#include "lts_session_manager.h"
|
|
#include "lts_session_data_dds.h"
|
|
#include "lts_session_lock_handler.h"
|
|
|
|
#include <PluginInterfaces/gui_plugin_interface.h>
|
|
#include <PluginInterfaces/data_plugin_interface.h>
|
|
#include <LtsWidgets/lts_background_widget.h>
|
|
#include <LtsWidgets/lts_base_layout_widget.h>
|
|
#include <LtsWidgets/lts_global_wait_dialog.h>
|
|
#include <LtsWidgets/lts_tab_widget.h>
|
|
#include <LtsSession/lts_session_data.h>
|
|
#include <LtsMultiMonitor/lts_multi_monitor.h>
|
|
#include <LtsMultiMonitor/lts_screen_base.h>
|
|
#include <LtsPluginManager/lts_plugin_loader.h>
|
|
#include <LtsNotification/lts_notification.h>
|
|
#include <LtsNotification/lts_notification_ctl.h>
|
|
#include <LtsUtilsGuiDds/request_helper.h>
|
|
#include <LtsUtilsGuiDds/dds_vector_to_pixmap.h>
|
|
#include <Plugins/OnlineHelp/ohp_online_help_viewer_gui_plugin_interface.h>
|
|
|
|
#include <QHostInfo>
|
|
#include <QApplication>
|
|
#include <QScreen>
|
|
#include <QNetworkInterface>
|
|
#include <QDesktopWidget>
|
|
#include <QWidget>
|
|
#include <QTimer>
|
|
#include <QUuid>
|
|
#include <QLabel>
|
|
#include <QSvgRenderer>
|
|
#include <QPainter>
|
|
|
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
|
|
|
|
|
using namespace LtsWidgets;
|
|
|
|
namespace LtsSession
|
|
{
|
|
bool LtsSession::s_valgrind = false;
|
|
int LtsSession::s_nextSessionId = 0;
|
|
|
|
|
|
LtsSession::LtsSession(LtsSessionManager *sessionManager)
|
|
: m_sessionManager(sessionManager)
|
|
, m_mainBackground(nullptr)
|
|
, m_hasBaseLayout(false)
|
|
, m_baseLayout(nullptr)
|
|
, m_markedForDeletion(false)
|
|
, m_payloads(false)
|
|
, m_initDone(false)
|
|
, m_menuVisible(true)
|
|
, m_firstActionsFetch(true)
|
|
, m_exerciseData(new LtsWidgets::ExerciseData)
|
|
, m_currentInitIfc(nullptr)
|
|
, m_slotPluginInitDoneMutex(false)
|
|
, m_pluginInitDone(false)
|
|
, m_hidden(false)
|
|
, m_loadedFromSavegame(false)
|
|
, m_foreverInvisible(false)
|
|
, m_id(s_nextSessionId++)
|
|
{
|
|
LtsWidgets::LtsGlobalWaitDialog::getInstance()->wait();
|
|
|
|
connect(this, &LtsSession::signalDoneInitializingSession,
|
|
this, &LtsSession::slotStopWaitDialog);
|
|
connect(this, &LtsSession::signalInitializationAborted,
|
|
this, &LtsSession::slotStopWaitDialog);
|
|
|
|
|
|
|
|
connect(this, &LtsSession::_signalDoneInitializingSession,
|
|
this, [this]()
|
|
{
|
|
|
|
|
|
disconnect(this, &LtsSession::_signalDoneInitializingSession,
|
|
this, nullptr);
|
|
|
|
m_initDone = true;
|
|
emit signalDoneInitializingSession();
|
|
});
|
|
|
|
|
|
QTimer *t = new QTimer(this);
|
|
t->setInterval(1000);
|
|
connect(t, &QTimer::timeout,
|
|
this, &LtsSession::signalStillAlive);
|
|
t->start();
|
|
m_scriptEditorTimer = new QTimer(this);
|
|
|
|
if ( strcmp(PROJECTBUILD, "qatarmout") == 0
|
|
|| strcmp(PROJECTBUILD, "qatar") == 0)
|
|
{
|
|
DEBUG_LOG(m_logger) << "qatarmout Timer = 4000";
|
|
m_scriptEditorTimer->setInterval(4000);
|
|
}
|
|
else
|
|
{
|
|
DEBUG_LOG(m_logger) << "qatarmout Timer = 0";
|
|
m_scriptEditorTimer->setInterval(0);
|
|
}
|
|
|
|
m_scriptEditorTimer->setSingleShot(true);
|
|
connect(m_scriptEditorTimer, &QTimer::timeout, this, &LtsSession::delayScriptEditorStart);
|
|
}
|
|
|
|
|
|
LtsSession::~LtsSession()
|
|
{
|
|
|
|
|
|
|
|
delete m_baseLayout;
|
|
|
|
|
|
|
|
|
|
|
|
clearGuiPluginInterfaces();
|
|
clearDataPluginInterfaces();
|
|
|
|
delete m_exerciseData;
|
|
}
|
|
|
|
|
|
QString LtsSession::toString() const
|
|
{
|
|
std::ostringstream stream;
|
|
stream << "LtsSession:"
|
|
<< " this=" << this
|
|
<< ", domainId=" << this->domainId()
|
|
<< ", partitionId=" << this->partitionId()
|
|
<< ", partitionType=" << this->partitionType()
|
|
<< ", exerciseId='" << this->exerciseId() << "'"
|
|
<< ", workspaceId='" << this->workspaceId() << "'"
|
|
<< ", appToString='" << this->appToString(this->app()) << "'"
|
|
<< ", LtsSessionDataDds=" << LtsSessionDataDds::toString();
|
|
return QString::fromStdString(stream.str());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
QWidget *LtsSession::baseLayoutWidget()
|
|
{
|
|
|
|
|
|
return static_cast<QWidget *>(m_baseLayout);
|
|
}
|
|
|
|
|
|
void LtsSession::aboutToCloseTab(LayoutArea area)
|
|
{
|
|
m_baseLayout->getTabFromLayoutArea(area)->aboutToClose();
|
|
}
|
|
|
|
|
|
void LtsSession::setDependency(LtsSession *session)
|
|
{
|
|
if (session == this)
|
|
{
|
|
Q_ASSERT(session != this);
|
|
ERROR_LOG(m_logger) << "Tried to set session dependency on self";
|
|
return;
|
|
}
|
|
|
|
m_dependency = session;
|
|
}
|
|
|
|
|
|
void LtsSession::aboutToClose()
|
|
{
|
|
emit sessionAboutToBeDestroyed(this);
|
|
|
|
if (m_baseLayout == nullptr)
|
|
return;
|
|
|
|
aboutToCloseTab(LayoutArea::eDialogTab);
|
|
aboutToCloseTab(LayoutArea::eInfoTab);
|
|
aboutToCloseTab(LayoutArea::eSpecialTab);
|
|
aboutToCloseTab(LayoutArea::eMainTab);
|
|
}
|
|
|
|
|
|
void LtsSession::slotStopWaitDialog()
|
|
{
|
|
disconnect(this, &LtsSession::signalDoneInitializingSession,
|
|
this, &LtsSession::slotStopWaitDialog);
|
|
disconnect(this, &LtsSession::signalInitializationAborted,
|
|
this, &LtsSession::slotStopWaitDialog);
|
|
|
|
LtsWidgets::LtsGlobalWaitDialog::getInstance()->done();
|
|
}
|
|
|
|
|
|
QString LtsSession::appToString(LtsAppDescriptor::App app)
|
|
{
|
|
using namespace LtsAppDescriptor;
|
|
switch (app)
|
|
{
|
|
case App::Situation:
|
|
return tr("Situation");
|
|
case App::ResourceManager:
|
|
return tr("Resource Manager");
|
|
case App::PlanEditor:
|
|
return tr("Plan Editor");
|
|
case App::BuildingViewer:
|
|
return tr("Building Viewer");
|
|
case App::OC:
|
|
return tr("O/C");
|
|
case App::OrgChart:
|
|
return tr("Organisation Chart");
|
|
case App::Scripts:
|
|
return tr("Scripts");
|
|
case App::Snapshot:
|
|
return tr("Snapshot");
|
|
case App::SystemMonitor:
|
|
return tr("System Monitor");
|
|
case App::Timeline:
|
|
return tr("Timeline");
|
|
case App::SymbolEditor:
|
|
return tr("Symbol Editor");
|
|
case App::ScriptEditorEssentialsView:
|
|
return tr("Scripts Essentials View");
|
|
case App::BaseDownloader:
|
|
return tr("Base Downloader");
|
|
case App::OnlineHelp:
|
|
return tr("Online Help");
|
|
case App::ThpSituationReplay:
|
|
return tr("THP Situation Replay");
|
|
case App::SituationTablet:
|
|
return tr("Situation (Tablet)");
|
|
case App::SilhouetteEditor:
|
|
return tr("Silhouette Editor");
|
|
case App::Shootback:
|
|
return tr("Shootback");
|
|
case App::Login:
|
|
return tr("Login");
|
|
break;
|
|
case App::SAAs:
|
|
return tr("SAAs");
|
|
break;
|
|
}
|
|
|
|
return tr("Unknown");
|
|
}
|
|
|
|
QString LtsSession::appIconFilename(LtsAppDescriptor::App app)
|
|
{
|
|
using namespace LtsAppDescriptor;
|
|
switch (app)
|
|
{
|
|
case App::Situation:
|
|
return QStringLiteral("icon:situation.svg");
|
|
case App::ResourceManager:
|
|
return QStringLiteral("icon:player_equipment.svg");
|
|
case App::PlanEditor:
|
|
return QStringLiteral("icon:plan_editor.svg");
|
|
case App::BuildingViewer:
|
|
return QStringLiteral("icon:3d_viewer.svg");
|
|
case App::OC:
|
|
return QStringLiteral("icon:display_oc_evaluations.svg");
|
|
case App::OrgChart:
|
|
return QStringLiteral("icon:org_chart.svg");
|
|
case App::Scripts:
|
|
return QStringLiteral("icon:insert_script.svg");
|
|
case App::Snapshot:
|
|
return QStringLiteral("icon:snapshots.svg");
|
|
case App::SystemMonitor:
|
|
return QStringLiteral("icon:system_status.svg");
|
|
case App::Timeline:
|
|
return QStringLiteral("icon:timeline.svg");
|
|
case App::SymbolEditor:
|
|
return QStringLiteral("icon:define_tactical_symbols.svg");
|
|
case App::ScriptEditorEssentialsView:
|
|
return QStringLiteral("icon:evaluation_elements.svg");
|
|
case App::BaseDownloader:
|
|
return QStringLiteral("icon:download.svg");
|
|
case App::OnlineHelp:
|
|
return QStringLiteral("icon:help.svg");
|
|
case App::ThpSituationReplay:
|
|
return QStringLiteral("icon:restart.svg");
|
|
case App::SituationTablet:
|
|
return QStringLiteral("icon:situation.svg");
|
|
case App::SilhouetteEditor:
|
|
return QStringLiteral("icon:situation.svg");
|
|
case App::Shootback:
|
|
return QStringLiteral("icon:target.svg");
|
|
case App::SAAs:
|
|
return QStringLiteral("icon:saa_remote_desktop.svg");
|
|
case App::Login:
|
|
break;
|
|
}
|
|
|
|
return {};
|
|
}
|
|
|
|
QIcon LtsSession::appToIcon(LtsAppDescriptor::App app)
|
|
{
|
|
return LtsUtils::iconFromSvg(appIconFilename(app));
|
|
}
|
|
|
|
|
|
bool LtsSession::removeMenuAction(LtsWidgets::LtsDragIcon *icon)
|
|
{
|
|
if (!m_baseLayout)
|
|
return false;
|
|
return m_baseLayout->removeMenuAction(icon);
|
|
}
|
|
|
|
|
|
void LtsSession::setMenuVisible(bool visible)
|
|
{
|
|
m_menuVisible = visible;
|
|
|
|
if (m_baseLayout == nullptr)
|
|
return;
|
|
|
|
m_baseLayout->getMenu()->setVisible(visible);
|
|
}
|
|
|
|
LtsDragIcon *LtsSession::addAction(const LtsWidgets::PluginData &plData, bool isFirstRun)
|
|
{
|
|
if (!m_baseLayout)
|
|
{
|
|
ERROR_LOG(m_logger) << "No BaseLayout available atm, cannot add action!";
|
|
return nullptr;
|
|
}
|
|
|
|
return m_baseLayout->addMenuAction(plData, isFirstRun);
|
|
}
|
|
|
|
|
|
LtsNotification::LtsNotification *LtsSession::createNotification(const QString &identifier)
|
|
{
|
|
LtsNotification::LtsNotificationController *c = new LtsNotification::LtsNotificationController(identifier);
|
|
LtsNotification::LtsNotification *n = new LtsNotification::LtsNotification(c);
|
|
|
|
if (m_baseLayout)
|
|
m_baseLayout->addNotification(c->createWidget());
|
|
|
|
m_notiCtlList.append(c);
|
|
|
|
connect(c, &LtsNotification::LtsNotificationController::destroyed,
|
|
this, [this, c]() { m_notiCtlList.removeAll(c); });
|
|
|
|
return n;
|
|
}
|
|
|
|
|
|
bool LtsSession::init(const DdsConnectionParams &connParams,
|
|
const QVector<LtsPluginManager::AppPluginInstance> &dataPluginList,
|
|
const QVector<LtsPluginManager::AppPluginInstance> &guiPluginList,
|
|
bool hidden)
|
|
{
|
|
m_foreverInvisible = hidden;
|
|
if (!LtsSessionDataDds::init(connParams))
|
|
return false;
|
|
initializePlugins(dataPluginList, guiPluginList);
|
|
return true;
|
|
}
|
|
|
|
|
|
bool LtsSession::init(const dds::domain::DomainParticipant &dp,
|
|
const DdsConnectionParams &connParams,
|
|
const QVector<LtsPluginManager::AppPluginInstance> &dataPluginList,
|
|
const QVector<LtsPluginManager::AppPluginInstance> &guiPluginList)
|
|
{
|
|
if (!LtsSessionDataDds::init(dp, connParams))
|
|
return false;
|
|
initializePlugins(dataPluginList, guiPluginList);
|
|
return true;
|
|
}
|
|
|
|
|
|
void LtsSession::initializePlugins(const QVector<LtsPluginManager::AppPluginInstance> &dataPluginList, const QVector<LtsPluginManager::AppPluginInstance> &guiPluginList)
|
|
{
|
|
initializeDataPlugins(dataPluginList);
|
|
initializeGuiPlugins(guiPluginList);
|
|
}
|
|
|
|
|
|
void LtsSession::initializeDataPlugins(const QVector<LtsPluginManager::AppPluginInstance> &dataPluginList)
|
|
{
|
|
QMap<QString, std::shared_ptr<DataPluginBase::Interface>> newDataPluginInterfaces;
|
|
|
|
for (const LtsPluginManager::AppPluginInstance &api : dataPluginList)
|
|
{
|
|
DataPluginBase::Plugin *plugin = qobject_cast<DataPluginBase::Plugin *>(api.pluginInstance.plugin);
|
|
|
|
if (!plugin)
|
|
{
|
|
WARNING_LOG(m_logger) << "Session: invalid data plugin (" << api.pluginInstance.plugin->metaObject()->className() << ")" << api.pluginInstance.fileName;
|
|
continue;
|
|
}
|
|
|
|
|
|
if (app() == LtsAppDescriptor::App::Login
|
|
&& (!plugin->pluginName().contains(QStringLiteral("AssetManagement"))
|
|
&& !plugin->pluginName().contains(QStringLiteral("OperatorManagement"))
|
|
&& !plugin->pluginName().contains(QStringLiteral("ExerciseManagement")))
|
|
)
|
|
continue;
|
|
|
|
|
|
if (!plugin->availableInPartition(partitionType()))
|
|
{
|
|
DEBUG_LOG(m_logger) << "Data plugin " << api.pluginInstance.pluginName << " is not available in this partition type " << partitionType();
|
|
continue;
|
|
}
|
|
|
|
|
|
if ((!plugin->pluginName().contains(QStringLiteral("AssetManagement"))
|
|
&& !plugin->pluginName().contains(QStringLiteral("OperatorManagement"))
|
|
&& !plugin->pluginName().contains(QStringLiteral("ExerciseManagement"))
|
|
) && app() == LtsAppDescriptor::App::Login
|
|
)
|
|
continue;
|
|
std::shared_ptr<DataPluginBase::Interface> ifc = plugin->createDataInterface(this);
|
|
if (!ifc)
|
|
{
|
|
WARNING_LOG(m_logger) << "Create data interface failed for '" << api.pluginInstance.pluginName << "' !";
|
|
continue;
|
|
}
|
|
|
|
m_dataPluginInterfaces[plugin->pluginName()] = ifc;
|
|
newDataPluginInterfaces[plugin->pluginName()] = ifc;
|
|
DEBUG_LOG(m_logger) << "Adding data plugin " << plugin->pluginName() << " for " << partitionType() << " - " << this;
|
|
}
|
|
|
|
addAvailablaeDataPluginInterfaces(newDataPluginInterfaces);
|
|
}
|
|
|
|
|
|
void LtsSession::initializeGuiPlugins(const QVector<LtsPluginManager::AppPluginInstance> &guiPluginList)
|
|
{
|
|
m_failedFetches.clear();
|
|
|
|
|
|
|
|
|
|
for (auto i = guiPluginList.constBegin(); i != guiPluginList.constEnd(); ++i)
|
|
{
|
|
const LtsPluginManager::AppPluginInstance &api = *i;
|
|
|
|
GuiPluginBase::Plugin *plugin = qobject_cast<GuiPluginBase::Plugin *>(api.pluginInstance.plugin);
|
|
|
|
if (!plugin)
|
|
{
|
|
WARNING_LOG(m_logger) << "Session: invalid gui plugin (" << api.pluginInstance.plugin->metaObject()->className() << ")" << api.pluginInstance.fileName;
|
|
continue;
|
|
}
|
|
|
|
|
|
|
|
if (!plugin->availableInPartition(partitionType()))
|
|
{
|
|
DEBUG_LOG(m_logger) << "Gui plugin " << api.pluginInstance.pluginName << " is not available in this partition type " << partitionType();
|
|
continue;
|
|
}
|
|
|
|
|
|
std::shared_ptr<GuiPluginBase::Interface> ifc = plugin->createGuiInterface(this);
|
|
|
|
if (!ifc)
|
|
{
|
|
WARNING_LOG(m_logger) << "Create gui interface failed for '" << api.pluginInstance.pluginName << "' (" << api.pluginInstance.plugin->metaObject()->className() << ") !";
|
|
continue;
|
|
}
|
|
|
|
|
|
QFlags<LtsAppDescriptor::PluginInfo::Flag> flags = api.m_flags;
|
|
|
|
if (api.pluginInstance.pluginName == QStringLiteral("dev"))
|
|
flags |= LtsAppDescriptor::PluginInfo::Flag::ACTIONS;
|
|
|
|
ifc->setFlags(flags);
|
|
ifc->setOptions(api.m_options);
|
|
ifc->setAppId(api.m_appId);
|
|
m_guiPluginInterfaces[plugin->pluginName()] = ifc;
|
|
DEBUG_LOG(m_logger) << "Adding gui plugin " << plugin->pluginName() << " for " << partitionType() << " - " << this;
|
|
}
|
|
|
|
|
|
|
|
|
|
QMutableMapIterator<QString, std::shared_ptr<GuiPluginBase::Interface> > it(m_guiPluginInterfaces);
|
|
while (it.hasNext())
|
|
{
|
|
const auto val = it.next();
|
|
const QString &guiPluginKey = val.key();
|
|
std::shared_ptr<GuiPluginBase::Interface> guiPlugin = val.value();
|
|
|
|
if (!guiPlugin->fetchInterfaces())
|
|
{
|
|
DEBUG_LOG(m_logger) << "Fetching interfaces failed for Gui Plugin '" << guiPluginKey << "' - removing and refetching !";
|
|
m_failedFetches.append(guiPluginKey);
|
|
it.remove();
|
|
it.toFront();
|
|
|
|
|
|
for (auto i = m_payloadPriorityMap.begin(); i != m_payloadPriorityMap.end(); ++i)
|
|
{
|
|
std::shared_ptr<GuiPluginBase::Interface> payloadIfc = *i;
|
|
|
|
if (payloadIfc == guiPlugin)
|
|
break;
|
|
}
|
|
|
|
m_payloadList.removeAll(guiPlugin);
|
|
}
|
|
else
|
|
{
|
|
|
|
|
|
int executionPriority = guiPlugin->executionPriority();
|
|
|
|
if (executionPriority > -1)
|
|
{
|
|
if (m_payloads && guiPlugin->getFlags().testFlag(LtsAppDescriptor::PluginInfo::Flag::PAYLOAD))
|
|
{
|
|
if (executionPriority == 9999)
|
|
{
|
|
if (!m_payloadList.contains(guiPlugin))
|
|
m_payloadList.append(guiPlugin);
|
|
}
|
|
else
|
|
m_payloadPriorityMap.insert(executionPriority, guiPlugin);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
QTimer::singleShot(100, this, &LtsSession::slotStartPluginInit);
|
|
|
|
}
|
|
|
|
|
|
LtsTabWidget *LtsSession::locateWidget(QWidget *widgetToLocate, LayoutArea area)
|
|
{
|
|
if (!m_baseLayout)
|
|
return nullptr;
|
|
|
|
LtsTabWidget *tabWidget = m_baseLayout->getTabFromLayoutArea(area);
|
|
|
|
if (tabWidget->indexOf(widgetToLocate) >= 0)
|
|
return tabWidget;
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
|
|
void LtsSession::enableBaseLayoutMenu(bool on)
|
|
{
|
|
if (m_baseLayout)
|
|
{
|
|
QWidget *ltsMenu = m_baseLayout->getMenu();
|
|
|
|
if (ltsMenu)
|
|
ltsMenu->setEnabled(on);
|
|
}
|
|
}
|
|
|
|
|
|
void LtsSession::enableBaseLayoutArea(LtsWidgets::LayoutArea area, bool on)
|
|
{
|
|
if (m_baseLayout)
|
|
{
|
|
QWidget *ltsWidget = m_baseLayout->getTabFromLayoutArea(area);
|
|
if (ltsWidget)
|
|
ltsWidget->setEnabled(on);
|
|
}
|
|
}
|
|
|
|
|
|
int LtsSession::workstationIp()
|
|
{
|
|
static int wsId = -1;
|
|
if (wsId == -1)
|
|
{
|
|
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
|
|
const QString hostname = workstationName();
|
|
const auto addreses = QHostInfo::fromName(hostname).addresses();
|
|
for (const QHostAddress &ha : addreses)
|
|
{
|
|
if (ha.isLoopback())
|
|
continue;
|
|
if (ha.protocol() != QAbstractSocket::NetworkLayerProtocol::IPv4Protocol)
|
|
continue;
|
|
wsId = static_cast<int>(ha.toIPv4Address());
|
|
break;
|
|
}
|
|
#else
|
|
const QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces();
|
|
for (const QNetworkInterface &ninterface : interfaces)
|
|
{
|
|
if (ninterface.type() == QNetworkInterface::InterfaceType::Wifi)
|
|
continue;
|
|
const auto addreseEntry = ninterface.addressEntries();
|
|
for (const QNetworkAddressEntry &ent : addreseEntry)
|
|
{
|
|
const QHostAddress ha = ent.ip();
|
|
if (ha.isLoopback())
|
|
continue;
|
|
if (ha.protocol() != QAbstractSocket::NetworkLayerProtocol::IPv4Protocol)
|
|
continue;
|
|
wsId = static_cast<int>(ha.toIPv4Address());
|
|
break;
|
|
}
|
|
if (wsId != -1)
|
|
break;
|
|
}
|
|
#endif
|
|
}
|
|
return wsId;
|
|
}
|
|
|
|
|
|
|
|
QString LtsSession::workstationName()
|
|
{
|
|
return QHostInfo::localHostName().toUpper();
|
|
}
|
|
|
|
|
|
const QString LtsSession::workspaceId() const
|
|
{
|
|
if (isReplayPartition())
|
|
return QStringLiteral("replay_%1").arg(QString::number(partitionId()));
|
|
return m_workspaceId;
|
|
}
|
|
|
|
|
|
void LtsSession::setWorkspaceId(const QString &newWorkspaceId )
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " change workspaceId: cur = '" << m_workspaceId << "' for app '" << appToString(app()) << "'";
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " change workspaceId: new = '" << newWorkspaceId << "' for app '" << appToString(app()) << "'";
|
|
m_workspaceId = newWorkspaceId;
|
|
|
|
if (m_baseLayout)
|
|
m_baseLayout->setWorkspaceId(workspaceId() );
|
|
|
|
emit workspaceIdChanged(newWorkspaceId);
|
|
}
|
|
|
|
|
|
ExcState LtsSession::exerciseState() const
|
|
{
|
|
return m_exerciseData ? m_exerciseData->exState : ExerciseState::eUnknown;
|
|
}
|
|
|
|
|
|
void LtsSession::connectOnlineHelpButton(LtsWidgets::LtsDialog *widget)
|
|
{
|
|
|
|
connect(widget, &LtsDialog::signalShowOnlineHelp,
|
|
this, &LtsSession::slotShowOnlineHelp,
|
|
Qt::UniqueConnection);
|
|
}
|
|
|
|
|
|
void LtsSession::slotStapleTopicLockHandler(LtsWidgets::LtsDialog *widget)
|
|
{
|
|
if (widget->property("topicLockStapled").isValid())
|
|
{
|
|
Q_ASSERT(false);
|
|
return;
|
|
}
|
|
widget->setProperty("topicLockStapled", true);
|
|
|
|
connectOnlineHelpButton(widget);
|
|
if (m_coreFtc == nullptr)
|
|
{
|
|
DEBUG_LOG(m_logger) << "no core ftc, no TopicLockHandler for " << toString();
|
|
return;
|
|
}
|
|
|
|
auto *topicLockHandler = new TopicLockHandler();
|
|
|
|
|
|
|
|
if (!topicLockHandler->init(m_coreFtc, m_exerciseId))
|
|
{
|
|
WARNING_LOG(m_logger) << "LtsSession::addWidget: init of TopicLockHandler failed!";
|
|
delete topicLockHandler;
|
|
return;
|
|
}
|
|
|
|
connect(topicLockHandler, &TopicLockHandler::signalLockDialog,
|
|
widget, &LtsDialog::slotLock, Qt::QueuedConnection);
|
|
connect(topicLockHandler, &TopicLockHandler::signalUnlockDialog,
|
|
widget, &LtsDialog::slotUnlock, Qt::QueuedConnection);
|
|
connect(widget, &LtsDialog::signalLockTopic,
|
|
topicLockHandler, &TopicLockHandler::slotTryLock, Qt::DirectConnection);
|
|
|
|
|
|
|
|
connect(widget, &LtsDialog::destroyed,
|
|
topicLockHandler, &TopicLockHandler::slotFinalize, Qt::QueuedConnection);
|
|
|
|
|
|
|
|
|
|
connectOnlineHelpButton(widget);
|
|
}
|
|
|
|
|
|
bool LtsSession::focusTab(const QString &menuGroup, const QString &identifier, LtsWidgets::LayoutArea area)
|
|
{
|
|
if (!m_baseLayout)
|
|
{
|
|
ERROR_LOG(m_logger) << "no base layout to focus a tab on! menuGroup: " << menuGroup << "ident: " << identifier;
|
|
return false;
|
|
}
|
|
|
|
return m_baseLayout->focusTab(menuGroup, identifier, area);
|
|
}
|
|
|
|
|
|
LtsWidgets::LtsDialog *LtsSession::getWidget(const QString &menuGroup, const QString &identifier, LtsWidgets::LayoutArea area)
|
|
{
|
|
if (!m_baseLayout)
|
|
{
|
|
ERROR_LOG(m_logger) << "no base layout to get a widget from! menuGroup: " << menuGroup << "ident: " << identifier;
|
|
return nullptr;
|
|
}
|
|
|
|
return m_baseLayout->getWidget(menuGroup, identifier, area);
|
|
}
|
|
|
|
|
|
bool LtsSession::widgetExists(const QString &menuGroup, const QString &identifier, LayoutArea area) const
|
|
{
|
|
if (!m_baseLayout)
|
|
return false;
|
|
LtsTabWidget *tab = m_baseLayout->getTabFromLayoutArea(area);
|
|
if (!tab)
|
|
return false;
|
|
QWidget *existingWidget = tab->getWidget(menuGroup, identifier);
|
|
return existingWidget != nullptr;
|
|
}
|
|
|
|
|
|
bool LtsSession::addWidget(LtsDialog *widget, const QString &menuGroup, const QString &identifier, LayoutArea area, bool setClosable)
|
|
{
|
|
|
|
|
|
if (!m_baseLayout)
|
|
{
|
|
ERROR_LOG(m_logger) << "no base layout to put a widget on! menuGroup: " << menuGroup << "ident: " << identifier;
|
|
return false;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return m_baseLayout->addWidget(widget, menuGroup, identifier, area, setClosable);
|
|
}
|
|
|
|
|
|
void LtsSession::setExerciseData(const LtsWidgets::ExerciseData &exerciseData)
|
|
{
|
|
|
|
if ((*m_exerciseData) == exerciseData)
|
|
return;
|
|
|
|
*m_exerciseData = exerciseData;
|
|
|
|
if (!m_baseLayout)
|
|
return;
|
|
m_baseLayout->setExerciseData(exerciseData);
|
|
emit signalExerciseDataChanged();
|
|
}
|
|
|
|
|
|
const LtsWidgets::ExerciseData *LtsSession::exerciseData() const
|
|
{
|
|
return m_exerciseData;
|
|
}
|
|
|
|
|
|
void LtsSession::setProfilePicture(const QPixmap &pixmap)
|
|
{
|
|
|
|
if (!m_baseLayout)
|
|
return;
|
|
m_baseLayout->setProfilePicture(pixmap);
|
|
}
|
|
|
|
|
|
void LtsSession::makeVisible()
|
|
{
|
|
Q_ASSERT(m_baseLayout == nullptr);
|
|
if (m_baseLayout)
|
|
{
|
|
qCritical() << "base layout already visible";
|
|
return;
|
|
}
|
|
|
|
createBaseLayout();
|
|
}
|
|
|
|
|
|
void LtsSession::refetchActions()
|
|
{
|
|
|
|
for (auto i = m_guiPluginInterfaces.cbegin(); i != m_guiPluginInterfaces.cend(); ++i)
|
|
{
|
|
std::shared_ptr<GuiPluginBase::Interface> ifc = *i;
|
|
|
|
if (!ifc->availableInPartition(partitionType()))
|
|
{
|
|
DEBUG_LOG(m_logger) << i.key() << " is not available in this partition type " << partitionType();
|
|
continue;
|
|
}
|
|
|
|
if (m_firstActionsFetch && ifc->getFlags().testFlag(LtsAppDescriptor::PluginInfo::Flag::MAIN) && !ifc->getFlags().testFlag(LtsAppDescriptor::PluginInfo::Flag::ACTIONS))
|
|
{
|
|
ERROR_LOG(m_logger) << "Plugin '" << i.key() << "' has flag 'MAIN' but is missing the 'ACTIONS' flag - ingoring actions!";
|
|
continue;
|
|
}
|
|
|
|
if (ifc->getFlags().testFlag(LtsAppDescriptor::PluginInfo::Flag::ACTIONS))
|
|
{
|
|
|
|
const QVector<LtsWidgets::PluginData> plData = ifc->getActions();
|
|
|
|
if (plData.isEmpty())
|
|
DEBUG_LOG(m_logger) << i.key() << " (" << ifc->menuGroup() << ") does not provide actions";
|
|
|
|
|
|
|
|
for (const LtsWidgets::PluginData &pd : plData)
|
|
{
|
|
if (!pd.menuGroup.isEmpty() && !pd.menuText.isEmpty() && pd.identifier.isEmpty())
|
|
ERROR_LOG(m_logger) << "Identifier for Action " << pd.menuGroup << " - " << pd.menuText << " missing - not added!";
|
|
else
|
|
{
|
|
if (!LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(pd.operatorRight))
|
|
m_missingRightActions += pd;
|
|
|
|
m_baseLayout->addMenuAction(pd, m_firstActionsFetch);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
#ifdef LTS_DEBUG
|
|
if (m_firstActionsFetch)
|
|
{
|
|
const QString &executeAction(qEnvironmentVariable("EXCON_EXECUTE_ACTION", {}));
|
|
if (!executeAction.isEmpty())
|
|
{
|
|
WARNING_LOG(m_logger) << "EXCON_EXECUTE_ACTION was set to: " << executeAction;
|
|
m_baseLayout->executeAction(executeAction);
|
|
}
|
|
}
|
|
#endif
|
|
|
|
m_firstActionsFetch = false;
|
|
}
|
|
|
|
void LtsSession::slotSwap()
|
|
{
|
|
LtsMultiMonitor::LtsMultiMonitor::getInstance()->selectAndSwap(m_baseLayout);
|
|
}
|
|
|
|
|
|
int LtsSession::screenId() const
|
|
{
|
|
if (m_baseLayout == nullptr)
|
|
return -1;
|
|
|
|
LtsMultiMonitor::LtsScreenBase *screen = LtsMultiMonitor::LtsMultiMonitor::getInstance()->widgetsScreen(m_baseLayout);
|
|
|
|
if (screen == nullptr)
|
|
return -2;
|
|
|
|
return screen->screenId();
|
|
}
|
|
|
|
|
|
int LtsSession::screenContainerId() const
|
|
{
|
|
if (m_baseLayout == nullptr)
|
|
return -1;
|
|
|
|
LtsMultiMonitor::LtsScreenBase *screen = LtsMultiMonitor::LtsMultiMonitor::getInstance()->widgetsScreen(m_baseLayout);
|
|
|
|
if (screen == nullptr)
|
|
return -2;
|
|
|
|
try
|
|
{
|
|
return screen->containerIdOfWidget(m_baseLayout);
|
|
}
|
|
catch(...){}
|
|
|
|
return -3;
|
|
}
|
|
|
|
|
|
int LtsSession::screenTypeId() const
|
|
{
|
|
if (m_baseLayout == nullptr)
|
|
return -1;
|
|
|
|
LtsMultiMonitor::LtsScreenBase *screen = LtsMultiMonitor::LtsMultiMonitor::getInstance()->widgetsScreen(m_baseLayout);
|
|
|
|
if (screen == nullptr)
|
|
return -2;
|
|
|
|
return screen->screenType();
|
|
}
|
|
|
|
|
|
LtsAppDescriptor::App LtsSession::app() const
|
|
{
|
|
return m_sessionManager ? m_sessionManager->appId() : LtsAppDescriptor::App::Login;
|
|
}
|
|
|
|
|
|
bool LtsSession::event(QEvent *e)
|
|
{
|
|
if (e->type() == QEvent::LanguageChange)
|
|
m_baseLayout->setAppName(appToString(app()));
|
|
|
|
return LtsSessionDataDds::event(e);
|
|
}
|
|
|
|
|
|
void LtsSession::addDeveloperActions()
|
|
{
|
|
|
|
{
|
|
LtsWidgets::PluginData p;
|
|
p.menuGroup = QStringLiteral("[Dev]");
|
|
p.menuText = QStringLiteral("Open Admin Session");
|
|
p.identifier = QStringLiteral("OpenAdminSession");
|
|
|
|
p.directFunc = [&](const LtsWidgets::PluginData &)
|
|
{
|
|
LtsSession *adminSession = m_sessionManager->getSession(IDL::PartitionType::Global, 0);
|
|
if (!adminSession)
|
|
{
|
|
|
|
DdsConnectionParams connParams;
|
|
connParams.domainId = domainId();
|
|
connParams.partitionId = 0;
|
|
connParams.exerciseId = 0;
|
|
connParams.partitionType = IDL::PartitionType::Global;
|
|
connParams.tcpConnectionUrl = tcpConnectionUrl();
|
|
connParams.qos_file = m_qosFileList;
|
|
adminSession = m_sessionManager->createSession(connParams,
|
|
true,
|
|
false);
|
|
return;
|
|
}
|
|
else
|
|
adminSession->makeVisible();
|
|
};
|
|
|
|
m_baseLayout->addMenuAction(p);
|
|
}
|
|
|
|
{
|
|
LtsWidgets::PluginData p;
|
|
p.menuGroup = QStringLiteral("[Dev]");
|
|
p.menuText = QStringLiteral("Slow down RequestHelper");
|
|
p.identifier = QStringLiteral("SlowDownRequestHelper");
|
|
|
|
p.directFunc = [&](const LtsWidgets::PluginData &)
|
|
{
|
|
LtsUtils::RequestHelper::s_debug = true;
|
|
};
|
|
|
|
m_baseLayout->addMenuAction(p);
|
|
}
|
|
|
|
{
|
|
LtsWidgets::PluginData p;
|
|
p.menuGroup = QStringLiteral("[Dev]");
|
|
p.menuText = QStringLiteral("Reset RequestHelper");
|
|
p.identifier = QStringLiteral("ResetRequestHelper");
|
|
|
|
p.directFunc = [&](const LtsWidgets::PluginData &)
|
|
{
|
|
LtsUtils::RequestHelper::s_debug = false;
|
|
};
|
|
|
|
m_baseLayout->addMenuAction(p);
|
|
}
|
|
|
|
{
|
|
LtsWidgets::PluginData p;
|
|
p.menuGroup = QStringLiteral("[Dev]");
|
|
p.menuText = QStringLiteral("fake DoneInitializingSession");
|
|
p.identifier = QStringLiteral("fakeDoneInitializingSession");
|
|
|
|
p.directFunc = [&](const LtsWidgets::PluginData &)
|
|
{
|
|
m_initDone = true;
|
|
emit _signalDoneInitializingSession();
|
|
};
|
|
|
|
m_baseLayout->addMenuAction(p);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
bool LtsSession::notifyUnsavedChanges()
|
|
{
|
|
if (m_baseLayout == nullptr)
|
|
return true;
|
|
|
|
return m_baseLayout->notifyUnsavedChanges();
|
|
}
|
|
|
|
|
|
void LtsSession::createBaseLayout()
|
|
{
|
|
|
|
|
|
using namespace LtsAppDescriptor;
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START, Creating Base Layout for Session " << partitionId();
|
|
|
|
Q_ASSERT(m_baseLayout == nullptr);
|
|
if (m_baseLayout != nullptr)
|
|
{
|
|
WARNING_LOG(m_logger) << "Base Layout already exists for Session" << this;
|
|
return;
|
|
}
|
|
|
|
m_baseLayout = new LtsBaseLayoutWidget;
|
|
|
|
connect(m_baseLayout, &LtsBaseLayoutWidget::signalSuccessfullyPlaced,
|
|
this, [this]()
|
|
{
|
|
DEBUG_LOG(m_logger) << "current APP "<<appToString(this->app());
|
|
|
|
if ( this->app() == App::Scripts)
|
|
{
|
|
m_scriptEditorTimer->start();
|
|
}
|
|
else
|
|
{
|
|
if (m_needsToBeSuccessfullyPlaced)
|
|
{
|
|
|
|
emit _signalDoneInitializingSession();
|
|
}
|
|
}
|
|
});
|
|
|
|
connect(m_baseLayout, &LtsBaseLayoutWidget::destroyed,
|
|
this, [this]()
|
|
{
|
|
m_baseLayout = nullptr;
|
|
|
|
});
|
|
|
|
m_baseLayout->hide();
|
|
m_baseLayout->setSessionInfo(domainId(), partitionType(), partitionId(), workspaceId());
|
|
m_baseLayout->setWindowIcon(appToIcon(app()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (app() == App::ScriptEditorEssentialsView ||
|
|
m_presetBaseLayoutAsSecondaryWidget)
|
|
m_baseLayout->setSecondaryWidget();
|
|
|
|
connect(m_baseLayout, &LtsBaseLayoutWidget::signalRetranslateActions,
|
|
this, &LtsSession::refetchActions);
|
|
connect(m_baseLayout, &LtsBaseLayoutWidget::signalClose,
|
|
this, &LtsSession::signalClose);
|
|
connect(m_baseLayout, &LtsBaseLayoutWidget::signalLogout,
|
|
this, &LtsSession::signalLogout);
|
|
connect(m_baseLayout, &LtsBaseLayoutWidget::signalShowOperatorSettings,
|
|
this, &LtsSession::slotShowOperatorSettings);
|
|
connect(m_baseLayout, &LtsBaseLayoutWidget::signalSwap,
|
|
this, &LtsSession::slotSwap);
|
|
connect(this, &LtsSession::partitionTimeChanged,
|
|
m_baseLayout, &LtsBaseLayoutWidget::setExerciseTime);
|
|
connect(m_baseLayout, &LtsBaseLayoutWidget::signalStapleTopicLockHandler,
|
|
this, &LtsSession::slotStapleTopicLockHandler, Qt::DirectConnection);
|
|
|
|
const auto *sessionData = LtsSessionData::LtsSessionData::getInstance();
|
|
|
|
const QString &operatorName = sessionData->getOperatorName();
|
|
bool showTerminalWindow = sessionData->getShowTerminalWindow();
|
|
m_baseLayout->setOperatorName(operatorName, showTerminalWindow);
|
|
m_baseLayout->setProfilePicture(sessionData->getProfilePicture());
|
|
m_baseLayout->setAppName(appToString(app()));
|
|
|
|
refetchActions();
|
|
|
|
#ifdef LTS_DEBUG
|
|
bool showDeveloperActions = true;
|
|
#else
|
|
bool showDeveloperActions = false;
|
|
#endif
|
|
|
|
if (sessionData->hasDebugFlag(QStringLiteral("DeveloperTools.Active")))
|
|
showDeveloperActions = true;
|
|
|
|
if (showDeveloperActions)
|
|
addDeveloperActions();
|
|
|
|
|
|
for (LtsNotification::LtsNotificationController *ctl : qAsConst(m_notiCtlList))
|
|
{
|
|
if (!m_baseLayout->notificationExists(ctl->identifier()))
|
|
m_baseLayout->addNotification(ctl->createWidget());
|
|
}
|
|
|
|
m_hasBaseLayout = true;
|
|
|
|
m_baseLayout->getMenu()->setVisible(m_menuVisible);
|
|
m_baseLayout->initilizationFinished();
|
|
|
|
|
|
|
|
if (!m_foreverInvisible)
|
|
{
|
|
|
|
QVector<QWidget *> irreplacableWidgets {baseLayoutWidget()};
|
|
LtsSession *dependencySession = dependency();
|
|
int runaway = 100;
|
|
while (dependencySession && runaway > 0)
|
|
{
|
|
irreplacableWidgets += dependencySession->baseLayoutWidget();
|
|
dependencySession = dependencySession->dependency();
|
|
runaway--;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LtsMultiMonitor::LtsMultiMonitor *multiMonitor = LtsMultiMonitor::LtsMultiMonitor::getInstance();
|
|
|
|
WARNING_LOG(m_logger) << "Presets: ScreenId: " << m_screenIdPreset << ", screenContainerId: " << m_screenContainerIdPreset;
|
|
if (m_screenIdPreset >= 0)
|
|
multiMonitor->putScreen(m_baseLayout, m_screenIdPreset, m_screenContainerIdPreset);
|
|
else
|
|
multiMonitor->selectScreen(m_baseLayout, nullptr, true, false, irreplacableWidgets);
|
|
|
|
slotMonitorSelected();
|
|
connect(multiMonitor, &LtsMultiMonitor::LtsMultiMonitor::signalSelected,
|
|
this, &LtsSession::slotMonitorSelected, Qt::UniqueConnection);
|
|
|
|
connect(multiMonitor, &LtsMultiMonitor::LtsMultiMonitor::signalScreenCountChanged,
|
|
m_baseLayout, &LtsBaseLayoutWidget::slotScreenCountChanged);
|
|
|
|
m_baseLayout->slotScreenCountChanged(multiMonitor->screenCount());
|
|
}
|
|
|
|
|
|
if (!sessionData->isTablet())
|
|
return;
|
|
|
|
|
|
LtsNotification::LtsNotification *noti = createNotification(QStringLiteral("TabletWindowSwitcher"));
|
|
|
|
noti->setIcon(QIcon(QStringLiteral("icon:switch_display.svg")));
|
|
noti->setAction([this]()
|
|
{
|
|
emit taskSwitch(this );
|
|
});
|
|
|
|
|
|
emit hideAllOtherBLWs(this);
|
|
}
|
|
|
|
|
|
void LtsSession::slotMonitorSelected()
|
|
{
|
|
auto mmm = LtsMultiMonitor::LtsMultiMonitor::getInstance();
|
|
LtsMultiMonitor::LtsScreenBase *screen = mmm->widgetsScreen(m_baseLayout);
|
|
|
|
if (!screen)
|
|
return;
|
|
|
|
int newScreenContainerId;
|
|
try
|
|
{
|
|
newScreenContainerId = screen->containerIdOfWidget(m_baseLayout);
|
|
}
|
|
catch (...)
|
|
{
|
|
WARNING_LOG(m_logger) << "cannot find container for base layout";
|
|
return;
|
|
}
|
|
|
|
const int newScreenId = screen->screenId();
|
|
if (m_screenId != newScreenId)
|
|
{
|
|
m_screenId = newScreenId;
|
|
m_screenContainerId = newScreenContainerId;
|
|
emit signalScreenIdChanged(m_screenId, m_screenContainerId, screen->screenType());
|
|
}
|
|
}
|
|
|
|
void LtsSession::delayScriptEditorStart()
|
|
{
|
|
DEBUG_LOG(m_logger)<<"LtsSession::delayScriptEditorStart ";
|
|
if (m_needsToBeSuccessfullyPlaced)
|
|
{
|
|
|
|
|
|
emit _signalDoneInitializingSession();
|
|
}
|
|
}
|
|
|
|
bool LtsSession::isChildOfSession(QWidget *child)
|
|
{
|
|
if (!child)
|
|
{
|
|
return false;
|
|
}
|
|
return baseLayout()->isAncestorOf(child);
|
|
}
|
|
|
|
void LtsSession::doneInitializingSession()
|
|
{
|
|
LtsGlobalWaitDialog::getInstance()->done();
|
|
|
|
|
|
|
|
if (m_markedForDeletion)
|
|
{
|
|
emit signalInitializationAborted();
|
|
emit signalClose();
|
|
return;
|
|
}
|
|
|
|
if (!m_sessionManager->isHeadless())
|
|
{
|
|
int sessionCount = m_sessionManager->sessionCount();
|
|
|
|
if (!m_hidden && (m_hasBaseLayout || sessionCount < 1))
|
|
makeVisible();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!createTopicClient<Core::Interface::Ftc>(m_coreFtc))
|
|
WARNING_LOG(m_logger) << "could not create core ftc - no tlh";
|
|
m_coreFtc->enableAll();
|
|
|
|
if (!getForeignGuiInterface(m_ohvIfc))
|
|
WARNING_LOG(m_logger) << "no ovh ifc, no Help-Button !";
|
|
|
|
INFO_LOG(m_logger) << "emit signalDoneInitializingSession, session=" << this;
|
|
|
|
|
|
if (!m_needsToBeSuccessfullyPlaced || m_sessionManager->isHeadless() || !m_hasBaseLayout)
|
|
{
|
|
|
|
|
|
emit _signalDoneInitializingSession();
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
void LtsSession::slotShowOnlineHelp(const QString &fileName)
|
|
{
|
|
if (m_ohvIfc == nullptr)
|
|
{
|
|
LtsWidgets::LtsMessageDialog::showMessage(baseLayout() , tr("Online Help not available."));
|
|
return;
|
|
}
|
|
|
|
m_ohvIfc->showHelp(fileName);
|
|
}
|
|
|
|
|
|
void LtsSession::slotShowOperatorSettings()
|
|
{
|
|
const QMap<LtsDragIcon *, PluginData> &mapButtons = m_baseLayout->mapButtons();
|
|
|
|
for (auto i = mapButtons.constBegin(); i != mapButtons.constEnd(); ++i)
|
|
{
|
|
const PluginData &pd = *i;
|
|
|
|
if (pd.identifier == QStringLiteral("_OpmShowOperatorSettings"))
|
|
{
|
|
LtsDialog *showOperatorSettingsDlg = pd.createWidgetFunc(nullptr);
|
|
|
|
if (showOperatorSettingsDlg != nullptr)
|
|
{
|
|
addWidget(showOperatorSettingsDlg, pd.menuGroup, pd.identifier, pd.layoutArea, pd.closable);
|
|
|
|
}
|
|
else
|
|
WARNING_LOG(m_logger) << "could not create operator settings dialog from action";
|
|
|
|
return;
|
|
}
|
|
}
|
|
|
|
WARNING_LOG(m_logger) << "action for showing operator settings not found !!";
|
|
}
|
|
|
|
|
|
void LtsSession::slotStartPluginInit()
|
|
{
|
|
m_initializeThesePlugins = m_guiPluginInterfaces;
|
|
slotPluginInitDone();
|
|
}
|
|
|
|
|
|
void LtsSession::slotPluginInitDone()
|
|
{
|
|
|
|
|
|
if (m_pluginInitDone)
|
|
return;
|
|
|
|
if (m_slotPluginInitDoneMutex)
|
|
{
|
|
|
|
|
|
return;
|
|
}
|
|
|
|
m_slotPluginInitDoneMutex = true;
|
|
|
|
GuiPluginBase::Interface *theSender = dynamic_cast<GuiPluginBase::Interface *>(sender());
|
|
|
|
if (theSender != m_currentInitIfc)
|
|
{
|
|
WARNING_LOG(m_logger) << this << " called slotPluginInitDone from plugin which was not currently active for initialization - ignoring";
|
|
#ifdef LTS_DEBUG
|
|
WARNING_LOG(m_logger) << "current init ifc: " << m_currentInitIfc << ", sender: " << sender();
|
|
#endif
|
|
m_slotPluginInitDoneMutex = false;
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
m_currentInitIfc = nullptr;
|
|
|
|
|
|
auto i = m_initializeThesePlugins.begin();
|
|
|
|
if (i == m_initializeThesePlugins.end())
|
|
{
|
|
m_pluginInitDone = true;
|
|
|
|
|
|
executePayloads();
|
|
|
|
return;
|
|
}
|
|
|
|
std::shared_ptr<GuiPluginBase::Interface> ifc = i.value();
|
|
|
|
if (ifc->availableInPartition(partitionType()))
|
|
{
|
|
m_currentInitIfc = ifc.get();
|
|
|
|
|
|
|
|
|
|
ifc->init();
|
|
if (!ifc->m_hasInit)
|
|
{
|
|
|
|
m_currentInitIfc = nullptr;
|
|
QTimer::singleShot(0, this, &LtsSession::slotPluginInitDone);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
m_currentInitIfc = nullptr;
|
|
QTimer::singleShot(0, this, &LtsSession::slotPluginInitDone);
|
|
}
|
|
|
|
m_initializeThesePlugins.erase(i);
|
|
|
|
m_slotPluginInitDoneMutex = false;
|
|
}
|
|
|
|
|
|
void LtsSession::slotExecuteNextPayload()
|
|
{
|
|
LtsWidgets::LtsGlobalWaitDialog::getInstance()->wait();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto it1 = m_payloadPriorityMap.begin();
|
|
|
|
if (it1 != m_payloadPriorityMap.end())
|
|
{
|
|
std::shared_ptr<GuiPluginBase::Interface> ifc = (*it1);
|
|
m_payloadPriorityMap.erase(it1);
|
|
|
|
DEBUG_LOG(m_logger) << "Executing priorized Payload in Partition " << partitionId() << ", Type " << partitionType();
|
|
|
|
LtsWidgets::LtsGlobalWaitDialog::getInstance()->done();
|
|
|
|
|
|
if (m_blub)
|
|
{
|
|
m_blub->stop();
|
|
m_blub->deleteLater();
|
|
|
|
}
|
|
m_blub = new QTimer(this);
|
|
m_blub2 = 0;
|
|
QString name(QString::fromUtf8(typeid(ifc.get()).name()));
|
|
connect(m_blub, &QObject::destroyed,
|
|
this, [name]()
|
|
{
|
|
|
|
});
|
|
connect(m_blub, &QTimer::timeout,
|
|
this, [this, name]()
|
|
{
|
|
m_blub2++;
|
|
|
|
});
|
|
m_blub->start(1000);
|
|
|
|
|
|
ifc->executePayload(m_mainBackground);
|
|
}
|
|
else
|
|
{
|
|
auto it2 = m_payloadList.begin();
|
|
|
|
if (it2 != m_payloadList.end())
|
|
{
|
|
std::shared_ptr<GuiPluginBase::Interface> ifc = (*it2);
|
|
m_payloadList.erase(it2);
|
|
|
|
DEBUG_LOG(m_logger) << "Executing unpriorized Payload in Partition " << partitionId() << ", Type " << partitionType();
|
|
|
|
LtsWidgets::LtsGlobalWaitDialog::getInstance()->done();
|
|
|
|
|
|
if (m_blub)
|
|
{
|
|
m_blub->stop();
|
|
m_blub->deleteLater();
|
|
|
|
}
|
|
m_blub = new QTimer(this);
|
|
m_blub2 = 0;
|
|
QString name(QString::fromUtf8(typeid(ifc.get()).name()));
|
|
connect(m_blub, &QObject::destroyed,
|
|
this, [name]()
|
|
{
|
|
|
|
});
|
|
connect(m_blub, &QTimer::timeout,
|
|
this, [this, name]()
|
|
{
|
|
m_blub2++;
|
|
|
|
});
|
|
m_blub->start(1000);
|
|
|
|
|
|
ifc->executePayload(m_mainBackground);
|
|
}
|
|
else
|
|
{
|
|
Q_ASSERT(m_payloadsDone == false);
|
|
m_payloadsDone = true;
|
|
|
|
m_mainBackground = nullptr;
|
|
|
|
if (m_blub)
|
|
{
|
|
m_blub->stop();
|
|
m_blub->deleteLater();
|
|
|
|
m_blub = nullptr;
|
|
}
|
|
|
|
|
|
|
|
doneInitializingSession();
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
void LtsSession::executePayloads()
|
|
{
|
|
|
|
if (!m_payloadPriorityMap.isEmpty() || !m_payloadList.isEmpty())
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
LtsWidgets::LtsGlobalWaitDialog::getInstance()->done();
|
|
|
|
slotExecuteNextPayload();
|
|
}
|
|
else
|
|
{
|
|
|
|
DEBUG_LOG(m_logger) << "no payloads";
|
|
|
|
if (partitionType() == IDL::PartitionType::Global)
|
|
{
|
|
m_hasBaseLayout = true;
|
|
}
|
|
|
|
doneInitializingSession();
|
|
}
|
|
}
|
|
|
|
|
|
void LtsSession::clearDataPluginInterfaces()
|
|
{
|
|
QMap<QString, std::weak_ptr<DataPluginBase::Interface>> weakDataPluginInterfaces;
|
|
for (auto i = m_dataPluginInterfaces.cbegin(); i != m_dataPluginInterfaces.cend(); ++i)
|
|
{
|
|
|
|
weakDataPluginInterfaces.insert(i.key(), i.value());
|
|
}
|
|
|
|
DEBUG_LOG(m_logger) << "Clearing data plugin interfaces for " << partitionType() << " - " << this;
|
|
m_dataPluginInterfaces.clear();
|
|
|
|
#ifdef LTS_DEBUG
|
|
|
|
if (partitionType() != IDL::PartitionType::Global)
|
|
{
|
|
for (auto i = weakDataPluginInterfaces.cbegin(); i != weakDataPluginInterfaces.cend(); ++i)
|
|
{
|
|
std::shared_ptr<DataPluginBase::Interface> sp = i.value().lock();
|
|
if (!sp)
|
|
continue;
|
|
WARNING_LOG(m_logger) << "still referenced Data Plugin '" << i.key()
|
|
<< "' in partition type " << partitionType()
|
|
<< " (use_count=" << sp.use_count() << ")"
|
|
<< " - application may crash on exit! " << this;
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
|
|
|
|
void LtsSession::clearGuiPluginInterfaces()
|
|
{
|
|
bool bInClearPluginInterfaces = true;
|
|
auto cbCheckEventLoop = [this, &bInClearPluginInterfaces]()
|
|
{
|
|
if (bInClearPluginInterfaces)
|
|
{
|
|
ERROR_LOG(m_logger) << "QEventLoop was called within clearGuiPluginInterfaces which is not allowed!";
|
|
Q_ASSERT(false);
|
|
}
|
|
};
|
|
QTimer::singleShot(0, this, cbCheckEventLoop);
|
|
m_ohvIfc = nullptr;
|
|
QMap<QString, std::weak_ptr<GuiPluginBase::Interface>> weakGuiPluginInterfaces;
|
|
for (auto i = m_guiPluginInterfaces.cbegin(); i != m_guiPluginInterfaces.cend(); ++i)
|
|
{
|
|
i.value()->clearInterfaces();
|
|
weakGuiPluginInterfaces.insert(i.key(), i.value());
|
|
}
|
|
bInClearPluginInterfaces = false;
|
|
|
|
DEBUG_LOG(m_logger) << "Clearing gui plugin interfaces for " << partitionType() << " - " << this;
|
|
m_guiPluginInterfaces.clear();
|
|
|
|
#ifdef LTS_DEBUG
|
|
|
|
if (partitionType() != IDL::PartitionType::Global)
|
|
{
|
|
for (auto i = weakGuiPluginInterfaces.cbegin(); i != weakGuiPluginInterfaces.cend(); ++i)
|
|
{
|
|
std::shared_ptr<GuiPluginBase::Interface> sp = i.value().lock();
|
|
if (!sp)
|
|
continue;
|
|
WARNING_LOG(m_logger) << "still referenced Gui Plugin '" << i.key()
|
|
<< "'in partition type " << partitionType()
|
|
<< " (use_count=" << sp.use_count() << ")"
|
|
<< " Gui Plugin '" << i.key() << "'"
|
|
<< " - application may crash on exit! " << this;
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
|
|
LtsSessionManager *LtsSession::getSessionManager()
|
|
{
|
|
return m_sessionManager;
|
|
}
|
|
|
|
}
|