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
fbb78845
Commit
fbb78845
authored
Jan 27, 2009
by
Jean-Philippe Andre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt: accelerate the menus
Avoid string comparisons. Avoid foreach.
parent
56988959
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
22 deletions
+24
-22
modules/gui/qt4/menus.cpp
modules/gui/qt4/menus.cpp
+24
-22
No files found.
modules/gui/qt4/menus.cpp
View file @
fbb78845
...
@@ -105,18 +105,18 @@ void addDPStaticEntry( QMenu *menu,
...
@@ -105,18 +105,18 @@ void addDPStaticEntry( QMenu *menu,
else
else
action
=
menu
->
addAction
(
text
,
THEDP
,
member
);
action
=
menu
->
addAction
(
text
,
THEDP
,
member
);
}
}
action
->
setData
(
"_static_"
);
action
->
setData
(
true
);
}
}
void
EnableDPStaticEntries
(
QMenu
*
menu
,
bool
enable
=
true
)
void
EnableDPStaticEntries
(
QMenu
*
menu
,
bool
enable
=
true
)
{
{
if
(
!
menu
)
return
;
if
(
!
menu
)
return
;
Q
Action
*
action
;
Q
List
<
QAction
*
>
actions
=
menu
->
actions
()
;
for
each
(
action
,
menu
->
actions
()
)
for
(
int
i
=
0
;
i
<
actions
.
size
();
++
i
)
{
{
if
(
action
->
data
().
toString
()
==
"_static_"
)
if
(
action
s
[
i
]
->
data
().
toBool
()
)
action
->
setEnabled
(
enable
);
action
s
[
i
]
->
setEnabled
(
enable
);
}
}
}
}
...
@@ -126,13 +126,13 @@ void EnableDPStaticEntries( QMenu *menu, bool enable = true )
...
@@ -126,13 +126,13 @@ void EnableDPStaticEntries( QMenu *menu, bool enable = true )
int
DeleteNonStaticEntries
(
QMenu
*
menu
)
int
DeleteNonStaticEntries
(
QMenu
*
menu
)
{
{
int
i_ret
=
0
;
int
i_ret
=
0
;
QAction
*
action
;
if
(
!
menu
)
if
(
!
menu
)
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
foreach
(
action
,
menu
->
actions
()
)
QList
<
QAction
*
>
actions
=
menu
->
actions
();
for
(
int
i
=
0
;
i
<
actions
.
size
();
++
i
)
{
{
if
(
action
->
data
().
toString
()
!=
"_static_"
)
if
(
!
actions
[
i
]
->
data
().
toBool
()
)
delete
action
;
delete
action
s
[
i
]
;
else
else
i_ret
++
;
i_ret
++
;
}
}
...
@@ -245,11 +245,11 @@ static int AudioAutoMenuBuilder( aout_instance_t *p_object,
...
@@ -245,11 +245,11 @@ static int AudioAutoMenuBuilder( aout_instance_t *p_object,
static
QAction
*
FindActionWithVar
(
QMenu
*
menu
,
const
char
*
psz_var
)
static
QAction
*
FindActionWithVar
(
QMenu
*
menu
,
const
char
*
psz_var
)
{
{
Q
Action
*
action
;
Q
List
<
QAction
*
>
actions
=
menu
->
actions
()
;
for
each
(
action
,
menu
->
actions
()
)
for
(
int
i
=
0
;
i
<
actions
.
size
();
++
i
)
{
{
if
(
action
->
data
().
toString
()
==
psz_var
)
if
(
action
s
[
i
]
->
data
().
toString
()
==
psz_var
)
return
action
;
return
action
s
[
i
]
;
}
}
return
NULL
;
return
NULL
;
}
}
...
@@ -405,10 +405,10 @@ QMenu *QVLCMenu::ViewMenu( intf_thread_t *p_intf,
...
@@ -405,10 +405,10 @@ QMenu *QVLCMenu::ViewMenu( intf_thread_t *p_intf,
act
=
menu
->
addAction
(
QIcon
(
":/playlist_menu"
),
act
=
menu
->
addAction
(
QIcon
(
":/playlist_menu"
),
qtr
(
"Play&list"
),
mi
,
qtr
(
"Play&list"
),
mi
,
SLOT
(
togglePlaylist
()
),
qtr
(
"Ctrl+L"
)
);
SLOT
(
togglePlaylist
()
),
qtr
(
"Ctrl+L"
)
);
act
->
setData
(
"_static_"
);
act
->
setData
(
true
);
}
}
act
=
menu
->
addMenu
(
SDMenu
(
p_intf
)
);
act
=
menu
->
addMenu
(
SDMenu
(
p_intf
)
);
act
->
setData
(
"_static_"
);
act
->
setData
(
true
);
/*menu->addSeparator();
/*menu->addSeparator();
menu->addAction( qtr( "Undock from Interface" ), mi,
menu->addAction( qtr( "Undock from Interface" ), mi,
SLOT( undockPlaylist() ), qtr( "Ctrl+U" ) );*/
SLOT( undockPlaylist() ), qtr( "Ctrl+U" ) );*/
...
@@ -430,7 +430,7 @@ QMenu *QVLCMenu::ViewMenu( intf_thread_t *p_intf,
...
@@ -430,7 +430,7 @@ QMenu *QVLCMenu::ViewMenu( intf_thread_t *p_intf,
QAction
*
action
=
menu
->
addAction
(
qtr
(
"Mi&nimal View"
),
mi
,
QAction
*
action
=
menu
->
addAction
(
qtr
(
"Mi&nimal View"
),
mi
,
SLOT
(
toggleMinimalView
()
),
qtr
(
"Ctrl+H"
)
);
SLOT
(
toggleMinimalView
()
),
qtr
(
"Ctrl+H"
)
);
action
->
setCheckable
(
true
);
action
->
setCheckable
(
true
);
action
->
setData
(
"_static_"
);
action
->
setData
(
true
);
if
(
mi
->
getControlsVisibilityStatus
()
&
CONTROLS_VISIBLE
)
if
(
mi
->
getControlsVisibilityStatus
()
&
CONTROLS_VISIBLE
)
action
->
setChecked
(
true
);
action
->
setChecked
(
true
);
minimalViewAction
=
action
;
/* HACK for minimalView */
minimalViewAction
=
action
;
/* HACK for minimalView */
...
@@ -439,13 +439,13 @@ QMenu *QVLCMenu::ViewMenu( intf_thread_t *p_intf,
...
@@ -439,13 +439,13 @@ QMenu *QVLCMenu::ViewMenu( intf_thread_t *p_intf,
action
=
menu
->
addAction
(
qtr
(
"&Fullscreen Interface"
),
mi
,
action
=
menu
->
addAction
(
qtr
(
"&Fullscreen Interface"
),
mi
,
SLOT
(
toggleFullScreen
()
),
QString
(
"F11"
)
);
SLOT
(
toggleFullScreen
()
),
QString
(
"F11"
)
);
action
->
setCheckable
(
true
);
action
->
setCheckable
(
true
);
action
->
setData
(
"_static_"
);
action
->
setData
(
true
);
/* Advanced Controls */
/* Advanced Controls */
action
=
menu
->
addAction
(
qtr
(
"&Advanced Controls"
),
mi
,
action
=
menu
->
addAction
(
qtr
(
"&Advanced Controls"
),
mi
,
SLOT
(
toggleAdvanced
()
)
);
SLOT
(
toggleAdvanced
()
)
);
action
->
setCheckable
(
true
);
action
->
setCheckable
(
true
);
action
->
setData
(
"_static_"
);
action
->
setData
(
true
);
if
(
mi
->
getControlsVisibilityStatus
()
&
CONTROLS_ADVANCED
)
if
(
mi
->
getControlsVisibilityStatus
()
&
CONTROLS_ADVANCED
)
action
->
setChecked
(
true
);
action
->
setChecked
(
true
);
#if 0 /* For Visualisations. Not yet working */
#if 0 /* For Visualisations. Not yet working */
...
@@ -500,6 +500,7 @@ QMenu *QVLCMenu::AudioMenu( intf_thread_t *p_intf, QMenu * current )
...
@@ -500,6 +500,7 @@ QMenu *QVLCMenu::AudioMenu( intf_thread_t *p_intf, QMenu * current )
if
(
p_input
)
if
(
p_input
)
vlc_object_hold
(
p_input
);
vlc_object_hold
(
p_input
);
p_aout
=
THEMIM
->
getAout
();
p_aout
=
THEMIM
->
getAout
();
EnableDPStaticEntries
(
current
,
(
p_aout
!=
NULL
)
);
if
(
p_aout
)
if
(
p_aout
)
{
{
AudioAutoMenuBuilder
(
p_aout
,
p_input
,
objects
,
varnames
);
AudioAutoMenuBuilder
(
p_aout
,
p_input
,
objects
,
varnames
);
...
@@ -554,6 +555,7 @@ QMenu *QVLCMenu::VideoMenu( intf_thread_t *p_intf, QMenu *current )
...
@@ -554,6 +555,7 @@ QMenu *QVLCMenu::VideoMenu( intf_thread_t *p_intf, QMenu *current )
vlc_object_hold
(
p_input
);
vlc_object_hold
(
p_input
);
p_vout
=
THEMIM
->
getVout
();
p_vout
=
THEMIM
->
getVout
();
EnableDPStaticEntries
(
current
,
(
p_vout
!=
NULL
)
);
if
(
p_vout
)
if
(
p_vout
)
{
{
VideoAutoMenuBuilder
(
p_vout
,
p_input
,
objects
,
varnames
);
VideoAutoMenuBuilder
(
p_vout
,
p_input
,
objects
,
varnames
);
...
@@ -989,11 +991,11 @@ QMenu * QVLCMenu::Populate( intf_thread_t *p_intf,
...
@@ -989,11 +991,11 @@ QMenu * QVLCMenu::Populate( intf_thread_t *p_intf,
if
(
!
menu
)
menu
=
new
QMenu
();
if
(
!
menu
)
menu
=
new
QMenu
();
/* Disable all non static entries */
/* Disable all non static entries */
Q
Action
*
p_action
;
Q
List
<
QAction
*
>
actions
=
menu
->
actions
()
;
for
each
(
p_action
,
menu
->
actions
()
)
for
(
int
i
=
0
;
i
<
actions
.
size
();
++
i
)
{
{
if
(
p_action
->
data
().
toString
()
!=
"_static_"
)
if
(
!
actions
[
i
]
->
data
().
toBool
()
)
p_action
->
setEnabled
(
false
);
actions
[
i
]
->
setEnabled
(
false
);
}
}
currentGroup
=
NULL
;
currentGroup
=
NULL
;
...
...
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