Skip to content

Commit

Permalink
InfoPage: Add reset settings button and popup
Browse files Browse the repository at this point in the history
Fix #166

Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
  • Loading branch information
patrickelectric committed Jun 24, 2018
1 parent 5b0745c commit 677ed18
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 18 deletions.
142 changes: 124 additions & 18 deletions qml/InfoPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import QtGraphicalEffects 1.0

import Qt.labs.settings 1.0

import Logger 1.0

Item {
Expand Down Expand Up @@ -156,23 +158,25 @@ Item {
Layout.leftMargin: 10

PingImage {
id: forumPost
source: "/icons/chat_white.svg"
id: scrollLock
source: log.scrollLockEnabled ? "/icons/lock_white.svg" : "/icons/unlock_white.svg"
height: 50
width: 50

MouseArea {
id: mouseAreaForumPost
id: mouseAreaScrollLock
anchors.fill: parent
hoverEnabled: true
onEntered: tooltipForumPost.visible = true
onExited: tooltipForumPost.visible = false
onClicked: Qt.openUrlExternally("http://discuss.bluerobotics.com")
onEntered: toolTipScrollLock.visible = true
onExited: toolTipScrollLock.visible = false
onClicked: {
log.scrollLockEnabled = !log.scrollLockEnabled
}
}

ToolTip {
id: tooltipForumPost
text: "Forum"
id: toolTipScrollLock
text: "Scroll Lock"
}
}

Expand All @@ -181,25 +185,23 @@ Item {
}

PingImage {
id: scrollLock
source: log.scrollLockEnabled ? "/icons/lock_white.svg" : "/icons/unlock_white.svg"
id: forumPost
source: "/icons/chat_white.svg"
height: 50
width: 50

MouseArea {
id: mouseAreaScrollLock
id: mouseAreaForumPost
anchors.fill: parent
hoverEnabled: true
onEntered: toolTipScrollLock.visible = true
onExited: toolTipScrollLock.visible = false
onClicked: {
log.scrollLockEnabled = !log.scrollLockEnabled
}
onEntered: tooltipForumPost.visible = true
onExited: tooltipForumPost.visible = false
onClicked: Qt.openUrlExternally("http://discuss.bluerobotics.com")
}

ToolTip {
id: toolTipScrollLock
text: "Scroll Lock"
id: tooltipForumPost
text: "Forum"
}
}

Expand Down Expand Up @@ -227,6 +229,35 @@ Item {
text: "Report issue"
}
}

Item {
Layout.fillWidth: true
}

PingImage {
id: resetSettings
source: "/icons/settings_reset_black.svg"
height: 50
width: 50

MouseArea {
id: mouseAreaResetSettings
anchors.fill: parent
hoverEnabled: true
onEntered: tooltipResetSettings.visible = true
onExited: tooltipResetSettings.visible = false
onClicked: {
print("Reset settings, interface need restart!")
popup.open()
//settings.reset = true
}
}

ToolTip {
id: tooltipResetSettings
text: "Reset settings"
}
}
}

Rectangle {
Expand Down Expand Up @@ -269,6 +300,76 @@ Item {
}
}

Popup {
id: popup
//mainPage
x: (window.width - width)/2
y: (window.height - height)/2
modal: true
focus: true
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent

GroupBox {
id: connGroup
title: "Reset settings"
enabled: true
// Hack
label.x: width/2 - label.contentWidth/2
anchors.fill: parent

GridLayout {
Layout.margins: 15
columns: 5
rowSpacing: 10
columnSpacing: 10
anchors.fill: parent

Text {
text: "This action will reset the appication settings and do a restart of the program, do you want to proceed ?"
clip: true
Layout.maximumWidth: parent.width - 50
Layout.columnSpan: 5
horizontalAlignment: Text.AlignHCenter
Layout.alignment: Qt.AlignHCenter
color: Style.textColor
wrapMode: Text.WordWrap
}

PingButton {
text: "Abort"
Layout.fillWidth: true
Layout.columnSpan: 2
onClicked: {
print("Abort settings reset")
popup.close()
}
}

Item {
Layout.fillWidth: true
Layout.columnSpan: 1
}

PingButton {
text: "Yes"
Layout.fillWidth: true
Layout.columnSpan: 2
onClicked: {
print("Reset settings.")
settings.reset = true
Qt.quit()
}
}

Item {
height: 10
Layout.columnSpan: 5
Layout.fillWidth: true
}
}
}
}

// Used to get text size
Text {
id: font
Expand All @@ -284,4 +385,9 @@ Item {
var link = repository + "/commit/" + id
return createHyperLink(link, id)
}

Settings {
id: settings
property bool reset: false
}
}
1 change: 1 addition & 0 deletions resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<file alias="lock_white.svg">qml/icons/lock_white.svg</file>
<file alias="report_white.svg">qml/icons/report_white.svg</file>
<file alias="settings_white.svg">qml/icons/settings_white.svg</file>
<file alias="settings_reset_black.svg">qml/icons/settings_reset_black.svg</file>
<file alias="unlock_white.svg">qml/icons/unlock_white.svg</file>
</qresource>
<qresource prefix="/imgs">
Expand Down

0 comments on commit 677ed18

Please sign in to comment.