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
96929b1b
Commit
96929b1b
authored
Oct 22, 2010
by
Jean-Baptiste Kempf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt: change the LocationBar Class file
parent
d3803618
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
230 additions
and
224 deletions
+230
-224
modules/gui/qt4/components/playlist/playlist.cpp
modules/gui/qt4/components/playlist/playlist.cpp
+190
-0
modules/gui/qt4/components/playlist/playlist.hpp
modules/gui/qt4/components/playlist/playlist.hpp
+40
-0
modules/gui/qt4/components/playlist/standardpanel.cpp
modules/gui/qt4/components/playlist/standardpanel.cpp
+0
-186
modules/gui/qt4/components/playlist/standardpanel.hpp
modules/gui/qt4/components/playlist/standardpanel.hpp
+0
-38
No files found.
modules/gui/qt4/components/playlist/playlist.cpp
View file @
96929b1b
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
#include "components/playlist/standardpanel.hpp"
#include "components/playlist/standardpanel.hpp"
#include "components/playlist/selector.hpp"
#include "components/playlist/selector.hpp"
#include "components/playlist/playlist.hpp"
#include "components/playlist/playlist.hpp"
#include "components/playlist/playlist_model.hpp"
#include "input_manager.hpp"
/* art signal */
#include "input_manager.hpp"
/* art signal */
#include "main_interface.hpp"
/* DropEvent TODO remove this*/
#include "main_interface.hpp"
/* DropEvent TODO remove this*/
...
@@ -160,3 +161,192 @@ void PlaylistWidget::forceShow()
...
@@ -160,3 +161,192 @@ void PlaylistWidget::forceShow()
rightPanel
->
show
();
rightPanel
->
show
();
updateGeometry
();
updateGeometry
();
}
}
#include <QSignalMapper>
#include <QMenu>
#include <QPainter>
LocationBar
::
LocationBar
(
PLModel
*
m
)
{
model
=
m
;
mapper
=
new
QSignalMapper
(
this
);
CONNECT
(
mapper
,
mapped
(
int
),
this
,
invoke
(
int
)
);
btnMore
=
new
LocationButton
(
"..."
,
false
,
true
,
this
);
menuMore
=
new
QMenu
(
this
);
btnMore
->
setMenu
(
menuMore
);
}
void
LocationBar
::
setIndex
(
const
QModelIndex
&
index
)
{
qDeleteAll
(
buttons
);
buttons
.
clear
();
qDeleteAll
(
actions
);
actions
.
clear
();
QModelIndex
i
=
index
;
bool
first
=
true
;
while
(
true
)
{
PLItem
*
item
=
model
->
getItem
(
i
);
char
*
fb_name
=
input_item_GetTitleFbName
(
item
->
inputItem
()
);
QString
text
=
qfu
(
fb_name
);
free
(
fb_name
);
QAbstractButton
*
btn
=
new
LocationButton
(
text
,
first
,
!
first
,
this
);
btn
->
setSizePolicy
(
QSizePolicy
::
Maximum
,
QSizePolicy
::
Fixed
);
buttons
.
append
(
btn
);
QAction
*
action
=
new
QAction
(
text
,
this
);
actions
.
append
(
action
);
CONNECT
(
btn
,
clicked
(),
action
,
trigger
()
);
mapper
->
setMapping
(
action
,
item
->
id
()
);
CONNECT
(
action
,
triggered
(),
mapper
,
map
()
);
first
=
false
;
if
(
i
.
isValid
()
)
i
=
i
.
parent
();
else
break
;
}
QString
prefix
;
for
(
int
a
=
actions
.
count
()
-
1
;
a
>=
0
;
a
--
)
{
actions
[
a
]
->
setText
(
prefix
+
actions
[
a
]
->
text
()
);
prefix
+=
QString
(
" "
);
}
if
(
isVisible
()
)
layOut
(
size
()
);
}
void
LocationBar
::
setRootIndex
()
{
setIndex
(
QModelIndex
()
);
}
void
LocationBar
::
invoke
(
int
i_id
)
{
QModelIndex
index
=
model
->
index
(
i_id
,
0
);
emit
invoked
(
index
);
}
void
LocationBar
::
layOut
(
const
QSize
&
size
)
{
menuMore
->
clear
();
widths
.
clear
();
int
count
=
buttons
.
count
();
int
totalWidth
=
0
;
for
(
int
i
=
0
;
i
<
count
;
i
++
)
{
int
w
=
buttons
[
i
]
->
sizeHint
().
width
();
widths
.
append
(
w
);
totalWidth
+=
w
;
if
(
totalWidth
>
size
.
width
()
)
break
;
}
int
x
=
0
;
int
shown
=
widths
.
count
();
if
(
totalWidth
>
size
.
width
()
&&
count
>
1
)
{
QSize
sz
=
btnMore
->
sizeHint
();
btnMore
->
setGeometry
(
0
,
0
,
sz
.
width
(),
size
.
height
()
);
btnMore
->
show
();
x
=
sz
.
width
();
totalWidth
+=
x
;
}
else
{
btnMore
->
hide
();
}
for
(
int
i
=
count
-
1
;
i
>=
0
;
i
--
)
{
if
(
totalWidth
<=
size
.
width
()
||
i
==
0
)
{
buttons
[
i
]
->
setGeometry
(
x
,
0
,
qMin
(
size
.
width
()
-
x
,
widths
[
i
]
),
size
.
height
()
);
buttons
[
i
]
->
show
();
x
+=
widths
[
i
];
totalWidth
-=
widths
[
i
];
}
else
{
menuMore
->
addAction
(
actions
[
i
]
);
buttons
[
i
]
->
hide
();
if
(
i
<
shown
)
totalWidth
-=
widths
[
i
];
}
}
}
void
LocationBar
::
resizeEvent
(
QResizeEvent
*
event
)
{
layOut
(
event
->
size
()
);
}
QSize
LocationBar
::
sizeHint
()
const
{
return
btnMore
->
sizeHint
();
}
LocationButton
::
LocationButton
(
const
QString
&
text
,
bool
bold
,
bool
arrow
,
QWidget
*
parent
)
:
b_arrow
(
arrow
),
QPushButton
(
parent
)
{
QFont
font
;
font
.
setBold
(
bold
);
setFont
(
font
);
setText
(
text
);
}
#define PADDING 4
void
LocationButton
::
paintEvent
(
QPaintEvent
*
event
)
{
QStyleOptionButton
option
;
option
.
initFrom
(
this
);
option
.
state
|=
QStyle
::
State_Enabled
;
QPainter
p
(
this
);
if
(
underMouse
()
)
{
p
.
save
();
p
.
setRenderHint
(
QPainter
::
Antialiasing
,
true
);
QColor
c
=
palette
().
color
(
QPalette
::
Highlight
);
p
.
setPen
(
c
);
p
.
setBrush
(
c
.
lighter
(
150
)
);
p
.
setOpacity
(
0.2
);
p
.
drawRoundedRect
(
option
.
rect
.
adjusted
(
0
,
2
,
0
,
-
2
),
5
,
5
);
p
.
restore
();
}
QRect
r
=
option
.
rect
.
adjusted
(
PADDING
,
0
,
-
PADDING
-
(
b_arrow
?
10
:
0
),
0
);
QString
str
(
text
()
);
/* This check is absurd, but either it is not done properly inside elidedText(),
or boundingRect() is wrong */
if
(
r
.
width
()
<
fontMetrics
().
boundingRect
(
text
()
).
width
()
)
str
=
fontMetrics
().
elidedText
(
text
(),
Qt
::
ElideRight
,
r
.
width
()
);
p
.
drawText
(
r
,
Qt
::
AlignVCenter
|
Qt
::
AlignLeft
,
str
);
if
(
b_arrow
)
{
option
.
rect
.
setWidth
(
10
);
option
.
rect
.
moveRight
(
rect
().
right
()
);
style
()
->
drawPrimitive
(
QStyle
::
PE_IndicatorArrowRight
,
&
option
,
&
p
);
}
}
QSize
LocationButton
::
sizeHint
()
const
{
QSize
s
(
fontMetrics
().
boundingRect
(
text
()
).
size
()
);
/* 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
*
PADDING
)
+
(
b_arrow
?
10
:
0
)
+
2
);
s
.
setHeight
(
s
.
height
()
+
2
*
PADDING
);
return
s
;
}
#undef PADDING
modules/gui/qt4/components/playlist/playlist.hpp
View file @
96929b1b
...
@@ -77,4 +77,44 @@ protected:
...
@@ -77,4 +77,44 @@ protected:
};
};
class
LocationButton
:
public
QPushButton
{
public:
LocationButton
(
const
QString
&
,
bool
bold
,
bool
arrow
,
QWidget
*
parent
=
NULL
);
QSize
sizeHint
()
const
;
private:
void
paintEvent
(
QPaintEvent
*
event
);
QFontMetrics
*
metrics
;
bool
b_arrow
;
};
class
PLModel
;
class
LocationBar
:
public
QWidget
{
Q_OBJECT
public:
LocationBar
(
PLModel
*
);
void
setIndex
(
const
QModelIndex
&
);
QSize
sizeHint
()
const
;
signals:
void
invoked
(
const
QModelIndex
&
);
public
slots
:
void
setRootIndex
();
private
slots
:
void
invoke
(
int
i_item_id
);
private:
void
layOut
(
const
QSize
&
size
);
void
resizeEvent
(
QResizeEvent
*
event
);
PLModel
*
model
;
QSignalMapper
*
mapper
;
QHBoxLayout
*
box
;
QList
<
QWidget
*>
buttons
;
QList
<
QAction
*>
actions
;
LocationButton
*
btnMore
;
QMenu
*
menuMore
;
QList
<
int
>
widths
;
};
#endif
#endif
modules/gui/qt4/components/playlist/standardpanel.cpp
View file @
96929b1b
...
@@ -43,11 +43,9 @@
...
@@ -43,11 +43,9 @@
#include <QModelIndexList>
#include <QModelIndexList>
#include <QLabel>
#include <QLabel>
#include <QMenu>
#include <QMenu>
#include <QSignalMapper>
#include <QWheelEvent>
#include <QWheelEvent>
#include <QToolButton>
#include <QToolButton>
#include <QFontMetrics>
#include <QFontMetrics>
#include <QPainter>
#include <QStackedLayout>
#include <QStackedLayout>
#include <assert.h>
#include <assert.h>
...
@@ -461,187 +459,3 @@ void StandardPLPanel::browseInto( input_item_t *p_input )
...
@@ -461,187 +459,3 @@ void StandardPLPanel::browseInto( input_item_t *p_input )
}
}
LocationBar
::
LocationBar
(
PLModel
*
m
)
{
model
=
m
;
mapper
=
new
QSignalMapper
(
this
);
CONNECT
(
mapper
,
mapped
(
int
),
this
,
invoke
(
int
)
);
btnMore
=
new
LocationButton
(
"..."
,
false
,
true
,
this
);
menuMore
=
new
QMenu
(
this
);
btnMore
->
setMenu
(
menuMore
);
}
void
LocationBar
::
setIndex
(
const
QModelIndex
&
index
)
{
qDeleteAll
(
buttons
);
buttons
.
clear
();
qDeleteAll
(
actions
);
actions
.
clear
();
QModelIndex
i
=
index
;
bool
first
=
true
;
while
(
true
)
{
PLItem
*
item
=
model
->
getItem
(
i
);
char
*
fb_name
=
input_item_GetTitleFbName
(
item
->
inputItem
()
);
QString
text
=
qfu
(
fb_name
);
free
(
fb_name
);
QAbstractButton
*
btn
=
new
LocationButton
(
text
,
first
,
!
first
,
this
);
btn
->
setSizePolicy
(
QSizePolicy
::
Maximum
,
QSizePolicy
::
Fixed
);
buttons
.
append
(
btn
);
QAction
*
action
=
new
QAction
(
text
,
this
);
actions
.
append
(
action
);
CONNECT
(
btn
,
clicked
(),
action
,
trigger
()
);
mapper
->
setMapping
(
action
,
item
->
id
()
);
CONNECT
(
action
,
triggered
(),
mapper
,
map
()
);
first
=
false
;
if
(
i
.
isValid
()
)
i
=
i
.
parent
();
else
break
;
}
QString
prefix
;
for
(
int
a
=
actions
.
count
()
-
1
;
a
>=
0
;
a
--
)
{
actions
[
a
]
->
setText
(
prefix
+
actions
[
a
]
->
text
()
);
prefix
+=
QString
(
" "
);
}
if
(
isVisible
()
)
layOut
(
size
()
);
}
void
LocationBar
::
setRootIndex
()
{
setIndex
(
QModelIndex
()
);
}
void
LocationBar
::
invoke
(
int
i_id
)
{
QModelIndex
index
=
model
->
index
(
i_id
,
0
);
emit
invoked
(
index
);
}
void
LocationBar
::
layOut
(
const
QSize
&
size
)
{
menuMore
->
clear
();
widths
.
clear
();
int
count
=
buttons
.
count
();
int
totalWidth
=
0
;
for
(
int
i
=
0
;
i
<
count
;
i
++
)
{
int
w
=
buttons
[
i
]
->
sizeHint
().
width
();
widths
.
append
(
w
);
totalWidth
+=
w
;
if
(
totalWidth
>
size
.
width
()
)
break
;
}
int
x
=
0
;
int
shown
=
widths
.
count
();
if
(
totalWidth
>
size
.
width
()
&&
count
>
1
)
{
QSize
sz
=
btnMore
->
sizeHint
();
btnMore
->
setGeometry
(
0
,
0
,
sz
.
width
(),
size
.
height
()
);
btnMore
->
show
();
x
=
sz
.
width
();
totalWidth
+=
x
;
}
else
{
btnMore
->
hide
();
}
for
(
int
i
=
count
-
1
;
i
>=
0
;
i
--
)
{
if
(
totalWidth
<=
size
.
width
()
||
i
==
0
)
{
buttons
[
i
]
->
setGeometry
(
x
,
0
,
qMin
(
size
.
width
()
-
x
,
widths
[
i
]
),
size
.
height
()
);
buttons
[
i
]
->
show
();
x
+=
widths
[
i
];
totalWidth
-=
widths
[
i
];
}
else
{
menuMore
->
addAction
(
actions
[
i
]
);
buttons
[
i
]
->
hide
();
if
(
i
<
shown
)
totalWidth
-=
widths
[
i
];
}
}
}
void
LocationBar
::
resizeEvent
(
QResizeEvent
*
event
)
{
layOut
(
event
->
size
()
);
}
QSize
LocationBar
::
sizeHint
()
const
{
return
btnMore
->
sizeHint
();
}
LocationButton
::
LocationButton
(
const
QString
&
text
,
bool
bold
,
bool
arrow
,
QWidget
*
parent
)
:
b_arrow
(
arrow
),
QPushButton
(
parent
)
{
QFont
font
;
font
.
setBold
(
bold
);
setFont
(
font
);
setText
(
text
);
}
#define PADDING 4
void
LocationButton
::
paintEvent
(
QPaintEvent
*
event
)
{
QStyleOptionButton
option
;
option
.
initFrom
(
this
);
option
.
state
|=
QStyle
::
State_Enabled
;
QPainter
p
(
this
);
if
(
underMouse
()
)
{
p
.
save
();
p
.
setRenderHint
(
QPainter
::
Antialiasing
,
true
);
QColor
c
=
palette
().
color
(
QPalette
::
Highlight
);
p
.
setPen
(
c
);
p
.
setBrush
(
c
.
lighter
(
150
)
);
p
.
setOpacity
(
0.2
);
p
.
drawRoundedRect
(
option
.
rect
.
adjusted
(
0
,
2
,
0
,
-
2
),
5
,
5
);
p
.
restore
();
}
QRect
r
=
option
.
rect
.
adjusted
(
PADDING
,
0
,
-
PADDING
-
(
b_arrow
?
10
:
0
),
0
);
QString
str
(
text
()
);
/* This check is absurd, but either it is not done properly inside elidedText(),
or boundingRect() is wrong */
if
(
r
.
width
()
<
fontMetrics
().
boundingRect
(
text
()
).
width
()
)
str
=
fontMetrics
().
elidedText
(
text
(),
Qt
::
ElideRight
,
r
.
width
()
);
p
.
drawText
(
r
,
Qt
::
AlignVCenter
|
Qt
::
AlignLeft
,
str
);
if
(
b_arrow
)
{
option
.
rect
.
setWidth
(
10
);
option
.
rect
.
moveRight
(
rect
().
right
()
);
style
()
->
drawPrimitive
(
QStyle
::
PE_IndicatorArrowRight
,
&
option
,
&
p
);
}
}
QSize
LocationButton
::
sizeHint
()
const
{
QSize
s
(
fontMetrics
().
boundingRect
(
text
()
).
size
()
);
/* 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
*
PADDING
)
+
(
b_arrow
?
10
:
0
)
+
2
);
s
.
setHeight
(
s
.
height
()
+
2
*
PADDING
);
return
s
;
}
#undef PADDING
modules/gui/qt4/components/playlist/standardpanel.hpp
View file @
96929b1b
...
@@ -120,42 +120,4 @@ private slots:
...
@@ -120,42 +120,4 @@ private slots:
void
browseInto
(
input_item_t
*
);
void
browseInto
(
input_item_t
*
);
};
};
class
LocationButton
:
public
QPushButton
{
public:
LocationButton
(
const
QString
&
,
bool
bold
,
bool
arrow
,
QWidget
*
parent
=
NULL
);
QSize
sizeHint
()
const
;
private:
void
paintEvent
(
QPaintEvent
*
event
);
QFontMetrics
*
metrics
;
bool
b_arrow
;
};
class
LocationBar
:
public
QWidget
{
Q_OBJECT
public:
LocationBar
(
PLModel
*
);
void
setIndex
(
const
QModelIndex
&
);
QSize
sizeHint
()
const
;
signals:
void
invoked
(
const
QModelIndex
&
);
public
slots
:
void
setRootIndex
();
private
slots
:
void
invoke
(
int
i_item_id
);
private:
void
layOut
(
const
QSize
&
size
);
void
resizeEvent
(
QResizeEvent
*
event
);
PLModel
*
model
;
QSignalMapper
*
mapper
;
QHBoxLayout
*
box
;
QList
<
QWidget
*>
buttons
;
QList
<
QAction
*>
actions
;
LocationButton
*
btnMore
;
QMenu
*
menuMore
;
QList
<
int
>
widths
;
};
#endif
#endif
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