- fixed a bug in baseconn
- added volume regulation for base station
This commit is contained in:
parent
575b508d56
commit
ab7154cfd0
9 changed files with 152 additions and 22 deletions
|
@ -53,6 +53,7 @@ private:
|
|||
// helper vars
|
||||
QVariantList qmlTimers;
|
||||
const QStringList remoteSettings = {"ready_en", "ready_delay", "at_marks_en", "at_marks_delay"};
|
||||
const QStringList remoteOnlySettings = {"soundVolume"};
|
||||
|
||||
private slots:
|
||||
// helper functions
|
||||
|
|
|
@ -330,7 +330,7 @@ Popup {
|
|||
|
||||
inputText: autostart_col.loadSetting("ready_delay", ready_del)
|
||||
|
||||
onInputTextChanged: {
|
||||
onInputFinished: {
|
||||
autostart_col.updateSetting("ready_delay", inputText, ready_delay_del)
|
||||
}
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ Popup {
|
|||
|
||||
inputText: autostart_col.loadSetting("at_marks_delay", at_marks_delay_del)
|
||||
|
||||
onInputTextChanged: {
|
||||
onInputFinished: {
|
||||
autostart_col.updateSetting("at_marks_delay", inputText, at_marks_delay_del)
|
||||
}
|
||||
}
|
||||
|
@ -380,8 +380,19 @@ Popup {
|
|||
|
||||
spacing: options_stack.rowSpacing
|
||||
|
||||
function baseConnected(){
|
||||
return speedBackend.baseStationState === "connected"
|
||||
property bool baseConnected: false
|
||||
|
||||
Connections {
|
||||
target: speedBackend
|
||||
|
||||
onBaseStationStateChanged: {
|
||||
if(speedBackend.baseStationState === "connected"){
|
||||
connectCol.baseConnected = true
|
||||
}
|
||||
else {
|
||||
connectCol.baseConnected = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ConnectionDelegate {
|
||||
|
@ -414,7 +425,7 @@ Popup {
|
|||
}
|
||||
|
||||
width: parent.width
|
||||
height: !connectCol.baseConnected() ? options_stack.delegateHeight:0
|
||||
height: !connectCol.baseConnected ? options_stack.delegateHeight:0
|
||||
|
||||
visible: height > 5
|
||||
|
||||
|
@ -426,12 +437,48 @@ Popup {
|
|||
}
|
||||
}
|
||||
|
||||
SmoothSliderDelegate {
|
||||
id: baseStationVolumeDel
|
||||
text: qsTr("volume")
|
||||
|
||||
property bool active: connectCol.baseConnected
|
||||
|
||||
width: parent.width
|
||||
height: active ? options_stack.delegateHeight:0
|
||||
|
||||
visible: height > 5
|
||||
|
||||
sliderValue: 0
|
||||
|
||||
onSliderFinished: {
|
||||
speedBackend.writeSetting("soundVolume", sliderValue)
|
||||
}
|
||||
|
||||
onActiveChanged: {
|
||||
|
||||
if(active){
|
||||
var val = speedBackend.readSetting("soundVolume")
|
||||
console.log(val)
|
||||
if(val !== "false"){
|
||||
sliderValue = parseFloat(val)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on height {
|
||||
NumberAnimation {
|
||||
duration: 400
|
||||
easing.type: Easing.Linear
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NextPageDelegate {
|
||||
id: baseStationConnectionsDel
|
||||
text: qsTr("connected extensions")
|
||||
|
||||
width: parent.width
|
||||
height: connectCol.baseConnected() ? options_stack.delegateHeight:0
|
||||
height: connectCol.baseConnected ? options_stack.delegateHeight:0
|
||||
|
||||
visible: height > 5
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ SmoothItemDelegate {
|
|||
property string inputText: ""
|
||||
property string inputHint: ""
|
||||
|
||||
signal inputFinished()
|
||||
|
||||
property int inputMethodHints: Qt.ImhNone
|
||||
|
||||
property int inputTextFieldWidth: control.width * 0.3
|
||||
|
@ -15,8 +17,6 @@ SmoothItemDelegate {
|
|||
textField.text = inputText
|
||||
}
|
||||
|
||||
text: qsTr("delay (ms)")
|
||||
|
||||
width: parent.width
|
||||
rightPadding: textField.width + width * 0.02
|
||||
height: parent.delegateHeight
|
||||
|
@ -44,6 +44,12 @@ SmoothItemDelegate {
|
|||
control.inputTextChanged()
|
||||
}
|
||||
|
||||
onActiveFocusChanged: {
|
||||
if(!activeFocus){
|
||||
control.inputFinished()
|
||||
}
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
implicitWidth: 200
|
||||
implicitHeight: 40
|
||||
|
|
|
@ -1,5 +1,71 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick.Controls 2.4
|
||||
|
||||
Item {
|
||||
SmoothItemDelegate {
|
||||
id: control
|
||||
|
||||
property double sliderValue: 0.5
|
||||
signal sliderFinished()
|
||||
|
||||
onSliderValueChanged: {
|
||||
slider.value = control.sliderValue
|
||||
}
|
||||
|
||||
rightPadding: slider.width + width * 0.02
|
||||
|
||||
Slider {
|
||||
id: slider
|
||||
|
||||
anchors {
|
||||
right: parent.right
|
||||
rightMargin: parent.width * 0.01
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
height: control.height * 0.4
|
||||
width: parent.width * 0.6
|
||||
|
||||
onValueChanged: {
|
||||
control.sliderValue = value
|
||||
}
|
||||
|
||||
onPressedChanged: {
|
||||
if(!pressed){
|
||||
control.sliderFinished()
|
||||
}
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
x: slider.leftPadding
|
||||
y: slider.topPadding + slider.availableHeight / 2 - height / 2
|
||||
implicitWidth: 200
|
||||
implicitHeight: 4
|
||||
width: slider.availableWidth
|
||||
height: slider.height * 0.2
|
||||
radius: height * 0.5
|
||||
color: "#bdbebf"
|
||||
|
||||
Rectangle {
|
||||
width: slider.visualPosition * parent.width
|
||||
height: parent.height
|
||||
color: "#21be2b"
|
||||
radius: height * 0.5
|
||||
}
|
||||
}
|
||||
|
||||
handle: Rectangle {
|
||||
x: slider.leftPadding + slider.visualPosition * (slider.availableWidth - width)
|
||||
y: slider.topPadding + slider.availableHeight / 2 - height / 2
|
||||
implicitWidth: 26
|
||||
implicitHeight: 26
|
||||
|
||||
width: slider.height
|
||||
height: width
|
||||
|
||||
radius: height * 0.5
|
||||
color: slider.pressed ? "#f0f0f0" : "#f6f6f6"
|
||||
border.color: "#bdbebf"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -212,6 +212,7 @@ Window {
|
|||
scale: 0
|
||||
|
||||
height: !root.landscape()? parent.height*0.17:parent.width*0.17
|
||||
width: status === "disconnected" ? 0:height
|
||||
|
||||
Component.onCompleted: {
|
||||
scale = 1
|
||||
|
@ -222,6 +223,12 @@ Window {
|
|||
duration: 200
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on width {
|
||||
NumberAnimation {
|
||||
duration: 200
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,5 +13,6 @@
|
|||
<file>components/SmoothItemDelegate.qml</file>
|
||||
<file>components/SmoothSwitchDelegate.qml</file>
|
||||
<file>components/InputDelegate.qml</file>
|
||||
<file>components/SmoothSliderDelegate.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -42,7 +42,6 @@ bool BaseConn::connectToHost() {
|
|||
if(timer.remainingTime() == -1){
|
||||
//the time has been triggered -> timeout
|
||||
this->socket->abort();
|
||||
setState("disconnected");
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
@ -50,7 +49,9 @@ bool BaseConn::connectToHost() {
|
|||
timer.stop();
|
||||
connect(this->socket, &QTcpSocket::readyRead, this, &BaseConn::readyRead);
|
||||
this->connection_progress = 100;
|
||||
setState("connected");
|
||||
|
||||
this->setState("connected");
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
@ -113,6 +114,7 @@ QVariantMap BaseConn::sendCommand(int header, QJsonValue data){
|
|||
|
||||
// generate id and witing requests entry
|
||||
int thisId = nextConnectionId;
|
||||
//qDebug() << "sending command: " << header << " with data: " << data << " and id: " << thisId;
|
||||
nextConnectionId ++;
|
||||
|
||||
QEventLoop loop;
|
||||
|
@ -163,7 +165,6 @@ QVariantMap BaseConn::sendCommand(int header, QJsonValue data){
|
|||
|
||||
timer.deleteLater();
|
||||
|
||||
//remoteSessions.release(1);
|
||||
return {{"status", reply.value("header").toInt()}, {"data", reply.value("data").toVariant()}};
|
||||
|
||||
}
|
||||
|
@ -227,7 +228,7 @@ void BaseConn::socketStateChanged(QAbstractSocket::SocketState socketState) {
|
|||
}
|
||||
case QAbstractSocket::ConnectedState:
|
||||
{
|
||||
this->setState("connected");
|
||||
//this->setState("connected");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -470,28 +470,30 @@ double ClimbingRace::getNextStartActionDelayProgress() {
|
|||
void ClimbingRace::writeSetting(QString key, QVariant value) {
|
||||
this->refreshMode();
|
||||
|
||||
if(this->mode == REMOTE && this->remoteSettings.contains(key)){
|
||||
if(this->mode == REMOTE && ( this->remoteSettings.contains(key) || this->remoteOnlySettings.contains(key) ) ){
|
||||
this->baseConn->writeRemoteSetting(key, value.toString());
|
||||
}
|
||||
else {
|
||||
else if(!this->remoteOnlySettings.contains(key)){
|
||||
this->appSettings->writeSetting(key, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QString ClimbingRace::readSetting(QString key) {
|
||||
this->refreshMode();
|
||||
|
||||
if(this->mode == REMOTE && this->remoteSettings.contains(key)){
|
||||
if(this->mode == REMOTE && ( this->remoteSettings.contains(key) || this->remoteOnlySettings.contains(key) )){
|
||||
QVariantMap reply = this->baseConn->sendCommand(3001, key);
|
||||
if(reply["status"] != 200){
|
||||
return "false";
|
||||
}
|
||||
return reply["data"].toString();
|
||||
}
|
||||
else {
|
||||
else if(!this->remoteOnlySettings.contains(key)){
|
||||
return this->appSettings->loadSetting(key);
|
||||
}
|
||||
else {
|
||||
return "false";
|
||||
}
|
||||
}
|
||||
|
||||
bool ClimbingRace::connectBaseStation() {
|
||||
|
|
|
@ -27,7 +27,6 @@ bool SpeedTimer::start(bool force) {
|
|||
this->setState(RUNNING);
|
||||
|
||||
return true;
|
||||
//this->startPad->appendCommand("SET_LED_RUNNING");
|
||||
}
|
||||
|
||||
bool SpeedTimer::stop(int type, bool force) {
|
||||
|
@ -128,7 +127,7 @@ QString SpeedTimer::getText() {
|
|||
QString newText;
|
||||
switch (this->state) {
|
||||
case SpeedTimer::IDLE:
|
||||
newText = "Click Start to start";
|
||||
newText = tr("Click Start to start");
|
||||
break;
|
||||
case SpeedTimer::STARTING:
|
||||
newText = "0.000 sec";
|
||||
|
@ -140,10 +139,10 @@ QString SpeedTimer::getText() {
|
|||
newText = QString::number( this->stoppedTime / 1000.0, 'f', 3 ) + " sec";
|
||||
break;
|
||||
case SpeedTimer::FAILED:
|
||||
newText = "False Start";
|
||||
newText = tr("False Start");
|
||||
break;
|
||||
case SpeedTimer::CANCELLED:
|
||||
newText = "Cancelled";
|
||||
newText = tr("Cancelled");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue