Merge branch 'main' into cxx-listview
This commit is contained in:
commit
009c5519fd
6 changed files with 123 additions and 20 deletions
|
|
@ -326,7 +326,7 @@ Singleton {
|
||||||
const provider = {
|
const provider = {
|
||||||
displayName: p.displayName,
|
displayName: p.displayName,
|
||||||
enabled: p.enabled,
|
enabled: p.enabled,
|
||||||
interface: p.iface,
|
interface: p.interface,
|
||||||
name: p.name
|
name: p.name
|
||||||
};
|
};
|
||||||
if (p.connectCmd && p.connectCmd.length > 0) {
|
if (p.connectCmd && p.connectCmd.length > 0) {
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ ColumnLayout {
|
||||||
|
|
||||||
required property PopoutState popouts
|
required property PopoutState popouts
|
||||||
|
|
||||||
|
width: 300
|
||||||
spacing: Appearance.spacing.small
|
spacing: Appearance.spacing.small
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
|
|
@ -99,6 +100,13 @@ ColumnLayout {
|
||||||
Layout.rightMargin: Appearance.spacing.small / 2
|
Layout.rightMargin: Appearance.spacing.small / 2
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: device.modelData.name
|
text: device.modelData.name
|
||||||
|
elide: Text.ElideRight
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialIcon {
|
||||||
|
visible: device.modelData.state === BluetoothDeviceState.Connected // qmllint disable unresolved-type
|
||||||
|
text: Icons.getBatteryIcon(device.modelData.batteryAvailable ? device.modelData.battery * 100 : -1)
|
||||||
|
color: device.modelData.battery < 0.2 ? Colours.palette.m3error : Colours.palette.m3onSurfaceVariant
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledRect {
|
StyledRect {
|
||||||
|
|
@ -141,6 +149,7 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
|
visible: status === Loader.Ready
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
active: device.modelData.bonded
|
active: device.modelData.bonded
|
||||||
sourceComponent: Item {
|
sourceComponent: Item {
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,13 @@ DeviceDetails {
|
||||||
newProvider.enabled = (i === index) ? false : (p.enabled !== false);
|
newProvider.enabled = (i === index) ? false : (p.enabled !== false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (p.connectCmd && p.connectCmd.length > 0) {
|
||||||
|
newProvider.connectCmd = p.connectCmd;
|
||||||
|
}
|
||||||
|
if (p.disconnectCmd && p.disconnectCmd.length > 0) {
|
||||||
|
newProvider.disconnectCmd = p.disconnectCmd;
|
||||||
|
}
|
||||||
|
|
||||||
providers.push(newProvider);
|
providers.push(newProvider);
|
||||||
} else {
|
} else {
|
||||||
providers.push(p);
|
providers.push(p);
|
||||||
|
|
@ -504,21 +511,31 @@ DeviceDetails {
|
||||||
const newProvider = {
|
const newProvider = {
|
||||||
displayName: editVpnDialog.displayName || editVpnDialog.interfaceName,
|
displayName: editVpnDialog.displayName || editVpnDialog.interfaceName,
|
||||||
enabled: wasEnabled,
|
enabled: wasEnabled,
|
||||||
iface: editVpnDialog.interfaceName,
|
interface: editVpnDialog.interfaceName,
|
||||||
name: editVpnDialog.providerName,
|
name: editVpnDialog.providerName
|
||||||
connectCmd: hasCommands ? editVpnDialog.connectCmd.split(" ").filter(s => s.length > 0) : undefined,
|
|
||||||
disconnectCmd: hasCommands ? editVpnDialog.disconnectCmd.split(" ").filter(s => s.length > 0) : undefined
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Remove undefined properties
|
if (hasCommands) {
|
||||||
if (!hasCommands) {
|
newProvider.connectCmd = editVpnDialog.connectCmd.split(" ").filter(s => s.length > 0);
|
||||||
delete newProvider.connectCmd;
|
newProvider.disconnectCmd = editVpnDialog.disconnectCmd.split(" ").filter(s => s.length > 0);
|
||||||
delete newProvider.disconnectCmd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
providers.push(newProvider);
|
providers.push(newProvider);
|
||||||
} else {
|
} else {
|
||||||
providers.push(Config.utilities.vpn.provider[i]);
|
const p = Config.utilities.vpn.provider[i];
|
||||||
|
const reconstructed = {
|
||||||
|
displayName: p.displayName,
|
||||||
|
enabled: p.enabled,
|
||||||
|
interface: p.interface,
|
||||||
|
name: p.name
|
||||||
|
};
|
||||||
|
if (p.connectCmd && p.connectCmd.length > 0) {
|
||||||
|
reconstructed.connectCmd = p.connectCmd;
|
||||||
|
}
|
||||||
|
if (p.disconnectCmd && p.disconnectCmd.length > 0) {
|
||||||
|
reconstructed.disconnectCmd = p.disconnectCmd;
|
||||||
|
}
|
||||||
|
providers.push(reconstructed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,12 @@ ColumnLayout {
|
||||||
interface: p.interface,
|
interface: p.interface,
|
||||||
enabled: (i === targetIndex)
|
enabled: (i === targetIndex)
|
||||||
};
|
};
|
||||||
|
if (p.connectCmd && p.connectCmd.length > 0) {
|
||||||
|
newProvider.connectCmd = p.connectCmd;
|
||||||
|
}
|
||||||
|
if (p.disconnectCmd && p.disconnectCmd.length > 0) {
|
||||||
|
newProvider.disconnectCmd = p.disconnectCmd;
|
||||||
|
}
|
||||||
providers.push(newProvider);
|
providers.push(newProvider);
|
||||||
} else {
|
} else {
|
||||||
providers.push(p);
|
providers.push(p);
|
||||||
|
|
@ -226,6 +232,12 @@ ColumnLayout {
|
||||||
interface: p.interface,
|
interface: p.interface,
|
||||||
enabled: (i === clickedIndex)
|
enabled: (i === clickedIndex)
|
||||||
};
|
};
|
||||||
|
if (p.connectCmd && p.connectCmd.length > 0) {
|
||||||
|
newProvider.connectCmd = p.connectCmd;
|
||||||
|
}
|
||||||
|
if (p.disconnectCmd && p.disconnectCmd.length > 0) {
|
||||||
|
newProvider.disconnectCmd = p.disconnectCmd;
|
||||||
|
}
|
||||||
providers.push(newProvider);
|
providers.push(newProvider);
|
||||||
} else {
|
} else {
|
||||||
providers.push(p);
|
providers.push(p);
|
||||||
|
|
@ -265,7 +277,20 @@ ColumnLayout {
|
||||||
const providers = [];
|
const providers = [];
|
||||||
for (let i = 0; i < Config.utilities.vpn.provider.length; i++) {
|
for (let i = 0; i < Config.utilities.vpn.provider.length; i++) {
|
||||||
if (i !== modelData.index) {
|
if (i !== modelData.index) {
|
||||||
providers.push(Config.utilities.vpn.provider[i]);
|
const p = Config.utilities.vpn.provider[i];
|
||||||
|
const reconstructed = {
|
||||||
|
name: p.name,
|
||||||
|
displayName: p.displayName,
|
||||||
|
interface: p.interface,
|
||||||
|
enabled: p.enabled
|
||||||
|
};
|
||||||
|
if (p.connectCmd && p.connectCmd.length > 0) {
|
||||||
|
reconstructed.connectCmd = p.connectCmd;
|
||||||
|
}
|
||||||
|
if (p.disconnectCmd && p.disconnectCmd.length > 0) {
|
||||||
|
reconstructed.disconnectCmd = p.disconnectCmd;
|
||||||
|
}
|
||||||
|
providers.push(reconstructed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Config.utilities.vpn.provider = providers;
|
Config.utilities.vpn.provider = providers;
|
||||||
|
|
|
||||||
|
|
@ -119,30 +119,62 @@ ColumnLayout {
|
||||||
icon: modelData.isActive ? "arrow_downward" : "arrow_upward"
|
icon: modelData.isActive ? "arrow_downward" : "arrow_upward"
|
||||||
visible: !modelData.isActive || Config.utilities.vpn.provider.length > 1
|
visible: !modelData.isActive || Config.utilities.vpn.provider.length > 1
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (modelData.isActive && index < Config.utilities.vpn.provider.length - 1) {
|
const providers = [];
|
||||||
|
for (let i = 0; i < Config.utilities.vpn.provider.length; i++) {
|
||||||
|
const p = Config.utilities.vpn.provider[i];
|
||||||
|
const reconstructed = {
|
||||||
|
name: p.name,
|
||||||
|
displayName: p.displayName,
|
||||||
|
interface: p.interface,
|
||||||
|
enabled: p.enabled
|
||||||
|
};
|
||||||
|
if (p.connectCmd && p.connectCmd.length > 0) {
|
||||||
|
reconstructed.connectCmd = p.connectCmd;
|
||||||
|
}
|
||||||
|
if (p.disconnectCmd && p.disconnectCmd.length > 0) {
|
||||||
|
reconstructed.disconnectCmd = p.disconnectCmd;
|
||||||
|
}
|
||||||
|
providers.push(reconstructed);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modelData.isActive && index < providers.length - 1) {
|
||||||
// Move down
|
// Move down
|
||||||
const providers = [...Config.utilities.vpn.provider];
|
|
||||||
const temp = providers[index];
|
const temp = providers[index];
|
||||||
providers[index] = providers[index + 1];
|
providers[index] = providers[index + 1];
|
||||||
providers[index + 1] = temp;
|
providers[index + 1] = temp;
|
||||||
Config.utilities.vpn.provider = providers;
|
|
||||||
Config.save();
|
|
||||||
} else if (!modelData.isActive) {
|
} else if (!modelData.isActive) {
|
||||||
// Make active (move to top)
|
// Make active (move to top)
|
||||||
const providers = [...Config.utilities.vpn.provider];
|
|
||||||
const provider = providers.splice(index, 1)[0];
|
const provider = providers.splice(index, 1)[0];
|
||||||
providers.unshift(provider);
|
providers.unshift(provider);
|
||||||
Config.utilities.vpn.provider = providers;
|
|
||||||
Config.save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Config.utilities.vpn.provider = providers;
|
||||||
|
Config.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IconButton {
|
IconButton {
|
||||||
icon: "delete"
|
icon: "delete"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
const providers = [...Config.utilities.vpn.provider];
|
const providers = [];
|
||||||
providers.splice(index, 1);
|
for (let i = 0; i < Config.utilities.vpn.provider.length; i++) {
|
||||||
|
if (i !== index) {
|
||||||
|
const p = Config.utilities.vpn.provider[i];
|
||||||
|
const reconstructed = {
|
||||||
|
name: p.name,
|
||||||
|
displayName: p.displayName,
|
||||||
|
interface: p.interface,
|
||||||
|
enabled: p.enabled
|
||||||
|
};
|
||||||
|
if (p.connectCmd && p.connectCmd.length > 0) {
|
||||||
|
reconstructed.connectCmd = p.connectCmd;
|
||||||
|
}
|
||||||
|
if (p.disconnectCmd && p.disconnectCmd.length > 0) {
|
||||||
|
reconstructed.disconnectCmd = p.disconnectCmd;
|
||||||
|
}
|
||||||
|
providers.push(reconstructed);
|
||||||
|
}
|
||||||
|
}
|
||||||
Config.utilities.vpn.provider = providers;
|
Config.utilities.vpn.provider = providers;
|
||||||
Config.save();
|
Config.save();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -240,4 +240,24 @@ Singleton {
|
||||||
}
|
}
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getBatteryIcon(charge: int): string {
|
||||||
|
if (charge > 0 && charge < 5)
|
||||||
|
return "battery_0_bar";
|
||||||
|
if (charge >= 5 && charge < 20)
|
||||||
|
return "battery_1_bar";
|
||||||
|
if (charge >= 20 && charge < 35)
|
||||||
|
return "battery_2_bar";
|
||||||
|
if (charge >= 35 && charge < 50)
|
||||||
|
return "battery_3_bar";
|
||||||
|
if (charge >= 50 && charge < 65)
|
||||||
|
return "battery_4_bar";
|
||||||
|
if (charge >= 65 && charge < 80)
|
||||||
|
return "battery_5_bar";
|
||||||
|
if (charge >= 80 && charge < 95)
|
||||||
|
return "battery_6_bar";
|
||||||
|
if (charge >= 95)
|
||||||
|
return "battery_full";
|
||||||
|
return "battery_alert";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue