aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Toast.qml15
-rw-r--r--main.qml209
-rw-r--r--qml.qrc1
-rw-r--r--qtquickcontrols2.conf6
-rw-r--r--src/session.cpp47
-rw-r--r--src/session.h2
6 files changed, 114 insertions, 166 deletions
diff --git a/Toast.qml b/Toast.qml
index 044f509..5a4e0db 100644
--- a/Toast.qml
+++ b/Toast.qml
@@ -1,15 +1,18 @@
import QtQuick 2.0
+import QtQuick.Controls 2.0
+import QtQuick.Controls.Material 2.3
/**
* adapted from StackOverflow:
* http://stackoverflow.com/questions/26879266/make-toast-in-android-by-qml
* GitHub Gist: https://gist.github.com/jonmcclung/bae669101d17b103e94790341301c129
+ * Adapted to work with dark/light theming
*/
/**
* @brief An Android-like timed message text in a box that self-destroys when finished if desired
*/
-Rectangle {
+Control {
/**
* Public
@@ -29,6 +32,7 @@ Rectangle {
else {
time = defaultTime;
}
+ console.log("Showing a new toast with display time: " + time);
animation.start();
}
@@ -53,14 +57,17 @@ Rectangle {
}
height: message.height + margin
- radius: margin
+
+ background: Rectangle {
+ color: (Material.theme == Material.Dark) ? "#212121" : "#dcdedc"
+ radius: margin
+ }
opacity: 0
- color: "#222222"
Text {
id: message
- color: "white"
+ color: (Material.theme == Material.Dark) ? "#f1f1f1" : "#010101"
wrapMode: Text.Wrap
horizontalAlignment: Text.AlignHCenter
anchors {
diff --git a/main.qml b/main.qml
index 80a9eca..d653056 100644
--- a/main.qml
+++ b/main.qml
@@ -1,14 +1,11 @@
import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Extras 1.4
-import QtQuick.Controls 2.3
-import QtQuick.Dialogs 1.1
-import QtQuick.Controls.Material 2.0
+import QtQuick.Controls 2.0
+import QtQuick.Dialogs 1.2
+import QtQuick.Controls.Material 2.3
ApplicationWindow {
- Material.theme: Material.Dark
- Material.accent: Material.Blue
-
property int normal_width: 700
property int normal_height: 400
@@ -49,10 +46,10 @@ ApplicationWindow {
id: start_support_button
objectName: "start_support_button"
text: qsTr("Start remote support session")
- anchors.topMargin: parent.height * 0.025
- anchors.left: pin_group.left
- anchors.leftMargin: 0
- anchors.top: pin_group.bottom
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 15
+ anchors.right: parent.right
+ anchors.rightMargin: 15
checkable: true
onClicked: mainqmladaptor.handleConnectButtonClick(checked);
@@ -113,35 +110,38 @@ ApplicationWindow {
enabled: false
anchors.left: parent.left
anchors.leftMargin: 15
- wrapMode: Text.WordWrap
+ wrapMode: Text.WrapAtWordBoundaryOrAnywhere
anchors.verticalCenterOffset: 0
anchors.verticalCenter: parent.verticalCenter
}
Label {
id: dbus_api_status_text
+ y: 350
+ width: parent.width / 2
+ height: 22
+ text: "Unknown state of Service"
+ wrapMode: Text.WrapAtWordBoundaryOrAnywhere
+ verticalAlignment: Text.AlignVCenter
+ font.pointSize: 11
+ fontSizeMode: Text.Fit
+ anchors.leftMargin: 15 + dbus_api_status_indicator.width + 5
objectName: "dbus_api_status_text"
- text: qsTr("Unknown state of service")
- font.family: "Verdana"
anchors.bottom: parent.bottom
anchors.bottomMargin: 15
anchors.left: parent.left
- anchors.leftMargin: 15
- font.pixelSize: 12
- }
- StatusIndicator {
- id: dbus_api_status_indicator
- objectName: "dbus_api_status_indicator"
- width: 15
- height: 15
- color: "#73d216"
- anchors.bottom: dbus_api_status_text.bottom
- anchors.bottomMargin: 0
- anchors.left: dbus_api_status_text.right
- anchors.leftMargin: 5
- visible: true
- active: false
+ StatusIndicator {
+ id: dbus_api_status_indicator
+ width: height
+ height: parent.height
+ objectName: "dbus_api_status_indicator"
+ color: "#73d216"
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.right: parent.left
+ anchors.rightMargin: 5
+ active: false
+ }
}
Item {
@@ -156,17 +156,6 @@ ApplicationWindow {
anchors.right: parent.right
anchors.rightMargin: 0
- Rectangle {
- id: your_url_seperator
- x: 47
- y: 39
- width: 320
- height: 1
- color: "#00000000"
- visible: false
- border.color: "#e6e6e6"
- }
-
Button {
id: copy_url_to_clipboard_button
x: 460
@@ -194,7 +183,7 @@ ApplicationWindow {
onClicked: {
mainqmladaptor.handleCopyToClipboardButtonClick(url_text.text);
- toast.show(qsTr("Copied URL into clipboard!"));
+ toast.show(qsTr("Copied URL into clipboard!"), "1000");
}
ToolTip.text: qsTr("Copy the URL into the clipboard")
@@ -218,7 +207,7 @@ ApplicationWindow {
anchors.left: parent.left
anchors.leftMargin: 0
font.bold: true
- font.pointSize: 14
+ font.pointSize: 13
fontSizeMode: Text.Fit
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
}
@@ -280,7 +269,7 @@ ApplicationWindow {
onClicked: {
mainqmladaptor.handleCopyToClipboardButtonClick(pin_text.text);
- toast.show(qsTr("Copied PIN into clipboard!"));
+ toast.show(qsTr("Copied PIN into clipboard!"), "1000");
}
ToolTip.text: qsTr("Copy the pin into the clipboard")
@@ -325,34 +314,42 @@ ApplicationWindow {
clip: false
fontSizeMode: Text.Fit
}
-
- Rectangle {
- id: your_pin_seperator
- x: 46
- y: 76
- width: 320
- height: 1
- color: "#00000000"
- visible: false
- border.color: "#e6e6e6"
- }
}
- Rectangle {
- id: top_menu_bar_rect
+ Material.theme: theme.position < 1 ? Material.Light : Material.Dark
+
+ Control {
+ id: top_menu_bar_frame
width: parent.width
height: parent.height * 0.10
- color: "#0d5eaf"
+
+ background: Rectangle {
+ color: parent.Material.background
+ border.color: parent.Material.background
+ }
+ Material.background: "#0d5eaf"
+ Material.foreground: "#ffffff"
+
anchors.left: parent.left
anchors.leftMargin: 0
anchors.top: parent.top
anchors.topMargin: 0
+ Switch {
+ id: theme
+ height: parent.height
+ anchors.margins: 10
+ text: "Dark theme"
+ anchors.left: sidemenu_open_button.right
+ anchors.leftMargin: 15
+ anchors.verticalCenter: parent.verticalCenter
+ checked: true
+ }
+
Label {
id: header_text
- y: 19
- width: parent.width * 0.90
height: parent.height
+ color: "#ffffff"
text: qsTr("Allow Remote Control")
padding: 5
font.family: "Verdana"
@@ -392,6 +389,7 @@ ApplicationWindow {
fillMode: Image.PreserveAspectFit
}
}
+
}
Page {
@@ -468,7 +466,6 @@ ApplicationWindow {
onClicked: page.visible = page.visible ? false : true, checked = false
}
}
-
}
@@ -500,96 +497,12 @@ ApplicationWindow {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/*##^## Designer {
D{i:1;anchors_x:0;anchors_y:339}D{i:5;anchors_x:0}D{i:7;anchors_x:15;anchors_y:115}
-D{i:14;anchors_x:47;anchors_y:0}D{i:15;anchors_height:50}D{i:10;anchors_y:154}D{i:19;anchors_height:35;anchors_x:73;anchors_y:35}
-D{i:20;anchors_y:0}D{i:16;anchors_height:35;anchors_width:350;anchors_x:379;anchors_y:183}
-D{i:24;anchors_x:15;anchors_y:17}D{i:22;anchors_x:0;anchors_y:0}
+D{i:11;anchors_height:20;anchors_width:20}D{i:10;anchors_y:154}D{i:14;anchors_x:47;anchors_y:0}
+D{i:15;anchors_height:50}D{i:16;anchors_height:35;anchors_width:350;anchors_x:379;anchors_y:183}
+D{i:19;anchors_height:35;anchors_x:73;anchors_y:35}D{i:18;anchors_height:35;anchors_x:73;anchors_y:35}
+D{i:20;anchors_y:0}D{i:21;anchors_x:0;anchors_y:0}D{i:23;anchors_x:15;anchors_y:17}
+D{i:24;anchors_height:20;anchors_width:200;anchors_x:15;anchors_y:10}
}
##^##*/
diff --git a/qml.qrc b/qml.qrc
index 8302df5..4c1e36c 100644
--- a/qml.qrc
+++ b/qml.qrc
@@ -19,5 +19,6 @@
<file>src/session.h</file>
<file>ToastManager.qml</file>
<file>Toast.qml</file>
+ <file>qtquickcontrols2.conf</file>
</qresource>
</RCC>
diff --git a/qtquickcontrols2.conf b/qtquickcontrols2.conf
new file mode 100644
index 0000000..4e8f8b1
--- /dev/null
+++ b/qtquickcontrols2.conf
@@ -0,0 +1,6 @@
+[Controls]
+Style=Material
+
+[Material]
+Primary=Blue
+Accent=Blue
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();