Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+352
@@ -0,0 +1,352 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2017-11-15
|
||||
*/
|
||||
|
||||
#include "dev_dialog.h"
|
||||
#include "ui_dev_dialog.h"
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsWidgets/lts_global_wait_dialog.h>
|
||||
#include <LtsAppManager/lts_app_manager.h>
|
||||
#include <LtsPluginManager/lts_plugin_manager.h>
|
||||
#include <LtsSession/lts_session_manager.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsLogin/lts_login.h>
|
||||
#include <LtsMultiMonitor/lts_multi_monitor.h>
|
||||
#include <LtsMultiMonitor/lts_dummy_widget.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
|
||||
#include <QTimer>
|
||||
#include <QFormLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QColorDialog>
|
||||
#include <QClipboard>
|
||||
#include <QInputDialog>
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
namespace DeveloperTools
|
||||
{
|
||||
|
||||
DevDialog::DevDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, m_ui(new Ui::DevDialog)
|
||||
, m_t(nullptr)
|
||||
, m_thisLayout(new QVBoxLayout())
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->scrollAreaWidgetContents->setLayout(m_thisLayout);
|
||||
|
||||
m_t = new QTimer(this);
|
||||
connect(m_t, &QTimer::timeout,
|
||||
this, &DevDialog::slotRefresh);
|
||||
m_t->setInterval(250);
|
||||
m_t->start();
|
||||
|
||||
connect(m_ui->cbAuto, &QCheckBox::toggled,
|
||||
this, &DevDialog::slotToggleAuto);
|
||||
connect(m_ui->pbRefresh, &QPushButton::clicked,
|
||||
this, &DevDialog::slotRefresh);
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
connect(m_ui->pbLDWNormal, &QPushButton::clicked,
|
||||
this, [this]()
|
||||
{
|
||||
LtsMultiMonitor::FullscreenVideoDummyWidget *dummy = new LtsMultiMonitor::FullscreenVideoDummyWidget;
|
||||
|
||||
connect(dummy, &LtsMultiMonitor::FullscreenVideoDummyWidget::destroyed,
|
||||
this, []()
|
||||
|
||||
{
|
||||
qWarning() << "dummy widget (normal only) was destroyed!";
|
||||
});
|
||||
|
||||
connect(dummy, &LtsMultiMonitor::FullscreenVideoDummyWidget::signalWidgetPlaced,
|
||||
this, [](const QRect &globalGeo)
|
||||
{
|
||||
qWarning() << "dummy widget (normal only) was placed!" << globalGeo;
|
||||
});
|
||||
|
||||
LtsMultiMonitor::LtsMultiMonitor::getInstance()->selectScreen(dummy, nullptr, false, true);
|
||||
});
|
||||
|
||||
connect(m_ui->pbLDW, &QPushButton::clicked,
|
||||
this, [this]()
|
||||
{
|
||||
LtsMultiMonitor::FullscreenVideoDummyWidget *dummy = new LtsMultiMonitor::FullscreenVideoDummyWidget;
|
||||
|
||||
connect(dummy, &LtsMultiMonitor::FullscreenVideoDummyWidget::destroyed,
|
||||
this, []()
|
||||
|
||||
{
|
||||
qWarning() << "dummy widget was destroyed!";
|
||||
});
|
||||
|
||||
connect(dummy, &LtsMultiMonitor::FullscreenVideoDummyWidget::signalWidgetPlaced,
|
||||
this, [](const QRect &globalGeo)
|
||||
{
|
||||
qWarning() << "dummy widget was placed!" << globalGeo;
|
||||
});
|
||||
|
||||
LtsMultiMonitor::LtsMultiMonitor::getInstance()->selectScreen(dummy);
|
||||
});
|
||||
|
||||
connect(m_ui->pbCQCD, &QPushButton::clicked,
|
||||
this, [this]()
|
||||
{
|
||||
QColorDialog *cd = new QColorDialog(this);
|
||||
cd->setOption(QColorDialog::DontUseNativeDialog);
|
||||
cd->show();
|
||||
});
|
||||
|
||||
connect(m_ui->pbCOSIC, &QPushButton::clicked,
|
||||
this, []()
|
||||
{
|
||||
QApplication::clipboard()->setText(QString::fromUtf8(LtsUtils::OperatorSettings::getInstance()->exportSettings()));
|
||||
});
|
||||
|
||||
connect(m_ui->pbCPSIC, &QPushButton::clicked,
|
||||
this, []()
|
||||
{
|
||||
QApplication::clipboard()->setText(QString::fromUtf8(LtsUtils::ProjectSettings::getInstance()->exportSettings()));
|
||||
});
|
||||
|
||||
connect(m_ui->pbGWDCT, &QPushButton::clicked,
|
||||
this, [this]()
|
||||
{
|
||||
LtsWidgets::LtsGlobalWaitDialog::getInstance()->wait(QInputDialog::getText(this, QStringLiteral("Custom Text"), QStringLiteral("Custom Text")));
|
||||
});
|
||||
|
||||
|
||||
auto *mousePosTimer = new QTimer(this);
|
||||
mousePosTimer->setInterval(300);
|
||||
connect(mousePosTimer, &QTimer::timeout,
|
||||
this, [this]()
|
||||
{
|
||||
m_ui->lblMousePos->setText(QStringLiteral("x: %1 - y: %2").arg(QString::number(QCursor::pos().x()).leftJustified(4), QString::number(QCursor::pos().y()).leftJustified(4)));
|
||||
});
|
||||
mousePosTimer->start();
|
||||
}
|
||||
|
||||
|
||||
QString boolToString(bool value)
|
||||
{
|
||||
return (value ? QStringLiteral("true") : QStringLiteral("false"));
|
||||
}
|
||||
|
||||
|
||||
void AppWidget::checkSessions(const QMap<LtsSession::LtsSessionManager::SessionKey, LtsSession::LtsSession *> &sessions)
|
||||
{
|
||||
// check for deleted sessions
|
||||
for (AppSessionWidget *appSessionWidget : qAsConst(appSessionList))
|
||||
{
|
||||
const LtsSession::LtsSession *session = nullptr;
|
||||
|
||||
for (LtsSession::LtsSession *_session : qAsConst(sessions))
|
||||
{
|
||||
if (appSessionWidget->appSessionPtr == _session)
|
||||
{
|
||||
session = _session;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!session) // found
|
||||
{
|
||||
appSessionWidget->setDeleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AppSessionWidget::setDeleted()
|
||||
{
|
||||
setStyleSheet(QStringLiteral("background-color: #FFA197;"));
|
||||
}
|
||||
|
||||
|
||||
void AppWidget::setDeleted()
|
||||
{
|
||||
setStyleSheet(QStringLiteral("background-color: #FFA197;"));
|
||||
}
|
||||
|
||||
|
||||
void AppWidget::addSession(LtsSession::LtsSession *appSession)
|
||||
{
|
||||
AppSessionWidget *appSessionWidget = nullptr;
|
||||
|
||||
for (auto i = appSessionList.begin(); i != appSessionList.end(); ++i)
|
||||
{
|
||||
AppSessionWidget *_appSessionWidget = *i;
|
||||
|
||||
if (_appSessionWidget->appSessionPtr == appSession)
|
||||
{
|
||||
appSessionWidget = _appSessionWidget;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (appSessionWidget == nullptr) // NEW SESSION
|
||||
{
|
||||
appSessionWidget = new AppSessionWidget();
|
||||
appSessionWidget->appSessionPtr = appSession;
|
||||
|
||||
QFormLayout *sessionForm = new QFormLayout(appSessionWidget);
|
||||
|
||||
sessionForm->addRow(QStringLiteral("Session Id:"), appSessionWidget->sessionId);
|
||||
sessionForm->addRow(QStringLiteral("Session adr:"), appSessionWidget->session);
|
||||
sessionForm->addRow(QStringLiteral("Session name:"), appSessionWidget->name);
|
||||
sessionForm->addRow(QStringLiteral("BaseLayout adr:"), appSessionWidget->blw);
|
||||
sessionForm->addRow(QStringLiteral("Domain Id:"), appSessionWidget->domainId);
|
||||
sessionForm->addRow(QStringLiteral("Exercise Id:"), appSessionWidget->exerciseId);
|
||||
sessionForm->addRow(QStringLiteral("Partition Id:"), appSessionWidget->partId);
|
||||
sessionForm->addRow(QStringLiteral("Partition Type:"), appSessionWidget->key);
|
||||
|
||||
sessionForm->addRow(QStringLiteral("Payloads:"), appSessionWidget->payloads);
|
||||
sessionForm->addRow(QStringLiteral("Has BaseLayout:"), appSessionWidget->hasBL);
|
||||
sessionForm->addRow(QStringLiteral("BaseLayout:"), appSessionWidget->isBL);
|
||||
sessionForm->addRow(QStringLiteral("Marked for deletion:"), appSessionWidget->deletion);
|
||||
sessionForm->addRow(QStringLiteral("Init done:"), appSessionWidget->init);
|
||||
|
||||
appSessionList.append(appSessionWidget);
|
||||
thisLayout->insertWidget(0, appSessionWidget);
|
||||
}
|
||||
|
||||
// AND EXISTING SESSION
|
||||
|
||||
appSessionWidget->sessionId->setText(QString::number(appSession->id()));
|
||||
appSessionWidget->session->setText(QString::number((qintptr)appSession, 16));
|
||||
appSessionWidget->name->setText(appSession->name());
|
||||
appSessionWidget->blw->setText(QString::number((qintptr)appSession->baseLayout(), 16));
|
||||
appSessionWidget->domainId->setText(QString::number(appSession->domainId()));
|
||||
appSessionWidget->exerciseId->setText(QString::number(appSession->exerciseId()));
|
||||
appSessionWidget->partId->setText(QString::number(appSession->partitionId()));
|
||||
appSessionWidget->key->setText(LtsSession::LtsSession::partitionTypeString(appSession->partitionType()));
|
||||
|
||||
appSessionWidget->payloads->setText(boolToString(appSession->m_payloads));
|
||||
appSessionWidget->hasBL->setText(boolToString(appSession->m_hasBaseLayout));
|
||||
appSessionWidget->isBL->setText(boolToString(appSession->m_baseLayout != nullptr));
|
||||
appSessionWidget->deletion->setText(boolToString(appSession->m_markedForDeletion));
|
||||
appSessionWidget->init->setText(boolToString(appSession->m_initDone));
|
||||
}
|
||||
|
||||
|
||||
void DevDialog::addApp(LtsPluginManager::LtsPluginManager *app)
|
||||
{
|
||||
AppWidget *appWidget = nullptr;
|
||||
|
||||
for (auto i = m_appWidgetList.begin(); i != m_appWidgetList.end(); ++i)
|
||||
{
|
||||
AppWidget *_appWidget = *i;
|
||||
|
||||
if (_appWidget->appPtr == app)
|
||||
{
|
||||
appWidget = _appWidget;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (appWidget == nullptr) // NEW APP WIDGET
|
||||
{
|
||||
appWidget = new AppWidget();
|
||||
appWidget->appPtr = app;
|
||||
|
||||
QFormLayout *form = new QFormLayout(appWidget);
|
||||
|
||||
form->addRow(QStringLiteral("Name: "), appWidget->appName);
|
||||
form->addRow(QStringLiteral("Description: "), appWidget->appDescription);
|
||||
form->addRow(QStringLiteral("Initialized: "), appWidget->init);
|
||||
|
||||
// Sessions:
|
||||
form->addRow(QStringLiteral("Session count: "), appWidget->sessionCountLabel);
|
||||
form->addRow(QStringLiteral("Sessions:"), appWidget->sessionsWidget);
|
||||
|
||||
m_thisLayout->insertWidget(0, appWidget);
|
||||
m_appWidgetList.append(appWidget);
|
||||
}
|
||||
|
||||
|
||||
// AND EXISTING APP WIDGET
|
||||
|
||||
const QString &appName = app->m_app.appName;
|
||||
appWidget->appName->setText(appName.isEmpty() ? QStringLiteral("<unknown>") : appName);
|
||||
const QString &appDescription = app->description();
|
||||
appWidget->appDescription->setText(appDescription.isEmpty() ? QStringLiteral("<none>") : appDescription);
|
||||
appWidget->init->setText(boolToString(app->m_initialized));
|
||||
|
||||
|
||||
const QMap<LtsSession::LtsSessionManager::SessionKey, LtsSession::LtsSession *> &sessions = app->m_sessionManager->m_sessionMap;
|
||||
|
||||
appWidget->sessionCountLabel->setText(QString::number(sessions.count()));
|
||||
|
||||
for (LtsSession::LtsSession *appSession : sessions)
|
||||
appWidget->addSession(appSession);
|
||||
}
|
||||
|
||||
|
||||
void DevDialog::slotRefresh()
|
||||
{
|
||||
m_ui->lblLtsDialogCount->setText(QString::number(LtsWidgets::LtsDialog::s_object_count));
|
||||
|
||||
LtsAppManager::LtsAppManager *appManager = LtsAppManager::LtsAppManager::getInstance();
|
||||
|
||||
QVector<LtsPluginManager::LtsPluginManager *> appList = appManager->m_appList;
|
||||
|
||||
bool loginAppExists = (appManager->m_login != nullptr ? (appManager->m_login->m_loginApp != nullptr ? true : false) : false);
|
||||
if (loginAppExists)
|
||||
appList.append(appManager->m_login->m_loginApp);
|
||||
|
||||
m_ui->lblAppCount->setText(QString::number(appList.count()));
|
||||
|
||||
// add apps
|
||||
for (auto *app : qAsConst(appList))
|
||||
addApp(app);
|
||||
|
||||
|
||||
// check for deleted apps and sessions
|
||||
for (AppWidget *appWidget : qAsConst(m_appWidgetList))
|
||||
{
|
||||
const LtsPluginManager::LtsPluginManager *app = nullptr;
|
||||
|
||||
for (LtsPluginManager::LtsPluginManager *_app : qAsConst(appList))
|
||||
{
|
||||
if (appWidget->appPtr == _app)
|
||||
{
|
||||
app = _app;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (app) // found, check for deleted sessions
|
||||
{
|
||||
appWidget->checkSessions(app->m_sessionManager->m_sessionMap);
|
||||
}
|
||||
else // not found
|
||||
{
|
||||
appWidget->setDeleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DevDialog::slotToggleAuto(bool checked)
|
||||
{
|
||||
if (checked)
|
||||
m_t->start();
|
||||
else
|
||||
m_t->stop();
|
||||
}
|
||||
|
||||
} // namespace DeveloperTools
|
||||
Reference in new issue
Block a user