Mercurial > hg > octave-jordi
changeset 19912:2a992bd19169
make color gradient of custom title bar adjustable (bug #44435)
* settings-dialog.ui: new spinbox for 3D effect of custom title bars
* settings-dialog.cc (settings_dialog): get settings for 3D effect and
initialize the spin box;
(write_changed_settings): write current spin box value into settings file;
* octave-dock-widget.h: new class variable for 3D effect
* octave-dock-widget.cc (octave_dock_widget): init new class variable;
(set_style): set the gradient depending on class variable;
(handle_settings): get settings on 3D effect from settings files
author | Torsten <ttl@justmail.de> |
---|---|
date | Fri, 06 Mar 2015 07:42:13 +0100 |
parents | b8ce2f42815c |
children | d9f6260cf20a |
files | libgui/src/octave-dock-widget.cc libgui/src/octave-dock-widget.h libgui/src/settings-dialog.cc libgui/src/settings-dialog.ui |
diffstat | 4 files changed, 133 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/octave-dock-widget.cc +++ b/libgui/src/octave-dock-widget.cc @@ -79,6 +79,7 @@ _close_button->setIconSize (QSize (12,12)); _icon_color = ""; + _title_3d = 50; QHBoxLayout *h_layout = new QHBoxLayout (); h_layout->addStretch (100); @@ -316,11 +317,24 @@ icon_col = _icon_color; } + QColor bg_col_top, bg_col_bottom; + if (_title_3d > 0) + { + bg_col_top = bg_col.lighter (100 + _title_3d); + bg_col_bottom = bg_col.darker (100 + _title_3d); + } + else + { + bg_col_top = bg_col.darker (100 - _title_3d); + bg_col_bottom = bg_col.lighter (100 - _title_3d); + } + QString background = QString ("background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1," - " stop: 0 %1, stop: 0.75 %2, stop: 0.9 %2, stop: 1.0 %1);"). - arg (bg_col.lighter ().name ()). - arg (bg_col.name ()); + " stop: 0 %1, stop: 0.60 %2, stop: 0.95 %2 stop: 1.0 %3);"). + arg (bg_col_top.name ()). + arg (bg_col.name ()). + arg (bg_col_bottom.name ()); #if defined (Q_OS_WIN32) css = background + QString (" color: %1 ;").arg (fg_col.name ()); @@ -374,6 +388,9 @@ _custom_style = settings->value ("DockWidgets/widget_title_custom_style",false).toBool (); + _title_3d = + settings->value ("DockWidgets/widget_title_3d",50).toInt (); + QColor default_var = QColor (0,0,0); _fg_color = settings->value ("Dockwidgets/title_fg_color", default_var).value<QColor> ();
--- a/libgui/src/octave-dock-widget.h +++ b/libgui/src/octave-dock-widget.h @@ -122,6 +122,7 @@ QMainWindow *_parent; // store the parent since we are reparenting to 0 bool _floating; bool _custom_style; + int _title_3d; QColor _bg_color; QColor _bg_color_active; QColor _fg_color;
--- a/libgui/src/settings-dialog.cc +++ b/libgui/src/settings-dialog.cc @@ -144,6 +144,8 @@ connect (ui->cb_widget_custom_style, SIGNAL (toggled (bool)), _widget_title_fg_color_active, SLOT (setEnabled (bool))); + ui->sb_3d_title->setValue ( + settings->value ("DockWidgets/widget_title_3d", 50).toInt ()); ui->cb_widget_custom_style->setChecked ( settings->value ("DockWidgets/widget_title_custom_style",false).toBool ()); @@ -644,6 +646,8 @@ // dock widget title bar settings->setValue ("DockWidgets/widget_title_custom_style", ui->cb_widget_custom_style->isChecked ()); + settings->setValue ("DockWidgets/widget_title_3d", + ui->sb_3d_title->value ( )); settings->setValue ("Dockwidgets/title_bg_color", _widget_title_bg_color->color ()); settings->setValue ("Dockwidgets/title_bg_color_active",
--- a/libgui/src/settings-dialog.ui +++ b/libgui/src/settings-dialog.ui @@ -32,7 +32,7 @@ </size> </property> <property name="currentIndex"> - <number>1</number> + <number>0</number> </property> <widget class="QWidget" name="tab_general"> <property name="enabled"> @@ -52,8 +52,8 @@ <rect> <x>0</x> <y>0</y> - <width>678</width> - <height>378</height> + <width>662</width> + <height>382</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_17"> @@ -226,6 +226,41 @@ <layout class="QHBoxLayout" name="horizontalLayout_4"> <item> <layout class="QGridLayout" name="gridLayout_13"> + <property name="rightMargin"> + <number>0</number> + </property> + <item row="0" column="9"> + <widget class="QLabel" name="label_bgtitle_active"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Active</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="1" column="4"> + <layout class="QHBoxLayout" name="layout_widget_fgtitle"/> + </item> + <item row="0" column="1"> + <spacer name="horizontalSpacer_22"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> <item row="1" column="2"> <widget class="QLabel" name="label_fgtitle"> <property name="enabled"> @@ -252,13 +287,6 @@ </property> </widget> </item> - <item row="0" column="0"> - <widget class="QCheckBox" name="cb_widget_custom_style"> - <property name="text"> - <string>Custom style</string> - </property> - </widget> - </item> <item row="0" column="7"> <spacer name="horizontalSpacer_23"> <property name="orientation"> @@ -275,38 +303,13 @@ </property> </spacer> </item> - <item row="0" column="1"> - <spacer name="horizontalSpacer_22"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="0" column="9"> - <widget class="QLabel" name="label_bgtitle_active"> - <property name="enabled"> - <bool>false</bool> - </property> + <item row="0" column="0"> + <widget class="QCheckBox" name="cb_widget_custom_style"> <property name="text"> - <string>Active</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + <string>Custom style</string> </property> </widget> </item> - <item row="1" column="4"> - <layout class="QHBoxLayout" name="layout_widget_fgtitle"/> - </item> <item row="0" column="4"> <layout class="QHBoxLayout" name="layout_widget_bgtitle"/> </item> @@ -329,6 +332,41 @@ <item row="1" column="10"> <layout class="QHBoxLayout" name="layout_widget_fgtitle_active"/> </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_3d_title"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>3D</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QSpinBox" name="sb_3d_title"> + <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>-80</number> + </property> + <property name="maximum"> + <number>80</number> + </property> + <property name="value"> + <number>50</number> + </property> + </widget> + </item> </layout> </item> <item> @@ -2900,5 +2938,37 @@ </hint> </hints> </connection> + <connection> + <sender>cb_widget_custom_style</sender> + <signal>toggled(bool)</signal> + <receiver>label_3d_title</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>260</x> + <y>186</y> + </hint> + <hint type="destinationlabel"> + <x>419</x> + <y>236</y> + </hint> + </hints> + </connection> + <connection> + <sender>cb_widget_custom_style</sender> + <signal>toggled(bool)</signal> + <receiver>sb_3d_title</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>260</x> + <y>186</y> + </hint> + <hint type="destinationlabel"> + <x>507</x> + <y>236</y> + </hint> + </hints> + </connection> </connections> </ui>