83 lines
1.5 KiB
C++
Executable File
83 lines
1.5 KiB
C++
Executable File
|
|
|
|
|
|
#pragma once
|
|
|
|
#include <ConnectDialog/ltsutilsguiconnectdialog_export.h>
|
|
#include <LtsWidgets/lts_frameless_dialog.h>
|
|
|
|
#include <QWidget>
|
|
#include <QTimer>
|
|
|
|
#include <functional>
|
|
|
|
|
|
namespace Ui
|
|
{
|
|
class ConnectingDialog;
|
|
}
|
|
|
|
namespace LtsUtils
|
|
{
|
|
|
|
class LTSUTILSGUICONNECTDIALOG_EXPORT ConnectingDialog : public LtsWidgets::LtsFramelessDialog
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
static int s_waitForHistoricalDataWaitTime;
|
|
|
|
template <typename DtcType, typename WaitForHistoricalDataFunction>
|
|
explicit ConnectingDialog(DtcType dtc,
|
|
WaitForHistoricalDataFunction waitForHistoricalDataFunction,
|
|
const QString &serviceName,
|
|
const QString &exerciseName,
|
|
QWidget *parent = nullptr)
|
|
: LtsWidgets::LtsFramelessDialog(parent, LtsWidgets::Behaviour::Modal)
|
|
, m_serviceName(serviceName)
|
|
, m_exerciseName(exerciseName)
|
|
, m_ui(nullptr)
|
|
{
|
|
setWindowTitle(tr("Connecting .."));
|
|
setup();
|
|
show();
|
|
|
|
while (true)
|
|
{
|
|
if ((dtc.get()->*waitForHistoricalDataFunction)(s_waitForHistoricalDataWaitTime))
|
|
{
|
|
deleteLater();
|
|
return;
|
|
}
|
|
|
|
if (s_waitForHistoricalDataWaitTime >= 999999)
|
|
{
|
|
deleteLater();
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
failed();
|
|
}
|
|
}
|
|
}
|
|
|
|
~ConnectingDialog();
|
|
|
|
void failed();
|
|
|
|
private:
|
|
QString m_serviceName;
|
|
QString m_exerciseName;
|
|
Ui::ConnectingDialog *m_ui;
|
|
|
|
void reset();
|
|
void setup();
|
|
|
|
signals:
|
|
void signalStopLoop();
|
|
|
|
};
|
|
|
|
}
|