Skip to content

Commit 8455a87

Browse files
Message tests
1 parent 2226283 commit 8455a87

File tree

7 files changed

+287
-40
lines changed

7 files changed

+287
-40
lines changed

src/FlatBufferConnection.cpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ void FlatBufferConnection::sendMessage(const uint8_t* buffer, uint32_t size)
128128
switch (_socket.state() )
129129
{
130130
case QAbstractSocket::UnconnectedState:
131-
qDebug() << "No connection to Hyperion: " << QSTRING_CSTR(_host) << _port;
131+
emit logMessage(QString("No connection to Hyperion: %1 %2").arg(_host).arg(_port));
132132
break;
133133
case QAbstractSocket::ConnectedState:
134-
qDebug() << "Connected to Hyperion: " << QSTRING_CSTR(_host) << _port;
134+
emit logMessage(QString("Connected to Hyperion: %1 %2").arg(_host).arg(_port));
135135
break;
136136
default:
137-
qDebug() << "Connecting to Hyperion: " << QSTRING_CSTR(_host) << _port;
137+
emit logMessage(QString("Connecting to Hyperion: %1 %2").arg(_host).arg(_port));
138138
break;
139139
}
140140
_prevSocketState = _socket.state();
@@ -188,6 +188,21 @@ bool FlatBufferConnection::parseReply(const hyperionnet::Reply *reply)
188188

189189
void FlatBufferConnection::disconnected()
190190
{
191-
qDebug() << "Connection to Hyperion server was closed";
192-
emit serverDisconnected();
191+
struct calldata call_data;
192+
calldata_init(&call_data);
193+
calldata_set_string(&call_data, "msg", "Connection to Hyperion server was closed");
194+
calldata_set_bool(&call_data, "running", true);
195+
signal_handler_t *handler = hyperion_get_signal_handler();
196+
signal_handler_signal(handler, "stop", &call_data);
197+
calldata_free(&call_data);
198+
}
199+
200+
void FlatBufferConnection::logMessage(const QString& message)
201+
{
202+
struct calldata call_data;
203+
calldata_init(&call_data);
204+
calldata_set_string(&call_data, "msg", message.toStdString().c_str());
205+
signal_handler_t *handler = hyperion_get_signal_handler();
206+
signal_handler_signal(handler, "log", &call_data);
207+
calldata_free(&call_data);
193208
}

src/FlatBufferConnection.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
#include <flatbuffers/flatbuffers.h>
1717

18+
#include "hyperion-obs.h"
19+
1820
const int FLATBUFFER_DEFAULT_PORT = 19400;
1921

2022
namespace hyperionnet
@@ -64,12 +66,12 @@ public slots:
6466
///
6567
void setImage(const Image<ColorRgb> &image);
6668

67-
signals:
69+
// signals:
6870

69-
///
70-
/// @brief Emits whenever the server disconnected
71-
///
72-
void serverDisconnected();
71+
// ///
72+
// /// @brief Emits whenever the server disconnected
73+
// ///
74+
// void serverDisconnected();
7375

7476
private slots:
7577
///
@@ -87,6 +89,8 @@ private slots:
8789
///
8890
void disconnected();
8991

92+
void logMessage(const QString& message);
93+
9094
private:
9195

9296
///

src/HyperionProperties.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void HyperionProperties::enableStart(bool enable)
6666

6767
void HyperionProperties::setWarningText(const char *msg)
6868
{
69-
ui->WarningText->setText(msg);
69+
ui->WarningText->appendPlainText(msg);
7070
}
7171

7272
void HyperionProperties::saveSettings()
@@ -94,6 +94,8 @@ void HyperionProperties::onStart()
9494

9595
signal_handler_t *handler = hyperion_get_signal_handler();
9696
signal_handler_connect(handler, "stop", output_stopped , this);
97+
signal_handler_connect(handler, "log", logger_message, this);
98+
9799
enableStart(false);
98100
setWarningText("");
99101
hyperion_start_streaming(address, port, sizeDecimation);
@@ -119,4 +121,13 @@ static void output_stopped(void *data, calldata_t *cd)
119121
signal_handler_t *handler = obs_output_get_signal_handler(output);
120122
page->enableStart(true);
121123
signal_handler_disconnect(handler, "stop", output_stopped , page);
124+
signal_handler_disconnect(handler, "log", logger_message, page);
125+
}
126+
127+
static void logger_message(void *data, calldata_t *cd)
128+
{
129+
auto *page = static_cast<HyperionProperties*>(data);
130+
auto *output = static_cast<obs_output_t*>(calldata_ptr(cd, "output"));
131+
const char* msg = calldata_string(cd, "msg");
132+
page->setWarningText(msg);
122133
}

src/HyperionProperties.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@ private Q_SLOTS:
3939

4040
static void output_started(void *data, calldata_t *cd);
4141
static void output_stopped(void *data, calldata_t *cd);
42+
static void logger_message(void *data, calldata_t *cd);
4243

4344
#endif // HYPERIONPROPERTIES_H

src/HyperionProperties.ui

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,18 @@
1717
<property name="geometry">
1818
<rect>
1919
<x>40</x>
20-
<y>20</y>
20+
<y>10</y>
2121
<width>381</width>
22-
<height>141</height>
22+
<height>171</height>
2323
</rect>
2424
</property>
2525
<layout class="QVBoxLayout" name="Hyperion">
26+
<property name="spacing">
27+
<number>0</number>
28+
</property>
29+
<property name="topMargin">
30+
<number>0</number>
31+
</property>
2632
<item>
2733
<layout class="QHBoxLayout" name="HyperionOutputConfig">
2834
<item>
@@ -106,40 +112,25 @@
106112
</layout>
107113
</item>
108114
<item>
109-
<spacer name="verticalSpacer">
115+
<spacer name="horizontalSpacer">
110116
<property name="orientation">
111-
<enum>Qt::Vertical</enum>
112-
</property>
113-
<property name="sizeType">
114-
<enum>QSizePolicy::Maximum</enum>
117+
<enum>Qt::Horizontal</enum>
115118
</property>
116119
<property name="sizeHint" stdset="0">
117120
<size>
118-
<width>20</width>
119-
<height>15</height>
121+
<width>40</width>
122+
<height>10</height>
120123
</size>
121124
</property>
122125
</spacer>
123126
</item>
124127
<item>
125-
<widget class="QLabel" name="WarningText">
126-
<property name="autoFillBackground">
127-
<bool>false</bool>
128-
</property>
129-
<property name="styleSheet">
130-
<string notr="true">color: rgb(245, 121, 0);</string>
131-
</property>
132-
<property name="frameShape">
133-
<enum>QFrame::StyledPanel</enum>
134-
</property>
135-
<property name="frameShadow">
136-
<enum>QFrame::Plain</enum>
137-
</property>
138-
<property name="text">
139-
<string notr="true"/>
128+
<widget class="QPlainTextEdit" name="WarningText">
129+
<property name="readOnly">
130+
<bool>true</bool>
140131
</property>
141-
<property name="textFormat">
142-
<enum>Qt::AutoText</enum>
132+
<property name="plainText">
133+
<string/>
143134
</property>
144135
</widget>
145136
</item>
@@ -149,12 +140,21 @@
149140
<property name="geometry">
150141
<rect>
151142
<x>40</x>
152-
<y>170</y>
143+
<y>190</y>
153144
<width>379</width>
154145
<height>41</height>
155146
</rect>
156147
</property>
157148
<layout class="QHBoxLayout" name="HyperionStreamControl">
149+
<property name="spacing">
150+
<number>0</number>
151+
</property>
152+
<property name="sizeConstraint">
153+
<enum>QLayout::SetDefaultConstraint</enum>
154+
</property>
155+
<property name="topMargin">
156+
<number>0</number>
157+
</property>
158158
<item>
159159
<widget class="QCheckBox" name="AutoStart">
160160
<property name="enabled">

0 commit comments

Comments
 (0)