added some more controls

This commit is contained in:
Dorian Zedler 2020-10-12 14:13:52 +02:00
parent 4d0e9bc74f
commit 28595d62bb
Signed by: dorian
GPG key ID: D3B255CB8BC7CD37
3 changed files with 103 additions and 22 deletions

View file

@ -49,7 +49,9 @@ QHash<int, QByteArray> OmobiDisplayTextModel::roleNames() const
{ ColorRole, "color" },
{ AlignmentRole, "alignment" },
{ ScrollRole, "scroll" },
{ ScrollCountRole, "scrollCount" }
{ ScrollSpeedRole, "scrollSpeed" },
{ ScrollCountRole, "scrollCount" },
{ BrightnessRole, "brightness" }
};
return roles;
}
@ -61,7 +63,9 @@ void OmobiDisplayTextModel::append(
QString color,
QString alignment,
bool scroll,
unsigned int scrollCount
unsigned int scrollSpeed,
unsigned int scrollCount,
unsigned int brightness
) {
QMap<int, QVariant> roles = {
{ TextRole, text },
@ -70,7 +74,9 @@ void OmobiDisplayTextModel::append(
{ ColorRole, color },
{ AlignmentRole, alignment },
{ ScrollRole, scroll },
{ ScrollCountRole, scrollCount }
{ ScrollSpeedRole, scrollSpeed },
{ ScrollCountRole, scrollCount },
{ BrightnessRole, brightness }
};
this->append(roles);
@ -113,5 +119,5 @@ void OmobiDisplayTextModel::clear() {
}
QString OmobiDisplayTextModel::getAsJson() {
return "";
}

View file

@ -20,7 +20,9 @@ public:
ColorRole,
AlignmentRole,
ScrollRole,
ScrollCountRole
ScrollSpeedRole,
ScrollCountRole,
BrightnessRole
};
Q_ENUM(QBluetoothLeUartDeviceModelRole)
@ -35,7 +37,9 @@ public:
QString color,
QString alignment,
bool scroll,
unsigned int scrollCount
unsigned int scrollSpeed,
unsigned int scrollCount,
unsigned int brightness
);
void append(const QMap<int, QVariant> &roles);

View file

@ -1,6 +1,6 @@
import QtQuick 2.0
import QtQuick 2.4
import QtQuick.Controls 2.9
import QtQuick.Layouts 1.0
import QtQuick.Layouts 1.9
import de.itsblue.omobidisplayapp 1.0
import QtQuick.Controls.Material 2.0
@ -55,16 +55,14 @@ ListView {
parent: Overlay.overlay
x: (parent.width - width) / 2
y: (parent.height - height) / 2
width: parent.width * 0.6
title: editing ? "Edit item" : "New item"
standardButtons: Dialog.Ok | Dialog.Cancel
width: parent.width
height: parent.height * 0.7
modal: true
title: editing ? "Edit item" : "New item"
onAccepted: {
if(editing) {
editingModel.active = activeSwitch.checked
@ -73,7 +71,9 @@ ListView {
editingModel.color = colorComboBox.currentText
editingModel.alignment = alignmentComboBox.currentText
editingModel.scroll = scrollSwitch.checked
editingModel.scrollSpeed = scrollSpeedSpinBox.value
editingModel.scrollCount = scrollCountSpinBox.value
editingModel.brightness = brightnessSpinBox.value
}
else {
control.model.append(textTextField.text,
@ -82,11 +82,18 @@ ListView {
colorComboBox.currentText,
alignmentComboBox.currentText,
scrollSwitch.checked,
scrollCountSpinBox.value
scrollSpeedSpinBox.value,
scrollCountSpinBox.value,
brightnessSpinBox.value
)
}
}
onDiscarded: {
control.model.remove(0)
popup.close()
}
contentItem: GridLayout {
property int rowHeight: 50
@ -156,6 +163,18 @@ ListView {
Layout.fillWidth: true
}
Label {
font.bold: true
text: "Scroll speed:"
}
SpinBox {
id: scrollSpeedSpinBox
Layout.fillWidth: true
from: 0
to: 10
}
Label {
font.bold: true
text: "Scroll count:"
@ -166,22 +185,70 @@ ListView {
Layout.fillWidth: true
}
Label {
font.bold: true
text: "Brightness:"
}
SpinBox {
id: brightnessSpinBox
Layout.fillWidth: true
from: 0
to: 10
}
}
footer: DialogButtonBox {
// alignment: Qt.AlignHCenter
buttonLayout: DialogButtonBox.GnomeLayout
Button {
flat: true
text: "save"
DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
}
Button {
flat: true
text: "cancel"
DialogButtonBox.buttonRole: DialogButtonBox.RejectRole
}
Button {
visible: popup.editing
Layout.preferredWidth: parent.width * 0.5
Layout.alignment: Layout.Center
Material.background: Material.Red
Material.foreground: "white"
flat: false
text: "delete"
onClicked: {
control.model.remove(0)
popup.close()
DialogButtonBox.buttonRole: DialogButtonBox.DestructiveRole
}
}
enter: Transition {
ParallelAnimation {
NumberAnimation { property: "opacity"; from: 0; to: 1 }
NumberAnimation { property: "y"; from: popup.parent.height - popup.height * 0.75; to: popup.parent.height - popup.height }
}
}
exit: Transition {
ParallelAnimation {
NumberAnimation { property: "opacity"; from: 1; to: 0 }
NumberAnimation { property: "y"; from: popup.parent.height - popup.height; to: popup.parent.height - popup.height * 0.75 }
}
}
function edit(model) {
@ -196,7 +263,9 @@ ListView {
colorComboBox.currentIndex = colorComboBox.model.indexOf(editingModel.color)
alignmentComboBox.currentIndex = alignmentComboBox.model.indexOf(editingModel.alignment)
scrollSwitch.checked = editingModel.scroll
scrollSpeedSpinBox = editingModel.scrollSpeed
scrollCountSpinBox.value = editingModel.scrollCount
brightnessSpinBox = editingModel.brightness
open()
}
@ -214,7 +283,9 @@ ListView {
colorComboBox.currentIndex = 0
alignmentComboBox.currentIndex = 0
scrollSwitch.checked = false
scrollSpeedSpinBox.value = 5
scrollCountSpinBox.value = 0
brightnessSpinBox.value = 10
}
}
}