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"
25 #include "PyEditor_Editor.h"
28 \class PyEditor_Settings
29 \brief Manager of setting values.
32 PyEditor_Settings* PyEditor_Settings::myGlobalSettings = 0;
36 \return reference to global settings object
38 PyEditor_Settings* PyEditor_Settings::settings()
40 return myGlobalSettings;
45 \param settings reference to global settings object
47 void PyEditor_Settings::setSettings( PyEditor_Settings* settings )
49 if ( myGlobalSettings )
50 delete myGlobalSettings;
51 myGlobalSettings = settings;
57 PyEditor_Settings::PyEditor_Settings()
58 : myHighlightCurrentLine( true ),
59 myTextWrapping( false ),
60 myCenterCursorOnScroll( true ),
61 myLineNumberArea( true ),
62 myVerticalEdge( true ),
63 myNumberColumns( 80 ),
64 myTabSpaceVisible( true ),
66 myFont( "Courier", 10 ),
67 myCompletionPolicy( PyEditor_Editor::Always )
72 \brief Set "highlight current line" option.
73 \param on option value
75 void PyEditor_Settings::setHighlightCurrentLine( bool on )
77 myHighlightCurrentLine = on;
81 \brief Get "highlight current line" option.
84 bool PyEditor_Settings::highlightCurrentLine() const
86 return myHighlightCurrentLine;
90 \brief Set "text wrapping" option.
91 \param on option value
93 void PyEditor_Settings::setTextWrapping( bool on )
99 \brief Get "text wrapping line" option.
102 bool PyEditor_Settings::textWrapping() const
104 return myTextWrapping;
108 \brief Set "center cursor on scroll" option.
109 \param on option value
111 void PyEditor_Settings::setCenterCursorOnScroll( bool on )
113 myCenterCursorOnScroll = on;
117 \brief Get "center cursor on scroll" option.
120 bool PyEditor_Settings::centerCursorOnScroll() const
122 return myCenterCursorOnScroll;
126 \brief Set "show line number area" option.
127 \param on option value
129 void PyEditor_Settings::setLineNumberArea( bool on )
131 myLineNumberArea = on;
135 \brief Get "show line number area" option.
138 bool PyEditor_Settings::lineNumberArea() const
140 return myLineNumberArea;
144 \brief Set "show vertical edge" option.
145 \param on option value
147 void PyEditor_Settings::setVerticalEdge( bool on )
153 \brief Get "show vertical edge" option.
156 bool PyEditor_Settings::verticalEdge() const
158 return myVerticalEdge;
162 \brief Set "number of columns" option.
163 \param value option value
165 void PyEditor_Settings::setNumberColumns( int value )
167 myNumberColumns = value;
171 \brief Get "number of columns" option.
174 int PyEditor_Settings::numberColumns() const
176 return myNumberColumns;
180 \brief Set "show tab spaces" option.
181 \param on option value
183 void PyEditor_Settings::setTabSpaceVisible( bool on )
185 myTabSpaceVisible = on;
189 \brief Get "show tab spaces" option.
192 bool PyEditor_Settings::tabSpaceVisible() const
194 return myTabSpaceVisible;
198 \brief Set "tab size" option.
199 \param value option value
201 void PyEditor_Settings::setTabSize( int value )
207 \brief Get "tab size" option.
210 int PyEditor_Settings::tabSize() const
216 \brief Set "font" option.
217 \param font option value
219 void PyEditor_Settings::setFont( const QFont& font )
225 \brief Get "font" option.
228 QFont PyEditor_Settings::font() const
234 \brief Set "completionPolicy" option.
235 \param completion policy option value
237 void PyEditor_Settings::setCompletionPolicy( int value )
239 myCompletionPolicy = value;
243 \brief Get "completionPolicy" option.
246 int PyEditor_Settings::completionPolicy() const
248 return myCompletionPolicy;
252 \brief Read settings from the persistence storage.
253 Base implementation does nothing; it should be reimplemented in successors.
255 void PyEditor_Settings::load()
260 \brief Write settings to the persistence storage.
261 Base implementation does nothing; it should be reimplemented in successors.
263 void PyEditor_Settings::save()
268 \brief Copy settings from another object.
269 \param other source settings object
271 void PyEditor_Settings::copyFrom( const PyEditor_Settings& other )
273 setHighlightCurrentLine( other.highlightCurrentLine() );
274 setTextWrapping( other.textWrapping() );
275 setCenterCursorOnScroll( other.centerCursorOnScroll() );
276 setLineNumberArea( other.lineNumberArea() );
277 setTabSpaceVisible( other.tabSpaceVisible() );
278 setTabSize( other.tabSize() );
279 setVerticalEdge( other.verticalEdge() );
280 setNumberColumns( other.numberColumns() );
281 setFont( other.font() );
282 setCompletionPolicy( other.completionPolicy() );
288 \brief Get preference item's identifier.
289 \return string identifier
291 QString PyEditor_Settings::option( Option option )
293 static const char* options[] = {
295 "HighlightCurrentLine",
297 "CenterCursorOnScroll",
306 return option >= 0 && option <= snCompletionPolicy ? options[option] : "Unknown";