Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
manjaro-settings-manager
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
57
Issues
57
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
2
Merge Requests
2
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Applications
manjaro-settings-manager
Commits
a0272302
Commit
a0272302
authored
Sep 12, 2017
by
Ramon Buldó
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel: right align labels, limit size of kernel name width
parent
f99081b1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
100 additions
and
99 deletions
+100
-99
src/modules/kernel/KernelListViewDelegate.cpp
src/modules/kernel/KernelListViewDelegate.cpp
+100
-99
No files found.
src/modules/kernel/KernelListViewDelegate.cpp
View file @
a0272302
...
...
@@ -71,29 +71,52 @@ KernelListViewDelegate::paint( QPainter* painter, const QStyleOptionViewItem& op
bool
isRc
=
qvariant_cast
<
bool
>
(
index
.
data
(
KernelModel
::
IsRcRole
)
);
bool
isRealtime
=
qvariant_cast
<
bool
>
(
index
.
data
(
KernelModel
::
IsRealtimeRole
)
);
// draw name
QFont
nameFont
=
option
.
font
;
nameFont
.
setPointSize
(
option
.
font
.
pointSize
()
*
1.15
);
QFontMetrics
nameFontMetrics
(
nameFont
);
QSize
nameSize
=
nameFontMetrics
.
size
(
Qt
::
TextSingleLine
,
name
);
QRectF
nameRect
(
QPointF
(),
nameSize
);
// draw right side buttons
QString
removeStr
(
tr
(
"Remove"
)
);
QString
installStr
(
tr
(
"Install"
)
);
QString
infoStr
(
tr
(
"Changelog"
)
);
QStringList
buttonStringList
=
(
QStringList
()
<<
removeStr
<<
installStr
<<
infoStr
);
painter
->
setPen
(
option
.
palette
.
color
(
QPalette
::
Normal
,
QPalette
::
WindowText
)
);
nameRect
.
moveTopLeft
(
option
.
rect
.
topLeft
()
+
QPoint
(
padding
,
padding
)
);
painter
->
setFont
(
nameFont
);
painter
->
drawText
(
nameRect
,
Qt
::
TextSingleLine
,
name
);
QFont
buttonFont
=
option
.
font
;
QFontMetrics
buttonFontMetrics
(
buttonFont
);
// draw package
QFont
packageFont
=
option
.
font
;
packageFont
.
setPointSize
(
option
.
font
.
pointSize
()
*
0.9
);
QFontMetrics
packageFontMetrics
(
packageFont
);
QSize
packageSize
=
packageFontMetrics
.
size
(
Qt
::
TextSingleLine
,
package
);
QRectF
packageRect
(
QPointF
(),
packageSize
);
int
buttonWidth
=
0
;
int
buttonHeight
=
0
;
foreach
(
const
QString
str
,
buttonStringList
)
{
QSize
buttonSize
=
buttonFontMetrics
.
size
(
Qt
::
TextSingleLine
,
str
);
if
(
buttonSize
.
width
()
>
buttonWidth
)
buttonWidth
=
buttonSize
.
width
();
if
(
buttonSize
.
height
()
>
buttonHeight
)
buttonHeight
=
buttonSize
.
height
();
}
painter
->
setPen
(
option
.
palette
.
color
(
QPalette
::
Normal
,
QPalette
::
WindowText
)
);
packageRect
.
moveTopLeft
(
nameRect
.
bottomLeft
()
);
painter
->
setFont
(
packageFont
);
painter
->
drawText
(
packageRect
,
Qt
::
TextSingleLine
,
package
);
// Draw remove/install button
QRectF
buttonRect
(
QPointF
(),
QSize
(
buttonWidth
+
20
,
buttonHeight
+
8
)
);
buttonRect
.
moveTopRight
(
QPointF
(
option
.
rect
.
right
()
-
padding
,
option
.
rect
.
center
().
y
()
-
buttonHeight
-
10
)
);
QStyleOptionButton
button
;
button
.
rect
=
buttonRect
.
toRect
();
if
(
isInstalled
)
button
.
text
=
removeStr
;
else
button
.
text
=
installStr
;
button
.
state
=
m_stateInstallButton
|
QStyle
::
State_Enabled
;
painter
->
setFont
(
buttonFont
);
QApplication
::
style
()
->
drawControl
(
QStyle
::
CE_PushButton
,
&
button
,
painter
);
// Draw changelog/information button
buttonRect
.
moveTopRight
(
QPointF
(
option
.
rect
.
right
()
-
padding
,
option
.
rect
.
center
().
y
()
+
2
)
);
QStyleOptionButton
infoButton
;
infoButton
.
rect
=
buttonRect
.
toRect
();
infoButton
.
text
=
infoStr
;
infoButton
.
state
=
m_stateInfoButton
|
QStyle
::
State_Enabled
;
painter
->
setFont
(
buttonFont
);
QString
changelog
=
QString
(
":/changelogs/%1.html"
).
arg
(
package
);
if
(
QFile
(
changelog
).
exists
()
)
QApplication
::
style
()
->
drawControl
(
QStyle
::
CE_PushButton
,
&
infoButton
,
painter
);
// draw middle labels
QString
ltsStr
(
tr
(
"LTS"
)
);
...
...
@@ -124,47 +147,8 @@ KernelListViewDelegate::paint( QPainter* painter, const QStyleOptionViewItem& op
}
QRectF
labelRect
(
QPointF
(),
QSize
(
labelWidth
+
padding
*
2
,
labelHeight
)
);
// draw first column (lts, recommended, experimental)
labelRect
.
moveTopRight
(
QPointF
(
option
.
rect
.
center
().
x
(),
option
.
rect
.
top
()
+
padding
)
);
painter
->
setFont
(
labelFont
);
if
(
isLts
)
{
painter
->
fillRect
(
labelRect
,
QColor
(
"#d9edf7"
)
);
painter
->
setPen
(
QColor
(
"#bce8f1"
)
);
painter
->
drawRect
(
labelRect
);
painter
->
setPen
(
QColor
(
"#31708f"
)
);
labelRect
.
moveTopLeft
(
labelRect
.
topLeft
()
+
QPoint
(
0
,
2
)
);
painter
->
drawText
(
labelRect
,
Qt
::
AlignCenter
,
ltsStr
);
labelRect
.
moveTopLeft
(
labelRect
.
topLeft
()
+
QPoint
(
0
,
labelHeight
+
2
)
);
}
if
(
isRecommended
)
{
painter
->
fillRect
(
labelRect
,
QColor
(
"#d9edf7"
)
);
painter
->
setPen
(
QColor
(
"#bce8f1"
)
);
painter
->
drawRect
(
labelRect
);
labelRect
.
moveTopLeft
(
labelRect
.
topLeft
()
+
QPoint
(
0
,
2
)
);
painter
->
setPen
(
QColor
(
"#31708f"
)
);
painter
->
drawText
(
labelRect
,
Qt
::
AlignCenter
,
recommendedStr
);
labelRect
.
moveTopLeft
(
labelRect
.
topLeft
()
+
QPoint
(
0
,
labelHeight
+
2
)
);
}
if
(
isRc
||
isRealtime
)
{
painter
->
fillRect
(
labelRect
,
QColor
(
"#FCF8E3"
)
);
painter
->
setPen
(
QColor
(
"#FAEBCC"
)
);
painter
->
drawRect
(
labelRect
);
labelRect
.
moveTopLeft
(
labelRect
.
topLeft
()
+
QPoint
(
0
,
2
)
);
painter
->
setPen
(
QColor
(
"#8A6D3B"
)
);
if
(
isRc
)
painter
->
drawText
(
labelRect
,
Qt
::
AlignCenter
,
experimentalStr
);
else
if
(
isRealtime
)
painter
->
drawText
(
labelRect
,
Qt
::
AlignCenter
,
realtimeStr
);
}
// draw second column (running, installed, unsupported)
labelRect
.
moveTop
Left
(
QPointF
(
option
.
rect
.
center
().
x
()
+
5
,
labelRect
.
moveTop
Right
(
QPointF
(
option
.
rect
.
right
()
-
buttonWidth
-
padding
*
2
-
40
,
option
.
rect
.
top
()
+
padding
)
);
if
(
isRunning
)
{
...
...
@@ -198,52 +182,69 @@ KernelListViewDelegate::paint( QPainter* painter, const QStyleOptionViewItem& op
painter
->
drawText
(
labelRect
,
Qt
::
AlignCenter
,
unsupportedStr
);
}
// draw right side buttons
QString
removeStr
(
tr
(
"Remove"
)
);
QString
installStr
(
tr
(
"Install"
)
);
QString
infoStr
(
tr
(
"Changelog"
)
);
QStringList
buttonStringList
=
(
QStringList
()
<<
removeStr
<<
installStr
<<
infoStr
);
// draw first column (lts, recommended, experimental)
labelRect
.
moveTopRight
(
QPointF
(
labelRect
.
topLeft
().
x
()
-
5
,
option
.
rect
.
top
()
+
padding
)
);
painter
->
setFont
(
labelFont
);
if
(
isLts
)
{
painter
->
fillRect
(
labelRect
,
QColor
(
"#d9edf7"
)
);
painter
->
setPen
(
QColor
(
"#bce8f1"
)
);
painter
->
drawRect
(
labelRect
);
painter
->
setPen
(
QColor
(
"#31708f"
)
);
labelRect
.
moveTopLeft
(
labelRect
.
topLeft
()
+
QPoint
(
0
,
2
)
);
painter
->
drawText
(
labelRect
,
Qt
::
AlignCenter
,
ltsStr
);
labelRect
.
moveTopLeft
(
labelRect
.
topLeft
()
+
QPoint
(
0
,
labelHeight
+
2
)
);
}
QFont
buttonFont
=
option
.
font
;
QFontMetrics
buttonFontMetrics
(
buttonFont
);
if
(
isRecommended
)
{
painter
->
fillRect
(
labelRect
,
QColor
(
"#d9edf7"
)
);
painter
->
setPen
(
QColor
(
"#bce8f1"
)
);
painter
->
drawRect
(
labelRect
);
labelRect
.
moveTopLeft
(
labelRect
.
topLeft
()
+
QPoint
(
0
,
2
)
);
painter
->
setPen
(
QColor
(
"#31708f"
)
);
painter
->
drawText
(
labelRect
,
Qt
::
AlignCenter
,
recommendedStr
);
labelRect
.
moveTopLeft
(
labelRect
.
topLeft
()
+
QPoint
(
0
,
labelHeight
+
2
)
);
}
int
buttonWidth
=
0
;
int
buttonHeight
=
0
;
foreach
(
const
QString
str
,
buttonStringList
)
if
(
isRc
||
isRealtime
)
{
QSize
buttonSize
=
buttonFontMetrics
.
size
(
Qt
::
TextSingleLine
,
str
);
if
(
buttonSize
.
width
()
>
buttonWidth
)
buttonWidth
=
buttonSize
.
width
();
if
(
buttonSize
.
height
()
>
buttonHeight
)
buttonHeight
=
buttonSize
.
height
();
painter
->
fillRect
(
labelRect
,
QColor
(
"#FCF8E3"
)
);
painter
->
setPen
(
QColor
(
"#FAEBCC"
)
);
painter
->
drawRect
(
labelRect
);
labelRect
.
moveTopLeft
(
labelRect
.
topLeft
()
+
QPoint
(
0
,
2
)
);
painter
->
setPen
(
QColor
(
"#8A6D3B"
)
);
if
(
isRc
)
painter
->
drawText
(
labelRect
,
Qt
::
AlignCenter
,
experimentalStr
);
else
if
(
isRealtime
)
painter
->
drawText
(
labelRect
,
Qt
::
AlignCenter
,
realtimeStr
);
}
// Draw remove/install button
QRectF
buttonRect
(
QPointF
(),
QSize
(
buttonWidth
+
20
,
buttonHeight
+
8
)
);
buttonRect
.
moveTopRight
(
QPointF
(
option
.
rect
.
right
()
-
padding
,
option
.
rect
.
center
().
y
()
-
buttonHeight
-
10
)
);
// draw name
QFont
nameFont
=
option
.
font
;
nameFont
.
setPointSize
(
option
.
font
.
pointSize
()
*
1.75
);
QFontMetrics
nameFontMetrics
(
nameFont
);
QSize
nameSize
=
nameFontMetrics
.
size
(
Qt
::
TextSingleLine
,
name
);
nameSize
.
setWidth
(
labelRect
.
topLeft
().
x
()
-
10
);
QRectF
nameRect
(
QPointF
(),
nameSize
);
QStyleOptionButton
button
;
button
.
rect
=
buttonRect
.
toRect
();
if
(
isInstalled
)
button
.
text
=
removeStr
;
else
button
.
text
=
installStr
;
button
.
state
=
m_stateInstallButton
|
QStyle
::
State_Enabled
;
painter
->
setFont
(
buttonFont
);
QApplication
::
style
()
->
drawControl
(
QStyle
::
CE_PushButton
,
&
button
,
painter
);
painter
->
setPen
(
option
.
palette
.
color
(
QPalette
::
Normal
,
QPalette
::
WindowText
)
);
nameRect
.
moveTopLeft
(
option
.
rect
.
topLeft
()
+
QPoint
(
padding
,
padding
)
);
painter
->
setFont
(
nameFont
);
painter
->
drawText
(
nameRect
,
Qt
::
TextWrapAnywhere
,
name
);
//
Draw changelog/information button
buttonRect
.
moveTopRight
(
QPointF
(
option
.
rect
.
right
()
-
padding
,
option
.
rect
.
center
().
y
()
+
2
)
);
Q
StyleOptionButton
infoButton
;
infoButton
.
rect
=
buttonRect
.
toRect
(
);
infoButton
.
text
=
infoStr
;
infoButton
.
state
=
m_stateInfoButton
|
QStyle
::
State_Enabled
;
painter
->
set
Font
(
buttonFont
);
QString
changelog
=
QString
(
":/changelogs/%1.html"
).
arg
(
package
);
if
(
QFile
(
changelog
).
exists
()
)
QApplication
::
style
()
->
drawControl
(
QStyle
::
CE_PushButton
,
&
infoButton
,
painter
);
//
draw package
QFont
packageFont
=
option
.
font
;
packageFont
.
setPointSize
(
option
.
font
.
pointSize
()
*
0.9
);
Q
FontMetrics
packageFontMetrics
(
packageFont
)
;
QSize
packageSize
=
packageFontMetrics
.
size
(
Qt
::
TextSingleLine
,
package
);
QRectF
packageRect
(
QPointF
(),
packageSize
)
;
painter
->
set
Pen
(
option
.
palette
.
color
(
QPalette
::
Normal
,
QPalette
::
WindowText
)
);
packageRect
.
moveTopLeft
(
nameRect
.
bottomLeft
()
);
painter
->
setFont
(
packageFont
);
painter
->
drawText
(
packageRect
,
Qt
::
TextSingleLine
,
package
);
painter
->
restore
();
}
...
...
Write
Preview
Markdown
is supported
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