add wallpaper picker
This commit is contained in:
parent
8e4c0fed9c
commit
3c744a0156
5 changed files with 148 additions and 10 deletions
|
|
@ -5,6 +5,7 @@ import Quickshell.Wayland
|
||||||
|
|
||||||
import qs
|
import qs
|
||||||
import qs.settings
|
import qs.settings
|
||||||
|
import qs.modules.wallpaper
|
||||||
|
|
||||||
Variants {
|
Variants {
|
||||||
model: Quickshell.screens
|
model: Quickshell.screens
|
||||||
|
|
@ -45,13 +46,17 @@ Variants {
|
||||||
moduleHeight: root.moduleHeight
|
moduleHeight: root.moduleHeight
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Item {
|
||||||
RowLayout {
|
id: middleItem
|
||||||
id: centerLayout
|
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
spacing: 5
|
implicitWidth: centerLayout.width
|
||||||
Clock {
|
implicitHeight: centerLayout.height
|
||||||
moduleHeight: root.moduleHeight
|
RowLayout {
|
||||||
|
id: centerLayout
|
||||||
|
spacing: 5
|
||||||
|
Clock {
|
||||||
|
moduleHeight: root.moduleHeight
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,6 +78,10 @@ Variants {
|
||||||
Tray {
|
Tray {
|
||||||
moduleHeight: root.moduleHeight
|
moduleHeight: root.moduleHeight
|
||||||
}
|
}
|
||||||
|
WallpaperPicker {
|
||||||
|
moduleHeight: root.moduleHeight
|
||||||
|
screenHeight: root.modelData.height
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import qs.settings
|
||||||
*/
|
*/
|
||||||
Variants {
|
Variants {
|
||||||
model: Quickshell.screens
|
model: Quickshell.screens
|
||||||
delegate: PanelWindow {
|
delegate: WlrLayershell {
|
||||||
id: root
|
id: root
|
||||||
required property ShellScreen modelData
|
required property ShellScreen modelData
|
||||||
screen: modelData
|
screen: modelData
|
||||||
|
|
@ -24,9 +24,11 @@ Variants {
|
||||||
left: true
|
left: true
|
||||||
right: true
|
right: true
|
||||||
}
|
}
|
||||||
margins.top: Config.floating ? 0 : Config.barHeight
|
margins {
|
||||||
|
top: Config.floating ? 0 : Config.barHeight
|
||||||
|
}
|
||||||
mask: Region {
|
mask: Region {
|
||||||
item: root
|
item: Item {}
|
||||||
}
|
}
|
||||||
color: 'transparent'
|
color: 'transparent'
|
||||||
exclusionMode: ExclusionMode.Ignore
|
exclusionMode: ExclusionMode.Ignore
|
||||||
|
|
|
||||||
124
modules/wallpaper/WallpaperPicker.qml
Normal file
124
modules/wallpaper/WallpaperPicker.qml
Normal file
|
|
@ -0,0 +1,124 @@
|
||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Wayland
|
||||||
|
import Quickshell.Widgets
|
||||||
|
import Quickshell.Hyprland
|
||||||
|
import QtQuick
|
||||||
|
import Qt.labs.folderlistmodel 2.11
|
||||||
|
|
||||||
|
import qs
|
||||||
|
import qs.settings
|
||||||
|
import qs.widgets
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: main
|
||||||
|
required property real moduleHeight
|
||||||
|
required property int screenHeight
|
||||||
|
color: Colors.base01
|
||||||
|
radius: Config.rounding
|
||||||
|
implicitWidth: moduleHeight
|
||||||
|
implicitHeight: moduleHeight
|
||||||
|
MaterialIcon {
|
||||||
|
anchors.centerIn: main
|
||||||
|
text: "\ue1bc"
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
id: clickHandler
|
||||||
|
anchors.fill: main
|
||||||
|
acceptedButtons: Qt.LeftButton
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: {
|
||||||
|
wallPicker.visible = !wallPicker.visible;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WlrLayershell {
|
||||||
|
id: wallPicker
|
||||||
|
visible: false
|
||||||
|
exclusionMode: ExclusionMode.Ignore
|
||||||
|
keyboardFocus: WlrKeyboardFocus.OnDemand
|
||||||
|
implicitHeight: 300
|
||||||
|
color: 'transparent'
|
||||||
|
anchors {
|
||||||
|
bottom: true
|
||||||
|
left: true
|
||||||
|
right: true
|
||||||
|
}
|
||||||
|
margins {
|
||||||
|
bottom: 20
|
||||||
|
left: 20
|
||||||
|
right: 20
|
||||||
|
}
|
||||||
|
HyprlandFocusGrab {
|
||||||
|
id: grabber
|
||||||
|
active: wallPicker.visible
|
||||||
|
windows: [wallPicker]
|
||||||
|
onCleared: wallPicker.visible = false
|
||||||
|
}
|
||||||
|
onVisibleChanged: {
|
||||||
|
if (wallPicker.visible)
|
||||||
|
container.forceActiveFocus();
|
||||||
|
}
|
||||||
|
ClippingRectangle {
|
||||||
|
id: container
|
||||||
|
focus: true
|
||||||
|
Keys.onEscapePressed: {
|
||||||
|
wallPicker.visible = false;
|
||||||
|
}
|
||||||
|
anchors.fill: parent
|
||||||
|
color: Colors.base02
|
||||||
|
radius: Config.rounding
|
||||||
|
border.width: 2
|
||||||
|
border.color: Colors.base0D
|
||||||
|
clip: true
|
||||||
|
GridView {
|
||||||
|
id: wallpaperLayout
|
||||||
|
clip: true
|
||||||
|
snapMode: GridView.SnapOneRow
|
||||||
|
flow: GridView.FlowTopToBottom
|
||||||
|
width: parent.width - 10
|
||||||
|
height: parent.height - 10
|
||||||
|
anchors.centerIn: parent
|
||||||
|
model: wallpaperList
|
||||||
|
cellWidth: ((wallPicker.width - wallPicker.margins.left * 2) / 5) + 5
|
||||||
|
cellHeight: (wallPicker.height - wallPicker.margins.bottom / 2)
|
||||||
|
delegate: ClippingWrapperRectangle {
|
||||||
|
id: wallTile
|
||||||
|
margin: 10
|
||||||
|
required property var modelData
|
||||||
|
color: 'transparent'
|
||||||
|
radius: Config.rounding - 4
|
||||||
|
implicitWidth: (wallPicker.width - wallPicker.margins.left * 2) / 5
|
||||||
|
implicitHeight: wallPicker.height - wallPicker.margins.bottom / 2
|
||||||
|
child: ClippingRectangle {
|
||||||
|
id: wpRounder
|
||||||
|
color: 'transparent'
|
||||||
|
radius: Config.rounding
|
||||||
|
Image {
|
||||||
|
id: wallpaper
|
||||||
|
anchors.fill: parent
|
||||||
|
source: wallTile.modelData.filePath
|
||||||
|
sourceSize.width: 16 * 30
|
||||||
|
sourceSize.height: 9 * 30
|
||||||
|
asynchronous: true
|
||||||
|
cache: true
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
id: wpClickHandler
|
||||||
|
anchors.fill: parent
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
acceptedButtons: Qt.LeftButton
|
||||||
|
onClicked: {
|
||||||
|
Config.wallpaper = wallTile.modelData.filePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FolderListModel {
|
||||||
|
id: wallpaperList
|
||||||
|
folder: Config.wallDir
|
||||||
|
nameFilters: ["*.png"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,7 +5,7 @@ import Quickshell
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
id: root
|
||||||
property string font: "Adwaita Mono Nerd Font Propo"
|
property string font: "Maple Mono"
|
||||||
property int fontSize: 12
|
property int fontSize: 12
|
||||||
property int iconSize: 14
|
property int iconSize: 14
|
||||||
property int barHeight: 30
|
property int barHeight: 30
|
||||||
|
|
@ -14,6 +14,7 @@ Singleton {
|
||||||
property bool floating: false
|
property bool floating: false
|
||||||
property double opacity: 1.0
|
property double opacity: 1.0
|
||||||
property string primaryMon: "eDP-1"
|
property string primaryMon: "eDP-1"
|
||||||
|
property string wallDir: "file://" + Quickshell.env("HOME") + "/.walls"
|
||||||
Settings {
|
Settings {
|
||||||
|
|
||||||
location: Qt.resolvedUrl("file:///home/lucy/.config/quickshell/settings/settings.ini")
|
location: Qt.resolvedUrl("file:///home/lucy/.config/quickshell/settings/settings.ini")
|
||||||
|
|
@ -25,5 +26,6 @@ Singleton {
|
||||||
property alias opacity: root.opacity
|
property alias opacity: root.opacity
|
||||||
property alias primaryMon: root.primaryMon
|
property alias primaryMon: root.primaryMon
|
||||||
property alias floating: root.floating
|
property alias floating: root.floating
|
||||||
|
property alias wallDir: root.wallDir
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,4 +12,5 @@ ShellRoot {
|
||||||
Ipc {}
|
Ipc {}
|
||||||
Wallpaper {}
|
Wallpaper {}
|
||||||
NotiPopup {}
|
NotiPopup {}
|
||||||
|
WallpaperPicker {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue