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
|
||||
- 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
|
||||
### Changed
|
||||
- increased the size f the back buttons in settings / profiles dialog
|
||||
|
||||
## [0.03 - BETA] - 2018-07-29
|
||||
### 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;
|
||||
QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
|
||||
|
||||
Q_INVOKABLE bool append(QString name);
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
|
|
@ -31,7 +31,7 @@ Popup {
|
|||
|
||||
Label {
|
||||
id: head_text
|
||||
text: options_stack.currentItem.title
|
||||
text: profiles_stack.currentItem.title
|
||||
font.pixelSize: headlineUnderline.width * 0.1
|
||||
anchors {
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
|
@ -91,36 +91,82 @@ Popup {
|
|||
left: parent.left
|
||||
leftMargin: parent.width * 0.17
|
||||
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
|
||||
|
||||
background: Rectangle {
|
||||
radius: width * 0.5
|
||||
color: "white"
|
||||
color: head_back.pressed ? "lightgrey":"white"
|
||||
border.color: "grey"
|
||||
border.width: 1
|
||||
Image {
|
||||
anchors.fill: parent
|
||||
anchors.margins: parent.width * 0.2
|
||||
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: {
|
||||
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 {
|
||||
NumberAnimation {
|
||||
duration: 100
|
||||
|
@ -129,54 +175,141 @@ Popup {
|
|||
}
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: profileList
|
||||
ListView{
|
||||
id: profileModel
|
||||
model: SqlProfileModel{}
|
||||
}
|
||||
|
||||
StackView {
|
||||
id: profiles_stack
|
||||
property int text_pixelSize: headlineUnderline.width * 0.08
|
||||
initialItem: profileListComp
|
||||
width: headlineUnderline.width
|
||||
|
||||
|
||||
|
||||
anchors {
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
leftMargin: ( parent.width - headlineUnderline.width ) / 2
|
||||
right: parent.right
|
||||
rightMargin: headlineUnderline.anchors.rightMargin
|
||||
topMargin: headlineUnderline.anchors.topMargin
|
||||
topMargin: headlineUnderline.anchors.topMargin * 1.2
|
||||
bottom: parent.bottom
|
||||
bottomMargin: headlineUnderline.anchors.topMargin
|
||||
}
|
||||
model:SqlProfileModel{}
|
||||
|
||||
delegate: SwipeDelegate {
|
||||
id: swipeDelegate
|
||||
text: model.name
|
||||
Behavior on opacity {
|
||||
NumberAnimation {duration: 200}
|
||||
}
|
||||
|
||||
width: profileList.width
|
||||
Component {
|
||||
id: component
|
||||
/*-----List of all profiles-----*/
|
||||
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 {
|
||||
color: mouse.pressed ? "#333" : "#444"
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
clip: true
|
||||
delegate: SwipeDelegate {
|
||||
id: swipeDelegate
|
||||
text: model.name
|
||||
|
||||
width: profileList.width
|
||||
Component {
|
||||
id: component
|
||||
|
||||
Rectangle {
|
||||
color: mouse.pressed ? "#333" : "#444"
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
clip: true
|
||||
|
||||
|
||||
Label {
|
||||
text: qsTr("Press me!")
|
||||
color: "#21be2b"
|
||||
anchors.centerIn: parent
|
||||
Label {
|
||||
text: qsTr("Press me!")
|
||||
color: "#21be2b"
|
||||
anchors.centerIn: parent
|
||||
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouseAr
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
model.remove(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouseAr
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
model.remove(index)
|
||||
}
|
||||
swipe.left: component
|
||||
swipe.right: component
|
||||
}
|
||||
ScrollIndicator.vertical: ScrollIndicator { }
|
||||
}
|
||||
}
|
||||
|
||||
/*-----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
|
||||
leftMargin: parent.width * 0.17
|
||||
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
|
||||
|
||||
background: Rectangle {
|
||||
|
|
|
@ -14,5 +14,6 @@
|
|||
<file>sounds/ready_2.wav</file>
|
||||
<file>sounds/at_marks_2.wav</file>
|
||||
<file>graphics/icons/buzzer_black.png</file>
|
||||
<file>graphics/icons/ok_black.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -35,6 +35,7 @@ SqlProfileModel::SqlProfileModel(QObject *parent) : QSqlTableModel(parent)
|
|||
qDebug("ProfileModel constructor");
|
||||
createTable();
|
||||
setTable("profiles");
|
||||
setEditStrategy(QSqlTableModel::OnManualSubmit);
|
||||
select();
|
||||
}
|
||||
|
||||
|
@ -55,3 +56,18 @@ QHash<int, QByteArray> SqlProfileModel::roleNames() const
|
|||
|
||||
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