Changeset View
Changeset View
Standalone View
Standalone View
src/controls/OverlayDrawer.qml
Show First 20 Lines • Show All 101 Lines • ▼ Show 20 Line(s) | 93 | Loader { | |||
---|---|---|---|---|---|
102 | source: { | 102 | source: { | ||
103 | var edge = root.edge; | 103 | var edge = root.edge; | ||
104 | if (Qt.application.layoutDirection == Qt.RightToLeft) { | 104 | if (Qt.application.layoutDirection == Qt.RightToLeft) { | ||
105 | if (edge === Qt.LeftEdge) { | 105 | if (edge === Qt.LeftEdge) { | ||
106 | edge = Qt.RightEdge; | 106 | edge = Qt.RightEdge; | ||
107 | } else { | 107 | } else { | ||
108 | edge = Qt.LeftEdge; | 108 | edge = Qt.LeftEdge; | ||
109 | } | 109 | } | ||
110 | } | 110 | } | ||
111 | switch(edge) { | 111 | | ||
mart: you can write it more compact and avoid code duplication, you can do:
if (root. | |||||
mart: also, coding style
spaces between if an ( and between ) and {
if () {
} | |||||
112 | case Qt.LeftEdge: | 112 | if (root.handleClosedIcon.source && root.handleOpenIcon.source) { | ||
113 | return Qt.resolvedUrl("templates/private/GenericDrawerIcon.qml"); | ||||
114 | } else if (edge == Qt.LeftEdge ) { | ||||
113 | return Qt.resolvedUrl("templates/private/MenuIcon.qml"); | 115 | return Qt.resolvedUrl("templates/private/MenuIcon.qml"); | ||
114 | case Qt.RightEdge: { | 116 | } else if(edge == Qt.RightEdge && root.hasOwnProperty("actions")) { | ||
115 | if (root.hasOwnProperty("actions")) { | | |||
116 | return Qt.resolvedUrl("templates/private/ContextIcon.qml"); | 117 | return Qt.resolvedUrl("templates/private/ContextIcon.qml"); | ||
117 | } else { | 118 | }else { | ||
118 | return Qt.resolvedUrl("templates/private/GenericDrawerIcon.qml"); | | |||
119 | } | | |||
120 | } | | |||
121 | default: | | |||
122 | return ""; | 119 | return ""; | ||
123 | } | 120 | } | ||
124 | } | 121 | } | ||
125 | onItemChanged: { | 122 | onItemChanged: { | ||
126 | if(item) { | 123 | if(item) { | ||
127 | item.drawer = Qt.binding(function(){return root}); | 124 | item.drawer = Qt.binding(function(){return root}); | ||
128 | item.color = Qt.binding(function(){return root.handle.pressed ? Theme.highlightedTextColor : Theme.textColor}); | 125 | item.color = Qt.binding(function(){return root.handle.pressed ? Theme.highlightedTextColor : Theme.textColor}); | ||
129 | } | 126 | } | ||
Show All 36 Lines |
you can write it more compact and avoid code duplication, you can do:
if (root.handleClosedIcon.source && root.handleOpenIcon.source) {
} else if (edge ==Qt.LeftEdge ) {
} else if()...
....}