forked from Shinonome/dots-hyprland
wallpaper selector: remove some useless layout crap
This commit is contained in:
@@ -12,17 +12,20 @@ import Quickshell.Wayland
|
||||
import Quickshell.Hyprland
|
||||
|
||||
Scope {
|
||||
id: scope
|
||||
id: root
|
||||
property int thumbnailWidth: 128
|
||||
property int thumbnailHeight: 72
|
||||
|
||||
Loader {
|
||||
active: GlobalStates.wallpaperSelectorOpen
|
||||
|
||||
sourceComponent: PanelWindow {
|
||||
id: root
|
||||
readonly property HyprlandMonitor monitor: Hyprland.monitorFor(root.screen)
|
||||
id: panelWindow
|
||||
readonly property HyprlandMonitor monitor: Hyprland.monitorFor(panelWindow.screen)
|
||||
property bool monitorIsFocused: (Hyprland.focusedMonitor?.id == monitor?.id)
|
||||
property var filteredWallpapers: Wallpapers.wallpapers
|
||||
|
||||
exclusionMode: ExclusionMode.Ignore
|
||||
WlrLayershell.namespace: "quickshell:wallpaperSelector"
|
||||
WlrLayershell.layer: WlrLayer.Overlay
|
||||
WlrLayershell.keyboardFocus: WlrKeyboardFocus.OnDemand
|
||||
@@ -35,6 +38,10 @@ Scope {
|
||||
right: true
|
||||
}
|
||||
|
||||
margins {
|
||||
top: Appearance.sizes.barHeight + Appearance.sizes.hyprlandGapsOut
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
id: layout
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
@@ -43,9 +50,9 @@ Scope {
|
||||
|
||||
TextField {
|
||||
id: filterField
|
||||
Layout.preferredWidth: bg.implicitWidth
|
||||
Layout.alignment: Qt.AlignHcenter
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
implicitHeight: 40
|
||||
implicitWidth: Appearance.sizes.searchWidth
|
||||
padding: 10
|
||||
placeholderText: "Search wallpapers..."
|
||||
placeholderTextColor: Appearance.colors.colSubtext
|
||||
@@ -68,9 +75,9 @@ Scope {
|
||||
newModel.push(wallpaperPath);
|
||||
}
|
||||
}
|
||||
root.filteredWallpapers = newModel;
|
||||
panelWindow.filteredWallpapers = newModel;
|
||||
} else {
|
||||
root.filteredWallpapers = Wallpapers.wallpapers;
|
||||
panelWindow.filteredWallpapers = Wallpapers.wallpapers;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,24 +121,25 @@ Scope {
|
||||
border.width: 1
|
||||
border.color: Appearance.colors.colLayer0Border
|
||||
radius: Appearance.rounding.screenRounding
|
||||
// Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
property int calculatedRows: Math.ceil(grid.count / grid.columns)
|
||||
|
||||
implicitWidth: {
|
||||
if (root.filteredWallpapers.length === 0) {
|
||||
if (panelWindow.filteredWallpapers.length === 0) {
|
||||
return 300;
|
||||
} else if (root.filteredWallpapers.length < grid.columns) {
|
||||
return root.filteredWallpapers.length * grid.cellWidth + 16;
|
||||
} else if (panelWindow.filteredWallpapers.length < grid.columns) {
|
||||
return panelWindow.filteredWallpapers.length * grid.cellWidth + 16;
|
||||
} else {
|
||||
return Math.min(root.width * 0.7, 900);
|
||||
return Math.min(panelWindow.width * 0.7, 900);
|
||||
}
|
||||
}
|
||||
|
||||
implicitHeight: {
|
||||
if (root.filteredWallpapers.length === 0) {
|
||||
if (panelWindow.filteredWallpapers.length === 0) {
|
||||
return 100;
|
||||
} else {
|
||||
return Math.min(root.height * 0.6, Math.min(calculatedRows, 3) * grid.cellHeight + 16);
|
||||
return Math.min(panelWindow.height * 0.6, Math.min(calculatedRows, 3) * grid.cellHeight + 16);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,24 +190,17 @@ Scope {
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 8
|
||||
spacing: 8
|
||||
|
||||
GridView {
|
||||
id: grid
|
||||
visible: root.filteredWallpapers.length > 0
|
||||
visible: panelWindow.filteredWallpapers.length > 0
|
||||
|
||||
readonly property int columns: 4
|
||||
readonly property int columns: 7
|
||||
property int currentIndex: 0
|
||||
readonly property int rows: Math.max(1, Math.ceil(count / columns))
|
||||
|
||||
Layout.preferredWidth: columns * cellWidth
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
Layout.fillHeight: true
|
||||
cellWidth: 128
|
||||
cellHeight: 72
|
||||
anchors.fill: parent
|
||||
cellWidth: root.thumbnailWidth
|
||||
cellHeight: root.thumbnailHeight
|
||||
clip: true
|
||||
interactive: true
|
||||
keyNavigationWraps: true
|
||||
@@ -208,14 +209,12 @@ Scope {
|
||||
cacheBuffer: cellHeight * 2
|
||||
ScrollBar.horizontal: ScrollBar {
|
||||
policy: ScrollBar.AsNeeded
|
||||
visible: false
|
||||
}
|
||||
ScrollBar.vertical: ScrollBar {
|
||||
policy: ScrollBar.AsNeeded
|
||||
visible: false
|
||||
}
|
||||
|
||||
model: root.filteredWallpapers
|
||||
model: panelWindow.filteredWallpapers
|
||||
onModelChanged: currentIndex = 0
|
||||
|
||||
function moveSelection(delta) {
|
||||
@@ -361,24 +360,15 @@ Scope {
|
||||
}
|
||||
}
|
||||
}
|
||||
// show when no wallpaper found
|
||||
ColumnLayout {
|
||||
id: noWallpapersFoundLayout
|
||||
visible: root.filteredWallpapers.length === 0
|
||||
anchors.centerIn: parent
|
||||
|
||||
implicitHeight: noWallpapersFoundLabel.implicitHeight
|
||||
implicitWidth: noWallpapersFoundLabel.implicitWidth
|
||||
|
||||
Label {
|
||||
id: noWallpapersFoundLabel
|
||||
visible: panelWindow.filteredWallpapers.length === 0
|
||||
anchors.centerIn: parent
|
||||
text: "No wallpapers found"
|
||||
font.family: Appearance.font.family.main
|
||||
font.pixelSize: Appearance.font.pixelSize.normal
|
||||
color: Appearance.colors.colSubtext
|
||||
Layout.alignment: Qt.AlignHcenter | Qt.AlignVCenter
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user