[applets/systemtray] Clean up QML/JavaScript code

wilder-5.26
ivan tkachenko 4 years ago
parent d4ffa0f8e0
commit 8031139aeb
No known key found for this signature in database
GPG Key ID: AF72731B7C654CB3
  1. 10
      applets/systemtray/package/contents/applet/CompactApplet.qml
  2. 4
      applets/systemtray/package/contents/ui/HiddenItemsView.qml
  3. 6
      applets/systemtray/package/contents/ui/items/AbstractItem.qml
  4. 31
      applets/systemtray/package/contents/ui/items/StatusNotifierItem.qml
  5. 36
      applets/systemtray/package/contents/ui/main.qml

@ -18,13 +18,13 @@ PlasmaCore.ToolTipArea {
mainText: Plasmoid.toolTipMainText mainText: Plasmoid.toolTipMainText
subText: Plasmoid.toolTipSubText subText: Plasmoid.toolTipSubText
location: if (Plasmoid.parent && Plasmoid.parent.inHiddenLayout && Plasmoid.location !== PlasmaCore.Types.LeftEdge) { location: if (Plasmoid.parent && Plasmoid.parent.inHiddenLayout && Plasmoid.location !== PlasmaCore.Types.LeftEdge) {
return PlasmaCore.Types.RightEdge; return PlasmaCore.Types.RightEdge;
} else { } else {
return Plasmoid.location; return Plasmoid.location;
} }
active: !Plasmoid.expanded active: !Plasmoid.expanded
textFormat: Plasmoid.toolTipTextFormat textFormat: Plasmoid.toolTipTextFormat
mainItem: Plasmoid.toolTipItem ? Plasmoid.toolTipItem : null mainItem: Plasmoid.toolTipItem
property Item fullRepresentation property Item fullRepresentation
property Item compactRepresentation property Item compactRepresentation

@ -71,9 +71,7 @@ PlasmaComponents3.ScrollView {
model: PlasmaCore.SortFilterModel { model: PlasmaCore.SortFilterModel {
sourceModel: Plasmoid.nativeInterface.systemTrayModel sourceModel: Plasmoid.nativeInterface.systemTrayModel
filterRole: "effectiveStatus" filterRole: "effectiveStatus"
filterCallback: function(source_row, value) { filterCallback: (source_row, value) => value === PlasmaCore.Types.PassiveStatus
return value === PlasmaCore.Types.PassiveStatus
}
} }
delegate: ItemLoader {} delegate: ItemLoader {}

@ -64,9 +64,9 @@ PlasmaCore.ToolTipArea {
PulseAnimation { PulseAnimation {
targetItem: iconContainer targetItem: iconContainer
running: (abstractItem.status === PlasmaCore.Types.NeedsAttentionStatus || running: (abstractItem.status === PlasmaCore.Types.NeedsAttentionStatus
abstractItem.status === PlasmaCore.Types.RequiresAttentionStatus ) && || abstractItem.status === PlasmaCore.Types.RequiresAttentionStatus)
PlasmaCore.Units.longDuration > 0 && PlasmaCore.Units.longDuration > 0
} }
function startActivatedAnimation() { function startActivatedAnimation() {

@ -37,11 +37,11 @@ AbstractItem {
} }
onActivated: { onActivated: {
let service = model.Service; const service = model.Service;
let operation = service.operationDescription("Activate"); const operation = service.operationDescription("Activate");
operation.x = pos.x; //mouseX operation.x = pos.x; //mouseX
operation.y = pos.y; //mouseY operation.y = pos.y; //mouseY
let job = service.startOperationCall(operation); const job = service.startOperationCall(operation);
job.finished.connect(() => { job.finished.connect(() => {
if (!job.result) { if (!job.result) {
// On error try to invoke the context menu. // On error try to invoke the context menu.
@ -66,10 +66,9 @@ AbstractItem {
openContextMenu(pos); openContextMenu(pos);
break; break;
case Qt.MiddleButton: case Qt.MiddleButton:
var operation = service.operationDescription("SecondaryActivate"); const operation = service.operationDescription("SecondaryActivate");
let service = model.Service; const service = model.Service;
operation.x = pos.x; operation.x = pos.x;
operation.y = pos.y; operation.y = pos.y;
service.startOperationCall(operation); service.startOperationCall(operation);
taskIcon.startActivatedAnimation() taskIcon.startActivatedAnimation()
@ -78,13 +77,13 @@ AbstractItem {
} }
function openContextMenu(pos = Qt.point(width/2, height/2)) { function openContextMenu(pos = Qt.point(width/2, height/2)) {
var service = model.Service; const service = model.Service;
var operation = service.operationDescription("ContextMenu"); const operation = service.operationDescription("ContextMenu");
operation.x = pos.x; operation.x = pos.x;
operation.y = pos.y; operation.y = pos.y;
var job = service.startOperationCall(operation); const job = service.startOperationCall(operation);
job.finished.connect(function () { job.finished.connect(() => {
Plasmoid.nativeInterface.showStatusNotifierContextMenu(job, taskIcon); Plasmoid.nativeInterface.showStatusNotifierContextMenu(job, taskIcon);
}); });
} }
@ -92,16 +91,16 @@ AbstractItem {
onWheel: { onWheel: {
//don't send activateVertScroll with a delta of 0, some clients seem to break (kmix) //don't send activateVertScroll with a delta of 0, some clients seem to break (kmix)
if (wheel.angleDelta.y !== 0) { if (wheel.angleDelta.y !== 0) {
var service = model.Service; const service = model.Service;
var operation = service.operationDescription("Scroll"); const operation = service.operationDescription("Scroll");
operation.delta =wheel.angleDelta.y; operation.delta = wheel.angleDelta.y;
operation.direction = "Vertical"; operation.direction = "Vertical";
service.startOperationCall(operation); service.startOperationCall(operation);
} }
if (wheel.angleDelta.x !== 0) { if (wheel.angleDelta.x !== 0) {
var service = model.Service; const service = model.Service;
var operation = service.operationDescription("Scroll"); const operation = service.operationDescription("Scroll");
operation.delta =wheel.angleDelta.x; operation.delta = wheel.angleDelta.x;
operation.direction = "Horizontal"; operation.direction = "Horizontal";
service.startOperationCall(operation); service.startOperationCall(operation);
} }

@ -30,7 +30,7 @@ MouseArea {
readonly property alias itemSize: tasksGrid.itemSize readonly property alias itemSize: tasksGrid.itemSize
readonly property alias visibleLayout: tasksGrid readonly property alias visibleLayout: tasksGrid
readonly property alias hiddenLayout: expandedRepresentation.hiddenLayout readonly property alias hiddenLayout: expandedRepresentation.hiddenLayout
readonly property bool oneRowOrColumn: tasksGrid.rowsOrColumns == 1 readonly property bool oneRowOrColumn: tasksGrid.rowsOrColumns === 1
onWheel: { onWheel: {
// Don't propagate unhandled wheel events // Don't propagate unhandled wheel events
@ -55,7 +55,7 @@ MouseArea {
DnD.DropArea { DnD.DropArea {
anchors.fill: parent anchors.fill: parent
preventStealing: true; preventStealing: true
/** Extracts the name of the system tray applet in the drag data if present /** Extracts the name of the system tray applet in the drag data if present
* otherwise returns null*/ * otherwise returns null*/
@ -63,7 +63,7 @@ MouseArea {
if (event.mimeData.formats.indexOf("text/x-plasmoidservicename") < 0) { if (event.mimeData.formats.indexOf("text/x-plasmoidservicename") < 0) {
return null; return null;
} }
var plasmoidId = event.mimeData.getDataAsByteArray("text/x-plasmoidservicename"); const plasmoidId = event.mimeData.getDataAsByteArray("text/x-plasmoidservicename");
if (!Plasmoid.nativeInterface.isSystemTrayApplet(plasmoidId)) { if (!Plasmoid.nativeInterface.isSystemTrayApplet(plasmoidId)) {
return null; return null;
@ -78,14 +78,14 @@ MouseArea {
} }
onDrop: { onDrop: {
var plasmoidId = systemTrayAppletName(event); const plasmoidId = systemTrayAppletName(event);
if (!plasmoidId) { if (!plasmoidId) {
event.ignore(); event.ignore();
return; return;
} }
if (Plasmoid.configuration.extraItems.indexOf(plasmoidId) < 0) { if (Plasmoid.configuration.extraItems.indexOf(plasmoidId) < 0) {
var extraItems = Plasmoid.configuration.extraItems; const extraItems = Plasmoid.configuration.extraItems;
extraItems.push(plasmoidId); extraItems.push(plasmoidId);
Plasmoid.configuration.extraItems = extraItems; Plasmoid.configuration.extraItems = extraItems;
} }
@ -155,9 +155,7 @@ MouseArea {
model: PlasmaCore.SortFilterModel { model: PlasmaCore.SortFilterModel {
sourceModel: Plasmoid.nativeInterface.systemTrayModel sourceModel: Plasmoid.nativeInterface.systemTrayModel
filterRole: "effectiveStatus" filterRole: "effectiveStatus"
filterCallback: function(source_row, value) { filterCallback: (source_row, value) => value === PlasmaCore.Types.ActiveStatus
return value === PlasmaCore.Types.ActiveStatus
}
} }
delegate: ItemLoader { delegate: ItemLoader {
@ -257,19 +255,19 @@ MouseArea {
visible: [PlasmaCore.Types.TopEdge, PlasmaCore.Types.LeftEdge, PlasmaCore.Types.RightEdge, PlasmaCore.Types.BottomEdge] visible: [PlasmaCore.Types.TopEdge, PlasmaCore.Types.LeftEdge, PlasmaCore.Types.RightEdge, PlasmaCore.Types.BottomEdge]
.includes(Plasmoid.location) .includes(Plasmoid.location)
anchors { anchors {
top: Plasmoid.location == PlasmaCore.Types.BottomEdge ? undefined : parent.top top: Plasmoid.location === PlasmaCore.Types.BottomEdge ? undefined : parent.top
left: Plasmoid.location == PlasmaCore.Types.RightEdge ? undefined : parent.left left: Plasmoid.location === PlasmaCore.Types.RightEdge ? undefined : parent.left
right: Plasmoid.location == PlasmaCore.Types.LeftEdge ? undefined : parent.right right: Plasmoid.location === PlasmaCore.Types.LeftEdge ? undefined : parent.right
bottom: Plasmoid.location == PlasmaCore.Types.TopEdge ? undefined : parent.bottom bottom: Plasmoid.location === PlasmaCore.Types.TopEdge ? undefined : parent.bottom
topMargin: Plasmoid.location == PlasmaCore.Types.BottomEdge ? undefined : -dialog.margins.top topMargin: Plasmoid.location === PlasmaCore.Types.BottomEdge ? undefined : -dialog.margins.top
leftMargin: Plasmoid.location == PlasmaCore.Types.RightEdge ? undefined : -dialog.margins.left leftMargin: Plasmoid.location === PlasmaCore.Types.RightEdge ? undefined : -dialog.margins.left
rightMargin: Plasmoid.location == PlasmaCore.Types.LeftEdge ? undefined : -dialog.margins.right rightMargin: Plasmoid.location === PlasmaCore.Types.LeftEdge ? undefined : -dialog.margins.right
bottomMargin: Plasmoid.location == PlasmaCore.Types.TopEdge ? undefined : -dialog.margins.bottom bottomMargin: Plasmoid.location === PlasmaCore.Types.TopEdge ? undefined : -dialog.margins.bottom
} }
height: (Plasmoid.location == PlasmaCore.Types.TopEdge || Plasmoid.location == PlasmaCore.Types.BottomEdge) ? 1 : undefined height: (Plasmoid.location === PlasmaCore.Types.TopEdge || Plasmoid.location === PlasmaCore.Types.BottomEdge) ? 1 : undefined
width: (Plasmoid.location == PlasmaCore.Types.LeftEdge || Plasmoid.location == PlasmaCore.Types.RightEdge) ? 1 : undefined width: (Plasmoid.location === PlasmaCore.Types.LeftEdge || Plasmoid.location === PlasmaCore.Types.RightEdge) ? 1 : undefined
z: 999 /* Draw the line on top of the applet */ z: 999 /* Draw the line on top of the applet */
elementId: (Plasmoid.location == PlasmaCore.Types.TopEdge || Plasmoid.location == PlasmaCore.Types.BottomEdge) ? "horizontal-line" : "vertical-line" elementId: (Plasmoid.location === PlasmaCore.Types.TopEdge || Plasmoid.location === PlasmaCore.Types.BottomEdge) ? "horizontal-line" : "vertical-line"
svg: PlasmaCore.Svg { svg: PlasmaCore.Svg {
imagePath: "widgets/line" imagePath: "widgets/line"
} }

Loading…
Cancel
Save