Subversion Repositories tpanel

Rev

Rev 19 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 19 Rev 21
Line 1... Line 1...
1
/*
1
/*
2
 * Copyright (C) 2020 by Andreas Theofilu <andreas@theosys.at>
2
 * Copyright (C) 2020, 2021 by Andreas Theofilu <andreas@theosys.at>
3
 *
3
 *
4
 * This program is free software; you can redistribute it and/or modify
4
 * This program is free software; you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
6
 * the Free Software Foundation; either version 3 of the License, or
7
 * (at your option) any later version.
7
 * (at your option) any later version.
Line 14... Line 14...
14
 * You should have received a copy of the GNU General Public License
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program; if not, write to the Free Software Foundation,
15
 * along with this program; if not, write to the Free Software Foundation,
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
17
 */
17
 */
18
 
18
 
-
 
19
/** @file tqtmain.cpp
-
 
20
 * @brief Implements the surface of the application.
-
 
21
 *
-
 
22
 * This file implements the callback functions of the suface. While the most
-
 
23
 * classes are drawing the elements, the methods here take the ready elements
-
 
24
 * and display them. This file makes the surface completely independent of
-
 
25
 * the rest of the application which makes it easy to change the surface by
-
 
26
 * any other technology.
-
 
27
 */
19
#include <QApplication>
28
#include <QApplication>
20
#include <QByteArray>
29
#include <QByteArray>
21
#include <QCommandLineParser>
30
#include <QCommandLineParser>
22
#include <QCommandLineOption>
31
#include <QCommandLineOption>
23
#include <QLabel>
32
#include <QLabel>
Line 26... Line 35...
26
#include <QMoveEvent>
35
#include <QMoveEvent>
27
#include <QPalette>
36
#include <QPalette>
28
#include <QPixmap>
37
#include <QPixmap>
29
#include <QFont>
38
#include <QFont>
30
#include <QFontDatabase>
39
#include <QFontDatabase>
-
 
40
#include <QtMultimediaWidgets/QVideoWidget>
-
 
41
#include <QtMultimedia/QMediaPlayer>
-
 
42
#include <QtMultimedia/QMediaPlaylist>
-
 
43
#include <QUrl>
31
#include <QThread>
44
#include <QThread>
32
 
45
 
33
#include <functional>
46
#include <functional>
34
#include <mutex>
47
#include <mutex>
35
 
48
 
Line 37... Line 50...
37
#include "tqtmain.h"
50
#include "tqtmain.h"
38
#include "tconfig.h"
51
#include "tconfig.h"
39
#include "tqtsettings.h"
52
#include "tqtsettings.h"
40
#include "tcolor.h"
53
#include "tcolor.h"
41
 
54
 
-
 
55
/**
-
 
56
 * @def __ANDROID__
-
 
57
 * Here we've to define some extra place holders because on Android only 10
-
 
58
 * place holders are defined by default. But we've a callback functions which
-
 
59
 * need 13 place holders. The defination is taken from the original defination
42
static TPageManager *pageManager = nullptr;
60
 * of place holders and expanded.
-
 
61
 */
43
std::mutex draw_mutex;
62
#ifdef __ANDROID__
-
 
63
#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
-
 
64
_LIBCPP_FUNC_VIS extern const std::placeholders::__ph<10> _11;
-
 
65
_LIBCPP_FUNC_VIS extern const std::placeholders::__ph<10> _12;
-
 
66
_LIBCPP_FUNC_VIS extern const std::placeholders::__ph<10> _13;
-
 
67
_LIBCPP_FUNC_VIS extern const std::placeholders::__ph<10> _14;
-
 
68
_LIBCPP_FUNC_VIS extern const std::placeholders::__ph<10> _15;
-
 
69
_LIBCPP_FUNC_VIS extern const std::placeholders::__ph<10> _16;
-
 
70
_LIBCPP_FUNC_VIS extern const std::placeholders::__ph<10> _17;
-
 
71
_LIBCPP_FUNC_VIS extern const std::placeholders::__ph<10> _18;
-
 
72
_LIBCPP_FUNC_VIS extern const std::placeholders::__ph<10> _19;
-
 
73
_LIBCPP_FUNC_VIS extern const _std::placeholders::_ph<10> _20;
-
 
74
#else
-
 
75
/* _LIBCPP_INLINE_VAR */ constexpr std::placeholders::__ph<11>   _11{};
-
 
76
/* _LIBCPP_INLINE_VAR */ constexpr std::placeholders::__ph<12>   _12{};
-
 
77
/* _LIBCPP_INLINE_VAR */ constexpr std::placeholders::__ph<13>   _13{};
-
 
78
/* _LIBCPP_INLINE_VAR */ constexpr std::placeholders::__ph<14>   _14{};
-
 
79
/* _LIBCPP_INLINE_VAR */ constexpr std::placeholders::__ph<15>   _15{};
-
 
80
/* _LIBCPP_INLINE_VAR */ constexpr std::placeholders::__ph<16>   _16{};
-
 
81
/* _LIBCPP_INLINE_VAR */ constexpr std::placeholders::__ph<17>   _17{};
-
 
82
/* _LIBCPP_INLINE_VAR */ constexpr std::placeholders::__ph<18>   _18{};
-
 
83
/* _LIBCPP_INLINE_VAR */ constexpr std::placeholders::__ph<19>   _19{};
-
 
84
/* _LIBCPP_INLINE_VAR */ constexpr std::placeholders::__ph<20>   _20{};
-
 
85
#endif // defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
-
 
86
#endif
-
 
87
 
-
 
88
static TPageManager *pageManager = nullptr;     //!< The pointer to the global defined main class.
-
 
89
std::mutex draw_mutex;                          //!< We're using threads and need to block execution sometimes
44
 
90
 
45
using std::bind;
91
using std::bind;
-
 
92
using std::string;
46
 
93
 
-
 
94
/**
-
 
95
 * @brief qtmain is used here as the entry point for the surface.
-
 
96
 *
-
 
97
 * The main entry function parses the command line parameters, if there were
-
 
98
 * any and sets the basic attributes. It creates the main window and starts the
-
 
99
 * application.
-
 
100
 *
-
 
101
 * @param argc      The number of command line arguments
-
 
102
 * @param argv      A pointer to a 2 dimensional array containing the command
-
 
103
 *                  line parameters.
-
 
104
 * @param pmanager  A pointer to the page manager class which is the main class
-
 
105
 *                  managing everything.
-
 
106
 *
-
 
107
 * @return If no errors occured it returns 0.
-
 
108
 */
47
int qtmain(int argc, char **argv, TPageManager *pmanager)
109
int qtmain(int argc, char **argv, TPageManager *pmanager)
48
{
110
{
49
    DECL_TRACER("qtmain(int argc, char **argv, width, int height)");
111
    DECL_TRACER("qtmain(int argc, char **argv, width, int height)");
50
 
112
 
51
    pageManager = pmanager;
113
    pageManager = pmanager;
52
 
114
 
53
    Q_INIT_RESOURCE(tpanel);
115
//    Q_INIT_RESOURCE(tpanel);
54
#ifdef Q_OS_ANDROID
116
#ifdef Q_OS_ANDROID
55
    QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
117
    QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
56
#endif
118
#endif
57
 
119
 
58
    QApplication app(argc, argv);
120
    QApplication app(argc, argv);
Line 68... Line 130...
68
    MainWindow mainWin;
130
    MainWindow mainWin;
69
    mainWin.show();
131
    mainWin.show();
70
    return app.exec();
132
    return app.exec();
71
}
133
}
72
 
134
 
-
 
135
/**
-
 
136
 * @brief MainWindow::MainWindow constructor
-
 
137
 *
-
 
138
 * This method is the constructor for this class. It registers the callback
-
 
139
 * functions to the class TPageManager and starts the main run loop.
-
 
140
 */
