diff options
author | Daniel Teichmann <daniel.teichmann@das-netzwerkteam.de> | 2020-07-28 04:12:57 +0200 |
---|---|---|
committer | Daniel Teichmann <daniel.teichmann@das-netzwerkteam.de> | 2020-07-28 04:20:10 +0200 |
commit | bff841139a36892603361ef02de2d48ea5798dea (patch) | |
tree | c0e5db4759ec80c4b1e08df4c8c7869f2f429df2 /src | |
parent | a4de2a1cdae7fb3c8ff993cc473a4bb24509f57b (diff) | |
download | RWA.Support.DesktopApp-bff841139a36892603361ef02de2d48ea5798dea.tar.gz RWA.Support.DesktopApp-bff841139a36892603361ef02de2d48ea5798dea.tar.bz2 RWA.Support.DesktopApp-bff841139a36892603361ef02de2d48ea5798dea.zip |
Fully remove 'session' out of QML context
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 5 | ||||
-rw-r--r-- | src/main_qmladaptor.cpp | 19 | ||||
-rw-r--r-- | src/main_qmladaptor.h | 20 | ||||
-rw-r--r-- | src/session.cpp | 17 |
4 files changed, 54 insertions, 7 deletions
diff --git a/src/main.cpp b/src/main.cpp index 51d0b9b..b29c58e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,7 +34,7 @@ int main(int argc, char *argv[]) { //MainQMLAdaptor *main_gui = new MainQMLAdaptor(&app, &engine); // Make mainqmladaptor available to QML engine.rootContext()->setContextProperty("mainqmladaptor", main_gui.data()); - qDebug() << "contextProperty 'mainqmladaptor' set."; + qDebug() << "'mainqmladaptor' is now available in QML context."; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); if (engine.rootObjects().isEmpty()) @@ -42,9 +42,6 @@ int main(int argc, char *argv[]) { QScopedPointer<Session> session (new Session(&app, main_gui.data())); //Session *session = new Session(&app, &engine, main_gui); - // Make 'session' available to QML - engine.rootContext()->setContextProperty("session", session.data()); - qDebug() << "contextProperty 'session' set."; QObject::connect(main_gui.data(), SIGNAL(minimizeWindow()), diff --git a/src/main_qmladaptor.cpp b/src/main_qmladaptor.cpp index 2366b03..ea8f732 100644 --- a/src/main_qmladaptor.cpp +++ b/src/main_qmladaptor.cpp @@ -107,6 +107,25 @@ void MainQMLAdaptor::handleCopyToClipboardButtonClick(QString 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() { // qDebug() << "Inside MainQMLAdaptor::onCloseHandler()"; diff --git a/src/main_qmladaptor.h b/src/main_qmladaptor.h index 630e961..6b90208 100644 --- a/src/main_qmladaptor.h +++ b/src/main_qmladaptor.h @@ -12,7 +12,9 @@ class MainQMLAdaptor : public QObject { Q_OBJECT - Q_PROPERTY(bool showMessageDialog READ getShowMessageDialog NOTIFY showMessageDialogChanged) // this makes showMessageDialog available as a QML property + Q_PROPERTY(QString url READ getURL WRITE setURL NOTIFY urlChanged) // this makes url available as a QML property + Q_PROPERTY(QString pin READ getPin WRITE setPin NOTIFY pinChanged) // this makes pin available as a QML property + Q_PROPERTY(bool showMessageDialog READ getShowMessageDialog NOTIFY showMessageDialogChanged) // this makes showMessageDialog available as a QML property Q_PROPERTY(QString _messageDialogTitle READ getMessageDialogTitle NOTIFY messageDialogTitleChanged) // this makes showMessageDialogTitle available as a QML property Q_PROPERTY(QString _messageDialogText READ getMessageDialogText NOTIFY messageDialogTextChanged) // this makes showMessageDialogText available as a QML property Q_PROPERTY(QMessageBox::Icon _messageDialogIcon READ getMessageDialogIcon NOTIFY messageDialogIconChanged) // this makes showMessageDialogIcon available as a QML property @@ -40,10 +42,16 @@ signals: void minimizeWindow(); + void onConnectButtonClick(bool checked); + + void pinChanged(QString pin); + void urlChanged(QString URL); + // static void onCloseSignal(); -//protected: -// Session _session; +protected: + QString _url; + QString _pin; private: QQmlApplicationEngine* _engine; @@ -54,5 +62,11 @@ private: public slots: void handleCopyToClipboardButtonClick(QString copy_data); + void handleConnectButtonClick(bool checked); + + void setPin(QString pin); + void setURL(QString URL); + QString getURL(); + QString getPin(); // static void onCloseHandler(); }; diff --git a/src/session.cpp b/src/session.cpp index f0d18f3..c87ff71 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -10,6 +10,23 @@ Session::Session(QObject *parent, MainQMLAdaptor* main_gui) : QObject(parent) { statusTimer = new QTimer(this); connect(statusTimer, &QTimer::timeout, this, &Session::statusTimerEvent); + // QML -> MainQMLAdaptor::handleConnectButtonClick --onConnectButtonClick--> this::handleConnectButtonClick + QObject::connect(_main_gui, + SIGNAL(onConnectButtonClick(bool)), + this, + SLOT(handleConnectButtonClick(bool))); + + // session::setPin --pinChanged--> MainQMLAdaptor::setPin --pinChanged--> QML + QObject::connect(this, + SIGNAL(pinChanged(QString)), + main_gui, + SLOT(setPin(QString))); + // session::setURL --urlChanged--> MainQMLAdaptor::setURL --urlChanged--> QML + QObject::connect(this, + SIGNAL(urlChanged(QString)), + main_gui, + SLOT(setURL(QString))); + this->init_vars(); } |