Mercurial > hg > octave-lojdl
changeset 16525:e192525236ad
configurable size of toolbar icons
* settings-dialog.ui: new spin box for icon sizes
* settings-dialog.cc: new setting toolbar_icon_size
* file-editor.cc(notice_settings): read toolbar icon size from settings
* files-dock-widget.cc/h: make toolbar a class variable
(notice-settings): read toolbar icon size from settings and reduce by 4 pixels
* main-window.cc/h: make toolbar a class variable
(notice-settings): read toolbar icon size from settings
author | Torsten <ttl@justmail.de> |
---|---|
date | Tue, 16 Apr 2013 21:34:39 +0200 |
parents | 6a8e63dadfad |
children | 01541f7321f7 |
files | libgui/src/files-dock-widget.cc libgui/src/files-dock-widget.h libgui/src/m-editor/file-editor.cc libgui/src/main-window.cc libgui/src/main-window.h libgui/src/settings-dialog.cc libgui/src/settings-dialog.ui |
diffstat | 7 files changed, 170 insertions(+), 119 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/files-dock-widget.cc +++ b/libgui/src/files-dock-widget.cc @@ -62,12 +62,11 @@ this, SLOT (notice_settings (const QSettings *))); // Create a toolbar - QToolBar *navigation_tool_bar = new QToolBar ("", container); - navigation_tool_bar->setAllowedAreas (Qt::TopToolBarArea); - navigation_tool_bar->setMovable (false); - navigation_tool_bar->setIconSize (QSize (20, 20)); + _navigation_tool_bar = new QToolBar ("", container); + _navigation_tool_bar->setAllowedAreas (Qt::TopToolBarArea); + _navigation_tool_bar->setMovable (false); - _current_directory = new QComboBox (navigation_tool_bar); + _current_directory = new QComboBox (_navigation_tool_bar); _current_directory->setToolTip (tr ("Enter the path or filename")); _current_directory->setEditable(true); _current_directory->setMaxCount(MaxMRUDirs); @@ -77,23 +76,23 @@ _current_directory->setSizePolicy(sizePol); QAction *directory_up_action = new QAction (QIcon(":/actions/icons/up.png"), - "", navigation_tool_bar); + "", _navigation_tool_bar); directory_up_action->setToolTip (tr ("Move up one directory")); _sync_browser_directory_action = new QAction (QIcon(":/actions/icons/reload.png"), - "", navigation_tool_bar); + "", _navigation_tool_bar); _sync_browser_directory_action->setToolTip (tr ("Goto current octave directory")); _sync_browser_directory_action->setEnabled ("false"); _sync_octave_directory_action = new QAction (QIcon(":/actions/icons/ok.png"), - "", navigation_tool_bar); + "", _navigation_tool_bar); _sync_octave_directory_action->setToolTip (tr ("Set octave directroy to current browser directory")); _sync_octave_directory_action->setEnabled ("false"); - navigation_tool_bar->addWidget (_current_directory); - navigation_tool_bar->addAction (directory_up_action); - navigation_tool_bar->addAction (_sync_browser_directory_action); - navigation_tool_bar->addAction (_sync_octave_directory_action); + _navigation_tool_bar->addWidget (_current_directory); + _navigation_tool_bar->addAction (directory_up_action); + _navigation_tool_bar->addAction (_sync_browser_directory_action); + _navigation_tool_bar->addAction (_sync_octave_directory_action); connect (directory_up_action, SIGNAL (triggered ()), this, SLOT (change_directory_up ())); @@ -146,7 +145,7 @@ // Layout the widgets vertically with the toolbar on top QVBoxLayout *vbox_layout = new QVBoxLayout (); vbox_layout->setSpacing (0); - vbox_layout->addWidget (navigation_tool_bar); + vbox_layout->addWidget (_navigation_tool_bar); vbox_layout->addWidget (_file_tree_view); vbox_layout->setMargin (1); @@ -512,6 +511,11 @@ { // Qsettings pointer is checked before emitting. + int icon_size = settings->value ("toolbar_icon_size",24).toInt (); + if (icon_size > 16) + icon_size = icon_size - 4; + _navigation_tool_bar->setIconSize (QSize (icon_size,icon_size)); + // file names are always shown, other columns can be hidden by settings _file_tree_view->setColumnHidden (0, false); _file_tree_view->setColumnHidden (1, !settings->value ("filesdockwidget/showFileSize",false).toBool ());
--- a/libgui/src/files-dock-widget.h +++ b/libgui/src/files-dock-widget.h @@ -115,6 +115,7 @@ void display_directory (const QString& dir, bool set_octave_dir = true); /** Variables for the actions **/ + QToolBar * _navigation_tool_bar; QAction * _sync_octave_directory_action; QAction * _sync_browser_directory_action;
--- a/libgui/src/m-editor/file-editor.cc +++ b/libgui/src/m-editor/file-editor.cc @@ -623,6 +623,8 @@ void file_editor::notice_settings (const QSettings *settings) { + int icon_size = settings->value ("toolbar_icon_size",24).toInt (); + _tool_bar->setIconSize (QSize (icon_size,icon_size)); // Relay signal to file editor tabs. emit fetab_settings_changed (settings); }
--- a/libgui/src/main-window.cc +++ b/libgui/src/main-window.cc @@ -280,6 +280,9 @@ } } + int icon_size = settings->value ("toolbar_icon_size",24).toInt (); + _main_tool_bar->setIconSize (QSize (icon_size,icon_size)); + resource_manager::update_network_settings (); } @@ -1253,21 +1256,21 @@ void main_window::construct_tool_bar (void) { - QToolBar *main_tool_bar = addToolBar ("Main"); + _main_tool_bar = addToolBar ("Main"); - main_tool_bar->setObjectName ("MainToolBar"); - main_tool_bar->addAction (_new_script_action); - main_tool_bar->addAction (_open_action); + _main_tool_bar->setObjectName ("MainToolBar"); + _main_tool_bar->addAction (_new_script_action); + _main_tool_bar->addAction (_open_action); - main_tool_bar->addSeparator (); + _main_tool_bar->addSeparator (); - main_tool_bar->addAction (_cut_action); - main_tool_bar->addAction (_copy_action); - main_tool_bar->addAction (_paste_action); - main_tool_bar->addAction (_undo_action); - main_tool_bar->addAction (_redo_action); + _main_tool_bar->addAction (_cut_action); + _main_tool_bar->addAction (_copy_action); + _main_tool_bar->addAction (_paste_action); + _main_tool_bar->addAction (_undo_action); + _main_tool_bar->addAction (_redo_action); - main_tool_bar->addSeparator (); + _main_tool_bar->addSeparator (); _current_directory_combo_box = new QComboBox (this); _current_directory_combo_box->setFixedWidth (current_directory_width); @@ -1279,20 +1282,16 @@ QSizePolicy sizePol(QSizePolicy::Expanding, QSizePolicy::Preferred); _current_directory_combo_box->setSizePolicy(sizePol); - QToolButton *current_directory_tool_button = new QToolButton (this); - current_directory_tool_button->setIcon (QIcon (":/actions/icons/search.png")); - current_directory_tool_button->setToolTip (tr ("Browse directories")); - - QToolButton *current_directory_up_tool_button = new QToolButton (this); - current_directory_up_tool_button->setIcon (QIcon (":/actions/icons/up.png")); - current_directory_up_tool_button->setToolTip (tr ("One directory up")); - // addWidget takes ownership of the objects so there is no // need to delete these upon destroying this main_window. - main_tool_bar->addWidget (new QLabel (tr ("Current Directory: "))); - main_tool_bar->addWidget (_current_directory_combo_box); - main_tool_bar->addWidget (current_directory_tool_button); - main_tool_bar->addWidget (current_directory_up_tool_button); + _main_tool_bar->addWidget (new QLabel (tr ("Current Directory: "))); + _main_tool_bar->addWidget (_current_directory_combo_box); + QAction *current_dir_up = _main_tool_bar->addAction ( + QIcon (":/actions/icons/up.png"), + tr ("One directory up")); + QAction *current_dir_search = _main_tool_bar->addAction ( + QIcon (":/actions/icons/search.png"), + tr ("Browse directories")); connect (_current_directory_combo_box, SIGNAL (activated (QString)), this, SLOT (set_current_working_directory (QString))); @@ -1300,10 +1299,10 @@ connect (_current_directory_combo_box->lineEdit(), SIGNAL (returnPressed ()), this, SLOT (accept_directory_line_edit ())); - connect (current_directory_tool_button, SIGNAL (clicked ()), + connect (current_dir_search, SIGNAL (triggered ()), this, SLOT (browse_for_directory ())); - connect (current_directory_up_tool_button, SIGNAL (clicked ()), + connect (current_dir_up, SIGNAL (triggered ()), this, SLOT (change_directory_up ())); }
--- a/libgui/src/main-window.h +++ b/libgui/src/main-window.h @@ -215,6 +215,7 @@ file_editor_interface *editor_window; workspace_view *workspace_window; + QToolBar *_main_tool_bar; QMenu *_debug_menu; QAction *_debug_continue;
--- a/libgui/src/settings-dialog.cc +++ b/libgui/src/settings-dialog.cc @@ -68,6 +68,8 @@ else ui->comboBox_language->setCurrentIndex (0); // System is default + ui->toolbar_icon_size->setValue (settings->value ("toolbar_icon_size",24).toInt ()); + // which icon has to be selected QString widget_icon_set = settings->value ("DockWidgets/widget_icon_set","NONE").toString (); @@ -263,6 +265,7 @@ settings->setValue ("language", language); // other settings + settings->setValue ("toolbar_icon_size", ui->toolbar_icon_size->value ()); settings->setValue ("useCustomFileEditor", ui->useCustomFileEditor->isChecked ()); settings->setValue ("customFileEditor", ui->customFileEditor->text ()); settings->setValue ("editor/showLineNumbers", ui->editor_showLineNumbers->isChecked ());
--- a/libgui/src/settings-dialog.ui +++ b/libgui/src/settings-dialog.ui @@ -46,105 +46,146 @@ <rect> <x>9</x> <y>10</y> - <width>561</width> - <height>131</height> + <width>651</width> + <height>371</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_7"> <item> - <layout class="QHBoxLayout" name="horizontalLayout_6"> - <item> + <layout class="QGridLayout" name="gridLayout"> + <item row="3" column="0"> + <widget class="QLabel" name="label_9"> + <property name="text"> + <string>Icon set for dock widgets</string> + </property> + </widget> + </item> + <item row="1" column="0"> <widget class="QLabel" name="label_2"> <property name="text"> <string>Language (requires restart)</string> </property> </widget> </item> - <item> - <widget class="QComboBox" name="comboBox_language"> - <property name="insertPolicy"> - <enum>QComboBox::InsertAtBottom</enum> + <item row="2" column="0"> + <widget class="QLabel" name="label_8"> + <property name="text"> + <string>Icon size</string> </property> </widget> </item> - <item> - <spacer name="horizontalSpacer_3"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> + <item row="2" column="2"> + <layout class="QHBoxLayout" name="horizontalLayout_6"> + <item> + <widget class="QSpinBox" name="toolbar_icon_size"> + <property name="minimum"> + <number>16</number> + </property> + <property name="maximum"> + <number>32</number> + </property> + <property name="singleStep"> + <number>4</number> + </property> + <property name="value"> + <number>24</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> + <item row="1" column="2"> + <layout class="QHBoxLayout" name="horizontalLayout_8"> + <item> + <widget class="QComboBox" name="comboBox_language"> + <property name="insertPolicy"> + <enum>QComboBox::InsertAtBottom</enum> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_3"> + <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="2"> + <layout class="QHBoxLayout" name="horizontalLayout_9"> + <item> + <widget class="QRadioButton" name="general_icon_octave"> + <property name="text"> + <string>Octave logo only</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="general_icon_letter"> + <property name="text"> + <string>Letter icons</string> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="general_icon_graphic"> + <property name="text"> + <string>Graphic icons</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_6"> + <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> </item> <item> - <widget class="QGroupBox" name="groupBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="title"> - <string>Icon set for dock widgets</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> - </property> - <property name="flat"> - <bool>false</bool> - </property> - <property name="checkable"> - <bool>false</bool> + <spacer name="verticalSpacer_4"> + <property name="orientation"> + <enum>Qt::Vertical</enum> </property> - <widget class="QRadioButton" name="general_icon_octave"> - <property name="geometry"> - <rect> - <x>0</x> - <y>20</y> - <width>151</width> - <height>21</height> - </rect> - </property> - <property name="text"> - <string>Octave logo only</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - <widget class="QRadioButton" name="general_icon_letter"> - <property name="geometry"> - <rect> - <x>0</x> - <y>40</y> - <width>151</width> - <height>21</height> - </rect> - </property> - <property name="text"> - <string>Letter icons</string> - </property> - </widget> - <widget class="QRadioButton" name="general_icon_graphic"> - <property name="geometry"> - <rect> - <x>0</x> - <y>60</y> - <width>151</width> - <height>21</height> - </rect> - </property> - <property name="text"> - <string>Graphic icons</string> - </property> - </widget> - </widget> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> </item> </layout> </widget>