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

View file

@ -20,7 +20,9 @@ public:
ColorRole, ColorRole,
AlignmentRole, AlignmentRole,
ScrollRole, ScrollRole,
ScrollCountRole ScrollSpeedRole,
ScrollCountRole,
BrightnessRole
}; };
Q_ENUM(QBluetoothLeUartDeviceModelRole) Q_ENUM(QBluetoothLeUartDeviceModelRole)
@ -35,7 +37,9 @@ public:
QString color, QString color,
QString alignment, QString alignment,
bool scroll, bool scroll,
unsigned int scrollCount unsigned int scrollSpeed,
unsigned int scrollCount,
unsigned int brightness
); );
void append(const QMap<int, QVariant> &roles); 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.Controls 2.9
import QtQuick.Layouts 1.0 import QtQuick.Layouts 1.9
import de.itsblue.omobidisplayapp 1.0 import de.itsblue.omobidisplayapp 1.0
import QtQuick.Controls.Material 2.0 import QtQuick.Controls.Material 2.0
@ -55,16 +55,14 @@ ListView {
parent: Overlay.overlay parent: Overlay.overlay
x: (parent.width - width) / 2 x: (parent.width - width) / 2
y: (parent.height - height) / 2
width: parent.width * 0.6 width: parent.width
height: parent.height * 0.7
title: editing ? "Edit item" : "New item"
standardButtons: Dialog.Ok | Dialog.Cancel
modal: true modal: true
title: editing ? "Edit item" : "New item"
onAccepted: { onAccepted: {
if(editing) { if(editing) {
editingModel.active = activeSwitch.checked editingModel.active = activeSwitch.checked
@ -73,7 +71,9 @@ ListView {
editingModel.color = colorComboBox.currentText editingModel.color = colorComboBox.currentText
editingModel.alignment = alignmentComboBox.currentText editingModel.alignment = alignmentComboBox.currentText
editingModel.scroll = scrollSwitch.checked editingModel.scroll = scrollSwitch.checked
editingModel.scrollSpeed = scrollSpeedSpinBox.value
editingModel.scrollCount = scrollCountSpinBox.value editingModel.scrollCount = scrollCountSpinBox.value
editingModel.brightness = brightnessSpinBox.value
} }
else { else {
control.model.append(textTextField.text, control.model.append(textTextField.text,
@ -82,11 +82,18 @@ ListView {
colorComboBox.currentText, colorComboBox.currentText,
alignmentComboBox.currentText, alignmentComboBox.currentText,
scrollSwitch.checked, scrollSwitch.checked,
scrollCountSpinBox.value scrollSpeedSpinBox.value,
scrollCountSpinBox.value,
brightnessSpinBox.value
) )
} }
} }
onDiscarded: {
control.model.remove(0)
popup.close()
}
contentItem: GridLayout { contentItem: GridLayout {
property int rowHeight: 50 property int rowHeight: 50
@ -156,6 +163,18 @@ ListView {
Layout.fillWidth: true Layout.fillWidth: true
} }
Label {
font.bold: true
text: "Scroll speed:"
}
SpinBox {
id: scrollSpeedSpinBox
Layout.fillWidth: true
from: 0
to: 10
}
Label { Label {
font.bold: true font.bold: true
text: "Scroll count:" text: "Scroll count:"
@ -166,22 +185,70 @@ ListView {
Layout.fillWidth: true 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 { Button {
visible: popup.editing visible: popup.editing
Layout.preferredWidth: parent.width * 0.5
Layout.alignment: Layout.Center
Material.background: Material.Red Material.background: Material.Red
Material.foreground: "white" Material.foreground: "white"
flat: false
text: "delete" text: "delete"
onClicked: {
control.model.remove(0) DialogButtonBox.buttonRole: DialogButtonBox.DestructiveRole
popup.close()
} }
} }
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) { function edit(model) {
@ -196,7 +263,9 @@ ListView {
colorComboBox.currentIndex = colorComboBox.model.indexOf(editingModel.color) colorComboBox.currentIndex = colorComboBox.model.indexOf(editingModel.color)
alignmentComboBox.currentIndex = alignmentComboBox.model.indexOf(editingModel.alignment) alignmentComboBox.currentIndex = alignmentComboBox.model.indexOf(editingModel.alignment)
scrollSwitch.checked = editingModel.scroll scrollSwitch.checked = editingModel.scroll
scrollSpeedSpinBox = editingModel.scrollSpeed
scrollCountSpinBox.value = editingModel.scrollCount scrollCountSpinBox.value = editingModel.scrollCount
brightnessSpinBox = editingModel.brightness
open() open()
} }
@ -214,7 +283,9 @@ ListView {
colorComboBox.currentIndex = 0 colorComboBox.currentIndex = 0
alignmentComboBox.currentIndex = 0 alignmentComboBox.currentIndex = 0
scrollSwitch.checked = false scrollSwitch.checked = false
scrollSpeedSpinBox.value = 5
scrollCountSpinBox.value = 0 scrollCountSpinBox.value = 0
brightnessSpinBox.value = 10
} }
} }
} }