Commit 789317d0 authored by Nate Graham's avatar Nate Graham

Clean up FlatButtonWithToolTip code

parent 23fa1d6b
......@@ -117,7 +117,7 @@ Item {
compare(startPlaybackSpy.count, 1);
compare(pausePlaybackSpy.count, 0);
compare(removeFromPlaylistSpy.count, 0);
compare(switchToTrackSpy.count, 0);
compare(switchToTrackSpy.count, 1);
}
......
......@@ -28,8 +28,8 @@ Button {
activeFocusOnTab: true
Keys.onReturnPressed: action.trigger()
Accessible.onPressAction: action.trigger()
Keys.onReturnPressed: flatButtonWithToolTip.clicked()
Accessible.onPressAction: flatButtonWithToolTip.clicked()
flat: true
display: AbstractButton.IconOnly
......@@ -42,5 +42,5 @@ Button {
ToolTip.visible: hovered
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
ToolTip.text: flatButtonWithToolTip.action.text
ToolTip.text: flatButtonWithToolTip.text
}
......@@ -50,29 +50,6 @@ FocusScope {
Accessible.name: title
Accessible.description: title
Action {
id: enqueueAction
text: i18nc("Enqueue current track", "Enqueue")
icon.name: "list-add"
onTriggered: enqueue(databaseId, title)
}
Action {
id: viewDetailsAction
text: i18nc("Show track metadata", "View Details")
icon.name: "help-about"
onTriggered: {
callOpenMetaDataView(databaseId)
}
}
Action {
id: replaceAndPlayAction
text: i18nc("Clear play list and enqueue current track", "Play Now and Replace Play List")
icon.name: "media-playback-start"
onTriggered: replaceAndPlay(databaseId, title)
}
Keys.onReturnPressed: enqueue(databaseId, title)
Keys.onEnterPressed: enqueue(databaseId, title)
......@@ -276,40 +253,33 @@ FocusScope {
FlatButtonWithToolTip {
id: detailsButton
height: elisaTheme.delegateHeight
width: elisaTheme.delegateHeight
icon.height: elisaTheme.smallControlButtonSize
icon.width: elisaTheme.smallControlButtonSize
action: viewDetailsAction
Accessible.onPressAction: action.trigger()
text: i18nc("Show track metadata", "View Details")
icon.name: "help-about"
onClicked: callOpenMetaDataView(databaseId)
}
FlatButtonWithToolTip {
id: enqueueButton
height: elisaTheme.delegateHeight
width: elisaTheme.delegateHeight
icon.height: elisaTheme.smallControlButtonSize
icon.width: elisaTheme.smallControlButtonSize
action: enqueueAction
Accessible.onPressAction: action.trigger()
text: i18nc("Enqueue current track", "Enqueue")
icon.name: "list-add"
onClicked: enqueue(databaseId, title)
}
FlatButtonWithToolTip {
id: clearAndEnqueueButton
scale: LayoutMirroring.enabled ? -1 : 1
height: elisaTheme.delegateHeight
width: elisaTheme.delegateHeight
icon.height: elisaTheme.smallControlButtonSize
icon.width: elisaTheme.smallControlButtonSize
action: replaceAndPlayAction
Accessible.onPressAction: action.trigger()
text: i18nc("Clear play list and enqueue current track", "Play Now and Replace Play List")
icon.name: "media-playback-start"
onClicked: replaceAndPlay(databaseId, title)
}
}
}
......
......@@ -68,14 +68,14 @@ FocusScope {
id: retryLoadAction
text: i18nc("Retry", "Retry")
icon.name: "edit-redo"
onTriggered: loadPlaylist.trigger()
onTriggered: loadPlaylistButton.clicked()
}
Kirigami.Action {
id: retrySaveAction
text: i18nc("Retry", "Retry")
icon.name: "edit-redo"
onTriggered: savePlaylist.trigger()
onTriggered: savePlaylistButton.clicked()
}
Connections {
......@@ -102,51 +102,6 @@ FocusScope {
Accessible.role: Accessible.Pane
Accessible.name: viewTitle.text
Action {
id: clearPlayList
text: i18nc("Remove all tracks from play list", "Clear Playlist")
icon.name: 'edit-clear-all'
enabled: elisa.mediaPlayList ? elisa.mediaPlayList.tracksCount > 0 : false
onTriggered: elisa.mediaPlayList.clearPlayList()
}
Action {
id: showCurrentTrack
text: i18nc("Show currently played track inside playlist", "Show Current Track")
icon.name: 'media-show-active-track-amarok'
enabled: elisa.mediaPlayList ? elisa.mediaPlayList.tracksCount > 0 : false
onTriggered: {
playListView.positionViewAtIndex(elisa.mediaPlayList.currentTrackRow, ListView.Contain)
playListView.currentIndex = elisa.mediaPlayList.currentTrackRow
playListView.currentItem.forceActiveFocus()
}
}
Action {
id: loadPlaylist
text: i18nc("Load a playlist file", "Load Playlist...")
icon.name: 'document-open'
onTriggered:
{
fileDialog.fileMode = PlatformDialog.FileDialog.OpenFile
fileDialog.file = ''
fileDialog.open()
}
}
Action {
id: savePlaylist
text: i18nc("Save a playlist file", "Save Playlist...")
icon.name: 'document-save'
enabled: elisa.mediaPlayList ? elisa.mediaPlayList.tracksCount > 0 : false
onTriggered:
{
fileDialog.fileMode = PlatformDialog.FileDialog.SaveFile
fileDialog.file = ''
fileDialog.open()
}
}
PlatformDialog.FileDialog {
id: fileDialog
......@@ -189,28 +144,41 @@ FocusScope {
// Toolbar buttons
FlatButtonWithToolTip {
action: showCurrentTrack
icon.height: elisaTheme.smallControlButtonSize
icon.width: elisaTheme.smallControlButtonSize
text: i18nc("Show currently played track inside playlist", "Show Current Track")
icon.name: 'media-show-active-track-amarok'
enabled: elisa.mediaPlayList ? elisa.mediaPlayList.tracksCount > 0 : false
onClicked: {
playListView.positionViewAtIndex(elisa.mediaPlayList.currentTrackRow, ListView.Contain)
playListView.currentIndex = elisa.mediaPlayList.currentTrackRow
playListView.currentItem.forceActiveFocus()
}
},
FlatButtonWithToolTip {
action: savePlaylist
icon.height: elisaTheme.smallControlButtonSize
icon.width: elisaTheme.smallControlButtonSize
id: savePlaylistButton
text: i18nc("Save a playlist file", "Save Playlist...")
icon.name: 'document-save'
enabled: elisa.mediaPlayList ? elisa.mediaPlayList.tracksCount > 0 : false
onClicked: {
fileDialog.fileMode = PlatformDialog.FileDialog.SaveFile
fileDialog.file = ''
fileDialog.open()
}
},
FlatButtonWithToolTip {
action: loadPlaylist
icon.height: elisaTheme.smallControlButtonSize
icon.width: elisaTheme.smallControlButtonSize
id: loadPlaylistButton
text: i18nc("Load a playlist file", "Load Playlist...")
icon.name: 'document-open'
onClicked: {
fileDialog.fileMode = PlatformDialog.FileDialog.OpenFile
fileDialog.file = ''
fileDialog.open()
}
},
FlatButtonWithToolTip {
action: clearPlayList
icon.height: elisaTheme.smallControlButtonSize
icon.width: elisaTheme.smallControlButtonSize
text: i18nc("Remove all tracks from play list", "Clear Playlist")
icon.name: 'edit-clear-all'
enabled: elisa.mediaPlayList ? elisa.mediaPlayList.tracksCount > 0 : false
onClicked: elisa.mediaPlayList.clearPlayList()
}
]
}
......
......@@ -57,65 +57,6 @@ FocusScope {
id: elisaTheme
}
Action {
id: applicationMenuAction
text: i18nc("open application menu", "Application Menu")
icon.name: "application-menu"
onTriggered: openMenu()
}
Action {
id: repeatAction
text: i18nc("toggle repeat mode for playlist", "Toggle Repeat")
icon.name: musicWidget.repeat ? "media-repeat-all" : "media-repeat-none"
onTriggered: musicWidget.repeat = !musicWidget.repeat
}
Action {
id: shuffleAction
text: i18nc("toggle shuffle mode for playlist", "Toggle Shuffle")
icon.name: musicWidget.shuffle ? "media-playlist-shuffle" : "media-playlist-normal"
onTriggered: musicWidget.shuffle = !musicWidget.shuffle
}
Action {
id: muteAction
text: i18nc("toggle mute mode for player", "Toggle Mute")
icon.name: musicWidget.muted ? "player-volume-muted" : "player-volume"
onTriggered: musicWidget.muted = !musicWidget.muted
}
Action {
id: playPauseAction
text: i18nc("toggle play and pause for the audio player", "Toggle Play and Pause")
icon.name: musicWidget.isPlaying? "media-playback-pause" : "media-playback-start"
onTriggered: musicWidget.isPlaying ? musicWidget.pause() : musicWidget.play()
enabled: playEnabled
}
Action {
id: skipBackwardAction
text: i18nc("skip backward in playlists", "Skip Backward")
icon.name: musicWidget.LayoutMirroring.enabled ? "media-skip-forward" : "media-skip-backward"
onTriggered: musicWidget.playPrevious()
enabled: skipBackwardEnabled
}
Action {
id: skipForwardAction
text: i18nc("skip forward in playlists", "Skip Forward")
icon.name: musicWidget.LayoutMirroring.enabled ? "media-skip-backward" : "media-skip-forward"
onTriggered: musicWidget.playNext()
enabled: skipForwardEnabled
}
Action {
id: minimizeMaximizeAction
text: i18nc("toggle between maximized and minimized ivre", "Toggle Maximize")
icon.name: musicWidget.isMaximized ? "draw-arrow-up" : "draw-arrow-down"
onTriggered: musicWidget.isMaximized = !musicWidget.isMaximized
}
Rectangle {
anchors.fill: parent
......@@ -129,39 +70,33 @@ FocusScope {
FlatButtonWithToolTip {
id: minimizeMaximizeButton
action: minimizeMaximizeAction
icon.width: elisaTheme.smallControlButtonSize
icon.height: elisaTheme.smallControlButtonSize
Layout.rightMargin: LayoutMirroring.enabled ? elisaTheme.mediaPlayerHorizontalMargin : 0
Layout.leftMargin: !LayoutMirroring.enabled ? elisaTheme.mediaPlayerHorizontalMargin : 0
text: i18nc("toggle between maximized and minimized ivre", "Toggle Maximize")
icon.name: musicWidget.isMaximized ? "draw-arrow-up" : "draw-arrow-down"
onClicked: musicWidget.isMaximized = !musicWidget.isMaximized
}
FlatButtonWithToolTip {
id: skipBackwardButton
action: skipBackwardAction
focus: skipBackwardEnabled
icon.width: elisaTheme.smallControlButtonSize
icon.height: elisaTheme.smallControlButtonSize
enabled: skipBackwardEnabled
text: i18nc("skip backward in playlists", "Skip Backward")
icon.name: musicWidget.LayoutMirroring.enabled ? "media-skip-forward" : "media-skip-backward"
onClicked: musicWidget.playPrevious()
}
FlatButtonWithToolTip {
id: playPauseButton
action: playPauseAction
focus: playEnabled
icon.width: elisaTheme.smallControlButtonSize
icon.height: elisaTheme.smallControlButtonSize
enabled: playEnabled
text: i18nc("toggle play and pause for the audio player", "Toggle Play and Pause")
icon.name: musicWidget.isPlaying? "media-playback-pause" : "media-playback-start"
onClicked: musicWidget.isPlaying ? musicWidget.pause() : musicWidget.play()
}
FlatButtonWithToolTip {
id: skipForwardButton
action: skipForwardAction
focus: skipForwardEnabled
icon.width: elisaTheme.smallControlButtonSize
icon.height: elisaTheme.smallControlButtonSize
enabled: skipForwardEnabled
text: i18nc("skip forward in playlists", "Skip Forward")
icon.name: musicWidget.LayoutMirroring.enabled ? "media-skip-backward" : "media-skip-forward"
onClicked: musicWidget.playNext()
}
TextMetrics {
......@@ -310,11 +245,9 @@ FocusScope {
FlatButtonWithToolTip {
id: muteButton
action: muteAction
focus: true
icon.width: elisaTheme.smallControlButtonSize
icon.height: elisaTheme.smallControlButtonSize
text: i18nc("toggle mute mode for player", "Toggle Mute")
icon.name: musicWidget.muted ? "player-volume-muted" : "player-volume"
onClicked: musicWidget.muted = !musicWidget.muted
}
MouseArea {
......@@ -395,21 +328,17 @@ FocusScope {
FlatButtonWithToolTip {
focus: true
action: shuffleAction
id: shuffleButton
icon.width: elisaTheme.smallControlButtonSize
icon.height: elisaTheme.smallControlButtonSize
text: i18nc("toggle shuffle mode for playlist", "Toggle Shuffle")
icon.name: musicWidget.shuffle ? "media-playlist-shuffle" : "media-playlist-normal"
onClicked: musicWidget.shuffle = !musicWidget.shuffle
}
FlatButtonWithToolTip {
focus: true
action: repeatAction
id: repeatButton
icon.width: elisaTheme.smallControlButtonSize
icon.height: elisaTheme.smallControlButtonSize
text: i18nc("toggle repeat mode for playlist", "Toggle Repeat")
icon.name: musicWidget.repeat ? "media-repeat-all" : "media-repeat-none"
onClicked: musicWidget.repeat = !musicWidget.repeat
}
// Not a FlatButtonWithToolTip because we want text
......@@ -437,11 +366,9 @@ FocusScope {
FlatButtonWithToolTip {
id: menuButton
action: applicationMenuAction
focus: true
icon.width: elisaTheme.smallControlButtonSize
icon.height: elisaTheme.smallControlButtonSize
text: i18nc("open application menu", "Application Menu")
icon.name: "application-menu"
onClicked: openMenu()
}
}
......
......@@ -50,72 +50,17 @@ ColumnLayout {
signal showArtist();
signal sort(var order);
Action {
id: goPreviousAction
text: i18nc("navigate back in the views stack", "Back")
icon.name: (Qt.application.layoutDirection == Qt.RightToLeft) ? "go-next" : "go-previous"
onTriggered: goBack()
enabled: enableGoBack
}
Action {
id: replaceAndPlayAction
text: i18n("Play now, replacing contents of Playlist")
icon.name: "media-playback-start"
onTriggered: replaceAndPlay()
}
Action {
id: enqueueAction
text: i18nc("Add current list to playlist", "Enqueue")
icon.name: "list-add"
onTriggered: enqueue()
}
Action {
id: createRadioAction
text: i18nc("Create a new radio", "Create a radio")
icon.name: "media-track-add-amarok"
onTriggered: createRadio()
}
Action {
id: showFilterAction
text: !navigationBar.expandedFilterView ? i18nc("Show filters in the navigation bar", "Show Search Options") : i18nc("Hide filters in the navigation bar", "Hide Search Options")
icon.name: 'search'
checkable: true
checked: expandedFilterView
onTriggered: persistentSettings.expandedFilterView = !persistentSettings.expandedFilterView
}
Action {
id: sortAction
text: i18nc("Toggle between ascending and descending order", "Toggle sort order")
icon.name: sortOrder ? "view-sort-ascending" : "view-sort-descending"
onTriggered: sortOrder ? sort(Qt.DescendingOrder) : sort(Qt.AscendingOrder)
}
Action {
id: showArtistAction
text: i18nc("Button to navigate to the artist of the album", "Display Artist")
icon.name: "view-media-artist"
onTriggered: showArtist()
}
HeaderFooterToolbar {
type: filterRow.visible? "other" : "header"
contentItems: [
FlatButtonWithToolTip {
action: goPreviousAction
id: goPreviousButton
objectName: 'goPreviousButton'
icon.height: elisaTheme.smallControlButtonSize
icon.width: elisaTheme.smallControlButtonSize
focus: enableGoBack
visible: enableGoBack
text: i18nc("navigate back in the views stack", "Back")
icon.name: (Qt.application.layoutDirection == Qt.RightToLeft) ? "go-next" : "go-previous"
onClicked: goBack()
},
Item {
id: spacer
......@@ -168,62 +113,48 @@ ColumnLayout {
}
},
FlatButtonWithToolTip {
action: createRadioAction
objectName: 'createRadioButton'
icon.height: elisaTheme.smallControlButtonSize
icon.width: elisaTheme.smallControlButtonSize
focus: true
visible: showCreateRadioButton
text: i18nc("Create a new radio", "Create a radio")
icon.name: "media-track-add-amarok"
onClicked: createRadio()
},
FlatButtonWithToolTip {
action: enqueueAction
objectName: 'enqueueButton'
icon.height: elisaTheme.smallControlButtonSize
icon.width: elisaTheme.smallControlButtonSize
focus: true
visible: !showCreateRadioButton
text: i18nc("Add current list to playlist", "Enqueue")
icon.name: "list-add"
onClicked: enqueue()
},
FlatButtonWithToolTip {
action: replaceAndPlayAction
objectName: 'replaceAndPlayButton'
icon.height: elisaTheme.smallControlButtonSize
icon.width: elisaTheme.smallControlButtonSize
visible: !showCreateRadioButton
text: i18n("Play now, replacing contents of Playlist")
icon.name: "media-playback-start"
onClicked: replaceAndPlay()
},
FlatButtonWithToolTip {
action: showArtistAction
objectName: 'showArtistButton'
icon.height: elisaTheme.smallControlButtonSize
icon.width: elisaTheme.smallControlButtonSize
visible: allowArtistNavigation && !showCreateRadioButton
text: i18nc("Button to navigate to the artist of the album", "Display Artist")
icon.name: "view-media-artist"
onClicked: showArtist()
},
FlatButtonWithToolTip {
action: sortAction
objectName: 'sortAscendingButton'
icon.height: elisaTheme.smallControlButtonSize
icon.width: elisaTheme.smallControlButtonSize
visible: enableSorting && !showCreateRadioButton
text: i18nc("Toggle between ascending and descending order", "Toggle sort order")
icon.name: sortOrder ? "view-sort-ascending" : "view-sort-descending"
onClicked: sortOrder ? sort(Qt.DescendingOrder) : sort(Qt.AscendingOrder)
},
FlatButtonWithToolTip {
action: showFilterAction
objectName: 'showFilterButton'
icon.height: elisaTheme.smallControlButtonSize
icon.width: elisaTheme.smallControlButtonSize
visible: !showCreateRadioButton
text: !navigationBar.expandedFilterView ? i18nc("Show filters in the navigation bar", "Show Search Options") : i18nc("Hide filters in the navigation bar", "Hide Search Options")
icon.name: 'search'
checkable: true
checked: expandedFilterView
onClicked: persistentSettings.expandedFilterView = !persistentSettings.expandedFilterView
}
]
}
......@@ -242,7 +173,7 @@ ColumnLayout {
objectName: 'filterTextInput'
Layout.fillWidth: true
focusSequence: null
focusSequence: ""
Accessible.role: Accessible.EditableText
......
......@@ -60,52 +60,6 @@ FocusScope {
height: elisaTheme.playListDelegateHeight
Action {
id: removeFromPlayList
text: i18nc("Remove current track from play list", "Remove")
icon.name: "error"
onTriggered: {
playListEntry.removeFromPlaylist(playListEntry.index)
}
}
Action {
id: playNow
text: i18nc("Play now current track from play list", "Play Now")
icon.name: "media-playback-start"
enabled: !(isPlaying === MediaPlayList.IsPlaying) && isValid
onTriggered: {
if (isPlaying === MediaPlayList.NotPlaying) {
playListEntry.switchToTrack(playListEntry.index)
}
playListEntry.startPlayback()
}
}
Action {
id: pauseNow
text: i18nc("Pause current track from play list", "Pause")
icon.name: "media-playback-pause"
enabled: isPlaying === MediaPlayList.IsPlaying && isValid
onTriggered: playListEntry.pausePlayback()
}
Action {
id: showInfo
text: i18nc("Show track metadata", "View Details")
icon.name: "help-about"
enabled: isValid
onTriggered: {
if (metadataLoader.active === false) {
metadataLoader.active = true
}
else {
metadataLoader.item.close();
metadataLoader.active = false
}
}
}
Loader {
id: metadataLoader
active: false
......@@ -345,16 +299,26 @@ FocusScope {
sourceComponent: Row {
anchors.centerIn: parent
enabled: isValid
FlatButtonWithToolTip {
id: infoButton
objectName: 'infoButton'
implicitHeight: elisaTheme.playListDelegateHeight
implicitWidth: elisaTheme.playListDelegateHeight
icon.height: elisaTheme.smallControlButtonSize
icon.width: elisaTheme.smallControlButtonSize
action: showInfo
text: i18nc("Show track metadata", "View Details")
icon.name: "help-about"
onClicked: {
if (metadataLoader.active === false) {
metadataLoader.active = true
}
else {
metadataLoader.item.close();
metadataLoader.active = false
}
}
}
FlatButtonWithToolTip {
......@@ -363,24 +327,29 @@ FocusScope {
implicitHeight: elisaTheme.playListDelegateHeight
implicitWidth: elisaTheme.playListDelegateHeight
icon.height: elisaTheme.smallControlButtonSize
icon.width: elisaTheme.smallControlButtonSize
scale: LayoutMirroring.enabled ? -1 : 1 // We can mirror the symmetrical pause icon
action: !(isPlaying === MediaPlayList.IsPlaying) ? playNow : pauseNow
text: (isPlaying === MediaPlayList.IsPlaying) ? i18nc("Pause current track from play list", "Pause") : i18nc("Play this track from play list", "Play")
icon.name: (isPlaying === MediaPlayList.IsPlaying) ? "media-playback-pause" : "media-playback-start"
onClicked: if (isPlaying === MediaPlayList.IsPlaying) {
playListEntry.pausePlayback()
} else {
playListEntry.switchToTrack(playListEntry.index)
playListEntry.startPlayback()
}
}
FlatButtonWithToolTip {
id: removeButton
objectName: 'removeButton'
action: removeFromPlayList
implicitHeight: elisaTheme.playListDelegateHeight
implicitWidth: elisaTheme.playListDelegateHeight
icon.height: elisaTheme.smallControlButtonSize
icon.width: elisaTheme.smallControlButtonSize
text: i18nc("Remove current track from play list", "Remove")
icon.name: "error"
onClicked: playListEntry.removeFromPlaylist(playListEntry.index)
}
}
......
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