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