Starting off quickshell widgets replacing waybar and utils
This commit is contained in:
@@ -0,0 +1,158 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Widgets
|
||||
|
||||
PanelWindow {
|
||||
id: launcher
|
||||
|
||||
required property bool open
|
||||
required property string repoRoot
|
||||
required property string flavorName
|
||||
|
||||
signal closeRequested()
|
||||
|
||||
visible: open
|
||||
focusable: true
|
||||
aboveWindows: true
|
||||
color: "transparent"
|
||||
|
||||
anchors {
|
||||
top: true
|
||||
right: true
|
||||
bottom: true
|
||||
left: true
|
||||
}
|
||||
|
||||
FileView {
|
||||
id: flavorFile
|
||||
|
||||
path: launcher.repoRoot + "/theme/flavors/" + launcher.flavorName + "/launcher.json"
|
||||
blockLoading: true
|
||||
watchChanges: true
|
||||
|
||||
onFileChanged: reload()
|
||||
}
|
||||
|
||||
readonly property var flavor: JSON.parse(flavorFile.text())
|
||||
|
||||
Process {
|
||||
id: appProcess
|
||||
}
|
||||
|
||||
function fileUrl(path) {
|
||||
if (!path || path.length === 0)
|
||||
return ""
|
||||
|
||||
if (path.startsWith("/"))
|
||||
return "file://" + path
|
||||
|
||||
return "file://" + launcher.repoRoot + "/" + path
|
||||
}
|
||||
|
||||
function launchProgram(program) {
|
||||
launcher.closeRequested()
|
||||
|
||||
appProcess.command = program.command
|
||||
appProcess.startDetached()
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: launcher.flavor.colors.overlay
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: launcher.closeRequested()
|
||||
}
|
||||
|
||||
Item {
|
||||
id: dial
|
||||
|
||||
property real r: launcher.flavor.radius
|
||||
property real appR: launcher.flavor.appRadius
|
||||
property real orbit: launcher.flavor.orbitMultiplier * r
|
||||
|
||||
width: orbit * 2 + appR * 2
|
||||
height: orbit * 2 + appR * 2
|
||||
|
||||
anchors.centerIn: parent
|
||||
|
||||
Rectangle {
|
||||
id: center
|
||||
|
||||
width: dial.r * 2
|
||||
height: dial.r * 2
|
||||
radius: dial.r
|
||||
|
||||
anchors.centerIn: parent
|
||||
|
||||
color: launcher.flavor.colors.centerBackground
|
||||
border.color: launcher.flavor.colors.centerBorder
|
||||
border.width: 2
|
||||
|
||||
clip: true
|
||||
|
||||
Image {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 6
|
||||
|
||||
source: launcher.fileUrl(launcher.flavor.centerIcon)
|
||||
fillMode: Image.PreserveAspectFit
|
||||
smooth: true
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: launcher.flavor.programs
|
||||
|
||||
delegate: Item {
|
||||
id: appButton
|
||||
|
||||
required property int index
|
||||
required property var modelData
|
||||
|
||||
property real angle: (index * 45 - 90) * Math.PI / 180
|
||||
|
||||
width: dial.appR * 2
|
||||
height: dial.appR * 2
|
||||
|
||||
x: dial.width / 2 + Math.cos(angle) * dial.orbit - width / 2
|
||||
y: dial.height / 2 + Math.sin(angle) * dial.orbit - height / 2
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: width / 2
|
||||
|
||||
color: mouse.containsMouse
|
||||
? launcher.flavor.colors.appHoverBackground
|
||||
: launcher.flavor.colors.appBackground
|
||||
|
||||
border.color: launcher.flavor.colors.appBorder
|
||||
border.width: 2
|
||||
|
||||
clip: true
|
||||
|
||||
Image {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 7
|
||||
|
||||
source: launcher.fileUrl(appButton.modelData.icon)
|
||||
fillMode: Image.PreserveAspectFit
|
||||
smooth: true
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouse
|
||||
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
|
||||
onClicked: launcher.launchProgram(appButton.modelData)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Hyprland
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
|
||||
PanelWindow {
|
||||
anchors.top: true
|
||||
anchors.left: false
|
||||
anchors.right: true
|
||||
anchors.bottom: true
|
||||
|
||||
property bool expanded: false
|
||||
property int collapsedWidth: 48
|
||||
property int expandedWidth: 320
|
||||
|
||||
implicitWidth: expanded ? expandedWidth : collapsedWidth
|
||||
|
||||
margins.top: 10
|
||||
margins.bottom: 10
|
||||
margins.right: 4
|
||||
|
||||
color: "transparent"
|
||||
|
||||
Behavior on implicitWidth {
|
||||
NumberAnimation {
|
||||
duration: 220
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: 16
|
||||
color: "#77330077"
|
||||
border.width: 1
|
||||
border.color: "#000000"
|
||||
}
|
||||
|
||||
Item {
|
||||
width: 48
|
||||
height: 48
|
||||
|
||||
Image {
|
||||
anchors.fill: parent
|
||||
source: Quickshell.shellDir + "/../../img/launcher/nixos_black.png"
|
||||
fillMode: Image.PreserveAspectFit
|
||||
smooth: true
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
Quickshell.execDetached(["wofi", "--show", "drun"])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 56
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
rightPadding: 12
|
||||
|
||||
visible: expanded
|
||||
opacity: expanded ? 1.0 : 0.0
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: 160
|
||||
}
|
||||
}
|
||||
|
||||
text: Hyprland.activeToplevel ? Hyprland.activeToplevel.title : ""
|
||||
color: "white"
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
GlobalShortcut {
|
||||
name: "toggle_title_bar"
|
||||
description: "Expand bar and show active window title"
|
||||
onPressed: {
|
||||
expanded = !expanded
|
||||
}
|
||||
}
|
||||
|
||||
GlobalShortcut {
|
||||
name: "show_active_title"
|
||||
description: "Show the active window title"
|
||||
onPressed: {
|
||||
expanded = true
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user