diff options
author | Daniel Teichmann <daniel.teichmann@das-netzwerkteam.de> | 2020-07-27 17:09:49 +0200 |
---|---|---|
committer | Daniel Teichmann <daniel.teichmann@das-netzwerkteam.de> | 2020-07-27 17:13:25 +0200 |
commit | 7411d37db68911c59016472e3aead0634cf555ae (patch) | |
tree | 72238bf0774ad15a1ac5326ba4607f6caeb7f48f /src/main_qmladaptor.cpp | |
parent | 77eefb1b2364737d824cc4cbefbe4b7bb1fd55b9 (diff) | |
download | RWA.Support.DesktopApp-7411d37db68911c59016472e3aead0634cf555ae.tar.gz RWA.Support.DesktopApp-7411d37db68911c59016472e3aead0634cf555ae.tar.bz2 RWA.Support.DesktopApp-7411d37db68911c59016472e3aead0634cf555ae.zip |
Move sources to src/ && lots of features
Diffstat (limited to 'src/main_qmladaptor.cpp')
-rw-r--r-- | src/main_qmladaptor.cpp | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/src/main_qmladaptor.cpp b/src/main_qmladaptor.cpp new file mode 100644 index 0000000..2366b03 --- /dev/null +++ b/src/main_qmladaptor.cpp @@ -0,0 +1,115 @@ +#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::onCloseHandler() { +// qDebug() << "Inside MainQMLAdaptor::onCloseHandler()"; + +// // Sending onClose signal to main and there to Session::onCloseHandler() +// emit MainQMLAdaptor::onCloseSignal(); +//} |