Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
VideoLAN
VLMC
Commits
bbbef023
Commit
bbbef023
authored
Oct 02, 2009
by
Clement CHAVANCE
Committed by
Clement CHAVANCE
Oct 03, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed the method that assigned an int to a settings object.
For now, there will be only one map for the settings
parent
56893065
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
69 deletions
+56
-69
src/Configuration/SettingsManager.cpp
src/Configuration/SettingsManager.cpp
+6
-11
src/Configuration/SettingsManager.h
src/Configuration/SettingsManager.h
+14
-19
src/GUI/Settings.cpp
src/GUI/Settings.cpp
+33
-34
src/GUI/Settings.h
src/GUI/Settings.h
+3
-5
No files found.
src/Configuration/SettingsManager.cpp
View file @
bbbef023
...
...
@@ -21,17 +21,18 @@
*****************************************************************************/
#include <QHash>
#include <QDomElement>
#include "SettingsManager.h"
int
SettingsManager
::
createNewSettings
()
{
this
->
m_settings
.
append
(
new
SettingsContainer
());
return
this
->
m_settings
.
size
()
-
1
;
this
->
m_settings
.
append
(
new
SettingsContainer
());
return
this
->
m_settings
.
size
()
-
1
;
}
SettingsManager
::
SettingsManager
(
QObject
*
parent
)
:
QObject
(
parent
)
SettingsManager
::
SettingsManager
(
QObject
*
parent
)
:
QObject
(
parent
)
{
}
...
...
@@ -39,12 +40,6 @@ SettingsManager::~SettingsManager()
{
}
void
SettingsManager
::
saveSettings
(
QDomDocument
&
xmlfile
,
int
index
)
void
SettingsManager
::
saveSettings
(
QDomDocument
&
xmlfile
,
QDomElement
&
root
)
{
Q_UNUSED
(
xmlfile
)
SettingsContainer
*
settings
=
m_settings
[
index
];
settings
->
lock
.
lockForRead
();
//SAVE SETTINGS TO DomDocument
settings
->
lock
.
unlock
();
}
src/Configuration/SettingsManager.h
View file @
bbbef023
...
...
@@ -33,31 +33,26 @@
#include "QSingleton.hpp"
struct
SettingsContainer
{
QReadWriteLock
lock
;
QHash
<
QString
,
QVariant
>
settings
;
};
class
SettingsManager
:
public
QObject
,
public
QSingleton
<
SettingsManager
>
{
//Q_OBJECT
//
friend
class
QSingleton
<
SettingsManager
>
;
public:
int
createNewSettings
();
Q_OBJECT
friend
class
QSingleton
<
SettingsManager
>
;
public:
void
setValues
(
QHash
<
QString
,
QVariant
>
,
int
index
);
void
setValue
(
const
QString
&
key
,
QVariant
&
value
,
int
index
);
QVariant
&
getValue
(
const
QString
&
key
);
private:
SettingsManager
(
QObject
*
parent
=
0
);
~
SettingsManager
();
void
setValues
(
QHash
<
QString
,
QVariant
>
);
void
setValue
(
const
QString
&
key
,
QVariant
&
value
);
QVariant
&
getValue
(
const
QString
&
key
);
private:
SettingsManager
(
QObject
*
parent
=
0
);
~
SettingsManager
();
QVector
<
SettingsContainer
*>
m_settings
;
QHash
<
QString
,
QVariant
>
m_data
;
QReadWriteLock
m_lock
;
public
slots
:
void
saveSettings
(
QDomDocument
&
xmlfile
,
int
index
);
public
slots
:
void
saveSettings
(
QDomDocument
&
xmlfile
,
QDomElement
&
root
);
};
...
...
src/GUI/Settings.cpp
View file @
bbbef023
...
...
@@ -38,19 +38,18 @@
Settings
::
Settings
(
QWidget
*
parent
,
Qt
::
WindowFlags
f
)
:
QDialog
(
parent
,
f
),
:
QDialog
(
parent
,
f
),
m_currentWidget
(
NULL
)
{
m_panel
=
new
Panel
(
this
);
m_stackedWidgets
=
new
QStackedWidget
(
this
);
connect
(
m_panel
,
SIGNAL
(
changePanel
(
int
)
),
SLOT
(
switchWidget
(
int
)
)
);
SIGNAL
(
changePanel
(
int
)
),
SLOT
(
switchWidget
(
int
)
)
);
QObject
::
connect
(
this
,
SIGNAL
(
widgetSwitched
(
int
)
),
m_stackedWidgets
,
SLOT
(
setCurrentIndex
(
int
)
));
m_settingsNumber
=
SettingsManager
::
getInstance
()
->
createNewSettings
();
SIGNAL
(
widgetSwitched
(
int
)
),
m_stackedWidgets
,
SLOT
(
setCurrentIndex
(
int
)
));
}
Settings
::~
Settings
()
...
...
@@ -61,9 +60,9 @@ Settings::~Settings()
//TODO : see if the widget MUST have a fixed size, or if the window can dynamicaly
//adjust to the size of the biggest Widget.
void
Settings
::
addWidget
(
const
QString
&
name
,
PreferenceWidget
*
pWidget
,
const
QString
&
icon
,
const
QString
&
label
)
PreferenceWidget
*
pWidget
,
const
QString
&
icon
,
const
QString
&
label
)
{
m_stackedWidgets
->
addWidget
(
pWidget
);
...
...
@@ -95,7 +94,7 @@ QVBoxLayout* Settings::buildRightHLayout()
m_buttons
=
new
QDialogButtonBox
(
this
);
QObject
::
connect
(
m_buttons
,
SIGNAL
(
clicked
(
QAbstractButton
*
)
),
this
,
SLOT
(
buttonClicked
(
QAbstractButton
*
)
)
);
this
,
SLOT
(
buttonClicked
(
QAbstractButton
*
)
)
);
m_title
=
new
QLabel
(
this
);
titleLine
->
setFrameShape
(
QFrame
::
HLine
);
...
...
@@ -108,8 +107,8 @@ QVBoxLayout* Settings::buildRightHLayout()
m_title
->
setFont
(
labelFont
);
m_buttons
->
setStandardButtons
(
QDialogButtonBox
::
Ok
|
QDialogButtonBox
::
Cancel
|
QDialogButtonBox
::
Apply
);
QDialogButtonBox
::
Cancel
|
QDialogButtonBox
::
Apply
);
QString
title
(
m_widgets
.
value
(
m_stackedWidgets
->
indexOf
(
m_currentWidget
)
)
);
m_title
->
setText
(
title
);
...
...
@@ -130,33 +129,33 @@ void Settings::buttonClicked( QAbstractButton* button )
bool
hide
=
false
;
switch
(
m_buttons
->
standardButton
(
button
)
)
{
case
QDialogButtonBox
::
Ok
:
save
=
true
;
hide
=
true
;
break
;
case
QDialogButtonBox
::
Cancel
:
hide
=
true
;
break
;
case
QDialogButtonBox
::
Apply
:
save
=
true
;
break
;
default
:
break
;
case
QDialogButtonBox
::
Ok
:
save
=
true
;
hide
=
true
;
break
;
case
QDialogButtonBox
::
Cancel
:
hide
=
true
;
break
;
case
QDialogButtonBox
::
Apply
:
save
=
true
;
break
;
default
:
break
;
}
if
(
save
==
true
)
{
qDebug
()
<<
"Saving Preferences"
;
//Save Settings
QHash
<
QString
,
QVariant
>
sett
;
PreferenceWidget
*
widg
;
foreach
(
widg
,
m_pWidgets
)
widg
->
save
(
sett
);
qDebug
()
<<
sett
;
qDebug
()
<<
"Saving Preferences"
;
//Save Settings
QHash
<
QString
,
QVariant
>
sett
;
PreferenceWidget
*
widg
;
foreach
(
widg
,
m_pWidgets
)
widg
->
save
(
sett
);
qDebug
()
<<
sett
;
}
if
(
hide
==
true
)
{
setVisible
(
false
);
setVisible
(
false
);
}
}
...
...
src/GUI/Settings.h
View file @
bbbef023
...
...
@@ -46,9 +46,9 @@ class Settings : public QDialog
Settings
(
QWidget
*
parent
=
0
,
Qt
::
WindowFlags
f
=
0
);
virtual
~
Settings
();
void
addWidget
(
const
QString
&
name
,
PreferenceWidget
*
pWidget
,
const
QString
&
icon
,
const
QString
&
label
);
PreferenceWidget
*
pWidget
,
const
QString
&
icon
,
const
QString
&
label
);
void
build
();
private:
...
...
@@ -65,8 +65,6 @@ class Settings : public QDialog
QDialogButtonBox
*
m_buttons
;
bool
m_saved
;
int
m_settingsNumber
;
public
slots
:
void
switchWidget
(
int
widget
);
...
...
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