Salome HOME
Merge V8_3_BR branch.
[modules/gui.git] / tools / PyEditor / src / PyEditor_StdSettings.cxx
1 // Copyright (C) 2015-2016  OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // File   : PyEditor_StdSettings.cxx
20 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
21 //
22
23 #include "PyEditor_StdSettings.h"
24
25 PyEditor_StdSettings::PyEditor_StdSettings() :
26   myLanguage( "en" )
27 {
28   load();
29 }
30
31 PyEditor_StdSettings::PyEditor_StdSettings( const QString& group ) :
32   myGroup( group ),
33   myLanguage( "en" )
34 {
35   load();
36 }
37
38 PyEditor_StdSettings::PyEditor_StdSettings( const QString& group,
39                                             const QString& filename,
40                                             QSettings::Format format ) :
41   mySettings( filename, format ),
42   myGroup( group ),
43   myLanguage( "en" )
44 {
45   load();
46 }
47
48 void PyEditor_StdSettings::setLanguage( const QString& language )
49 {
50   myLanguage = language;
51 }
52
53 QString PyEditor_StdSettings::language() const
54 {
55   return myLanguage;
56 }
57
58 void PyEditor_StdSettings::load()
59 {
60   mySettings.beginGroup( myGroup.isEmpty() ? option( snEditor ) : myGroup );
61
62   setHighlightCurrentLine( mySettings.value( option( snHighlightCurrentLine ), highlightCurrentLine() ).toBool() );
63   setTextWrapping( mySettings.value( option( snTextWrapping ), textWrapping() ).toBool() );
64   setCenterCursorOnScroll( mySettings.value( option( snCenterCursorOnScroll ), centerCursorOnScroll() ).toBool() );
65   setLineNumberArea( mySettings.value( option( snLineNumberArea ), lineNumberArea() ).toBool() );
66   setVerticalEdge( mySettings.value( option( snVerticalEdge  ), verticalEdge() ).toBool() );
67   setNumberColumns( mySettings.value( option( snNumberColumns ), numberColumns() ).toInt() );
68   setTabSpaceVisible( mySettings.value( option( snTabSpaceVisible ), tabSpaceVisible() ).toBool() );
69   setTabSize( mySettings.value( option( snTabSize ), tabSize() ).toInt() );
70   setFont( mySettings.value( option( snFont ), font() ).value<QFont>() );
71   setLanguage( mySettings.value( "language", language() ).toString() );
72
73   mySettings.endGroup();
74 }
75
76 void PyEditor_StdSettings::save()
77 {
78   mySettings.beginGroup( myGroup.isEmpty() ? option( snEditor ) : myGroup );
79
80   mySettings.setValue( option( snHighlightCurrentLine ), highlightCurrentLine() );
81   mySettings.setValue( option( snTextWrapping ), textWrapping() );
82   mySettings.setValue( option( snCenterCursorOnScroll ), centerCursorOnScroll() );
83   mySettings.setValue( option( snLineNumberArea ), lineNumberArea() );
84   mySettings.setValue( option( snVerticalEdge  ), verticalEdge() );
85   mySettings.setValue( option( snNumberColumns ), numberColumns() );
86   mySettings.setValue( option( snTabSpaceVisible ), tabSpaceVisible() );
87   mySettings.setValue( option( snTabSize ), tabSize() );
88   mySettings.setValue( option( snFont ), font() );
89   mySettings.setValue( "language", language() );
90
91   mySettings.endGroup();
92 }