Skip to content
Permalink
Browse files

Profile switcher

  • Loading branch information...
martonborzak committed Oct 12, 2019
1 parent 296fb0c commit ca685febdc7c8b44da803ed92a762f88db9b7394
Showing with 287 additions and 38 deletions.
  1. +3 βˆ’18 basic_ui/MainNavigation.qml
  2. +206 βˆ’0 basic_ui/Profiles.qml
  3. 0 basic_ui/ProgressCircle.qml
  4. +2 βˆ’1 basic_ui/StatusBar.qml
  5. +3 βˆ’1 basic_ui/pages/Group.qml
  6. +20 βˆ’2 basic_ui/settings/PowerSaving.qml
  7. +46 βˆ’15 main.qml
  8. +2 βˆ’1 qml.qrc
  9. +2 βˆ’0 remote.pro
  10. +3 βˆ’0 sources/config.h
@@ -22,20 +22,6 @@ Item {
// MENU CONFIGURATION
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

property bool manualRearrange: false

Connections {
target: config

onConfigChanged: {
// if the config is changed, reload the menu
if (manualRearrange != true) {
// compare what is in the listmodel with the config and adjust
// still needs to be done
}
}
}

property alias menuConfig: menuConfig

ListModel {
@@ -68,6 +54,8 @@ Item {
}

function savemenuConfig() {
console.debug("SAVE MENUCONFIG");

var tmp = config.read;

var newConfig = [];
@@ -92,11 +80,10 @@ Item {

config.write = tmp;
config.writeConfig();
manualRearrange = false;
}

Component.onCompleted: {
loadmenuConfig()
loadmenuConfig()
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -123,8 +110,6 @@ Item {
haptic.playEffect("click");
}
onReleased: {
manualRearrange = true;

if (held) {
savemenuConfig()
}
@@ -0,0 +1,206 @@
import QtQuick 2.11
import QtQuick.Controls 2.5

Rectangle {
id: profiles
width: 480
height: 0
color: colorHighlight2
radius: cornerRadius
anchors.bottom: parent.bottom

Component.onCompleted: {
parent.width = width;
parent.height = height;
parent.anchors.bottom = parent.parent.bottom;

for (var value in config.read.ui_config.profiles) {
var v = config.read.ui_config.profiles[value];
v["id"] = value;
profileModel.append(v);
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// STATES
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
state: "closed"


states: [
State { name: "closed";
PropertyChanges {target: profiles; height: 0 }
PropertyChanges {target: parent; height: 0 }
PropertyChanges {target: loader_main; state: "visible" }
},
State { name: "open";
when: parent.status == Loader.Ready
PropertyChanges {target: profiles; height: 670 }
PropertyChanges {target: parent; height: 670 }
PropertyChanges {target: loader_main; state: "hidden" }
}
]
transitions: [
Transition {to: "closed";
SequentialAnimation {
ParallelAnimation {
PropertyAnimation { target: profiles; properties: "height"; easing.type: Easing.OutExpo; duration: 300 }
PropertyAnimation { target: parent; properties: "height"; easing.type: Easing.OutBack; easing.overshoot: 0.8; duration: 300 }
}
PropertyAction { target: loader_second; property: "source"; value: "" }
}
},
Transition {to: "open";
PropertyAnimation { target: profiles; properties: "height"; easing.type: Easing.OutBack; easing.overshoot: 0.8; duration: 300 }
PropertyAnimation { target: parent; properties: "height"; easing.type: Easing.OutBack; easing.overshoot: 0.8; duration: 300 }
}
]

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// UI ELEMENTS
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Text {
id: title
color: colorText
text: qsTr("Profiles") + translateHandler.emptyString
anchors { top: parent.top; topMargin: 30; left: parent.left; leftMargin: 30 }
font {family: "Open Sans Regular"; pixelSize: 60 }
lineHeight: 0.9
}

// PROFILES
ListView {
id: profileListView
width: parent.width-60
height: parent.height
anchors.top: title.bottom
anchors.topMargin: 70
anchors.left: parent.left
anchors.leftMargin: 30
spacing: 30

model: profileModel
delegate: profileDelegate

move: Transition {
NumberAnimation { properties: "y"; easing.type: Easing.OutExpo; duration: 300 }
}
}

// MODEL
ListModel {
id: profileModel
}

// LISTVIEW DELEGATE
Component {
id: profileDelegate

Item {
width: 380
height: id == config.profile ? 100 : 70

Rectangle {
width: parent.width
height: 2
color: colorLight
visible: id == config.profile ? true : false
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
}

Rectangle {
id: img
width: 70
height: 70
radius: width/2
color: id == config.profile ? colorText : colorHighlight1
anchors.top: parent.top
anchors.left: parent.left

Text {
anchors.centerIn: parent
color: id == config.profile ? colorBackground : colorText
text: name.substring(0,1);
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font {family: "Open Sans Bold"; pixelSize: 40 }
}
}

Text {
color: id == config.profile ? colorText : colorHighlight1
text: name
anchors { verticalCenter: img.verticalCenter; left: img.right; leftMargin: 20 }
font {family: "Open Sans Regular"; pixelSize: 27 }
lineHeight: 0.9
}

MouseArea {
anchors.fill: parent

onClicked: {
config.profile = id;
profileModel.move(index, 0, 1);
reloadTimer.start();
// closeTimer.start();
}
}

// Timer {
// id: closeTimer
// interval: 300
// repeat: false
// running: false

// onTriggered: {
// profiles.state = "closed";
// }
// }

}
}

Text {
id: smallText
color: colorText
opacity: 0.5
text: qsTr("To edit your profiles, use the web configurator tool in settings.") + translateHandler.emptyString
wrapMode: Text.WordWrap
width: parent.width - 60
anchors.left: parent.left
anchors.leftMargin: 30
anchors.bottom: parent.bottom
anchors.bottomMargin: 30
font.family: "Open Sans"
font.weight: Font.Normal
font.pixelSize: 20
lineHeight: 1
}

Image {
id: closeButton
asynchronous: true
width: 30
height: 30
fillMode: Image.PreserveAspectFit
source: "qrc:/images/components/close_button.png"
anchors.right: parent.right
anchors.rightMargin: 20
anchors.top: parent.top
anchors.topMargin: 20

MouseArea {
width: parent.width + 60
height: parent.height + 60
anchors.centerIn: parent

onClicked: {
haptic.playEffect("click");
profiles.state = "closed"
}
}
}

}
0 basic_ui/ProgressCircle.qml 100755 β†’ 100644
No changes.
@@ -264,7 +264,8 @@ Item {
}

onPressAndHold: {
console.debug("OPEN PROFILES");
console.debug("LOAD PROFILE");
loader_second.setSource("qrc:/basic_ui/Profiles.qml");
}
}

@@ -133,7 +133,9 @@ Item {

Component.onCompleted: {
var e = entities.get(config.read.ui_config.groups[groupID].entities[index]);
this.setSource("qrc:/components/"+ e.type +"/ui/Button.qml", { "obj": e });
if (e) {
this.setSource("qrc:/components/"+ e.type +"/ui/Button.qml", { "obj": e });
}
}
}
}
@@ -62,6 +62,8 @@ Item {
anchors.topMargin: 114
anchors.horizontalCenter: parent.horizontalCenter

property bool setbyUser: false

background: Rectangle {
x: parent.leftPadding
y: wifioffSlider.topPadding + wifioffSlider.availableHeight / 2 - height / 2
@@ -103,7 +105,14 @@ Item {
onValueChanged: {
var tmp = config.read;
tmp.settings.wifitime = wifioffSlider.value*60;
config.write = tmp;
if (setbyUser) {
config.write = tmp;
setbyUser = false;
}
}

onMoved: {
setbyUser = true;
}

onPressedChanged: {
@@ -177,6 +186,8 @@ Item {
anchors.topMargin: 114
anchors.horizontalCenter: parent.horizontalCenter

property bool setbyUser: false

background: Rectangle {
x: parent.leftPadding
y: shutdownSlider.topPadding + shutdownSlider.availableHeight / 2 - height / 2
@@ -218,7 +229,14 @@ Item {
onValueChanged: {
var tmp = config.read
tmp.settings.shutdowntime = shutdownSlider.value*60*60
config.write = tmp
if (setbyUser) {
config.write = tmp
setbyUser = false;
}
}

onMoved: {
setbyUser = true;
}

onPressedChanged: {

0 comments on commit ca685fe

Please sign in to comment.
You can’t perform that action at this time.