author | sandman <sandman> | 2002-07-15 00:52:50 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-07-15 00:52:50 (UTC) |
commit | ecf2a873be3274bb30be0c659b7db6ef8a43be84 (patch) (unidiff) | |
tree | 5c80fb0863966fffd245f6ed44c6bf524c11842b /noncore/styles/liquid/liquid.cpp | |
parent | 4feeec8b5b41cfd3d13274411f515524f687da09 (diff) | |
download | opie-ecf2a873be3274bb30be0c659b7db6ef8a43be84.zip opie-ecf2a873be3274bb30be0c659b7db6ef8a43be84.tar.gz opie-ecf2a873be3274bb30be0c659b7db6ef8a43be84.tar.bz2 |
Added an option to make toolbar buttons flat
Diffstat (limited to 'noncore/styles/liquid/liquid.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/styles/liquid/liquid.cpp | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp index 87b5488..22bf8af 100644 --- a/noncore/styles/liquid/liquid.cpp +++ b/noncore/styles/liquid/liquid.cpp | |||
@@ -166,12 +166,14 @@ bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) | |||
166 | 166 | ||
167 | LiquidStyle::LiquidStyle() | 167 | LiquidStyle::LiquidStyle() |
168 | :QWindowsStyle() | 168 | :QWindowsStyle() |
169 | { | 169 | { |
170 | setName ( "LiquidStyle" ); | 170 | setName ( "LiquidStyle" ); |
171 | 171 | ||
172 | flatTBButtons = false; | ||
173 | |||
172 | btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true); | 174 | btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true); |
173 | btnMaskBmp.setMask(btnMaskBmp); | 175 | btnMaskBmp.setMask(btnMaskBmp); |
174 | htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true); | 176 | htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true); |
175 | htmlBtnMaskBmp.setMask(htmlBtnMaskBmp); | 177 | htmlBtnMaskBmp.setMask(htmlBtnMaskBmp); |
176 | headerHoverID = -1; | 178 | headerHoverID = -1; |
177 | highlightWidget = NULL; | 179 | highlightWidget = NULL; |
@@ -828,12 +830,19 @@ void LiquidStyle::polish(QPalette &appPal) | |||
828 | 830 | ||
829 | void LiquidStyle::polish(QWidget *w) | 831 | void LiquidStyle::polish(QWidget *w) |
830 | { | 832 | { |
831 | if(w->inherits("QMenuBar")){ | 833 | if(w->inherits("QMenuBar")){ |
832 | //((QFrame*)w)->setLineWidth(0); | 834 | //((QFrame*)w)->setLineWidth(0); |
833 | w->setBackgroundMode(QWidget::PaletteBackground); | 835 | w->setBackgroundMode(QWidget::PaletteBackground); |
836 | w->setBackgroundOrigin(QWidget::ParentOrigin); | ||
837 | return; | ||
838 | } | ||
839 | if(w->inherits("QToolBar")){ | ||
840 | w->installEventFilter(this); | ||
841 | w->setBackgroundMode(QWidget::PaletteBackground); | ||
842 | w->setBackgroundOrigin(QWidget::WidgetOrigin); | ||
834 | return; | 843 | return; |
835 | } | 844 | } |
836 | if(w->inherits("QPopupMenu")) | 845 | if(w->inherits("QPopupMenu")) |
837 | w->setBackgroundMode(QWidget::NoBackground); | 846 | w->setBackgroundMode(QWidget::NoBackground); |
838 | else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { | 847 | else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { |
839 | w->installEventFilter(menuHandler); | 848 | w->installEventFilter(menuHandler); |
@@ -890,14 +899,16 @@ void LiquidStyle::polish(QWidget *w) | |||
890 | } | 899 | } |
891 | } | 900 | } |
892 | if(w->inherits("QHeader")){ | 901 | if(w->inherits("QHeader")){ |
893 | w->setMouseTracking(true); | 902 | w->setMouseTracking(true); |
894 | w->installEventFilter(this); | 903 | w->installEventFilter(this); |
895 | } | 904 | } |
896 | if(w-> inherits("QToolButton")) { | 905 | if(w-> inherits("QToolButton")&&w->parent()->inherits("QToolBar")) { |
897 | ((QToolButton*)w)->setAutoRaise (false); | 906 | ((QToolButton*)w)->setAutoRaise (flatTBButtons); |
907 | if ( flatTBButtons ) | ||
908 | w->setBackgroundOrigin(QWidget::ParentOrigin); | ||
898 | } | 909 | } |
899 | if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){ | 910 | if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){ |
900 | return; | 911 | return; |
901 | } | 912 | } |
902 | 913 | ||
903 | if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())-> | 914 | if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())-> |
@@ -909,17 +920,12 @@ void LiquidStyle::polish(QWidget *w) | |||
909 | !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) { | 920 | !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) { |
910 | if(w->backgroundMode() == QWidget::PaletteBackground || | 921 | if(w->backgroundMode() == QWidget::PaletteBackground || |
911 | w->backgroundMode() == QWidget::PaletteButton){ | 922 | w->backgroundMode() == QWidget::PaletteButton){ |
912 | w->setBackgroundMode(QWidget::X11ParentRelative); | 923 | w->setBackgroundMode(QWidget::X11ParentRelative); |
913 | } | 924 | } |
914 | } | 925 | } |
915 | if(w->inherits("QToolBar")){ | ||
916 | w->installEventFilter(this); | ||
917 | w->setBackgroundMode(QWidget::PaletteBackground); | ||
918 | return; | ||
919 | } | ||
920 | 926 | ||
921 | } | 927 | } |
922 | 928 | ||
923 | void LiquidStyle::unPolish(QWidget *w) | 929 | void LiquidStyle::unPolish(QWidget *w) |
924 | { | 930 | { |
925 | if(w->inherits("QMenuBar")){ | 931 | if(w->inherits("QMenuBar")){ |
@@ -998,12 +1004,14 @@ void LiquidStyle::polish(QApplication *app) | |||
998 | 1004 | ||
999 | Config config ( "qpe" ); | 1005 | Config config ( "qpe" ); |
1000 | config. setGroup ( "Liquid-Style" ); | 1006 | config. setGroup ( "Liquid-Style" ); |
1001 | 1007 | ||
1002 | if ( config. readBoolEntry ( "WinDecoration", true )) | 1008 | if ( config. readBoolEntry ( "WinDecoration", true )) |
1003 | QApplication::qwsSetDecoration ( new LiquidDecoration ( )); | 1009 | QApplication::qwsSetDecoration ( new LiquidDecoration ( )); |
1010 | |||
1011 | flatTBButtons = config. readBoolEntry ( "FlatToolButtons", false ); | ||
1004 | } | 1012 | } |
1005 | 1013 | ||
1006 | void LiquidStyle::unPolish(QApplication *app) | 1014 | void LiquidStyle::unPolish(QApplication *app) |
1007 | { | 1015 | { |
1008 | QWindowsStyle::unPolish(app); | 1016 | QWindowsStyle::unPolish(app); |
1009 | app->setEffectEnabled(UI_AnimateMenu, menuAni); | 1017 | app->setEffectEnabled(UI_AnimateMenu, menuAni); |
@@ -1995,14 +2003,16 @@ void LiquidStyle::drawMenuBarItem(QPainter *p, int x, int y, int w, int h, | |||
1995 | if(active){ | 2003 | if(active){ |
1996 | x -= 2; // Bug in Qt/E | 2004 | x -= 2; // Bug in Qt/E |
1997 | y -= 2; | 2005 | y -= 2; |
1998 | w += 2; | 2006 | w += 2; |
1999 | h += 2; | 2007 | h += 2; |
2000 | } | 2008 | } |
2001 | 2009 | ||
2002 | p-> fillRect ( x, y, w, h, g.brush(QColorGroup::Background)); | 2010 | QWidget *parent = (QWidget *)p->device(); |
2011 | p->setBrushOrigin(parent->pos()); | ||
2012 | parent->erase(x, y, w, h); | ||
2003 | 2013 | ||
2004 | if(menuHandler->useShadowText()){ | 2014 | if(menuHandler->useShadowText()){ |
2005 | QColor shadow; | 2015 | QColor shadow; |
2006 | if(p->device() && p->device()->devType() == QInternal::Widget && | 2016 | if(p->device() && p->device()->devType() == QInternal::Widget && |
2007 | ((QWidget *)p->device())->inherits("QMenuBar")){ | 2017 | ((QWidget *)p->device())->inherits("QMenuBar")){ |
2008 | shadow = ((QMenuBar*)p->device())->isTopLevel() ? g.button().dark(130) : | 2018 | shadow = ((QMenuBar*)p->device())->isTopLevel() ? g.button().dark(130) : |