Commit f0d869db authored by Nate Graham's avatar Nate Graham
Browse files

Remove some unnecessary FocusScopes

Many components already act as FocusScopes, including ScrollView and
StackView. this means we never need to wrap those in FocusScope items.
parent a27eeb74
......@@ -173,52 +173,47 @@ FocusScope {
}
}
FocusScope {
ScrollView {
id: scrollView
readonly property int scrollBarWidth: ScrollBar.vertical.visible ? ScrollBar.vertical.width : 0
readonly property int availableSpace: scrollView.width - scrollView.scrollBarWidth
Layout.fillHeight: true
Layout.fillWidth: true
Layout.leftMargin: Kirigami.Units.smallSpacing
ScrollView {
id: scrollView
readonly property int scrollBarWidth: ScrollBar.vertical.visible ? ScrollBar.vertical.width : 0
readonly property int availableSpace: scrollView.width - scrollView.scrollBarWidth
contentItem: GridView {
id: contentDirectoryView
anchors.fill: parent
activeFocusOnTab: true
keyNavigationEnabled: true
contentItem: GridView {
id: contentDirectoryView
reuseItems: true
activeFocusOnTab: true
keyNavigationEnabled: true
model: delegateModel
reuseItems: true
// HACK: setting currentIndex to -1 in mobile for some reason causes segfaults, no idea why
currentIndex: Kirigami.Settings.isMobile ? 0 : -1
model: delegateModel
Accessible.role: Accessible.List
Accessible.name: mainTitle
// HACK: setting currentIndex to -1 in mobile for some reason causes segfaults, no idea why
currentIndex: Kirigami.Settings.isMobile ? 0 : -1
Accessible.role: Accessible.List
Accessible.name: mainTitle
Kirigami.PlaceholderMessage {
anchors.centerIn: parent
width: parent.width - (Kirigami.Units.largeSpacing * 4)
visible: contentDirectoryView.count === 0 && !suppressNoDataPlaceholderMessage
text: i18n("Nothing to display")
}
Kirigami.PlaceholderMessage {
anchors.centerIn: parent
width: parent.width - (Kirigami.Units.largeSpacing * 4)
visible: contentDirectoryView.count === 0 && !suppressNoDataPlaceholderMessage
text: i18n("Nothing to display")
}
cellWidth: {
let columns = Math.max(Math.floor(scrollView.availableSpace / elisaTheme.gridDelegateSize), 2);
return Math.floor(scrollView.availableSpace / columns);
}
cellHeight: {
if (Kirigami.Settings.isMobile) {
return cellWidth + Kirigami.Units.gridUnit * 2 + Kirigami.Units.largeSpacing;
} else {
return elisaTheme.gridDelegateSize + Kirigami.Units.gridUnit * 2 + Kirigami.Units.largeSpacing;
}
cellWidth: {
let columns = Math.max(Math.floor(scrollView.availableSpace / elisaTheme.gridDelegateSize), 2);
return Math.floor(scrollView.availableSpace / columns);
}
cellHeight: {
if (Kirigami.Settings.isMobile) {
return cellWidth + Kirigami.Units.gridUnit * 2 + Kirigami.Units.largeSpacing;
} else {
return elisaTheme.gridDelegateSize + Kirigami.Units.gridUnit * 2 + Kirigami.Units.largeSpacing;
}
}
}
......
......@@ -11,8 +11,8 @@ import QtGraphicalEffects 1.0
import org.kde.kirigami 2.10 as Kirigami
import org.kde.elisa 1.0
FocusScope {
id: rootFocusScope
ScrollView {
id: scrollView
readonly property alias currentIndex: viewModeView.currentIndex
property double textOpacity
......@@ -29,59 +29,53 @@ FocusScope {
implicitWidth: 225
ScrollView {
id: scrollView
contentItem: ListView {
id: viewModeView
anchors.fill: parent
Accessible.role: Accessible.List
contentItem: ListView {
id: viewModeView
focus: true
clip: true
activeFocusOnTab: true
keyNavigationEnabled: true
interactive: true
Accessible.role: Accessible.List
property bool ignoreCurrentItemChanges: false
focus: true
clip: true
activeFocusOnTab: true
keyNavigationEnabled: true
interactive: true
model: DelegateModel {
id: pageDelegateModel
property bool ignoreCurrentItemChanges: false
delegate: ViewSelectorDelegate {
id: entry
model: DelegateModel {
id: pageDelegateModel
delegate: ViewSelectorDelegate {
id: entry
height: Kirigami.Units.iconSizes.smallMedium + 3 * Kirigami.Units.smallSpacing
width: viewModeView.width
height: Kirigami.Units.iconSizes.smallMedium + 3 * Kirigami.Units.smallSpacing
width: viewModeView.width
focus: true
focus: true
isSelected: viewModeView.currentIndex === index
isSelected: viewModeView.currentIndex === index
image: model.image
title: model.display
secondTitle: model.secondTitle
useSecondTitle: model.useSecondTitle
databaseId: model.databaseId
image: model.image
title: model.display
secondTitle: model.secondTitle
useSecondTitle: model.useSecondTitle
databaseId: model.databaseId
onClicked: {
viewModeView.currentIndex = index
entry.forceActiveFocus()
}
onClicked: {
viewModeView.currentIndex = index
entry.forceActiveFocus()
}
}
}
section.property: 'entryCategory'
section.delegate: Kirigami.ListSectionHeader {
label: (section != 'default' ? section : '')
height: if (section == 'default') 0
width: viewModeView.width
}
onCurrentItemChanged: if (!ignoreCurrentItemChanges) switchView(currentIndex)
section.property: 'entryCategory'
section.delegate: Kirigami.ListSectionHeader {
label: (section != 'default' ? section : '')
height: if (section == 'default') 0
width: viewModeView.width
}
onCurrentItemChanged: if (!ignoreCurrentItemChanges) switchView(currentIndex)
}
Behavior on implicitWidth {
......@@ -103,7 +97,7 @@ FocusScope {
name: 'iconsAndText'
when: mainWindow.width >= elisaTheme.viewSelectorSmallSizeThreshold
PropertyChanges {
target: rootFocusScope
target: scrollView
textOpacity: 1
implicitWidth: 225
}
......@@ -112,7 +106,7 @@ FocusScope {
name: 'iconsOnly'
when: mainWindow.width < elisaTheme.viewSelectorSmallSizeThreshold
PropertyChanges {
target: rootFocusScope
target: scrollView
textOpacity: 0
implicitWidth: Kirigami.Units.iconSizes.smallMedium + 2 * Kirigami.Units.largeSpacing
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment