mirror of
https://github.com/hyprwm/hyprsysteminfo.git
synced 2024-11-21 21:45:59 +01:00
qml: fix scaling and clean up layout (#7)
Fixes behavior with varying font sizes + general cleanup.
This commit is contained in:
parent
52a32d3afe
commit
9b50bb2c29
1 changed files with 80 additions and 164 deletions
244
qml/main.qml
244
qml/main.qml
|
@ -1,255 +1,178 @@
|
||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
|
||||||
ApplicationWindow {
|
ApplicationWindow {
|
||||||
property var _width: 720
|
id: window
|
||||||
property var _height: 440
|
|
||||||
property var _first_panel_height: 120
|
|
||||||
|
|
||||||
minimumWidth: _width
|
FontMetrics { id: fontMetrics }
|
||||||
maximumWidth: _width
|
|
||||||
width: _width
|
property var firstPanelHeight: fontMetrics.height * 7
|
||||||
minimumHeight: _height
|
|
||||||
maximumHeight: _height
|
minimumWidth: Math.max(fontMetrics.height * 50, mainLayout.Layout.minimumWidth) + mainLayout.anchors.margins * 2
|
||||||
height: _height
|
minimumHeight: Math.max(fontMetrics.height * 30, mainLayout.Layout.minimumHeight) + mainLayout.anchors.margins * 2
|
||||||
|
maximumWidth: minimumWidth
|
||||||
|
maximumHeight: minimumHeight
|
||||||
visible: true
|
visible: true
|
||||||
|
|
||||||
SystemPalette {
|
component Separator: Rectangle {
|
||||||
id: system
|
color: Qt.darker(window.palette.text, 1.5)
|
||||||
|
}
|
||||||
|
|
||||||
colorGroup: SystemPalette.Active
|
component VSeparator: Separator {
|
||||||
|
implicitWidth: 1
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.topMargin: fontMetrics.height
|
||||||
|
Layout.bottomMargin: fontMetrics.height
|
||||||
|
}
|
||||||
|
|
||||||
|
component HSeparator: Separator {
|
||||||
|
implicitHeight: 1
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.leftMargin: fontMetrics.height * 8
|
||||||
|
Layout.rightMargin: fontMetrics.height * 8
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: mainLayout
|
id: mainLayout
|
||||||
|
spacing: fontMetrics.height
|
||||||
anchors.margins: 4
|
|
||||||
|
|
||||||
anchors {
|
anchors {
|
||||||
top: parent.top
|
fill: parent
|
||||||
left: parent.left
|
margins: 4
|
||||||
right: parent.right
|
|
||||||
bottom: parent.bottom
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
// First panel hyprland and distro info
|
// First panel hyprland and distro info
|
||||||
Layout.fillWidth: true
|
Layout.preferredHeight: firstPanelHeight
|
||||||
Layout.preferredHeight: _first_panel_height
|
Layout.maximumHeight: firstPanelHeight
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.topMargin: fontMetrics.height
|
||||||
|
spacing: fontMetrics.height
|
||||||
|
|
||||||
|
Item { Layout.fillWidth: true }
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
id: distroLogoName
|
id: distroLogoName
|
||||||
|
spacing: fontMetrics.height
|
||||||
Layout.preferredWidth: _width / 2 - 40
|
|
||||||
spacing: 10
|
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
visible: hsi.hasSystemLogoName()
|
visible: hsi.hasSystemLogoName()
|
||||||
source: "image://systemIcons/" + hsi.getSystemLogoName()
|
source: "image://systemIcons/" + hsi.getSystemLogoName()
|
||||||
sourceSize.width: _first_panel_height - 10
|
sourceSize.width: firstPanelHeight
|
||||||
sourceSize.height: _first_panel_height - 10
|
sourceSize.height: firstPanelHeight
|
||||||
Layout.preferredWidth: _first_panel_height - 10
|
Layout.preferredWidth: firstPanelHeight
|
||||||
Layout.preferredHeight: _first_panel_height - 10
|
Layout.preferredHeight: firstPanelHeight
|
||||||
Layout.alignment: Qt.AlignCenter
|
Layout.alignment: Qt.AlignCenter
|
||||||
smooth: true
|
smooth: true
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
spacing: 2
|
id: distroText
|
||||||
|
|
||||||
Text {
|
Layout.preferredWidth: hyprlandInfo.visible ? Math.max(Layout.minimumWidth, hyprlandText.Layout.minimumWidth) : Layout.minimumWidth
|
||||||
|
spacing: 2
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
|
||||||
|
Label {
|
||||||
text: hsi.getSystemName()
|
text: hsi.getSystemName()
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
color: system.windowText
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Label {
|
||||||
text: hsi.getSystemURL()
|
text: hsi.getSystemURL()
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
color: system.windowText
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Label {
|
||||||
text: hsi.getSystemKernel()
|
text: hsi.getSystemKernel()
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
color: system.windowText
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Item { visible: hyprlandInfo.visible; Layout.fillWidth: true }
|
||||||
visible: hsi.hasHyprland()
|
VSeparator { visible: hyprlandInfo.visible }
|
||||||
color: Qt.darker(system.text, 1.5)
|
Item { visible: hyprlandInfo.visible; Layout.fillWidth: true }
|
||||||
Layout.preferredWidth: 1
|
|
||||||
Layout.preferredHeight: _first_panel_height - 40
|
|
||||||
Layout.leftMargin: 20
|
|
||||||
Layout.rightMargin: 20
|
|
||||||
Layout.alignment: Qt.AlignVCenter
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
id: hyprlandInfo
|
id: hyprlandInfo
|
||||||
|
|
||||||
visible: hsi.hasHyprland()
|
visible: hsi.hasHyprland()
|
||||||
Layout.preferredWidth: _width / 2 - 40
|
spacing: fontMetrics.height
|
||||||
spacing: 10
|
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
source: "qrc:/resource/hyprlandlogo.svg"
|
source: "qrc:/resource/hyprlandlogo.svg"
|
||||||
sourceSize.width: _first_panel_height - 10
|
sourceSize.width: firstPanelHeight
|
||||||
sourceSize.height: _first_panel_height - 10
|
sourceSize.height: firstPanelHeight
|
||||||
Layout.preferredWidth: _first_panel_height - 10
|
Layout.preferredWidth: firstPanelHeight
|
||||||
Layout.preferredHeight: _first_panel_height - 10
|
Layout.preferredHeight: firstPanelHeight
|
||||||
Layout.alignment: Qt.AlignCenter
|
Layout.alignment: Qt.AlignCenter
|
||||||
smooth: true
|
smooth: true
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
|
id: hyprlandText
|
||||||
|
Layout.preferredWidth: Math.max(Layout.minimumWidth, distroText.Layout.minimumWidth)
|
||||||
spacing: 2
|
spacing: 2
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
|
||||||
Text {
|
Label {
|
||||||
text: "Hyprland"
|
text: "Hyprland"
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
color: system.windowText
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Label {
|
||||||
text: hsi.getHyprlandVersion()
|
text: hsi.getHyprlandVersion()
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
color: system.windowText
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Label {
|
||||||
visible: hsi.getHyprlandVersion() != hsi.getHyprlandVersionLong()
|
visible: hsi.getHyprlandVersion() != hsi.getHyprlandVersionLong()
|
||||||
text: hsi.getHyprlandVersionLong()
|
text: hsi.getHyprlandVersionLong()
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
color: system.windowText
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Item { Layout.fillWidth: true }
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
HSeparator {}
|
||||||
color: Qt.darker(system.text, 1.5)
|
|
||||||
Layout.preferredHeight: 1
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.leftMargin: 180
|
|
||||||
Layout.rightMargin: 180
|
|
||||||
Layout.topMargin: 10
|
|
||||||
Layout.bottomMargin: 10
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
spacing: 6
|
spacing: 6
|
||||||
Layout.leftMargin: 60
|
Layout.leftMargin: fontMetrics.height * 4
|
||||||
Layout.rightMargin: 60
|
Layout.rightMargin: fontMetrics.height * 4
|
||||||
|
|
||||||
Text {
|
component DetailsLabel: Label {
|
||||||
visible: hsi.getUserAt().length > 0
|
Layout.fillWidth: true
|
||||||
text: "User: " + hsi.getUserAt()
|
|
||||||
Layout.maximumWidth: _width - 120
|
|
||||||
color: system.windowText
|
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
textFormat: Text.PlainText
|
|
||||||
wrapMode: Text.NoWrap
|
wrapMode: Text.NoWrap
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
DetailsLabel { text: "User: " + hsi.getUserAt(); visible: hsi.getUserAt() != "" }
|
||||||
visible: hsi.getModel().length > 0
|
DetailsLabel { text: "Model: " + hsi.getModel(); visible: hsi.getModel() != "" }
|
||||||
text: "Model: " + hsi.getModel()
|
DetailsLabel { text: "CPU: " + hsi.getCPUInfo() }
|
||||||
Layout.maximumWidth: _width - 120
|
|
||||||
color: system.windowText
|
|
||||||
elide: Text.ElideRight
|
|
||||||
textFormat: Text.PlainText
|
|
||||||
wrapMode: Text.NoWrap
|
|
||||||
}
|
|
||||||
|
|
||||||
Text {
|
|
||||||
text: "CPU: " + hsi.getCPUInfo()
|
|
||||||
Layout.maximumWidth: _width - 120
|
|
||||||
color: system.windowText
|
|
||||||
elide: Text.ElideRight
|
|
||||||
textFormat: Text.PlainText
|
|
||||||
wrapMode: Text.NoWrap
|
|
||||||
}
|
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
model: hsi.getGPUInfoCount()
|
model: hsi.getGPUInfoCount()
|
||||||
|
|
||||||
Text {
|
DetailsLabel {
|
||||||
required property int index
|
required property int index
|
||||||
|
|
||||||
text: "GPU: " + hsi.getGPUInfo(index)
|
text: "GPU: " + hsi.getGPUInfo(index)
|
||||||
Layout.maximumWidth: _width - 120
|
|
||||||
color: system.windowText
|
|
||||||
elide: Text.ElideRight
|
|
||||||
textFormat: Text.PlainText
|
|
||||||
wrapMode: Text.NoWrap
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Text {
|
|
||||||
text: "Memory: " + hsi.getRAMInfo()
|
|
||||||
Layout.maximumWidth: _width - 120
|
|
||||||
color: system.windowText
|
|
||||||
elide: Text.ElideRight
|
|
||||||
textFormat: Text.PlainText
|
|
||||||
wrapMode: Text.NoWrap
|
|
||||||
}
|
|
||||||
|
|
||||||
Text {
|
|
||||||
text: "DE: " + hsi.getDE()
|
|
||||||
Layout.maximumWidth: _width - 120
|
|
||||||
color: system.windowText
|
|
||||||
elide: Text.ElideRight
|
|
||||||
textFormat: Text.PlainText
|
|
||||||
wrapMode: Text.NoWrap
|
|
||||||
}
|
|
||||||
|
|
||||||
Text {
|
|
||||||
text: "Uptime: " + hsi.getUptime()
|
|
||||||
Layout.maximumWidth: _width - 120
|
|
||||||
color: system.windowText
|
|
||||||
elide: Text.ElideRight
|
|
||||||
textFormat: Text.PlainText
|
|
||||||
wrapMode: Text.NoWrap
|
|
||||||
}
|
|
||||||
|
|
||||||
Text {
|
|
||||||
text: "Displays: " + hsi.getDisplays()
|
|
||||||
Layout.maximumWidth: _width - 120
|
|
||||||
color: system.windowText
|
|
||||||
elide: Text.ElideRight
|
|
||||||
textFormat: Text.PlainText
|
|
||||||
wrapMode: Text.NoWrap
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DetailsLabel { text: "Memory: " + hsi.getRAMInfo() }
|
||||||
|
DetailsLabel { text: "DE: " + hsi.getDE() }
|
||||||
|
DetailsLabel { text: "Uptime: " + hsi.getUptime() }
|
||||||
|
DetailsLabel { text: "Displays: " + hsi.getDisplays() }
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Item { Layout.fillHeight: true }
|
||||||
color: "transparent"
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.fillHeight: true
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
HSeparator {}
|
||||||
visible: hsi.hasHyprland()
|
|
||||||
color: Qt.darker(system.text, 1.5)
|
|
||||||
Layout.preferredHeight: 1
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.leftMargin: 180
|
|
||||||
Layout.rightMargin: 180
|
|
||||||
Layout.topMargin: 10
|
|
||||||
Layout.bottomMargin: 10
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
visible: hsi.hasHyprland()
|
visible: hsi.hasHyprland()
|
||||||
|
@ -259,20 +182,13 @@ ApplicationWindow {
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
text: "Copy Hyprland System Info"
|
text: "Copy Hyprland System Info"
|
||||||
onClicked: (e) => {
|
onClicked: hsi.copySystemInfo();
|
||||||
hsi.copySystemInfo();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
text: "Copy Hyprland Version"
|
text: "Copy Hyprland Version"
|
||||||
onClicked: (e) => {
|
onClicked: hsi.copyVersion();
|
||||||
hsi.copyVersion();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue