Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
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
Show 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,
...
@@ -430,6 +430,7 @@ ExtensionItemDelegate::ExtensionItemDelegate( intf_thread_t *p_intf,
QListView
*
view
)
QListView
*
view
)
:
QStyledItemDelegate
(
view
),
view
(
view
),
p_intf
(
p_intf
)
:
QStyledItemDelegate
(
view
),
view
(
view
),
p_intf
(
p_intf
)
{
{
margins
=
QMargins
(
4
,
4
,
4
,
4
);
}
}
ExtensionItemDelegate
::~
ExtensionItemDelegate
()
ExtensionItemDelegate
::~
ExtensionItemDelegate
()
...
@@ -440,80 +441,73 @@ void ExtensionItemDelegate::paint( QPainter *painter,
...
@@ -440,80 +441,73 @@ void ExtensionItemDelegate::paint( QPainter *painter,
const
QStyleOptionViewItem
&
option
,
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
const
QModelIndex
&
index
)
const
{
{
int
width
=
option
.
rect
.
width
();
QStyleOptionViewItemV4
opt
=
option
;
initStyleOption
(
&
opt
,
index
);
// Pixmap: buffer where to draw
QPixmap
pix
(
option
.
rect
.
size
());
// Draw background
// Draw background
pix
.
fill
(
Qt
::
transparent
);
// FIXME
if
(
opt
.
state
&
QStyle
::
State_Selected
)
painter
->
fillRect
(
opt
.
rect
,
opt
.
palette
.
highlight
()
);
// 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
;
// Icon
// Icon
QPixmap
icon
=
index
.
data
(
Qt
::
DecorationRole
).
value
<
QPixmap
>
();
QPixmap
icon
=
index
.
data
(
Qt
::
DecorationRole
).
value
<
QPixmap
>
();
if
(
!
icon
.
isNull
()
)
if
(
!
icon
.
isNull
()
)
{
{
pixpaint
->
drawPixmap
(
7
,
7
,
2
*
metrics
.
height
(),
2
*
metrics
.
height
(),
painter
->
drawPixmap
(
opt
.
rect
.
left
()
+
margins
.
left
(),
icon
);
opt
.
rect
.
top
()
+
margins
.
top
(),
icon
.
scaled
(
opt
.
decorationSize
,
Qt
::
KeepAspectRatio
,
Qt
::
SmoothTransformation
)
);
}
}
// Title: bold
painter
->
save
();
pixpaint
->
setRenderHint
(
QPainter
::
TextAntialiasing
);
painter
->
setRenderHint
(
QPainter
::
TextAntialiasing
);
if
(
opt
.
state
&
QStyle
::
State_Selected
)
painter
->
setPen
(
opt
.
palette
.
highlightedText
().
color
()
);
QFont
font
(
option
.
font
);
font
.
setBold
(
true
);
font
.
setBold
(
true
);
pixpaint
->
setFont
(
font
);
painter
->
setFont
(
font
);
pixpaint
->
drawText
(
QRect
(
17
+
2
*
metrics
.
height
(),
7
,
QRect
textrect
(
opt
.
rect
);
width
-
40
-
2
*
metrics
.
height
(),
textrect
.
adjust
(
2
*
margins
.
left
()
+
margins
.
right
()
+
opt
.
decorationSize
.
width
(),
metrics
.
height
()
),
margins
.
top
(),
Qt
::
AlignLeft
,
index
.
data
(
Qt
::
DisplayRole
).
toString
()
);
-
margins
.
right
(),
-
margins
.
bottom
()
-
opt
.
fontMetrics
.
height
()
);
// Short description: normal
painter
->
drawText
(
textrect
,
Qt
::
AlignLeft
,
font
.
setBold
(
false
);
index
.
data
(
Qt
::
DisplayRole
).
toString
()
);
pixpaint
->
setFont
(
font
);
pixpaint
->
drawText
(
QRect
(
17
+
2
*
metrics
.
height
(),
7
+
metrics
.
height
(),
width
-
40
,
metrics
.
height
()
),
Qt
::
AlignLeft
,
index
.
data
(
ExtensionListModel
::
DescriptionRole
).
toString
()
);
// Flush paint operations
font
.
setBold
(
false
);
delete
pixpaint
;
painter
->
setFont
(
font
);
painter
->
drawText
(
textrect
.
translated
(
0
,
option
.
fontMetrics
.
height
()
),
Qt
::
AlignLeft
,
index
.
data
(
ExtensionListModel
::
DescriptionRole
).
toString
()
);
// Draw it on the screen!
painter
->
restore
();
painter
->
drawPixmap
(
option
.
rect
,
pix
);
}
}
QSize
ExtensionItemDelegate
::
sizeHint
(
const
QStyleOptionViewItem
&
option
,
QSize
ExtensionItemDelegate
::
sizeHint
(
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
const
QModelIndex
&
index
)
const
{
{
if
(
index
.
isValid
()
&&
index
.
column
()
==
0
)
if
(
index
.
isValid
()
)
{
{
QFontMetrics
metrics
=
option
.
fontMetrics
;
return
QSize
(
200
,
2
*
option
.
fontMetrics
.
height
()
return
QSize
(
200
,
14
+
2
*
metrics
.
height
()
);
+
margins
.
top
()
+
margins
.
bottom
()
);
}
}
else
else
return
QSize
();
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 */
/* "More information" dialog */
ExtensionInfoDialog
::
ExtensionInfoDialog
(
const
QModelIndex
&
index
,
ExtensionInfoDialog
::
ExtensionInfoDialog
(
const
QModelIndex
&
index
,
...
...
modules/gui/qt4/dialogs/plugins.hpp
View file @
5f78dc28
...
@@ -183,8 +183,11 @@ public:
...
@@ -183,8 +183,11 @@ public:
const
QModelIndex
&
index
)
const
;
const
QModelIndex
&
index
)
const
;
virtual
QSize
sizeHint
(
const
QStyleOptionViewItem
&
option
,
virtual
QSize
sizeHint
(
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
;
const
QModelIndex
&
index
)
const
;
virtual
void
initStyleOption
(
QStyleOptionViewItem
*
option
,
const
QModelIndex
&
index
)
const
;
private:
private:
QMargins
margins
;
QListView
*
view
;
QListView
*
view
;
intf_thread_t
*
p_intf
;
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