1 // Copyright (C) 2015-2016 OPEN CASCADE
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // File : PyEditor_Settings.cxx
20 // Author : Maxim GLIBIN, Open CASCADE S.A.S. (maxim.glibin@opencascade.com)
23 #include "PyEditor_Settings.h"
26 \class PyEditor_Settings
27 \brief Manager of setting values.
30 PyEditor_Settings* PyEditor_Settings::myGlobalSettings = 0;
34 \return reference to global settings object
36 PyEditor_Settings* PyEditor_Settings::settings()
38 return myGlobalSettings;
43 \param settings reference to global settings object
45 void PyEditor_Settings::setSettings( PyEditor_Settings* settings )
47 if ( myGlobalSettings )
48 delete myGlobalSettings;
49 myGlobalSettings = settings;
55 PyEditor_Settings::PyEditor_Settings()
56 : myHighlightCurrentLine( true ),
57 myTextWrapping( false ),
58 myCenterCursorOnScroll( true ),
59 myLineNumberArea( true ),
60 myVerticalEdge( true ),
61 myNumberColumns( 80 ),
62 myTabSpaceVisible( true ),
64 myFont( "Courier", 10 )
69 \brief Set "highlight current line" option.
70 \param on option value
72 void PyEditor_Settings::setHighlightCurrentLine( bool on )
74 myHighlightCurrentLine = on;
78 \brief Get "highlight current line" option.
81 bool PyEditor_Settings::highlightCurrentLine() const
83 return myHighlightCurrentLine;
87 \brief Set "text wrapping" option.
88 \param on option value
90 void PyEditor_Settings::setTextWrapping( bool on )
96 \brief Get "text wrapping line" option.
99 bool PyEditor_Settings::textWrapping() const
101 return myTextWrapping;
105 \brief Set "center cursor on scroll" option.
106 \param on option value
108 void PyEditor_Settings::setCenterCursorOnScroll( bool on )
110 myCenterCursorOnScroll = on;
114 \brief Get "center cursor on scroll" option.
117 bool PyEditor_Settings::centerCursorOnScroll() const
119 return myCenterCursorOnScroll;
123 \brief Set "show line number area" option.
124 \param on option value
126 void PyEditor_Settings::setLineNumberArea( bool on )
128 myLineNumberArea = on;
132 \brief Get "show line number area" option.
135 bool PyEditor_Settings::lineNumberArea() const
137 return myLineNumberArea;
141 \brief Set "show vertical edge" option.
142 \param on option value
144 void PyEditor_Settings::setVerticalEdge( bool on )
150 \brief Get "show vertical edge" option.
153 bool PyEditor_Settings::verticalEdge() const
155 return myVerticalEdge;
159 \brief Set "number of columns" option.
160 \param value option value
162 void PyEditor_Settings::setNumberColumns( int value )
164 myNumberColumns = value;
168 \brief Get "number of columns" option.
171 int PyEditor_Settings::numberColumns() const
173 return myNumberColumns;
177 \brief Set "show tab spaces" option.
178 \param on option value
180 void PyEditor_Settings::setTabSpaceVisible( bool on )
182 myTabSpaceVisible = on;
186 \brief Get "show tab spaces" option.
189 bool PyEditor_Settings::tabSpaceVisible() const
191 return myTabSpaceVisible;
195 \brief Set "tab size" option.
196 \param value option value
198 void PyEditor_Settings::setTabSize( int value )
204 \brief Get "tab size" option.
207 int PyEditor_Settings::tabSize() const
213 \brief Set "font" option.
214 \param font option value
216 void PyEditor_Settings::setFont( const QFont& font )
222 \brief Get "font" option.
225 QFont PyEditor_Settings::font() const
231 \brief Read settings from the persistence storage.
232 Base implementation does nothing; it should be reimplemented in successors.
234 void PyEditor_Settings::load()
239 \brief Write settings to the persistence storage.
240 Base implementation does nothing; it should be reimplemented in successors.
242 void PyEditor_Settings::save()
247 \brief Copy settings from another object.
248 \param other source settings object
250 void PyEditor_Settings::copyFrom( const PyEditor_Settings& other )
252 setHighlightCurrentLine( other.highlightCurrentLine() );
253 setTextWrapping( other.textWrapping() );
254 setCenterCursorOnScroll( other.centerCursorOnScroll() );
255 setLineNumberArea( other.lineNumberArea() );
256 setTabSpaceVisible( other.tabSpaceVisible() );
257 setTabSize( other.tabSize() );
258 setVerticalEdge( other.verticalEdge() );
259 setNumberColumns( other.numberColumns() );
260 setFont( other.font() );
265 \brief Get preference item's identifier.
266 \return string identifier
268 QString PyEditor_Settings::option( Option option )
270 static const char* options[] = {
272 "HighlightCurrentLine",
274 "CenterCursorOnScroll",
282 return option >= 0 && option <= snFont ? options[option] : "Unknown";