Changeset View
Changeset View
Standalone View
Standalone View
discover/qml/DiscoverDrawer.qml
Show All 23 Lines | |||||
24 | import org.kde.discover 2.0 | 24 | import org.kde.discover 2.0 | ||
25 | import org.kde.discover.app 1.0 | 25 | import org.kde.discover.app 1.0 | ||
26 | import org.kde.kirigami 2.8 as Kirigami | 26 | import org.kde.kirigami 2.8 as Kirigami | ||
27 | import "navigation.js" as Navigation | 27 | import "navigation.js" as Navigation | ||
28 | 28 | | |||
29 | Kirigami.GlobalDrawer { | 29 | Kirigami.GlobalDrawer { | ||
30 | id: drawer | 30 | id: drawer | ||
31 | 31 | | |||
32 | leftPadding: 0 | ||||
33 | rightPadding: 0 | ||||
34 | topPadding: 0 | ||||
35 | | ||||
32 | // FIXME: Dirty workaround for 385992 | 36 | // FIXME: Dirty workaround for 385992 | ||
33 | width: Kirigami.Units.gridUnit * 14 | 37 | width: Kirigami.Units.gridUnit * 14 | ||
34 | 38 | | |||
35 | property bool wideScreen: false | 39 | property bool wideScreen: false | ||
36 | bannerImageSource: "qrc:/banners/banner.svg" | 40 | bannerImageSource: modal ? "qrc:/banners/banner.svg" : "" | ||
37 | //make the left and bottom margins for search field the same | | |||
38 | topPadding: drawer.wideScreen ? -toploader.height - leftPadding : 0 | | |||
39 | bottomPadding: 0 | | |||
40 | 41 | | |||
41 | // In desktop view, it's a sidebar, and sidebars get the view BG color | 42 | // In desktop view, it's a sidebar, and sidebars get the view BG color | ||
42 | Kirigami.Theme.colorSet: modal ? Kirigami.Theme.Window : Kirigami.Theme.View | 43 | Kirigami.Theme.colorSet: modal ? Kirigami.Theme.Window : Kirigami.Theme.View | ||
43 | 44 | | |||
44 | resetMenuOnTriggered: false | 45 | resetMenuOnTriggered: false | ||
45 | 46 | | |||
46 | onBannerClicked: { | 47 | onBannerClicked: { | ||
47 | Navigation.openHome(); | 48 | Navigation.openHome(); | ||
48 | if (modal) | | |||
49 | drawerOpen = false | 49 | drawerOpen = false | ||
50 | } | 50 | } | ||
51 | 51 | | |||
52 | property string currentSearchText | 52 | property string currentSearchText | ||
53 | 53 | | |||
54 | onCurrentSubMenuChanged: { | 54 | onCurrentSubMenuChanged: { | ||
55 | if (currentSubMenu) | 55 | if (currentSubMenu) | ||
56 | currentSubMenu.trigger() | 56 | currentSubMenu.trigger() | ||
57 | else if (currentSearchText.length > 0) | 57 | else if (currentSearchText.length > 0) | ||
58 | window.leftPage.category = null | 58 | window.leftPage.category = null | ||
59 | else | 59 | else | ||
60 | Navigation.openHome() | 60 | Navigation.openHome() | ||
61 | } | 61 | } | ||
62 | 62 | | |||
63 | function suggestSearchText(text) { | 63 | function suggestSearchText(text) { | ||
64 | toploader.item.text = text | 64 | toploader.item.text = text | ||
65 | toploader.item.forceActiveFocus() | 65 | toploader.item.forceActiveFocus() | ||
66 | } | 66 | } | ||
67 | topContent: ConditionalLoader { | 67 | topContent: ConditionalLoader { | ||
68 | id: toploader | 68 | id: toploader | ||
69 | condition: drawer.wideScreen | 69 | condition: !modal | ||
70 | Layout.fillWidth: true | 70 | Layout.fillWidth: true | ||
71 | componentFalse: Item { | 71 | componentFalse: Item { | ||
72 | Layout.minimumHeight: 1 | 72 | Layout.minimumHeight: 1 | ||
73 | } | 73 | } | ||
74 | componentTrue: SearchField { | 74 | componentTrue: Kirigami.AbstractApplicationHeader { | ||
75 | preferredHeight: 40 // Match Kirigami.ToolBarApplicationHeader, which is hardcoded to this | ||||
76 | | ||||
77 | RowLayout { | ||||
78 | width: parent.width | ||||
79 | anchors.centerIn: parent | ||||
80 | | ||||
81 | ToolButton { | ||||
82 | Layout.leftMargin: Kirigami.Units.smallSpacing | ||||
83 | | ||||
84 | icon.name: "go-home" | ||||
85 | onPressed: Navigation.openHome() | ||||
86 | | ||||
87 | ToolTip { | ||||
88 | text: i18n("Return to the Featured page") | ||||
89 | } | ||||
90 | } | ||||
91 | | ||||
92 | SearchField { | ||||
75 | id: searchField | 93 | id: searchField | ||
76 | 94 | | |||
95 | Layout.fillWidth: true | ||||
96 | Layout.rightMargin: Kirigami.Units.smallSpacing | ||||
97 | | ||||
77 | visible: window.leftPage && (window.leftPage.searchFor !== null || window.leftPage.hasOwnProperty("search")) | 98 | visible: window.leftPage && (window.leftPage.searchFor !== null || window.leftPage.hasOwnProperty("search")) | ||
78 | 99 | | |||
79 | page: window.leftPage | 100 | page: window.leftPage | ||
80 | 101 | | |||
81 | onCurrentSearchTextChanged: { | 102 | onCurrentSearchTextChanged: { | ||
82 | var curr = window.leftPage; | 103 | var curr = window.leftPage; | ||
83 | 104 | | |||
84 | if (pageStack.depth>1) | 105 | if (pageStack.depth>1) | ||
85 | pageStack.pop() | 106 | pageStack.pop() | ||
86 | 107 | | |||
87 | if (currentSearchText === "" && window.currentTopLevel === "" && !window.leftPage.category) { | 108 | if (currentSearchText === "" && window.currentTopLevel === "" && !window.leftPage.category) { | ||
88 | Navigation.openHome() | 109 | Navigation.openHome() | ||
89 | } else if (!curr.hasOwnProperty("search")) { | 110 | } else if (!curr.hasOwnProperty("search")) { | ||
90 | if (currentSearchText) { | 111 | if (currentSearchText) { | ||
91 | Navigation.clearStack() | 112 | Navigation.clearStack() | ||
92 | Navigation.openApplicationList( { search: currentSearchText }) | 113 | Navigation.openApplicationList( { search: currentSearchText }) | ||
93 | } | 114 | } | ||
94 | } else { | 115 | } else { | ||
95 | curr.search = currentSearchText; | 116 | curr.search = currentSearchText; | ||
96 | curr.forceActiveFocus() | 117 | curr.forceActiveFocus() | ||
97 | } | 118 | } | ||
98 | } | 119 | } | ||
99 | } | 120 | } | ||
100 | } | 121 | } | ||
122 | } | ||||
123 | } | ||||
101 | 124 | | |||
102 | ColumnLayout { | 125 | ColumnLayout { | ||
103 | spacing: 0 | 126 | spacing: 0 | ||
104 | Layout.fillWidth: true | 127 | Layout.fillWidth: true | ||
105 | Layout.leftMargin: -drawer.leftPadding | 128 | Layout.leftMargin: -drawer.leftPadding | ||
106 | Layout.rightMargin: -drawer.rightPadding | 129 | Layout.rightMargin: -drawer.rightPadding | ||
107 | 130 | | |||
108 | Kirigami.Separator { | 131 | Kirigami.Separator { | ||
▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines |