Salome HOME
Merge remote branch 'origin/hydro/imps_2015'
[modules/gui.git] / src / PyViewer / PyViewer_Settings.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   : PyViewer_Settings.cxx
20 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
21 //
22
23 #include "PyViewer_Settings.h"
24
25 #include <QtxResourceMgr.h>
26
27 PyViewer_Settings::PyViewer_Settings( QtxResourceMgr* resMgr ) :
28   myResMgr( resMgr )
29 {
30   load();
31 }
32
33 PyViewer_Settings::PyViewer_Settings( QtxResourceMgr* resMgr, const QString& group ) :
34   myResMgr( resMgr ),
35   myGroup( group )
36 {
37   load();
38 }
39
40 void PyViewer_Settings::load()
41 {
42   if ( !myResMgr ) return;
43   QString group = myGroup.isEmpty() ? option( snEditor ) : myGroup;
44   setHighlightCurrentLine( myResMgr->booleanValue( group, option( snHighlightCurrentLine ), highlightCurrentLine() ) );
45   setTextWrapping( myResMgr->booleanValue( group, option( snTextWrapping ), textWrapping() ) );
46   setCenterCursorOnScroll( myResMgr->booleanValue( group, option( snCenterCursorOnScroll ), centerCursorOnScroll() ) );
47   setLineNumberArea( myResMgr->booleanValue( group, option( snLineNumberArea ), lineNumberArea() ) );
48   setVerticalEdge( myResMgr->booleanValue( group, option( snVerticalEdge  ), verticalEdge() ) );
49   setNumberColumns( myResMgr->integerValue( group, option( snNumberColumns ), numberColumns() ) );
50   setTabSpaceVisible( myResMgr->booleanValue( group, option( snTabSpaceVisible ), tabSpaceVisible() ) );
51   setTabSize( myResMgr->integerValue( group, option( snTabSize ), tabSize() ) );
52   setFont( myResMgr->fontValue( group, option( snFont ), font() ) );
53 }
54
55 void PyViewer_Settings::save()
56 {
57   if ( !myResMgr ) return;
58   QString group = myGroup.isEmpty() ? option( snEditor ) : myGroup;
59   myResMgr->setValue( group, option( snHighlightCurrentLine ), highlightCurrentLine() );
60   myResMgr->setValue( group, option( snTextWrapping ), textWrapping() );
61   myResMgr->setValue( group, option( snCenterCursorOnScroll ), centerCursorOnScroll() );
62   myResMgr->setValue( group, option( snLineNumberArea ), lineNumberArea() );
63   myResMgr->setValue( group, option( snVerticalEdge  ), verticalEdge() );
64   myResMgr->setValue( group, option( snNumberColumns ), numberColumns() );
65   myResMgr->setValue( group, option( snTabSpaceVisible ), tabSpaceVisible() );
66   myResMgr->setValue( group, option( snTabSize ), tabSize() );
67   myResMgr->setValue( group, option( snFont ), font() );
68 }