aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Teichmann <daniel.teichmann@das-netzwerkteam.de>2020-07-30 07:48:21 +0200
committerDaniel Teichmann <daniel.teichmann@das-netzwerkteam.de>2020-07-30 07:49:53 +0200
commit9bacfb6c56bb1f863eb7ab7ab8d77840f3507b72 (patch)
tree4603fb530621bdb9fe4603e3ae02f7bfc4519976 /src
parentf0dc186cf00fb6952531d124e714cbb2f39b737e (diff)
downloadRWA.Support.DesktopApp-9bacfb6c56bb1f863eb7ab7ab8d77840f3507b72.tar.gz
RWA.Support.DesktopApp-9bacfb6c56bb1f863eb7ab7ab8d77840f3507b72.tar.bz2
RWA.Support.DesktopApp-9bacfb6c56bb1f863eb7ab7ab8d77840f3507b72.zip
Add dark mode
Diffstat (limited to 'src')
-rw-r--r--src/session.cpp47
-rw-r--r--src/session.h2
2 files changed, 35 insertions, 14 deletions
diff --git a/src/session.cpp b/src/session.cpp
index 9b308cd..52f1670 100644
--- a/src/session.cpp
+++ b/src/session.cpp
@@ -68,19 +68,29 @@ QString Session::getPin() {
}
bool Session::isSessionAliveOrRunning(QString status) {
- if (status.length() > 0 && (status == "running" || status == "active")) {
+ if (status == "running" || status == "active") {
return true;
} else {
return false;
}
}
+void Session::minimizeWindow() {
+ if (!_minimizedBefore) {
+ qDebug() << "Minimizing window now...";
+ emit _main_gui->minimizeWindow();
+ _minimizedBefore = true;
+ }
+}
+
void Session::setStatus(QString status) {
_status = status;
QString guiString = tr("Unknown state of service");
_main_gui->setStatusIndicator(false);
+ qDebug() << "setStatus(): Setting status to " << status;
+
if (status == "running") {
/* Session is running but no one is connected yet */
guiString = tr("Remote Support session is ready to be connected to");
@@ -94,6 +104,8 @@ void Session::setStatus(QString status) {
_main_gui->setStatusIndicator(true, QColor(255, 0, 0, 127));
emit _main_gui->showWindow();
+
+ _main_gui->showToast(tr("Remote Support session was stopped ungracefully"), 5000);
} else if (status == "stopped") {
/* Session is stopped */
guiString = tr("Remote Support session was stopped");
@@ -102,15 +114,14 @@ void Session::setStatus(QString status) {
this->init_vars();
emit _main_gui->showWindow();
+
+ _main_gui->showToast(tr("Remote Support session was stopped"), 5000);
} else if (status == "active") {
/* Partner is connected */
- if (!_minimizedBefore) {
- qDebug() << "Minimizing window now...";
- emit _main_gui->minimizeWindow();
- _minimizedBefore = true;
- }
+ QTimer::singleShot(1000, this, &Session::minimizeWindow);
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...");
@@ -119,7 +130,7 @@ void Session::setStatus(QString status) {
guiString = tr("Remote Support session couldn't be started!");
_main_gui->setStatusIndicator(true, QColor(255, 0, 0, 127));
- _main_gui->showToast(tr("An error occured while trying to start a session!"));
+ _main_gui->showToast(tr("An error occured while trying to start a session!"), 5000);
} else if (status == "start_session_success") {
/* Session successfully started */
guiString = tr("Remote Support session successfully started!");
@@ -127,14 +138,16 @@ void Session::setStatus(QString status) {
_main_gui->showToast(tr("Session was started successfully"));
} else if (status == "status_session_error") {
- _main_gui->showToast(tr("Session status could not be refreshed!"));
- guiString = tr("Session status could not be refreshed, remote support partner could still be connected!");
+ /* Session's status couldn't be refreshed */
+ _main_gui->showToast(tr("Session status could not be refreshed!"), 5000);
+ guiString = tr("Session status could not be refreshed!") + "\n" + tr("remote support partner could still be connected!");
_main_gui->setStatusIndicator(true, QColor(255, 0, 0, 127));
emit _main_gui->showWindow();
} else if (status == "stop_session_error") {
- _main_gui->showToast(tr("Session could not be stopped!"));
- guiString = tr("Session could not be stopped, remote support partner could still be connected!");
+ /* Session couldn't be stopped */
+ _main_gui->showToast(tr("Session could not be stopped!"), 5000);
+ guiString = tr("Session could not be stopped!") + "\n" + tr("remote support partner could still be connected!");
_main_gui->setStatusIndicator(true, QColor(255, 0, 0, 127));
emit _main_gui->showWindow();
@@ -311,11 +324,15 @@ void Session::stop_dbus_replied(QDBusPendingCallWatcher *call) {
QJsonDocument doc = QJsonDocument::fromJson(result.toUtf8());
QJsonObject jObject = doc.object();
QVariantMap mainMap = jObject.toVariantMap();
- qDebug() << "Refreshed status:" << mainMap["status"].toString();
- this->setStatus(mainMap["status"].toString());
+
+ QString new_status = mainMap["status"].toString();
+ qDebug() << "stop_dbus_replied(): Refreshed status:" << new_status;
// Clear current variables
this->init_vars();
+
+ // But the status indicator should display that the Session has stopped
+ this->setStatus(new_status);
}
void Session::status_request_dbus(int pid) {
@@ -375,11 +392,13 @@ void Session::status_dbus_replied(QDBusPendingCallWatcher *call) {
QJsonObject jObject = doc.object();
QVariantMap mainMap = jObject.toVariantMap();
QString new_status = mainMap["status"].toString();
- qDebug() << "Refreshed status:" << new_status;
+ qDebug() << "status_dbus_replied(): Refreshed status:" << new_status;
// Enable (dis)connect button
_main_gui->setConnectButtonEnabled(true);
+ this->setStatus(new_status);
+
if (this->isSessionAliveOrRunning(new_status)) {
// Ask status every 1000 millisecond
QTimer::singleShot(1000, this, &Session::statusTimerEvent);
diff --git a/src/session.h b/src/session.h
index 2b39a78..ae92fce 100644
--- a/src/session.h
+++ b/src/session.h
@@ -46,6 +46,7 @@ protected:
QString _status;
void statusTimerEvent();
void init_vars();
+
private:
MainQMLAdaptor* _main_gui;
int _id;
@@ -55,6 +56,7 @@ private:
void _initDBus();
bool _minimizedBefore = false;
+ void minimizeWindow();
signals:
void finished();