changeset 23490:7463c8e91dba

customizable size of line numbers in the editor (bug #46959) * file_editor_tab (update_lexer): set the font size for the line numbers depending on the default font of the lexer and on the size difference from the settings * settings-dialog.cc (settings_dialog): fill the new spin box for the line numbers_size from the settings, reduce size of color box for line highlighting; (write_changed_settings) store the value from the spin box with the size of the line numbers into the settings file * settings-dialog.ui: some reordering of the editor settings, new spin box for the size difference between lexer default font and line numbers in the editor
author Torsten <mttl@mailbox.org>
date Sun, 14 May 2017 00:44:43 +0200
parents 1b017f9ee3f1
children 16d77dc05af6
files libgui/src/m-editor/file-editor-tab.cc libgui/src/settings-dialog.cc libgui/src/settings-dialog.ui
diffstat 3 files changed, 274 insertions(+), 173 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc	Sat May 13 17:07:12 2017 +0200
+++ b/libgui/src/m-editor/file-editor-tab.cc	Sun May 14 00:44:43 2017 +0200
@@ -765,9 +765,24 @@
   _edit_area->setIndicatorForegroundColor (hg, _indicator_highlight_all);
   _edit_area->setIndicatorOutlineColor (hg, _indicator_highlight_all);
 
-  // fix line number width with respect to the font size of the lexer
+  // fix line number width with respect to the font size of the lexer and
+  // set the line numbers font depending on the lexers font
   if (settings->value ("editor/showLineNumbers", true).toBool ())
-    auto_margin_width ();
+    {
+      // Line numbers width
+      auto_margin_width ();
+
+      // Line numbers font
+      QFont line_numbers_font = lexer->defaultFont ();
+      int font_size = line_numbers_font.pointSize ();
+      font_size = font_size
+                  + settings->value ("editor/line_numbers_size", 0).toInt ();
+      if (font_size < 4)
+        font_size = 4;
+      line_numbers_font.setPointSize (font_size);
+
+      _edit_area->setMarginsFont (line_numbers_font);
+    }
   else
     _edit_area->setMarginWidth (2,0);
 
--- a/libgui/src/settings-dialog.cc	Sat May 13 17:07:12 2017 +0200
+++ b/libgui/src/settings-dialog.cc	Sun May 14 00:44:43 2017 +0200
@@ -385,6 +385,8 @@
     settings->value ("customFileEditor").toString ());
   ui->editor_showLineNumbers->setChecked (
     settings->value ("editor/showLineNumbers",true).toBool ());
+  ui->editor_linenr_size->setValue (
+      settings->value ("editor/line_numbers_size",0).toInt ());
 
   resource_manager::combo_encoding (ui->editor_combo_encoding);
 
@@ -393,7 +395,7 @@
                                           default_var).value<QColor> ();
   _editor_current_line_color = new color_picker (setting_color);
   ui->editor_grid_current_line->addWidget (_editor_current_line_color,0,3);
-  _editor_current_line_color->setMinimumSize (50,10);
+  _editor_current_line_color->setMinimumSize (20,10);
   _editor_current_line_color->setEnabled (false);
   connect (ui->editor_highlightCurrentLine, SIGNAL (toggled (bool)),
            _editor_current_line_color, SLOT (setEnabled (bool)));
@@ -792,6 +794,8 @@
   settings->setValue ("customFileEditor", ui->customFileEditor->text ());
   settings->setValue ("editor/showLineNumbers",
                       ui->editor_showLineNumbers->isChecked ());
