loading state rewrite

This commit is contained in:
umorist 2026-03-14 13:42:15 +03:00
parent 16bb81bd2f
commit 751aab6ffa

View file

@ -85,7 +85,7 @@ PlasmoidItem {
ListModel { id: ownedlocalipsModel } ListModel { id: ownedlocalipsModel }
// buttons blocker (antispam) // buttons blocker (antispam)
property int isLoadingItems: 0 property int isLoadingItems: 0 // крч на деле говно ебаное я ебал фиксить
property bool isLoading: false // колясочные технологии, по итогу юзается токо isLoadingItems property bool isLoading: false // колясочные технологии, по итогу юзается токо isLoadingItems
property bool isBlocked: false property bool isBlocked: false
property bool shareBlocked: false property bool shareBlocked: false
@ -97,6 +97,12 @@ PlasmoidItem {
property bool firewallBlocked: false property bool firewallBlocked: false
property bool timeouted: false property bool timeouted: false
property int generalLoading: (routesLoading || profileLoading || statsLoading || firewallLoading)
property bool routesLoading: false
property bool profileLoading: false
property bool statsLoading: false
property bool firewallLoading: false
onIsLoadingItemsChanged: { onIsLoadingItemsChanged: {
if (isLoadingItems > 0) { if (isLoadingItems > 0) {
isLoading = true isLoading = true
@ -145,7 +151,8 @@ PlasmoidItem {
firewallBlocked = true firewallBlocked = true
Plasmoid.configuration.OnErrorRefresh ? ( Plasmoid.configuration.OnErrorRefresh ? (
meowRelayWatchdog.start(), meowRelayWatchdog.start(),
isLoadingItems += Plasmoid.configuration.BIrefresh, //isLoadingItems += Plasmoid.configuration.BIrefresh,
(Plasmoid.configuration.BIrefresh ? (routesLoading = true, profileLoading = true, statsLoading = true, firewallLoading = true) : null),
//isBlocked = true, //isBlocked = true,
superWorker.sendMessage({ "action": "fetch_routes" }), superWorker.sendMessage({ "action": "fetch_routes" }),
superWorker.sendMessage({ "action": "fetch_profile" }), superWorker.sendMessage({ "action": "fetch_profile" }),
@ -167,7 +174,7 @@ PlasmoidItem {
refreshBlocked = false refreshBlocked = false
Plasmoid.configuration.OnErrorRefresh ? ( Plasmoid.configuration.OnErrorRefresh ? (
meowRelayWatchdogRoutes.start(), meowRelayWatchdogRoutes.start(),
isLoadingItems += Plasmoid.configuration.BIrefresh, //isLoadingItems += Plasmoid.configuration.BIrefresh,
//isBlocked = true, //isBlocked = true,
superWorker.sendMessage({ "action": "fetch_routes" }), superWorker.sendMessage({ "action": "fetch_routes" }),
fetchRoutesTimer.restart() fetchRoutesTimer.restart()
@ -184,7 +191,7 @@ PlasmoidItem {
refreshBlocked = false refreshBlocked = false
Plasmoid.configuration.OnErrorRefresh ? ( Plasmoid.configuration.OnErrorRefresh ? (
meowRelayWatchdogProfile.start(), meowRelayWatchdogProfile.start(),
isLoadingItems += Plasmoid.configuration.BIrefresh, //isLoadingItems += Plasmoid.configuration.BIrefresh,
//isBlocked = true, //isBlocked = true,
superWorker.sendMessage({ "action": "fetch_profile" }), superWorker.sendMessage({ "action": "fetch_profile" }),
fetchProfileTimer.restart() fetchProfileTimer.restart()
@ -201,13 +208,27 @@ PlasmoidItem {
refreshBlocked = false refreshBlocked = false
Plasmoid.configuration.OnErrorRefresh ? ( Plasmoid.configuration.OnErrorRefresh ? (
meowRelayWatchdogStats.start(), meowRelayWatchdogStats.start(),
isLoadingItems += Plasmoid.configuration.BIrefresh, //isLoadingItems += Plasmoid.configuration.BIrefresh,
//isBlocked = true, //isBlocked = true,
superWorker.sendMessage({ "action": "fetch_stats" }), superWorker.sendMessage({ "action": "fetch_stats" }),
fetchStatsTimer.restart() fetchStatsTimer.restart()
) : null ) : null
} }
} }
Timer {
id: meowRelayWatchdogProfileAction
interval: 10000
repeat: false
onTriggered: {
console.error("MeowRelay unreachable!") //ваша няшка умерла
timeouted = true
refreshBlocked = false
Plasmoid.configuration.OnErrorRefresh ? (
meowRelayWatchdogProfileAction.start(),
superWorker.sendMessage({ "action": "fetch_profile" })
) : null
}
}
Timer { Timer {
id: meowRelayPing id: meowRelayPing
interval: Plasmoid.configuration.AutoPingInt * 1000 interval: Plasmoid.configuration.AutoPingInt * 1000
@ -231,9 +252,10 @@ PlasmoidItem {
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
routeModel.append(data[i]); routeModel.append(data[i]);
}; };
if (Plasmoid.configuration.BIrefresh || Plasmoid.configuration.BIautoupdate) { // if (Plasmoid.configuration.BIrefresh || Plasmoid.configuration.BIautoupdate) {
isLoadingItems -= 1 // isLoadingItems -= 1
}; // };
routesLoading = false;
meowRelayWatchdogRoutes.stop(); meowRelayWatchdogRoutes.stop();
refreshBlocked = false; refreshBlocked = false;
timeouted = false; timeouted = false;
@ -258,9 +280,10 @@ PlasmoidItem {
for (let i = 0; i < serverArray.length; i++) { for (let i = 0; i < serverArray.length; i++) {
statsModel.append(serverArray[i]); statsModel.append(serverArray[i]);
}; };
if (Plasmoid.configuration.BIrefresh || Plasmoid.configuration.BIautoupdate) { // if (Plasmoid.configuration.BIrefresh || Plasmoid.configuration.BIautoupdate) {
isLoadingItems -= 1 // isLoadingItems -= 1
}; // };
statsLoading = false;
meowRelayWatchdogStats.stop(); meowRelayWatchdogStats.stop();
refreshBlocked = false; refreshBlocked = false;
timeouted = false; timeouted = false;
@ -289,11 +312,13 @@ PlasmoidItem {
tabs.setProperty(2, "visible", firewallEnabled) tabs.setProperty(2, "visible", firewallEnabled)
} }
} }
if (Plasmoid.configuration.BIrefresh || Plasmoid.configuration.BIautoupdate) { // if (Plasmoid.configuration.BIrefresh || Plasmoid.configuration.BIautoupdate) {
isLoadingItems -= 1 // isLoadingItems -= 1
} // }
profileLoading = false;
meowRelayWatchdog.stop(); meowRelayWatchdog.stop();
meowRelayWatchdogProfile.stop(); meowRelayWatchdogProfile.stop();
meowRelayWatchdogProfileAction.stop();
timeouted = false; timeouted = false;
isBlocked = false; isBlocked = false;
refreshBlocked = false; refreshBlocked = false;
@ -330,22 +355,24 @@ PlasmoidItem {
}); });
} }
firewallBlocked = false; firewallBlocked = false;
if (Plasmoid.configuration.BIpostfirewall) { // if (Plasmoid.configuration.BIpostfirewall) {
isLoadingItems -= 1 // isLoadingItems -= 1
}; // };
firewallLoading = false;
}, },
"post_country": ({ status }) => { "post_country": ({ status }) => {
if (status === 200) { if (status === 200) {
superWorker.sendMessage({ "action": "fetch_profile" }) superWorker.sendMessage({ "action": "fetch_profile" })
routesLoading = false
//done //done
} }
else { else {
superWorker.sendMessage({ "actions": "fetch_routes" }) superWorker.sendMessage({ "actions": "fetch_routes" })
//error //error
}; };
if (Plasmoid.configuration.BIpostcountry) { // if (Plasmoid.configuration.BIpostcountry) {
isLoadingItems -= 1 // isLoadingItems -= 1
} // }
}, },
"post_share": ({ status }) => { "post_share": ({ status }) => {
if (status === 200) { if (status === 200) {
@ -353,13 +380,13 @@ PlasmoidItem {
//done //done
} }
else { else {
superWorker.sendMessage({ "action": "fetch_profile" }) superWorker.sendMessage({ "action": "fetch_profile" }) // кофе
// share = !share // share = !share
//error //error
}; };
if (Plasmoid.configuration.BIpostshare) { // if (Plasmoid.configuration.BIpostshare) {
isLoadingItems -= 1 // isLoadingItems -= 1
} // }
shareBlocked = false; shareBlocked = false;
}, },
"post_ebalka": ({ status, ip }) => { "post_ebalka": ({ status, ip }) => {
@ -371,12 +398,12 @@ PlasmoidItem {
superWorker.sendMessage({ "action": "fetch_profile" }) // кофе superWorker.sendMessage({ "action": "fetch_profile" }) // кофе
//error //error
}; };
if (Plasmoid.configuration.BIpostebalka) { // if (Plasmoid.configuration.BIpostebalka) {
isLoadingItems -= 1 // isLoadingItems -= 1
} // }
if (Plasmoid.configuration.BIdevicesupdate) { // if (Plasmoid.configuration.BIdevicesupdate) {
isLoadingItems -= 1 // isLoadingItems -= 1
} // }
ebalkaBlocked = false; ebalkaBlocked = false;
devicesBlocked = false; devicesBlocked = false;
}, },
@ -388,36 +415,36 @@ PlasmoidItem {
else { else {
//error //error
}; };
if (Plasmoid.configuration.BIdevicesupdate) { // if (Plasmoid.configuration.BIdevicesupdate) {
isLoadingItems -= 1 // isLoadingItems -= 1
} // }
devicesBlocked = false; devicesBlocked = false;
}, },
"post_feature": ({ status }) => { "post_feature": ({ status }) => {
superWorker.sendMessage({ "action": "fetch_profile" }); superWorker.sendMessage({ "action": "fetch_profile" });
if (Plasmoid.configuration.BIfeaturesupdate) { // if (Plasmoid.configuration.BIfeaturesupdate) {
isLoadingItems -= 1 // isLoadingItems -= 1
} // }
featuresBlocked = false; featuresBlocked = false;
}, },
"post_idconnect": ({ status }) => { "post_idconnect": ({ status }) => {
superWorker.sendMessage({ "action": "fetch_profile" }); superWorker.sendMessage({ "action": "fetch_profile" });
superWorker.sendMessage({ "action": "fetch_routes" }); superWorker.sendMessage({ "action": "fetch_routes" });
if (Plasmoid.configuration.BIpostcountry) { // if (Plasmoid.configuration.BIpostcountry) {
isLoadingItems -= 1 // isLoadingItems -= 1
} // }
}, },
"post_ruleadd": ({ status }) => { "post_ruleadd": ({ status }) => {
superWorker.sendMessage({ "action": "fetch_firewall" }); superWorker.sendMessage({ "action": "fetch_firewall" });
if (Plasmoid.configuration.BIpostfirewall) { // if (Plasmoid.configuration.BIpostfirewall) {
isLoadingItems -= 1 // isLoadingItems -= 1
} // }
}, },
"post_ruledrop": ({ status }) => { "post_ruledrop": ({ status }) => {
superWorker.sendMessage({ "action": "fetch_firewall" }); superWorker.sendMessage({ "action": "fetch_firewall" });
if (Plasmoid.configuration.BIpostfirewall) { // if (Plasmoid.configuration.BIpostfirewall) {
isLoadingItems -= 1 // isLoadingItems -= 1
} // }
} }
}) })
@ -430,7 +457,8 @@ PlasmoidItem {
// init fetch // init fetch
Component.onCompleted: { Component.onCompleted: {
isLoadingItems += Plasmoid.configuration.BIinit //isLoadingItems += Plasmoid.configuration.BIinit
Plasmoid.configuration.BIinit ? (routesLoading = true, profileLoading = true, statsLoading = true, firewallLoading = true) : null
isBlocked = true isBlocked = true
meowRelayWatchdog.start() meowRelayWatchdog.start()
superWorker.sendMessage({ "action": "fetch_routes" }) superWorker.sendMessage({ "action": "fetch_routes" })
@ -452,7 +480,8 @@ PlasmoidItem {
triggeredOnStart: false triggeredOnStart: false
onTriggered: { onTriggered: {
//refreshBlocked = true //refreshBlocked = true
isLoadingItems += Plasmoid.configuration.BIautoupdate //isLoadingItems += Plasmoid.configuration.BIautoupdate
Plasmoid.configuration.BIautoupdate ? (routesLoading = true) : null
meowRelayWatchdogRoutes.start() meowRelayWatchdogRoutes.start()
superWorker.sendMessage({ "action": "fetch_routes" }) superWorker.sendMessage({ "action": "fetch_routes" })
} }
@ -465,7 +494,8 @@ PlasmoidItem {
triggeredOnStart: false triggeredOnStart: false
onTriggered: { onTriggered: {
//refreshBlocked = true //refreshBlocked = true
isLoadingItems += Plasmoid.configuration.BIautoupdate //isLoadingItems += Plasmoid.configuration.BIautoupdate
Plasmoid.configuration.BIautoupdate ? (statsLoading = true) : null
meowRelayWatchdogStats.start() meowRelayWatchdogStats.start()
superWorker.sendMessage({ "action": "fetch_stats" }) superWorker.sendMessage({ "action": "fetch_stats" })
} }
@ -478,7 +508,8 @@ PlasmoidItem {
triggeredOnStart: false triggeredOnStart: false
onTriggered: { onTriggered: {
//refreshBlocked = true //refreshBlocked = true
isLoadingItems += Plasmoid.configuration.BIautoupdate //isLoadingItems += Plasmoid.configuration.BIautoupdate
Plasmoid.configuration.BIautoupdate ? (profileLoading = true) : null
meowRelayWatchdogProfile.start() meowRelayWatchdogProfile.start()
superWorker.sendMessage({ "action": "fetch_profile" }) superWorker.sendMessage({ "action": "fetch_profile" })
} }
@ -610,7 +641,8 @@ PlasmoidItem {
icon.name: "view-refresh" icon.name: "view-refresh"
enabled: !(isBlocked) enabled: !(isBlocked)
onClicked: { onClicked: {
isLoadingItems += Plasmoid.configuration.BIpostfirewall //isLoadingItems += Plasmoid.configuration.BIpostfirewall
Plasmoid.configuration.BIpostfirewall ? (firewallLoading = true) : null
firewallBlocked = true firewallBlocked = true
superWorker.sendMessage({ "action": "fetch_firewall" }) superWorker.sendMessage({ "action": "fetch_firewall" })
} }
@ -619,7 +651,8 @@ PlasmoidItem {
text: "Add" text: "Add"
enabled: !(isBlocked || firewallBlocked) enabled: !(isBlocked || firewallBlocked)
onClicked: { onClicked: {
isLoadingItems += Plasmoid.configuration.BIpostfirewall //isLoadingItems += Plasmoid.configuration.BIpostfirewall
Plasmoid.configuration.BIpostfirewall ? (firewallLoading = true) : null
firewallBlocked = true firewallBlocked = true
superWorker.sendMessage({ "action": "post_ruleadd", "dst": firewallLocalIp.currentValue, "ext": firewallIp.currentValue, "local_port": firewallLocalPortSpinner.value, "port": firewallPortSpinner.value, "proto": firewallProto.currentValue }) superWorker.sendMessage({ "action": "post_ruleadd", "dst": firewallLocalIp.currentValue, "ext": firewallIp.currentValue, "local_port": firewallLocalPortSpinner.value, "port": firewallPortSpinner.value, "proto": firewallProto.currentValue })
} }
@ -765,8 +798,12 @@ PlasmoidItem {
icon.name: "view-refresh" icon.name: "view-refresh"
onClicked: { onClicked: {
meowRelayWatchdog.running ? meowRelayWatchdog.stop() : null meowRelayWatchdog.running ? meowRelayWatchdog.stop() : null
meowRelayWatchdogRoutes.running ? meowRelayWatchdogRoutes.stop() : null
meowRelayWatchdogProfile.running ? meowRelayWatchdogProfile.stop() : null
meowRelayWatchdogStats.running ? meowRelayWatchdogStats.stop() : null
meowRelayWatchdog.start() meowRelayWatchdog.start()
isLoadingItems += Plasmoid.configuration.BIrefresh //isLoadingItems = (0 + (Plasmoid.configuration.BIrefresh * 4))
Plasmoid.configuration.BIrefresh ? (routesLoading = true, profileLoading = true, statsLoading = true, firewallLoading = true) : null
isBlocked = true isBlocked = true
superWorker.sendMessage({ "action": "fetch_routes" }) superWorker.sendMessage({ "action": "fetch_routes" })
superWorker.sendMessage({ "action": "fetch_profile" }) superWorker.sendMessage({ "action": "fetch_profile" })
@ -780,7 +817,7 @@ PlasmoidItem {
Layout.fillWidth: false Layout.fillWidth: false
} }
PlasmaComponents.BusyIndicator { PlasmaComponents.BusyIndicator {
running: isLoadingItems //isLoading running: generalLoading //isLoading
implicitWidth: 28 implicitWidth: 28
implicitHeight: 28 implicitHeight: 28
} }
@ -806,7 +843,8 @@ PlasmoidItem {
checked: share checked: share
enabled: !(isBlocked || shareBlocked) enabled: !(isBlocked || shareBlocked)
onClicked: { onClicked: {
isLoadingItems += Plasmoid.configuration.BIpostshare //isLoadingItems += Plasmoid.configuration.BIpostshare
Plasmoid.configuration.BIpostshare ? (profileLoading = true) : null
shareBlocked = true shareBlocked = true
superWorker.sendMessage({ "action": "post_share", "bool": !share }) superWorker.sendMessage({ "action": "post_share", "bool": !share })
share = !share share = !share
@ -824,7 +862,8 @@ PlasmoidItem {
checked: ebalka checked: ebalka
enabled: !(isBlocked || ebalkaBlocked) enabled: !(isBlocked || ebalkaBlocked)
onClicked: { onClicked: {
isLoadingItems += Plasmoid.configuration.BIpostebalka //isLoadingItems += Plasmoid.configuration.BIpostebalka
Plasmoid.configuration.BIpostebalka ? (profileLoading = true) : null
ebalkaBlocked = true ebalkaBlocked = true
superWorker.sendMessage({ "action": "post_ebalka", "bool": !ebalka, "ip": null }) superWorker.sendMessage({ "action": "post_ebalka", "bool": !ebalka, "ip": null })
ebalka = !ebalka ebalka = !ebalka
@ -899,7 +938,8 @@ PlasmoidItem {
} }
} }
onClicked: { onClicked: {
isLoadingItems += Plasmoid.configuration.BIpostcountry //isLoadingItems += Plasmoid.configuration.BIpostcountry
Plasmoid.configuration.BIpostcountry ? (routesLoading = true) : null
superWorker.sendMessage({ "action": "post_country", "code": model.code, "provider": model.provider }) superWorker.sendMessage({ "action": "post_country", "code": model.code, "provider": model.provider })
} }
} }
@ -1016,7 +1056,8 @@ PlasmoidItem {
checked: model.ebalka checked: model.ebalka
enabled: !(isBlocked || devicesBlocked) enabled: !(isBlocked || devicesBlocked)
onClicked: { onClicked: {
isLoadingItems += Plasmoid.configuration.BIdevicesupdate //isLoadingItems += Plasmoid.configuration.BIdevicesupdate
Plasmoid.configuration.BIdevicesupdate ? (profileLoading = true) : null
devicesBlocked = true devicesBlocked = true
superWorker.sendMessage({ "action": "post_ebalka", "bool": !model.ebalka, "ip": model.ip }) superWorker.sendMessage({ "action": "post_ebalka", "bool": !model.ebalka, "ip": model.ip })
// ebalka = !ebalka // ebalka = !ebalka
@ -1036,6 +1077,7 @@ PlasmoidItem {
padding: Kirigami.Units.largeSpacing padding: Kirigami.Units.largeSpacing
function confirmAction() { function confirmAction() {
Plasmoid.configuration.BIdevicesupdate ? (profileLoading = true) : null
superWorker.sendMessage({ "action": "post_name", "ip": model.ip, "name": textInput.text }) superWorker.sendMessage({ "action": "post_name", "ip": model.ip, "name": textInput.text })
inputMenu.close(); inputMenu.close();
textInput.text = ""; textInput.text = "";
@ -1178,7 +1220,8 @@ PlasmoidItem {
text: "Drop" text: "Drop"
enabled: !(isBlocked || firewallBlocked) enabled: !(isBlocked || firewallBlocked)
onClicked: { onClicked: {
isLoadingItems += Plasmoid.configuration.BIpostfirewall //isLoadingItems += Plasmoid.configuration.BIpostfirewall
Plasmoid.configuration.BIpostfirewall ? (firewallLoading = true) : null
firewallBlocked = true firewallBlocked = true
superWorker.sendMessage({ "action": "post_ruledrop", "dst": model.dst, "ext": model.ip, "local_port": model.local_port, "port": model.port, "proto": model.proto }) superWorker.sendMessage({ "action": "post_ruledrop", "dst": model.dst, "ext": model.ip, "local_port": model.local_port, "port": model.port, "proto": model.proto })
} }
@ -1307,7 +1350,8 @@ PlasmoidItem {
} }
} }
onClicked: { onClicked: {
isLoadingItems += Plasmoid.configuration.BIpostcountry //isLoadingItems += Plasmoid.configuration.BIpostcountry
Plasmoid.configuration.BIpostcountry ? (routesLoading = true, profileLoading = true) : null
superWorker.sendMessage({ "action": "post_idconnect", "iface": model.name }) superWorker.sendMessage({ "action": "post_idconnect", "iface": model.name })
} }
} }
@ -1378,7 +1422,8 @@ PlasmoidItem {
checked: model.value checked: model.value
enabled: !(isBlocked || featuresBlocked) enabled: !(isBlocked || featuresBlocked)
onClicked: { onClicked: {
isLoadingItems += Plasmoid.configuration.BIfeaturesupdate //isLoadingItems += Plasmoid.configuration.BIfeaturesupdate
Plasmoid.configuration.BIfeaturesupdate ? (profileLoading = true) : null
//featuresBlocked = true //featuresBlocked = true
superWorker.sendMessage({ "action": "post_feature", "name": model.name, "value": !model.value }) superWorker.sendMessage({ "action": "post_feature", "name": model.name, "value": !model.value })
} }