Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Minuet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Education
Minuet
Commits
8a0bd2fc
Commit
8a0bd2fc
authored
Jul 01, 2016
by
Sandro Andrade
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial MinuetMenu refactoring
parent
73e88607
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
58 additions
and
81 deletions
+58
-81
src/interfaces/icore.h
src/interfaces/icore.h
+3
-3
src/interfaces/iexercisecontroller.h
src/interfaces/iexercisecontroller.h
+3
-2
src/interfaces/isoundbackend.h
src/interfaces/isoundbackend.h
+1
-1
src/shell/exercisecontroller.cpp
src/shell/exercisecontroller.cpp
+6
-5
src/shell/qml/ExerciseView.qml
src/shell/qml/ExerciseView.qml
+4
-4
src/shell/qml/Main.qml
src/shell/qml/Main.qml
+24
-41
src/shell/qml/MinuetMenu.qml
src/shell/qml/MinuetMenu.qml
+10
-18
src/shell/qml/midiplayer/MidiPlayer.qml
src/shell/qml/midiplayer/MidiPlayer.qml
+7
-7
No files found.
src/interfaces/icore.h
View file @
8a0bd2fc
...
...
@@ -39,10 +39,10 @@ class MINUETINTERFACES_EXPORT ICore : public QObject
{
Q_OBJECT
Q_PROPERTY
(
IPluginController
*
pluginController
READ
pluginController
);
Q_PROPERTY
(
IPluginController
*
pluginController
READ
pluginController
CONSTANT
);
Q_PROPERTY
(
ISoundBackend
*
soundBackend
READ
soundBackend
NOTIFY
soundBackendChanged
);
Q_PROPERTY
(
IExerciseController
*
exerciseController
READ
exerciseController
);
Q_PROPERTY
(
IUiController
*
uiController
READ
uiController
);
Q_PROPERTY
(
IExerciseController
*
exerciseController
READ
exerciseController
CONSTANT
);
Q_PROPERTY
(
IUiController
*
uiController
READ
uiController
CONSTANT
);
public:
virtual
~
ICore
()
override
;
...
...
src/interfaces/iexercisecontroller.h
View file @
8a0bd2fc
...
...
@@ -27,6 +27,7 @@
#include <QObject>
#include <QJsonArray>
#include <QJsonObject>
namespace
Minuet
{
...
...
@@ -37,7 +38,7 @@ class MINUETINTERFACES_EXPORT IExerciseController : public QObject
Q_PROPERTY
(
quint8
minRootNote
MEMBER
m_minRootNote
)
Q_PROPERTY
(
quint8
maxRootNote
MEMBER
m_maxRootNote
)
Q_PROPERTY
(
QJsonArray
exercises
READ
exercises
)
Q_PROPERTY
(
QJson
Array
currentExercise
MEMBER
m_currentExercise
)
Q_PROPERTY
(
QJson
Object
currentExercise
MEMBER
m_currentExercise
)
Q_PROPERTY
(
quint8
answerLength
MEMBER
m_answerLength
)
Q_PROPERTY
(
QJsonArray
selectedOptions
MEMBER
m_selectedOptions
)
...
...
@@ -54,7 +55,7 @@ protected:
quint8
m_minRootNote
;
quint8
m_maxRootNote
;
QJson
Array
m_currentExercise
;
QJson
Object
m_currentExercise
;
quint8
m_answerLength
;
QJsonArray
m_selectedOptions
;
};
...
...
src/interfaces/isoundbackend.h
View file @
8a0bd2fc
...
...
@@ -75,7 +75,7 @@ public Q_SLOTS:
virtual
void
play
()
=
0
;
virtual
void
pause
()
=
0
;
virtual
void
stop
()
=
0
;
Q_SIGNALS:
void
pitchChanged
(
qint8
newPitch
);
void
volumeChanged
(
quint8
newVolume
);
...
...
src/shell/exercisecontroller.cpp
View file @
8a0bd2fc
...
...
@@ -73,9 +73,10 @@ void ExerciseController::randomlySelectOptions()
int
minNote
=
INT_MAX
;
int
maxNote
=
INT_MIN
;
for
(
quint8
i
=
0
;
i
<
m_answerLength
;
++
i
)
{
quint8
chosenExercise
=
qrand
()
%
m_currentExercise
.
size
();
QJsonArray
exerciseOptions
=
m_currentExercise
[
QStringLiteral
(
"options"
)].
toArray
();
quint8
chosenExerciseOption
=
qrand
()
%
exerciseOptions
.
size
();
QString
sequence
=
m_currentExercise
[
chosenExercise
].
toObject
()[
QStringLiteral
(
"sequence"
)].
toString
();
QString
sequence
=
exerciseOptions
[
chosenExerciseOption
].
toObject
()[
QStringLiteral
(
"sequence"
)].
toString
();
foreach
(
const
QString
&
additionalNote
,
sequence
.
split
(
' '
))
{
int
note
=
additionalNote
.
toInt
();
if
(
note
>
maxNote
)
maxNote
=
note
;
...
...
@@ -85,10 +86,10 @@ void ExerciseController::randomlySelectOptions()
m_chosenRootNote
=
m_minRootNote
+
qrand
()
%
(
m_maxRootNote
-
m_minRootNote
);
while
(
m_chosenRootNote
+
maxNote
>
108
||
m_chosenRootNote
+
minNote
<
21
);
QJsonObject
jsonObject
=
m_currentExercise
[
chosenExercise
].
toObject
();
QJsonObject
jsonObject
=
exerciseOptions
[
chosenExerciseOption
].
toObject
();
jsonObject
[
"rootNote"
]
=
QString
::
number
(
m_chosenRootNote
);
m_currentExercise
[
chosenExercise
]
=
jsonObject
;
m_selectedOptions
.
append
(
m_currentExercise
[
chosenExercise
]);
exerciseOptions
[
chosenExerciseOption
]
=
jsonObject
;
m_selectedOptions
.
append
(
exerciseOptions
[
chosenExerciseOption
]);
}
}
...
...
src/shell/qml/ExerciseView.qml
View file @
8a0bd2fc
...
...
@@ -55,14 +55,14 @@ Item {
})
animation
.
start
()
}
function
itemChanged
(
model
)
{
// sequencer.allNotesOff()
function
setCurrentExercise
(
currentExercise
)
{
clearExerciseGrid
()
var
length
=
model
.
length
var
currentExerciseOptions
=
currentExercise
[
"
options
"
];
var
length
=
currentExerciseOptions
.
length
answerGrid
.
columns
=
Math
.
min
(
6
,
length
)
answerGrid
.
rows
=
Math
.
ceil
(
length
/
6
)
for
(
var
i
=
0
;
i
<
length
;
++
i
)
answerOption
.
createObject
(
answerGrid
,
{
model
:
model
[
i
],
index
:
i
,
color
:
colors
[
i
%
24
]})
answerOption
.
createObject
(
answerGrid
,
{
model
:
currentExerciseOptions
[
i
],
index
:
i
,
color
:
colors
[
i
%
24
]})
exerciseView
.
visible
=
true
exerciseView
.
state
=
"
initial
"
}
...
...
src/shell/qml/Main.qml
View file @
8a0bd2fc
...
...
@@ -44,11 +44,21 @@ Item {
width
:
menuBarWidth
;
height
:
parent
.
height
-
midiPlayer
.
height
anchors
{
left
:
parent
.
left
;
top
:
parent
.
top
}
onCurrentExerciseChanged
:
{
exerciseView
.
setCurrentExercise
(
currentExercise
);
rhythmAnswerView
.
resetAnswers
()
}
onBackPressed
:
{
core
.
soundBackend
.
stop
();
exerciseView
.
clearExerciseGrid
()
}
onUserMessageChanged
:
{
exerciseView
.
changeUserMessage
(
message
);
mainItem
.
userMessageChanged
(
message
)
}
}
MidiPlayer
{
id
:
midiPlayer
width
:
menuBarWidth
playbackLabel
:
core
.
soundBackend
.
playbackLabel
soundBackendState
:
core
.
soundBackend
.
state
onPlayActivated
:
core
.
soundBackend
.
play
()
onPauseActivated
:
core
.
soundBackend
.
pause
()
onStopActivated
:
core
.
soundBackend
.
stop
()
}
Image
{
id
:
background
...
...
@@ -71,14 +81,28 @@ Item {
anchors
{
bottom
:
parent
.
bottom
;
bottomMargin
:
14
;
horizontalCenter
:
parent
.
horizontalCenter
}
visible
:
false
exerciseView
:
exerciseView
onAnswerCompleted
:
exerciseView
.
checkAnswers
(
answers
)
}
ExerciseView
{
id
:
exerciseView
width
:
background
.
width
;
height
:
minuetMenu
.
height
+
20
anchors
{
top
:
background
.
top
;
horizontalCenter
:
background
.
horizontalCenter
}
onAnswerHoverEnter
:
pianoView
.
noteMark
(
chan
,
pitch
,
vel
,
color
)
onAnswerHoverExit
:
pianoView
.
noteUnmark
(
chan
,
pitch
,
vel
)
onAnswerClicked
:
rhythmAnswerView
.
answerClicked
(
answerImageSource
,
color
)
onStateChanged
:
mainItem
.
exerciseViewStateChanged
()
onShowCorrectAnswer
:
rhythmAnswerView
.
showCorrectAnswer
(
chosenExercises
,
chosenColors
)
onChosenExercisesChanged
:
rhythmAnswerView
.
fillCorrectAnswerGrid
()
}
}
Binding
{
target
:
core
.
exerciseController
property
:
"
currentExercise
"
value
:
minuetMenu
.
currentExercise
}
Binding
{
target
:
core
.
soundBackend
property
:
"
pitch
"
...
...
@@ -94,51 +118,10 @@ Item {
property
:
"
tempo
"
value
:
midiPlayer
.
tempo
}
Binding
{
target
:
midiPlayer
property
:
"
playbackLabel
"
value
:
core
.
soundBackend
.
playbackLabel
}
Binding
{
target
:
midiPlayer
property
:
"
sequencerState
"
value
:
core
.
soundBackend
.
state
}
Connections
{
target
:
midiPlayer
onPlayActivated
:
core
.
soundBackend
.
play
()
onPauseActivated
:
core
.
soundBackend
.
pause
()
onStopActivated
:
core
.
soundBackend
.
stop
()
}
// Connections {
// target: sequencer
// onNoteOn: pianoView.noteOn(chan, pitch, vel)
// onNoteOff: pianoView.noteOff(chan, pitch, vel)
// onAllNotesOff: pianoView.allNotesOff()
// }
Connections
{
target
:
minuetMenu
onItemChanged
:
exerciseView
.
itemChanged
(
model
)
onBreadcrumbPressed
:
exerciseView
.
clearExerciseGrid
()
onUserMessageChanged
:
exerciseView
.
changeUserMessage
(
message
)
}
Connections
{
target
:
minuetMenu
onItemChanged
:
rhythmAnswerView
.
resetAnswers
(
model
)
onBreadcrumbPressed
:
rhythmAnswerView
.
resetAnswers
()
onUserMessageChanged
:
mainItem
.
userMessageChanged
(
message
)
}
Connections
{
target
:
exerciseView
onAnswerHoverEnter
:
pianoView
.
noteMark
(
chan
,
pitch
,
vel
,
color
)
onAnswerHoverExit
:
pianoView
.
noteUnmark
(
chan
,
pitch
,
vel
)
onAnswerClicked
:
rhythmAnswerView
.
answerClicked
(
answerImageSource
,
color
)
onStateChanged
:
mainItem
.
exerciseViewStateChanged
()
onShowCorrectAnswer
:
rhythmAnswerView
.
showCorrectAnswer
(
chosenExercises
,
chosenColors
)
onChosenExercisesChanged
:
rhythmAnswerView
.
fillCorrectAnswerGrid
()
}
Connections
{
target
:
rhythmAnswerView
onAnswerCompleted
:
exerciseView
.
checkAnswers
(
answers
)
}
}
src/shell/qml/MinuetMenu.qml
View file @
8a0bd2fc
...
...
@@ -29,31 +29,20 @@ import org.kde.minuet 1.0
Item
{
id
:
minuetMenu
property
Item
selectedMenuItem
property
string
message
readonly
property
alias
currentExercise
:
stackView
.
currentExercise
signal
breadcrumbPressed
signal
itemChanged
(
var
model
)
signal
backPressed
signal
userMessageChanged
(
string
message
)
function
itemClicked
(
delegateRect
,
index
)
{
var
model
=
delegateRect
.
ListView
.
view
.
model
[
index
].
options
if
(
model
!=
undefined
)
{
core
.
exerciseController
.
currentExercise
=
model
minuetMenu
.
itemChanged
(
model
)
}
}
Button
{
id
:
breadcrumb
width
:
(
stackView
.
depth
>
1
)
?
24
:
0
;
height
:
parent
.
height
iconName
:
"
go-previous
"
onClicked
:
{
// sequencer.allNotesOff()
// sequencer.clearSong()
minuetMenu
.
breadcrumbPressed
()
selectedMenuItem
=
null
backPressed
()
stackView
.
currentExerciseMenuItem
=
null
stackView
.
pop
()
userMessageChanged
(
"
exercise
"
)
if
(
stackView
.
depth
==
1
)
...
...
@@ -63,6 +52,9 @@ Item {
StackView
{
id
:
stackView
property
var
currentExercise
property
Item
currentExerciseMenuItem
width
:
parent
.
width
-
breadcrumb
.
width
;
height
:
parent
.
height
anchors.left
:
breadcrumb
.
right
clip
:
true
...
...
@@ -83,10 +75,10 @@ Item {
message
=
userMessage
var
children
=
delegateRect
.
ListView
.
view
.
model
[
index
].
children
if
(
!
children
)
{
if
(
s
electedMenuItem
!=
undefined
)
selected
MenuItem
.
checked
=
false
if
(
s
tackView
.
currentExerciseMenuItem
!=
undefined
)
stackView
.
currentExercise
MenuItem
.
checked
=
false
userMessageChanged
(
message
)
itemClicked
(
delegateRect
,
index
)
s
elected
MenuItem
=
delegateRect
stackView
.
currentExercise
=
delegateRect
.
ListView
.
view
.
model
[
index
]
s
tackView
.
currentExercise
MenuItem
=
delegateRect
}
else
{
stackView
.
push
(
categoryMenu
.
createObject
(
stackView
,
{
model
:
children
}))
...
...
src/shell/qml/midiplayer/MidiPlayer.qml
View file @
8a0bd2fc
...
...
@@ -26,11 +26,11 @@ import org.kde.plasma.core 2.0 as PlasmaCore
import
org
.
kde
.
minuet
1.0
Rectangle
{
property
alias
pitch
:
pitchSlider
.
value
property
alias
volume
:
volumeSlider
.
value
property
alias
tempo
:
tempoSlider
.
value
readonly
property
alias
pitch
:
pitchSlider
.
value
readonly
property
alias
volume
:
volumeSlider
.
value
readonly
property
alias
tempo
:
tempoSlider
.
value
property
alias
playbackLabel
:
playbackLabelText
.
text
property
int
s
equencer
State
property
int
s
oundBackend
State
signal
playActivated
signal
pauseActivated
...
...
@@ -90,10 +90,10 @@ Rectangle {
width
:
playbackLabelText
.
contentWidth
/
2
anchors.horizontalCenterOffset
:
-
30
anchors
{
top
:
playbackLabelText
.
bottom
;
horizontalCenter
:
playbackLabelText
.
horizontalCenter
}
text
:
(
s
equencer
State
!=
ISoundBackend
.
PlayingState
)
?
i18n
(
"
Play
"
):
i18n
(
"
Pause
"
)
source
:
(
s
equencer
State
!=
ISoundBackend
.
PlayingState
)
?
"
../images/multimedia-play.png
"
:
"
../images/multimedia-pause.png
"
text
:
(
s
oundBackend
State
!=
ISoundBackend
.
PlayingState
)
?
i18n
(
"
Play
"
):
i18n
(
"
Pause
"
)
source
:
(
s
oundBackend
State
!=
ISoundBackend
.
PlayingState
)
?
"
../images/multimedia-play.png
"
:
"
../images/multimedia-pause.png
"
onActivated
:
{
if
(
s
equencerState
==
ISoundBackend
.
StoppedState
||
sequencer
State
==
ISoundBackend
.
PausedState
)
if
(
s
oundBackendState
==
ISoundBackend
.
StoppedState
||
soundBackend
State
==
ISoundBackend
.
PausedState
)
playActivated
()
else
pauseActivated
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment