mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-29 07:52:50 -05:00
settings: fix sidebar binding when clicked by emitting signal
This commit is contained in:
@@ -319,8 +319,8 @@ FloatingWindow {
|
|||||||
visible: settingsModal.isCompactMode ? settingsModal.menuVisible : true
|
visible: settingsModal.isCompactMode ? settingsModal.menuVisible : true
|
||||||
parentModal: settingsModal
|
parentModal: settingsModal
|
||||||
currentIndex: settingsModal.currentTabIndex
|
currentIndex: settingsModal.currentTabIndex
|
||||||
onCurrentIndexChanged: {
|
onTabChangeRequested: tabIndex => {
|
||||||
settingsModal.currentTabIndex = currentIndex;
|
settingsModal.currentTabIndex = tabIndex;
|
||||||
if (settingsModal.isCompactMode) {
|
if (settingsModal.isCompactMode) {
|
||||||
settingsModal.enableAnimations = true;
|
settingsModal.enableAnimations = true;
|
||||||
settingsModal.menuVisible = false;
|
settingsModal.menuVisible = false;
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ Rectangle {
|
|||||||
|
|
||||||
property int currentIndex: 0
|
property int currentIndex: 0
|
||||||
property var parentModal: null
|
property var parentModal: null
|
||||||
|
|
||||||
|
signal tabChangeRequested(int tabIndex)
|
||||||
property var expandedCategories: ({})
|
property var expandedCategories: ({})
|
||||||
property var autoExpandedCategories: ({})
|
property var autoExpandedCategories: ({})
|
||||||
property bool searchActive: searchField.text.length > 0
|
property bool searchActive: searchField.text.length > 0
|
||||||
@@ -55,8 +57,9 @@ Rectangle {
|
|||||||
if (keyboardHighlightIndex < 0)
|
if (keyboardHighlightIndex < 0)
|
||||||
return;
|
return;
|
||||||
var oldIndex = currentIndex;
|
var oldIndex = currentIndex;
|
||||||
currentIndex = keyboardHighlightIndex;
|
var newIndex = keyboardHighlightIndex;
|
||||||
autoCollapseIfNeeded(oldIndex, currentIndex);
|
tabChangeRequested(newIndex);
|
||||||
|
autoCollapseIfNeeded(oldIndex, newIndex);
|
||||||
keyboardHighlightIndex = -1;
|
keyboardHighlightIndex = -1;
|
||||||
Qt.callLater(searchField.forceActiveFocus);
|
Qt.callLater(searchField.forceActiveFocus);
|
||||||
}
|
}
|
||||||
@@ -398,28 +401,32 @@ Rectangle {
|
|||||||
var flatItems = getFlatNavigableItems();
|
var flatItems = getFlatNavigableItems();
|
||||||
var currentPos = flatItems.findIndex(item => item.tabIndex === currentIndex);
|
var currentPos = flatItems.findIndex(item => item.tabIndex === currentIndex);
|
||||||
var oldIndex = currentIndex;
|
var oldIndex = currentIndex;
|
||||||
|
var newIndex;
|
||||||
if (currentPos === -1) {
|
if (currentPos === -1) {
|
||||||
currentIndex = flatItems[0]?.tabIndex ?? 0;
|
newIndex = flatItems[0]?.tabIndex ?? 0;
|
||||||
} else {
|
} else {
|
||||||
var nextPos = (currentPos + 1) % flatItems.length;
|
var nextPos = (currentPos + 1) % flatItems.length;
|
||||||
currentIndex = flatItems[nextPos].tabIndex;
|
newIndex = flatItems[nextPos].tabIndex;
|
||||||
}
|
}
|
||||||
autoCollapseIfNeeded(oldIndex, currentIndex);
|
tabChangeRequested(newIndex);
|
||||||
autoExpandForTab(currentIndex);
|
autoCollapseIfNeeded(oldIndex, newIndex);
|
||||||
|
autoExpandForTab(newIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
function navigatePrevious() {
|
function navigatePrevious() {
|
||||||
var flatItems = getFlatNavigableItems();
|
var flatItems = getFlatNavigableItems();
|
||||||
var currentPos = flatItems.findIndex(item => item.tabIndex === currentIndex);
|
var currentPos = flatItems.findIndex(item => item.tabIndex === currentIndex);
|
||||||
var oldIndex = currentIndex;
|
var oldIndex = currentIndex;
|
||||||
|
var newIndex;
|
||||||
if (currentPos === -1) {
|
if (currentPos === -1) {
|
||||||
currentIndex = flatItems[0]?.tabIndex ?? 0;
|
newIndex = flatItems[0]?.tabIndex ?? 0;
|
||||||
} else {
|
} else {
|
||||||
var prevPos = (currentPos - 1 + flatItems.length) % flatItems.length;
|
var prevPos = (currentPos - 1 + flatItems.length) % flatItems.length;
|
||||||
currentIndex = flatItems[prevPos].tabIndex;
|
newIndex = flatItems[prevPos].tabIndex;
|
||||||
}
|
}
|
||||||
autoCollapseIfNeeded(oldIndex, currentIndex);
|
tabChangeRequested(newIndex);
|
||||||
autoExpandForTab(currentIndex);
|
autoCollapseIfNeeded(oldIndex, newIndex);
|
||||||
|
autoExpandForTab(newIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFlatNavigableItems() {
|
function getFlatNavigableItems() {
|
||||||
@@ -488,7 +495,7 @@ Rectangle {
|
|||||||
SettingsSearchService.navigateToSection(result.section);
|
SettingsSearchService.navigateToSection(result.section);
|
||||||
}
|
}
|
||||||
var oldIndex = root.currentIndex;
|
var oldIndex = root.currentIndex;
|
||||||
root.currentIndex = result.tabIndex;
|
tabChangeRequested(result.tabIndex);
|
||||||
autoCollapseIfNeeded(oldIndex, result.tabIndex);
|
autoCollapseIfNeeded(oldIndex, result.tabIndex);
|
||||||
autoExpandForTab(result.tabIndex);
|
autoExpandForTab(result.tabIndex);
|
||||||
searchField.text = "";
|
searchField.text = "";
|
||||||
@@ -807,7 +814,7 @@ Rectangle {
|
|||||||
if (categoryDelegate.modelData.children) {
|
if (categoryDelegate.modelData.children) {
|
||||||
root.toggleCategory(categoryDelegate.modelData.id);
|
root.toggleCategory(categoryDelegate.modelData.id);
|
||||||
} else if (categoryDelegate.modelData.tabIndex !== undefined) {
|
} else if (categoryDelegate.modelData.tabIndex !== undefined) {
|
||||||
root.currentIndex = categoryDelegate.modelData.tabIndex;
|
root.tabChangeRequested(categoryDelegate.modelData.tabIndex);
|
||||||
}
|
}
|
||||||
Qt.callLater(searchField.forceActiveFocus);
|
Qt.callLater(searchField.forceActiveFocus);
|
||||||
}
|
}
|
||||||
@@ -882,7 +889,7 @@ Rectangle {
|
|||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.keyboardHighlightIndex = -1;
|
root.keyboardHighlightIndex = -1;
|
||||||
root.currentIndex = childDelegate.modelData.tabIndex;
|
root.tabChangeRequested(childDelegate.modelData.tabIndex);
|
||||||
Qt.callLater(searchField.forceActiveFocus);
|
Qt.callLater(searchField.forceActiveFocus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user