Commit 2b5a548f authored by Sandro Andrade's avatar Sandro Andrade

Constrains QML properties visibility

parent 994c7b67
......@@ -40,9 +40,9 @@ IExerciseController::~IExerciseController()
{
}
QJsonArray IExerciseController::selectedOptions() const
QJsonArray IExerciseController::selectedExerciseOptions() const
{
return m_selectedOptions;
return m_selectedExerciseOptions;
}
}
......
......@@ -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;
};
}
......
......@@ -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);
......
......@@ -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()
......
......@@ -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)
......
......@@ -126,7 +126,7 @@ Item {
}
Connections {
target: core.exerciseController
onSelectedOptionsChanged: pianoView.clearAllMarks()
onSelectedExerciseOptionsChanged: pianoView.clearAllMarks()
onCurrentExerciseChanged: pianoView.clearAllMarks()
}
}
......@@ -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 {
......
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