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
Hide 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
...
@@ -71,29 +71,52 @@ KernelListViewDelegate::paint( QPainter* painter, const QStyleOptionViewItem& op
bool
isRc
=
qvariant_cast
<
bool
>
(
index
.
data
(
KernelModel
::
IsRcRole
)
);
bool
isRc
=
qvariant_cast
<
bool
>
(
index
.
data
(
KernelModel
::
IsRcRole
)
);
bool
isRealtime
=
qvariant_cast
<
bool
>
(
index
.
data
(
KernelModel
::
IsRealtimeRole
)
);
bool
isRealtime
=
qvariant_cast
<
bool
>
(
index
.
data
(
KernelModel
::
IsRealtimeRole
)
);
// draw name
// draw right side buttons
QFont
nameFont
=
option
.
font
;
QString
removeStr
(
tr
(
"Remove"
)
);
nameFont
.
setPointSize
(
option
.
font
.
pointSize
()
*
1.15
);
QString
installStr
(
tr
(
"Install"
)
);
QFontMetrics
nameFontMetrics
(
nameFont
);
QString
infoStr
(
tr
(
"Changelog"
)
);
QSize
nameSize
=
nameFontMetrics
.
size
(
Qt
::
TextSingleLine
,
name
);
QStringList
buttonStringList
=
(
QStringList
()
<<
removeStr
<<
installStr
<<
infoStr
);
QRectF
nameRect
(
QPointF
(),
nameSize
);
painter
->
setPen
(
option
.
palette
.
color
(
QPalette
::
Normal
,
QPalette
::
WindowText
)
);
QFont
buttonFont
=
option
.
font
;
nameRect
.
moveTopLeft
(
option
.
rect
.
topLeft
()
+
QPoint
(
padding
,
padding
)
);
QFontMetrics
buttonFontMetrics
(
buttonFont
);
painter
->
setFont
(
nameFont
);
painter
->
drawText
(
nameRect
,
Qt
::
TextSingleLine
,
name
);
// draw package
int
buttonWidth
=
0
;
QFont
packageFont
=
option
.
font
;
int
buttonHeight
=
0
;
packageFont
.
setPointSize
(
option
.
font
.
pointSize
()
*
0.9
);
foreach
(
const
QString
str
,
buttonStringList
)
QFontMetrics
packageFontMetrics
(
packageFont
);
{
QSize
packageSize
=
packageFontMetrics
.
size
(
Qt
::
TextSingleLine
,
package
);
QSize
buttonSize
=
buttonFontMetrics
.
size
(
Qt
::
TextSingleLine
,
str
);
QRectF
packageRect
(
QPointF
(),
packageSize
);
if
(
buttonSize
.
width
()
>
buttonWidth
)
buttonWidth
=
buttonSize
.
width
();
if
(
buttonSize
.
height
()
>
buttonHeight
)
buttonHeight
=
buttonSize
.
height
();
}
painter
->
setPen
(
option
.
palette
.
color
(
QPalette
::
Normal
,
QPalette
::
WindowText
)
);
// Draw remove/install button
packageRect
.
moveTopLeft
(
nameRect
.
bottomLeft
()
);
QRectF
buttonRect
(
QPointF
(),
QSize
(
buttonWidth
+
20
,
buttonHeight
+
8
)
);
painter
->
setFont
(
packageFont
);
buttonRect
.
moveTopRight
(
QPointF
(
option
.
rect
.
right
()
-
padding
,
painter
->
drawText
(
packageRect
,
Qt
::
TextSingleLine
,
package
);
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
// draw middle labels
QString
ltsStr
(
tr
(
"LTS"
)
);
QString
ltsStr
(
tr
(
"LTS"
)
);
...
@@ -124,8 +147,43 @@ KernelListViewDelegate::paint( QPainter* painter, const QStyleOptionViewItem& op
...
@@ -124,8 +147,43 @@ KernelListViewDelegate::paint( QPainter* painter, const QStyleOptionViewItem& op
}
}
QRectF
labelRect
(
QPointF
(),
QSize
(
labelWidth
+
padding
*
2
,
labelHeight
)
);
QRectF
labelRect
(
QPointF
(),
QSize
(
labelWidth
+
padding
*
2
,
labelHeight
)
);
// draw second column (running, installed, unsupported)
labelRect
.
moveTopRight
(
QPointF
(
option
.
rect
.
right
()
-
buttonWidth
-
padding
*
2
-
40
,
option
.
rect
.
top
()
+
padding
)
);
if
(
isRunning
)
{
painter
->
fillRect
(
labelRect
,
QColor
(
"#d6e9c6"
)
);
painter
->
setPen
(
QColor
(
"#dff0d8"
)
);
painter
->
drawRect
(
labelRect
);
painter
->
setPen
(
QColor
(
"#3c763d"
)
);
labelRect
.
moveTopLeft
(
labelRect
.
topLeft
()
+
QPoint
(
0
,
2
)
);
painter
->
drawText
(
labelRect
,
Qt
::
AlignCenter
,
runningStr
);
labelRect
.
moveTopLeft
(
labelRect
.
topLeft
()
+
QPoint
(
0
,
labelHeight
+
2
)
);
}
if
(
isInstalled
)
{
painter
->
fillRect
(
labelRect
,
QColor
(
"#d6e9c6"
)
);
painter
->
setPen
(
QColor
(
"#dff0d8"
)
);
painter
->
drawRect
(
labelRect
);
painter
->
setPen
(
QColor
(
"#3c763d"
)
);
labelRect
.
moveTopLeft
(
labelRect
.
topLeft
()
+
QPoint
(
0
,
2
)
);
painter
->
drawText
(
labelRect
,
Qt
::
AlignCenter
,
installedStr
);
labelRect
.
moveTopLeft
(
labelRect
.
topLeft
()
+
QPoint
(
0
,
labelHeight
+
2
)
);
}
if
(
isUnsupported
)
{
painter
->
fillRect
(
labelRect
,
QColor
(
"#f2dede"
)
);
painter
->
setPen
(
QColor
(
"#ebccd1"
)
);
painter
->
drawRect
(
labelRect
);
painter
->
setPen
(
QColor
(
"#a94442"
)
);
labelRect
.
moveTopLeft
(
labelRect
.
topLeft
()
+
QPoint
(
0
,
2
)
);
painter
->
drawText
(
labelRect
,
Qt
::
AlignCenter
,
unsupportedStr
);
}
// draw first column (lts, recommended, experimental)
// draw first column (lts, recommended, experimental)
labelRect
.
moveTopRight
(
QPointF
(
option
.
rect
.
center
().
x
()
,
labelRect
.
moveTopRight
(
QPointF
(
labelRect
.
topLeft
().
x
()
-
5
,
option
.
rect
.
top
()
+
padding
)
);
option
.
rect
.
top
()
+
padding
)
);
painter
->
setFont
(
labelFont
);
painter
->
setFont
(
labelFont
);
if
(
isLts
)
if
(
isLts
)
...
@@ -163,87 +221,30 @@ KernelListViewDelegate::paint( QPainter* painter, const QStyleOptionViewItem& op
...
@@ -163,87 +221,30 @@ KernelListViewDelegate::paint( QPainter* painter, const QStyleOptionViewItem& op
painter
->
drawText
(
labelRect
,
Qt
::
AlignCenter
,
realtimeStr
);
painter
->
drawText
(
labelRect
,
Qt
::
AlignCenter
,
realtimeStr
);
}
}
// draw second column (running, installed, unsupported)
// draw name
labelRect
.
moveTopLeft
(
QPointF
(
option
.
rect
.
center
().
x
()
+
5
,
QFont
nameFont
=
option
.
font
;
option
.
rect
.
top
()
+
padding
)
);
nameFont
.
setPointSize
(
option
.
font
.
pointSize
()
*
1.75
);
if
(
isRunning
)
QFontMetrics
nameFontMetrics
(
nameFont
);
{
QSize
nameSize
=
nameFontMetrics
.
size
(
Qt
::
TextSingleLine
,
name
);
painter
->
fillRect
(
labelRect
,
QColor
(
"#d6e9c6"
)
);
nameSize
.
setWidth
(
labelRect
.
topLeft
().
x
()
-
10
);
painter
->
setPen
(
QColor
(
"#dff0d8"
)
);
QRectF
nameRect
(
QPointF
(),
nameSize
);
painter
->
drawRect
(
labelRect
);
painter
->
setPen
(
QColor
(
"#3c763d"
)
);
labelRect
.
moveTopLeft
(
labelRect
.
topLeft
()
+
QPoint
(
0
,
2
)
);
painter
->
drawText
(
labelRect
,
Qt
::
AlignCenter
,
runningStr
);
labelRect
.
moveTopLeft
(
labelRect
.
topLeft
()
+
QPoint
(
0
,
labelHeight
+
2
)
);
}
if
(
isInstalled
)
{
painter
->
fillRect
(
labelRect
,
QColor
(
"#d6e9c6"
)
);
painter
->
setPen
(
QColor
(
"#dff0d8"
)
);
painter
->
drawRect
(
labelRect
);
painter
->
setPen
(
QColor
(
"#3c763d"
)
);
labelRect
.
moveTopLeft
(
labelRect
.
topLeft
()
+
QPoint
(
0
,
2
)
);
painter
->
drawText
(
labelRect
,
Qt
::
AlignCenter
,
installedStr
);
labelRect
.
moveTopLeft
(
labelRect
.
topLeft
()
+
QPoint
(
0
,
labelHeight
+
2
)
);
}
if
(
isUnsupported
)
{
painter
->
fillRect
(
labelRect
,
QColor
(
"#f2dede"
)
);
painter
->
setPen
(
QColor
(
"#ebccd1"
)
);
painter
->
drawRect
(
labelRect
);
painter
->
setPen
(
QColor
(
"#a94442"
)
);
labelRect
.
moveTopLeft
(
labelRect
.
topLeft
()
+
QPoint
(
0
,
2
)
);
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
);
QFont
buttonFont
=
option
.
font
;
QFontMetrics
buttonFontMetrics
(
buttonFont
);
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
();
}
// Draw remove/install button
painter
->
setPen
(
option
.
palette
.
color
(
QPalette
::
Normal
,
QPalette
::
WindowText
)
);
QRectF
buttonRect
(
QPointF
(),
QSize
(
buttonWidth
+
20
,
buttonHeight
+
8
)
);
nameRect
.
moveTopLeft
(
option
.
rect
.
topLeft
()
+
QPoint
(
padding
,
padding
)
);
buttonRect
.
moveTopRight
(
QPointF
(
option
.
rect
.
right
()
-
padding
,
painter
->
setFont
(
nameFont
);
option
.
rect
.
center
().
y
()
-
buttonHeight
-
10
)
);
painter
->
drawText
(
nameRect
,
Qt
::
TextWrapAnywhere
,
name
);
QStyleOptionButton
button
;
// draw package
button
.
rect
=
buttonRect
.
toRect
();
QFont
packageFont
=
option
.
font
;
if
(
isInstalled
)
packageFont
.
setPointSize
(
option
.
font
.
pointSize
()
*
0.9
);
button
.
text
=
removeStr
;
QFontMetrics
packageFontMetrics
(
packageFont
);
else
QSize
packageSize
=
packageFontMetrics
.
size
(
Qt
::
TextSingleLine
,
package
);
button
.
text
=
installStr
;
QRectF
packageRect
(
QPointF
(),
packageSize
);
button
.
state
=
m_stateInstallButton
|
QStyle
::
State_Enabled
;
painter
->
setFont
(
buttonFont
);
QApplication
::
style
()
->
drawControl
(
QStyle
::
CE_PushButton
,
&
button
,
painter
);
// Draw changelog/information button
painter
->
setPen
(
option
.
palette
.
color
(
QPalette
::
Normal
,
QPalette
::
WindowText
)
);
buttonRect
.
moveTopRight
(
QPointF
(
option
.
rect
.
right
()
-
padding
,
packageRect
.
moveTopLeft
(
nameRect
.
bottomLeft
()
);
option
.
rect
.
center
().
y
()
+
2
)
);
painter
->
setFont
(
packageFont
);
QStyleOptionButton
infoButton
;
painter
->
drawText
(
packageRect
,
Qt
::
TextSingleLine
,
package
);
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
);
painter
->
restore
();
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