Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
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
videolan
vlc-2-2
Commits
5f78dc28
Commit
5f78dc28
authored
Jan 17, 2014
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt: ExtensionItemDelegate: rewrite (fix #10407)
does it the right way
parent
09680206
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
50 deletions
+47
-50
modules/gui/qt4/dialogs/plugins.cpp
modules/gui/qt4/dialogs/plugins.cpp
+44
-50
modules/gui/qt4/dialogs/plugins.hpp
modules/gui/qt4/dialogs/plugins.hpp
+3
-0
No files found.
modules/gui/qt4/dialogs/plugins.cpp
View file @
5f78dc28
...
...
@@ -430,6 +430,7 @@ ExtensionItemDelegate::ExtensionItemDelegate( intf_thread_t *p_intf,
QListView
*
view
)
:
QStyledItemDelegate
(
view
),
view
(
view
),
p_intf
(
p_intf
)
{
margins
=
QMargins
(
4
,
4
,
4
,
4
);
}
ExtensionItemDelegate
::~
ExtensionItemDelegate
()
...
...
@@ -440,80 +441,73 @@ void ExtensionItemDelegate::paint( QPainter *painter,
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
{
int
width
=
option
.
rect
.
width
();
// Pixmap: buffer where to draw
QPixmap
pix
(
option
.
rect
.
size
());
QStyleOptionViewItemV4
opt
=
option
;
initStyleOption
(
&
opt
,
index
);
// Draw background
pix
.
fill
(
Qt
::
transparent
);
// FIXME
// ItemView primitive style
QApplication
::
style
()
->
drawPrimitive
(
QStyle
::
PE_PanelItemViewItem
,
&
option
,
painter
);
// Painter on the pixmap
QPainter
*
pixpaint
=
new
QPainter
(
&
pix
);
// Text font & pen
QFont
font
=
painter
->
font
();
QPen
pen
=
painter
->
pen
();
if
(
view
->
selectionModel
()
->
selectedIndexes
().
contains
(
index
)
)
{
pen
.
setBrush
(
option
.
palette
.
highlightedText
()
);
}
else
{
pen
.
setBrush
(
option
.
palette
.
text
()
);
}
pixpaint
->
setPen
(
pen
);
QFontMetrics
metrics
=
option
.
fontMetrics
;
if
(
opt
.
state
&
QStyle
::
State_Selected
)
painter
->
fillRect
(
opt
.
rect
,
opt
.
palette
.
highlight
()
);
// Icon
QPixmap
icon
=
index
.
data
(
Qt
::
DecorationRole
).
value
<
QPixmap
>
();
if
(
!
icon
.
isNull
()
)
{
pixpaint
->
drawPixmap
(
7
,
7
,
2
*
metrics
.
height
(),
2
*
metrics
.
height
(),
icon
);
painter
->
drawPixmap
(
opt
.
rect
.
left
()
+
margins
.
left
(),
opt
.
rect
.
top
()
+
margins
.
top
(),
icon
.
scaled
(
opt
.
decorationSize
,
Qt
::
KeepAspectRatio
,
Qt
::
SmoothTransformation
)
);
}
// Title: bold
pixpaint
->
setRenderHint
(
QPainter
::
TextAntialiasing
);
painter
->
save
();
painter
->
setRenderHint
(
QPainter
::
TextAntialiasing
);
if
(
opt
.
state
&
QStyle
::
State_Selected
)
painter
->
setPen
(
opt
.
palette
.
highlightedText
().
color
()
);
QFont
font
(
option
.
font
);
font
.
setBold
(
true
);
pixpaint
->
setFont
(
font
);
pixpaint
->
drawText
(
QRect
(
17
+
2
*
metrics
.
height
(),
7
,
width
-
40
-
2
*
metrics
.
height
(),
metrics
.
height
()
),
Qt
::
AlignLeft
,
index
.
data
(
Qt
::
DisplayRole
).
toString
()
);
painter
->
setFont
(
font
);
QRect
textrect
(
opt
.
rect
);
textrect
.
adjust
(
2
*
margins
.
left
()
+
margins
.
right
()
+
opt
.
decorationSize
.
width
(),
margins
.
top
(),
-
margins
.
right
(),
-
margins
.
bottom
()
-
opt
.
fontMetrics
.
height
()
);
// Short description: normal
font
.
setBold
(
false
);
pixpaint
->
setFont
(
font
);
pixpaint
->
drawText
(
QRect
(
17
+
2
*
metrics
.
height
(),
7
+
metrics
.
height
(),
width
-
40
,
metrics
.
height
()
),
Qt
::
AlignLeft
,
index
.
data
(
ExtensionListModel
::
DescriptionRole
).
toString
()
);
painter
->
drawText
(
textrect
,
Qt
::
AlignLeft
,
index
.
data
(
Qt
::
DisplayRole
).
toString
()
);
// Flush paint operations
delete
pixpaint
;
font
.
setBold
(
false
);
painter
->
setFont
(
font
);
painter
->
drawText
(
textrect
.
translated
(
0
,
option
.
fontMetrics
.
height
()
),
Qt
::
AlignLeft
,
index
.
data
(
ExtensionListModel
::
DescriptionRole
).
toString
()
);
// Draw it on the screen!
painter
->
drawPixmap
(
option
.
rect
,
pix
);
painter
->
restore
();
}
QSize
ExtensionItemDelegate
::
sizeHint
(
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
{
if
(
index
.
isValid
()
&&
index
.
column
()
==
0
)
if
(
index
.
isValid
()
)
{
QFontMetrics
metrics
=
option
.
fontMetrics
;
return
QSize
(
200
,
14
+
2
*
metrics
.
height
()
);
return
QSize
(
200
,
2
*
option
.
fontMetrics
.
height
()
+
margins
.
top
()
+
margins
.
bottom
()
);
}
else
return
QSize
();
}
void
ExtensionItemDelegate
::
initStyleOption
(
QStyleOptionViewItem
*
option
,
const
QModelIndex
&
index
)
const
{
QStyledItemDelegate
::
initStyleOption
(
option
,
index
);
option
->
decorationSize
=
QSize
(
option
->
rect
.
height
(),
option
->
rect
.
height
()
);
option
->
decorationSize
-=
QSize
(
margins
.
left
()
+
margins
.
right
(),
margins
.
top
()
+
margins
.
bottom
()
);
}
/* "More information" dialog */
ExtensionInfoDialog
::
ExtensionInfoDialog
(
const
QModelIndex
&
index
,
...
...
modules/gui/qt4/dialogs/plugins.hpp
View file @
5f78dc28
...
...
@@ -183,8 +183,11 @@ public:
const
QModelIndex
&
index
)
const
;
virtual
QSize
sizeHint
(
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
;
virtual
void
initStyleOption
(
QStyleOptionViewItem
*
option
,
const
QModelIndex
&
index
)
const
;
private:
QMargins
margins
;
QListView
*
view
;
intf_thread_t
*
p_intf
;
};
...
...
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