+  settings->setValue ("editor/line_numbers_size",
+                      ui->editor_linenr_size->value ());
   settings->setValue ("editor/highlightCurrentLine",
                       ui->editor_highlightCurrentLine->isChecked ());
   settings->setValue ("editor/highlight_current_line_color",
--- a/libgui/src/settings-dialog.ui	Sat May 13 17:07:12 2017 +0200
+++ b/libgui/src/settings-dialog.ui	Sun May 14 00:44:43 2017 +0200
@@ -500,7 +500,7 @@
             <x>0</x>
             <y>0</y>
             <width>642</width>
-            <height>956</height>
+            <height>936</height>
            </rect>
           </property>
           <layout class="QVBoxLayout" name="verticalLayout_16">
@@ -515,20 +515,13 @@
                 <property name="topMargin">
                  <number>0</number>
                 </property>
-                <item row="3" column="2">
-                 <widget class="QCheckBox" name="editor_ws_indent_checkbox">
-                  <property name="enabled">
-                   <bool>false</bool>
-                  </property>
-                  <property name="text">
-                   <string>Do not show whitespace used for indentation</string>
-                  </property>
-                 </widget>
-                </item>
                 <item row="1" column="2">
                  <layout class="QGridLayout" name="gridLayout_6">
                   <item row="0" column="0">
                    <widget class="QLabel" name="editor_lbl_min_tab_width">
+                    <property name="enabled">
+                     <bool>false</bool>
+                    </property>
                     <property name="text">
                      <string>Tab width min.</string>
                     </property>
@@ -571,6 +564,9 @@
                   </item>
                   <item row="0" column="5">
                    <widget class="QSpinBox" name="editor_notebook_tab_width_max">
+                    <property name="enabled">
+                     <bool>false</bool>
+                    </property>
                     <property name="sizePolicy">
                      <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                       <horstretch>0</horstretch>
@@ -593,6 +589,9 @@
                   </item>
                   <item row="0" column="4">
                    <widget class="QLabel" name="editor_lbl_max_tab_width">
+                    <property name="enabled">
+                     <bool>false</bool>
+                    </property>
                     <property name="text">
                      <string>max.</string>
                     </property>
@@ -600,164 +599,6 @@
                   </item>
                  </layout>
                 </item>
-                <item row="3" column="0">
-                 <widget class="QCheckBox" name="editor_ws_checkbox">
-                  <property name="sizePolicy">
-                   <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
-                    <horstretch>0</horstretch>
-                    <verstretch>0</verstretch>
-                   </sizepolicy>
-                  </property>
-                  <property name="text">
-                   <string>Show whitespace</string>
-                  </property>
-                 </widget>
-                </item>
-                <item row="9" column="0">
-                 <widget class="QCheckBox" name="cb_edit_status_bar">
-                  <property name="sizePolicy">
-                   <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
-                    <horstretch>0</horstretch>
-                    <verstretch>0</verstretch>
-                   </sizepolicy>
-                  </property>
-                  <property name="text">
-                   <string>Show status bar</string>
-                  </property>
-                  <property name="checked">
-                   <bool>true</bool>
-                  </property>
-                 </widget>
-                </item>
-                <item row="8" column="0">
-                 <widget class="QCheckBox" name="cb_code_folding">
-                  <property name="sizePolicy">
-                   <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
-                    <horstretch>0</horstretch>
-                    <verstretch>0</verstretch>
-                   </sizepolicy>
-                  </property>
-                  <property name="text">
-                   <string>Enable Code Folding</string>
-                  </property>
-                  <property name="checked">
-                   <bool>true</bool>
-                  </property>
-                 </widget>
-                </item>
-                <item row="9" column="2">
-                 <widget class="QCheckBox" name="cb_edit_tool_bar">
-                  <property name="sizePolicy">
-                   <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
-                    <horstretch>0</horstretch>
-                    <verstretch>0</verstretch>
-                   </sizepolicy>
-                  </property>
-                  <property name="text">
-                   <string>Show tool bar</string>
-                  </property>
-                  <property name="checked">
-                   <bool>true</bool>
-                  </property>
-                 </widget>
-                </item>
-                <item row="2" column="2">
-                 <widget class="QCheckBox" name="cb_show_eol">
-                  <property name="sizePolicy">
-                   <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
-                    <horstretch>0</horstretch>
-                    <verstretch>0</verstretch>
-                   </sizepolicy>
-                  </property>
-                  <property name="text">
-                   <string>Show EOL characters</string>
-                  </property>
-                 </widget>
-                </item>
-                <item row="5" column="2">
-                 <layout class="QGridLayout" name="editor_grid_current_line" rowstretch="0" columnstretch="0,0,0,0,0">
-                  <property name="horizontalSpacing">
-                   <number>12</number>
-                  </property>
-                  <property name="verticalSpacing">
-                   <number>0</number>
-                  </property>
-                  <item row="0" column="1">
-                   <widget class="QLabel" name="editor_label_cl_color">
-                    <property name="enabled">
-                     <bool>false</bool>
-                    </property>
-                    <property name="text">
-                     <string>Color</string>
-                    </property>
-                   </widget>
-                  </item>
-                  <item row="0" column="3">
-                   <spacer name="horizontalSpacer_11">
-                    <property name="orientation">
-                     <enum>Qt::Horizontal</enum>
-                    </property>
-                    <property name="sizeType">
-                     <enum>QSizePolicy::Fixed</enum>
-                    </property>
-                    <property name="sizeHint" stdset="0">
-                     <size>
-                      <width>80</width>
-                      <height>20</height>
-                     </size>
-                    </property>
-                   </spacer>
-                  </item>
-                  <item row="0" column="4">
-                   <spacer name="horizontalSpacer_9">
-                    <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>
-                <item row="5" column="0">
-                 <widget class="QCheckBox" name="editor_highlightCurrentLine">
-                  <property name="enabled">
-                   <bool>true</bool>
-                  </property>
-                  <property name="sizePolicy">
-                   <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
-                    <horstretch>0</horstretch>
-                    <verstretch>0</verstretch>
-                   </sizepolicy>
-                  </property>
-                  <property name="text">
-                   <string>Highlight current line</string>
-                  </property>
-                 </widget>
-                </item>
-                <item row="10" column="0">
-                 <widget class="QCheckBox" name="cb_show_hscrollbar">
-                  <property name="enabled">
-                   <bool>true</bool>
-                  </property>
-                  <property name="sizePolicy">
-                   <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
-                    <horstretch>0</horstretch>
-                    <verstretch>0</verstretch>
-                   </sizepolicy>
-                  </property>
-                  <property name="text">
-                   <string>Show horizontal scroll bar</string>
-                  </property>
-                  <property name="checked">
-                   <bool>true</bool>
-                  </property>
-                 </widget>
-                </item>
                 <item row="1" column="0">
                  <widget class="QCheckBox" name="editor_longWindowTitle">
                   <property name="sizePolicy">
@@ -767,7 +608,7 @@
                    </sizepolicy>
                   </property>
                   <property name="text">
-                   <string>Show complete path in window title</string>
+                   <string>Show complete path in title</string>
                   </property>
                  </widget>
                 </item>
@@ -787,6 +628,32 @@
                   </property>
                  </spacer>
                 </item>
+                <item row="3" column="2">
+                 <widget class="QCheckBox" name="editor_ws_indent_checkbox">
+                  <property name="enabled">
+                   <bool>false</bool>
+                  </property>
+                  <property name="text">
+                   <string>Do not show whitespace used for indentation</string>
+                  </property>
+                 </widget>
+                </item>
+                <item row="10" column="0">
+                 <widget class="QCheckBox" name="cb_edit_status_bar">
+                  <property name="sizePolicy">
+                   <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+                    <horstretch>0</horstretch>
+                    <verstretch>0</verstretch>
+                   </sizepolicy>
+                  </property>
+                  <property name="text">
+                   <string>Show status bar</string>
+                  </property>
+                  <property name="checked">
+                   <bool>true</bool>
+                  </property>
+                 </widget>
+                </item>
                 <item row="2" column="0">
                  <widget class="QCheckBox" name="editor_showLineNumbers">
                   <property name="enabled">
@@ -803,6 +670,189 @@
                   </property>
                  </widget>
                 </item>
+                <item row="3" column="0">
+                 <widget class="QCheckBox" name="editor_ws_checkbox">
+                  <property name="sizePolicy">
+                   <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+                    <horstretch>0</horstretch>
+                    <verstretch>0</verstretch>
+                   </sizepolicy>
+                  </property>
+                  <property name="text">
+                   <string>Show whitespace</string>
+                  </property>
+                 </widget>
+                </item>
+                <item row="9" column="0">
+                 <widget class="QCheckBox" name="cb_code_folding">
+                  <property name="sizePolicy">
+                   <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+                    <horstretch>0</horstretch>
+                    <verstretch>0</verstretch>
+                   </sizepolicy>
+                  </property>
+                  <property name="text">
+                   <string>Enable Code Folding</string>
+                  </property>
+                  <property name="checked">
+                   <bool>true</bool>
+                  </property>
+                 </widget>
+                </item>
+                <item row="10" column="2">
+                 <widget class="QCheckBox" name="cb_edit_tool_bar">
+                  <property name="sizePolicy">
+                   <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+                    <horstretch>0</horstretch>
+                    <verstretch>0</verstretch>
+                   </sizepolicy>
+                  </property>
+                  <property name="text">
+                   <string>Show tool bar</string>
+                  </property>
+                  <property name="checked">
+                   <bool>true</bool>
+                  </property>
+                 </widget>
+                </item>
+                <item row="9" column="2">
+                 <widget class="QCheckBox" name="cb_show_hscrollbar">
+                  <property name="enabled">
+                   <bool>true</bool>
+                  </property>
+                  <property name="sizePolicy">
+                   <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+                    <horstretch>0</horstretch>
+                    <verstretch>0</verstretch>
+                   </sizepolicy>
+                  </property>
+                  <property name="text">
+                   <string>Show horizontal scroll bar</string>
+                  </property>
+                  <property name="checked">
+                   <bool>true</bool>
+                  </property>
+                 </widget>
+                </item>
+                <item row="2" column="2">
+                 <layout class="QGridLayout" name="gridLayout_17">
+                  <item row="0" column="0">
+                   <widget class="QLabel" name="editor_linenr_size_label">
+                    <property name="text">
+                     <string>Number size as difference to editor font</string>
+                    </property>
+                   </widget>
+                  </item>
+                  <item row="0" column="1">
+                   <widget class="QSpinBox" name="editor_linenr_size">
+                    <property name="enabled">
+                     <bool>false</bool>
+                    </property>
+                    <property name="sizePolicy">
+                     <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+                      <horstretch>0</horstretch>
+                      <verstretch>0</verstretch>
+                     </sizepolicy>
+                    </property>
+                    <property name="minimum">
+                     <number>-6</number>
+                    </property>
+                    <property name="maximum">
+                     <number>6</number>
+                    </property>
+                   </widget>
+                  </item>
+                  <item row="0" column="2">
+                   <spacer name="horizontalSpacer_9">
+                    <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>
+                <item row="4" column="2">
+                 <layout class="QGridLayout" name="gridLayout_16">
+                  <item row="0" column="1">
+                   <spacer name="horizontalSpacer_11">
+                    <property name="orientation">
+                     <enum>Qt::Horizontal</enum>
+                    </property>
+                    <property name="sizeHint" stdset="0">
+                     <size>
+                      <width>40</width>
+                      <height>20</height>
+                     </size>
+                    </property>
+                   </spacer>
+                  </item>
+                  <item row="0" column="0">
+                   <layout class="QGridLayout" name="editor_grid_current_line">
+                    <item row="0" column="2">
+                     <widget class="QLabel" name="editor_label_cl_color">
+                      <property name="enabled">
+                       <bool>false</bool>
+                      </property>
+                      <property name="text">
+                       <string>Color</string>
+                      </property>
+                     </widget>
+                    </item>
+                    <item row="0" column="0">
+                     <widget class="QCheckBox" name="editor_highlightCurrentLine">
+                      <property name="enabled">
+                       <bool>true</bool>
+                      </property>
+                      <property name="sizePolicy">
+                       <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+                        <horstretch>0</horstretch>
+                        <verstretch>0</verstretch>
+                       </sizepolicy>
+                      </property>
+                      <property name="text">
+                       <string>Highlight current line</string>
+                      </property>
+                     </widget>
+                    </item>
+                    <item row="0" column="1">
+                     <spacer name="horizontalSpacer_14">
+                      <property name="orientation">
+                       <enum>Qt::Horizontal</enum>
+                      </property>
+                      <property name="sizeType">
+                       <enum>QSizePolicy::Fixed</enum>
+                      </property>
+                      <property name="sizeHint" stdset="0">
+                       <size>
+                        <width>20</width>
+                        <height>20</height>
+                       </size>
+                      </property>
+                     </spacer>
+                    </item>
+                   </layout>
+                  </item>
+                 </layout>
+                </item>
+                <item row="4" column="0">
+                 <widget class="QCheckBox" name="cb_show_eol">
+                  <property name="sizePolicy">
+                   <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+                    <horstretch>0</horstretch>
+                    <verstretch>0</verstretch>
+                   </sizepolicy>
+                  </property>
+                  <property name="text">
+                   <string>Show EOL characters</string>
+                  </property>
+                 </widget>
+                </item>
                </layout>
               </item>
               <item>
@@ -3087,5 +3137,37 @@
     </hint>
    </hints>
   </connection>
+  <connection>
+   <sender>editor_showLineNumbers</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>editor_linenr_size_label</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>161</x>
+     <y>124</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>377</x>
+     <y>124</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>editor_showLineNumbers</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>editor_linenr_size</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>161</x>
+     <y>124</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>488</x>
+     <y>124</y>
+    </hint>
+   </hints>
+  </connection>
  </connections>
 </ui>