Commit 63f3dae4 authored by Johnny Jazeix's avatar Johnny Jazeix
Browse files

multiple_dataset, add Cancel/Save/Save and Play buttons to dialog

parent a7ffb47f
......@@ -132,8 +132,6 @@ ActivityBase {
height: main.height
fillMode: Image.PreserveAspectCrop
opacity: clickMode === "play" ? 1 : 0.8
Timer {
// triggered once at startup to populate the keyboard
id: keyboardFiller
......@@ -350,7 +348,7 @@ ActivityBase {
anchors {
top: {
if(activity.currentTag === "search")
if(searchBar.visible)
return searchBar.bottom
else
return horizontal ? section.bottom : parent.top
......@@ -471,11 +469,17 @@ ActivityBase {
DialogChooseLevel {
id: dialogChooseLevel
onClose: home()
onStop: {
onClose: {
home()
}
onSaveData: {
currentLevel = dialogChooseLevel.chosenLevel
ApplicationSettings.setCurrentLevel(name, currentLevel)
}
onStartActivity: {
clickMode = "play"
selectCurrentItem()
}
}
function selectCurrentItem() {
......@@ -545,9 +549,9 @@ ActivityBase {
Rectangle {
id: searchBar
width: horizontal ? parent.width/2 : parent.width - (section.width+10)
width: horizontal ? parent.width/2 : parent.width - (section.width+10)
height: searchTextField.height
visible: activity.currentTag === "search"
visible: clickMode === "activityConfig" || activity.currentTag === "search"
anchors {
top: horizontal ? section.bottom : parent.top
left: horizontal ? undefined : section.right
......@@ -591,9 +595,20 @@ ActivityBase {
}
}
GCText {
id: activitySettingsLabel
text: qsTr("Activity Settings")
visible: clickMode === "activityConfig"
width: parent.width
height: paintedHeight
anchors.verticalCenter: parent.verticalCenter
horizontalAlignment: Text.AlignHCenter
color: "black"
}
TextField {
id: searchTextField
width: parent.width
visible: activity.currentTag === "search"
textColor: "black"
font.pointSize: 16
font.bold: true
......@@ -698,7 +713,6 @@ ActivityBase {
}
onActivityConfigClicked: {
print("activityConfig")
if(clickMode == "play") {
clickMode = "activityConfig"
}
......
......@@ -432,28 +432,28 @@ QVariantMap ApplicationSettings::loadActivityConfiguration(const QString &activi
void ApplicationSettings::setFavorite(const QString &activity, bool favorite)
{
updateValueInConfig(FAVORITE_GROUP_KEY, activity, favorite);
updateValueInConfig(FAVORITE_GROUP_KEY, activity, favorite);
}
bool ApplicationSettings::isFavorite(const QString &activity)
{
m_config.beginGroup(FAVORITE_GROUP_KEY);
bool favorite = m_config.value(activity, false).toBool();
m_config.endGroup();
return favorite;
m_config.beginGroup(FAVORITE_GROUP_KEY);
bool favorite = m_config.value(activity, false).toBool();
m_config.endGroup();
return favorite;
}
void ApplicationSettings::setCurrentLevel(const QString &activity, const QString &level)
{
updateValueInConfig(LEVELS_GROUP_KEY, activity, level);
updateValueInConfig(LEVELS_GROUP_KEY, activity, level);
}
QString ApplicationSettings::currentLevel(const QString &activity)
{
m_config.beginGroup(LEVELS_GROUP_KEY);
QString level = m_config.value(activity, "").toString();
m_config.endGroup();
return level;
m_config.beginGroup(LEVELS_GROUP_KEY);
QString level = m_config.value(activity, "").toString();
m_config.endGroup();
return level;
}
template<class T> void ApplicationSettings::updateValueInConfig(const QString& group,
......
......@@ -135,7 +135,7 @@ Rectangle {
function getInitialConfiguration() {
if(activityName == "") {
activityName = ActivityInfoTree.currentActivity.name.split('/')[0];
activityName = activityInfo.name.split('/')[0];
}
dataToSave = ApplicationSettings.loadActivityConfiguration(activityName)
loadData()
......
......@@ -74,6 +74,10 @@ Rectangle {
signal stop
signal saveData
signal startActivity
color: "#696da3"
border.color: "black"
border.width: 1
......@@ -81,7 +85,6 @@ Rectangle {
onCurrentActivityChanged: initialize()
function initialize() {
print(currentActivity.currentLevel)
activityName = currentActivity.name.split('/')[0]
chosenLevel = currentActivity.currentLevel
difficultiesModel = []
......@@ -161,19 +164,48 @@ Rectangle {
}
}
Row {
id: datasetOptionsRow
height: datasetVisibleButton.height
width: parent.width
spacing: parent.width / 4
anchors.leftMargin: parent.width / 8
Button {
id: datasetVisibleButton
text: qsTr("Dataset")
width: parent.width / 3
property bool selected: true
style: GCButtonStyle {
selected: datasetVisibleButton.selected
}
onClicked: { selected = true; }
}
Button {
id: optionsVisibleButton
text: qsTr("Options")
width: parent.width / 3
style: GCButtonStyle {
selected: !datasetVisibleButton.selected
}
onClicked: { datasetVisibleButton.selected = false; } //showOptions()
}
}
Rectangle {
color: "#e6e6e6"
radius: 6.0
width: dialogChooseLevel.width - 30
height: dialogChooseLevel.height - (30 + title.height * 1.2)
height: dialogChooseLevel.height - (30 + title.height * 1.2) - saveAndPlayRow.height - datasetOptionsRow.height - 3 * parent.spacing
border.color: "black"
border.width: 2
anchors.margins: 100
Flickable {
id: flick
anchors.margins: 8
anchors.fill: parent
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
flickableDirection: Flickable.VerticalFlick
clip: true
contentHeight: contentItem.childrenRect.height + 40 * ApplicationInfo.ratio
......@@ -206,6 +238,41 @@ Rectangle {
upVisible: flick.visibleArea.yPosition <= 0 ? false : true
downVisible: flick.visibleArea.yPosition + flick.visibleArea.heightRatio >= 1 ? false : true
}
}
Row {
id: saveAndPlayRow
height: cancelButton.height
width: parent.width
spacing: parent.width / 16
Button {
id: cancelButton
text: qsTr("Cancel")
width: parent.width / 4
property bool selected: true
style: GCButtonStyle {}
onClicked: dialogChooseLevel.close()
}
Button {
id: saveButton
text: qsTr("Save")
width: parent.width / 4
property bool selected: true
style: GCButtonStyle { }
onClicked: {
saveData();
}
}
Button {
id: saveAndStartButton
text: qsTr("Save and start")
width: parent.width / 3
style: GCButtonStyle { }
onClicked: {
saveData();
startActivity();
}
}
}
Item { width: 1; height: 10 }
......
......@@ -101,14 +101,16 @@ ButtonStyle {
fontBold: true
}
}
property bool selected: false
background: Rectangle {
border.width: control.activeFocus ? 4 : 2
border.color: themes[theme].borderColor
radius: 10
gradient: Gradient {
GradientStop { position: 0 ; color: control.pressed ? themes[theme].selectedColorGradient0 : themes[theme].backgroundColorGradient0 }
GradientStop { position: 1 ; color: control.pressed ? themes[theme].selectedColorGradient1 : themes[theme].backgroundColorGradient1 }
GradientStop { position: 0 ; color: (control.pressed || selected) ? themes[theme].selectedColorGradient0 : themes[theme].backgroundColorGradient0 }
GradientStop { position: 1 ; color: (control.pressed || selected) ? themes[theme].selectedColorGradient1 : themes[theme].backgroundColorGradient1 }
}
}
label: Item {
......
......@@ -237,8 +237,9 @@ Window {
!properties.enterItem.isDialog) // going into an activity then
playIntroVoice(properties.enterItem.activityInfo.name); // play intro
if (!properties.exitItem.isDialog || // if coming from menu or
properties.enterItem.alwaysStart) // start signal enforced (for special case like transition from config-dialog to editor)
// is this if needed?
//if (!properties.exitItem.isDialog || // if coming from menu or
// properties.enterItem.alwaysStart) // start signal enforced (for special case like transition from config-dialog to editor)
properties.enterItem.start();
if(properties.name === "pushTransition") {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment