Mercurial > hg > octave-nkf
changeset 18411:3df71e1d3b24 gui-release
improve width of editor tabs when showing complete file path
* settings-dialog.ui (editor tab): new option for min tab width
* settings-dialog.cc (constructor): init new spin box for min tab width;
(write-changed-settings): read value from new spin box for min tab width
* file-editor.cc (notice-settings): elife mode and style sheet for tabs
width new min. and max. option only when displaying complete path
author | Torsten <ttl@justmail.de> |
---|---|
date | Thu, 23 Jan 2014 19:35:43 +0100 |
parents | 1ecfcfa4858e |
children | dfc6ef6ac455 |
files | libgui/src/m-editor/file-editor.cc libgui/src/settings-dialog.cc libgui/src/settings-dialog.ui |
diffstat | 3 files changed, 139 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor.cc +++ b/libgui/src/m-editor/file-editor.cc @@ -856,10 +856,26 @@ int icon_size = settings->value ("toolbar_icon_size", 16).toInt (); _tool_bar->setIconSize (QSize (icon_size, icon_size)); - int tab_width = settings->value ("editor/notebook_tab_width", 300).toInt (); - QString style_sheet = QString ("QTabBar::tab {max-height: 4ex; " - "max-width: %1px; text-align: right }"). - arg (tab_width); + int tab_width_min = settings->value ("editor/notebook_tab_width_min", 160) + .toInt (); + int tab_width_max = settings->value ("editor/notebook_tab_width_max", 300) + .toInt (); + + QString style_sheet; + if (settings->value ("editor/longWindowTitle", false).toBool ()) + { + style_sheet = QString ("QTabBar::tab {max-height: 4ex; " + "min-width: %1px; max-width: %2px;}") + .arg (tab_width_min).arg (tab_width_max); + _tab_widget->setElideMode (Qt::ElideLeft); + } + else + { + style_sheet = QString ("QTabBar::tab {max-height: 4ex;}"); + _tab_widget->setElideMode (Qt::ElideNone); + } + + _tab_widget->setUsesScrollButtons (true); _tab_widget->setStyleSheet (style_sheet); // Relay signal to file editor tabs. @@ -894,8 +910,6 @@ #ifdef HAVE_QTABWIDGET_SETMOVABLE _tab_widget->setMovable (true); #endif - _tab_widget->setElideMode (Qt::ElideLeft); - QAction *new_action = new QAction (QIcon (":/actions/icons/filenew.png"), tr ("&New File"), _tool_bar);
--- a/libgui/src/settings-dialog.cc +++ b/libgui/src/settings-dialog.cc @@ -173,8 +173,10 @@ settings->value ("editor/tab_width", 2).toInt ()); ui->editor_longWindowTitle->setChecked ( settings->value ("editor/longWindowTitle",false).toBool ()); - ui->editor_notebook_tab_width->setValue ( - settings->value ("editor/notebook_tab_width", 300).toInt ()); + ui->editor_notebook_tab_width_min->setValue ( + settings->value ("editor/notebook_tab_width_min", 160).toInt ()); + ui->editor_notebook_tab_width_max->setValue ( + settings->value ("editor/notebook_tab_width_max", 300).toInt ()); ui->editor_restoreSession->setChecked ( settings->value ("editor/restoreSession", true).toBool ()); ui->editor_create_new_file->setChecked ( @@ -570,8 +572,10 @@ ui->editor_tab_width_spinbox->value ()); settings->setValue ("editor/longWindowTitle", ui->editor_longWindowTitle->isChecked ()); - settings->setValue ("editor/notebook_tab_width", - ui->editor_notebook_tab_width->value ()); + settings->setValue ("editor/notebook_tab_width_min", + ui->editor_notebook_tab_width_min->value ()); + settings->setValue ("editor/notebook_tab_width_max", + ui->editor_notebook_tab_width_max->value ()); settings->setValue ("editor/restoreSession", ui->editor_restoreSession->isChecked ()); settings->setValue ("editor/create_new_file",
--- a/libgui/src/settings-dialog.ui +++ b/libgui/src/settings-dialog.ui @@ -32,7 +32,7 @@ </size> </property> <property name="currentIndex"> - <number>0</number> + <number>1</number> </property> <widget class="QWidget" name="tab_general"> <property name="enabled"> @@ -388,7 +388,7 @@ <rect> <x>0</x> <y>0</y> - <width>554</width> + <width>662</width> <height>399</height> </rect> </property> @@ -554,16 +554,45 @@ <item row="1" column="2"> <layout class="QGridLayout" name="gridLayout_6"> <item row="0" column="0"> - <widget class="QLabel" name="label_16"> + <widget class="QLabel" name="editor_lbl_min_tab_width"> <property name="text"> - <string>Max. tab width in pixel</string> + <string>Tab width min.</string> </property> </widget> </item> - <item row="0" column="1"> - <widget class="QSpinBox" name="editor_notebook_tab_width"> + <item row="0" column="3"> + <widget class="QSpinBox" name="editor_notebook_tab_width_min"> <property name="minimum"> - <number>100</number> + <number>80</number> + </property> + <property name="maximum"> + <number>600</number> + </property> + <property name="singleStep"> + <number>20</number> + </property> + <property name="value"> + <number>160</number> + </property> + </widget> + </item> + <item row="0" column="6"> + <spacer name="horizontalSpacer_25"> + <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="5"> + <widget class="QSpinBox" name="editor_notebook_tab_width_max"> + <property name="minimum"> + <number>180</number> </property> <property name="maximum"> <number>600</number> @@ -576,18 +605,12 @@ </property> </widget> </item> - <item row="0" column="2"> - <spacer name="horizontalSpacer_25"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> + <item row="0" column="4"> + <widget class="QLabel" name="editor_lbl_max_tab_width"> + <property name="text"> + <string>max.</string> </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> + </widget> </item> </layout> </item> @@ -1327,8 +1350,8 @@ <rect> <x>0</x> <y>0</y> - <width>474</width> - <height>318</height> + <width>678</width> + <height>378</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_18"> @@ -1491,8 +1514,8 @@ <rect> <x>0</x> <y>0</y> - <width>154</width> - <height>114</height> + <width>678</width> + <height>378</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_19"> @@ -1569,8 +1592,8 @@ <rect> <x>0</x> <y>0</y> - <width>529</width> - <height>204</height> + <width>678</width> + <height>378</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_20"> @@ -2174,5 +2197,69 @@ </hint> </hints> </connection> + <connection> + <sender>editor_longWindowTitle</sender> + <signal>toggled(bool)</signal> + <receiver>editor_lbl_min_tab_width</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>145</x> + <y>72</y> + </hint> + <hint type="destinationlabel"> + <x>343</x> + <y>72</y> + </hint> + </hints> + </connection> + <connection> + <sender>editor_longWindowTitle</sender> + <signal>toggled(bool)</signal> + <receiver>editor_notebook_tab_width_max</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>145</x> + <y>72</y> + </hint> + <hint type="destinationlabel"> + <x>437</x> + <y>72</y> + </hint> + </hints> + </connection> + <connection> + <sender>editor_longWindowTitle</sender> + <signal>toggled(bool)</signal> + <receiver>editor_lbl_max_tab_width</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>145</x> + <y>72</y> + </hint> + <hint type="destinationlabel"> + <x>439</x> + <y>72</y> + </hint> + </hints> + </connection> + <connection> + <sender>editor_longWindowTitle</sender> + <signal>toggled(bool)</signal> + <receiver>editor_notebook_tab_width_min</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>145</x> + <y>72</y> + </hint> + <hint type="destinationlabel"> + <x>393</x> + <y>72</y> + </hint> + </hints> + </connection> </connections> </ui>