Changeset View
Changeset View
Standalone View
Standalone View
applets/notifications/package/contents/ui/JobItem.qml
Show All 38 Lines | 32 | ColumnLayout { | |||
---|---|---|---|---|---|
39 | property alias suspendable: suspendButton.visible | 39 | property alias suspendable: suspendButton.visible | ||
40 | property alias killable: killButton.visible | 40 | property alias killable: killButton.visible | ||
41 | 41 | | |||
42 | property bool hovered | 42 | property bool hovered | ||
43 | property QtObject jobDetails | 43 | property QtObject jobDetails | ||
44 | // TOOD make an alias on visible if we're not doing an animation | 44 | // TOOD make an alias on visible if we're not doing an animation | ||
45 | property bool showDetails | 45 | property bool showDetails | ||
46 | 46 | | |||
47 | readonly property int totalFiles: jobItem.jobDetails && jobItem.jobDetails.totalFiles || 0 | ||||
48 | readonly property var url: { | ||||
49 | if (jobItem.jobState !== NotificationManager.Notifications.JobStateStopped | ||||
50 | || jobItem.jobError | ||||
51 | || totalFiles <= 0) { | ||||
52 | return null; | ||||
53 | } | ||||
54 | | ||||
55 | // For a single file show actions for it | ||||
56 | if (totalFiles === 1) { | ||||
57 | return jobItem.jobDetails.descriptionUrl; | ||||
58 | // Otherwise the destination folder all of them were copied into | ||||
59 | } else { | ||||
60 | return jobItem.jobDetails.destUrl; | ||||
61 | } | ||||
62 | } | ||||
63 | | ||||
64 | property alias iconContainerItem: jobDragIcon.parent | ||||
65 | | ||||
66 | readonly property alias dragging: jobDragArea.dragging | ||||
47 | readonly property alias menuOpen: otherFileActionsMenu.visible | 67 | readonly property alias menuOpen: otherFileActionsMenu.visible | ||
48 | 68 | | |||
49 | signal suspendJobClicked | 69 | signal suspendJobClicked | ||
50 | signal resumeJobClicked | 70 | signal resumeJobClicked | ||
51 | signal killJobClicked | 71 | signal killJobClicked | ||
52 | 72 | | |||
53 | signal openUrl(string url) | 73 | signal openUrl(string url) | ||
54 | signal fileActionInvoked | 74 | signal fileActionInvoked | ||
55 | 75 | | |||
56 | spacing: 0 | 76 | spacing: 0 | ||
57 | 77 | | |||
78 | // This item is parented to the NotificationItem iconContainer | ||||
79 | PlasmaCore.IconItem { | ||||
80 | id: jobDragIcon | ||||
81 | width: parent ? parent.width : 0 | ||||
82 | height: parent ? parent.height : 0 | ||||
83 | usesPlasmaTheme: false | ||||
84 | visible: valid | ||||
85 | active: jobDragArea.containsMouse | ||||
86 | source: jobItem.totalFiles === 1 && jobItem.url ? plasmoid.nativeInterface.iconNameForUrl(jobItem.url) : "" | ||||
87 | | ||||
88 | Binding { | ||||
89 | target: jobDragIcon.parent | ||||
90 | property: "visible" | ||||
91 | value: true | ||||
92 | when: jobDragIcon.valid | ||||
93 | } | ||||
94 | | ||||
95 | DraggableFileArea { | ||||
96 | id: jobDragArea | ||||
97 | anchors.fill: parent | ||||
98 | | ||||
99 | hoverEnabled: true | ||||
100 | dragParent: jobDragIcon | ||||
101 | dragUrl: jobItem.url || "" | ||||
102 | dragPixmap: jobDragIcon.source | ||||
103 | | ||||
104 | onActivated: jobItem.openUrl(jobItem.url) | ||||
105 | onContextMenuRequested: { | ||||
106 | // avoid menu button glowing if we didn't actually press it | ||||
107 | otherFileActionsButton.checked = false; | ||||
108 | | ||||
109 | otherFileActionsMenu.visualParent = this; | ||||
110 | otherFileActionsMenu.open(x, y); | ||||
111 | } | ||||
112 | } | ||||
113 | } | ||||
114 | | ||||
58 | RowLayout { | 115 | RowLayout { | ||
59 | id: progressRow | 116 | id: progressRow | ||
60 | Layout.fillWidth: true | 117 | Layout.fillWidth: true | ||
61 | spacing: units.smallSpacing | 118 | spacing: units.smallSpacing | ||
62 | 119 | | |||
63 | PlasmaComponents.ProgressBar { | 120 | PlasmaComponents.ProgressBar { | ||
64 | id: progressBar | 121 | id: progressBar | ||
65 | Layout.fillWidth: true | 122 | Layout.fillWidth: true | ||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | 163 | Loader { | |||
109 | // Loader doesn't reset its height when unloaded, just hide it altogether | 166 | // Loader doesn't reset its height when unloaded, just hide it altogether | ||
110 | visible: active | 167 | visible: active | ||
111 | sourceComponent: JobDetails { | 168 | sourceComponent: JobDetails { | ||
112 | jobDetails: jobItem.jobDetails | 169 | jobDetails: jobItem.jobDetails | ||
113 | } | 170 | } | ||
114 | } | 171 | } | ||
115 | 172 | | |||
116 | Flow { // it's a Flow so it can wrap if too long | 173 | Flow { // it's a Flow so it can wrap if too long | ||
117 | id: jobDoneActions | | |||
118 | Layout.fillWidth: true | 174 | Layout.fillWidth: true | ||
119 | spacing: units.smallSpacing | 175 | spacing: units.smallSpacing | ||
120 | // We want the actions to be right-aligned but Flow also reverses | 176 | // We want the actions to be right-aligned but Flow also reverses | ||
121 | // the order of items, so we put them in reverse order | 177 | // the order of items, so we put them in reverse order | ||
122 | layoutDirection: Qt.RightToLeft | 178 | layoutDirection: Qt.RightToLeft | ||
123 | visible: url && url.toString() !== "" | 179 | visible: url && url.toString() !== "" | ||
124 | 180 | | |||
125 | property var url: { | | |||
126 | if (jobItem.jobState !== NotificationManager.Notifications.JobStateStopped | | |||
127 | || jobItem.jobError | | |||
128 | || !jobItem.jobDetails | | |||
129 | || jobItem.jobDetails.totalFiles <= 0) { | | |||
130 | return null; | | |||
131 | } | | |||
132 | | ||||
133 | // For a single file show actions for it | | |||
134 | if (jobItem.jobDetails.totalFiles === 1) { | | |||
135 | return jobItem.jobDetails.descriptionUrl; | | |||
136 | } else { | | |||
137 | return jobItem.jobDetails.destUrl; | | |||
138 | } | | |||
139 | } | | |||
140 | | ||||
141 | PlasmaComponents.Button { | 181 | PlasmaComponents.Button { | ||
142 | id: otherFileActionsButton | 182 | id: otherFileActionsButton | ||
143 | height: Math.max(implicitHeight, openButton.implicitHeight) | 183 | height: Math.max(implicitHeight, openButton.implicitHeight) | ||
144 | iconName: "application-menu" | 184 | iconName: "application-menu" | ||
145 | tooltip: i18nd("plasma_applet_org.kde.plasma.notifications", "More Options...") | 185 | tooltip: i18nd("plasma_applet_org.kde.plasma.notifications", "More Options...") | ||
146 | checkable: true | 186 | checkable: true | ||
147 | onPressedChanged: { | 187 | onPressedChanged: { | ||
148 | if (pressed) { | 188 | if (pressed) { | ||
149 | checked = Qt.binding(function() { | 189 | checked = Qt.binding(function() { | ||
150 | return otherFileActionsMenu.visible; | 190 | return otherFileActionsMenu.visible; | ||
151 | }); | 191 | }); | ||
192 | otherFileActionsMenu.visualParent = this; | ||||
193 | // -1 tells it to "align bottom left of visualParent (this)" | ||||
152 | otherFileActionsMenu.open(-1, -1); | 194 | otherFileActionsMenu.open(-1, -1); | ||
153 | } | 195 | } | ||
154 | } | 196 | } | ||
155 | 197 | | |||
156 | Notifications.FileMenu { | 198 | Notifications.FileMenu { | ||
157 | id: otherFileActionsMenu | 199 | id: otherFileActionsMenu | ||
158 | url: jobDoneActions.url || "" | 200 | url: jobItem.url || "" | ||
159 | visualParent: otherFileActionsButton | | |||
160 | onActionTriggered: jobItem.fileActionInvoked() | 201 | onActionTriggered: jobItem.fileActionInvoked() | ||
161 | } | 202 | } | ||
162 | } | 203 | } | ||
163 | 204 | | |||
164 | PlasmaComponents.Button { | 205 | PlasmaComponents.Button { | ||
165 | id: openButton | 206 | id: openButton | ||
166 | height: Math.max(implicitHeight, otherFileActionsButton.implicitHeight) | 207 | height: Math.max(implicitHeight, otherFileActionsButton.implicitHeight) | ||
167 | // would be nice to have the file icon here? | 208 | // would be nice to have the file icon here? | ||
168 | text: jobItem.jobDetails && jobItem.jobDetails.totalFiles > 1 | 209 | text: jobItem.jobDetails && jobItem.jobDetails.totalFiles > 1 | ||
169 | ? i18nd("plasma_applet_org.kde.plasma.notifications", "Open Containing Folder") | 210 | ? i18nd("plasma_applet_org.kde.plasma.notifications", "Open Containing Folder") | ||
170 | : i18nd("plasma_applet_org.kde.plasma.notifications", "Open") | 211 | : i18nd("plasma_applet_org.kde.plasma.notifications", "Open") | ||
171 | onClicked: jobItem.openUrl(jobDoneActions.url) | 212 | onClicked: jobItem.openUrl(jobItem.url) | ||
172 | width: minimumWidth | 213 | width: minimumWidth | ||
173 | } | 214 | } | ||
174 | } | 215 | } | ||
175 | 216 | | |||
176 | states: [ | 217 | states: [ | ||
177 | State { | 218 | State { | ||
178 | when: jobItem.jobState === NotificationManager.Notifications.JobStateSuspended | 219 | when: jobItem.jobState === NotificationManager.Notifications.JobStateSuspended | ||
179 | PropertyChanges { | 220 | PropertyChanges { | ||
Show All 22 Lines |