Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
c410d268
Commit
c410d268
authored
Jan 14, 2010
by
Tobias Hunger
Browse files
Move EditorSettings over to new save/restore scheme
Reviewed-by: dt
parent
533a85a6
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/plugins/projectexplorer/editorconfiguration.cpp
View file @
c410d268
...
...
@@ -33,6 +33,10 @@
using
namespace
ProjectExplorer
;
namespace
{
const
char
*
const
CODEC
(
"EditorConfiguration.Codec"
);
}
EditorConfiguration
::
EditorConfiguration
()
:
m_defaultTextCodec
(
QTextCodec
::
codecForLocale
())
{
...
...
@@ -45,6 +49,23 @@ QTextCodec *EditorConfiguration::defaultTextCodec() const
void
EditorConfiguration
::
setDefaultTextCodec
(
QTextCodec
*
codec
)
{
if
(
!
codec
)
return
;
m_defaultTextCodec
=
codec
;
}
QVariantMap
EditorConfiguration
::
toMap
()
const
{
QVariantMap
map
;
map
.
insert
(
QLatin1String
(
CODEC
),
m_defaultTextCodec
->
name
());
return
map
;
}
bool
EditorConfiguration
::
fromMap
(
const
QVariantMap
&
map
)
{
QTextCodec
*
codec
=
QTextCodec
::
codecForName
(
map
.
value
(
QLatin1String
(
CODEC
)).
toString
().
toLocal8Bit
());
if
(
!
codec
)
return
false
;
m_defaultTextCodec
=
codec
;
return
true
;
}
src/plugins/projectexplorer/editorconfiguration.h
View file @
c410d268
...
...
@@ -32,7 +32,7 @@
#include
"projectexplorer_export.h"
#include
<QtCore/
qglobal.h
>
#include
<QtCore/
QVariantMap
>
QT_BEGIN_NAMESPACE
class
QTextCodec
;
...
...
@@ -44,9 +44,13 @@ class PROJECTEXPLORER_EXPORT EditorConfiguration
{
public:
EditorConfiguration
();
QTextCodec
*
defaultTextCodec
()
const
;
void
setDefaultTextCodec
(
QTextCodec
*
codec
);
QVariantMap
toMap
()
const
;
bool
fromMap
(
const
QVariantMap
&
map
);
private:
QTextCodec
*
m_defaultTextCodec
;
};
...
...
src/plugins/projectexplorer/project.cpp
View file @
c410d268
...
...
@@ -50,6 +50,7 @@ using namespace ProjectExplorer::Internal;
namespace
{
const
char
*
const
PROJECT_FILE_POSTFIX
(
".user"
);
const
char
*
const
EDITOR_SETTINGS_KEY
(
"ProjectExplorer.Project.EditorSettings"
);
}
// namespace
// -------------------------------------------------------------------------
...
...
@@ -211,7 +212,7 @@ void Project::saveSettingsImpl(PersistentSettingsWriter &writer)
writer
.
setPrefix
(
QString
::
null
);
writer
.
saveValue
(
"activeRunConfiguration"
,
activeId
);
writer
.
saveValue
(
"defaultFileEncoding"
,
m_editorConfiguration
->
defaultTextCodec
()
->
name
());
writer
.
saveValue
(
QLatin1String
(
EDITOR_SETTINGS_KEY
)
,
m_editorConfiguration
->
toMap
());
}
bool
Project
::
restoreSettingsImpl
(
PersistentSettingsReader
&
reader
)
...
...
@@ -386,13 +387,11 @@ bool Project::restoreSettingsImpl(PersistentSettingsReader &reader)
}
reader
.
setPrefix
(
QString
::
null
);
QTextCodec
*
codec
=
QTextCodec
::
codecForName
(
reader
.
restoreValue
(
"defaultFileEncoding"
).
toByteArray
());
if
(
codec
)
m_editorConfiguration
->
setDefaultTextCodec
(
codec
);
if
(
!
m_activeRunConfiguration
&&
!
m_runConfigurations
.
isEmpty
())
setActiveRunConfiguration
(
m_runConfigurations
.
at
(
0
));
return
true
;
QVariantMap
tmp
=
reader
.
restoreValue
(
QLatin1String
(
EDITOR_SETTINGS_KEY
)).
toMap
();
return
m_editorConfiguration
->
fromMap
(
tmp
);
}
BuildConfiguration
*
Project
::
activeBuildConfiguration
()
const
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment