Mercurial > hg > octave-jordi
changeset 20991:73e92fca3c78
GUI: add editor toolbar display option (Bug #46705)
* libgui/src/m-editor/file-editor.cc, libgui/src/m-editor/file-editor.h
(file_editor::show_toolbar): new function
(file_editor::notice_settings): set toolbar state from settings
(file_editor::construct): add show toolbar action
* libgui/src/settings-dialog.cc
(settings_dialog::settings_dialog): set toolbar checkbox from settings
(settings_dialog::write_changed_settings): save toolbar state to settings
* libgui/src/settings-dialog.ui: added showtoolbar checkbox
author | John Donoghue <john.donoghue@ieee.org> |
---|---|
date | Sun, 27 Dec 2015 10:50:32 -0500 |
parents | 3ec8332e0e01 |
children | 31a12af0aaaf |
files | libgui/src/m-editor/file-editor.cc libgui/src/m-editor/file-editor.h libgui/src/settings-dialog.cc libgui/src/settings-dialog.ui |
diffstat | 4 files changed, 173 insertions(+), 137 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor.cc +++ b/libgui/src/m-editor/file-editor.cc @@ -1167,6 +1167,11 @@ { toggle_preference ("editor/long_line_marker",true); } +void +file_editor::show_toolbar (bool) +{ + toggle_preference ("editor/show_toolbar",true); +} void file_editor::zoom_in (bool) @@ -1256,6 +1261,10 @@ show_it = settings->value ("editor/long_line_marker",true).toBool (); _show_longline_action->setChecked (show_it); + show_it = settings->value ("editor/show_toolbar",true).toBool (); + _show_toolbar_action->setChecked (show_it); + _tool_bar->setVisible (show_it); + set_shortcuts (); // Relay signal to file editor tabs. @@ -1593,6 +1602,10 @@ tr ("Show Long Line &Marker"), SLOT (show_long_line (bool))); _show_longline_action->setCheckable (true); + _show_toolbar_action = add_action (_view_editor_menu, QIcon (), + tr ("Show &Toolbar"), SLOT (show_toolbar (bool))); + _show_toolbar_action->setCheckable (true); + view_menu->addSeparator (); _zoom_in_action = add_action (view_menu, resource_manager::icon ("zoom-in"), @@ -2003,6 +2016,7 @@ shortcut_manager::set_shortcut (_show_eol_action, "editor_view:show_eol_chars"); shortcut_manager::set_shortcut (_show_indguide_action, "editor_view:show_ind_guides"); shortcut_manager::set_shortcut (_show_longline_action, "editor_view:show_long_line"); + shortcut_manager::set_shortcut (_show_toolbar_action, "editor_view:show_toolbar"); shortcut_manager::set_shortcut (_zoom_in_action, "editor_view:zoom_in"); shortcut_manager::set_shortcut (_zoom_out_action, "editor_view:zoom_out"); shortcut_manager::set_shortcut (_zoom_normal_action, "editor_view:zoom_normal");
--- a/libgui/src/m-editor/file-editor.h +++ b/libgui/src/m-editor/file-editor.h @@ -271,6 +271,7 @@ void show_eol_chars (bool); void show_indent_guides (bool); void show_long_line (bool); + void show_toolbar (bool); void zoom_in (bool); void zoom_out (bool); void zoom_normal (bool); @@ -346,6 +347,7 @@ QAction *_show_eol_action; QAction *_show_indguide_action; QAction *_show_longline_action; + QAction *_show_toolbar_action; QAction *_zoom_in_action; QAction *_zoom_out_action; QAction *_zoom_normal_action;
--- a/libgui/src/settings-dialog.cc +++ b/libgui/src/settings-dialog.cc @@ -395,6 +395,8 @@ settings->value ("editor/long_line_column",80).toInt ()); ui->cb_edit_status_bar->setChecked ( settings->value ("editor/show_edit_status_bar",true).toBool ()); + ui->cb_edit_tool_bar->setChecked ( + settings->value ("editor/show_toolbar",true).toBool ()); ui->cb_code_folding->setChecked ( settings->value ("editor/code_folding",true).toBool ()); @@ -777,6 +779,8 @@ ui->cb_code_folding->isChecked ()); settings->setValue ("editor/show_edit_status_bar", ui->cb_edit_status_bar->isChecked ()); + settings->setValue ("editor/show_toolbar", + ui->cb_edit_tool_bar->isChecked ()); settings->setValue ("editor/codeCompletion", ui->editor_codeCompletion->isChecked ()); settings->setValue ("editor/codeCompletion_threshold", @@ -1039,4 +1043,4 @@ settings_dialog::default_shortcut_set () { shortcut_manager::import_export (shortcut_manager::OSC_DEFAULT); -} \ No newline at end of file +}
--- a/libgui/src/settings-dialog.ui +++ b/libgui/src/settings-dialog.ui @@ -512,11 +512,27 @@ <layout class="QVBoxLayout" name="verticalLayout_13"> <item> <layout class="QGridLayout" name="editor_common_settings_grid"> - <item row="5" column="0"> - <widget class="QCheckBox" name="editor_highlightCurrentLine"> - <property name="enabled"> + <item row="6" column="0"> + <widget class="QCheckBox" name="editor_long_line_marker"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>This works well for monospaced fonts. The line is drawn at a position based on the width of a space character in the default font. It may not work very well if styles use proportional fonts or if varied font sizes or bold, italic and normal texts are used.</string> + </property> + <property name="text"> + <string>Draw a long line marker</string> + </property> + <property name="checked"> <bool>true</bool> </property> + </widget> + </item> + <item row="8" column="2"> + <widget class="QCheckBox" name="cb_edit_tool_bar"> <property name="sizePolicy"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -524,63 +540,10 @@ </sizepolicy> </property> <property name="text"> - <string>Highlight current line</string> + <string>Show tool bar</string> </property> - </widget> - </item> - <item row="6" column="2"> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="QLabel" name="editor_long_line_column_text"> - <property name="text"> - <string>After Column</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="editor_long_line_column"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimum"> - <number>2</number> - </property> - <property name="maximum"> - <number>256</number> - </property> - <property name="value"> - <number>80</number> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_7"> - <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="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 name="checked"> + <bool>true</bool> </property> </widget> </item> @@ -600,28 +563,21 @@ </property> </widget> </item> - <item row="1" column="0"> - <widget class="QCheckBox" name="editor_longWindowTitle"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <item row="1" column="1"> + <spacer name="horizontalSpacer_24"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> </property> - <property name="text"> - <string>Show complete path in window title</string> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> </property> - </widget> - </item> - <item row="3" column="2"> - <widget class="QCheckBox" name="editor_ws_indent_checkbox"> - <property name="enabled"> - <bool>false</bool> + <property name="sizeHint" stdset="0"> + <size> + <width>10</width> + <height>0</height> + </size> </property> - <property name="text"> - <string>Do not show whitespace used for indentation</string> - </property> - </widget> + </spacer> </item> <item row="5" column="2"> <layout class="QGridLayout" name="editor_grid_current_line" rowstretch="0" columnstretch="0,0,0,0,0"> @@ -672,6 +628,61 @@ </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="1" column="0"> + <widget class="QCheckBox" name="editor_longWindowTitle"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Show complete path in window title</string> + </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="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> <item row="1" column="2"> <layout class="QGridLayout" name="gridLayout_6"> <item row="0" column="0"> @@ -747,40 +758,48 @@ </item> </layout> </item> - <item row="1" column="1"> - <spacer name="horizontalSpacer_24"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>10</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - <item row="6" column="0"> - <widget class="QCheckBox" name="editor_long_line_marker"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="toolTip"> - <string>This works well for monospaced fonts. The line is drawn at a position based on the width of a space character in the default font. It may not work very well if styles use proportional fonts or if varied font sizes or bold, italic and normal texts are used.</string> - </property> - <property name="text"> - <string>Draw a long line marker</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> + <item row="6" column="2"> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QLabel" name="editor_long_line_column_text"> + <property name="text"> + <string>After Column</string> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="editor_long_line_column"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimum"> + <number>2</number> + </property> + <property name="maximum"> + <number>256</number> + </property> + <property name="value"> + <number>80</number> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_7"> + <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="7" column="0"> <widget class="QCheckBox" name="cb_code_folding"> @@ -798,32 +817,13 @@ </property> </widget> </item> - <item row="8" 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> + <item row="3" column="2"> + <widget class="QCheckBox" name="editor_ws_indent_checkbox"> + <property name="enabled"> + <bool>false</bool> </property> <property name="text"> - <string>Show status bar</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </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> + <string>Do not show whitespace used for indentation</string> </property> </widget> </item> @@ -846,6 +846,22 @@ </property> </widget> </item> + <item row="8" 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> </layout> </item> <item>