Commit 5353bfc0 authored by Leander Schulten's avatar Leander Schulten
Browse files

Weiterentwicklung der Oberfläche.

parent 1300e996
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
ModelView{
id:modelView
model:devicePrototypeModel
ListView{
clip:true
Layout.column: 2
Layout.columnSpan: 2
Layout.row: 2
Layout.fillHeight: true
Layout.fillWidth: true
id : channelView
delegate: ItemDelegate{
width: parent.width
text: index + " :"
onClicked: channelView.currentIndex = index
TextInputField{
x:parent.implicitWidth-15
anchors.baseline: parent.baseline
visible: true
text : name
underlineColor: parent.ListView.isCurrentItem?"lightgreen":"lightgrey"
onCursorPositionChanged: {
//if(focus)
channelView.currentIndex = index;
//focus = true;*/
}
onTextChanged: name = text
}
}
model: modelView.currentItem.data.channel
}
onAddClicked: ModelManager.addDevicePrototype("New DevicePrototype");
RowLayout{
Layout.row: 3
Layout.column: 2
Layout.columnSpan: 2
Layout.fillWidth: true
Button{
Layout.fillWidth: true
text:"+"
font.pixelSize: 15
onClicked: modelView.currentItem.data.pushChannel("te34324324327st")
}
Button{
Layout.fillWidth: true
text:"-"
font.pixelSize: 15
onClicked: modelView.currentItem.data.popChannel()
}
}
}
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
import QtQuick.Dialogs 1.2
ModelView{
id: deviceModelView
model:deviceModel
rows: 6
rows: 7
onAddClicked:dialog.visible = true
Text{
Layout.row: 2
Layout.column: 2
......@@ -34,5 +37,115 @@ ModelView{
Layout.column: 3
text:parent.currentItem.data.prototype.name
font.pixelSize: 15
TextUnderline{
extendetWidth:1
color:"lightgrey"
}
}
Text{
Layout.row: 4
Layout.column: 2
text:"Position:"
Layout.rightMargin: 20
font.pixelSize: 15
}
RowLayout{
Layout.row: 4
Layout.column: 3
Text{
text:"x:"
font.pixelSize: 15
}
TextInputField{
Layout.minimumWidth: 50
text:deviceModelView.currentItem.data.position.x
validator: IntValidator{}
onTextChanged: deviceModelView.currentItem.data.position.x = text.length?text:0
}
Text{
Layout.leftMargin: 10
text:"y:"
font.pixelSize: 15
}
TextInputField{
text:deviceModelView.currentItem.data.position.y
validator: IntValidator{}
onTextChanged: deviceModelView.currentItem.data.position.y = text.length?text:0
}
}
Dialog{
modality: Qt.WindowModal
id:dialog
title: "Hallo"
width:300
contentItem: RowLayout {
Pane{
Layout.fillWidth: true
ColumnLayout{
anchors.left: parent.left
anchors.right: parent.right
spacing: 10
ComboBox{
Layout.fillWidth: true
id:prototype
model: devicePrototypeModel
textRole: "display"
}
RowLayout{
Label{
id:nameLabel
text:"Name :"
}
TextInputField{
Layout.fillWidth: true
id:name
}
}
RowLayout{
Label{
text:"Description :"
}
TextInputField{
Layout.fillWidth: true
id:description
}
}
RowLayout{
Label{
text:"Start DMX Channel :"
}
TextInputField{
Layout.fillWidth: true
id:dmx
validator: IntValidator{
bottom: 0
top:1024
}
}
}
RowLayout{
Button{
Layout.fillWidth: true
text:"Abbrechen"
onClicked: dialog.visible = false
}
Button{
Layout.fillWidth: true
text:"Erzeugen"
onClicked: {
if(name.text===""){
name.underlineColor = "red";
}else{
dialog.visible = false;
ModelManager.addDevice(prototype.currentIndex,dmx.text,name.text,description.text);
}
}
}
}
}
}
}
}
}
......@@ -26,7 +26,8 @@ SOURCES += main.cpp \
dmxchannelfilter.cpp \
syncservice.cpp \
usermanagment.cpp \
channelprogrammeditor.cpp
channelprogrammeditor.cpp \
modelmanager.cpp
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked deprecated (the exact warnings
......@@ -52,7 +53,8 @@ HEADERS += \
syncservice.h \
dmxchannelfilter.h \
usermanagment.h \
channelprogrammeditor.h
channelprogrammeditor.h \
modelmanager.h
# Default rules for deployment.
......@@ -60,4 +62,6 @@ qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
DISTFILES +=
......@@ -8,18 +8,22 @@ GridLayout{
rowSpacing: 5
columns: 4
rows: 4
signal addClicked()
property alias model : listView.model
property alias currentItem : listView.currentItem
property Button addButton: buttonAdd
property alias listView : listView
ListView{
Layout.fillHeight: true
Layout.preferredWidth: 300
Layout.preferredWidth: Math.max(300,implicitWidth)
Layout.columnSpan: 2
Layout.rowSpan: parent.rows-1
id:listView
delegate: ItemDelegate{
property var data: modelData
property var data: itemData
width: parent.width
text: modelData.name +"("+modelData.description+")"
text: itemData.name +"("+itemData.description+")"
onClicked: listView.currentIndex = index
}
......@@ -32,18 +36,20 @@ GridLayout{
Button{
Layout.row: parent.rows-1
Layout.column: 0
Layout.preferredWidth: 150
Layout.preferredWidth: listView.width/2
id: buttonAdd
text:"+"
font.pixelSize: 15
onClicked: addClicked(3)
}
Button{
Layout.row: parent.rows-1
Layout.column: 1
Layout.preferredWidth: 150
Layout.preferredWidth: listView.width/2
id: buttonRemove
text:"-"
font.pixelSize: 15
onClicked: ModelManager.remove(listView.currentItem.data)
}
......
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
import QtQuick.Dialogs 1.2
import custom.licht 1.0
ModelView{
model:programmPrototypeModel
id:modelView
ListView{
clip:true
Layout.column: 2
Layout.columnSpan: 2
Layout.row: 2
Layout.fillHeight: true
Layout.fillWidth: true
header: Text{
text:"Die einzelnen ChannelProgramme : "
height:70
}
id : channelView
spacing: 50
delegate:
ChannelProgrammEditor{
clickRadius: 50
antialiasing: true
id:editor
width: parent.width
//onClicked: channelView.currentIndex = index
height:100
background: Rectangle{color:"lightgrey"}
channelProgramm: modelData
focus: true
informationDisplayTextItem:Text{}
RowLayout{
height:50
anchors.bottom: editor.top
Label{
text:editor.channelProgramm.channel.name
font.bold: true
Layout.minimumWidth: 60
}
Label{
text:"time: "
visible: editor.currentTimePoint.hasCurrent
}
TextInputField{
Layout.minimumWidth: 30
text:editor.currentTimePoint.time
visible: editor.currentTimePoint.hasCurrent
onAccepted: editor.currentTimePoint.time = text
}
Label{
text:"value: "
visible: editor.currentTimePoint.hasCurrent
}
TextInputField{
Layout.minimumWidth: 30
text:editor.currentTimePoint.value
visible: editor.currentTimePoint.hasCurrent
onAccepted: editor.currentTimePoint.value = text
validator: IntValidator{bottom: 0; top:255}
}
Label{
text: "To Next:"
visible: editor.currentTimePoint.hasCurrent
}
ComboBox{
model: easingModel
currentIndex: editor.currentTimePoint.curveToNext
visible: editor.currentTimePoint.hasCurrent
onHighlightedIndexChanged: {editor.currentTimePoint.curveToNext = highlightedIndex
console.log("selected")
}
}
}
}
model: modelView.currentItem.data.channelProgramms
}
onAddClicked: dialog.visible = true
Dialog{
modality: Qt.WindowModal
id:dialog
title: "Hallo"
width:300
contentItem: RowLayout {
Pane{
Layout.fillWidth: true
ColumnLayout{
anchors.left: parent.left
anchors.right: parent.right
spacing: 10
ComboBox{
Layout.fillWidth: true
id:prototype
model: devicePrototypeModel
textRole: "display"
}
RowLayout{
Label{
id:nameLabel
text:"Name :"
}
TextInputField{
Layout.fillWidth: true
id:name
}
}
RowLayout{
Label{
text:"Description :"
}
TextInputField{
Layout.fillWidth: true
id:description
}
}
RowLayout{
Button{
Layout.fillWidth: true
text:"Abbrechen"
onClicked: dialog.visible = false
}
Button{
Layout.fillWidth: true
text:"Erzeugen"
onClicked: {
if(name.text===""){
name.underlineColor = "red";
}else{
dialog.visible = false;
ModelManager.addProgrammPrototype(prototype.currentIndex,name.text,description.text);
}
}
}
}
}
}
}
}
}
......@@ -6,6 +6,8 @@ TextInput{
selectByMouse: true
font.pixelSize: 15
selectionColor: "lightgreen"
property alias underlineColor : underline.color
property alias underline: underline
cursorDelegate: Rectangle{
color: "lightgreen"
x:parent.cursorRectangle.x
......@@ -17,16 +19,9 @@ TextInput{
NumberAnimation { easing.type: Easing.OutCubic; easing.amplitude: 9; easing.period: 50.0; duration: 500 }
}
}
Rectangle{
anchors.top:parent.bottom
anchors.left:parent.left
width: parent.contentWidth+10
height: 2
radius: 1
color: "lightgreen"
Behavior on width {
NumberAnimation { easing.type: Easing.OutExpo; easing.amplitude: 5.0; easing.period: 2.0; duration: 800 }
}
//onCursorRectangleChanged: underline.clickX = cursorRectangle.x
TextUnderline{
id:underline
//hasFocus: parent.focus
}
}
This diff is collapsed.
......@@ -12,7 +12,7 @@ class CurrentTimePointWrapper : public QObject{
Q_PROPERTY(unsigned char value READ getValue WRITE setValue NOTIFY valueChanged)
Q_PROPERTY(bool hasCurrent READ hasCurrent NOTIFY hasCurrentChanged)
Q_PROPERTY(double time READ getTime WRITE setTime NOTIFY timeChanged)
Q_PROPERTY(QEasingCurve curveToNext READ getCurve WRITE setCurve NOTIFY curveChanged)
Q_PROPERTY(QEasingCurve::Type curveToNext READ getCurve WRITE setCurve NOTIFY curveChanged)
ChannelProgrammEditor * editor;
public:
CurrentTimePointWrapper(ChannelProgrammEditor * editor);
......@@ -21,8 +21,8 @@ public:
bool hasCurrent();
void setTime(double time);
double getTime()const;
void setCurve(const QEasingCurve &c);
QEasingCurve getCurve()const;
void setCurve(const QEasingCurve::Type &c);
QEasingCurve::Type getCurve()const;
signals:
void valueChanged();
void hasCurrentChanged();
......@@ -42,18 +42,42 @@ class ChannelProgrammEditor : public QQuickItem
Q_PROPERTY(QString tooltipText READ getTooltipText CONSTANT)
Q_PROPERTY(ChannelProgramm* channelProgramm READ getChannelProgramm WRITE setChannelProgramm NOTIFY channelProgrammChanged)
private:
friend class CurrentTimePointWrapper;
CurrentTimePointWrapper currentTimePointWrapper;
ChannelProgramm * channelProgramm = nullptr;
QQuickItem * backgroundItem = nullptr;
QQuickItem * valueChangeItem = nullptr;
decltype(ChannelProgramm::timeline)::iterator currentTimePoint;
int clickRadius=4;
double xScale = 1.0;
double xScale = 4.;
double totalXOffset = 0;
double xDiff = 0 ;
QColor graphColor = QColor(0,0,0);
enum Modifier{X_PRESSED,Y_PRESSED,N_PRESSED,T_PRESSED,V_PRESSED,D_PRESSED};
enum Modifier{X_PRESSED=0x1,Y_PRESSED=0x2,N_PRESSED=0x4,T_PRESSED=0x8,V_PRESSED=0x10,D_PRESSED=0x20};
QFlags<Modifier> modifier;
#define INVALID_POS QPoint(std::numeric_limits<int>::max(),std::numeric_limits<int>::max())
QPoint lastMousePosition = INVALID_POS;
decltype(ChannelProgramm::timeline)::iterator getTimePointForPosition(int x, int y);
double getScaledX(int x){return x * 1/xScale;}
/**
* @brief mapToVisualX maps from values/mouse Position to the visual Position of the graph
* eg: mouse/value = 100
* xScale = 2
* totalXOffset = 100
* result = x*xScale+totalXOffset = 300
* @param x the x coordinate
* @return x * xScale + totalXOffset
*/
double mapToVisualX(double x){return x * xScale + totalXOffset;}
/**
* @brief mapFromVisualX maps from the visual Position of the graph to real values
* @param xthe x coordinate
* eg: visual value = 300
* xScale = 2
* totalXOffset = 100
* result = (x-totalXOffset)*(1/xScale) = 100
* @return
*/
double mapFromVisualX(double x){return (x-totalXOffset) * (1/xScale);}
int getScaledY(int y){return 255 - int(y / height() * 255);}
public:
ChannelProgrammEditor();
......@@ -70,12 +94,17 @@ public:
CurrentTimePointWrapper * getCurrentTimePointWrapper(){return &currentTimePointWrapper;}
protected:
virtual void updatePolish()override;
virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)override;
virtual QSGNode* updatePaintNode(QSGNode *, UpdatePaintNodeData *)override;
virtual void mouseMoveEvent(QMouseEvent *event)override;
virtual void mousePressEvent(QMouseEvent *event)override;
virtual void mouseReleaseEvent(QMouseEvent *event)override;
virtual void hoverEnterEvent(QHoverEvent*e)override{lastMousePosition=e->pos();e->accept();forceActiveFocus(Qt::MouseFocusReason);}
virtual void hoverMoveEvent(QHoverEvent*e)override;
virtual void hoverLeaveEvent(QHoverEvent*e)override{lastMousePosition=INVALID_POS;update();e->accept();}
virtual void keyPressEvent(QKeyEvent *event)override;
virtual void keyReleaseEvent(QKeyEvent *event)override;
virtual void wheelEvent(QWheelEvent *event)override;
signals:
void backgroundItemChanged();
void valueChangeItemChanged();
......
......@@ -17,9 +17,15 @@
#include "device.h"
#include <QQmlContext>
#include <QFileInfo>
#include <limits>
#include "modelmanager.h"
#include "channelprogrammeditor.h"
int main(int argc, char *argv[])
{
//qmlRegisterType<const ChannelVector*>("my.models",1,0,"ChannelVector");
qmlRegisterType<ChannelProgrammEditor>("custom.licht",1,0,"ChannelProgrammEditor");
const auto filename = "QTJSONFile.json";
QFile file(filename);
qDebug()<< QFileInfo(file).absoluteFilePath() <<'\n';
......@@ -31,21 +37,32 @@ int main(int argc, char *argv[])
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
qDebug()<<std::numeric_limits<long>::max()<<'\n';
qDebug()<<std::numeric_limits<long long>::max()<<'\n';
qDebug()<<std::numeric_limits<qint64>::max()<<'\n';
qDebug() << model->rowCount()<<'\n';
for(int i = 0 ; i < model->rowCount();++i){
qDebug() << model->data(model->index(i))<<'\n';
}
QStringList dataList;
const QMetaObject &mo = QEasingCurve::staticMetaObject;
QMetaEnum metaEnum = mo.enumerator(mo.indexOfEnumerator("Type"));
for (int i = 0; i < QEasingCurve::NCurveTypes - 1; ++i) {
dataList.append(metaEnum.key(i));
}
app.connect(&app,&QGuiApplication::lastWindowClosed,[&](){ApplicationData::saveData(file);});
/*QSurfaceFormat format = view.format();
format.setSamples(16);
view.setFormat(format);*/
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("ModelManager",new ModelManager());
engine.rootContext()->setContextProperty("deviceModel",IDBaseDataModel<Device>::singletone());
engine.rootContext()->setContextProperty("easingModel",dataList);
engine.rootContext()->setContextProperty("devicePrototypeModel",IDBaseDataModel<DevicePrototype>::singletone());
engine.rootContext()->setContextProperty("programmModel",IDBaseDataModel<Programm>::singletone());
engine.rootContext()->setContextProperty("programmPrototypeModel",IDBaseDataModel<ProgrammPrototype>::singletone());
......
......@@ -3,6 +3,7 @@
#include <QObject>
#include "device.h"
#include "programmprototype.h"
class ModelManager : public QObject{
Q_OBJECT
......@@ -20,6 +21,19 @@ public:
}
return false;
}
Q_INVOKABLE bool addDevicePrototype(QString name, QString description=""){
new DevicePrototype(name,description);
return true;
}
Q_INVOKABLE bool addProgrammPrototype(int row/*DevicePrototype*/,QString name, QString description=""){
DevicePrototype * prototype = IDBaseDataModel<DevicePrototype>::singletone()->data(row);
if(prototype){
new ProgrammPrototype(prototype,name,description);
return true;
}
return false;
}
};
#endif // MODELMANAGER_H
......@@ -9,5 +9,6 @@
<file>ProgrammView.qml</file>
<file>ProgrammPrototypeView.qml</file>
<file>ModelView.qml</file>
<file>TextUnderline.qml</file>
</qresource>