on xenial help sign in
Number with the active filters
commit42f822d623ce9cc0ee5557d1d99714c1ad1899e3 authorAlbert Astals Cid <albert.astals@canonical.com> dateTue 13 Oct 2015, 17:12 (11 years ago) parent036c0ff
3 files changed+34−24
qml/Dash/GenericScopeView.qml+1 qml/Dash/PageHeader.qml+32−20 tests/mocks/Unity/fake_optionselectoroptions.cpp+1−4
qml/Dash/GenericScopeView.qml+1
@@ -623,6 +623,7 @@ FocusScope {
623623 searchHistory: SearchHistoryModel
624624 searchHint: scopeView.scope && scopeView.scope.searchHint || i18n.ctr("Label: Hint for dash search line edit", "Search")
625625 scopeHasFilters: scopeView.scope.filters != null
626+ activeFiltersCount: scopeView.scope.activeFiltersCount
626627 showBackButton: scopeView.hasBackAction
627628 searchEntryEnabled: true
628629 settingsEnabled: scopeView.scope && scopeView.scope.settings && scopeView.scope.settings.count > 0 || false
qml/Dash/PageHeader.qml+32−20
@@ -26,6 +26,7 @@ Item {
2626 implicitHeight: headerContainer.height + bottomContainer.height + signatureLineHeight
2727 readonly property real signatureLineHeight: showSignatureLine ? units.gu(2) : 0
2828
29+ property int activeFiltersCount: 0
2930 property bool scopeHasFilters: false
3031 property bool showBackButton: false
3132 property bool backIsClose: false
@@ -206,31 +207,42 @@ Item {
206207 text: root.navigationTag
207208 }
208209
209− secondaryItem: AbstractButton {
210− id: clearOrSettingsButton
210+ secondaryItem: Row {
211211 height: searchTextField.height
212− width: height
213− enabled: searchTextField.text.length > 0 || root.navigationTag != ""
214−
215− Image {
216− objectName: "clearIcon"
217− anchors.fill: parent
218− anchors.margins: units.gu(.75)
219− source: searchTextField.clearIsSettings ? "image://theme/settings" : "image://theme/clear"
220− opacity: parent.enabled
221− visible: opacity > 0
222− Behavior on opacity {
223− UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
212+
213+ AbstractButton {
214+ id: clearOrSettingsButton
215+ height: parent.height
216+ width: height
217+ enabled: searchTextField.text.length > 0 || root.navigationTag != ""
218+
219+ Image {
220+ objectName: "clearIcon"
221+ anchors.fill: parent
222+ anchors.margins: units.gu(.75)
223+ source: searchTextField.clearIsSettings ? "image://theme/settings" : "image://theme/clear"
224+ opacity: parent.enabled
225+ visible: opacity > 0
226+ Behavior on opacity {
227+ UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
228+ }
224229 }
225− }
226230
227− onClicked: {
228− if (searchTextField.clearIsSettings) {
229− root.showFiltersPopup(clearOrSettingsButton);
230− } else {
231− root.clearSearch(true);
231+ onClicked: {
232+ if (searchTextField.clearIsSettings) {
233+ root.showFiltersPopup(clearOrSettingsButton);
234+ } else {
235+ root.clearSearch(true);
236+ }
232237 }
233238 }
239+
240+ Label {
241+ visible: searchTextField.clearIsSettings && root.activeFiltersCount > 0
242+ height: parent.height
243+ text: root.activeFiltersCount
244+ verticalAlignment: Text.AlignVCenter
245+ }
234246 }
235247
236248 onActiveFocusChanged: {
tests/mocks/Unity/fake_optionselectoroptions.cpp+1−4
@@ -53,7 +53,6 @@ QVariant FakeOptionSelectorOptions::data(const QModelIndex &index, int role) con
5353
5454void FakeOptionSelectorOptions::setChecked(int row, bool checked)
5555{
56− const bool wasChecked = anyChecked();
5756 if (checked) {
5857 if (!static_cast<FakeOptionSelectorFilter*>(parent())->multiSelect()) {
5958 if (!m_checkedIndexes.isEmpty()) {
@@ -67,9 +66,7 @@ void FakeOptionSelectorOptions::setChecked(int row, bool checked)
6766 }
6867 const QModelIndex idx = index(row, 0);
6968 Q_EMIT dataChanged(idx, idx, QVector<int>() << RoleOptionChecked);
70− if (wasChecked != anyChecked()) {
71− Q_EMIT anyCheckedChanged();
72− }
69+ Q_EMIT anyCheckedChanged();
7370}
7471
7572bool FakeOptionSelectorOptions::anyChecked() const