Changeset View
Changeset View
Standalone View
Standalone View
src/controls/templates/SwipeListItem.qml
Show All 13 Lines | |||||
14 | * You should have received a copy of the GNU Library General Public | 14 | * You should have received a copy of the GNU Library General Public | ||
15 | * License along with this program; if not, write to the | 15 | * License along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | 16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | import QtQuick 2.7 | 20 | import QtQuick 2.7 | ||
21 | import QtQuick.Layouts 1.2 | 21 | import QtQuick.Layouts 1.2 | ||
22 | import QtQuick.Controls 2.0 as Controls | 22 | import QtQuick.Controls 2.7 as Controls | ||
23 | import org.kde.kirigami 2.7 | 23 | import org.kde.kirigami 2.7 | ||
24 | import "../private" | 24 | import "../private" | ||
25 | import QtQuick.Templates 2.0 as T2 | 25 | import QtQuick.Templates 2.0 as T2 | ||
26 | 26 | | |||
27 | /** | 27 | /** | ||
28 | * An item delegate Intended to support extra actions obtainable | 28 | * An item delegate Intended to support extra actions obtainable | ||
29 | * by uncovering them by dragging away the item with the handle | 29 | * by uncovering them by dragging away the item with the handle | ||
30 | * This acts as a container for normal list items. | 30 | * This acts as a container for normal list items. | ||
▲ Show 20 Lines • Show All 144 Lines • ▼ Show 20 Line(s) | 173 | //END properties | |||
175 | Item { | 175 | Item { | ||
176 | id: behindItem | 176 | id: behindItem | ||
177 | parent: listItem | 177 | parent: listItem | ||
178 | z: -1 | 178 | z: -1 | ||
179 | //TODO: a global "open" state | 179 | //TODO: a global "open" state | ||
180 | enabled: background.x !== 0 | 180 | enabled: background.x !== 0 | ||
181 | property bool indicateActiveFocus: listItem.pressed || Settings.tabletMode || listItem.activeFocus || (view ? view.activeFocus : false) | 181 | property bool indicateActiveFocus: listItem.pressed || Settings.tabletMode || listItem.activeFocus || (view ? view.activeFocus : false) | ||
182 | property Flickable view: listItem.ListView.view || (listItem.parent ? (listItem.parent.ListView.view || listItem.parent) : null) | 182 | property Flickable view: listItem.ListView.view || (listItem.parent ? (listItem.parent.ListView.view || listItem.parent) : null) | ||
183 | property T2.ScrollBar flickableVerticalScrollbar: view ? (view.T2.ScrollBar.vertical ? view.T2.ScrollBar.vertical : null) : null | ||||
184 | property T2.ScrollBar scrollviewVerticalScrollbar: view ? (view.parent.T2.ScrollBar.vertical ? view.parent.T2.ScrollBar.vertical : null) : null | ||||
183 | onViewChanged: { | 185 | onViewChanged: { | ||
184 | if (view && Settings.tabletMode && !behindItem.view.parent.parent._swipeFilter) { | 186 | if (view && Settings.tabletMode && !behindItem.view.parent.parent._swipeFilter) { | ||
185 | var component = Qt.createComponent(Qt.resolvedUrl("../private/SwipeItemEventFilter.qml")); | 187 | var component = Qt.createComponent(Qt.resolvedUrl("../private/SwipeItemEventFilter.qml")); | ||
186 | behindItem.view.parent.parent._swipeFilter = component.createObject(behindItem.view.parent.parent); | 188 | behindItem.view.parent.parent._swipeFilter = component.createObject(behindItem.view.parent.parent); | ||
187 | } | 189 | } | ||
188 | } | 190 | } | ||
189 | 191 | | |||
192 | // Some of the views use flickables, and some use scrollviews, so we | ||||
193 | // need to handle both when we determine whether or not to move items | ||||
194 | // over to the right so the scrollbar doesn't overlap them | ||||
195 | function calculateMargin() { | ||||
196 | if (scrollviewVerticalScrollbar && scrollviewVerticalScrollbar.visible) { | ||||
197 | return scrollviewVerticalScrollbar.width | ||||
198 | } else if (flickableVerticalScrollbar && flickableVerticalScrollbar.visible) { | ||||
199 | return flickableVerticalScrollbar.width | ||||
200 | } | ||||
201 | return Units.smallSpacing | ||||
202 | } | ||||
203 | | ||||
190 | anchors { | 204 | anchors { | ||
191 | fill: parent | 205 | fill: parent | ||
192 | } | 206 | } | ||
193 | Rectangle { | 207 | Rectangle { | ||
194 | id: shadowHolder | 208 | id: shadowHolder | ||
195 | color: Qt.darker(Theme.backgroundColor, 1.05); | 209 | color: Qt.darker(Theme.backgroundColor, 1.05); | ||
196 | anchors.fill: parent | 210 | anchors.fill: parent | ||
197 | } | 211 | } | ||
Show All 35 Lines | 246 | Behavior on opacity { | |||
233 | OpacityAnimator { | 247 | OpacityAnimator { | ||
234 | duration: Units.longDuration | 248 | duration: Units.longDuration | ||
235 | easing.type: Easing.InOutQuad | 249 | easing.type: Easing.InOutQuad | ||
236 | } | 250 | } | ||
237 | } | 251 | } | ||
238 | anchors { | 252 | anchors { | ||
239 | right: parent.right | 253 | right: parent.right | ||
240 | verticalCenter: parent.verticalCenter | 254 | verticalCenter: parent.verticalCenter | ||
241 | rightMargin: Units.gridUnit | 255 | rightMargin: LayoutMirroring.enabled ? 0 : behindItem.calculateMargin() | ||
256 | leftLargin: LayoutMirroring.enabled ? 0 : behindItem.calculateMargin() | ||||
apol: Wouldn't checking for scrollbar visibility be enough? if there's a scrollbar but isMobile we… | |||||
242 | } | 257 | } | ||
243 | height: Math.min( parent.height / 1.5, Units.iconSizes.smallMedium) | 258 | height: Math.min( parent.height / 1.5, Units.iconSizes.smallMedium) | ||
244 | width: childrenRect.width | 259 | width: childrenRect.width | ||
245 | property bool exclusive: false | 260 | property bool exclusive: false | ||
246 | property Item checkedButton | 261 | property Item checkedButton | ||
247 | spacing: Units.largeSpacing | 262 | spacing: Settings.tabletMode ? Units.largeSpacing : 0 | ||
248 | property int visibleActions: 0 | 263 | property int visibleActions: 0 | ||
249 | Repeater { | 264 | Repeater { | ||
250 | model: { | 265 | model: { | ||
251 | if (listItem.actions.length === 0) { | 266 | if (listItem.actions.length === 0) { | ||
252 | return null; | 267 | return null; | ||
253 | } else { | 268 | } else { | ||
254 | return listItem.actions[0].text !== undefined && | 269 | return listItem.actions[0].text !== undefined && | ||
255 | listItem.actions[0].trigger !== undefined ? | 270 | listItem.actions[0].trigger !== undefined ? | ||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | |||||
301 | MouseArea { | 316 | MouseArea { | ||
302 | id: handleMouse | 317 | id: handleMouse | ||
303 | parent: listItem.background | 318 | parent: listItem.background | ||
304 | visible: Settings.tabletMode && listItem.actionsVisible && actionsLayout.visibleActions > 0 | 319 | visible: Settings.tabletMode && listItem.actionsVisible && actionsLayout.visibleActions > 0 | ||
305 | z: 99 | 320 | z: 99 | ||
306 | anchors { | 321 | anchors { | ||
307 | right: parent.right | 322 | right: parent.right | ||
308 | verticalCenter: parent.verticalCenter | 323 | verticalCenter: parent.verticalCenter | ||
309 | rightMargin: !Settings.isMobile && behindItem.view && behindItem.view.T2.ScrollBar && behindItem.view.T2.ScrollBar.vertical && behindItem.view.T2.ScrollBar.vertical.visible ? behindItem.view.T2.ScrollBar.vertical.width : Units.smallSpacing | 324 | rightMargin: LayoutMirroring.enabled ? 0 : behindItem.calculateMargin() | ||
325 | leftLargin: LayoutMirroring.enabled ? 0 : behindItem.calculateMargin() | ||||
310 | } | 326 | } | ||
311 | 327 | | |||
312 | preventStealing: true | 328 | preventStealing: true | ||
313 | width: Units.iconSizes.smallMedium | 329 | width: Units.iconSizes.smallMedium | ||
314 | height: width | 330 | height: width | ||
315 | property var downTimestamp; | 331 | property var downTimestamp; | ||
316 | property int startX | 332 | property int startX | ||
317 | property int startMouseX | 333 | property int startMouseX | ||
▲ Show 20 Lines • Show All 142 Lines • Show Last 20 Lines |
Wouldn't checking for scrollbar visibility be enough? if there's a scrollbar but isMobile we still want the different spacing.