Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
gepetto-viewer-corba
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gepetto
gepetto-viewer-corba
Commits
b03cfd1f
Commit
b03cfd1f
authored
7 years ago
by
Joseph Mirabel
Committed by
Joseph Mirabel
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix way of finding config files
parent
4c40b3a8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/gepetto/gui/settings.hh
+0
-3
0 additions, 3 deletions
include/gepetto/gui/settings.hh
src/gui/settings.cc
+25
-19
25 additions, 19 deletions
src/gui/settings.cc
with
25 additions
and
22 deletions
include/gepetto/gui/settings.hh
+
0
−
3
View file @
b03cfd1f
...
...
@@ -43,9 +43,6 @@ namespace gepetto {
/// and GEPETTO_GUI_SETTINGS_DIR are read.
void
setupPaths
()
const
;
/// Return the directory into which configuration file are.
QDir
getConfigPath
()
const
;
/// Get the filename of a configuration file.
QString
getQSettingsFileName
(
const
std
::
string
&
settingsName
)
const
;
...
...
This diff is collapsed.
Click to expand it.
src/gui/settings.cc
+
25
−
19
View file @
b03cfd1f
...
...
@@ -208,27 +208,21 @@ namespace gepetto {
;
}
QDir
Settings
::
getConfigPath
()
const
{
QDir
d
(
installDirectory
);
d
.
cd
(
"etc"
);
d
.
cd
(
QCoreApplication
::
organizationName
());
return
d
;
}
QString
Settings
::
getQSettingsFileName
(
const
std
::
string
&
settingsName
)
const
{
QString
name
(
QString
::
fromStdString
(
settingsName
));
QString
ext
(
".conf"
);
QDir
dir
(
getConfigPath
());
if
(
dir
.
exists
(
name
+
ext
)
||
!
dir
.
exists
(
name
))
return
dir
.
absoluteFilePath
(
name
+
ext
);
return
dir
.
absoluteFilePath
(
name
)
;
// Remove extension
if
(
name
.
endsWith
(
ext
))
name
=
name
.
left
(
name
.
size
()
-
ext
.
size
()
);
return
name
;
}
void
Settings
::
readRobotFile
()
{
QSettings
robot
(
getQSettingsFileName
(
predifinedRobotConf
));
QSettings
robot
(
QSettings
::
SystemScope
,
QCoreApplication
::
organizationName
(),
getQSettingsFileName
(
predifinedRobotConf
));
if
(
robot
.
status
()
!=
QSettings
::
NoError
)
{
logError
(
QString
(
"Enable to open configuration file "
)
+
robot
.
fileName
());
...
...
@@ -254,7 +248,9 @@ namespace gepetto {
void
Settings
::
readEnvFile
()
{
QSettings
env
(
getQSettingsFileName
(
predifinedEnvConf
));
QSettings
env
(
QSettings
::
SystemScope
,
QCoreApplication
::
organizationName
(),
getQSettingsFileName
(
predifinedEnvConf
));
if
(
env
.
status
()
!=
QSettings
::
NoError
)
{
logError
(
QString
(
"Enable to open configuration file "
)
+
env
.
fileName
());
}
else
{
...
...
@@ -277,7 +273,9 @@ namespace gepetto {
void
Settings
::
readSettingFile
()
{
QSettings
env
(
getQSettingsFileName
(
configurationFile
));
QSettings
env
(
QSettings
::
SystemScope
,
QCoreApplication
::
organizationName
(),
getQSettingsFileName
(
configurationFile
));
if
(
env
.
status
()
!=
QSettings
::
NoError
)
{
logError
(
QString
(
"Enable to open configuration file "
)
+
env
.
fileName
());
}
else
{
...
...
@@ -297,7 +295,9 @@ namespace gepetto {
void
Settings
::
writeRobotFile
()
{
QSettings
robot
(
getQSettingsFileName
(
predifinedRobotConf
));
QSettings
robot
(
QSettings
::
SystemScope
,
QCoreApplication
::
organizationName
(),
getQSettingsFileName
(
predifinedRobotConf
));
if
(
!
robot
.
isWritable
())
{
log
(
QString
(
"Configuration file "
)
+
robot
.
fileName
()
+
QString
(
" is not writable."
));
return
;
...
...
@@ -318,7 +318,9 @@ namespace gepetto {
void
Settings
::
writeEnvFile
()
{
QSettings
env
(
getQSettingsFileName
(
predifinedEnvConf
));
QSettings
env
(
QSettings
::
SystemScope
,
QCoreApplication
::
organizationName
(),
getQSettingsFileName
(
predifinedEnvConf
));
if
(
!
env
.
isWritable
())
{
logError
(
QString
(
"Configuration file"
)
+
env
.
fileName
()
+
QString
(
"is not writable."
));
return
;
...
...
@@ -336,7 +338,9 @@ namespace gepetto {
void
Settings
::
writeSettingFile
()
{
QSettings
env
(
getQSettingsFileName
(
configurationFile
));
QSettings
env
(
QSettings
::
SystemScope
,
QCoreApplication
::
organizationName
(),
getQSettingsFileName
(
configurationFile
));
if
(
!
env
.
isWritable
())
{
logError
(
QString
(
"Configuration file"
)
+
env
.
fileName
()
+
QString
(
"is not writable."
));
return
;
...
...
@@ -357,7 +361,9 @@ namespace gepetto {
QVariant
Settings
::
getSetting
(
const
QString
&
key
,
const
QVariant
&
defaultValue
)
{
QSettings
env
(
getQSettingsFileName
(
configurationFile
));
QSettings
env
(
QSettings
::
SystemScope
,
QCoreApplication
::
organizationName
(),
getQSettingsFileName
(
configurationFile
));
if
(
env
.
status
()
==
QSettings
::
NoError
)
{
return
env
.
value
(
key
,
defaultValue
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment