1

プラズモイドの通知の書き方に関する文献や例を見つけるのに苦労しています。

私のプラズモイドは、これまでのところ、特定の条件が満たされたときに通知を表示し、アラームを鳴らすことができますが、方法がわかりません:

  1. 通知に「閉じる」ボタンを追加して、継続的なアラームの再生を停止する、または
  2. 通知が閉じられたときにアラームが鳴らなくなるようにします。

これまでのところ、これは私の(要約された)コードです:

PlasmaCore.DataSource {
    id: notificationSource
    engine: "notifications"
}

SoundEffect {
    id: notificationSound
    source: plasmoid.file("data", "beep-alarm.wav")
    loops: SoundEffect.Infinite
}

function createNotification(text) {
    var service = notificationSource.serviceForSource("notification");
    var operation = service.operationDescription("createNotification");

    operation["appName"] = root.appName;
    operation["appIcon"] = plasmoid.configuration.icon;
    operation.summary = root.title;
    operation["body"] = '<b>' + text + '</b>';
    operation["expireTimeout"] = 0;
    operation["isPersistent"] = 'isPersistent';
    operation["urgency"] = 2;

    var tmp = service.startOperationCall(operation);
    if (plasmoid.configuration.alarmEnabled) {
        notificationSound.play();
    }
}

Plasmoid.compactRepresentation: Item {
...
    PlasmaComponents.Label {
        text: {
            if (Number(root.x) >= plasmoid.configuration.y) {
                root.createNotification(root.x);
            }
            root.x
        }
    }
...
}
4

0 に答える 0