Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
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-1.1
Commits
72a25f19
Commit
72a25f19
authored
Nov 05, 2007
by
Jean-Baptiste Kempf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt4 - SPrefs, doing funny things with qobject_cast to improve a bit the code...
parent
b8836621
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
104 additions
and
82 deletions
+104
-82
modules/gui/qt4/components/preferences_widgets.cpp
modules/gui/qt4/components/preferences_widgets.cpp
+1
-0
modules/gui/qt4/components/simple_preferences.cpp
modules/gui/qt4/components/simple_preferences.cpp
+82
-71
modules/gui/qt4/components/simple_preferences.hpp
modules/gui/qt4/components/simple_preferences.hpp
+21
-11
No files found.
modules/gui/qt4/components/preferences_widgets.cpp
View file @
72a25f19
...
@@ -44,6 +44,7 @@
...
@@ -44,6 +44,7 @@
#include <QGroupBox>
#include <QGroupBox>
#include <QTreeWidgetItem>
#include <QTreeWidgetItem>
#include <QSignalMapper>
#include <QSignalMapper>
QString
formatTooltip
(
const
QString
&
tooltip
)
QString
formatTooltip
(
const
QString
&
tooltip
)
{
{
QString
formatted
=
QString
formatted
=
...
...
modules/gui/qt4/components/simple_preferences.cpp
View file @
72a25f19
...
@@ -26,12 +26,7 @@
...
@@ -26,12 +26,7 @@
#include "components/simple_preferences.hpp"
#include "components/simple_preferences.hpp"
#include "components/preferences_widgets.hpp"
#include "components/preferences_widgets.hpp"
#include "ui/sprefs_input.h"
#include "ui/sprefs_audio.h"
#include "ui/sprefs_video.h"
#include "ui/sprefs_subtitles.h"
#include "ui/sprefs_hotkeys.h"
#include "ui/sprefs_interface.h"
#include <vlc_config_cat.h>
#include <vlc_config_cat.h>
#include <vlc_configuration.h>
#include <vlc_configuration.h>
...
@@ -204,6 +199,19 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
...
@@ -204,6 +199,19 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
CONFIG_GENERIC
(
"audio"
,
Bool
,
NULL
,
enableAudio
);
CONFIG_GENERIC
(
"audio"
,
Bool
,
NULL
,
enableAudio
);
/* and hide if necessary */
#ifdef WIN32
ui
.
OSSControl
->
hide
();
ui
.
alsaControl
->
hide
();
#else
ui
.
DirectXControl
->
hide
();
#endif
ui
.
lastfm_user_edit
->
hide
();
ui
.
lastfm_user_label
->
hide
();
ui
.
lastfm_pass_edit
->
hide
();
ui
.
lastfm_pass_label
->
hide
();
/* General Audio Options */
/* General Audio Options */
CONFIG_GENERIC_NO_BOOL
(
"volume"
,
IntegerRangeSlider
,
NULL
,
CONFIG_GENERIC_NO_BOOL
(
"volume"
,
IntegerRangeSlider
,
NULL
,
defaultVolume
);
defaultVolume
);
...
@@ -225,7 +233,7 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
...
@@ -225,7 +233,7 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
CONNECT
(
ui
.
outputModule
,
currentIndexChanged
(
int
),
this
,
CONNECT
(
ui
.
outputModule
,
currentIndexChanged
(
int
),
this
,
updateAudioOptions
(
int
)
);
updateAudioOptions
(
int
)
);
audioOutput
=
ui
.
outputModule
;
//TODO: use modules_Exists
//TODO: use modules_Exists
#ifndef WIN32
#ifndef WIN32
...
@@ -239,30 +247,20 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
...
@@ -239,30 +247,20 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
// File exists everywhere
// File exists everywhere
CONFIG_GENERIC_FILE
(
"audiofile-file"
,
File
,
ui
.
fileLabel
,
CONFIG_GENERIC_FILE
(
"audiofile-file"
,
File
,
ui
.
fileLabel
,
fileName
,
fileBrowseButton
);
fileName
,
fileBrowseButton
);
alsa_options
=
ui
.
alsaControl
;
oss_options
=
ui
.
OSSControl
;
directx_options
=
ui
.
DirectXControl
;
file_options
=
ui
.
fileControl
;
/* and hide if necessary */
#ifdef WIN32
oss_options
->
hide
();
alsa_options
->
hide
();
#else
directx_options
->
hide
();
#endif
updateAudioOptions
(
audioOutput
->
currentIndex
()
);
optionWidgets
.
append
(
ui
.
alsaControl
);
optionWidgets
.
append
(
ui
.
OSSControl
);
optionWidgets
.
append
(
ui
.
DirectXControl
);
optionWidgets
.
append
(
ui
.
fileControl
);
optionWidgets
.
append
(
ui
.
outputModule
);
optionWidgets
.
append
(
ui
.
volNormBox
);
updateAudioOptions
(
ui
.
outputModule
->
currentIndex
()
);
/* LastFM */
/* LastFM */
CONFIG_GENERIC
(
"lastfm-username"
,
String
,
ui
.
lastfm_user_label
,
CONFIG_GENERIC
(
"lastfm-username"
,
String
,
ui
.
lastfm_user_label
,
lastfm_user_edit
);
lastfm_user_edit
);
CONFIG_GENERIC
(
"lastfm-password"
,
String
,
ui
.
lastfm_pass_label
,
CONFIG_GENERIC
(
"lastfm-password"
,
String
,
ui
.
lastfm_pass_label
,
lastfm_pass_edit
);
lastfm_pass_edit
);
ui
.
lastfm_user_edit
->
hide
();
ui
.
lastfm_user_label
->
hide
();
ui
.
lastfm_pass_edit
->
hide
();
ui
.
lastfm_pass_label
->
hide
();
if
(
config_ExistIntf
(
VLC_OBJECT
(
p_intf
),
"audioscrobbler"
)
)
if
(
config_ExistIntf
(
VLC_OBJECT
(
p_intf
),
"audioscrobbler"
)
)
ui
.
lastfm
->
setCheckState
(
Qt
::
Checked
);
ui
.
lastfm
->
setCheckState
(
Qt
::
Checked
);
...
@@ -272,8 +270,9 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
...
@@ -272,8 +270,9 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
lastfm_Changed
(
int
)
);
lastfm_Changed
(
int
)
);
/* Normalizer */
/* Normalizer */
normalizerBox
=
ui
.
volNormBox
;
CONNECT
(
ui
.
volNormBox
,
toggled
(
bool
),
ui
.
volNormSpin
,
setEnabled
(
bool
)
);
CONNECT
(
ui
.
volNormBox
,
toggled
(
bool
),
ui
.
volNormSpin
,
setEnabled
(
bool
)
);
qs_filter
=
qfu
(
config_GetPsz
(
p_intf
,
"audio-filter"
)
);
qs_filter
=
qfu
(
config_GetPsz
(
p_intf
,
"audio-filter"
)
);
bool
b_normalizer
=
(
qs_filter
.
contains
(
"volnorm"
)
);
bool
b_normalizer
=
(
qs_filter
.
contains
(
"volnorm"
)
);
{
{
...
@@ -285,7 +284,8 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
...
@@ -285,7 +284,8 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
/* Input and Codecs Panel Implementation */
/* Input and Codecs Panel Implementation */
START_SPREFS_CAT
(
InputAndCodecs
,
qtr
(
"Input & Codecs settings"
)
);
START_SPREFS_CAT
(
InputAndCodecs
,
qtr
(
"Input & Codecs settings"
)
);
inputDevice
=
ui
.
DVDDevice
;
/* Disk Devices */
/* Disk Devices */
{
{
ui
.
DVDDevice
->
setToolTip
(
ui
.
DVDDevice
->
setToolTip
(
...
@@ -309,7 +309,14 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
...
@@ -309,7 +309,14 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
CONFIG_GENERIC
(
"http-proxy"
,
String
,
NULL
,
proxy
);
CONFIG_GENERIC
(
"http-proxy"
,
String
,
NULL
,
proxy
);
/* Caching */
/* Caching */
/* CONFIG_GENERIC( );*/
//FIXME
#define addToCachingBox( str, cachingNumber ) \
ui.cachingCombo->addItem( str, QVariant( cachingNumber ) );
addToCachingBox
(
"Custom"
,
CachingCustom
);
addToCachingBox
(
"Lowest latency"
,
CachingLowest
);
addToCachingBox
(
"Low latency"
,
CachingLow
);
addToCachingBox
(
"Normal"
,
CachingNormal
);
addToCachingBox
(
"High latency"
,
CachingHigh
);
addToCachingBox
(
"Higher latency"
,
CachingHigher
);
CONFIG_GENERIC_NO_BOOL
(
"ffmpeg-pp-q"
,
Integer
,
NULL
,
PostProcLevel
);
CONFIG_GENERIC_NO_BOOL
(
"ffmpeg-pp-q"
,
Integer
,
NULL
,
PostProcLevel
);
CONFIG_GENERIC
(
"avi-index"
,
IntegerList
,
NULL
,
AviRepair
);
CONFIG_GENERIC
(
"avi-index"
,
IntegerList
,
NULL
,
AviRepair
);
...
@@ -325,13 +332,18 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
...
@@ -325,13 +332,18 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
ui
.
dumpBox
->
setChecked
(
qs_filter
.
contains
(
"dump"
)
);
ui
.
dumpBox
->
setChecked
(
qs_filter
.
contains
(
"dump"
)
);
ui
.
recordBox
->
setChecked
(
qs_filter
.
contains
(
"record"
)
);
ui
.
recordBox
->
setChecked
(
qs_filter
.
contains
(
"record"
)
);
ui
.
bandwidthBox
->
setChecked
(
qs_filter
.
contains
(
"bandwidth"
)
);
ui
.
bandwidthBox
->
setChecked
(
qs_filter
.
contains
(
"bandwidth"
)
);
timeshiftBox
=
ui
.
timeshiftBox
;
recordBox
=
ui
.
recordBox
;
optionWidgets
.
append
(
ui
.
recordBox
);
dumpBox
=
ui
.
dumpBox
;
optionWidgets
.
append
(
ui
.
dumpBox
);
bandwidthBox
=
ui
.
bandwidthBox
;
optionWidgets
.
append
(
ui
.
bandwidthBox
);
optionWidgets
.
append
(
ui
.
timeshiftBox
);
optionWidgets
.
append
(
ui
.
DVDDevice
);
optionWidgets
.
append
(
ui
.
cachingCombo
);
END_SPREFS_CAT
;
END_SPREFS_CAT
;
/* Interface Panel */
/*******************
* Interface Panel *
*******************/
START_SPREFS_CAT
(
Interface
,
qtr
(
"Interface settings"
)
);
START_SPREFS_CAT
(
Interface
,
qtr
(
"Interface settings"
)
);
ui
.
defaultLabel
->
setFont
(
italicFont
);
ui
.
defaultLabel
->
setFont
(
italicFont
);
ui
.
skinsLabel
->
setFont
(
italicFont
);
ui
.
skinsLabel
->
setFont
(
italicFont
);
...
@@ -353,14 +365,15 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
...
@@ -353,14 +365,15 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
else
if
(
strstr
(
psz_intf
,
"qt"
)
)
else
if
(
strstr
(
psz_intf
,
"qt"
)
)
ui
.
qt4
->
setChecked
(
true
);
ui
.
qt4
->
setChecked
(
true
);
}
}
skinInterfaceButton
=
ui
.
skins
;
qtInterfaceButton
=
ui
.
qt4
;
delete
psz_intf
;
delete
psz_intf
;
optionWidgets
.
append
(
ui
.
skins
);
optionWidgets
.
append
(
ui
.
qt4
);
CONFIG_GENERIC
(
"qt-always-video"
,
Bool
,
NULL
,
qtAlwaysVideo
);
CONFIG_GENERIC
(
"qt-always-video"
,
Bool
,
NULL
,
qtAlwaysVideo
);
CONFIG_GENERIC_FILE
(
"skins2-last"
,
File
,
NULL
,
fileSkin
,
CONFIG_GENERIC_FILE
(
"skins2-last"
,
File
,
NULL
,
fileSkin
,
skinBrowse
);
skinBrowse
);
#if defined( WIN32 ) || defined(
HAVE_DBUS_3
)
#if defined( WIN32 ) || defined(
HAVE_DBUS_3
)
CONFIG_GENERIC
(
"one-instance"
,
Bool
,
NULL
,
OneInterfaceMode
);
CONFIG_GENERIC
(
"one-instance"
,
Bool
,
NULL
,
OneInterfaceMode
);
CONFIG_GENERIC
(
"playlist-enqueue"
,
Bool
,
NULL
,
CONFIG_GENERIC
(
"playlist-enqueue"
,
Bool
,
NULL
,
EnqueueOneInterfaceMode
);
EnqueueOneInterfaceMode
);
...
@@ -388,37 +401,26 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
...
@@ -388,37 +401,26 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
END_SPREFS_CAT
;
END_SPREFS_CAT
;
}
}
panel_layout
->
addWidget
(
panel_label
);
panel_layout
->
addWidget
(
panel_label
);
panel_layout
->
addWidget
(
title_line
);
panel_layout
->
addWidget
(
title_line
);
panel_layout
->
addWidget
(
panel
);
panel_layout
->
addWidget
(
panel
);
panel_layout
->
addStretch
(
2
);
panel_layout
->
addStretch
(
2
);
this
->
setLayout
(
panel_layout
);
setLayout
(
panel_layout
);
}
}
void
SPrefsPanel
::
updateAudioOptions
(
int
number
)
void
SPrefsPanel
::
updateAudioOptions
(
int
number
)
{
{
QString
value
=
audioOutput
->
itemData
(
number
).
toString
();
QString
value
=
qobject_cast
<
QComboBox
*>
(
optionWidgets
[
audioOutCoB
])
->
itemData
(
number
).
toString
();
#ifndef WIN32
#ifndef WIN32
o
ss_options
->
hide
(
);
o
ptionWidgets
[
ossW
]
->
setVisible
(
(
value
==
"oss"
)
);
alsa_options
->
hide
(
);
optionWidgets
[
alsaW
]
->
setVisible
(
(
value
==
"alsa"
)
);
#else
#else
directx_options
->
hide
();
optionWidgets
[
directxW
]
->
setVisible
(
(
value
==
"directx"
)
);
#endif
file_options
->
hide
();
if
(
value
==
"aout_file"
)
file_options
->
show
();
#ifndef WIN32
else
if
(
value
==
"alsa"
)
alsa_options
->
show
();
else
if
(
value
==
"oss"
)
oss_options
->
show
();
#else
else
if
(
value
==
"directx"
)
directx_options
->
show
();
#endif
#endif
optionWidgets
[
fileW
]
->
setVisible
(
(
value
==
"aout_file"
)
);
}
}
void
SPrefsPanel
::
apply
()
void
SPrefsPanel
::
apply
()
...
@@ -436,7 +438,9 @@ void SPrefsPanel::apply()
...
@@ -436,7 +438,9 @@ void SPrefsPanel::apply()
/* Devices */
/* Devices */
if
(
number
==
SPrefsInputAndCodecs
)
if
(
number
==
SPrefsInputAndCodecs
)
{
{
char
*
psz_devicepath
=
qtu
(
inputDevice
->
text
()
);
/* Device default selection */
char
*
psz_devicepath
=
qtu
(
qobject_cast
<
QLineEdit
*>
(
optionWidgets
[
inputLE
]
)
->
text
()
);
if
(
!
EMPTY_STR
(
psz_devicepath
)
)
if
(
!
EMPTY_STR
(
psz_devicepath
)
)
{
{
config_PutPsz
(
p_intf
,
"dvd"
,
psz_devicepath
);
config_PutPsz
(
p_intf
,
"dvd"
,
psz_devicepath
);
...
@@ -444,7 +448,7 @@ void SPrefsPanel::apply()
...
@@ -444,7 +448,7 @@ void SPrefsPanel::apply()
config_PutPsz
(
p_intf
,
"cd-audio"
,
psz_devicepath
);
config_PutPsz
(
p_intf
,
"cd-audio"
,
psz_devicepath
);
}
}
bool
b_first
=
true
;
/* Access filters */
#define saveBox( name, box ) {\
#define saveBox( name, box ) {\
if( box->isChecked() ) { \
if( box->isChecked() ) { \
if( b_first ) { \
if( b_first ) { \
...
@@ -454,25 +458,32 @@ void SPrefsPanel::apply()
...
@@ -454,25 +458,32 @@ void SPrefsPanel::apply()
else qs_filter.append( ":" ).append( name ); \
else qs_filter.append( ":" ).append( name ); \
} }
} }
saveBox
(
"record"
,
recordBox
);
bool
b_first
=
true
;
saveBox
(
"dump"
,
dumpBox
);
saveBox
(
"record"
,
qobject_cast
<
QCheckBox
*>
(
optionWidgets
[
recordChB
])
);
saveBox
(
"timeshift"
,
timeshiftBox
);
saveBox
(
"dump"
,
qobject_cast
<
QCheckBox
*>
(
optionWidgets
[
dumpChB
])
);
saveBox
(
"bandwidth"
,
bandwidthBox
);
saveBox
(
"timeshift"
,
qobject_cast
<
QCheckBox
*>
(
optionWidgets
[
timeshiftChB
])
);
saveBox
(
"bandwidth"
,
qobject_cast
<
QCheckBox
*>
(
optionWidgets
[
bandwidthChB
]
)
);
config_PutPsz
(
p_intf
,
"access-filter"
,
qtu
(
qs_filter
)
);
config_PutPsz
(
p_intf
,
"access-filter"
,
qtu
(
qs_filter
)
);
QComboBox
*
cachingCombo
=
qobject_cast
<
QComboBox
*>
(
optionWidgets
[
cachingCoB
]);
/* Caching */
msg_Dbg
(
p_intf
,
"%i"
,
cachingCombo
->
itemData
(
cachingCombo
->
currentIndex
()
).
toInt
()
);
}
}
/* Interfaces */
/* Interfaces */
if
(
number
==
SPrefsInterface
)
if
(
number
==
SPrefsInterface
)
{
{
if
(
skinInterfaceButton
->
isChecked
()
)
if
(
qobject_cast
<
QRadioButton
*>
(
optionWidgets
[
skinRB
])
->
isChecked
()
)
config_PutPsz
(
p_intf
,
"intf"
,
"skins2"
);
config_PutPsz
(
p_intf
,
"intf"
,
"skins2"
);
if
(
q
tInterfaceButton
->
isChecked
()
)
if
(
q
object_cast
<
QRadioButton
*>
(
optionWidgets
[
qtRB
])
->
isChecked
()
)
config_PutPsz
(
p_intf
,
"intf"
,
"qt4"
);
config_PutPsz
(
p_intf
,
"intf"
,
"qt4"
);
}
}
if
(
number
==
SPrefsAudio
)
if
(
number
==
SPrefsAudio
)
{
{
bool
b_normChecked
=
normalizerBox
->
isChecked
();
bool
b_normChecked
=
qobject_cast
<
QCheckBox
*>
(
optionWidgets
[
normalizerChB
])
->
isChecked
();
if
(
qs_filter
.
isEmpty
()
)
if
(
qs_filter
.
isEmpty
()
)
{
{
/* the psz_filter is already empty, so we just append it needed */
/* the psz_filter is already empty, so we just append it needed */
...
...
modules/gui/qt4/components/simple_preferences.hpp
View file @
72a25f19
...
@@ -28,6 +28,13 @@
...
@@ -28,6 +28,13 @@
#include <vlc_interface.h>
#include <vlc_interface.h>
#include <QWidget>
#include <QWidget>
#include "ui/sprefs_input.h"
#include "ui/sprefs_audio.h"
#include "ui/sprefs_video.h"
#include "ui/sprefs_subtitles.h"
#include "ui/sprefs_hotkeys.h"
#include "ui/sprefs_interface.h"
enum
{
enum
{
SPrefsInterface
=
0
,
SPrefsInterface
=
0
,
SPrefsAudio
,
SPrefsAudio
,
...
@@ -39,6 +46,19 @@ enum {
...
@@ -39,6 +46,19 @@ enum {
};
};
#define SPrefsDefaultCat SPrefsInterface
#define SPrefsDefaultCat SPrefsInterface
enum
{
CachingCustom
=
0
,
CachingLowest
=
100
,
CachingLow
=
200
,
CachingNormal
=
300
,
CachingHigh
=
400
,
CachingHigher
=
500
};
enum
{
alsaW
=
0
,
ossW
,
directxW
,
fileW
,
audioOutCoB
,
normalizerChB
};
enum
{
recordChB
,
dumpChB
,
bandwidthChB
,
timeshiftChB
,
inputLE
,
cachingCoB
};
enum
{
skinRB
,
qtRB
};
class
ConfigControl
;
class
ConfigControl
;
class
QComboBox
;
class
QComboBox
;
class
QLineEdit
;
class
QLineEdit
;
...
@@ -74,18 +94,8 @@ private:
...
@@ -74,18 +94,8 @@ private:
int
number
;
int
number
;
/* this is ugly and bad until I found a new solution */
QList
<
QWidget
*>
optionWidgets
;
QWidget
*
alsa_options
;
QWidget
*
oss_options
;
QWidget
*
directx_options
;
QWidget
*
file_options
;
QComboBox
*
audioOutput
;
QLineEdit
*
inputDevice
;
QRadioButton
*
skinInterfaceButton
;
QRadioButton
*
qtInterfaceButton
;
QString
qs_filter
;
QString
qs_filter
;
QCheckBox
*
normalizerBox
;
QCheckBox
*
recordBox
,
*
dumpBox
,
*
bandwidthBox
,
*
timeshiftBox
;
/* Display only the options for the selected audio output */
/* Display only the options for the selected audio output */
private
slots
:
private
slots
:
...
...
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