forked from Shinonome/dots-hyprland
cheatsheet: use toolbar tabbar
This commit is contained in:
@@ -31,7 +31,6 @@ Scope { // Scope
|
|||||||
sourceComponent: PanelWindow { // Window
|
sourceComponent: PanelWindow { // Window
|
||||||
id: cheatsheetRoot
|
id: cheatsheetRoot
|
||||||
visible: cheatsheetLoader.active
|
visible: cheatsheetLoader.active
|
||||||
property int selectedTab: 0
|
|
||||||
|
|
||||||
anchors {
|
anchors {
|
||||||
top: true
|
top: true
|
||||||
@@ -86,16 +85,16 @@ Scope { // Scope
|
|||||||
}
|
}
|
||||||
if (event.modifiers === Qt.ControlModifier) {
|
if (event.modifiers === Qt.ControlModifier) {
|
||||||
if (event.key === Qt.Key_PageDown) {
|
if (event.key === Qt.Key_PageDown) {
|
||||||
cheatsheetRoot.selectedTab = Math.min(cheatsheetRoot.selectedTab + 1, root.tabButtonList.length - 1);
|
tabBar.incrementCurrentIndex();
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
} else if (event.key === Qt.Key_PageUp) {
|
} else if (event.key === Qt.Key_PageUp) {
|
||||||
cheatsheetRoot.selectedTab = Math.max(cheatsheetRoot.selectedTab - 1, 0);
|
tabBar.decrementCurrentIndex();
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
} else if (event.key === Qt.Key_Tab) {
|
} else if (event.key === Qt.Key_Tab) {
|
||||||
cheatsheetRoot.selectedTab = (cheatsheetRoot.selectedTab + 1) % root.tabButtonList.length;
|
tabBar.setCurrentIndex((tabBar.currentIndex + 1) % root.tabButtonList.length);
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
} else if (event.key === Qt.Key_Backtab) {
|
} else if (event.key === Qt.Key_Backtab) {
|
||||||
cheatsheetRoot.selectedTab = (cheatsheetRoot.selectedTab - 1 + root.tabButtonList.length) % root.tabButtonList.length;
|
tabBar.setCurrentIndex((tabBar.currentIndex - 1 + root.tabButtonList.length) % root.tabButtonList.length);
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,11 +140,14 @@ Scope { // Scope
|
|||||||
}
|
}
|
||||||
text: Translation.tr("Cheat sheet")
|
text: Translation.tr("Cheat sheet")
|
||||||
}
|
}
|
||||||
PrimaryTabBar { // Tab strip
|
|
||||||
id: tabBar
|
Toolbar {
|
||||||
tabButtonList: root.tabButtonList
|
Layout.alignment: Qt.AlignHCenter
|
||||||
Synchronizer on currentIndex {
|
enableShadow: false
|
||||||
property alias source: cheatsheetRoot.selectedTab
|
ToolbarTabBar {
|
||||||
|
id: tabBar
|
||||||
|
tabButtonList: root.tabButtonList
|
||||||
|
currentIndex: swipeView.currentIndex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,26 +156,11 @@ Scope { // Scope
|
|||||||
Layout.topMargin: 5
|
Layout.topMargin: 5
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
|
currentIndex: tabBar.currentIndex
|
||||||
spacing: 10
|
spacing: 10
|
||||||
|
|
||||||
Behavior on implicitWidth {
|
implicitWidth: Math.max.apply(null, contentChildren.map(child => child.implicitWidth || 0))
|
||||||
id: contentWidthBehavior
|
implicitHeight: Math.max.apply(null, contentChildren.map(child => child.implicitHeight || 0))
|
||||||
enabled: false
|
|
||||||
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
|
|
||||||
}
|
|
||||||
Behavior on implicitHeight {
|
|
||||||
id: contentHeightBehavior
|
|
||||||
enabled: false
|
|
||||||
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
currentIndex: cheatsheetRoot.selectedTab
|
|
||||||
onCurrentIndexChanged: {
|
|
||||||
contentWidthBehavior.enabled = true;
|
|
||||||
contentHeightBehavior.enabled = true;
|
|
||||||
tabBar.enableIndicatorAnimation = true;
|
|
||||||
cheatsheetRoot.selectedTab = currentIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
clip: true
|
clip: true
|
||||||
layer.enabled: true
|
layer.enabled: true
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ Item {
|
|||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: mainLayout
|
id: mainLayout
|
||||||
|
anchors.centerIn: parent
|
||||||
spacing: root.spacing
|
spacing: root.spacing
|
||||||
|
|
||||||
Repeater { // Main table rows
|
Repeater { // Main table rows
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ RippleButton {
|
|||||||
id: root
|
id: root
|
||||||
required property var element
|
required property var element
|
||||||
opacity: element.type != "empty" ? 1 : 0
|
opacity: element.type != "empty" ? 1 : 0
|
||||||
implicitHeight: 60
|
implicitHeight: 70
|
||||||
implicitWidth: 60
|
implicitWidth: 70
|
||||||
colBackground: Appearance.colors.colLayer2
|
colBackground: Appearance.colors.colLayer2
|
||||||
buttonRadius: Appearance.rounding.small
|
buttonRadius: Appearance.rounding.small
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user