Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
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-gpu
Commits
05d736ea
Commit
05d736ea
authored
Feb 15, 2010
by
Jakob Leben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt: respect font sizes
parent
a9c6b1f1
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
105 additions
and
45 deletions
+105
-45
modules/gui/qt4/components/playlist/icon_view.cpp
modules/gui/qt4/components/playlist/icon_view.cpp
+55
-33
modules/gui/qt4/components/playlist/icon_view.hpp
modules/gui/qt4/components/playlist/icon_view.hpp
+3
-3
modules/gui/qt4/components/playlist/selector.cpp
modules/gui/qt4/components/playlist/selector.cpp
+3
-2
modules/gui/qt4/components/playlist/standardpanel.cpp
modules/gui/qt4/components/playlist/standardpanel.cpp
+12
-5
modules/gui/qt4/util/customwidgets.cpp
modules/gui/qt4/util/customwidgets.cpp
+19
-0
modules/gui/qt4/util/customwidgets.hpp
modules/gui/qt4/util/customwidgets.hpp
+13
-2
No files found.
modules/gui/qt4/components/playlist/icon_view.cpp
View file @
05d736ea
...
...
@@ -35,13 +35,10 @@
#include "assert.h"
#define RECT_SIZE_W 120
#define RECT_SIZE_H 120
#define ART_SIZE_W 110
#define ART_SIZE_H 80
//#define OFFSET (RECT_SIZE_W-ART_SIZE_W)/2
//#define ITEMS_SPACING 10
#define ART_RADIUS 5
#define SPACER 5
QString
AbstractPlViewItemDelegate
::
getMeta
(
const
QModelIndex
&
index
,
int
meta
)
const
{
...
...
@@ -140,9 +137,8 @@ void PlIconViewItemDelegate::paint( QPainter * painter, const QStyleOptionViewIt
if
(
option
.
state
&
QStyle
::
State_Selected
)
painter
->
setPen
(
option
.
palette
.
color
(
QPalette
::
HighlightedText
)
);
QFont
font
;
QFont
font
(
index
.
data
(
Qt
::
FontRole
).
value
<
QFont
>
()
)
;
font
.
setPointSize
(
7
);
font
.
setBold
(
index
.
data
(
Qt
::
FontRole
).
value
<
QFont
>
().
bold
()
);
// Draw title
font
.
setItalic
(
true
);
...
...
@@ -150,7 +146,7 @@ void PlIconViewItemDelegate::paint( QPainter * painter, const QStyleOptionViewIt
QFontMetrics
fm
=
painter
->
fontMetrics
();
QRect
textRect
=
option
.
rect
.
adjusted
(
1
,
ART_SIZE_H
+
10
,
0
,
-
1
);
textRect
.
setHeight
(
fm
.
height
()
+
1
);
textRect
.
setHeight
(
fm
.
height
()
);
painter
->
drawText
(
textRect
,
fm
.
elidedText
(
title
,
Qt
::
ElideRight
,
textRect
.
width
()
),
...
...
@@ -162,8 +158,8 @@ void PlIconViewItemDelegate::paint( QPainter * painter, const QStyleOptionViewIt
painter
->
setFont
(
font
);
fm
=
painter
->
fontMetrics
();
textRect
=
textRect
.
adjusted
(
0
,
textRect
.
height
(),
0
,
textRect
.
height
()
);
textRect
.
moveTop
(
textRect
.
bottom
()
+
1
);
painter
->
drawText
(
textRect
,
fm
.
elidedText
(
artist
,
Qt
::
ElideRight
,
textRect
.
width
()
),
QTextOption
(
Qt
::
AlignCenter
)
);
...
...
@@ -173,9 +169,17 @@ void PlIconViewItemDelegate::paint( QPainter * painter, const QStyleOptionViewIt
QSize
PlIconViewItemDelegate
::
sizeHint
(
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
{
return
QSize
(
RECT_SIZE_W
,
RECT_SIZE_H
);
QFont
f
;
f
.
setPointSize
(
7
);
f
.
setBold
(
true
);
QFontMetrics
fm
(
f
);
int
textHeight
=
fm
.
height
();
QSize
sz
(
ART_SIZE_W
+
2
*
SPACER
,
ART_SIZE_H
+
3
*
SPACER
+
2
*
textHeight
+
1
);
return
sz
;
}
#define LISTVIEW_ART_SIZE 45
void
PlListViewItemDelegate
::
paint
(
QPainter
*
painter
,
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
...
...
@@ -198,25 +202,20 @@ void PlListViewItemDelegate::paint( QPainter * painter, const QStyleOptionViewIt
QPixmap
artPix
=
getArtPixmap
(
index
,
QSize
(
LISTVIEW_ART_SIZE
,
LISTVIEW_ART_SIZE
)
);
//Draw selection rectangle
QApplication
::
style
()
->
drawPrimitive
(
QStyle
::
PE_PanelItemViewItem
,
&
option
,
painter
);
//Paint background if item is playing
if
(
index
.
data
(
PLModel
::
IsCurrentRole
).
toBool
()
)
paintPlayingItemBg
(
painter
,
option
);
painter
->
drawPixmap
(
option
.
rect
.
topLeft
()
+
QPoint
(
3
,
3
)
+
QPoint
(
(
LISTVIEW_ART_SIZE
-
artPix
.
width
())
/
2
,
(
LISTVIEW_ART_SIZE
-
artPix
.
height
())
/
2
),
artPix
);
int
textH
=
option
.
fontMetrics
.
height
()
+
2
;
int
marginY
=
(
option
.
rect
.
height
()
/
2
)
-
textH
;
QRect
textRect
=
option
.
rect
.
adjusted
(
LISTVIEW_ART_SIZE
+
10
,
marginY
,
-
10
,
marginY
*
-
1
-
(
artistAlbum
.
isEmpty
()
?
0
:
textH
)
);
QRect
artRect
(
artPix
.
rect
()
);
artRect
.
moveCenter
(
QPoint
(
artRect
.
center
().
x
()
+
3
,
option
.
rect
.
center
().
y
()
)
);
//Draw album art
painter
->
drawPixmap
(
artRect
,
artPix
);
//Start drawing text
painter
->
save
();
if
(
option
.
state
&
QStyle
::
State_Selected
)
...
...
@@ -225,35 +224,59 @@ void PlListViewItemDelegate::paint( QPainter * painter, const QStyleOptionViewIt
QTextOption
textOpt
(
Qt
::
AlignVCenter
|
Qt
::
AlignLeft
);
textOpt
.
setWrapMode
(
QTextOption
::
NoWrap
);
QFont
f
(
option
.
font
);
if
(
index
.
data
(
PLModel
::
IsCurrentRole
).
toBool
()
)
f
.
setBold
(
true
);
QFont
f
(
index
.
data
(
Qt
::
FontRole
).
value
<
QFont
>
()
);
//Draw title info
f
.
setItalic
(
true
);
painter
->
setFont
(
f
);
QFontMetrics
fm
(
painter
->
fontMetrics
()
);
painter
->
drawText
(
textRect
,
title
,
textOpt
);
QRect
textRect
=
option
.
rect
.
adjusted
(
LISTVIEW_ART_SIZE
+
10
,
0
,
-
10
,
0
);
if
(
!
artistAlbum
.
isEmpty
()
)
{
textRect
.
setHeight
(
fm
.
height
()
);
textRect
.
moveBottom
(
option
.
rect
.
center
().
y
()
-
1
);
}
painter
->
drawText
(
textRect
,
fm
.
elidedText
(
title
,
Qt
::
ElideRight
,
textRect
.
width
()
),
textOpt
);
// Draw artist and album info
if
(
!
artistAlbum
.
isEmpty
()
)
{
f
.
setItalic
(
false
);
painter
->
setFont
(
f
);
textRect
.
moveTop
(
textRect
.
top
()
+
textH
);
fm
=
painter
->
fontMetrics
(
);
painter
->
drawText
(
textRect
,
artistAlbum
,
textOpt
);
textRect
.
moveTop
(
textRect
.
bottom
()
+
2
);
painter
->
drawText
(
textRect
,
fm
.
elidedText
(
artistAlbum
,
Qt
::
ElideRight
,
textRect
.
width
()
),
textOpt
);
}
painter
->
restore
();
}
QSize
PlListViewItemDelegate
::
sizeHint
(
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
{
return
QSize
(
LISTVIEW_ART_SIZE
+
6
,
LISTVIEW_ART_SIZE
+
6
);
QFont
f
;
f
.
setBold
(
true
);
QFontMetrics
fm
(
f
);
int
height
=
qMax
(
LISTVIEW_ART_SIZE
,
2
*
fm
.
height
()
+
2
)
+
6
;
return
QSize
(
0
,
height
);
}
PlIconView
::
PlIconView
(
PLModel
*
model
,
QWidget
*
parent
)
:
QListView
(
parent
)
{
PlIconViewItemDelegate
*
delegate
=
new
PlIconViewItemDelegate
(
this
);
setModel
(
model
);
setViewMode
(
QListView
::
IconMode
);
setMovement
(
QListView
::
Static
);
setResizeMode
(
QListView
::
Adjust
);
setGridSize
(
QSize
(
RECT_SIZE_W
,
RECT_SIZE_H
)
);
setGridSize
(
delegate
->
sizeHint
(
)
);
setWrapping
(
true
);
setUniformItemSizes
(
true
);
setSelectionMode
(
QAbstractItemView
::
ExtendedSelection
);
...
...
@@ -262,7 +285,6 @@ PlIconView::PlIconView( PLModel *model, QWidget *parent ) : QListView( parent )
//setAcceptDrops( true );
//setDropIndicatorShown(true);
PlIconViewItemDelegate
*
delegate
=
new
PlIconViewItemDelegate
(
this
);
setItemDelegate
(
delegate
);
}
...
...
modules/gui/qt4/components/playlist/icon_view.hpp
View file @
05d736ea
...
...
@@ -44,10 +44,10 @@ class PlIconViewItemDelegate : public AbstractPlViewItemDelegate
Q_OBJECT
public:
PlIconViewItemDelegate
(
QWidget
*
parent
=
0
)
:
AbstractPlViewItemDelegate
(
parent
)
{}
PlIconViewItemDelegate
(
QWidget
*
parent
=
0
)
:
AbstractPlViewItemDelegate
(
parent
)
{}
void
paint
(
QPainter
*
painter
,
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
;
QSize
sizeHint
(
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
;
QSize
sizeHint
(
const
QStyleOptionViewItem
&
option
=
QStyleOptionViewItem
(),
const
QModelIndex
&
index
=
QModelIndex
()
)
const
;
};
class
PlListViewItemDelegate
:
public
AbstractPlViewItemDelegate
...
...
modules/gui/qt4/components/playlist/selector.cpp
View file @
05d736ea
...
...
@@ -65,13 +65,14 @@ PLSelItem::PLSelItem ( QTreeWidgetItem *i, const QString& text )
layout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
layout
->
addSpacing
(
3
);
lbl
=
new
QLabel
(
text
);
lbl
=
new
Q
VLCEliding
Label
(
text
);
layout
->
addWidget
(
lbl
,
1
);
setLayout
(
layout
);
setMinimumHeight
(
22
);
//Action icon height plus 6
int
height
=
qMax
(
22
,
fontMetrics
().
height
()
+
8
);
setMinimumHeight
(
height
);
}
void
PLSelItem
::
addAction
(
ItemAction
act
,
const
QString
&
tooltip
)
...
...
modules/gui/qt4/components/playlist/standardpanel.cpp
View file @
05d736ea
...
...
@@ -477,7 +477,7 @@ void LocationBar::setIndex( const QModelIndex &index )
free
(
fb_name
);
QAbstractButton
*
btn
=
new
LocationButton
(
text
,
bold
,
i
.
isValid
()
);
btn
->
setSizePolicy
(
QSizePolicy
::
Maximum
,
QSizePolicy
::
Fixed
);
box
->
insertWidget
(
0
,
btn
,
bold
?
1
:
0
);
box
->
insertWidget
(
0
,
btn
);
buttons
.
append
(
btn
);
mapper
->
setMapping
(
btn
,
item
->
id
()
);
...
...
@@ -524,9 +524,14 @@ void LocationButton::paintEvent ( QPaintEvent * event )
int
margin
=
style
()
->
pixelMetric
(
QStyle
::
PM_DefaultFrameWidth
,
0
,
this
)
+
PADDING
;
QRect
rect
=
option
.
rect
.
adjusted
(
b_arrow
?
15
+
margin
:
margin
,
0
,
margin
*
-
1
,
0
);
p
.
drawText
(
rect
,
Qt
::
AlignVCenter
,
fontMetrics
().
elidedText
(
text
(),
Qt
::
ElideRight
,
rect
.
width
()
)
);
QRect
rect
=
option
.
rect
.
adjusted
(
b_arrow
?
15
+
margin
:
margin
,
0
,
-
margin
,
0
);
QString
str
(
text
()
);
/* This check is absurd, but either it is not done properly inside elidedText(),
or boundingRect() is wrong */
if
(
rect
.
width
()
<
fontMetrics
().
boundingRect
(
text
()
).
width
()
)
str
=
fontMetrics
().
elidedText
(
text
(),
Qt
::
ElideRight
,
rect
.
width
()
);
p
.
drawText
(
rect
,
Qt
::
AlignVCenter
|
Qt
::
AlignLeft
,
str
);
if
(
b_arrow
)
{
...
...
@@ -540,7 +545,9 @@ QSize LocationButton::sizeHint() const
{
int
frameWidth
=
style
()
->
pixelMetric
(
QStyle
::
PM_DefaultFrameWidth
,
0
,
this
);
QSize
s
(
fontMetrics
().
boundingRect
(
text
()
).
size
()
);
s
.
setWidth
(
s
.
width
()
+
(
2
*
frameWidth
)
+
(
2
*
PADDING
)
+
(
b_arrow
?
15
:
0
)
);
/* Add two pixels to width: font metrics are buggy, if you pass text through elidation
with exactly the width of its bounding rect, sometimes it still elides */
s
.
setWidth
(
s
.
width
()
+
(
2
*
frameWidth
)
+
(
2
*
PADDING
)
+
(
b_arrow
?
15
:
0
)
+
2
);
s
.
setHeight
(
QPushButton
::
sizeHint
().
height
()
);
return
s
;
}
...
...
modules/gui/qt4/util/customwidgets.cpp
View file @
05d736ea
...
...
@@ -208,6 +208,25 @@ void SearchLineEdit::paintEvent( QPaintEvent *event )
painter
.
drawText
(
rect
,
Qt
::
AlignLeft
|
Qt
::
AlignVCenter
,
qtr
(
I_PL_FILTER
)
);
}
QVLCElidingLabel
::
QVLCElidingLabel
(
const
QString
&
s
,
Qt
::
TextElideMode
mode
,
QWidget
*
parent
)
:
elideMode
(
mode
),
QLabel
(
s
,
parent
)
{
}
void
QVLCElidingLabel
::
setElideMode
(
Qt
::
TextElideMode
mode
)
{
elideMode
=
mode
;
repaint
();
}
void
QVLCElidingLabel
::
paintEvent
(
QPaintEvent
*
event
)
{
QPainter
p
(
this
);
int
space
=
frameWidth
()
+
margin
();
QRect
r
=
rect
().
adjusted
(
space
,
space
,
-
space
,
-
space
);
p
.
drawText
(
r
,
fontMetrics
().
elidedText
(
text
(),
elideMode
,
r
.
width
()
),
alignment
()
);
}
/***************************************************************************
* Hotkeys converters
***************************************************************************/
...
...
modules/gui/qt4/util/customwidgets.hpp
View file @
05d736ea
...
...
@@ -29,6 +29,7 @@
#include <QLineEdit>
#include <QPushButton>
#include <QLabel>
/**
This class provides a QLineEdit which contains a greyed-out hinting
...
...
@@ -67,8 +68,6 @@ protected:
virtual
void
paintEvent
(
QPaintEvent
*
event
);
};
class
QLabel
;
class
SearchLineEdit
:
public
QLineEdit
{
Q_OBJECT
...
...
@@ -92,6 +91,18 @@ private slots:
void
updateText
(
const
QString
&
);
};
class
QVLCElidingLabel
:
public
QLabel
{
public:
QVLCElidingLabel
(
const
QString
&
s
=
QString
(),
Qt
::
TextElideMode
mode
=
Qt
::
ElideRight
,
QWidget
*
parent
=
NULL
);
void
setElideMode
(
Qt
::
TextElideMode
);
private:
void
paintEvent
(
QPaintEvent
*
event
);
Qt
::
TextElideMode
elideMode
;
};
/* VLC Key/Wheel hotkeys interactions */
class
QKeyEvent
;
...
...
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