summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandro S. Andrade <[email protected]>2016-07-01 02:53:26 -0300
committerSandro S. Andrade <[email protected]>2016-07-01 02:53:26 -0300
commit2b5a548f08aac5b4edc436ebf95a6ade7f9ad35a (patch)
treefc3b0740c9fa3b232bd06568c7c5fa689bd7e88d
parent994c7b67bd78ed553ad72f96e4a90452973e27bc (diff)
Constrains QML properties visibility
-rw-r--r--src/interfaces/iexercisecontroller.cpp4
-rw-r--r--src/interfaces/iexercisecontroller.h8
-rw-r--r--src/interfaces/isoundbackend.h2
-rw-r--r--src/shell/exercisecontroller.cpp8
-rw-r--r--src/shell/qml/ExerciseView.qml8
-rw-r--r--src/shell/qml/Main.qml2
-rw-r--r--src/shell/qml/MinuetMenu.qml5
7 files changed, 19 insertions, 18 deletions
diff --git a/src/interfaces/iexercisecontroller.cpp b/src/interfaces/iexercisecontroller.cpp
index 53c2bd7..0125503 100644
--- a/src/interfaces/iexercisecontroller.cpp
+++ b/src/interfaces/iexercisecontroller.cpp
@@ -40,9 +40,9 @@ IExerciseController::~IExerciseController()
{
}
-QJsonArray IExerciseController::selectedOptions() const
+QJsonArray IExerciseController::selectedExerciseOptions() const
{
- return m_selectedOptions;
+ return m_selectedExerciseOptions;
}
}
diff --git a/src/interfaces/iexercisecontroller.h b/src/interfaces/iexercisecontroller.h
index 97831cd..5ec3197 100644
--- a/src/interfaces/iexercisecontroller.h
+++ b/src/interfaces/iexercisecontroller.h
@@ -40,20 +40,20 @@ class MINUETINTERFACES_EXPORT IExerciseController : public QObject
Q_PROPERTY(QJsonArray exercises READ exercises)
Q_PROPERTY(QJsonObject currentExercise MEMBER m_currentExercise NOTIFY currentExerciseChanged)
Q_PROPERTY(quint8 answerLength MEMBER m_answerLength)
- Q_PROPERTY(QJsonArray selectedOptions READ selectedOptions NOTIFY selectedOptionsChanged)
+ Q_PROPERTY(QJsonArray selectedExerciseOptions READ selectedExerciseOptions NOTIFY selectedExerciseOptionsChanged)
public:
virtual ~IExerciseController() override;
virtual QJsonArray exercises() const = 0;
- QJsonArray selectedOptions() const;
+ QJsonArray selectedExerciseOptions() const;
public Q_SLOTS:
virtual void randomlySelectOptions() = 0;
Q_SIGNALS:
void currentExerciseChanged(QJsonObject newCurrentExercise);
- void selectedOptionsChanged(QJsonArray newSelectedOptions);
+ void selectedExerciseOptionsChanged(QJsonArray newSelectedExerciseOptions);
protected:
explicit IExerciseController(QObject *parent = 0);
@@ -62,7 +62,7 @@ protected:
quint8 m_maxRootNote;
QJsonObject m_currentExercise;
quint8 m_answerLength;
- QJsonArray m_selectedOptions;
+ QJsonArray m_selectedExerciseOptions;
};
}
diff --git a/src/interfaces/isoundbackend.h b/src/interfaces/isoundbackend.h
index 28cd61a..449d13f 100644
--- a/src/interfaces/isoundbackend.h
+++ b/src/interfaces/isoundbackend.h
@@ -81,8 +81,8 @@ Q_SIGNALS:
void volumeChanged(quint8 newVolume);
void tempoChanged(quint8 newTempo);
void playbackLabelChanged(QString newPlaybackLabel);
- void stateChanged(State newState);
void playModeChanged(PlayMode newPlayMode);
+ void stateChanged(State newState);
protected:
explicit ISoundBackend(QObject *parent = 0);
diff --git a/src/shell/exercisecontroller.cpp b/src/shell/exercisecontroller.cpp
index 0a78d13..f106a4b 100644
--- a/src/shell/exercisecontroller.cpp
+++ b/src/shell/exercisecontroller.cpp
@@ -65,8 +65,8 @@ bool ExerciseController::initialize(Core *core)
void ExerciseController::randomlySelectOptions()
{
- while (!m_selectedOptions.isEmpty())
- m_selectedOptions.removeFirst();
+ while (!m_selectedExerciseOptions.isEmpty())
+ m_selectedExerciseOptions.removeFirst();
qsrand(QDateTime::currentDateTimeUtc().toTime_t());
@@ -89,9 +89,9 @@ void ExerciseController::randomlySelectOptions()
QJsonObject jsonObject = exerciseOptions[chosenExerciseOption].toObject();
jsonObject["rootNote"] = QString::number(m_chosenRootNote);
exerciseOptions[chosenExerciseOption] = jsonObject;
- m_selectedOptions.append(exerciseOptions[chosenExerciseOption]);
+ m_selectedExerciseOptions.append(exerciseOptions[chosenExerciseOption]);
}
- emit selectedOptionsChanged(m_selectedOptions);
+ emit selectedExerciseOptionsChanged(m_selectedExerciseOptions);
}
unsigned int ExerciseController::chosenRootNote()
diff --git a/src/shell/qml/ExerciseView.qml b/src/shell/qml/ExerciseView.qml
index eae388c..da45e63 100644
--- a/src/shell/qml/ExerciseView.qml
+++ b/src/shell/qml/ExerciseView.qml
@@ -110,11 +110,11 @@ Item {
onClicked: {
exerciseView.state = "waitingForAnswer"
core.exerciseController.randomlySelectOptions()
- var selectedOptions = core.exerciseController.selectedOptions
- core.soundBackend.prepareFromExerciseOptions(selectedOptions, "scale")
+ var selectedExerciseOptions = core.exerciseController.selectedExerciseOptions
+ core.soundBackend.prepareFromExerciseOptions(selectedExerciseOptions, "scale")
var newChosenExercises = [];
- for (var i = 0; i < selectedOptions.length; ++i)
- newChosenExercises.push(selectedOptions[i].name);
+ for (var i = 0; i < selectedExerciseOptions.length; ++i)
+ newChosenExercises.push(selectedExerciseOptions[i].name);
chosenExercises = newChosenExercises
for (var i = 0; i < chosenExercises.length; ++i)
for (var j = 0; j < answerGrid.children.length; ++j)
diff --git a/src/shell/qml/Main.qml b/src/shell/qml/Main.qml
index a67d1b7..7a03ddf 100644
--- a/src/shell/qml/Main.qml
+++ b/src/shell/qml/Main.qml
@@ -126,7 +126,7 @@ Item {
}
Connections {
target: core.exerciseController
- onSelectedOptionsChanged: pianoView.clearAllMarks()
+ onSelectedExerciseOptionsChanged: pianoView.clearAllMarks()
onCurrentExerciseChanged: pianoView.clearAllMarks()
}
}
diff --git a/src/shell/qml/MinuetMenu.qml b/src/shell/qml/MinuetMenu.qml
index 7c4c6aa..6031a5a 100644
--- a/src/shell/qml/MinuetMenu.qml
+++ b/src/shell/qml/MinuetMenu.qml
@@ -30,7 +30,7 @@ Item {
id: minuetMenu
property string message
- property var currentExercise
+ readonly property alias currentExercise: stackView.currentExercise
signal backPressed
signal userMessageChanged(string message)
@@ -52,6 +52,7 @@ Item {
StackView {
id: stackView
+ property var currentExercise
property Item currentExerciseMenuItem
width: parent.width - breadcrumb.width; height: parent.height
@@ -76,7 +77,7 @@ Item {
if (!children) {
if (stackView.currentExerciseMenuItem != undefined) stackView.currentExerciseMenuItem.checked = false
userMessageChanged(message)
- currentExercise = delegateRect.ListView.view.model[index]
+ stackView.currentExercise = delegateRect.ListView.view.model[index]
stackView.currentExerciseMenuItem = delegateRect
}
else {