73
MainWindow::MainWindow()
141
MainWindow::MainWindow()
74
{
142
{
75
    DECL_TRACER("MainWindow::MainWindow()");
143
    DECL_TRACER("MainWindow::MainWindow()");
76
 
144
 
77
    pageManager->registerCallbackDB(bind(&MainWindow::_displayButton, this,
145
    pageManager->registerCallbackDB(bind(&MainWindow::_displayButton, this,
Line 112... Line 180...
112
                                         std::placeholders::_6,
180
                                         std::placeholders::_6,
113
                                         std::placeholders::_7,
181
                                         std::placeholders::_7,
114
                                         std::placeholders::_8,
182
                                         std::placeholders::_8,
115
                                         std::placeholders::_9,
183
                                         std::placeholders::_9,
116
                                         std::placeholders::_10,
184
                                         std::placeholders::_10,
-
 
185
#ifdef __ANDROID__
-
 
186
                                         _11,
-
 
187
                                         _12,
-
 
188
                                         _13));
-
 
189
#else
117
                                         std::placeholders::_11,
190
                                         std::placeholders::_11,
118
                                         std::placeholders::_12,
191
                                         std::placeholders::_12,
119
                                         std::placeholders::_13));
192
                                         std::placeholders::_13));
-
 
193
#endif
120
 
194
 
121
    pageManager->regCallDropPage(bind(&MainWindow::_dropPage, this, std::placeholders::_1));
195
    pageManager->regCallDropPage(bind(&MainWindow::_dropPage, this, std::placeholders::_1));
122
    pageManager->regCallDropSubPage(bind(&MainWindow::_dropSubPage, this, std::placeholders::_1));
196
    pageManager->regCallDropSubPage(bind(&MainWindow::_dropSubPage, this, std::placeholders::_1));
-
 
197
    pageManager->regCallPlayVideo(bind(&MainWindow::_playVideo, this,
-
 
198
                                       std::placeholders::_1,
-
 
199
                                       std::placeholders::_2,
-
 
200
                                       std::placeholders::_3,
-
 
201
                                       std::placeholders::_4,
-
 
202
                                       std::placeholders::_5,
-
 
203
                                       std::placeholders::_6,
-
 
204
                                       std::placeholders::_7,
-
 
205
                                       std::placeholders::_8,
-
 
206
                                       std::placeholders::_9));
123
 
207
 
124
    createActions();
208
    createActions();
125
 
209
 
126
#ifndef QT_NO_SESSIONMANAGER
210
#ifndef QT_NO_SESSIONMANAGER
127
    QGuiApplication::setFallbackSessionManagementEnabled(false);
211
    QGuiApplication::setFallbackSessionManagementEnabled(false);
Line 145... Line 229...
145
        connect(this, &MainWindow::sigSetSubPage, this, &MainWindow::setSubPage);
229
        connect(this, &MainWindow::sigSetSubPage, this, &MainWindow::setSubPage);
146
        connect(this, &MainWindow::sigSetBackground, this, &MainWindow::setBackground);
230
        connect(this, &MainWindow::sigSetBackground, this, &MainWindow::setBackground);
147
        connect(this, &MainWindow::sigSetText, this, &MainWindow::setText);
231
        connect(this, &MainWindow::sigSetText, this, &MainWindow::setText);
148
        connect(this, &MainWindow::sigDropPage, this, &MainWindow::dropPage);
232
        connect(this, &MainWindow::sigDropPage, this, &MainWindow::dropPage);
149
        connect(this, &MainWindow::sigDropSubPage, this, &MainWindow::dropSubPage);
233
        connect(this, &MainWindow::sigDropSubPage, this, &MainWindow::dropSubPage);
-
 
234
        connect(this, &MainWindow::sigPlayVideo, this, &MainWindow::playVideo);
150
    }
235
    }
151
    catch (std::exception& e)
236
    catch (std::exception& e)
152
    {
237
    {
153
        MSG_ERROR("Connection error: " << e.what());
238
        MSG_ERROR("Connection error: " << e.what());
154
    }
239
    }
155
 
240
 
156
    setUnifiedTitleAndToolBarOnMac(true);
241
    setUnifiedTitleAndToolBarOnMac(true);
157
    pageManager->run();
242
    pageManager->run();
158
}
243
}
159
 
244
 
-
 
245
/**
-
 
246
 * @brief MainWindow::closeEvent called when the application receives an exit event.
-
 
247
 *
-
 
248
 * If the user clicks on the exit icon or on the menu point _Exit_ this method
-
 
249
 * is called. It makes sure everything is written to the configuration file
-
 
250
 * and accepts the evernt.
-
 
251
 *
-
 
252
 * @param event The exit event
-
 
253
 */
