mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-05 05:12:05 -04:00
chore: Tidy up superfluous whitespace (#503)
This commit is contained in:
@@ -11,7 +11,7 @@ Singleton {
|
||||
id: root
|
||||
|
||||
property var applications: DesktopEntries.applications.values.filter(app => !app.noDisplay && !app.runInTerminal)
|
||||
|
||||
|
||||
|
||||
|
||||
function searchApplications(query) {
|
||||
@@ -266,7 +266,7 @@ Singleton {
|
||||
|
||||
function getPluginCategoryIcon(category) {
|
||||
if (typeof PluginService === "undefined") return null
|
||||
|
||||
|
||||
const launchers = PluginService.getLauncherPlugins()
|
||||
for (const pluginId in launchers) {
|
||||
const plugin = launchers[pluginId]
|
||||
@@ -296,7 +296,7 @@ Singleton {
|
||||
|
||||
function getPluginItems(category, query) {
|
||||
if (typeof PluginService === "undefined") return []
|
||||
|
||||
|
||||
const launchers = PluginService.getLauncherPlugins()
|
||||
for (const pluginId in launchers) {
|
||||
const plugin = launchers[pluginId]
|
||||
@@ -338,42 +338,42 @@ Singleton {
|
||||
|
||||
function executePluginItem(item, pluginId) {
|
||||
if (typeof PluginService === "undefined") return false
|
||||
|
||||
|
||||
const component = PluginService.pluginLauncherComponents[pluginId]
|
||||
if (!component) return false
|
||||
|
||||
|
||||
try {
|
||||
const instance = component.createObject(root, {
|
||||
"pluginService": PluginService
|
||||
})
|
||||
|
||||
|
||||
if (instance && typeof instance.executeItem === "function") {
|
||||
instance.executeItem(item)
|
||||
instance.destroy()
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
if (instance) {
|
||||
instance.destroy()
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn("AppSearchService: Error executing item from plugin", pluginId, ":", e)
|
||||
}
|
||||
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
function searchPluginItems(query) {
|
||||
if (typeof PluginService === "undefined") return []
|
||||
|
||||
|
||||
let allItems = []
|
||||
const launchers = PluginService.getLauncherPlugins()
|
||||
|
||||
|
||||
for (const pluginId in launchers) {
|
||||
const items = getPluginItemsForPlugin(pluginId, query)
|
||||
allItems = allItems.concat(items)
|
||||
}
|
||||
|
||||
|
||||
return allItems
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ Singleton {
|
||||
property string ethernetConnectionUuid: ""
|
||||
|
||||
property var wiredConnections: []
|
||||
|
||||
|
||||
property string wifiIP: ""
|
||||
property string wifiInterface: ""
|
||||
property bool wifiConnected: false
|
||||
@@ -75,7 +75,7 @@ Singleton {
|
||||
property string networkInfoSSID: ""
|
||||
property string networkInfoDetails: ""
|
||||
property bool networkInfoLoading: false
|
||||
|
||||
|
||||
property string networkWiredInfoUUID: ""
|
||||
property string networkWiredInfoDetails: ""
|
||||
property bool networkWiredInfoLoading: false
|
||||
@@ -158,12 +158,12 @@ Singleton {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if (line.includes("StateChanged") ||
|
||||
line.includes("PrimaryConnectionChanged") ||
|
||||
line.includes("WirelessEnabled") ||
|
||||
(line.includes("ActiveConnection") && line.includes("State"))) {
|
||||
|
||||
|
||||
if (now - nmStateMonitor.lastRefreshTime > nmStateMonitor.minRefreshInterval) {
|
||||
nmStateMonitor.lastRefreshTime = now
|
||||
refreshNetworkState()
|
||||
|
||||
@@ -71,7 +71,7 @@ Singleton {
|
||||
property string networkInfoSSID: ""
|
||||
property string networkInfoDetails: ""
|
||||
property bool networkInfoLoading: false
|
||||
|
||||
|
||||
property string networkWiredInfoUUID: ""
|
||||
property string networkWiredInfoDetails: ""
|
||||
property bool networkWiredInfoLoading: false
|
||||
@@ -227,7 +227,7 @@ Singleton {
|
||||
|
||||
connectionChanged()
|
||||
}
|
||||
|
||||
|
||||
function connectToSpecificWiredConfig(uuid) {
|
||||
if (!networkAvailable || isConnecting) return
|
||||
|
||||
@@ -446,7 +446,7 @@ Singleton {
|
||||
autoScan = false
|
||||
autoRefreshEnabled = false
|
||||
}
|
||||
|
||||
|
||||
function fetchWiredNetworkInfo(uuid) {
|
||||
if (!networkAvailable) return
|
||||
|
||||
@@ -475,18 +475,18 @@ Singleton {
|
||||
details += "Driver: " + info.driver + "\\n"
|
||||
details += "MAC Addr: " + info.hwAddr + "\\n"
|
||||
details += "Speed: " + info.speed + " Mb/s\\n\\n"
|
||||
|
||||
|
||||
details += "IPv4 informations:\\n"
|
||||
|
||||
|
||||
for (const ip4 of info.IPv4s.ips) {
|
||||
details += " IPv4 address: " + ip4 + "\\n"
|
||||
}
|
||||
details += " Gateway: " + info.IPv4s.gateway + "\\n"
|
||||
details += " DNS: " + info.IPv4s.dns + "\\n"
|
||||
|
||||
|
||||
if (info.IPv6s.ips) {
|
||||
details += "\\nIPv6 informations:\\n"
|
||||
|
||||
|
||||
for (const ip6 of info.IPv6s.ips) {
|
||||
details += " IPv6 address: " + ip6 + "\\n"
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ Singleton {
|
||||
property string networkInfoSSID: activeService?.networkInfoSSID ?? ""
|
||||
property string networkInfoDetails: activeService?.networkInfoDetails ?? ""
|
||||
property bool networkInfoLoading: activeService?.networkInfoLoading ?? false
|
||||
|
||||
|
||||
property string networkWiredInfoUUID: activeService?.networkWiredInfoUUID ?? ""
|
||||
property string networkWiredInfoDetails: activeService?.networkWiredInfoDetails ?? ""
|
||||
property bool networkWiredInfoLoading: activeService?.networkWiredInfoLoading ?? false
|
||||
@@ -252,7 +252,7 @@ Singleton {
|
||||
activeService.refreshNetworkState()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function connectToSpecificWiredConfig(uuid) {
|
||||
if (activeService && activeService.connectToSpecificWiredConfig) {
|
||||
activeService.connectToSpecificWiredConfig(uuid)
|
||||
|
||||
@@ -538,7 +538,7 @@ Singleton {
|
||||
// Launcher plugin helper functions
|
||||
function getLauncherPlugins() {
|
||||
const launchers = {}
|
||||
|
||||
|
||||
// Check plugins that have launcher components
|
||||
for (const pluginId in pluginLauncherComponents) {
|
||||
const plugin = availablePlugins[pluginId]
|
||||
|
||||
@@ -302,7 +302,7 @@ Singleton {
|
||||
|
||||
function cyclePrevForMonitor(screenName) {
|
||||
if (!screenName) return
|
||||
|
||||
|
||||
var currentWallpaper = SessionData.getMonitorWallpaper(screenName)
|
||||
if (currentWallpaper) {
|
||||
cycleToPrevWallpaper(screenName, currentWallpaper)
|
||||
@@ -370,10 +370,10 @@ Singleton {
|
||||
|
||||
Process {
|
||||
id: cyclingProcess
|
||||
|
||||
|
||||
property string targetScreenName: ""
|
||||
property string currentWallpaper: ""
|
||||
|
||||
|
||||
running: false
|
||||
|
||||
stdout: StdioCollector {
|
||||
@@ -404,10 +404,10 @@ Singleton {
|
||||
|
||||
Process {
|
||||
id: prevCyclingProcess
|
||||
|
||||
|
||||
property string targetScreenName: ""
|
||||
property string currentWallpaper: ""
|
||||
|
||||
|
||||
running: false
|
||||
|
||||
stdout: StdioCollector {
|
||||
|
||||
@@ -75,7 +75,7 @@ Singleton {
|
||||
"96": "thunderstorm",
|
||||
"99": "thunderstorm"
|
||||
})
|
||||
|
||||
|
||||
property var nightWeatherIcons: ({
|
||||
"0": "clear_night",
|
||||
"1": "clear_night",
|
||||
@@ -114,7 +114,7 @@ Singleton {
|
||||
const iconMap = isDay ? weatherIcons : nightWeatherIcons
|
||||
return iconMap[String(code)] || "cloud"
|
||||
}
|
||||
|
||||
|
||||
function getWeatherCondition(code) {
|
||||
const conditions = {
|
||||
"0": "Clear",
|
||||
@@ -148,10 +148,10 @@ Singleton {
|
||||
}
|
||||
return conditions[String(code)] || "Unknown"
|
||||
}
|
||||
|
||||
|
||||
function formatTime(isoString) {
|
||||
if (!isoString) return "--"
|
||||
|
||||
|
||||
try {
|
||||
const date = new Date(isoString)
|
||||
const format = SettingsData.use24HourClock ? "HH:mm" : "h:mm AP"
|
||||
@@ -160,15 +160,15 @@ Singleton {
|
||||
return "--"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function formatForecastDay(isoString, index) {
|
||||
if (!isoString) return "--"
|
||||
|
||||
|
||||
try {
|
||||
const date = new Date(isoString)
|
||||
if (index === 0) return I18n.tr("Today")
|
||||
if (index === 1) return I18n.tr("Tomorrow")
|
||||
|
||||
|
||||
const locale = Qt.locale()
|
||||
return locale.dayName(date.getDay(), Locale.ShortFormat)
|
||||
} catch (e) {
|
||||
@@ -180,7 +180,7 @@ Singleton {
|
||||
if (!location) {
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
const params = [
|
||||
"latitude=" + location.latitude,
|
||||
"longitude=" + location.longitude,
|
||||
@@ -189,14 +189,14 @@ Singleton {
|
||||
"timezone=auto",
|
||||
"forecast_days=7"
|
||||
]
|
||||
|
||||
|
||||
if (SettingsData.useFahrenheit) {
|
||||
params.push("temperature_unit=fahrenheit")
|
||||
}
|
||||
|
||||
|
||||
return "https://api.open-meteo.com/v1/forecast?" + params.join('&')
|
||||
}
|
||||
|
||||
|
||||
function getGeocodingUrl(query) {
|
||||
return "https://geocoding-api.open-meteo.com/v1/search?name=" + encodeURIComponent(query) + "&count=1&language=en&format=json"
|
||||
}
|
||||
@@ -229,25 +229,25 @@ Singleton {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const cityName = SettingsData.weatherLocation
|
||||
if (cityName) {
|
||||
getLocationFromCity(cityName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getLocationFromCoords(lat, lon) {
|
||||
const url = "https://nominatim.openstreetmap.org/reverse?lat=" + lat + "&lon=" + lon + "&format=json&addressdetails=1&accept-language=en"
|
||||
reverseGeocodeFetcher.command = lowPriorityCmd.concat(curlBaseCmd).concat(["-H", "User-Agent: DankMaterialShell Weather Widget", url])
|
||||
reverseGeocodeFetcher.running = true
|
||||
}
|
||||
|
||||
|
||||
function getLocationFromCity(city) {
|
||||
cityGeocodeFetcher.command = lowPriorityCmd.concat(curlBaseCmd).concat([getGeocodingUrl(city)])
|
||||
cityGeocodeFetcher.running = true
|
||||
}
|
||||
|
||||
|
||||
function getLocationFromIP() {
|
||||
ipLocationFetcher.running = true
|
||||
}
|
||||
@@ -287,7 +287,7 @@ Singleton {
|
||||
root.lastFetchTime = 0 // Reset throttle
|
||||
fetchWeather()
|
||||
}
|
||||
|
||||
|
||||
function nextInterval() {
|
||||
const jitter = Math.floor(Math.random() * 15000) - 7500
|
||||
return Math.max(60000, root.updateInterval + jitter)
|
||||
@@ -324,7 +324,7 @@ Singleton {
|
||||
id: ipLocationFetcher
|
||||
command: lowPriorityCmd.concat(curlBaseCmd).concat(["http://ipinfo.io/json"])
|
||||
running: false
|
||||
|
||||
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
const raw = text.trim()
|
||||
@@ -337,23 +337,23 @@ Singleton {
|
||||
const data = JSON.parse(raw)
|
||||
const coords = data.loc
|
||||
const city = data.city
|
||||
|
||||
|
||||
if (!coords || !city) {
|
||||
throw new Error("Missing location data")
|
||||
}
|
||||
|
||||
|
||||
const coordsParts = coords.split(",")
|
||||
if (coordsParts.length !== 2) {
|
||||
throw new Error("Invalid coordinates format")
|
||||
}
|
||||
|
||||
|
||||
const lat = parseFloat(coordsParts[0])
|
||||
const lon = parseFloat(coordsParts[1])
|
||||
|
||||
|
||||
if (isNaN(lat) || isNaN(lon)) {
|
||||
throw new Error("Invalid coordinate values")
|
||||
}
|
||||
|
||||
|
||||
root.location = {
|
||||
city: city,
|
||||
latitude: lat,
|
||||
@@ -365,18 +365,18 @@ Singleton {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onExited: exitCode => {
|
||||
if (exitCode !== 0) {
|
||||
root.handleWeatherFailure()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Process {
|
||||
id: reverseGeocodeFetcher
|
||||
running: false
|
||||
|
||||
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
const raw = text.trim()
|
||||
@@ -388,32 +388,32 @@ Singleton {
|
||||
try {
|
||||
const data = JSON.parse(raw)
|
||||
const address = data.address || {}
|
||||
|
||||
|
||||
root.location = {
|
||||
city: address.hamlet || address.city || address.town || address.village || "Unknown",
|
||||
country: address.country || "Unknown",
|
||||
latitude: parseFloat(data.lat),
|
||||
longitude: parseFloat(data.lon)
|
||||
}
|
||||
|
||||
|
||||
fetchWeather()
|
||||
} catch (e) {
|
||||
root.handleWeatherFailure()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onExited: exitCode => {
|
||||
if (exitCode !== 0) {
|
||||
root.handleWeatherFailure()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Process {
|
||||
id: cityGeocodeFetcher
|
||||
running: false
|
||||
|
||||
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
const raw = text.trim()
|
||||
@@ -425,27 +425,27 @@ Singleton {
|
||||
try {
|
||||
const data = JSON.parse(raw)
|
||||
const results = data.results
|
||||
|
||||
|
||||
if (!results || results.length === 0) {
|
||||
throw new Error("No results found")
|
||||
}
|
||||
|
||||
|
||||
const result = results[0]
|
||||
|
||||
|
||||
root.location = {
|
||||
city: result.name,
|
||||
country: result.country,
|
||||
latitude: result.latitude,
|
||||
longitude: result.longitude
|
||||
}
|
||||
|
||||
|
||||
fetchWeather()
|
||||
} catch (e) {
|
||||
root.handleWeatherFailure()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onExited: exitCode => {
|
||||
if (exitCode !== 0) {
|
||||
root.handleWeatherFailure()
|
||||
@@ -467,7 +467,7 @@ Singleton {
|
||||
|
||||
try {
|
||||
const data = JSON.parse(raw)
|
||||
|
||||
|
||||
if (!data.current || !data.daily) {
|
||||
throw new Error("Required weather data fields missing")
|
||||
}
|
||||
@@ -475,12 +475,12 @@ Singleton {
|
||||
const current = data.current
|
||||
const daily = data.daily
|
||||
const currentUnits = data.current_units || {}
|
||||
|
||||
|
||||
const tempC = current.temperature_2m || 0
|
||||
const tempF = SettingsData.useFahrenheit ? tempC : (tempC * 9/5 + 32)
|
||||
const feelsLikeC = current.apparent_temperature || tempC
|
||||
const feelsLikeF = SettingsData.useFahrenheit ? feelsLikeC : (feelsLikeC * 9/5 + 32)
|
||||
|
||||
|
||||
const forecast = []
|
||||
if (daily.time && daily.time.length > 0) {
|
||||
for (let i = 0; i < Math.min(daily.time.length, 7); i++) {
|
||||
@@ -488,7 +488,7 @@ Singleton {
|
||||
const tempMaxC = daily.temperature_2m_max?.[i] || 0
|
||||
const tempMinF = SettingsData.useFahrenheit ? tempMinC : (tempMinC * 9/5 + 32)
|
||||
const tempMaxF = SettingsData.useFahrenheit ? tempMaxC : (tempMaxC * 9/5 + 32)
|
||||
|
||||
|
||||
forecast.push({
|
||||
"day": formatForecastDay(daily.time[i], i),
|
||||
"wCode": daily.weather_code?.[i] || 0,
|
||||
@@ -502,7 +502,7 @@ Singleton {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
root.weather = {
|
||||
"available": true,
|
||||
"loading": false,
|
||||
@@ -577,7 +577,7 @@ Singleton {
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
|
||||
|
||||
SettingsData.weatherCoordinatesChanged.connect(() => {
|
||||
root.location = null
|
||||
root.weather = {
|
||||
@@ -635,7 +635,7 @@ Singleton {
|
||||
root.lastFetchTime = 0
|
||||
root.forceRefresh()
|
||||
})
|
||||
|
||||
|
||||
SettingsData.useFahrenheitChanged.connect(() => {
|
||||
root.lastFetchTime = 0
|
||||
root.forceRefresh()
|
||||
|
||||
Reference in New Issue
Block a user