added adaptive quickshell
This commit is contained in:
1 parent
6eb56d2065
commit
5b33a73fd8
189 files changed
+8678
-15
No files matched your search
@@ -0,0 +1,109 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import "services"
|
||||
import "services/Policy.js" as Policy
|
||||
|
||||
Item {
|
||||
id: home
|
||||
signal launchRequested()
|
||||
signal openLauncher()
|
||||
property int pageIndex: 0
|
||||
property bool editing: false
|
||||
readonly property int pageSize: width < 600 ? 12 : 24
|
||||
readonly property var installed: DesktopEntries.applications.values.filter(app => !app.noDisplay)
|
||||
readonly property var favoriteIds: Preferences.data.favorites || []
|
||||
readonly property var pages: Policy.homePages(favoriteIds, pageSize)
|
||||
readonly property var currentIds: pages[Math.min(pageIndex, pages.length - 1)] || []
|
||||
readonly property var currentApps: currentIds.map(id => installed.find(app => app.id === id)).filter(app => app !== undefined)
|
||||
onPagesChanged: if (pageIndex >= pages.length) pageIndex = Math.max(0, pages.length - 1)
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 16
|
||||
spacing: 14
|
||||
Item { Layout.fillHeight: true }
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text: "Главный экран"
|
||||
font.pixelSize: 28
|
||||
font.weight: Font.DemiBold
|
||||
color: Theme.foreground
|
||||
}
|
||||
GridView {
|
||||
id: grid
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: Math.min(540, Math.max(120, Math.ceil(home.currentApps.length / Math.max(1, Math.floor(width / 94))) * 112))
|
||||
clip: true
|
||||
model: home.currentApps
|
||||
cellWidth: width / Math.max(1, Math.floor(width / 94))
|
||||
cellHeight: 112
|
||||
delegate: Item {
|
||||
id: tile
|
||||
required property var modelData
|
||||
width: grid.cellWidth
|
||||
height: grid.cellHeight
|
||||
Column {
|
||||
anchors.centerIn: parent
|
||||
spacing: 7
|
||||
Image {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
width: 52; height: 52
|
||||
source: Quickshell.iconPath(tile.modelData.icon, "application-x-executable")
|
||||
fillMode: Image.PreserveAspectFit
|
||||
}
|
||||
Label {
|
||||
width: grid.cellWidth - 8
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
elide: Text.ElideRight
|
||||
text: tile.modelData.name
|
||||
color: Theme.foreground
|
||||
}
|
||||
}
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onPressAndHold: home.editing = true
|
||||
onClicked: {
|
||||
if (home.editing) return;
|
||||
tile.modelData.execute();
|
||||
Preferences.recordLaunch(tile.modelData.id);
|
||||
home.launchRequested();
|
||||
}
|
||||
}
|
||||
Row {
|
||||
visible: home.editing
|
||||
anchors.top: parent.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
spacing: 2
|
||||
Button { text: "←"; enabled: Preferences.writable; onClicked: Preferences.moveFavorite(tile.modelData.id, -1) }
|
||||
Button { text: "×"; enabled: Preferences.writable; onClicked: Preferences.toggleFavorite(tile.modelData.id) }
|
||||
Button { text: "→"; enabled: Preferences.writable; onClicked: Preferences.moveFavorite(tile.modelData.id, 1) }
|
||||
}
|
||||
}
|
||||
}
|
||||
RowLayout {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
Button { text: "‹"; enabled: home.pageIndex > 0; onClicked: home.pageIndex-- }
|
||||
Label { text: (home.pageIndex + 1) + " / " + home.pages.length; color: Theme.foreground }
|
||||
Button { text: "›"; enabled: home.pageIndex + 1 < home.pages.length; onClicked: home.pageIndex++ }
|
||||
}
|
||||
RowLayout {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
Button { text: "Все приложения"; onClicked: home.openLauncher() }
|
||||
Button {
|
||||
text: home.editing ? "Готово" : "Изменить"
|
||||
onClicked: home.editing = !home.editing
|
||||
}
|
||||
}
|
||||
Label {
|
||||
visible: home.favoriteIds.length === 0
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
text: "Закрепите приложения через ☆ в списке приложений"
|
||||
color: Theme.outline
|
||||
wrapMode: Text.Wrap
|
||||
}
|
||||
Item { Layout.fillHeight: true }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user