160
void MainWindow::closeEvent(QCloseEvent *event)
254
void MainWindow::closeEvent(QCloseEvent *event)
161
{
255
{
162
    DECL_TRACER("MainWindow::closeEvent(QCloseEvent *event)");
256
    DECL_TRACER("MainWindow::closeEvent(QCloseEvent *event)");
163
 
257
 
164
    if (settingsChanged)
258
    if (settingsChanged)
Line 167... Line 261...
167
        event->accept();
261
        event->accept();
168
    }
262
    }
169
    else
263
    else
170
    {
264
    {
171
//      event->ignore();
265
//      event->ignore();
-
 
266
        prg_stopped = true;
-
 
267
        MSG_TRACE("Program will stop!");
172
        event->accept();
268
        event->accept();
173
    }
269
    }
174
}
270
}
175
 
271
 
-
 
272
/**
-
 
273
 * @brief MainWindow::eventFilter filters the QEvent::MouseMove event
-
 
274
 * @param obj   The object where the event occured.
-
 
275
 * @param event The event.
-
 
276
 * @return `true` when the event should be ignored.
-
 
277
 */
176
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
278
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
177
{
279
{
178
//    DECL_TRACER("MainWindow::eventFilter(QObject *obj, QEvent *event)");
280
//    DECL_TRACER("MainWindow::eventFilter(QObject *obj, QEvent *event)");
179
 
281
 
180
    if (event->type() == QEvent::MouseMove)
282
    if (event->type() == QEvent::MouseMove)
181
        return true;    // Filter event out, i.e. stop it being handled further.
283
        return true;    // Filter event out, i.e. stop it being handled further.
182
 
284
 
183
    return QMainWindow::eventFilter(obj, event);
285
    return QMainWindow::eventFilter(obj, event);
184
}
286
}
185
 
287
 
-
 
288
/**
-
 
289
 * @brief MainWindow::createActions creates the configuration dialog window.
-
 
290
 */
186
void MainWindow::createActions()
291
void MainWindow::createActions()
187
{
292
{
188
    DECL_TRACER("MainWindow::createActions()");
293
    DECL_TRACER("MainWindow::createActions()");
189
 
294
 
190
    // Add a menu
295
    // Add a menu
Line 209... Line 314...
209
    QAction *exitAct = editMenu->addAction(exitIcon, tr("E&xit"), this, &QWidget::close);
314
    QAction *exitAct = editMenu->addAction(exitIcon, tr("E&xit"), this, &QWidget::close);
210
    exitAct->setShortcuts(QKeySequence::Quit);
315
    exitAct->setShortcuts(QKeySequence::Quit);
211
    exitAct->setStatusTip(tr("Exit the application"));
316
    exitAct->setStatusTip(tr("Exit the application"));
212
}
317
}
213
 
318
 
-
 
319
/**
-
 
320
 * @brief MainWindow::mousePressEvent catches the event Qt::LeftButton.
-
 
321
 *
-
 
322
 * If the user presses the left mouse button somewhere in the main window, this
-
 
323
 * method is triggered. It retrieves the position of the mouse pointer and
-
 
324
 * sends it to the page manager TPageManager.
-
 
325
 *
-
 
326
 * @param event The event
-
 
327
 */
214
void MainWindow::mousePressEvent(QMouseEvent* event)
328
void MainWindow::mousePressEvent(QMouseEvent* event)
215
{
329
{
216
    if(event->button() == Qt::LeftButton)
330
    if(event->button() == Qt::LeftButton)
217
    {
331
    {
218
        pageManager->mouseEvent(event->x(), event->y(), true);
332
        pageManager->mouseEvent(event->x(), event->y(), true);
219
    }
333
    }
220
}
334
}
221
 
335
 
-
 
336
/**
-
 
337
 * @brief MainWindow::mouseReleaseEvent catches the event Qt::LeftButton.
-
 
338
 *
-
 
339
 * If the user releases the left mouse button somewhere in the main window, this
-
 
340
 * method is triggered. It retrieves the position of the mouse pointer and
-
 
341
 * sends it to the page manager TPageManager.
-
 
342
 *
-
 
343
 * @param event The event
-
 
344
 */
222
void MainWindow::mouseReleaseEvent(QMouseEvent* event)
345
void MainWindow::mouseReleaseEvent(QMouseEvent* event)
223
{
346
{
224
    if(event->button() == Qt::LeftButton)
347
    if(event->button() == Qt::LeftButton)
225
    {
348
    {
226
        pageManager->mouseEvent(event->x(), event->y(), false);
349
        pageManager->mouseEvent(event->x(), event->y(), false);
227
    }
350
    }
228
}
351
}
229
 
352
 
-
 
353
/**
-
 
354
 * @brief MainWindow::settings initiates the configuration dialog.
-
 
355
 */
230
void MainWindow::settings()
356
void MainWindow::settings()
231
{
357
{
232
    DECL_TRACER("MainWindow::settings()");
358
    DECL_TRACER("MainWindow::settings()");
233
 
359
 
234
    TQtSettings *dlg_settings = new TQtSettings(this);
360
    TQtSettings *dlg_settings = new TQtSettings(this);
235
    dlg_settings->show();
361
    dlg_settings->show();
236
}
362
}
237
 
363
 
-
 
364
/**
-
 
365
 * @brief MainWindow::writeSettings Writes the settings into the configuration file.
-
 
366
 */
238
void MainWindow::writeSettings()
367
void MainWindow::writeSettings()
239
{
368
{
240
    DECL_TRACER("MainWindow::writeSettings()");
369
    DECL_TRACER("MainWindow::writeSettings()");
241
}
370
}
242
 
371
 
-
 
372
/**
-
 
373
 * @brief MainWindow::about displays the _about_ dialog.
-
 
374
 */
