Commit bd1f434a authored by Andreas Cord-Landwehr's avatar Andreas Cord-Landwehr
Browse files

Close phrase editor when unit is closed.

parent b6f93d7b
......@@ -47,6 +47,12 @@ Item {
}
}
function close()
{
root.phrase = null
editorClosed()
}
function applyChanges()
{
root.phrase.type = root.__changedPhraseType
......@@ -81,11 +87,14 @@ Item {
anchors.verticalCenter: inputLine.verticalCenter
onTextChanged: root.__changedPhraseText = text
onPhraseChanged: {
text = root.phrase.text
if (root.phrase != null)
text = root.phrase.text
else
text = ""
}
onAccepted: {
applyChanges()
editorClosed()
close()
}
}
PlasmaComponents.ToolButton {
......@@ -96,7 +105,7 @@ Item {
iconSource: "dialog-ok-apply"
onClicked: {
applyChanges()
editorClosed()
close()
}
}
PlasmaComponents.ToolButton {
......@@ -109,16 +118,17 @@ Item {
phraseInput.text = root.phrase.text
phraseEditStateSetter.updateCheckedStates()
phraseTypeSetter.updateCheckedStates()
editorClosed()
close()
}
}
}
Row {
id: originalPhraseInfo
property string originalPhrase : (root.phrase != null) ? root.phrase.i18nText : ""
spacing: 10
visible: { root.phrase.i18nText != "" }
visible: { root.phrase != null && originalPhrase != "" }
Text {
text: i18n("Original Phrase:") + " <i>" + root.phrase.i18nText + "</i>"
text: i18n("Original Phrase:") + " <i>" + originalPhraseInfo.originalPhrase + "</i>"
width: root.width - 70
wrapMode: Text.WordWrap
}
......@@ -150,7 +160,7 @@ Item {
width: 100
text: model.title
checkable: true
checked: phrase.hasPhoneme(model.dataRole)
checked: { phrase != null && phrase.hasPhoneme(model.dataRole) }
onClicked: { //TODO this button has no undo operation yet
if (checked) {
phrase.addPhoneme(model.dataRole)
......@@ -169,7 +179,10 @@ Item {
height: 30 * count / columns + 60
cellWidth: 100
cellHeight: 30
model: PhonemeModel { language: root.phrase.unit.course.language }
model:
PhonemeModel {
language: { (phrase != null) ? root.phrase.unit.course.language : null }
}
delegate: phonemeItem
}
}
......
......@@ -38,11 +38,16 @@ Item {
onPhraseChanged: {
updateCheckedStates();
selectedState = phrase.editState
if (phrase != null) {
selectedState = phrase.editState
}
}
function updateCheckedStates()
{
if (root.phrase == null) {
return;
}
switch (root.phrase.editState) {
case Phrase.Unknown:
buttonUnknown.checked = true;
......
......@@ -50,11 +50,11 @@ Item {
text: i18n("Existing Recording:")
}
PlasmaComponents.ToolButton {
property int soundState: phrase.playbackSoundState
property int soundState: (phrase != null) ? phrase.playbackSoundState : Phrase.StoppedState
anchors.verticalCenter: parent.verticalCenter
iconSource: "artikulate-media-playback-start"
enabled: phrase.isSound
enabled: { phrase != null && phrase.isSound }
onClicked: {
if (soundState == Phrase.PlayingState) {
......@@ -82,7 +82,7 @@ Item {
text: i18n("Create New Recording:")
}
PlasmaComponents.ToolButton {
property int recordingState: phrase.recordingState
property int recordingState: (root.phrase != null) ? root.phrase.recordingState : Phrase.NotRecordingState
property bool recording: true
anchors.verticalCenter: parent.verticalCenter
......@@ -110,7 +110,7 @@ Item {
}
}
PlasmaComponents.ToolButton {
property int soundState: phrase.playbackNativeSoundBufferState
property int soundState: (phrase != null) ? phrase.playbackNativeSoundBufferState : Phrase.StoppedState
anchors.verticalCenter: parent.verticalCenter
iconSource: "artikulate-media-playback-start"
......
......@@ -38,11 +38,16 @@ Item {
onPhraseChanged: {
updateCheckedStates()
root.selectedType = phrase.type
if (phrase != null) {
root.selectedType = phrase.type
}
}
function updateCheckedStates()
{
if (root.phrase == null) {
return;
}
switch (root.phrase.type) {
case Phrase.Word:
buttonWord.checked = true;
......
......@@ -124,6 +124,7 @@ Item {
font.pointSize: 20;
onClicked: {
closeUnit()
phraseEditor.close()
}
}
Text {
......
Supports Markdown
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