Graph::Graph(MainWindow* parentWindow) : QObject(parentWindow), m_window(*parentWindow) { m_dataSets.reserve(64); m_remoteIP = QString::fromUtf8(m_settings.getString("robotIP").c_str()); m_dataPort = m_settings.getInt("robotGraphPort"); connect(&m_dataSocket, SIGNAL(readyRead()), this, SLOT(handleSocketData())); }
Graph::Graph(MainWindow* parentWindow) : QObject(parentWindow) { m_window = parentWindow; m_dataSets.reserve(64); m_graphNames.reserve(64); m_dataSocket = std::make_unique<QTcpSocket>(this); m_remoteIP = QString::fromUtf8(m_settings.getString("robotIP").c_str()); m_dataPort = m_settings.getInt("robotGraphPort"); connect(m_dataSocket.get(), SIGNAL(readyRead()), this, SLOT(handleSocketData())); }
MainWindow::MainWindow(int width, int height) : m_buffer(0xffff - 28) { setMinimumSize(width, height); centralWidget = new QWidget(this); setCentralWidget(centralWidget); m_settings = std::make_unique<Settings>("IPSettings.txt"); m_client = new MjpegClient(m_settings->getString("streamHost"), m_settings->getInt("mjpegPort"), m_settings->getString("mjpegRequestPath")); m_stream = new VideoStream(m_client, this, 640, 480, &m_streamCallback, [this] {}, [this] { m_button->setText("Stop Stream"); }, [this] { m_button->setText("Start Stream"); }); m_stream->setMaximumSize(640, 480); m_button = new QPushButton("Start Stream"); connect(m_button, SIGNAL(released()), this, SLOT(toggleButton())); m_leftLayout = new QVBoxLayout; m_centerLayout = new QVBoxLayout; m_centerLayout->addWidget(m_stream, 0, Qt::AlignTop); QHBoxLayout* buttonLayout = new QHBoxLayout; buttonLayout->addWidget(m_button, 0, Qt::AlignTop); buttonLayout->insertStretch(1); m_centerLayout->addLayout(buttonLayout); m_rightLayout = new QVBoxLayout; m_optionLayout = new QVBoxLayout; m_autoSelect = new QComboBox; connect(m_autoSelect, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), [this](int index) { char data[16] = "autonSelect\r\n"; data[13] = index; m_dataSocket->writeDatagram(data, sizeof(data), m_remoteIP, m_dataPort); }); m_optionLayout->addWidget(m_autoSelect); m_optionLayout->setAlignment(m_autoSelect, Qt::AlignTop); QGridLayout* mainLayout = new QGridLayout; mainLayout->setColumnMinimumWidth(0, width / 4); mainLayout->setColumnMinimumWidth(1, width / 4); mainLayout->setColumnMinimumWidth(2, width / 4); mainLayout->setColumnMinimumWidth(3, width / 4); mainLayout->addLayout(m_leftLayout, 0, 0); mainLayout->addLayout(m_centerLayout, 0, 1); mainLayout->addLayout(m_rightLayout, 0, 2); mainLayout->addLayout(m_optionLayout, 0, 3); centralWidget->setLayout(mainLayout); createActions(); createMenus(); setUnifiedTitleAndToolBarOnMac(true); m_dataSocket = std::make_unique<QUdpSocket>(this); m_dataSocket->bind(m_settings->getInt("dsDataPort")); connect(m_dataSocket.get(), SIGNAL(readyRead()), this, SLOT(handleSocketData())); m_remoteIP = QString::fromUtf8(m_settings->getString("robotIP").c_str()); m_dataPort = m_settings->getInt("robotDataPort"); m_connectTimer = std::make_unique<QTimer>(); connect(m_connectTimer.get(), &QTimer::timeout, [this] { if (!m_connectDlgOpen) { char data[16] = "connect\r\n"; m_dataSocket->writeDatagram(data, sizeof(data), m_remoteIP, m_dataPort); } m_connectTimer->start(2000); }); m_connectTimer->start(2000); }