#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("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("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("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("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::onCloseHandler() { // qDebug() << "Inside MainQMLAdaptor::onCloseHandler()"; // // Sending onClose signal to main and there to Session::onCloseHandler() // emit MainQMLAdaptor::onCloseSignal(); //}