243
void MainWindow::about()
375
void MainWindow::about()
244
{
376
{
245
    DECL_TRACER("MainWindow::about()");
377
    DECL_TRACER("MainWindow::about()");
246
 
378
 
247
    QMessageBox::about(this, tr(std::string("About ").append(TConfig::getProgName()).c_str()),
379
    QMessageBox::about(this, tr(std::string("About ").append(TConfig::getProgName()).c_str()),
Line 254... Line 386...
254
 
386
 
255
void MainWindow::_displayButton(ulong handle, ulong parent, unsigned char* buffer, int width, int height, int pixline, int left, int top)
387
void MainWindow::_displayButton(ulong handle, ulong parent, unsigned char* buffer, int width, int height, int pixline, int left, int top)
256
{
388
{
257
    DECL_TRACER("MainWindow::_displayButton(ulong handle, ulong parent, unsigned char* buffer, int width, int height, int pixline, int left, int top)");
389
    DECL_TRACER("MainWindow::_displayButton(ulong handle, ulong parent, unsigned char* buffer, int width, int height, int pixline, int left, int top)");
258
 
390
 
-
 
391
    if (prg_stopped)
-
 
392
        return;
-
 
393
 
259
    QByteArray buf;
394
    QByteArray buf;
260
 
395
 
261
    if (buffer && pixline > 0)
396
    if (buffer && pixline > 0)
262
    {
397
    {
263
        size_t size = width * height * (pixline / width);
398
        size_t size = width * height * (pixline / width);
Line 277... Line 412...
277
 
412
 
278
void MainWindow::_setPage(ulong handle, int width, int height)
413
void MainWindow::_setPage(ulong handle, int width, int height)
279
{
414
{
280
    DECL_TRACER("MainWindow::_setPage(ulong handle, int width, int height)");
415
    DECL_TRACER("MainWindow::_setPage(ulong handle, int width, int height)");
281
 
416
 
-
 
417
    if (prg_stopped)
-
 
418
        return;
-
 
419
 
282
    emit sigSetPage(handle, width, height);
420
    emit sigSetPage(handle, width, height);
283
}
421
}
284
 
422
 
285
void MainWindow::_setSubPage(ulong handle, int left, int top, int width, int height)
423
void MainWindow::_setSubPage(ulong handle, int left, int top, int width, int height)
286
{
424
{
287
    DECL_TRACER("MainWindow::_setSubPage(ulong handle, int left, int top, int width, int height)");
425
    DECL_TRACER("MainWindow::_setSubPage(ulong handle, int left, int top, int width, int height)");
288
 
426
 
-
 
427
    if (prg_stopped)
-
 
428
        return;
-
 
429
 
289
    emit sigSetSubPage(handle, left, top, width, height);
430
    emit sigSetSubPage(handle, left, top, width, height);
290
}
431
}
291
 
432
 
292
void MainWindow::_setBackground(ulong handle, unsigned char *image, size_t size, size_t rowBytes, ulong color)
433
void MainWindow::_setBackground(ulong handle, unsigned char *image, size_t size, size_t rowBytes, ulong color)
293
{
434
{
294
    DECL_TRACER("MainWindow::_setBackground(ulong handle, unsigned char *image, size_t size, size_t rowBytes, ulong color)");
435
    DECL_TRACER("MainWindow::_setBackground(ulong handle, unsigned char *image, size_t size, size_t rowBytes, ulong color)");
295
 
436
 
-
 
437
    if (prg_stopped)
-
 
438
        return;
-
 
439
 
296
    QByteArray buf;
440
    QByteArray buf;
297
 
441
 
298
    if (image && size > 0)
442
    if (image && size > 0)
299
        buf.insert(0, (const char *)image, size);
443
        buf.insert(0, (const char *)image, size);
300
 
444
 
Line 303... Line 447...
303
 
447
 
304
void MainWindow::_setText(ulong handle, const std::string& text, const std::string& font, const std::string& family, int size, int x, int y, ulong color, ulong effectColor, FONT_STYLE style, Button::TEXT_ORIENTATION ori, Button::TEXT_EFFECT effect, bool ww)
448
void MainWindow::_setText(ulong handle, const std::string& text, const std::string& font, const std::string& family, int size, int x, int y, ulong color, ulong effectColor, FONT_STYLE style, Button::TEXT_ORIENTATION ori, Button::TEXT_EFFECT effect, bool ww)
305
{
449
{
306
    DECL_TRACER("MainWindow::_setText(ulong handle, const std::string& text, const std::string& font, const std::string& family, int size, int x, int y, ulong color, ulong effectColor, FONT_STYLE style, Button::TEXT_ORIENTATION ori, Button::TEXT_EFFECT effect, bool ww)");
450
    DECL_TRACER("MainWindow::_setText(ulong handle, const std::string& text, const std::string& font, const std::string& family, int size, int x, int y, ulong color, ulong effectColor, FONT_STYLE style, Button::TEXT_ORIENTATION ori, Button::TEXT_EFFECT effect, bool ww)");
307
 
451
 
-
 
452
    if (prg_stopped)
-
 
453
        return;
-
 
454
 
308
    emit sigSetText(handle, text, font, family, size, x, y, color, effectColor, style, ori, effect, ww);
455
    emit sigSetText(handle, text, font, family, size, x, y, color, effectColor, style, ori, effect, ww);
309
}
456
}
310
 
457
 
311
void MainWindow::_dropPage(ulong handle)
458
void MainWindow::_dropPage(ulong handle)
312
{
459
{
Line 320... Line 467...
320
    DECL_TRACER("MainWindow::_dropSubPage(ulong handle)");
467
    DECL_TRACER("MainWindow::_dropSubPage(ulong handle)");
321
 
468
 
322
    emit sigDropSubPage(handle);
469
    emit sigDropSubPage(handle);
323
}
470
}
324
 
471
 
-
 
472
void MainWindow::_playVideo(ulong handle, ulong parent, int left, int top, int width, int height, const string& url, const string& user, const string& pw)
-
 
473
{
-
 
474
    DECL_TRACER("MainWindow::_playVideo(ulong handle, const string& url)");
-
 
475
 
-
 
476
    if (prg_stopped)
-
 
477
        return;
-
 
478
 
-
 
479
    emit sigPlayVideo(handle, parent, left, top, width, height, url, user, pw);
-
 
480
}
-
 
481
 
325
/******************* Draw elements *************************/
482
/******************* Draw elements *************************/
326
 
483
 
327
void MainWindow::displayButton(ulong handle, ulong parent, QByteArray buffer, int width, int height, int pixline, int left, int top)
484
void MainWindow::displayButton(ulong handle, ulong parent, QByteArray buffer, int width, int height, int pixline, int left, int top)
328
{
485
{
329
    draw_mutex.lock();
486
    draw_mutex.lock();
Line 333... Line 490...
333
    OBJECT_t *par = findObject(parent);
490
    OBJECT_t *par = findObject(parent);
334
    MSG_DEBUG("Processing button " << handleToString(handle) << " from parent " << handleToString(parent));
491
    MSG_DEBUG("Processing button " << handleToString(handle) << " from parent " << handleToString(parent));
335
 
492
 
336
    if (!par)
493
    if (!par)
337
    {
494
    {
338
        MSG_WARNING("Button has no parent! Ignoring it.");
495
        MSG_WARNING("Button " << handle << " has no parent (" << parent << ")! Ignoring it.");
339
        draw_mutex.unlock();
496
        draw_mutex.unlock();
340
        return;
497
        return;
341
    }
498
    }
342
 
499
 
343
    if (!obj)
500
    if (!obj)
Line 689... Line 846...
689
    dropContent(obj);
846
    dropContent(obj);
690
    removeObject(handle);
847
    removeObject(handle);
691
    draw_mutex.unlock();
848
    draw_mutex.unlock();
692
}
849
}
693
 
850
 
-
 
851
void MainWindow::playVideo(ulong handle, ulong parent, int left, int top, int width, int height, const string& url, const string& user, const string& pw)
-
 
852
{
-
 
853
    draw_mutex.lock();
-
 
854
    DECL_TRACER("MainWindow::playVideo(ulong handle, const string& url, const string& user, const string& pw))");
-
 
855
 
-
 
856
    OBJECT_t *obj = findObject(handle);
-
 
857
    OBJECT_t *par = findObject(parent);
-
 
858
    MSG_DEBUG("Processing button " << handleToString(handle) << " from parent " << handleToString(parent));
-
 
859
 
-
 
860
    if (!par)
-
 
861
    {
-
 
862
        MSG_WARNING("Button has no parent! Ignoring it.");
-
 
863
        draw_mutex.unlock();
-
 
864
        return;
-
 
865
    }
-
 
866
 
-
 
867
    if (!obj)
-
 
868
    {
-
 
869
        MSG_DEBUG("Adding new video object ...");
-
 
870
        obj = addObject();
-
 
871
 
-
 
872
        if (!obj)
-
 
873
        {
-
 
874
            MSG_ERROR("Error creating a video object!");
-
 
875
            TError::setError();
-
 
876
            draw_mutex.unlock();
-
 
877
            return;
-
 
878
        }
-
 
879
 
-
 
880
        obj->type = OBJ_VIDEO;
-
 
881
        obj->handle = handle;
-
 
882
        obj->width = width;
-
 
883
        obj->height = height;
-
 
884
        obj->left = left;
-
 
885
        obj->top = top;
-
 
886
        obj->object.vwidget = new QVideoWidget(par->object.widget);
-
 
887
        obj->object.vwidget->installEventFilter(this);
-
 
888
    }
-
 
889
    else
-
 
890
        MSG_DEBUG("Object " << handleToString(handle) << " of type " << objectToString(obj->type) << " found!");
-
 
891
 
-
 
892
    QMediaPlaylist *playlist = new QMediaPlaylist;
-
 
893
    QUrl qurl(url.c_str());
-
 
894
 
-
 
895
    if (!user.empty())
-
 
896
        qurl.setUserName(user.c_str());
-
 
897
 
-
 
898
    if (!pw.empty())
-
 
899
        qurl.setPassword(pw.c_str());
-
 
900
 
-
 
901
    playlist->addMedia(qurl);
-
 
902
    obj->player = new QMediaPlayer;
-
 
903
    obj->player->setPlaylist(playlist);
-
 
904
    obj->player->setVideoOutput(obj->object.vwidget);
-
 
905
    obj->object.vwidget->show();
-
 
906
    obj->player->play();
-
 
907
}
-
 
908
 
694
#ifndef QT_NO_SESSIONMANAGER
909
#ifndef QT_NO_SESSIONMANAGER
695
void MainWindow::commitData(QSessionManager &manager)
910
void MainWindow::commitData(QSessionManager &manager)
696
{
911
{
697
    if (manager.allowsInteraction())
912
    if (manager.allowsInteraction())
698
    {
913
    {