mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-29 22:42:11 -04:00
ui: cleanup some anti patterns
This commit is contained in:
@@ -28,10 +28,6 @@ Column {
|
|||||||
signal collapseRequested
|
signal collapseRequested
|
||||||
signal configRequested(int index, var widgetData, var anchor)
|
signal configRequested(int index, var widgetData, var anchor)
|
||||||
|
|
||||||
function requestCollapse() {
|
|
||||||
collapseRequested();
|
|
||||||
}
|
|
||||||
|
|
||||||
spacing: editMode ? Theme.spacingL : Theme.spacingS
|
spacing: editMode ? Theme.spacingL : Theme.spacingS
|
||||||
|
|
||||||
property real maxPopoutHeight: 9999
|
property real maxPopoutHeight: 9999
|
||||||
@@ -103,39 +99,56 @@ Column {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getCompoundPillIconBlinking(id) {
|
function getCompoundPillIconBlinking(id) {
|
||||||
if (id === "wifi") return NetworkService.isWifiConnecting;
|
if (id === "wifi")
|
||||||
if (id === "bluetooth") return BluetoothService.connecting;
|
return NetworkService.isWifiConnecting;
|
||||||
|
if (id === "bluetooth")
|
||||||
|
return BluetoothService.connecting;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCompoundPillIconName(id, widgetDef) {
|
function getCompoundPillIconName(id, widgetDef) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case "wifi": {
|
case "wifi":
|
||||||
if (NetworkService.wifiToggling) return "sync";
|
{
|
||||||
if (NetworkService.isConnecting && !NetworkService.ethernetConnected) return NetworkService.wifiSignalIcon;
|
if (NetworkService.wifiToggling)
|
||||||
const status = NetworkService.networkStatus;
|
return "sync";
|
||||||
if (status === "ethernet") return "settings_ethernet";
|
if (NetworkService.isConnecting && !NetworkService.ethernetConnected)
|
||||||
if (status === "vpn") return NetworkService.ethernetConnected ? "settings_ethernet" : NetworkService.wifiSignalIcon;
|
return NetworkService.wifiSignalIcon;
|
||||||
if (status === "wifi") return NetworkService.wifiSignalIcon;
|
const status = NetworkService.networkStatus;
|
||||||
return "wifi";
|
if (status === "ethernet")
|
||||||
}
|
return "settings_ethernet";
|
||||||
case "bluetooth": {
|
if (status === "vpn")
|
||||||
return "bluetooth";
|
return NetworkService.ethernetConnected ? "settings_ethernet" : NetworkService.wifiSignalIcon;
|
||||||
}
|
if (status === "wifi")
|
||||||
case "audioOutput": {
|
return NetworkService.wifiSignalIcon;
|
||||||
if (!AudioService.sink?.audio) return "volume_off";
|
return "wifi";
|
||||||
let volume = AudioService.sink.audio.volume;
|
}
|
||||||
let muted = AudioService.sink.audio.muted;
|
case "bluetooth":
|
||||||
if (muted) return "volume_off";
|
{
|
||||||
if (volume === 0.0) return "volume_mute";
|
return "bluetooth";
|
||||||
if (volume <= 0.33) return "volume_down";
|
}
|
||||||
if (volume <= 0.66) return "volume_up";
|
case "audioOutput":
|
||||||
return "volume_up";
|
{
|
||||||
}
|
if (!AudioService.sink?.audio)
|
||||||
case "audioInput": {
|
return "volume_off";
|
||||||
if (!AudioService.source?.audio) return "mic_off";
|
let volume = AudioService.sink.audio.volume;
|
||||||
return AudioService.source.audio.muted ? "mic_off" : "mic";
|
let muted = AudioService.sink.audio.muted;
|
||||||
}
|
if (muted)
|
||||||
|
return "volume_off";
|
||||||
|
if (volume === 0.0)
|
||||||
|
return "volume_mute";
|
||||||
|
if (volume <= 0.33)
|
||||||
|
return "volume_down";
|
||||||
|
if (volume <= 0.66)
|
||||||
|
return "volume_up";
|
||||||
|
return "volume_up";
|
||||||
|
}
|
||||||
|
case "audioInput":
|
||||||
|
{
|
||||||
|
if (!AudioService.source?.audio)
|
||||||
|
return "mic_off";
|
||||||
|
return AudioService.source.audio.muted ? "mic_off" : "mic";
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return widgetDef?.icon || "help";
|
return widgetDef?.icon || "help";
|
||||||
}
|
}
|
||||||
@@ -143,14 +156,19 @@ Column {
|
|||||||
|
|
||||||
function getCompoundPillIsActive(id) {
|
function getCompoundPillIsActive(id) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case "wifi": {
|
case "wifi":
|
||||||
if (NetworkService.wifiToggling) return false;
|
{
|
||||||
const status = NetworkService.networkStatus;
|
if (NetworkService.wifiToggling)
|
||||||
if (status === "ethernet") return true;
|
return false;
|
||||||
if (status === "vpn") return NetworkService.ethernetConnected || NetworkService.wifiConnected;
|
const status = NetworkService.networkStatus;
|
||||||
if (status === "wifi") return true;
|
if (status === "ethernet")
|
||||||
return NetworkService.wifiEnabled;
|
return true;
|
||||||
}
|
if (status === "vpn")
|
||||||
|
return NetworkService.ethernetConnected || NetworkService.wifiConnected;
|
||||||
|
if (status === "wifi")
|
||||||
|
return true;
|
||||||
|
return NetworkService.wifiEnabled;
|
||||||
|
}
|
||||||
case "bluetooth":
|
case "bluetooth":
|
||||||
return !!(BluetoothService.available && BluetoothService.adapter && BluetoothService.adapter.enabled);
|
return !!(BluetoothService.available && BluetoothService.adapter && BluetoothService.adapter.enabled);
|
||||||
case "audioOutput":
|
case "audioOutput":
|
||||||
@@ -164,52 +182,62 @@ Column {
|
|||||||
|
|
||||||
function handleCompoundPillToggled(id) {
|
function handleCompoundPillToggled(id) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case "wifi": {
|
case "wifi":
|
||||||
if (NetworkService.networkStatus !== "ethernet" && !NetworkService.wifiToggling) {
|
{
|
||||||
NetworkService.toggleWifiRadio();
|
if (NetworkService.networkStatus !== "ethernet" && !NetworkService.wifiToggling) {
|
||||||
|
NetworkService.toggleWifiRadio();
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
case "bluetooth":
|
||||||
}
|
{
|
||||||
case "bluetooth": {
|
if (BluetoothService.available && BluetoothService.adapter) {
|
||||||
if (BluetoothService.available && BluetoothService.adapter) {
|
BluetoothService.adapter.enabled = !BluetoothService.adapter.enabled;
|
||||||
BluetoothService.adapter.enabled = !BluetoothService.adapter.enabled;
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
case "audioOutput":
|
||||||
}
|
{
|
||||||
case "audioOutput": {
|
if (AudioService.sink && AudioService.sink.audio) {
|
||||||
if (AudioService.sink && AudioService.sink.audio) {
|
AudioService.sink.audio.muted = !AudioService.sink.audio.muted;
|
||||||
AudioService.sink.audio.muted = !AudioService.sink.audio.muted;
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
case "audioInput":
|
||||||
}
|
{
|
||||||
case "audioInput": {
|
if (AudioService.source && AudioService.source.audio) {
|
||||||
if (AudioService.source && AudioService.source.audio) {
|
AudioService.source.audio.muted = !AudioService.source.audio.muted;
|
||||||
AudioService.source.audio.muted = !AudioService.source.audio.muted;
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleCompoundPillWheelEvent(id, wheelEvent) {
|
function handleCompoundPillWheelEvent(id, wheelEvent) {
|
||||||
if (id === "audioOutput") {
|
if (id === "audioOutput") {
|
||||||
if (!AudioService.sink || !AudioService.sink.audio) return;
|
if (!AudioService.sink || !AudioService.sink.audio)
|
||||||
|
return;
|
||||||
let delta = wheelEvent.angleDelta.y;
|
let delta = wheelEvent.angleDelta.y;
|
||||||
let maxVol = AudioService.sinkMaxVolume;
|
let maxVol = AudioService.sinkMaxVolume;
|
||||||
let currentVolume = AudioService.sink.audio.volume * 100;
|
let currentVolume = AudioService.sink.audio.volume * 100;
|
||||||
let newVolume;
|
let newVolume;
|
||||||
if (delta > 0) newVolume = Math.min(maxVol, currentVolume + 5);
|
if (delta > 0)
|
||||||
else newVolume = Math.max(0, currentVolume - 5);
|
newVolume = Math.min(maxVol, currentVolume + 5);
|
||||||
|
else
|
||||||
|
newVolume = Math.max(0, currentVolume - 5);
|
||||||
AudioService.sink.audio.muted = false;
|
AudioService.sink.audio.muted = false;
|
||||||
AudioService.sink.audio.volume = newVolume / 100;
|
AudioService.sink.audio.volume = newVolume / 100;
|
||||||
wheelEvent.accepted = true;
|
wheelEvent.accepted = true;
|
||||||
} else if (id === "audioInput") {
|
} else if (id === "audioInput") {
|
||||||
if (!AudioService.source || !AudioService.source.audio) return;
|
if (!AudioService.source || !AudioService.source.audio)
|
||||||
|
return;
|
||||||
let delta = wheelEvent.angleDelta.y;
|
let delta = wheelEvent.angleDelta.y;
|
||||||
let currentVolume = AudioService.source.audio.volume * 100;
|
let currentVolume = AudioService.source.audio.volume * 100;
|
||||||
let newVolume;
|
let newVolume;
|
||||||
if (delta > 0) newVolume = Math.min(100, currentVolume + 5);
|
if (delta > 0)
|
||||||
else newVolume = Math.max(0, currentVolume - 5);
|
newVolume = Math.min(100, currentVolume + 5);
|
||||||
|
else
|
||||||
|
newVolume = Math.max(0, currentVolume - 5);
|
||||||
AudioService.source.audio.muted = false;
|
AudioService.source.audio.muted = false;
|
||||||
AudioService.source.audio.volume = newVolume / 100;
|
AudioService.source.audio.volume = newVolume / 100;
|
||||||
wheelEvent.accepted = true;
|
wheelEvent.accepted = true;
|
||||||
@@ -354,7 +382,7 @@ Column {
|
|||||||
expandedWidgetData: active ? root.expandedWidgetData : retainedWidgetData
|
expandedWidgetData: active ? root.expandedWidgetData : retainedWidgetData
|
||||||
bluetoothCodecSelector: root.bluetoothCodecSelector
|
bluetoothCodecSelector: root.bluetoothCodecSelector
|
||||||
widgetModel: root.model
|
widgetModel: root.model
|
||||||
collapseCallback: root.requestCollapse
|
collapseCallback: root.collapseRequested
|
||||||
screenName: root.screenName
|
screenName: root.screenName
|
||||||
screenModel: root.screenModel
|
screenModel: root.screenModel
|
||||||
|
|
||||||
@@ -1208,15 +1236,18 @@ Column {
|
|||||||
isActive: root.getCompoundPillIsActive(widgetData.id || "")
|
isActive: root.getCompoundPillIsActive(widgetData.id || "")
|
||||||
enabled: (widgetDef?.enabled ?? true) && !root.editMode
|
enabled: (widgetDef?.enabled ?? true) && !root.editMode
|
||||||
onToggled: {
|
onToggled: {
|
||||||
if (root.editMode) return;
|
if (root.editMode)
|
||||||
|
return;
|
||||||
root.handleCompoundPillToggled(widgetData.id || "");
|
root.handleCompoundPillToggled(widgetData.id || "");
|
||||||
}
|
}
|
||||||
onExpandClicked: {
|
onExpandClicked: {
|
||||||
if (root.editMode) return;
|
if (root.editMode)
|
||||||
|
return;
|
||||||
root.expandClicked(widgetData, widgetIndex);
|
root.expandClicked(widgetData, widgetIndex);
|
||||||
}
|
}
|
||||||
onWheelEvent: function(wheelEvent) {
|
onWheelEvent: function (wheelEvent) {
|
||||||
if (root.editMode) return;
|
if (root.editMode)
|
||||||
|
return;
|
||||||
root.handleCompoundPillWheelEvent(widgetData.id || "", wheelEvent);
|
root.handleCompoundPillWheelEvent(widgetData.id || "", wheelEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1231,7 +1262,8 @@ Column {
|
|||||||
height: 48
|
height: 48
|
||||||
colorPickerModal: root.colorPickerModal
|
colorPickerModal: root.colorPickerModal
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (root.editMode) return;
|
if (root.editMode)
|
||||||
|
return;
|
||||||
if (root.colorPickerModal)
|
if (root.colorPickerModal)
|
||||||
root.colorPickerModal.show();
|
root.colorPickerModal.show();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1538,15 +1538,11 @@ BasePill {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeWithAction() {
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: pendingActionCloseTimer
|
id: pendingActionCloseTimer
|
||||||
interval: 80
|
interval: 80
|
||||||
repeat: false
|
repeat: false
|
||||||
onTriggered: menuRoot.closeWithAction()
|
onTriggered: menuRoot.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
function showSubMenu(entry) {
|
function showSubMenu(entry) {
|
||||||
@@ -1906,7 +1902,7 @@ BasePill {
|
|||||||
} else {
|
} else {
|
||||||
SessionData.hideTrayId(itemKey);
|
SessionData.hideTrayId(itemKey);
|
||||||
}
|
}
|
||||||
menuRoot.closeWithAction();
|
menuRoot.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,15 +102,7 @@ Item {
|
|||||||
return textEditor.hasUnsavedChanges();
|
return textEditor.hasUnsavedChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasUnsavedTemporaryContent() {
|
|
||||||
return hasUnsavedChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
function createNewTab() {
|
function createNewTab() {
|
||||||
performCreateNewTab();
|
|
||||||
}
|
|
||||||
|
|
||||||
function performCreateNewTab() {
|
|
||||||
textEditor.commitLiveBuffer();
|
textEditor.commitLiveBuffer();
|
||||||
NotepadStorageService.createNewTab();
|
NotepadStorageService.createNewTab();
|
||||||
textEditor.applyingShared = true;
|
textEditor.applyingShared = true;
|
||||||
@@ -221,7 +213,7 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function loadFromFile(fileUrl) {
|
function loadFromFile(fileUrl) {
|
||||||
if (hasUnsavedTemporaryContent()) {
|
if (hasUnsavedChanges()) {
|
||||||
root.pendingFileUrl = fileUrl;
|
root.pendingFileUrl = fileUrl;
|
||||||
root.pendingAction = "load_file";
|
root.pendingAction = "load_file";
|
||||||
root.confirmationDialogOpen = true;
|
root.confirmationDialogOpen = true;
|
||||||
|
|||||||
@@ -19,33 +19,25 @@ Item {
|
|||||||
readonly property Component detailContent: pluginInstance?.ccDetailContent || null
|
readonly property Component detailContent: pluginInstance?.ccDetailContent || null
|
||||||
readonly property real detailHeight: pluginInstance?.ccDetailHeight || 250
|
readonly property real detailHeight: pluginInstance?.ccDetailHeight || 250
|
||||||
|
|
||||||
signal toggled()
|
signal toggled
|
||||||
signal expanded()
|
signal expanded
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (pluginInstance) {
|
if (pluginInstance) {
|
||||||
pluginInstance.ccWidgetToggled.connect(handleToggled)
|
pluginInstance.ccWidgetToggled.connect(toggled);
|
||||||
pluginInstance.ccWidgetExpanded.connect(handleExpanded)
|
pluginInstance.ccWidgetExpanded.connect(expanded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleToggled() {
|
|
||||||
toggled()
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleExpanded() {
|
|
||||||
expanded()
|
|
||||||
}
|
|
||||||
|
|
||||||
function invokeToggle() {
|
function invokeToggle() {
|
||||||
if (pluginInstance) {
|
if (pluginInstance) {
|
||||||
pluginInstance.ccWidgetToggled()
|
pluginInstance.ccWidgetToggled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function invokeExpand() {
|
function invokeExpand() {
|
||||||
if (pluginInstance) {
|
if (pluginInstance) {
|
||||||
pluginInstance.ccWidgetExpanded()
|
pluginInstance.ccWidgetExpanded();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,10 +62,6 @@ Singleton {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showChangelog() {
|
|
||||||
changelogRequested();
|
|
||||||
}
|
|
||||||
|
|
||||||
function dismissChangelog() {
|
function dismissChangelog() {
|
||||||
changelogDismissed = true;
|
changelogDismissed = true;
|
||||||
touchMarkerProcess.running = true;
|
touchMarkerProcess.running = true;
|
||||||
|
|||||||
@@ -64,10 +64,6 @@ Singleton {
|
|||||||
property bool monitorsOff: false
|
property bool monitorsOff: false
|
||||||
property bool isShellLocked: false
|
property bool isShellLocked: false
|
||||||
|
|
||||||
function wake() {
|
|
||||||
requestMonitorOn();
|
|
||||||
}
|
|
||||||
|
|
||||||
function reapplyDpmsIfNeeded() {
|
function reapplyDpmsIfNeeded() {
|
||||||
if (monitorsOff)
|
if (monitorsOff)
|
||||||
CompositorService.powerOffMonitors();
|
CompositorService.powerOffMonitors();
|
||||||
|
|||||||
Reference in New Issue
Block a user