From 35ccae4a43e922e8d6d6d452752f794c4dce6e02 Mon Sep 17 00:00:00 2001 From: ToonzDev Date: Thu, 4 Mar 2021 20:23:34 +0100 Subject: [PATCH 1/7] fixed show-hide system tray icon --- Changelog.txt | 3 +++ PiholestatsTray.qml | 2 +- version.txt | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 767364f..96e4ae9 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,6 @@ +0.1.7 +- fixed show/hide system tray icon based on the usersetting + 0.1.6 - added working code for buttons diff --git a/PiholestatsTray.qml b/PiholestatsTray.qml index f825c1d..f0b0278 100644 --- a/PiholestatsTray.qml +++ b/PiholestatsTray.qml @@ -5,7 +5,7 @@ import qb.base 1.0 SystrayIcon { id: piholeSystrayIcon - visible: true + visible: app.showAppIcon posIndex: 8000 property string objectName: "piholeSystrayIcon" diff --git a/version.txt b/version.txt index a192233..a1e1395 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.1.6 \ No newline at end of file +0.1.7 \ No newline at end of file From 253efeec14702bbbb915ea806216f1da24dc77b1 Mon Sep 17 00:00:00 2001 From: ToonzDev Date: Thu, 16 Sep 2021 21:25:28 +0200 Subject: [PATCH 2/7] versie 0.1.8 --- Changelog.txt | 5 ++++ PiholestatsApp.qml | 34 ++++++++++++-------------- PiholestatsScreen.qml | 4 ++-- PiholestatsTile.qml | 56 ++++++++++++++++++++++++++----------------- version.txt | 2 +- 5 files changed, 57 insertions(+), 44 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 96e4ae9..9ae5b1c 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,8 @@ +0.1.8 +- redesigned tile to show more user friendly data +- added last refresh time to the details screen +- fixed broken auto update function + 0.1.7 - fixed show/hide system tray icon based on the usersetting diff --git a/PiholestatsApp.qml b/PiholestatsApp.qml index 667b083..bfd9de4 100644 --- a/PiholestatsApp.qml +++ b/PiholestatsApp.qml @@ -25,12 +25,14 @@ App { property string connectionPath property string ipadres property string poortnummer : "80" - property int refreshrate : 60 // interval to retrieve data + property int refreshrate : 60 // interval to retrieve data property string authtoken //data vars property string tmp_ads_blocked_today property string tmp_ads_percentage_today + property string lastupdated + property string status // user settings from config file property variant userSettingsJSON : { @@ -70,6 +72,7 @@ App { } catch(e) { } refreshScreen(); + datetimeTimer.start() } // refresh screen @@ -96,7 +99,7 @@ App { // read json file function readPiHolePHPData() { -// console.log("*****PiHole connectionPath:" + connectionPath); + status = "geen connectie" if ( connectionPath.length > 4 ) { var xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET", "http://"+connectionPath+"/admin/api.php", true); @@ -104,31 +107,24 @@ App { if (xmlhttp.readyState == XMLHttpRequest.DONE) { if (xmlhttp.status === 200) { -// console.log("*****PiHole response:" + xmlhttp.responseText); -// saveJSON(xmlhttp.responseText); - piholeConfigJSON = JSON.parse(xmlhttp.responseText); + piholeConfigJSON = JSON.parse(xmlhttp.responseText); - tmp_ads_blocked_today = piholeConfigJSON['ads_blocked_today']; -// console.log("*****PiHole tmp_ads_blocked_today: " + tmp_ads_blocked_today); -// last tmp_ads_percentage_today = piholeConfigJSON['ads_percentage_today']; - tmp_ads_percentage_today = Math.round(piholeConfigJSON['ads_percentage_today']) + " %"; -// console.log("*****PiHole tmp_ads_percentage_today: " + tmp_ads_percentage_today); + tmp_ads_blocked_today = piholeConfigJSON['ads_blocked_today']; + tmp_ads_percentage_today = Math.round(piholeConfigJSON['ads_percentage_today']) + "%"; + status = piholeConfigJSON['status']; + var tmp = new Date(); + lastupdated = tmp.getFullYear() + "-" + ("0" + (tmp.getMonth() + 1)).slice(-2) + "-" + ("0" + tmp.getDate()).slice(-2) + " " + ("0" + tmp.getHours() ).slice(-2) + ":" + ("0" + tmp.getMinutes()).slice(-2); + } } else { - tmp_ads_blocked_today = "server incorrect"; -// console.log("*****PiHole tmp_ads_blocked_today: "+ tmp_ads_blocked_today); - tmp_ads_percentage_today = "server incorrect"; -// console.log("*****PiHole tmp_ads_percentage_today: "+ tmp_ads_percentage_today); - + tmp_ads_blocked_today = "server incorrect"; + tmp_ads_percentage_today = "server incorrect"; } - } } + xmlhttp.send(); } else { tmp_ads_blocked_today = "empty settings"; -// console.log("*****PiHole tmp_ads_blocked_today: "+ tmp_ads_blocked_today); tmp_ads_percentage_today = "empty settings"; -// console.log("*****PiHole tmp_ads_percentage_today: "+ tmp_ads_percentage_today); } - xmlhttp.send(); } // save json data in json file. Optional, see readPiHolePHPData diff --git a/PiholestatsScreen.qml b/PiholestatsScreen.qml index b5bb62d..ddc71ce 100644 --- a/PiholestatsScreen.qml +++ b/PiholestatsScreen.qml @@ -40,7 +40,7 @@ Screen { Text { id: headerText - text: "Pi-Hole live gegevens:" + text: "Pi-Hole live gegevens (per " + app.lastupdated + ")" font.family: qfont.semiBold.name font.pixelSize: isNxt ? 25 : 20 anchors { @@ -161,7 +161,7 @@ Screen { // line 4 text Text { id: line4text - text: "Reclame vandaag geblokkeerd: " + text: "Reclame geblokkeerd laatste 24h: " font.family: qfont.italic.name font.pixelSize: isNxt ? 23 : 18 anchors { diff --git a/PiholestatsTile.qml b/PiholestatsTile.qml index 439a8b8..2f66d02 100644 --- a/PiholestatsTile.qml +++ b/PiholestatsTile.qml @@ -28,53 +28,65 @@ Tile { // line 1 text Text { id: tileline1 - text: "Ads blocked today: " + text: "In de laatste 24 uur is" color: (typeof dimmableColors !== 'undefined') ? dimmableColors.clockTileColor : colors.clockTileColor anchors { top: tiletitle.bottom - left: parent.left - leftMargin: isNxt ? 10 : 8 + topMargin: isNxt ? 25 : 20 + horizontalCenter: parent.horizontalCenter + } + font { + family: qfont.regular.name + pixelSize: isNxt ? 22 : 18 } - font.pixelSize: isNxt ? 25 : 20 - font.family: qfont.italic.name + visible: (app.status !== "geen connectie") } // line 2 text Text { id: tileline2 - text: app.tmp_ads_blocked_today + text: app.tmp_ads_percentage_today + " van het DNS" color: (typeof dimmableColors !== 'undefined') ? dimmableColors.clockTileColor : colors.clockTileColor anchors { - left: tileline1.left top: tileline1.bottom + horizontalCenter: parent.horizontalCenter } - font.pixelSize: isNxt ? 25 : 20 - font.family: qfont.italic.name + font { + family: qfont.regular.name + pixelSize: isNxt ? 22 : 18 + } + visible: (app.status !== "geen connectie") } -// line 3 text +// line 4 text Text { - id: tileline3 - text: "Percentage blocked: " + id: tileline4 + text: "verkeer geblokkeerd." color: (typeof dimmableColors !== 'undefined') ? dimmableColors.clockTileColor : colors.clockTileColor anchors { - left: tileline2.left top: tileline2.bottom + horizontalCenter: parent.horizontalCenter + } + font { + family: qfont.regular.name + pixelSize: isNxt ? 22 : 18 } - font.pixelSize: isNxt ? 25 : 20 - font.family: qfont.italic.name + visible: (app.status !== "geen connectie") } -// line 4 text +// line 5 text Text { - id: tileline4 - text: app.tmp_ads_percentage_today + id: tileline5 + text: "status: " + app.status color: (typeof dimmableColors !== 'undefined') ? dimmableColors.clockTileColor : colors.clockTileColor anchors { - left: tileline3.left - top: tileline3.bottom + top: tileline4.bottom + topMargin: 15 + horizontalCenter: parent.horizontalCenter + } + font { + family: qfont.regular.name + pixelSize: isNxt ? 22 : 18 } - font.pixelSize: isNxt ? 25 : 20 - font.family: qfont.italic.name } } diff --git a/version.txt b/version.txt index a1e1395..84aa3a7 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.1.7 \ No newline at end of file +0.1.8 \ No newline at end of file From 800288feb277e9018533633906499e38a5817d2c Mon Sep 17 00:00:00 2001 From: ToonzDev Date: Fri, 17 Sep 2021 20:44:27 +0200 Subject: [PATCH 3/7] versie 0.1.9 --- Changelog.txt | 3 ++- PiholestatsApp.qml | 31 +++++++++++++++++++++---------- PiholestatsScreen.qml | 8 ++++---- PiholestatsTile.qml | 30 ++++++++++++++++++------------ version.txt | 2 +- 5 files changed, 46 insertions(+), 28 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 9ae5b1c..d2e773b 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,7 +1,8 @@ -0.1.8 +0.1.8/9 - redesigned tile to show more user friendly data - added last refresh time to the details screen - fixed broken auto update function +- data reset when connection lost 0.1.7 - fixed show/hide system tray icon based on the usersetting diff --git a/PiholestatsApp.qml b/PiholestatsApp.qml index bfd9de4..68709fa 100644 --- a/PiholestatsApp.qml +++ b/PiholestatsApp.qml @@ -19,6 +19,25 @@ App { property bool showAppIcon : true property bool firstTimeShown : true property variant piholeConfigJSON + property variant emptyPiholeConfigJSON : { + "domains_being_blocked":0, + "dns_queries_today":0, + "ads_blocked_today":0, + "ads_percentage_today":0, + "unique_domains":0, + "queries_forwarded":0, + "queries_cached":0, + "clients_ever_seen":0, + "unique_clients":0, + "dns_queries_all_types":0, + "reply_NODATA":0, + "reply_NXDOMAIN":0, + "reply_CNAME":0, + "reply_IP":0, + "privacy_level":0, + "status":"geen connectie", + "gravity_last_updated":{"file_exists":true,"absolute":0,"relative":{"days":0,"hours":0,"minutes":0}} + } property bool piholeDataRead: false // app settings @@ -77,7 +96,6 @@ App { // refresh screen function refreshScreen() { - piholeDataRead = false; readPiHolePHPData(); } @@ -99,7 +117,8 @@ App { // read json file function readPiHolePHPData() { - status = "geen connectie" + + piholeConfigJSON = emptyPiholeConfigJSON; if ( connectionPath.length > 4 ) { var xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET", "http://"+connectionPath+"/admin/api.php", true); @@ -127,14 +146,6 @@ App { } } -// save json data in json file. Optional, see readPiHolePHPData - function saveJSON(text) { - - var doc3 = new XMLHttpRequest(); - doc3.open("PUT", "file:///var/volatile/tmp/pihole_retrieved_data.json"); - doc3.send(text); - } - // Timer in s * 1000 Timer { id: datetimeTimer diff --git a/PiholestatsScreen.qml b/PiholestatsScreen.qml index ddc71ce..869c8d8 100644 --- a/PiholestatsScreen.qml +++ b/PiholestatsScreen.qml @@ -28,8 +28,8 @@ Screen { function changeState(request) { var xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET", request, true); + if (xmlhttp.readyState == XMLHttpRequest.DONE) app.refreshScreen(); xmlhttp.send(); - app.refreshScreen(); } // header @@ -95,7 +95,7 @@ Screen { // line 1 value Text { id: line1value - text: app.piholeConfigJSON['status']; + text: app.piholeConfigJSON['status'] color: colors.clockTileColor font.family: qfont.italic.name font.pixelSize: isNxt ? 23 : 18 @@ -373,8 +373,8 @@ Screen { bottomMargin: isNxt ? 20 : 16 } onClicked: { - changeState("http://"+app.connectionPath+"/admin/api.php?disable=30&auth="+app.authtoken); - } + changeState("http://"+app.connectionPath+"/admin/api.php?disable=30&auth="+app.authtoken); + } } // button 60s diff --git a/PiholestatsTile.qml b/PiholestatsTile.qml index 2f66d02..29f6124 100644 --- a/PiholestatsTile.qml +++ b/PiholestatsTile.qml @@ -13,7 +13,7 @@ Tile { // Title Text { id: tiletitle - text: "PiHole Stats" + text: "PiHole Status" anchors { baseline: parent.top baselineOffset: isNxt ? 30 : 24 @@ -24,6 +24,7 @@ Tile { pixelSize: isNxt ? 25 : 20 } color: (typeof dimmableColors !== 'undefined') ? dimmableColors.waTileTextColor : colors.waTileTextColor + visible: !dimState || (app.piholeConfigJSON['status'] == "geen connectie") } // line 1 text Text { @@ -39,7 +40,7 @@ Tile { family: qfont.regular.name pixelSize: isNxt ? 22 : 18 } - visible: (app.status !== "geen connectie") + visible: (app.piholeConfigJSON['status'] !== "geen connectie") } // line 2 text @@ -55,7 +56,7 @@ Tile { family: qfont.regular.name pixelSize: isNxt ? 22 : 18 } - visible: (app.status !== "geen connectie") + visible: (app.piholeConfigJSON['status'] !== "geen connectie") } // line 4 text @@ -71,22 +72,27 @@ Tile { family: qfont.regular.name pixelSize: isNxt ? 22 : 18 } - visible: (app.status !== "geen connectie") + visible: (app.piholeConfigJSON['status'] !== "geen connectie") } // line 5 text - Text { - id: tileline5 - text: "status: " + app.status - color: (typeof dimmableColors !== 'undefined') ? dimmableColors.clockTileColor : colors.clockTileColor + Rectangle { + color: (app.piholeConfigJSON['status'] == "geen connectie") ? "#FF0000" : dimmableColors.background anchors { top: tileline4.bottom topMargin: 15 horizontalCenter: parent.horizontalCenter } - font { - family: qfont.regular.name - pixelSize: isNxt ? 22 : 18 + Text { + id: tileline5 + text: "status: " + app.piholeConfigJSON['status'] + color: (typeof dimmableColors !== 'undefined') ? dimmableColors.clockTileColor : colors.clockTileColor + font { + family: qfont.regular.name + pixelSize: isNxt ? 22 : 18 + } } - } + width: childrenRect.width + height: childrenRect.height + } } diff --git a/version.txt b/version.txt index 84aa3a7..82551ad 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.1.8 \ No newline at end of file +0.1.9 \ No newline at end of file From a7eec7b08c5b145dfdde98803ca18560d20e6f2f Mon Sep 17 00:00:00 2001 From: ToonzDev Date: Sat, 18 Sep 2021 15:59:19 +0200 Subject: [PATCH 4/7] 0.1.10 --- Changelog.txt | 4 ++++ PiholestatsTile.qml | 1 + version.txt | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index d2e773b..e191298 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,7 @@ +0.1.10 +- Tile colored red completely when connection with PiHole has been lost + (not in dim state) + 0.1.8/9 - redesigned tile to show more user friendly data - added last refresh time to the details screen diff --git a/PiholestatsTile.qml b/PiholestatsTile.qml index 29f6124..ca54506 100644 --- a/PiholestatsTile.qml +++ b/PiholestatsTile.qml @@ -9,6 +9,7 @@ Tile { onClicked: { stage.openFullscreen(app.piholeScreenUrl); } + bgColor: (app.piholeConfigJSON['status'] == "geen connectie") ? "#FF0000" : dimmableColors.background // Title Text { diff --git a/version.txt b/version.txt index 82551ad..345f8cc 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.1.9 \ No newline at end of file +0.1.10 \ No newline at end of file From 3ebc72127edcdae746346eea45c4c89b3e29e743 Mon Sep 17 00:00:00 2001 From: ToonzDev Date: Sun, 19 Sep 2021 10:01:50 +0200 Subject: [PATCH 5/7] 0.1.11 --- Changelog.txt | 5 +++-- PiholestatsApp.qml | 28 +++++++++++++++++++++++----- PiholestatsTile.qml | 13 ++++++++++--- version.txt | 2 +- 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index e191298..bd13c0d 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,6 +1,7 @@ -0.1.10 +0.1.11 - Tile colored red completely when connection with PiHole has been lost - (not in dim state) + Tile colored orange when PiHole is disabled + (not in dim state a colored status message is shown) 0.1.8/9 - redesigned tile to show more user friendly data diff --git a/PiholestatsApp.qml b/PiholestatsApp.qml index 68709fa..3c54bcc 100644 --- a/PiholestatsApp.qml +++ b/PiholestatsApp.qml @@ -39,6 +39,10 @@ App { "gravity_last_updated":{"file_exists":true,"absolute":0,"relative":{"days":0,"hours":0,"minutes":0}} } property bool piholeDataRead: false + property string tileBackcolor : dimmableColors.background + property string stringBackcolor : dimmableColors.background + property string stringColor : dimmableColors.clockTileColor + // app settings property string connectionPath @@ -118,26 +122,40 @@ App { // read json file function readPiHolePHPData() { - piholeConfigJSON = emptyPiholeConfigJSON; if ( connectionPath.length > 4 ) { var xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET", "http://"+connectionPath+"/admin/api.php", true); xmlhttp.onreadystatechange = function() { + if (xmlhttp.readyState == XMLHttpRequest.DONE) { if (xmlhttp.status === 200) { - piholeConfigJSON = JSON.parse(xmlhttp.responseText); - + piholeConfigJSON = JSON.parse(xmlhttp.responseText); tmp_ads_blocked_today = piholeConfigJSON['ads_blocked_today']; tmp_ads_percentage_today = Math.round(piholeConfigJSON['ads_percentage_today']) + "%"; status = piholeConfigJSON['status']; var tmp = new Date(); lastupdated = tmp.getFullYear() + "-" + ("0" + (tmp.getMonth() + 1)).slice(-2) + "-" + ("0" + tmp.getDate()).slice(-2) + " " + ("0" + tmp.getHours() ).slice(-2) + ":" + ("0" + tmp.getMinutes()).slice(-2); } + if (xmlhttp.status === 0) { + piholeConfigJSON = emptyPiholeConfigJSON; + } + if (piholeConfigJSON['status'] == "geen connectie") { + tileBackcolor = "#FF0000"; + stringBackcolor = "#FF0000"; + stringColor = "#FFFFFF"; } else { - tmp_ads_blocked_today = "server incorrect"; - tmp_ads_percentage_today = "server incorrect"; + if (piholeConfigJSON['status'] == "disabled") { + tileBackcolor = "#FFA500"; + stringBackcolor = "#FFA500"; + stringColor = "#000000"; + } else { + tileBackcolor = dimmableColors.tileBackground; + stringBackcolor = dimmableColors.tileBackground; + stringColor = dimmableColors.clockTileColor; + } } + } } xmlhttp.send(); } else { diff --git a/PiholestatsTile.qml b/PiholestatsTile.qml index ca54506..8e89966 100644 --- a/PiholestatsTile.qml +++ b/PiholestatsTile.qml @@ -9,7 +9,13 @@ Tile { onClicked: { stage.openFullscreen(app.piholeScreenUrl); } - bgColor: (app.piholeConfigJSON['status'] == "geen connectie") ? "#FF0000" : dimmableColors.background + + Rectangle { + width: piholeTile.width + height: piholeTile.height + color: dimState ? dimmableColors.tileBackground : app.tileBackcolor + radius: 5 + } // Title Text { @@ -78,7 +84,7 @@ Tile { // line 5 text Rectangle { - color: (app.piholeConfigJSON['status'] == "geen connectie") ? "#FF0000" : dimmableColors.background + color: app.stringBackcolor anchors { top: tileline4.bottom topMargin: 15 @@ -87,7 +93,7 @@ Tile { Text { id: tileline5 text: "status: " + app.piholeConfigJSON['status'] - color: (typeof dimmableColors !== 'undefined') ? dimmableColors.clockTileColor : colors.clockTileColor + color: app.stringColor font { family: qfont.regular.name pixelSize: isNxt ? 22 : 18 @@ -95,5 +101,6 @@ Tile { } width: childrenRect.width height: childrenRect.height + visible: (app.piholeConfigJSON['status'] !== "enabled") } } diff --git a/version.txt b/version.txt index 345f8cc..a34eaa5 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.1.10 \ No newline at end of file +0.1.11 \ No newline at end of file From 9470fdbef4688db402d9a723fa93ca279efeec88 Mon Sep 17 00:00:00 2001 From: ToonzDev Date: Sun, 19 Sep 2021 20:43:55 +0200 Subject: [PATCH 6/7] 0.1.12 --- Changelog.txt | 2 +- PiholestatsApp.qml | 27 ++++++++++++++------------- PiholestatsTile.qml | 14 +++++++++----- version.txt | 2 +- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index bd13c0d..ec3038d 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,4 +1,4 @@ -0.1.11 +0.1.12 - Tile colored red completely when connection with PiHole has been lost Tile colored orange when PiHole is disabled (not in dim state a colored status message is shown) diff --git a/PiholestatsApp.qml b/PiholestatsApp.qml index 3c54bcc..4477c34 100644 --- a/PiholestatsApp.qml +++ b/PiholestatsApp.qml @@ -13,6 +13,7 @@ App { property url piholeTileUrl : "PiholestatsTile.qml" property PiholestatsSettings piholeSettings property PiholestatsScreen piholeScreen + property PiholestatsTile piholeTile property bool dialogShown : false //shown when changes have been. Shown only once. property SystrayIcon piholeTray @@ -39,10 +40,6 @@ App { "gravity_last_updated":{"file_exists":true,"absolute":0,"relative":{"days":0,"hours":0,"minutes":0}} } property bool piholeDataRead: false - property string tileBackcolor : dimmableColors.background - property string stringBackcolor : dimmableColors.background - property string stringColor : dimmableColors.clockTileColor - // app settings property string connectionPath @@ -57,6 +54,10 @@ App { property string lastupdated property string status + property string tileColor + property string textBgColor + property string textColor + // user settings from config file property variant userSettingsJSON : { 'connectionPath': [], @@ -141,18 +142,18 @@ App { piholeConfigJSON = emptyPiholeConfigJSON; } if (piholeConfigJSON['status'] == "geen connectie") { - tileBackcolor = "#FF0000"; - stringBackcolor = "#FF0000"; - stringColor = "#FFFFFF"; + tileColor = "#FF0000"; + textBgColor = "#FF0000"; + textColor = "#FFFFFF"; } else { if (piholeConfigJSON['status'] == "disabled") { - tileBackcolor = "#FFA500"; - stringBackcolor = "#FFA500"; - stringColor = "#000000"; + tileColor = "#FFA500"; + textBgColor = "#FFA500"; + textColor = "#000000"; } else { - tileBackcolor = dimmableColors.tileBackground; - stringBackcolor = dimmableColors.tileBackground; - stringColor = dimmableColors.clockTileColor; + tileColor = dimmableColors.tileBackground; + textBgColor = dimmableColors.tileBackground; + textColor = dimmableColors.clockTileColor; } } } diff --git a/PiholestatsTile.qml b/PiholestatsTile.qml index 8e89966..d5e5d1d 100644 --- a/PiholestatsTile.qml +++ b/PiholestatsTile.qml @@ -10,11 +10,14 @@ Tile { stage.openFullscreen(app.piholeScreenUrl); } - Rectangle { - width: piholeTile.width - height: piholeTile.height - color: dimState ? dimmableColors.tileBackground : app.tileBackcolor - radius: 5 + Item { //listener to respond realtime to property changes + property string tileColor: app.tileColor + property string textColor: app.textColor + property string textBgColor: app.textBgColor + + onTileColorChanged: piholeTile.bgColor = tileColor; + onTextColorChanged: tileline5.color = textColor; + onTextBgColorChanged: text5Rect.color = textBgColor; } // Title @@ -84,6 +87,7 @@ Tile { // line 5 text Rectangle { + id: text5Rect color: app.stringBackcolor anchors { top: tileline4.bottom diff --git a/version.txt b/version.txt index a34eaa5..6a36bb4 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.1.11 \ No newline at end of file +0.1.12 \ No newline at end of file From 5dfadae94a5337504ca5941f90cf7cc22b778fc8 Mon Sep 17 00:00:00 2001 From: ToonzDev Date: Mon, 20 Sep 2021 10:26:49 +0200 Subject: [PATCH 7/7] 0.1.13 --- Changelog.txt | 2 +- PiholestatsApp.qml | 2 +- PiholestatsTile.qml | 30 ++++++++++++++++++++++++++++-- version.txt | 2 +- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index ec3038d..4824e7e 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,4 +1,4 @@ -0.1.12 +0.1.13 - Tile colored red completely when connection with PiHole has been lost Tile colored orange when PiHole is disabled (not in dim state a colored status message is shown) diff --git a/PiholestatsApp.qml b/PiholestatsApp.qml index 4477c34..80a86bf 100644 --- a/PiholestatsApp.qml +++ b/PiholestatsApp.qml @@ -151,7 +151,7 @@ App { textBgColor = "#FFA500"; textColor = "#000000"; } else { - tileColor = dimmableColors.tileBackground; + tileColor = "#FFFFFF"; textBgColor = dimmableColors.tileBackground; textColor = dimmableColors.clockTileColor; } diff --git a/PiholestatsTile.qml b/PiholestatsTile.qml index d5e5d1d..ccdc52d 100644 --- a/PiholestatsTile.qml +++ b/PiholestatsTile.qml @@ -6,6 +6,25 @@ Tile { id: piholeTile property bool dimState: screenStateController.dimmedColors + onDimStateChanged: { + resetBackgroundColor(); + } + + function resetBackgroundColor() { + if (app.piholeConfigJSON['status'] == "enabled") { + fullRectangle.color = dimState ? "#000000" : "#FFFFFF" + console.log("PiHole enabled, dim:" + dimState); + } else { + if (app.piholeConfigJSON['status'] == "disabled") { + fullRectangle.color = dimState ? "#000000" : "#FFA500" + console.log("PiHole disabled, dim:" + dimState); + } else { + fullRectangle.color = dimState ? "#000000" : "#FF0000" + console.log("PiHole other, dim:" + dimState); + } + } + } + onClicked: { stage.openFullscreen(app.piholeScreenUrl); } @@ -15,11 +34,18 @@ Tile { property string textColor: app.textColor property string textBgColor: app.textBgColor - onTileColorChanged: piholeTile.bgColor = tileColor; + onTileColorChanged: resetBackgroundColor(); onTextColorChanged: tileline5.color = textColor; onTextBgColorChanged: text5Rect.color = textBgColor; } + Rectangle { + id:fullRectangle + width: piholeTile.width + height: piholeTile.height + radius: 5 + } + // Title Text { id: tiletitle @@ -91,7 +117,7 @@ Tile { color: app.stringBackcolor anchors { top: tileline4.bottom - topMargin: 15 + topMargin: isNxt ? 15 : 10 horizontalCenter: parent.horizontalCenter } Text { diff --git a/version.txt b/version.txt index 6a36bb4..45263ab 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.1.12 \ No newline at end of file +0.1.13 \ No newline at end of file