mirror of
https://github.com/monero-project/monero-gui.git
synced 2025-01-10 11:52:05 +02:00
Merge pull request #2879
ca79525
Slider component (xiphon)503c1af
SettingsLayout: implement autosave, enabled by default (10 minutes) (xiphon)
This commit is contained in:
commit
1d3a201077
68
components/Slider.qml
Normal file
68
components/Slider.qml
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
import QtQuick 2.9
|
||||||
|
import QtQuick.Controls 2.0 as QtQuickControls
|
||||||
|
import QtQuick.Layouts 1.1
|
||||||
|
|
||||||
|
import "../components" as MoneroComponents
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
property alias from: slider.from
|
||||||
|
property alias stepSize: slider.stepSize
|
||||||
|
property alias to: slider.to
|
||||||
|
property alias value: slider.value
|
||||||
|
|
||||||
|
property alias text: label.text
|
||||||
|
|
||||||
|
signal moved()
|
||||||
|
|
||||||
|
spacing: 0
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: label
|
||||||
|
color: MoneroComponents.Style.defaultFontColor
|
||||||
|
font.pixelSize: 14
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
|
||||||
|
QtQuickControls.Slider {
|
||||||
|
id: slider
|
||||||
|
leftPadding: 0
|
||||||
|
snapMode: QtQuickControls.Slider.SnapAlways
|
||||||
|
|
||||||
|
background: Rectangle {
|
||||||
|
x: parent.leftPadding
|
||||||
|
y: parent.topPadding + parent.availableHeight / 2 - height / 2
|
||||||
|
implicitWidth: 200
|
||||||
|
implicitHeight: 4
|
||||||
|
width: parent.availableWidth
|
||||||
|
height: implicitHeight
|
||||||
|
radius: 2
|
||||||
|
color: MoneroComponents.Style.progressBarBackgroundColor
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
width: parent.visualPosition * parent.width
|
||||||
|
height: parent.height
|
||||||
|
color: MoneroComponents.Style.green
|
||||||
|
radius: 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handle: Rectangle {
|
||||||
|
x: parent.leftPadding + parent.visualPosition * (parent.availableWidth - width)
|
||||||
|
y: parent.topPadding + parent.availableHeight / 2 - height / 2
|
||||||
|
implicitWidth: 18
|
||||||
|
implicitHeight: 18
|
||||||
|
radius: 8
|
||||||
|
color: parent.pressed ? "#f0f0f0" : "#f6f6f6"
|
||||||
|
border.color: MoneroComponents.Style.grey
|
||||||
|
}
|
||||||
|
|
||||||
|
onMoved: parent.moved()
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
acceptedButtons: Qt.NoButton
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
20
main.qml
20
main.qml
@ -1370,6 +1370,8 @@ ApplicationWindow {
|
|||||||
property int lockOnUserInActivityInterval: 10 // minutes
|
property int lockOnUserInActivityInterval: 10 // minutes
|
||||||
property bool blackTheme: true
|
property bool blackTheme: true
|
||||||
property bool checkForUpdates: true
|
property bool checkForUpdates: true
|
||||||
|
property bool autosave: true
|
||||||
|
property int autosaveMinutes: 10
|
||||||
|
|
||||||
property bool fiatPriceEnabled: false
|
property bool fiatPriceEnabled: false
|
||||||
property bool fiatPriceToggle: false
|
property bool fiatPriceToggle: false
|
||||||
@ -1811,6 +1813,24 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: autosaveTimer
|
||||||
|
interval: persistentSettings.autosaveMinutes * 60 * 1000
|
||||||
|
repeat: true
|
||||||
|
running: persistentSettings.autosave
|
||||||
|
onTriggered: {
|
||||||
|
if (currentWallet) {
|
||||||
|
currentWallet.storeAsync(function(success) {
|
||||||
|
if (success) {
|
||||||
|
appWindow.showStatusMessage(qsTr("Autosaved the wallet"), 3);
|
||||||
|
} else {
|
||||||
|
appWindow.showStatusMessage(qsTr("Failed to autosave the wallet"), 3);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Make the callback dynamic
|
// TODO: Make the callback dynamic
|
||||||
Timer {
|
Timer {
|
||||||
id: statusMessageTimer
|
id: statusMessageTimer
|
||||||
|
@ -94,6 +94,25 @@ Rectangle {
|
|||||||
text: qsTr("Ask for password before sending a transaction") + translationManager.emptyString
|
text: qsTr("Ask for password before sending a transaction") + translationManager.emptyString
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MoneroComponents.CheckBox {
|
||||||
|
checked: persistentSettings.autosave
|
||||||
|
onClicked: persistentSettings.autosave = !persistentSettings.autosave
|
||||||
|
text: qsTr("Autosave") + translationManager.emptyString
|
||||||
|
}
|
||||||
|
|
||||||
|
MoneroComponents.Slider {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.leftMargin: 35
|
||||||
|
Layout.topMargin: 6
|
||||||
|
visible: persistentSettings.autosave
|
||||||
|
from: 1
|
||||||
|
stepSize: 1
|
||||||
|
to: 60
|
||||||
|
value: persistentSettings.autosaveMinutes
|
||||||
|
text: "%1 %2 %3".arg(qsTr("Every")).arg(value).arg(qsTr("minute(s)")) + translationManager.emptyString
|
||||||
|
onMoved: persistentSettings.autosaveMinutes = value
|
||||||
|
}
|
||||||
|
|
||||||
MoneroComponents.CheckBox {
|
MoneroComponents.CheckBox {
|
||||||
id: userInActivityCheckbox
|
id: userInActivityCheckbox
|
||||||
checked: persistentSettings.lockOnUserInActivity
|
checked: persistentSettings.lockOnUserInActivity
|
||||||
@ -101,70 +120,20 @@ Rectangle {
|
|||||||
text: qsTr("Lock wallet on inactivity") + translationManager.emptyString
|
text: qsTr("Lock wallet on inactivity") + translationManager.emptyString
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
MoneroComponents.Slider {
|
||||||
visible: userInActivityCheckbox.checked
|
visible: userInActivityCheckbox.checked
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 6
|
Layout.topMargin: 6
|
||||||
Layout.leftMargin: 42
|
Layout.leftMargin: 35
|
||||||
spacing: 0
|
from: 1
|
||||||
|
stepSize: 1
|
||||||
Text {
|
to: 60
|
||||||
color: MoneroComponents.Style.defaultFontColor
|
value: persistentSettings.lockOnUserInActivityInterval
|
||||||
font.pixelSize: 14
|
text: {
|
||||||
Layout.fillWidth: true
|
var minutes = value > 1 ? qsTr("minutes") : qsTr("minute");
|
||||||
text: {
|
return qsTr("After ") + value + " " + minutes + translationManager.emptyString;
|
||||||
var val = userInactivitySlider.value;
|
|
||||||
var minutes = val > 1 ? qsTr("minutes") : qsTr("minute");
|
|
||||||
|
|
||||||
qsTr("After ") + val + " " + minutes + translationManager.emptyString;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Slider {
|
|
||||||
id: userInactivitySlider
|
|
||||||
from: 1
|
|
||||||
value: persistentSettings.lockOnUserInActivityInterval
|
|
||||||
to: 60
|
|
||||||
leftPadding: 0
|
|
||||||
stepSize: 1
|
|
||||||
snapMode: Slider.SnapAlways
|
|
||||||
|
|
||||||
background: Rectangle {
|
|
||||||
x: parent.leftPadding
|
|
||||||
y: parent.topPadding + parent.availableHeight / 2 - height / 2
|
|
||||||
implicitWidth: 200
|
|
||||||
implicitHeight: 4
|
|
||||||
width: parent.availableWidth
|
|
||||||
height: implicitHeight
|
|
||||||
radius: 2
|
|
||||||
color: MoneroComponents.Style.progressBarBackgroundColor
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
width: parent.visualPosition * parent.width
|
|
||||||
height: parent.height
|
|
||||||
color: MoneroComponents.Style.green
|
|
||||||
radius: 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handle: Rectangle {
|
|
||||||
x: parent.leftPadding + parent.visualPosition * (parent.availableWidth - width)
|
|
||||||
y: parent.topPadding + parent.availableHeight / 2 - height / 2
|
|
||||||
implicitWidth: 18
|
|
||||||
implicitHeight: 18
|
|
||||||
radius: 8
|
|
||||||
color: parent.pressed ? "#f0f0f0" : "#f6f6f6"
|
|
||||||
border.color: MoneroComponents.Style.grey
|
|
||||||
}
|
|
||||||
|
|
||||||
onMoved: persistentSettings.lockOnUserInActivityInterval = userInactivitySlider.value;
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
acceptedButtons: Qt.NoButton
|
|
||||||
hoverEnabled: true
|
|
||||||
cursorShape: Qt.PointingHandCursor
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
onMoved: persistentSettings.lockOnUserInActivityInterval = value
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Manage pricing
|
//! Manage pricing
|
||||||
|
1
qml.qrc
1
qml.qrc
@ -5,6 +5,7 @@
|
|||||||
<file>MiddlePanel.qml</file>
|
<file>MiddlePanel.qml</file>
|
||||||
<file>components/Label.qml</file>
|
<file>components/Label.qml</file>
|
||||||
<file>components/SettingsListItem.qml</file>
|
<file>components/SettingsListItem.qml</file>
|
||||||
|
<file>components/Slider.qml</file>
|
||||||
<file>components/UpdateDialog.qml</file>
|
<file>components/UpdateDialog.qml</file>
|
||||||
<file>images/whatIsIcon.png</file>
|
<file>images/whatIsIcon.png</file>
|
||||||
<file>images/whatIsIcon@2x.png</file>
|
<file>images/whatIsIcon@2x.png</file>
|
||||||
|
Loading…
Reference in New Issue
Block a user