From 94ebdd66dc0a85875c81c463ba1138fc39caa11b Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Sat, 31 Aug 2019 00:31:38 +0200 Subject: [PATCH] Rework button interface inheritance --- libnymea/interfaces/button.json | 6 ++++++ libnymea/interfaces/interfaces.qrc | 1 + libnymea/interfaces/longpressbutton.json | 3 ++- libnymea/interfaces/longpressmultibutton.json | 3 ++- libnymea/interfaces/multibutton.json | 15 +++++++++++++++ libnymea/interfaces/simplebutton.json | 6 +----- libnymea/interfaces/simplemultibutton.json | 14 ++------------ 7 files changed, 29 insertions(+), 19 deletions(-) create mode 100644 libnymea/interfaces/multibutton.json diff --git a/libnymea/interfaces/button.json b/libnymea/interfaces/button.json index 2c63c085..72211093 100644 --- a/libnymea/interfaces/button.json +++ b/libnymea/interfaces/button.json @@ -1,2 +1,8 @@ { + "description": "The base for all buttons that emit a pressed event.", + "events": [ + { + "name": "pressed" + } + ] } diff --git a/libnymea/interfaces/interfaces.qrc b/libnymea/interfaces/interfaces.qrc index 5d70e051..e24b9c19 100644 --- a/libnymea/interfaces/interfaces.qrc +++ b/libnymea/interfaces/interfaces.qrc @@ -20,6 +20,7 @@ battery.json batterylevel.json button.json + multibutton.json simplebutton.json longpressbutton.json simplemultibutton.json diff --git a/libnymea/interfaces/longpressbutton.json b/libnymea/interfaces/longpressbutton.json index bc9c3440..75efeb8d 100644 --- a/libnymea/interfaces/longpressbutton.json +++ b/libnymea/interfaces/longpressbutton.json @@ -1,5 +1,6 @@ { - "extends": "simplebutton", + "description": "A button that emits different events, pressed and longpressed, depending on how long the user presses it. Note that the button should only emit one of them at a time. I.e. don't emit pressed on botton down and later longPressed if the user keeps on holding the button. Such a longpress should only emit longPressed. Common practice is to emit pressed if a release event is received before a timeout expires, else emit longpress when the timeout expires.", + "extends": "button", "events": [ { "name": "longPressed" diff --git a/libnymea/interfaces/longpressmultibutton.json b/libnymea/interfaces/longpressmultibutton.json index 7baec3d0..60fd2c7a 100644 --- a/libnymea/interfaces/longpressmultibutton.json +++ b/libnymea/interfaces/longpressmultibutton.json @@ -1,5 +1,6 @@ { - "extends": "longpressbutton", + "description": "A remote control with multiple buttons that can distinguish between short and long presses. Note that the button should only emit one of them at a time. I.e. don't emit pressed on botton down and later longPressed if the user keeps on holding the button. Such a longpress should only emit longPressed. Common practice is to emit pressed if a release event is received before a timeout expires, else emit longpress when the timeout expires.", + "extends": "simplemultibutton", "events": [ { "name": "longPressed", diff --git a/libnymea/interfaces/multibutton.json b/libnymea/interfaces/multibutton.json new file mode 100644 index 00000000..8fc5ae08 --- /dev/null +++ b/libnymea/interfaces/multibutton.json @@ -0,0 +1,15 @@ +{ + "description": "A remote control with multiple buttons. Emits pressed(buttonName) on button presses.", + "extends": "button", + "events": [ + { + "name": "pressed", + "params": [ + { + "name": "buttonName", + "type": "QString" + } + ] + } + ] +} diff --git a/libnymea/interfaces/simplebutton.json b/libnymea/interfaces/simplebutton.json index 948a683f..4ba5d607 100644 --- a/libnymea/interfaces/simplebutton.json +++ b/libnymea/interfaces/simplebutton.json @@ -1,8 +1,4 @@ { "extends": "button", - "events": [ - { - "name": "pressed" - } - ] + "description": "Deprecated - Use button instead." } diff --git a/libnymea/interfaces/simplemultibutton.json b/libnymea/interfaces/simplemultibutton.json index 525fe038..334e6c79 100644 --- a/libnymea/interfaces/simplemultibutton.json +++ b/libnymea/interfaces/simplemultibutton.json @@ -1,14 +1,4 @@ { - "extends": "button", - "events": [ - { - "name": "pressed", - "params": [ - { - "name": "buttonName", - "type": "QString" - } - ] - } - ] + "description": "Deprecated - Use multibutton instead", + "extends": "multibutton" }