Commit 17edcbf3 authored by Alexander Stippich's avatar Alexander Stippich Committed by Alexander Stippich
Browse files

implement shortcut to toggle filter view

Summary: use the shortcut as in dolphin to toggle the filter view. also simplifies the implementation a bit and adjust tests

Test Plan: filter view is toggled persistently across all views either with shortcut or button. test passes

Reviewers: #elisa, mgallien

Reviewed By: #elisa, mgallien

Tags: #elisa

Differential Revision: https://phabricator.kde.org/D11673
parent c3481ab8
......@@ -23,7 +23,7 @@ import "../../src/qml"
FocusScope {
property string filterState: ""
property bool expandedFilterView: false
function i18nc(string1,string2) {
return string2
......@@ -45,8 +45,8 @@ FocusScope {
Binding {
target: navigationActionBar1
property: "state"
value: filterState
property: "expandedFilterView"
value: expandedFilterView
}
NavigationActionBar {
......@@ -69,7 +69,7 @@ FocusScope {
enableGoBack: false
allowArtistNavigation: false
showRating: false
state: 'expanded'
expandedFilterView: true
height: 100
y: 200
......@@ -151,7 +151,7 @@ FocusScope {
filterViewChangedSpy2.clear();
showArtistSpy1.clear();
showArtistSpy2.clear();
filterState = "";
expandedFilterView = false;
}
function test_goBack() {
......@@ -206,23 +206,24 @@ FocusScope {
compare(showArtistSpy1.count, 0);
compare(showArtistSpy2.count, 0);
navigationActionBar1.state = ""
var showFilterButtonItem1 = findChild(navigationActionBar1, "showFilterButton");
verify(showFilterButtonItem1 !== null, "valid showFilterButton")
mouseClick(showFilterButtonItem1);
compare(filterViewChangedSpy1.count, 1);
var signalArgument1 = filterViewChangedSpy1.signalArguments[0];
filterState = signalArgument1[0];
compare(filterState,'expanded')
expandedFilterView = signalArgument1[0];
compare(expandedFilterView,true);
compare(navigationActionBar1.state,'expanded')
var showFilterButtonItem2 = findChild(navigationActionBar2, "showFilterButton");
verify(showFilterButtonItem2 !== null, "valid showFilterButton")
mouseClick(showFilterButtonItem2);
compare(filterViewChangedSpy2.count, 1);
var signalArgument2 = filterViewChangedSpy2.signalArguments[0];
compare(signalArgument2[0],"")
filterState = signalArgument2[0];
compare(filterState,"")
compare(navigationActionBar1.state,"")
compare(signalArgument2[0],false)
expandedFilterView = signalArgument2[0];
compare(expandedFilterView,false)
compare(navigationActionBar1.expandedFilterView, false)
compare(navigationActionBar1.state,'collapsed')
}
function test_replaceAndPlay() {
......@@ -266,10 +267,7 @@ FocusScope {
}
function test_filterRating() {
var showFilterButtonItem1 = findChild(navigationActionBar1, "showFilterButton");
verify(showFilterButtonItem1 !== null, "valid showFilterButton")
mouseClick(showFilterButtonItem1);
compare(filterViewChangedSpy1.count, 1);
expandedFilterView = true;
wait(200);
var ratingFilterItem1 = findChild(navigationActionBar1, "ratingFilter");
verify(ratingFilterItem1 !== null, "valid ratingFilter")
......
......@@ -144,6 +144,11 @@ void ElisaApplication::setupActions(const QString &actionName)
d->mCollection.addAction(goBackAction->objectName(), goBackAction);
}
if (actionName == QStringLiteral("edit_find") && KAuthorized::authorizeAction(actionName)) {
auto findAction = KStandardAction::find(this, &ElisaApplication::find, this);
d->mCollection.addAction(findAction->objectName(), findAction);
}
d->mCollection.readSettings();
#endif
}
......@@ -230,6 +235,8 @@ void ElisaApplication::configureElisa()
void ElisaApplication::goBack() {}
void ElisaApplication::find() {}
QStringList ElisaApplication::checkFileListAndMakeAbsolute(const QStringList &filesList, const QString &workingDirectory) const
{
QStringList filesToOpen;
......
......@@ -156,6 +156,8 @@ private Q_SLOTS:
void goBack();
void find();
private:
void setupActions(const QString &actionName);
......
......@@ -23,10 +23,13 @@ import QtQuick.Layouts 1.2
import org.kde.elisa 1.0
RowLayout {
id: contentViewContainer
spacing: 0
property alias playList: playList
signal toggleSearch()
function goBack() {
localAlbums.goBack()
localArtists.goBack()
......@@ -154,11 +157,11 @@ RowLayout {
Binding {
target: allAlbumsView
property: 'filterState'
value: persistentSettings.filterState
property: 'expandedFilterView'
value: persistentSettings.expandedFilterView
}
onFilterViewChanged: persistentSettings.filterState = filterState
onFilterViewChanged: persistentSettings.expandedFilterView = expandedFilterView
}
visible: opacity > 0
......@@ -202,11 +205,11 @@ RowLayout {
Binding {
target: allArtistsView
property: 'filterState'
value: persistentSettings.filterState
property: 'expandedFilterView'
value: persistentSettings.expandedFilterView
}
onFilterViewChanged: persistentSettings.filterState = filterState
onFilterViewChanged: persistentSettings.expandedFilterView = expandedFilterView
}
visible: opacity > 0
......@@ -233,11 +236,11 @@ RowLayout {
Binding {
target: allTracksView
property: 'filterState'
value: persistentSettings.filterState
property: 'expandedFilterView'
value: persistentSettings.expandedFilterView
}
onFilterViewChanged: persistentSettings.filterState = filterState
onFilterViewChanged: persistentSettings.expandedFilterView = expandedFilterView
}
visible: opacity > 0
......@@ -566,11 +569,11 @@ RowLayout {
Binding {
target: innerAlbumGridView
property: 'filterState'
value: persistentSettings.filterState
property: 'expandedFilterView'
value: persistentSettings.expandedFilterView
}
onFilterViewChanged: persistentSettings.filterState = filterState
onFilterViewChanged: persistentSettings.expandedFilterView = expandedFilterView
}
}
......@@ -600,13 +603,15 @@ RowLayout {
}
onGoBack: stackView.pop()
expandedFilterView: true
Binding {
target: albumGridView
property: 'filterState'
value: persistentSettings.filterState
property: 'expandedFilterView'
value: persistentSettings.expandedFilterView
}
onFilterViewChanged: persistentSettings.filterState = filterState
onFilterViewChanged: persistentSettings.expandedFilterView = expandedFilterView
}
}
}
......@@ -44,7 +44,19 @@ ApplicationWindow {
title: i18n("Elisa")
property var goBackAction: elisa.action("go_back")
property var findAction: elisa.action("edit_find")
Controls1.Action {
shortcut: findAction.shortcut
onTriggered: {
if ( persistentSettings.expandedFilterView == true)
{
persistentSettings.expandedFilterView = false
} else {
persistentSettings.expandedFilterView = true
}
}
}
Controls1.Action {
shortcut: goBackAction.shortcut
onTriggered: contentView.goBack()
......@@ -87,7 +99,7 @@ ApplicationWindow {
property double playControlItemVolume : 100.0
property bool playControlItemMuted : false
property string filterState
property bool expandedFilterView: false
}
......
......@@ -36,11 +36,11 @@ FocusScope {
property alias contentModel: contentDirectoryView.model
property alias showRating: navigationBar.showRating
property bool delegateDisplaySecondaryText: true
property alias filterState: navigationBar.state
property alias expandedFilterView: navigationBar.expandedFilterView
signal open(var innerMainTitle, var innerSecondaryTitle, var innerImage, var databaseId)
signal goBack()
signal filterViewChanged(string filterState)
signal filterViewChanged(bool expandedFilterView)
SystemPalette {
id: myPalette
......@@ -87,7 +87,7 @@ FocusScope {
onGoBack: gridView.goBack()
onFilterViewChanged: gridView.filterViewChanged(filterState)
onFilterViewChanged: gridView.filterViewChanged(expandedFilterView)
}
Rectangle {
......
......@@ -31,13 +31,13 @@ FocusScope {
property var artistName
property var albumArtUrl
property bool isSingleDiscAlbum
property alias filterState: navigationBar.state
property alias expandedFilterView: navigationBar.expandedFilterView
property var albumId
property alias contentModel: contentDirectoryView.model
signal showArtist(var name)
signal goBack();
signal filterViewChanged(string filterState)
signal filterViewChanged(bool expandedFilterView)
SystemPalette {
id: myPalette
......@@ -81,7 +81,7 @@ FocusScope {
onGoBack: topListing.goBack()
onFilterViewChanged: topListing.filterViewChanged(filterState)
onFilterViewChanged: topListing.filterViewChanged(expandedFilterView)
onShowArtist: topListing.showArtist(topListing.contentModel.sourceModel.author)
......
......@@ -31,9 +31,9 @@ FocusScope {
property var stackView
property alias contentModel: contentDirectoryView.model
property alias filterState: navigationBar.state
property alias expandedFilterView: navigationBar.expandedFilterView
signal filterViewChanged(string filterState)
signal filterViewChanged(bool expandedFilterView)
SystemPalette {
id: myPalette
......@@ -76,7 +76,7 @@ FocusScope {
onEnqueue: contentModel.enqueueToPlayList()
onFilterViewChanged: rootElement.filterViewChanged(filterState)
onFilterViewChanged: rootElement.filterViewChanged(expandedFilterView)
onReplaceAndPlay: contentModel.replaceAndPlayOfPlayList()
}
......
......@@ -36,12 +36,13 @@ FocusScope {
property alias filterText: filterTextInput.text
property alias filterRating: ratingFilter.starRating
property bool enableGoBack: true
property bool expandedFilterView: false
signal enqueue();
signal replaceAndPlay();
signal goBack();
signal showArtist();
signal filterViewChanged(string filterState);
signal filterViewChanged(bool expandedFilterView);
Controls1.Action {
id: goPreviousAction
......@@ -52,12 +53,9 @@ FocusScope {
Controls1.Action {
id: showFilterAction
text: navigationBar.state === "" ? i18nc("Show filters in the navigation bar", "Show Search Options") : i18nc("Hide filters in the navigation bar", "Hide Search Options")
iconName: navigationBar.state === "" ? "go-down-search" : "go-up-search"
onTriggered: {
navigationBar.state === "" ? navigationBar.state = 'expanded' : navigationBar.state = ""
filterViewChanged(navigationBar.state)
}
text: !navigationBar.expandedFilterView ? i18nc("Show filters in the navigation bar", "Show Search Options") : i18nc("Hide filters in the navigation bar", "Hide Search Options")
iconName: !navigationBar.expandedFilterView ? "go-down-search" : "go-up-search"
onTriggered: filterViewChanged(!navigationBar.expandedFilterView)
}
ColumnLayout {
......@@ -325,7 +323,8 @@ FocusScope {
states: [
State {
name: ""
name: 'collapsed'
when: !expandedFilterView
PropertyChanges {
target: navigationBar
height: elisaTheme.navigationBarHeight
......@@ -337,6 +336,7 @@ FocusScope {
},
State {
name: 'expanded'
when: expandedFilterView
PropertyChanges {
target: navigationBar
height: elisaTheme.navigationBarHeight + elisaTheme.navigationBarFilterHeight
......@@ -348,6 +348,7 @@ FocusScope {
}
]
transitions: Transition {
from: "expanded,collapsed"
PropertyAnimation {
properties: "height"
easing.type: Easing.Linear
......
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