1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
#include "osd.h"
#include <QtDebug>
#if 0 //QT_VERSION >= 0x050000
# include <QQuickView>
# include <QQmlContext>
# include <QQuickItem>
#else
# include <QDeclarativeView>
# include <QDeclarativeContext>
# include <QDeclarativeItem>
#endif
OSD::OSD(QObject* parent)
: QObject(parent)
{
m_view = new OSD_VIEWCLASS;
// Qt5 QQuickView: setFlags()
m_view->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::ToolTip);
m_view->rootContext()->setContextProperty("viewerWidget", m_view);
m_view->setSource(QUrl("qrc:/qml/osd.qml"));
QObject* buttonHangup;
buttonHangup = m_view->rootObject()->findChild<QObject*>("hangup");
connect(buttonHangup, SIGNAL(clicked()), this, SLOT(onHangupClicked()));
m_caller = m_view->rootObject()->findChild<QML_ITEMTYPE*>("callerName");
m_time = m_view->rootObject()->findChild<QML_ITEMTYPE*>("callTime");
m_mute = m_view->rootObject()->findChild<QML_ITEMTYPE*>("mute");
connect(m_mute, SIGNAL(clicked()), this, SLOT(onMuteClicked()));
}
OSD::~OSD()
{
delete m_view;
}
void OSD::onHangupClicked()
{
emit hangupClicked();
}
void OSD::onMuteClicked()
{
emit muteClicked();
}
void OSD::setMuted(bool muted)
{
QString path;
if (muted)
path = "qrc:/icons/images/osd_mic_off.png";
else
path = "qrc:/icons/images/osd_mic_on.png";
m_mute->setProperty("image", path);
}
void OSD::setCaller(const QString& text)
{
m_caller->setProperty("text", text);
}
void OSD::setTime(const QString& timeText)
{
m_time->setProperty("text", timeText);
}
void OSD::move(int x, int y)
{
// Qt5 QQuickView: setPosition
m_view->move(x, y);
}
void OSD::show()
{
m_view->show();
}
void OSD::hide()
{
m_view->hide();
}
int OSD::width() const
{
return m_view->width();
}
int OSD::height() const
{
return m_view->height();
}
|