Mercurial > hg > octave-lyh
changeset 13659:d98c6ef06dff
included some editor setting into the setting dialog
author | ttl <ttl@justmail.de> |
---|---|
date | Sun, 28 Aug 2011 20:53:15 +0200 |
parents | d5b84316610d |
children | 632f653a29a0 |
files | gui/src/FileEditorMdiSubWindow.cpp gui/src/MainWindow.cpp gui/src/SettingsDialog.cpp gui/src/SettingsDialog.ui |
diffstat | 4 files changed, 222 insertions(+), 53 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/src/FileEditorMdiSubWindow.cpp +++ b/gui/src/FileEditorMdiSubWindow.cpp @@ -391,6 +391,7 @@ void FileEditorMdiSubWindow::construct () { + QSettings *settings = ResourceManager::instance ()->settings (); QStyle *style = QApplication::style (); setWidget (new QWidget ()); @@ -407,28 +408,37 @@ this,SLOT(handleMarginClicked(int,int,Qt::KeyboardModifiers))); // line numbers - QFont marginFont("Monospace",9); - m_editor->setMarginsFont(marginFont); - QFontMetrics metrics(marginFont); m_editor->setMarginsForegroundColor(QColor(96,96,96)); m_editor->setMarginsBackgroundColor(QColor(232,232,220)); - m_editor->setMarginType (2, QsciScintilla::TextMargin); - m_editor->setMarginWidth(2, metrics.width("99999")); - m_editor->setMarginLineNumbers(2, true); - + if ( settings->value ("editor/showLineNumbers",true).toBool () ) + { + QFont marginFont( settings->value ("editor/fontName","Courier").toString () , + settings->value ("editor/fontSize",10).toInt () ); + m_editor->setMarginsFont( marginFont ); + QFontMetrics metrics(marginFont); + m_editor->setMarginType (2, QsciScintilla::TextMargin); + m_editor->setMarginWidth(2, metrics.width("99999")); + m_editor->setMarginLineNumbers(2, true); + } // code folding m_editor->setMarginType (3, QsciScintilla::SymbolMargin); m_editor->setFolding (QsciScintilla::BoxedTreeFoldStyle , 3); - - m_editor->setCaretLineVisible(true); - m_editor->setCaretLineBackgroundColor(QColor(255,255,200)); + // other features + if ( settings->value ("editor/highlightActualLine",true).toBool () ) + { + m_editor->setCaretLineVisible(true); + m_editor->setCaretLineBackgroundColor(QColor(255,255,200)); + } m_editor->setBraceMatching (QsciScintilla::SloppyBraceMatch); m_editor->setAutoIndent (true); m_editor->setIndentationWidth (2); m_editor->setIndentationsUseTabs (false); - m_editor->autoCompleteFromAll(); - m_editor->setAutoCompletionSource(QsciScintilla::AcsAPIs); - m_editor->setAutoCompletionThreshold (3); + if ( settings->value ("editor/codeCompletion",true).toBool () ) + { + m_editor->autoCompleteFromAll(); + m_editor->setAutoCompletionSource(QsciScintilla::AcsAPIs); + m_editor->setAutoCompletionThreshold (3); + } m_editor->setUtf8 (true); // The Actions
--- a/gui/src/MainWindow.cpp +++ b/gui/src/MainWindow.cpp @@ -74,7 +74,11 @@ { // this has to be done only once, not for each editor m_lexer = new LexerOctaveGui(); - m_lexer->setDefaultFont(QFont("Monospace",10)); + // Editor font (default or from settings) + QSettings *settings = ResourceManager::instance ()->settings (); + m_lexer->setDefaultFont( QFont( + settings->value ("editor/fontName","Courier").toString (), + settings->value ("editor/fontSize",10).toInt () ) ); // TODO: Autoindent not working as it should m_lexer->setAutoIndentStyle(QsciScintilla::AiMaintain || QsciScintilla::AiOpening ||
--- a/gui/src/SettingsDialog.cpp +++ b/gui/src/SettingsDialog.cpp @@ -16,6 +16,11 @@ ui->nickServPassword->setText (settings->value ("nickServPassword").toString ()); ui->useCustomFileEditor->setChecked (settings->value ("useCustomFileEditor").toBool ()); ui->customFileEditor->setText (settings->value ("customFileEditor").toString ()); + ui->editor_showLineNumbers->setChecked (settings->value ("editor/showLineNumbers",true).toBool () ); + ui->editor_highlightActualLine->setChecked (settings->value ("editor/highlightActualLine",true).toBool () ); + ui->editor_codeCompletion->setChecked (settings->value ("editor/codeCompletion",true).toBool () ); + ui->editor_fontName->setCurrentFont (QFont (settings->value ("editor/fontName","Courier").toString()) ); + ui->editor_fontSize->setValue (settings->value ("editor/fontSize",10).toInt ()); ui->showFilenames->setChecked (settings->value ("showFilenames").toBool()); ui->showFileSize->setChecked (settings->value ("showFileSize").toBool()); ui->showFileType->setChecked (settings->value ("showFileType").toBool()); @@ -48,6 +53,11 @@ settings->setValue ("nickServPassword", ui->nickServPassword->text ()); settings->setValue ("useCustomFileEditor", ui->useCustomFileEditor->isChecked ()); settings->setValue ("customFileEditor", ui->customFileEditor->text ()); + settings->setValue ("editor/showLineNumbers", ui->editor_showLineNumbers->isChecked ()); + settings->setValue ("editor/highlightActualLine", ui->editor_highlightActualLine->isChecked ()); + settings->setValue ("editor/codeCompletion", ui->editor_codeCompletion->isChecked ()); + settings->setValue ("editor/fontName", ui->editor_fontName->currentFont().family()); + settings->setValue ("editor/fontSize", ui->editor_fontSize->value()); settings->setValue ("showFilenames", ui->showFilenames->isChecked ()); settings->setValue ("showFileSize", ui->showFileSize->isChecked ()); settings->setValue ("showFileType", ui->showFileType->isChecked ());
--- a/gui/src/SettingsDialog.ui +++ b/gui/src/SettingsDialog.ui @@ -32,7 +32,7 @@ <item> <widget class="QTabWidget" name="tabWidget"> <property name="currentIndex"> - <number>0</number> + <number>1</number> </property> <widget class="QWidget" name="chatTab"> <attribute name="title"> @@ -125,28 +125,7 @@ <string>Editor</string> </attribute> <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="QCheckBox" name="useCustomFileEditor"> - <property name="text"> - <string>Use custom file editor:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="customFileEditor"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>emacs</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="0"> + <item row="3" column="0"> <spacer name="verticalSpacer"> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -159,6 +138,124 @@ </property> </spacer> </item> + <item row="1" column="0"> + <layout class="QVBoxLayout" name="verticalLayout_7"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QCheckBox" name="useCustomFileEditor"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Use custom file editor:</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="customFileEditor"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>emacs</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QCheckBox" name="editor_showLineNumbers"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Show line numbers</string> + </property> + <property name="checked"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="editor_highlightActualLine"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Highlight actual line</string> + </property> + <property name="checked"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="editor_codeCompletion"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Code completion</string> + </property> + <property name="checked"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </item> + <item row="2" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <item> + <widget class="QLabel" name="label_8"> + <property name="text"> + <string>Font</string> + </property> + </widget> + </item> + <item> + <widget class="QFontComboBox" name="editor_fontName"> + <property name="editable"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_9"> + <property name="text"> + <string>Font Size</string> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="editor_fontSize"> + <property name="minimum"> + <number>2</number> + </property> + <property name="maximum"> + <number>96</number> + </property> + <property name="value"> + <number>10</number> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_4"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> </layout> </widget> <widget class="QWidget" name="tab_2"> @@ -402,8 +499,8 @@ <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> - <x>249</x> - <y>144</y> + <x>261</x> + <y>139</y> </hint> <hint type="destinationlabel"> <x>384</x> @@ -454,8 +551,8 @@ <y>59</y> </hint> <hint type="destinationlabel"> - <x>291</x> - <y>157</y> + <x>364</x> + <y>154</y> </hint> </hints> </connection> @@ -486,8 +583,8 @@ <y>59</y> </hint> <hint type="destinationlabel"> - <x>57</x> - <y>124</y> + <x>69</x> + <y>122</y> </hint> </hints> </connection> @@ -502,8 +599,8 @@ <y>59</y> </hint> <hint type="destinationlabel"> - <x>37</x> - <y>157</y> + <x>44</x> + <y>152</y> </hint> </hints> </connection> @@ -518,8 +615,8 @@ <y>59</y> </hint> <hint type="destinationlabel"> - <x>291</x> - <y>190</y> + <x>364</x> + <y>184</y> </hint> </hints> </connection> @@ -534,8 +631,8 @@ <y>59</y> </hint> <hint type="destinationlabel"> - <x>291</x> - <y>223</y> + <x>364</x> + <y>214</y> </hint> </hints> </connection> @@ -550,8 +647,8 @@ <y>59</y> </hint> <hint type="destinationlabel"> - <x>56</x> - <y>190</y> + <x>68</x> + <y>182</y> </hint> </hints> </connection> @@ -566,8 +663,56 @@ <y>59</y> </hint> <hint type="destinationlabel"> - <x>55</x> - <y>223</y> + <x>67</x> + <y>212</y> + </hint> + </hints> + </connection> + <connection> + <sender>editor_showLineNumbers</sender> + <signal>toggled(bool)</signal> + <receiver>editor_showLineNumbers</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>249</x> + <y>87</y> + </hint> + <hint type="destinationlabel"> + <x>249</x> + <y>87</y> + </hint> + </hints> + </connection> + <connection> + <sender>editor_highlightActualLine</sender> + <signal>toggled(bool)</signal> + <receiver>editor_highlightActualLine</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>249</x> + <y>112</y> + </hint> + <hint type="destinationlabel"> + <x>249</x> + <y>112</y> + </hint> + </hints> + </connection> + <connection> + <sender>editor_codeCompletion</sender> + <signal>toggled(bool)</signal> + <receiver>editor_codeCompletion</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>249</x> + <y>137</y> + </hint> + <hint type="destinationlabel"> + <x>249</x> + <y>137</y> </hint> </hints> </connection>