summaryrefslogtreecommitdiff
path: root/noncore/styles/liquid/liquid.cpp
authorsandman <sandman>2002-06-27 20:23:25 (UTC)
committer sandman <sandman>2002-06-27 20:23:25 (UTC)
commitc9871ef295afed6bc4f4cc5451f46bf3b6e8d462 (patch) (unidiff)
tree2fa3264c0a847100d1368df6e1eae2dd5b7a47ac /noncore/styles/liquid/liquid.cpp
parent9cd1aef30015628e06e8f24b9b7e91acb631b52b (diff)
downloadopie-c9871ef295afed6bc4f4cc5451f46bf3b6e8d462.zip
opie-c9871ef295afed6bc4f4cc5451f46bf3b6e8d462.tar.gz
opie-c9871ef295afed6bc4f4cc5451f46bf3b6e8d462.tar.bz2
Enhanced liquid style:
1) All WType_Popup's now get a transparent background (volume-applet) 2) Settings/Liquid Settings - a new app that acts like the KDE Control Panel page for Liquid
Diffstat (limited to 'noncore/styles/liquid/liquid.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/styles/liquid/liquid.cpp57
1 files changed, 53 insertions, 4 deletions
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp
index 5f014ad..4653639 100644
--- a/noncore/styles/liquid/liquid.cpp
+++ b/noncore/styles/liquid/liquid.cpp
@@ -74,30 +74,35 @@ TransMenuHandler::TransMenuHandler(QObject *parent)
74 74
75void TransMenuHandler::reloadSettings() 75void TransMenuHandler::reloadSettings()
76{ 76{
77 pixDict.clear(); 77 pixDict.clear();
78 78
79 Config config ( "qpe" ); 79 Config config ( "qpe" );
80 config. setGroup ( "MosfetMenus" ); 80 config. setGroup ( "MosfetMenus" );
81 81
82 type = config. readNumEntry("Type", TransStippleBg); 82 type = config. readNumEntry("Type", TransStippleBg);
83 color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name())); 83 color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name()));
84 fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name())); 84 fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name()));
85 opacity = config. readNumEntry("Opacity", 10); 85 opacity = config. readNumEntry("Opacity", 10);
86 if ( opacity < -20 )
87 opacity = 20;
88 else if ( opacity > 20 )
89 opacity = 20;
90
86 shadowText = config. readBoolEntry("ShadowText", true); 91 shadowText = config. readBoolEntry("ShadowText", true);
87} 92}
88 93
89bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) 94bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev)
90{ 95{
91 QPopupMenu *p = (QPopupMenu *)obj; 96 QWidget *p = (QWidget *)obj;
92 97
93 if(ev->type() == QEvent::Show){ 98 if(ev->type() == QEvent::Show){
94 if(type == TransStippleBg || type == TransStippleBtn || 99 if(type == TransStippleBg || type == TransStippleBtn ||
95 type == Custom){ 100 type == Custom){
96 QApplication::syncX(); 101 QApplication::syncX();
97 QPixmap *pix = new QPixmap; 102 QPixmap *pix = new QPixmap;
98 if(p->testWFlags(Qt::WType_Popup)){ 103 if(p->testWFlags(Qt::WType_Popup)){
99 QRect r(p->x(), p->y(), p->width(), p->height()); 104 QRect r(p->x(), p->y(), p->width(), p->height());
100 QRect deskR = QApplication::desktop()->rect(); 105 QRect deskR = QApplication::desktop()->rect();
101 if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){ 106 if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){
102 r.setBottom(deskR.bottom()); 107 r.setBottom(deskR.bottom());
103 r.setRight(deskR.right()); 108 r.setRight(deskR.right());
@@ -109,32 +114,68 @@ bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev)
109 pix->resize(p->width(), p->height()); 114 pix->resize(p->width(), p->height());
110 pix->fill(Qt::black.rgb()); 115 pix->fill(Qt::black.rgb());
111 } 116 }
112 if(type == TransStippleBg){ 117 if(type == TransStippleBg){
113 stripePixmap(*pix, p->colorGroup().background()); 118 stripePixmap(*pix, p->colorGroup().background());
114 } 119 }
115 else if(type == TransStippleBtn){ 120 else if(type == TransStippleBtn){
116 stripePixmap(*pix, p->colorGroup().button()); 121 stripePixmap(*pix, p->colorGroup().button());
117 } 122 }
118 else{ 123 else{
119 QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color); 124 QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color);
120 } 125 }
121 pixDict.insert(p->winId(), pix); 126
127 if (p->inherits("QPopupMenu"))
128 pixDict.insert(p->winId(), pix);
129 else {
130 p->setBackgroundPixmap(*pix);
131
132 QObjectList *ol = p-> queryList("QWidget");
133 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) {
134 QWidget *wid = (QWidget *) it.current ( );
135
136 wid-> setBackgroundPixmap(*pix);
137 wid-> setBackgroundOrigin(QWidget::ParentOrigin);
138 }
139 delete ol;
140 }
122 } 141 }
123 } 142 }
124 else if(ev->type() == QEvent::Hide){ 143 else if(ev->type() == QEvent::Hide){
125 if(type == TransStippleBg || type == TransStippleBtn || 144 if(type == TransStippleBg || type == TransStippleBtn ||
126 type == Custom){ 145 type == Custom){
127// qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width()); 146// qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width());
128 pixDict.remove(p->winId()); 147
148 if (p->inherits("QPopupMenu"))
149 pixDict.remove(p->winId());
150 else {
151 p->setBackgroundMode(QWidget::PaletteBackground);
152
153 QObjectList *ol = p-> queryList("QWidget");
154 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) {
155 QWidget *wid = (QWidget *) it.current ( );
156
157 wid-> setBackgroundMode( QWidget::PaletteBackground );
158 }
159 delete ol;
160 }
161 }
162 }
163 else if(ev->type() == QEvent::Paint){
164 if(type == TransStippleBg || type == TransStippleBtn ||
165 type == Custom){
166// qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width());
167
168 if (!p->inherits("QPopupMenu"))
169 p->erase();
129 } 170 }
130 } 171 }
131 return(false); 172 return(false);
132} 173}
133 174
134 175
135LiquidStyle::LiquidStyle() 176LiquidStyle::LiquidStyle()
136 :QWindowsStyle() 177 :QWindowsStyle()
137{ 178{
138 setName ( "LiquidStyle" ); 179 setName ( "LiquidStyle" );
139 180
140 btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true); 181 btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true);
@@ -787,28 +828,33 @@ void LiquidStyle::polish(QPalette &appPal)
787 828
788} 829}
789 830
790void LiquidStyle::polish(QWidget *w) 831void LiquidStyle::polish(QWidget *w)
791{ 832{
792 if(w->inherits("QMenuBar")){ 833 if(w->inherits("QMenuBar")){
793 //((QFrame*)w)->setLineWidth(0); 834 //((QFrame*)w)->setLineWidth(0);
794 w->setBackgroundMode(QWidget::PaletteBackground); 835 w->setBackgroundMode(QWidget::PaletteBackground);
795 return; 836 return;
796 } 837 }
797 if(w->inherits("QPopupMenu")) 838 if(w->inherits("QPopupMenu"))
798 w->setBackgroundMode(QWidget::NoBackground); 839 w->setBackgroundMode(QWidget::NoBackground);
799 840 else if(w-> testWFlags(Qt::WType_Popup)) {
841 printf("install popup: %s\n", w-> className ( ));
842 w->installEventFilter(menuHandler);
843 }
844
800 if(w->isTopLevel()){ 845 if(w->isTopLevel()){
801 return; 846 return;
802 } 847 }
848
803 849
804 w-> setBackgroundOrigin ( QWidget::ParentOrigin ); 850 w-> setBackgroundOrigin ( QWidget::ParentOrigin );
805 851
806 if(w->inherits("QComboBox") || 852 if(w->inherits("QComboBox") ||
807 w->inherits("QLineEdit") || w->inherits("QRadioButton") || 853 w->inherits("QLineEdit") || w->inherits("QRadioButton") ||
808 w->inherits("QCheckBox") || w->inherits("QScrollBar")) { 854 w->inherits("QCheckBox") || w->inherits("QScrollBar")) {
809 w->installEventFilter(this); 855 w->installEventFilter(this);
810 } 856 }
811 if(w->inherits("QLineEdit")){ 857 if(w->inherits("QLineEdit")){
812 QPalette pal = w->palette(); 858 QPalette pal = w->palette();
813 pal.setBrush(QColorGroup::Base, baseBrush); 859 pal.setBrush(QColorGroup::Base, baseBrush);
814 w->setPalette(pal); 860 w->setPalette(pal);
@@ -877,24 +923,27 @@ void LiquidStyle::polish(QWidget *w)
877} 923}
878 924
879void LiquidStyle::unPolish(QWidget *w) 925void LiquidStyle::unPolish(QWidget *w)
880{ 926{
881 if(w->inherits("QMenuBar")){ 927 if(w->inherits("QMenuBar")){
882 ((QFrame *)w)->setLineWidth(1); 928 ((QFrame *)w)->setLineWidth(1);
883 w->setBackgroundMode(QWidget::PaletteBackground); 929 w->setBackgroundMode(QWidget::PaletteBackground);
884 return; 930 return;
885 } 931 }
886 932
887 if(w->inherits("QPopupMenu")) 933 if(w->inherits("QPopupMenu"))
888 w->setBackgroundMode(QWidget::PaletteButton); 934 w->setBackgroundMode(QWidget::PaletteButton);
935 else if(w-> testWFlags(Qt::WType_Popup)) {
936 w->removeEventFilter(menuHandler);
937 }
889 938
890 if(w->isTopLevel()) 939 if(w->isTopLevel())
891 return; 940 return;
892 941
893 // for viewport children, don't just check for NoBackground.... 942 // for viewport children, don't just check for NoBackground....
894 bool isViewportChild = w->parent() && 943 bool isViewportChild = w->parent() &&
895 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || 944 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) ||
896 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); 945 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0));
897 946
898 w->setPalette(QApplication::palette()); 947 w->setPalette(QApplication::palette());
899 if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){ 948 if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){
900 if(w->inherits("QPushButton")) 949 if(w->inherits("QPushButton"))