Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
System Settings
Commits
5c5301a3
Commit
5c5301a3
authored
Nov 23, 2020
by
Janet Blackquill
🌈
Committed by
Janet Blackquill
Apr 16, 2021
Browse files
Port CategoryItem to use Kirigami's new leading/trailing properties on the BasicListItem
parent
ba7c40a8
Changes
3
Hide whitespace changes
Inline
Side-by-side
sidebar/package/contents/ui/CategoriesPage.qml
View file @
5c5301a3
...
...
@@ -134,7 +134,7 @@ Kirigami.ScrollablePage {
}
}
delegate
:
Kirigami.AbstractList
Item
{
delegate
:
Category
Item
{
id
:
delegate
Accessible.role
:
Accessible
.
ListItem
...
...
@@ -174,18 +174,15 @@ Kirigami.ScrollablePage {
highlighted
:
categoryView
.
currentIndex
==
index
Keys.onEnterPressed
:
clicked
();
Keys.onReturnPressed
:
clicked
();
contentItem
:
CategoryItem
{
showArrow
:
{
if
(
!
model
.
IsCategoryRole
)
{
return
false
;
}
const
modelIndex
=
delegate
.
ListView
.
view
.
model
.
index
(
index
,
0
)
return
delegate
.
ListView
.
view
.
model
.
rowCount
(
modelIndex
)
>
1
showArrow
:
{
if
(
!
model
.
IsCategoryRole
)
{
return
false
;
}
selected
:
delegate
.
highlighted
||
delegate
.
pressed
// Only indent subcategory icons in the search view
isSearching
:
searchField
.
text
.
length
>
0
const
modelIndex
=
delegate
.
ListView
.
view
.
model
.
index
(
index
,
0
)
return
delegate
.
ListView
.
view
.
model
.
rowCount
(
modelIndex
)
>
1
}
// Only indent subcategory icons in the search view
isSearching
:
searchField
.
text
.
length
>
0
}
}
...
...
sidebar/package/contents/ui/CategoryItem.qml
View file @
5c5301a3
import
QtQuick
2.5
import
QtQuick
.
Controls
2.5
as
QQC2
import
QtQuick
.
Layouts
1.1
import
org
.
kde
.
kirigami
2.1
0
as
Kirigami
import
org
.
kde
.
kirigami
2.1
3
as
Kirigami
RowLayout
{
id
:
layout
Kirigami.BasicListItem
{
id
:
delegate
property
bool
showArrow
:
false
property
bool
selected
:
fal
se
property
bool
selected
:
delegate
.
highlighted
||
delegate
.
pres
se
d
property
bool
isSearching
:
false
spacing
:
Kirigami
.
Settings
.
tabletMode
?
Kirigami
.
Units
.
largeSpacing
:
Kirigami
.
Units
.
smallSpacing
Kirigami.Icon
{
id
:
icon
source
:
model
.
decoration
Layout.preferredHeight
:
Layout
.
preferredWidth
Layout.preferredWidth
:
Kirigami
.
Units
.
iconSizes
.
smallMedium
Layout.leftMargin
:
model
.
DepthRole
>
1
&&
layout
.
isSearching
?
(
model
.
DepthRole
-
1
)
*
(
Kirigami
.
Units
.
iconSizes
.
smallMedium
+
layout
.
spacing
)
:
0
}
QQC2.Label
{
Layout.fillWidth
:
true
text
:
model
.
display
color
:
(
delegate
.
highlighted
||
delegate
.
checked
||
(
delegate
.
pressed
&&
delegate
.
supportsMouseEvents
))
?
Kirigami
.
Theme
.
highlightedTextColor
:
Kirigami
.
Theme
.
textColor
elide
:
Text
.
ElideRight
}
Rectangle
{
id
:
defaultIndicator
radius
:
width
*
0.5
implicitWidth
:
Kirigami
.
Units
.
largeSpacing
implicitHeight
:
Kirigami
.
Units
.
largeSpacing
visible
:
model
.
showDefaultIndicator
&&
systemsettings
.
defaultsIndicatorsVisible
Kirigami.Theme.colorSet
:
Kirigami
.
Theme
.
View
color
:
Kirigami
.
Theme
.
neutralTextColor
text
:
model
.
display
leading
:
RowLayout
{
id
:
row
Kirigami.Icon
{
source
:
model
.
decoration
Layout.preferredWidth
:
row
.
height
Layout.preferredHeight
:
row
.
height
Layout.leftMargin
:
(
model
.
DepthRole
>
1
&&
delegate
.
isSearching
)
?
(
model
.
DepthRole
-
1
)
*
(
row
.
height
*
1.5
)
:
0
}
}
trailing
:
RowLayout
{
Rectangle
{
id
:
defaultIndicator
radius
:
width
*
0.5
implicitWidth
:
Kirigami
.
Units
.
largeSpacing
implicitHeight
:
Kirigami
.
Units
.
largeSpacing
visible
:
model
.
showDefaultIndicator
&&
systemsettings
.
defaultsIndicatorsVisible
Kirigami.Theme.colorSet
:
Kirigami
.
Theme
.
View
color
:
Kirigami
.
Theme
.
neutralTextColor
}
// Extra space to make the defaults indicators line up vertically for all items
Item
{
visible
:
defaultIndicator
.
visible
&&
!
arrow
.
visible
implicitWidth
:
arrow
.
Layout
.
preferredWidth
}
// Extra space to make the defaults indicators line up vertically for all items
Item
{
visible
:
defaultIndicator
.
visible
&&
!
arrow
.
visible
implicitWidth
:
arrow
.
Layout
.
preferredWidth
}
Kirigami.Icon
{
id
:
arrow
Layout.alignment
:
Qt
.
AlignVCenter
Layout.preferredHeight
:
Kirigami
.
Units
.
iconSizes
.
small
opacity
:
0.7
Layout.preferredWidth
:
Layout
.
preferredHeight
source
:
(
LayoutMirroring
.
enabled
?
"
go-next-symbolic-rtl
"
:
"
go-next-symbolic
"
)
visible
:
layout
.
showArrow
selected
:
layout
.
selected
Kirigami.Icon
{
id
:
arrow
Layout.alignment
:
Qt
.
AlignVCenter
Layout.preferredHeight
:
Kirigami
.
Units
.
iconSizes
.
small
opacity
:
0.7
Layout.preferredWidth
:
Layout
.
preferredHeight
source
:
(
LayoutMirroring
.
enabled
?
"
go-next-symbolic-rtl
"
:
"
go-next-symbolic
"
)
visible
:
delegate
.
showArrow
selected
:
delegate
.
selected
}
}
}
sidebar/package/contents/ui/SubCategoryPage.qml
View file @
5c5301a3
...
...
@@ -138,8 +138,9 @@ Kirigami.ScrollablePage {
}
}
delegate
:
Kirigami.AbstractList
Item
{
delegate
:
Category
Item
{
id
:
delegate
leftPadding
:
Kirigami
.
Units
.
smallSpacing
+
(
Kirigami
.
Units
.
smallSpacing
+
Kirigami
.
Units
.
iconSizes
.
smallMedium
)
*
(
model
.
DepthRole
-
2
)
onClicked
:
{
systemsettings
.
loadModule
(
subCategoryView
.
model
.
index
(
index
,
0
));
}
...
...
@@ -158,8 +159,6 @@ Kirigami.ScrollablePage {
highlighted
:
systemsettings
.
activeSubCategoryRow
==
index
Keys.onEnterPressed
:
clicked
();
Keys.onReturnPressed
:
clicked
();
leftPadding
:
Kirigami
.
Units
.
smallSpacing
+
(
Kirigami
.
Units
.
smallSpacing
+
Kirigami
.
Units
.
iconSizes
.
smallMedium
)
*
(
model
.
DepthRole
-
2
)
contentItem
:
CategoryItem
{}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment