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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
/*
* This file is part of Remote Support Desktop
* https://gitlab.das-netzwerkteam.de/RemoteWebApp/rwa.support.desktopapp
* Copyright 2020 Daniel Teichmann <daniel.teichmann@das-netzwerkteam.de>
* Copyright 2020 Mike Gabriel <mike.gabriel@das-netzwerktea.de>
* SPDX-License-Identifier: GPL-2.0-or-later
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "main_qmladaptor.h"
MainQMLAdaptor::MainQMLAdaptor(QObject *parent, QQmlApplicationEngine* engine) : QObject(parent)
{
_engine = engine;
}
//void MainQMLAdaptor::setSession(Session session) {
// _session = session;
//}
bool MainQMLAdaptor::setConnectButtonEnabled(bool enabled) {
// Find item via 'objectName'
QQuickItem *item = _engine->rootObjects().at(0)->findChild<QQuickItem*>("start_support_button");
if (item) {
item->setProperty("enabled", enabled);
if (item->property("checked").toBool()) {
item->setProperty("text", tr("Stop remote support session"));
} else {
item->setProperty("text", tr("Start remote support session"));
}
} else {
qWarning() << "Unable to find 'start_support_button' Item!";
return false;
}
return true;
}
bool MainQMLAdaptor::setConnectButtonChecked(bool checked) {
// Find item via 'objectName'
QQuickItem *item = _engine->rootObjects().at(0)->findChild<QQuickItem*>("start_support_button");
if (item) {
item->setProperty("checked", checked);
} else {
qWarning() << "Unable to find 'start_support_button' Item!";
return false;
}
return true;
}
bool MainQMLAdaptor::setStatus(QString status) {
// Find item via 'objectName'
QQuickItem *item = _engine->rootObjects().at(0)->findChild<QQuickItem*>("dbus_api_status_text");
if (item) {
item->setProperty("text", status);
} else {
qWarning() << "Unable to find 'dbus_api_status_text' Item!";
return false;
}
return true;
}
bool MainQMLAdaptor::openMessageDialog(QString title, QString text, QMessageBox::Icon icon) {
_messageDialogText = text;
_messageDialogTitle = title;
_messageDialogIcon = icon;
_showMessageDialog = true;
emit messageDialogIconChanged(_messageDialogIcon);
emit messageDialogTitleChanged(_messageDialogTitle);
emit messageDialogTextChanged(_messageDialogText);
emit showMessageDialogChanged(_showMessageDialog);
qDebug() << "Opening MessageDialog!";
return true;
}
QString MainQMLAdaptor::getMessageDialogTitle() {
return _messageDialogTitle;
}
QString MainQMLAdaptor::getMessageDialogText() {
return _messageDialogText;
}
QMessageBox::Icon MainQMLAdaptor::getMessageDialogIcon() {
return _messageDialogIcon;
}
bool MainQMLAdaptor::getShowMessageDialog() {
return _showMessageDialog;
}
bool MainQMLAdaptor::setStatusIndicator(bool active, QColor color) {
// Find item via 'objectName'
QQuickItem *item = _engine->rootObjects().at(0)->findChild<QQuickItem*>("dbus_api_status_indicator");
if (item) {
item->setProperty("active", active);
item->setProperty("color", color);
} else {
qWarning() << "Unable to find 'dbus_api_status_indicator' Item!";
return false;
}
return true;
}
void MainQMLAdaptor::handleCopyToClipboardButtonClick(QString copy_data) {
QClipboard *clipboard = QApplication::clipboard();
QString originalText = clipboard->text();
clipboard->setText(copy_data);
qDebug() << "Copied into clipboard:" << copy_data;
}
void MainQMLAdaptor::handleConnectButtonClick(bool checked) {
emit onConnectButtonClick(checked);
}
void MainQMLAdaptor::setPin(QString pin) {
_pin = pin;
emit pinChanged(pin);
}
void MainQMLAdaptor::setURL(QString URL) {
_url = URL;
emit urlChanged(URL);
}
QString MainQMLAdaptor::getURL() {
return _url;
}
QString MainQMLAdaptor::getPin() {
return _pin;
}
void MainQMLAdaptor::onCloseHandler() {
// Do cleanup things here...
emit onCloseSignal();
}
void MainQMLAdaptor::showToast(QString text, uint durationMs) {
emit showToastSignal(text, QString::number(durationMs));
}
//void MainQMLAdaptor::onCloseHandler() {
// qDebug() << "Inside MainQMLAdaptor::onCloseHandler()";
// // Sending onClose signal to main and there to Session::onCloseHandler()
// emit MainQMLAdaptor::onCloseSignal();
//}
|