diff options
author | Daniel Teichmann <daniel.teichmann@das-netzwerkteam.de> | 2020-07-28 03:52:45 +0200 |
---|---|---|
committer | Daniel Teichmann <daniel.teichmann@das-netzwerkteam.de> | 2020-07-28 03:52:45 +0200 |
commit | a4de2a1cdae7fb3c8ff993cc473a4bb24509f57b (patch) | |
tree | 0f14d1db11df5953a5d85c8b63f92ca9624901fd /src | |
parent | 755a279d8588ed68a9ed5e1a12bd3a8c3e7dbd37 (diff) | |
download | RWA.Support.DesktopApp-a4de2a1cdae7fb3c8ff993cc473a4bb24509f57b.tar.gz RWA.Support.DesktopApp-a4de2a1cdae7fb3c8ff993cc473a4bb24509f57b.tar.bz2 RWA.Support.DesktopApp-a4de2a1cdae7fb3c8ff993cc473a4bb24509f57b.zip |
Minimize main window when support partner connects
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 18 | ||||
-rw-r--r-- | src/main_qmladaptor.h | 2 | ||||
-rw-r--r-- | src/session.cpp | 15 | ||||
-rw-r--r-- | src/session.h | 5 |
4 files changed, 30 insertions, 10 deletions
diff --git a/src/main.cpp b/src/main.cpp index a1b1b9f..51d0b9b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -28,20 +28,28 @@ int main(int argc, char *argv[]) { qDebug() << "Unable to load translation"; } - QQmlApplicationEngine engine; - engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); - if (engine.rootObjects().isEmpty()) - return -1; + QQmlApplicationEngine engine(&app); QScopedPointer<MainQMLAdaptor> main_gui (new MainQMLAdaptor(&app, &engine)); //MainQMLAdaptor *main_gui = new MainQMLAdaptor(&app, &engine); // Make mainqmladaptor available to QML engine.rootContext()->setContextProperty("mainqmladaptor", main_gui.data()); + qDebug() << "contextProperty 'mainqmladaptor' set."; + + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + if (engine.rootObjects().isEmpty()) + return -1; - QScopedPointer<Session> session (new Session(&app, &engine, main_gui.data())); + 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()), + engine.rootObjects().takeFirst(), + SLOT(minimizeWindow())); // We don't want users to have multiple instances of this app running QString tmpDirPath = QDir::tempPath() + "/rwa"; diff --git a/src/main_qmladaptor.h b/src/main_qmladaptor.h index 30aae97..630e961 100644 --- a/src/main_qmladaptor.h +++ b/src/main_qmladaptor.h @@ -38,6 +38,8 @@ signals: void messageDialogTitleChanged(QString title); void messageDialogIconChanged(int iconindex); + void minimizeWindow(); + // static void onCloseSignal(); //protected: diff --git a/src/session.cpp b/src/session.cpp index d668e85..f0d18f3 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -2,11 +2,9 @@ #include "session.h" -Session::Session(QObject *parent, QQmlApplicationEngine* engine, MainQMLAdaptor* main_gui) : QObject(parent) { +Session::Session(QObject *parent, MainQMLAdaptor* main_gui) : QObject(parent) { _initDBus(); - _engine = engine; - _main_gui = main_gui; statusTimer = new QTimer(this); @@ -29,6 +27,8 @@ void Session::init_vars() { _main_gui->setConnectButtonEnabled(true); _main_gui->setStatusIndicator(false); + _minimizedBefore = false; + this->statusTimer->stop(); } @@ -55,23 +55,32 @@ void Session::setStatus(QString status) { _main_gui->setStatusIndicator(false); if (status == "running") { + /* Session is running but no one is connected yet */ guiString = tr("Remote Support session is ready to be connected to"); _main_gui->setStatusIndicator(true, QColor(255, 255, 0, 127)); } else if (status == "dead") { + /* Session died */ guiString = tr("Remote Support session was stopped ungracefully"); // Clear current variables this->init_vars(); _main_gui->setStatusIndicator(true, QColor(255, 0, 0, 127)); } else if (status == "stopped") { + /* Session is stopped */ guiString = tr("Remote Support session was stopped"); // Clear current variables this->init_vars(); } else if (status == "active") { + /* Partner is connected */ + if (!_minimizedBefore) { + emit _main_gui->minimizeWindow(); + _minimizedBefore = true; + } guiString = tr("Your partner is connected to the Remote Support session"); _main_gui->setStatusIndicator(true, QColor(0, 255, 0, 127)); } else if (status == "waiting_start_request_answer") { + /* When pressing on start button display following message while waiting */ guiString = tr("Trying to reach session service..."); } diff --git a/src/session.h b/src/session.h index bc9a7cf..b9106ba 100644 --- a/src/session.h +++ b/src/session.h @@ -19,7 +19,7 @@ class Session : public QObject Q_PROPERTY(QString url READ getURL NOTIFY urlChanged ) // this makes url available as a QML property Q_PROPERTY(QString pin READ getPin NOTIFY pinChanged ) // this makes pin available as a QML property public: - explicit Session(QObject *parent, QQmlApplicationEngine *engine = nullptr, MainQMLAdaptor *main_gui = nullptr); + explicit Session(QObject *parent, MainQMLAdaptor *main_gui = nullptr); void init_vars(); QString getStatus(); @@ -46,7 +46,6 @@ protected: QTimer *statusTimer; void statusTimerEvent(); private: - QQmlApplicationEngine* _engine; MainQMLAdaptor* _main_gui; int _id; QString _url; @@ -54,6 +53,8 @@ private: OrgArcticaProjectRWAInterface* _dbus_rwa; void _initDBus(); + bool _minimizedBefore = false; + signals: void finished(); void statusChanged(QString status); |