added "add profile" dialog
This commit is contained in:
parent
1518680397
commit
1331af45c4
7 changed files with 200 additions and 46 deletions
|
@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||||
### Fixed
|
### Fixed
|
||||||
- start seqnece continues in a buggy way when cancel is being pressed while 'at your marks' or 'ready'
|
- start seqnece continues in a buggy way when cancel is being pressed while 'at your marks' or 'ready'
|
||||||
- bug that made the start sequence freeze if a delay of zero or lower or a non valid number was set as delay
|
- bug that made the start sequence freeze if a delay of zero or lower or a non valid number was set as delay
|
||||||
|
### Changed
|
||||||
|
- increased the size f the back buttons in settings / profiles dialog
|
||||||
|
|
||||||
## [0.03 - BETA] - 2018-07-29
|
## [0.03 - BETA] - 2018-07-29
|
||||||
### Added
|
### Added
|
||||||
|
|
BIN
graphics/icons/ok_black.png
Normal file
BIN
graphics/icons/ok_black.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 383 B |
|
@ -17,6 +17,8 @@ public:
|
||||||
|
|
||||||
QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
|
QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
|
||||||
QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
|
QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
Q_INVOKABLE bool append(QString name);
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
|
@ -31,7 +31,7 @@ Popup {
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
id: head_text
|
id: head_text
|
||||||
text: options_stack.currentItem.title
|
text: profiles_stack.currentItem.title
|
||||||
font.pixelSize: headlineUnderline.width * 0.1
|
font.pixelSize: headlineUnderline.width * 0.1
|
||||||
anchors {
|
anchors {
|
||||||
horizontalCenter: parent.horizontalCenter
|
horizontalCenter: parent.horizontalCenter
|
||||||
|
@ -91,36 +91,82 @@ Popup {
|
||||||
left: parent.left
|
left: parent.left
|
||||||
leftMargin: parent.width * 0.17
|
leftMargin: parent.width * 0.17
|
||||||
top:parent.top
|
top:parent.top
|
||||||
topMargin: parent.height * 0.025
|
topMargin: parent.height * 0.01
|
||||||
}
|
}
|
||||||
height: parent.height * 0.1
|
height: parent.height * 0.13
|
||||||
width:height
|
width:height
|
||||||
|
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
radius: width * 0.5
|
radius: width * 0.5
|
||||||
color: "white"
|
color: head_back.pressed ? "lightgrey":"white"
|
||||||
border.color: "grey"
|
border.color: "grey"
|
||||||
border.width: 1
|
border.width: 1
|
||||||
Image {
|
Image {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: parent.width * 0.2
|
anchors.margins: parent.width * 0.2
|
||||||
source: "qrc:/graphics/icons/back_black.png"
|
source: "qrc:/graphics/icons/back_black.png"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onClicked: profiles_stack.depth > 1 ? profiles_stack.pop():root.close()
|
||||||
|
|
||||||
|
Behavior on opacity {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: 100
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
id: head_add
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
right: parent.right
|
||||||
|
rightMargin: parent.width * 0.17
|
||||||
|
top:parent.top
|
||||||
|
topMargin: parent.height * 0.01
|
||||||
|
}
|
||||||
|
height: parent.height * 0.13
|
||||||
|
width:height
|
||||||
|
|
||||||
|
background: Rectangle {
|
||||||
|
radius: width * 0.5
|
||||||
|
color: parent.pressed ? "lightgrey":"white"
|
||||||
|
border.color: "grey"
|
||||||
|
border.width: 1
|
||||||
|
Label {
|
||||||
|
anchors {
|
||||||
|
top: parent.top
|
||||||
|
topMargin: parent.height/2 - height*0.55
|
||||||
|
left: parent.left
|
||||||
|
leftMargin: parent.width/2 - width/2
|
||||||
|
}
|
||||||
|
opacity: profiles_stack.currentItem.secondButt === "add" ? 1:0
|
||||||
|
text: "+"
|
||||||
|
font.pixelSize: parent.height
|
||||||
|
}
|
||||||
|
|
||||||
|
Image {
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: parent.width * 0.2
|
||||||
|
source: "qrc:/graphics/icons/ok_black.png"
|
||||||
|
opacity: profiles_stack.currentItem.secondButt === "ok" ? 1:0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
options_stack.depth > 1 ? options_stack.pop():root.close()
|
switch(profiles_stack.currentItem.secondButt){
|
||||||
|
case "add":
|
||||||
|
profiles_stack.push(addProfileComp)
|
||||||
|
break
|
||||||
|
case "ok":
|
||||||
|
if(profileModel.model.append(profiles_stack.currentItem.newProfileName)){
|
||||||
|
profiles_stack.pop()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onPressedChanged: {
|
|
||||||
if(pressed){
|
|
||||||
background.color = "lightgrey"
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
background.color = "white"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Behavior on opacity {
|
Behavior on opacity {
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
duration: 100
|
duration: 100
|
||||||
|
@ -129,54 +175,141 @@ Popup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ListView {
|
ListView{
|
||||||
id: profileList
|
id: profileModel
|
||||||
|
model: SqlProfileModel{}
|
||||||
|
}
|
||||||
|
|
||||||
|
StackView {
|
||||||
|
id: profiles_stack
|
||||||
|
property int text_pixelSize: headlineUnderline.width * 0.08
|
||||||
|
initialItem: profileListComp
|
||||||
|
width: headlineUnderline.width
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
anchors {
|
anchors {
|
||||||
top: parent.top
|
top: parent.top
|
||||||
left: parent.left
|
left: parent.left
|
||||||
leftMargin: ( parent.width - headlineUnderline.width ) / 2
|
leftMargin: ( parent.width - headlineUnderline.width ) / 2
|
||||||
right: parent.right
|
topMargin: headlineUnderline.anchors.topMargin * 1.2
|
||||||
rightMargin: headlineUnderline.anchors.rightMargin
|
|
||||||
topMargin: headlineUnderline.anchors.topMargin
|
|
||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
|
bottomMargin: headlineUnderline.anchors.topMargin
|
||||||
}
|
}
|
||||||
model:SqlProfileModel{}
|
|
||||||
|
|
||||||
delegate: SwipeDelegate {
|
Behavior on opacity {
|
||||||
id: swipeDelegate
|
NumberAnimation {duration: 200}
|
||||||
text: model.name
|
}
|
||||||
|
|
||||||
width: profileList.width
|
/*-----List of all profiles-----*/
|
||||||
Component {
|
Component {
|
||||||
id: component
|
id: profileListComp
|
||||||
|
ListView {
|
||||||
|
id: profileList
|
||||||
|
model: profileModel.model
|
||||||
|
property string title: "profiles"
|
||||||
|
property string secondButt: "add"
|
||||||
|
Label {
|
||||||
|
visible: profileList.count <= 0
|
||||||
|
text: "add a profile by clicking +"
|
||||||
|
anchors.centerIn: parent
|
||||||
|
font.pixelSize: parent.width*0.06
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle {
|
delegate: SwipeDelegate {
|
||||||
color: mouse.pressed ? "#333" : "#444"
|
id: swipeDelegate
|
||||||
width: parent.width
|
text: model.name
|
||||||
height: parent.height
|
|
||||||
clip: true
|
width: profileList.width
|
||||||
|
Component {
|
||||||
|
id: component
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
color: mouse.pressed ? "#333" : "#444"
|
||||||
|
width: parent.width
|
||||||
|
height: parent.height
|
||||||
|
clip: true
|
||||||
|
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
text: qsTr("Press me!")
|
text: qsTr("Press me!")
|
||||||
color: "#21be2b"
|
color: "#21be2b"
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: mouseAr
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
model.remove(index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
swipe.left: component
|
||||||
id: mouseAr
|
swipe.right: component
|
||||||
anchors.fill: parent
|
}
|
||||||
onClicked: {
|
ScrollIndicator.vertical: ScrollIndicator { }
|
||||||
model.remove(index)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*-----Option to add a profile-----*/
|
||||||
|
Component {
|
||||||
|
id: addProfileComp
|
||||||
|
Column {
|
||||||
|
property string title: "add profile"
|
||||||
|
property string secondButt: "ok"
|
||||||
|
property string newProfileName: ""
|
||||||
|
TextField {
|
||||||
|
width: parent.width
|
||||||
|
placeholderText: "name"
|
||||||
|
onTextChanged: {
|
||||||
|
parent.newProfileName = text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
swipe.left: component
|
|
||||||
swipe.right: component
|
|
||||||
}
|
}
|
||||||
ScrollIndicator.vertical: ScrollIndicator { }
|
|
||||||
|
/*-----Custom animations-----*/
|
||||||
|
|
||||||
|
pushEnter: Transition {
|
||||||
|
NumberAnimation {
|
||||||
|
property: "opacity"
|
||||||
|
from: 0
|
||||||
|
to: 1
|
||||||
|
duration: 200
|
||||||
|
easing.type: Easing.InOutQuad
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pushExit: Transition {
|
||||||
|
NumberAnimation {
|
||||||
|
property: "opacity"
|
||||||
|
from: 1
|
||||||
|
to: 0
|
||||||
|
duration: 200
|
||||||
|
easing.type: Easing.InOutQuad
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
popExit: Transition {
|
||||||
|
NumberAnimation {
|
||||||
|
property: "opacity"
|
||||||
|
from: 1
|
||||||
|
to: 0
|
||||||
|
duration: 200
|
||||||
|
easing.type: Easing.InOutQuad
|
||||||
|
}
|
||||||
|
}
|
||||||
|
popEnter: Transition {
|
||||||
|
NumberAnimation {
|
||||||
|
property: "opacity"
|
||||||
|
from: 0
|
||||||
|
to: 1
|
||||||
|
duration: 200
|
||||||
|
easing.type: Easing.InOutQuad
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,9 +89,9 @@ Popup {
|
||||||
left: parent.left
|
left: parent.left
|
||||||
leftMargin: parent.width * 0.17
|
leftMargin: parent.width * 0.17
|
||||||
top:parent.top
|
top:parent.top
|
||||||
topMargin: parent.height * 0.025
|
topMargin: parent.height * 0.01
|
||||||
}
|
}
|
||||||
height: parent.height * 0.1
|
height: parent.height * 0.13
|
||||||
width:height
|
width:height
|
||||||
|
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
|
|
|
@ -14,5 +14,6 @@
|
||||||
<file>sounds/ready_2.wav</file>
|
<file>sounds/ready_2.wav</file>
|
||||||
<file>sounds/at_marks_2.wav</file>
|
<file>sounds/at_marks_2.wav</file>
|
||||||
<file>graphics/icons/buzzer_black.png</file>
|
<file>graphics/icons/buzzer_black.png</file>
|
||||||
|
<file>graphics/icons/ok_black.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -35,6 +35,7 @@ SqlProfileModel::SqlProfileModel(QObject *parent) : QSqlTableModel(parent)
|
||||||
qDebug("ProfileModel constructor");
|
qDebug("ProfileModel constructor");
|
||||||
createTable();
|
createTable();
|
||||||
setTable("profiles");
|
setTable("profiles");
|
||||||
|
setEditStrategy(QSqlTableModel::OnManualSubmit);
|
||||||
select();
|
select();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,3 +56,18 @@ QHash<int, QByteArray> SqlProfileModel::roleNames() const
|
||||||
|
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SqlProfileModel::append(QString name)
|
||||||
|
{
|
||||||
|
qDebug() << name;
|
||||||
|
QSqlRecord newRecord = record();
|
||||||
|
newRecord.setValue("name", name);
|
||||||
|
|
||||||
|
if (!insertRecord(rowCount(), newRecord)) {
|
||||||
|
qWarning() << "Failed to add profile:" << lastError().text();
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
submitAll();
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
Reference in a new issue