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