mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
i18n: general term cleanup, add missing terms, interpolate some
This commit is contained in:
@@ -384,7 +384,7 @@ Singleton {
|
||||
|
||||
DMSService.sendRequest("cups.pausePrinter", params, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Failed to pause printer") + " - " + response.error);
|
||||
ToastService.showError(I18n.tr("Failed to pause printer"), response.error);
|
||||
} else {
|
||||
getState();
|
||||
}
|
||||
@@ -400,7 +400,7 @@ Singleton {
|
||||
|
||||
DMSService.sendRequest("cups.resumePrinter", params, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Failed to resume printer") + " - " + response.error);
|
||||
ToastService.showError(I18n.tr("Failed to resume printer"), response.error);
|
||||
} else {
|
||||
getState();
|
||||
}
|
||||
@@ -417,7 +417,7 @@ Singleton {
|
||||
|
||||
DMSService.sendRequest("cups.cancelJob", params, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Failed to cancel selected job") + " - " + response.error);
|
||||
ToastService.showError(I18n.tr("Failed to cancel selected job"), response.error);
|
||||
} else {
|
||||
fetchJobsForPrinter(printerName);
|
||||
}
|
||||
@@ -433,7 +433,7 @@ Singleton {
|
||||
|
||||
DMSService.sendRequest("cups.purgeJobs", params, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Failed to cancel all jobs") + " - " + response.error);
|
||||
ToastService.showError(I18n.tr("Failed to cancel all jobs"), response.error);
|
||||
} else {
|
||||
fetchJobsForPrinter(printerName);
|
||||
}
|
||||
@@ -499,7 +499,7 @@ Singleton {
|
||||
DMSService.sendRequest("cups.createPrinter", params, response => {
|
||||
creatingPrinter = false;
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Failed to create printer") + " - " + response.error);
|
||||
ToastService.showError(I18n.tr("Failed to create printer"), response.error);
|
||||
} else {
|
||||
ToastService.showInfo(I18n.tr("Printer created successfully"));
|
||||
getState();
|
||||
@@ -516,7 +516,7 @@ Singleton {
|
||||
|
||||
DMSService.sendRequest("cups.deletePrinter", params, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Failed to delete printer") + " - " + response.error);
|
||||
ToastService.showError(I18n.tr("Failed to delete printer"), response.error);
|
||||
} else {
|
||||
ToastService.showInfo(I18n.tr("Printer deleted"));
|
||||
if (selectedPrinter === printerName) {
|
||||
@@ -536,7 +536,7 @@ Singleton {
|
||||
|
||||
DMSService.sendRequest("cups.acceptJobs", params, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Failed to enable job acceptance") + " - " + response.error);
|
||||
ToastService.showError(I18n.tr("Failed to enable job acceptance"), response.error);
|
||||
} else {
|
||||
getState();
|
||||
}
|
||||
@@ -552,7 +552,7 @@ Singleton {
|
||||
|
||||
DMSService.sendRequest("cups.rejectJobs", params, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Failed to disable job acceptance") + " - " + response.error);
|
||||
ToastService.showError(I18n.tr("Failed to disable job acceptance"), response.error);
|
||||
} else {
|
||||
getState();
|
||||
}
|
||||
@@ -569,7 +569,7 @@ Singleton {
|
||||
|
||||
DMSService.sendRequest("cups.setPrinterShared", params, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Failed to update sharing") + " - " + response.error);
|
||||
ToastService.showError(I18n.tr("Failed to update sharing"), response.error);
|
||||
} else {
|
||||
getState();
|
||||
}
|
||||
@@ -586,7 +586,7 @@ Singleton {
|
||||
|
||||
DMSService.sendRequest("cups.setPrinterLocation", params, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Failed to update location") + " - " + response.error);
|
||||
ToastService.showError(I18n.tr("Failed to update location"), response.error);
|
||||
} else {
|
||||
getState();
|
||||
}
|
||||
@@ -603,7 +603,7 @@ Singleton {
|
||||
|
||||
DMSService.sendRequest("cups.setPrinterInfo", params, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Failed to update description") + " - " + response.error);
|
||||
ToastService.showError(I18n.tr("Failed to update description"), response.error);
|
||||
} else {
|
||||
getState();
|
||||
}
|
||||
@@ -619,7 +619,7 @@ Singleton {
|
||||
|
||||
DMSService.sendRequest("cups.printTestPage", params, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Failed to print test page") + " - " + response.error);
|
||||
ToastService.showError(I18n.tr("Failed to print test page"), response.error);
|
||||
} else {
|
||||
ToastService.showInfo(I18n.tr("Test page sent to printer"));
|
||||
fetchJobsForPrinter(printerName);
|
||||
@@ -637,7 +637,7 @@ Singleton {
|
||||
|
||||
DMSService.sendRequest("cups.moveJob", params, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Failed to move job") + " - " + response.error);
|
||||
ToastService.showError(I18n.tr("Failed to move job"), response.error);
|
||||
} else {
|
||||
fetchAllJobs();
|
||||
}
|
||||
@@ -653,7 +653,7 @@ Singleton {
|
||||
|
||||
DMSService.sendRequest("cups.restartJob", params, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Failed to restart job") + " - " + response.error);
|
||||
ToastService.showError(I18n.tr("Failed to restart job"), response.error);
|
||||
} else {
|
||||
fetchAllJobs();
|
||||
}
|
||||
@@ -672,7 +672,7 @@ Singleton {
|
||||
|
||||
DMSService.sendRequest("cups.holdJob", params, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Failed to hold job") + " - " + response.error);
|
||||
ToastService.showError(I18n.tr("Failed to hold job"), response.error);
|
||||
} else {
|
||||
fetchAllJobs();
|
||||
}
|
||||
@@ -689,7 +689,7 @@ Singleton {
|
||||
|
||||
DMSService.sendRequest("cups.addPrinterToClass", params, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Failed to add printer to class") + " - " + response.error);
|
||||
ToastService.showError(I18n.tr("Failed to add printer to class"), response.error);
|
||||
} else {
|
||||
getClasses();
|
||||
}
|
||||
@@ -706,7 +706,7 @@ Singleton {
|
||||
|
||||
DMSService.sendRequest("cups.removePrinterFromClass", params, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Failed to remove printer from class") + " - " + response.error);
|
||||
ToastService.showError(I18n.tr("Failed to remove printer from class"), response.error);
|
||||
} else {
|
||||
getClasses();
|
||||
}
|
||||
@@ -722,7 +722,7 @@ Singleton {
|
||||
|
||||
DMSService.sendRequest("cups.deleteClass", params, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Failed to delete class") + " - " + response.error);
|
||||
ToastService.showError(I18n.tr("Failed to delete class"), response.error);
|
||||
} else {
|
||||
getClasses();
|
||||
}
|
||||
|
||||
@@ -353,7 +353,7 @@ Singleton {
|
||||
pendingConnectionSSID = "";
|
||||
} else {
|
||||
if (connectionError) {
|
||||
ToastService.showError(I18n.tr("Failed to connect to ") + pendingConnectionSSID);
|
||||
ToastService.showError(I18n.tr("Failed to connect to %1").arg(pendingConnectionSSID));
|
||||
}
|
||||
connectionStatus = "failed";
|
||||
pendingConnectionSSID = "";
|
||||
@@ -382,7 +382,7 @@ Singleton {
|
||||
connectionError = response.error;
|
||||
lastConnectionError = response.error;
|
||||
connectionStatus = "failed";
|
||||
ToastService.showError(I18n.tr("Failed to activate configuration"));
|
||||
ToastService.showError(I18n.tr("Failed to activate configuration"), response.error);
|
||||
} else {
|
||||
connectionError = "";
|
||||
connectionStatus = "connected";
|
||||
@@ -461,7 +461,7 @@ Singleton {
|
||||
lastConnectionError = response.error;
|
||||
pendingConnectionSSID = "";
|
||||
connectionStatus = "failed";
|
||||
ToastService.showError(I18n.tr("Failed to start connection to ") + ssid);
|
||||
ToastService.showError(I18n.tr("Failed to start connection to %1").arg(ssid));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -474,7 +474,7 @@ Singleton {
|
||||
} : null;
|
||||
DMSService.sendRequest("network.wifi.disconnect", params, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Failed to disconnect WiFi"));
|
||||
ToastService.showError(I18n.tr("Failed to disconnect WiFi"), response.error);
|
||||
} else {
|
||||
ToastService.showInfo(I18n.tr("Disconnected from WiFi"));
|
||||
currentWifiSSID = "";
|
||||
@@ -534,7 +534,7 @@ Singleton {
|
||||
if (response.error) {
|
||||
console.warn("Failed to forget network:", response.error);
|
||||
} else {
|
||||
ToastService.showInfo(I18n.tr("Forgot network ") + ssid);
|
||||
ToastService.showInfo(I18n.tr("Forgot network %1").arg(ssid));
|
||||
|
||||
savedConnections = savedConnections.filter(s => s.ssid !== ssid);
|
||||
savedWifiNetworks = savedWifiNetworks.filter(s => s.ssid !== ssid);
|
||||
@@ -577,7 +577,7 @@ Singleton {
|
||||
return;
|
||||
DMSService.sendRequest("network.wifi.enable", null, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Failed to enable WiFi"));
|
||||
ToastService.showError(I18n.tr("Failed to enable WiFi"), response.error);
|
||||
} else {
|
||||
ToastService.showInfo(I18n.tr("WiFi enabled"));
|
||||
}
|
||||
@@ -826,7 +826,7 @@ Singleton {
|
||||
vpnIsBusy = false;
|
||||
pendingVpnUuid = "";
|
||||
vpnBusyStartTime = 0;
|
||||
ToastService.showError(I18n.tr("Failed to connect VPN"));
|
||||
ToastService.showError(I18n.tr("Failed to connect VPN"), response.error);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -850,7 +850,7 @@ Singleton {
|
||||
if (response.error) {
|
||||
vpnIsBusy = false;
|
||||
vpnBusyStartTime = 0;
|
||||
ToastService.showError(I18n.tr("Failed to disconnect VPN"));
|
||||
ToastService.showError(I18n.tr("Failed to disconnect VPN"), response.error);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -868,7 +868,7 @@ Singleton {
|
||||
DMSService.sendRequest("network.vpn.disconnectAll", null, response => {
|
||||
if (response.error) {
|
||||
vpnIsBusy = false;
|
||||
ToastService.showError(I18n.tr("Failed to disconnect VPNs"));
|
||||
ToastService.showError(I18n.tr("Failed to disconnect VPNs"), response.error);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -933,7 +933,7 @@ Singleton {
|
||||
|
||||
DMSService.sendRequest("network.wifi.setAutoconnect", params, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Failed to update autoconnect"));
|
||||
ToastService.showError(I18n.tr("Failed to update autoconnect"), response.error);
|
||||
} else {
|
||||
ToastService.showInfo(autoconnect ? I18n.tr("Autoconnect enabled") : I18n.tr("Autoconnect disabled"));
|
||||
Qt.callLater(() => getState());
|
||||
|
||||
@@ -319,7 +319,7 @@ Singleton {
|
||||
DMSService.sendRequest("brightness.setBrightness", params, response => {
|
||||
if (response.error) {
|
||||
console.error("DisplayService: Failed to set brightness:", response.error);
|
||||
ToastService.showError("Failed to set brightness: " + response.error, "", "", "brightness");
|
||||
ToastService.showError(I18n.tr("Failed to set brightness"), response.error, "", "brightness");
|
||||
} else {
|
||||
ToastService.dismissCategory("brightness");
|
||||
}
|
||||
@@ -453,7 +453,7 @@ Singleton {
|
||||
}, response => {
|
||||
if (response.error) {
|
||||
console.error("DisplayService: Failed to enable gamma control:", response.error);
|
||||
ToastService.showError("Failed to enable night mode: " + response.error, "", "", "night-mode");
|
||||
ToastService.showError(I18n.tr("Failed to enable night mode"), response.error, "", "night-mode");
|
||||
nightModeEnabled = false;
|
||||
SessionData.setNightModeEnabled(false);
|
||||
return;
|
||||
@@ -481,7 +481,7 @@ Singleton {
|
||||
}, response => {
|
||||
if (response.error) {
|
||||
console.error("DisplayService: Failed to disable gamma control:", response.error);
|
||||
ToastService.showError("Failed to disable night mode: " + response.error, "", "", "night-mode");
|
||||
ToastService.showError(I18n.tr("Failed to disable night mode"), response.error, "", "night-mode");
|
||||
} else {
|
||||
ToastService.dismissCategory("night-mode");
|
||||
}
|
||||
@@ -522,7 +522,7 @@ Singleton {
|
||||
}, response => {
|
||||
if (response.error) {
|
||||
console.error("DisplayService: Failed to set temperature:", response.error);
|
||||
ToastService.showError("Failed to set night mode temperature: " + response.error, "", "", "night-mode");
|
||||
ToastService.showError(I18n.tr("Failed to set night mode temperature"), response.error, "", "night-mode");
|
||||
} else {
|
||||
ToastService.dismissCategory("night-mode");
|
||||
}
|
||||
@@ -573,7 +573,7 @@ Singleton {
|
||||
}, response => {
|
||||
if (response.error) {
|
||||
console.error("DisplayService: Failed to set temperature:", response.error);
|
||||
ToastService.showError("Failed to set night mode temperature: " + response.error, "", "", "night-mode");
|
||||
ToastService.showError(I18n.tr("Failed to set night mode temperature"), response.error, "", "night-mode");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -583,7 +583,7 @@ Singleton {
|
||||
}, response => {
|
||||
if (response.error) {
|
||||
console.error("DisplayService: Failed to set manual times:", response.error);
|
||||
ToastService.showError("Failed to set night mode schedule: " + response.error, "", "", "night-mode");
|
||||
ToastService.showError(I18n.tr("Failed to set night mode schedule"), response.error, "", "night-mode");
|
||||
} else {
|
||||
ToastService.dismissCategory("night-mode");
|
||||
}
|
||||
@@ -611,7 +611,7 @@ Singleton {
|
||||
}, response => {
|
||||
if (response.error) {
|
||||
console.error("DisplayService: Failed to set temperature:", response.error);
|
||||
ToastService.showError("Failed to set night mode temperature: " + response.error, "", "", "night-mode");
|
||||
ToastService.showError(I18n.tr("Failed to set night mode temperature"), response.error, "", "night-mode");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -621,7 +621,7 @@ Singleton {
|
||||
}, response => {
|
||||
if (response.error) {
|
||||
console.error("DisplayService: Failed to enable IP location:", response.error);
|
||||
ToastService.showError("Failed to enable IP location: " + response.error, "", "", "night-mode");
|
||||
ToastService.showError(I18n.tr("Failed to enable IP location"), response.error, "", "night-mode");
|
||||
} else {
|
||||
ToastService.dismissCategory("night-mode");
|
||||
}
|
||||
@@ -641,7 +641,7 @@ Singleton {
|
||||
}, response => {
|
||||
if (response.error) {
|
||||
console.error("DisplayService: Failed to set location:", response.error);
|
||||
ToastService.showError("Failed to set night mode location: " + response.error, "", "", "night-mode");
|
||||
ToastService.showError(I18n.tr("Failed to set night mode location"), response.error, "", "night-mode");
|
||||
} else {
|
||||
ToastService.dismissCategory("night-mode");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
pragma Singleton
|
||||
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
@@ -22,161 +21,157 @@ Singleton {
|
||||
|
||||
readonly property string socketPath: Quickshell.env("DMS_SOCKET")
|
||||
|
||||
function init() {}
|
||||
function init() {
|
||||
}
|
||||
|
||||
function getSystemProfileImage() {
|
||||
if (!freedeskAvailable)
|
||||
return
|
||||
|
||||
const username = Quickshell.env("USER")
|
||||
return;
|
||||
const username = Quickshell.env("USER");
|
||||
if (!username)
|
||||
return
|
||||
|
||||
return;
|
||||
DMSService.sendRequest("freedesktop.accounts.getUserIconFile", {
|
||||
"username": username
|
||||
}, response => {
|
||||
if (response.result && response.result.success) {
|
||||
const iconFile = response.result.value || ""
|
||||
if (iconFile && iconFile !== "" && iconFile !== "/var/lib/AccountsService/icons/") {
|
||||
systemProfileImage = iconFile
|
||||
if (!profileImage || profileImage === "") {
|
||||
profileImage = iconFile
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
"username": username
|
||||
}, response => {
|
||||
if (response.result && response.result.success) {
|
||||
const iconFile = response.result.value || "";
|
||||
if (iconFile && iconFile !== "" && iconFile !== "/var/lib/AccountsService/icons/") {
|
||||
systemProfileImage = iconFile;
|
||||
if (!profileImage || profileImage === "") {
|
||||
profileImage = iconFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getUserProfileImage(username) {
|
||||
if (!username) {
|
||||
profileImage = ""
|
||||
return
|
||||
profileImage = "";
|
||||
return;
|
||||
}
|
||||
if (Quickshell.env("DMS_RUN_GREETER") === "1" || Quickshell.env("DMS_RUN_GREETER") === "true") {
|
||||
profileImage = ""
|
||||
return
|
||||
profileImage = "";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!freedeskAvailable) {
|
||||
profileImage = ""
|
||||
return
|
||||
profileImage = "";
|
||||
return;
|
||||
}
|
||||
|
||||
DMSService.sendRequest("freedesktop.accounts.getUserIconFile", {
|
||||
"username": username
|
||||
}, response => {
|
||||
if (response.result && response.result.success) {
|
||||
const icon = response.result.value || ""
|
||||
if (icon && icon !== "" && icon !== "/var/lib/AccountsService/icons/") {
|
||||
profileImage = icon
|
||||
} else {
|
||||
profileImage = ""
|
||||
}
|
||||
} else {
|
||||
profileImage = ""
|
||||
}
|
||||
})
|
||||
"username": username
|
||||
}, response => {
|
||||
if (response.result && response.result.success) {
|
||||
const icon = response.result.value || "";
|
||||
if (icon && icon !== "" && icon !== "/var/lib/AccountsService/icons/") {
|
||||
profileImage = icon;
|
||||
} else {
|
||||
profileImage = "";
|
||||
}
|
||||
} else {
|
||||
profileImage = "";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setProfileImage(imagePath) {
|
||||
if (accountsServiceAvailable) {
|
||||
pendingProfileImage = imagePath
|
||||
setSystemProfileImage(imagePath || "")
|
||||
pendingProfileImage = imagePath;
|
||||
setSystemProfileImage(imagePath || "");
|
||||
} else {
|
||||
profileImage = imagePath
|
||||
profileImage = imagePath;
|
||||
}
|
||||
}
|
||||
|
||||
function getSystemColorScheme() {
|
||||
if (typeof SettingsData !== "undefined" && SettingsData.syncModeWithPortal === false) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
if (!freedeskAvailable)
|
||||
return
|
||||
|
||||
return;
|
||||
DMSService.sendRequest("freedesktop.settings.getColorScheme", null, response => {
|
||||
if (response.result) {
|
||||
systemColorScheme = response.result.value || 0
|
||||
}
|
||||
})
|
||||
if (response.result) {
|
||||
systemColorScheme = response.result.value || 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setLightMode(isLightMode) {
|
||||
if (typeof SettingsData !== "undefined" && SettingsData.syncModeWithPortal === false) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
setSystemColorScheme(isLightMode)
|
||||
setSystemColorScheme(isLightMode);
|
||||
}
|
||||
|
||||
function setSystemColorScheme(isLightMode) {
|
||||
if (typeof SettingsData !== "undefined" && SettingsData.syncModeWithPortal === false) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
const targetScheme = isLightMode ? "default" : "prefer-dark"
|
||||
const targetScheme = isLightMode ? "default" : "prefer-dark";
|
||||
|
||||
if (colorSchemeCommand === "gsettings") {
|
||||
Quickshell.execDetached(["gsettings", "set", "org.gnome.desktop.interface", "color-scheme", targetScheme])
|
||||
Quickshell.execDetached(["gsettings", "set", "org.gnome.desktop.interface", "color-scheme", targetScheme]);
|
||||
}
|
||||
if (colorSchemeCommand === "dconf") {
|
||||
Quickshell.execDetached(["dconf", "write", "/org/gnome/desktop/interface/color-scheme", `'${targetScheme}'`])
|
||||
Quickshell.execDetached(["dconf", "write", "/org/gnome/desktop/interface/color-scheme", `'${targetScheme}'`]);
|
||||
}
|
||||
}
|
||||
|
||||
function setSystemIconTheme(themeName) {
|
||||
if (!settingsPortalAvailable || !freedeskAvailable)
|
||||
return
|
||||
|
||||
return;
|
||||
DMSService.sendRequest("freedesktop.settings.setIconTheme", {
|
||||
"iconTheme": themeName
|
||||
}, response => {
|
||||
if (response.error) {
|
||||
console.warn("PortalService: Failed to set icon theme:", response.error)
|
||||
}
|
||||
})
|
||||
"iconTheme": themeName
|
||||
}, response => {
|
||||
if (response.error) {
|
||||
console.warn("PortalService: Failed to set icon theme:", response.error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setSystemProfileImage(imagePath) {
|
||||
if (!accountsServiceAvailable || !freedeskAvailable)
|
||||
return
|
||||
|
||||
return;
|
||||
DMSService.sendRequest("freedesktop.accounts.setIconFile", {
|
||||
"path": imagePath || ""
|
||||
}, response => {
|
||||
if (response.error) {
|
||||
console.warn("PortalService: Failed to set icon file:", response.error)
|
||||
"path": imagePath || ""
|
||||
}, response => {
|
||||
if (response.error) {
|
||||
console.warn("PortalService: Failed to set icon file:", response.error);
|
||||
|
||||
const errorMsg = response.error.toString()
|
||||
let userMessage = I18n.tr("Failed to set profile image")
|
||||
const errorMsg = response.error.toString();
|
||||
let userMessage = I18n.tr("Failed to set profile image");
|
||||
|
||||
if (errorMsg.includes("too large")) {
|
||||
userMessage = I18n.tr("Profile image is too large. Please use a smaller image.")
|
||||
} else if (errorMsg.includes("permission")) {
|
||||
userMessage = I18n.tr("Permission denied to set profile image.")
|
||||
} else if (errorMsg.includes("not found") || errorMsg.includes("does not exist")) {
|
||||
userMessage = I18n.tr("Selected image file not found.")
|
||||
} else {
|
||||
userMessage = I18n.tr("Failed to set profile image: ") + errorMsg.split(":").pop().trim()
|
||||
}
|
||||
if (errorMsg.includes("too large")) {
|
||||
userMessage = I18n.tr("Profile image is too large. Please use a smaller image.");
|
||||
} else if (errorMsg.includes("permission")) {
|
||||
userMessage = I18n.tr("Permission denied to set profile image.");
|
||||
} else if (errorMsg.includes("not found") || errorMsg.includes("does not exist")) {
|
||||
userMessage = I18n.tr("Selected image file not found.");
|
||||
} else {
|
||||
userMessage = I18n.tr("Failed to set profile image: %1").arg(errorMsg.split(":").pop().trim());
|
||||
}
|
||||
|
||||
Quickshell.execDetached(["notify-send", "-u", "normal", "-a", "DMS", "-i", "error", I18n.tr("Profile Image Error"), userMessage])
|
||||
Quickshell.execDetached(["notify-send", "-u", "normal", "-a", "DMS", "-i", "error", I18n.tr("Profile Image Error"), userMessage]);
|
||||
|
||||
pendingProfileImage = ""
|
||||
} else {
|
||||
profileImage = pendingProfileImage
|
||||
pendingProfileImage = ""
|
||||
Qt.callLater(() => getSystemProfileImage())
|
||||
}
|
||||
})
|
||||
pendingProfileImage = "";
|
||||
} else {
|
||||
profileImage = pendingProfileImage;
|
||||
pendingProfileImage = "";
|
||||
Qt.callLater(() => getSystemProfileImage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if (socketPath && socketPath.length > 0) {
|
||||
checkDMSCapabilities()
|
||||
checkDMSCapabilities();
|
||||
} else {
|
||||
console.info("PortalService: DMS_SOCKET not set")
|
||||
console.info("PortalService: DMS_SOCKET not set");
|
||||
}
|
||||
colorSchemeDetector.running = true
|
||||
colorSchemeDetector.running = true;
|
||||
}
|
||||
|
||||
Connections {
|
||||
@@ -184,7 +179,7 @@ Singleton {
|
||||
|
||||
function onConnectionStateChanged() {
|
||||
if (DMSService.isConnected) {
|
||||
checkDMSCapabilities()
|
||||
checkDMSCapabilities();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -194,63 +189,61 @@ Singleton {
|
||||
enabled: DMSService.isConnected
|
||||
|
||||
function onCapabilitiesChanged() {
|
||||
checkDMSCapabilities()
|
||||
checkDMSCapabilities();
|
||||
}
|
||||
}
|
||||
|
||||
function checkDMSCapabilities() {
|
||||
if (!DMSService.isConnected) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
if (DMSService.capabilities.length === 0) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
freedeskAvailable = DMSService.capabilities.includes("freedesktop")
|
||||
freedeskAvailable = DMSService.capabilities.includes("freedesktop");
|
||||
if (freedeskAvailable) {
|
||||
checkAccountsService()
|
||||
checkSettingsPortal()
|
||||
checkAccountsService();
|
||||
checkSettingsPortal();
|
||||
} else {
|
||||
console.info("PortalService: freedesktop capability not available in DMS")
|
||||
console.info("PortalService: freedesktop capability not available in DMS");
|
||||
}
|
||||
}
|
||||
|
||||
function checkAccountsService() {
|
||||
if (!freedeskAvailable)
|
||||
return
|
||||
|
||||
return;
|
||||
DMSService.sendRequest("freedesktop.getState", null, response => {
|
||||
if (response.result && response.result.accounts) {
|
||||
accountsServiceAvailable = response.result.accounts.available || false
|
||||
if (accountsServiceAvailable) {
|
||||
getSystemProfileImage()
|
||||
}
|
||||
}
|
||||
})
|
||||
if (response.result && response.result.accounts) {
|
||||
accountsServiceAvailable = response.result.accounts.available || false;
|
||||
if (accountsServiceAvailable) {
|
||||
getSystemProfileImage();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function checkSettingsPortal() {
|
||||
if (!freedeskAvailable)
|
||||
return
|
||||
|
||||
return;
|
||||
DMSService.sendRequest("freedesktop.getState", null, response => {
|
||||
if (response.result && response.result.settings) {
|
||||
settingsPortalAvailable = response.result.settings.available || false
|
||||
if (settingsPortalAvailable && SettingsData.syncModeWithPortal) {
|
||||
getSystemColorScheme()
|
||||
}
|
||||
}
|
||||
})
|
||||
if (response.result && response.result.settings) {
|
||||
settingsPortalAvailable = response.result.settings.available || false;
|
||||
if (settingsPortalAvailable && SettingsData.syncModeWithPortal) {
|
||||
getSystemColorScheme();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getGreeterUserProfileImage(username) {
|
||||
if (!username) {
|
||||
profileImage = ""
|
||||
return
|
||||
profileImage = "";
|
||||
return;
|
||||
}
|
||||
userProfileCheckProcess.command = ["bash", "-c", `uid=$(id -u ${username} 2>/dev/null) && [ -n "$uid" ] && dbus-send --system --print-reply --dest=org.freedesktop.Accounts /org/freedesktop/Accounts/User$uid org.freedesktop.DBus.Properties.Get string:org.freedesktop.Accounts.User string:IconFile 2>/dev/null | grep -oP 'string "\\K[^"]+' || echo ""`]
|
||||
userProfileCheckProcess.running = true
|
||||
userProfileCheckProcess.command = ["bash", "-c", `uid=$(id -u ${username} 2>/dev/null) && [ -n "$uid" ] && dbus-send --system --print-reply --dest=org.freedesktop.Accounts /org/freedesktop/Accounts/User$uid org.freedesktop.DBus.Properties.Get string:org.freedesktop.Accounts.User string:IconFile 2>/dev/null | grep -oP 'string "\\K[^"]+' || echo ""`];
|
||||
userProfileCheckProcess.running = true;
|
||||
}
|
||||
|
||||
Process {
|
||||
@@ -260,18 +253,18 @@ Singleton {
|
||||
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
const trimmed = text.trim()
|
||||
const trimmed = text.trim();
|
||||
if (trimmed && trimmed !== "" && !trimmed.includes("Error") && trimmed !== "/var/lib/AccountsService/icons/") {
|
||||
root.profileImage = trimmed
|
||||
root.profileImage = trimmed;
|
||||
} else {
|
||||
root.profileImage = ""
|
||||
root.profileImage = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onExited: exitCode => {
|
||||
if (exitCode !== 0) {
|
||||
root.profileImage = ""
|
||||
root.profileImage = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -283,11 +276,11 @@ Singleton {
|
||||
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
const cmd = text.trim()
|
||||
const cmd = text.trim();
|
||||
if (cmd.includes("gsettings")) {
|
||||
root.colorSchemeCommand = "gsettings"
|
||||
root.colorSchemeCommand = "gsettings";
|
||||
} else if (cmd.includes("dconf")) {
|
||||
root.colorSchemeCommand = "dconf"
|
||||
root.colorSchemeCommand = "dconf";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -297,27 +290,27 @@ Singleton {
|
||||
target: "profile"
|
||||
|
||||
function getImage(): string {
|
||||
return root.profileImage
|
||||
return root.profileImage;
|
||||
}
|
||||
|
||||
function setImage(path: string): string {
|
||||
if (!path) {
|
||||
return "ERROR: No path provided"
|
||||
return "ERROR: No path provided";
|
||||
}
|
||||
|
||||
const absolutePath = path.startsWith("/") ? path : `${StandardPaths.writableLocation(StandardPaths.HomeLocation)}/${path}`
|
||||
const absolutePath = path.startsWith("/") ? path : `${StandardPaths.writableLocation(StandardPaths.HomeLocation)}/${path}`;
|
||||
|
||||
try {
|
||||
root.setProfileImage(absolutePath)
|
||||
return "SUCCESS: Profile image set to " + absolutePath
|
||||
root.setProfileImage(absolutePath);
|
||||
return "SUCCESS: Profile image set to " + absolutePath;
|
||||
} catch (e) {
|
||||
return "ERROR: Failed to set profile image: " + e.toString()
|
||||
return "ERROR: Failed to set profile image: " + e.toString();
|
||||
}
|
||||
}
|
||||
|
||||
function clearImage(): string {
|
||||
root.setProfileImage("")
|
||||
return "SUCCESS: Profile image cleared"
|
||||
root.setProfileImage("");
|
||||
return "SUCCESS: Profile image cleared";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,14 +81,14 @@ Singleton {
|
||||
|
||||
if (response.error) {
|
||||
importError = response.error;
|
||||
ToastService.showError(I18n.tr("Failed to import VPN"));
|
||||
ToastService.showError(I18n.tr("Failed to import VPN"), response.error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!response.result)
|
||||
return;
|
||||
if (response.result.success) {
|
||||
ToastService.showInfo(I18n.tr("VPN imported: ") + (response.result.name || ""));
|
||||
ToastService.showInfo(I18n.tr("VPN imported: %1").arg(response.result.name || ""));
|
||||
DMSNetworkService.refreshVpnProfiles();
|
||||
importComplete(response.result.uuid || "", response.result.name || "");
|
||||
return;
|
||||
@@ -111,7 +111,7 @@ Singleton {
|
||||
configLoading = false;
|
||||
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Failed to load VPN config"));
|
||||
ToastService.showError(I18n.tr("Failed to load VPN config"), response.error);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ Singleton {
|
||||
|
||||
DMSService.sendRequest("network.vpn.updateConfig", params, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Failed to update VPN"));
|
||||
ToastService.showError(I18n.tr("Failed to update VPN"), response.error);
|
||||
return;
|
||||
}
|
||||
ToastService.showInfo(I18n.tr("VPN configuration updated"));
|
||||
@@ -153,7 +153,7 @@ Singleton {
|
||||
uuid: uuidOrName
|
||||
}, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Failed to delete VPN"));
|
||||
ToastService.showError(I18n.tr("Failed to delete VPN"), response.error);
|
||||
return;
|
||||
}
|
||||
ToastService.showInfo(I18n.tr("VPN deleted"));
|
||||
|
||||
Reference in New Issue
Block a user