Formatting
This commit is contained in:
parent
566e3e2aa7
commit
ce9ab7f90f
8 changed files with 73 additions and 86 deletions
|
|
@ -47,7 +47,8 @@ Singleton {
|
|||
// -----------
|
||||
function applyOpacity(color, opacity) {
|
||||
// Convert color to string and apply opacity
|
||||
if (!color) return "transparent"
|
||||
if (!color)
|
||||
return "transparent"
|
||||
return color.toString().replace("#", "#" + opacity)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ QtObject {
|
|||
return component
|
||||
}
|
||||
|
||||
const errorMsg = `Failed to load ${widgetName}.qml widget, status: ${component.status}, error: ${component.errorString()}`
|
||||
const errorMsg = `Failed to load ${widgetName}.qml widget, status: ${component.status}, error: ${component.errorString(
|
||||
)}`
|
||||
Logger.error("WidgetLoader", errorMsg)
|
||||
return null
|
||||
}
|
||||
|
|
@ -64,11 +65,7 @@ QtObject {
|
|||
// This is where you should add your Modules/Bar/Widgets/
|
||||
// so it gets registered in the BarTab
|
||||
function discoverAvailableWidgets() {
|
||||
const widgetFiles = [
|
||||
"ActiveWindow", "Battery", "Bluetooth", "Brightness", "Clock",
|
||||
"MediaMini", "NotificationHistory", "ScreenRecorderIndicator",
|
||||
"SidePanelToggle", "SystemMonitor", "Tray", "Volume", "WiFi", "Workspace"
|
||||
]
|
||||
const widgetFiles = ["ActiveWindow", "Battery", "Bluetooth", "Brightness", "Clock", "MediaMini", "NotificationHistory", "ScreenRecorderIndicator", "SidePanelToggle", "SystemMonitor", "Tray", "Volume", "WiFi", "Workspace"]
|
||||
|
||||
const availableWidgets = []
|
||||
|
||||
|
|
@ -77,8 +74,8 @@ QtObject {
|
|||
const component = getWidgetComponent(widgetName)
|
||||
if (component) {
|
||||
availableWidgets.push({
|
||||
key: widgetName,
|
||||
name: widgetName
|
||||
"key": widgetName,
|
||||
"name": widgetName
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ Variants {
|
|||
implicitHeight: Style.barHeight * scaling
|
||||
color: Color.transparent
|
||||
|
||||
|
||||
|
||||
// If no bar activated in settings, then show them all
|
||||
visible: modelData ? (Settings.data.bar.monitors.includes(modelData.name)
|
||||
|| (Settings.data.bar.monitors.length === 0)) : false
|
||||
|
|
@ -137,23 +135,15 @@ Variants {
|
|||
WidgetLoader {
|
||||
id: widgetLoader
|
||||
|
||||
onWidgetFailed: function(widgetName, error) {
|
||||
onWidgetFailed: function (widgetName, error) {
|
||||
Logger.error("Bar", `Widget failed: ${widgetName} - ${error}`)
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize widget loading tracking
|
||||
Component.onCompleted: {
|
||||
const allWidgets = [
|
||||
...Settings.data.bar.widgets.left,
|
||||
...Settings.data.bar.widgets.center,
|
||||
...Settings.data.bar.widgets.right
|
||||
]
|
||||
const allWidgets = [...Settings.data.bar.widgets.left, ...Settings.data.bar.widgets.center, ...Settings.data.bar.widgets.right]
|
||||
widgetLoader.initializeLoading(allWidgets)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import qs.Commons
|
|||
import qs.Services
|
||||
import qs.Widgets
|
||||
|
||||
|
||||
NIconButton {
|
||||
id: root
|
||||
|
||||
|
|
|
|||
|
|
@ -9,14 +9,11 @@ import qs.Commons
|
|||
import qs.Services
|
||||
import qs.Widgets
|
||||
|
||||
|
||||
|
||||
Rectangle {
|
||||
readonly property real itemSize: 24 * scaling
|
||||
|
||||
visible: Settings.data.bar.showTray && (SystemTray.items.values.length > 0)
|
||||
|
||||
|
||||
width: tray.width + Style.marginM * scaling * 2
|
||||
|
||||
height: Math.round(Style.capsuleHeight * scaling)
|
||||
|
|
|
|||
|
|
@ -166,7 +166,8 @@ ColumnLayout {
|
|||
Layout.fillWidth: true
|
||||
Layout.minimumHeight: {
|
||||
var widgetCount = Settings.data.bar.widgets.left.length
|
||||
if (widgetCount === 0) return 140 * scaling
|
||||
if (widgetCount === 0)
|
||||
return 140 * scaling
|
||||
|
||||
var availableWidth = scrollView.availableWidth - (Style.marginM * scaling * 2) // Card margins
|
||||
var avgWidgetWidth = 150 * scaling // Estimated widget width including spacing
|
||||
|
|
@ -192,7 +193,9 @@ ColumnLayout {
|
|||
color: Color.mOnSurface
|
||||
}
|
||||
|
||||
Item { Layout.fillWidth: true }
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
NComboBox {
|
||||
id: leftComboBox
|
||||
|
|
@ -290,7 +293,8 @@ ColumnLayout {
|
|||
Layout.fillWidth: true
|
||||
Layout.minimumHeight: {
|
||||
var widgetCount = Settings.data.bar.widgets.center.length
|
||||
if (widgetCount === 0) return 140 * scaling
|
||||
if (widgetCount === 0)
|
||||
return 140 * scaling
|
||||
|
||||
var availableWidth = scrollView.availableWidth - (Style.marginM * scaling * 2) // Card margins
|
||||
var avgWidgetWidth = 150 * scaling // Estimated widget width including spacing
|
||||
|
|
@ -316,7 +320,9 @@ ColumnLayout {
|
|||
color: Color.mOnSurface
|
||||
}
|
||||
|
||||
Item { Layout.fillWidth: true }
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
NComboBox {
|
||||
id: centerComboBox
|
||||
|
|
@ -415,7 +421,8 @@ ColumnLayout {
|
|||
Layout.fillWidth: true
|
||||
Layout.minimumHeight: {
|
||||
var widgetCount = Settings.data.bar.widgets.right.length
|
||||
if (widgetCount === 0) return 140 * scaling
|
||||
if (widgetCount === 0)
|
||||
return 140 * scaling
|
||||
|
||||
var availableWidth = scrollView.availableWidth - (Style.marginM * scaling * 2) // Card margins
|
||||
var avgWidgetWidth = 150 * scaling // Estimated widget width including spacing
|
||||
|
|
@ -441,7 +448,9 @@ ColumnLayout {
|
|||
color: Color.mOnSurface
|
||||
}
|
||||
|
||||
Item { Layout.fillWidth: true }
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
NComboBox {
|
||||
id: rightComboBox
|
||||
|
|
@ -540,8 +549,6 @@ ColumnLayout {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Helper functions
|
||||
function addWidgetToSection(widgetName, section) {
|
||||
console.log("Adding widget", widgetName, "to section", section)
|
||||
|
|
@ -574,8 +581,8 @@ ColumnLayout {
|
|||
function reorderWidgetInSection(section, fromIndex, toIndex) {
|
||||
console.log("Reordering widget in section", section, "from", fromIndex, "to", toIndex)
|
||||
var sectionArray = Settings.data.bar.widgets[section]
|
||||
if (sectionArray && fromIndex >= 0 && fromIndex < sectionArray.length &&
|
||||
toIndex >= 0 && toIndex < sectionArray.length) {
|
||||
if (sectionArray && fromIndex >= 0 && fromIndex < sectionArray.length && toIndex >= 0
|
||||
&& toIndex < sectionArray.length) {
|
||||
|
||||
// Create a new array to avoid modifying the original
|
||||
var newArray = sectionArray.slice()
|
||||
|
|
@ -613,8 +620,5 @@ ColumnLayout {
|
|||
discoveredWidgets.forEach(widget => {
|
||||
availableWidgets.append(widget)
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,8 +37,6 @@ ColumnLayout {
|
|||
return -1
|
||||
}
|
||||
|
||||
|
||||
|
||||
ComboBox {
|
||||
id: combo
|
||||
Layout.fillWidth: true
|
||||
|
|
@ -64,9 +62,10 @@ ColumnLayout {
|
|||
font.pointSize: Style.fontSizeM * scaling
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
elide: Text.ElideRight
|
||||
color: (combo.currentIndex >= 0 && combo.currentIndex < root.model.count) ? Color.mOnSurface : Color.mOnSurfaceVariant
|
||||
text: (combo.currentIndex >= 0 && combo.currentIndex < root.model.count) ? root.model.get(
|
||||
combo.currentIndex).name : root.placeholder
|
||||
color: (combo.currentIndex >= 0
|
||||
&& combo.currentIndex < root.model.count) ? Color.mOnSurface : Color.mOnSurfaceVariant
|
||||
text: (combo.currentIndex >= 0
|
||||
&& combo.currentIndex < root.model.count) ? root.model.get(combo.currentIndex).name : root.placeholder
|
||||
}
|
||||
|
||||
indicator: NIcon {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue