[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: Transparent panel.
From: Zack Rusin <zack () kde ! org>
Date: 2002-07-23 18:21:29
[Download RAW message or body]
Hey everyone,
I fixed some problems with this patch and unless someones says "screw
you hippie" I'm going to commit the "transparent panel" patch. I fixed
the problem with the panel buttons not being transparent. So, what's
transparent:
- the panel itself,
- all panel buttons,
what's not transparent
- tasklist,
- clock,
- applets.
Neither of the last three (maybe with the exception of the tasklist, on
which I'm going to hack a little) is going to become transparent
(unless _real_ transparency gets into XFree86 ). If you feel like
testing it, patch your kdebase with the attached patch, or look at the
screenshots below and drool/flame on/read another post.
http://vortex.bd.psu.edu/~mus11/img/kicker2.png
http://vortex.bd.psu.edu/~mus11/img/kicker3.png
http://vortex.bd.psu.edu/~mus11/img/kicker1.png
Zack Rusin
--
"I get to go to lots of overseas places, like Canada." - Britney
Spears
["transparent.diff" (text/x-diff)]
? transparent.diff
? kate/app/dummy_kate.cpp
? kate/app/dummy_kate_la.cpp
? kate/app/dummy_kwrite.cpp
? kcontrol/kded/Makefile
? kcontrol/kicker/lookandfeeltab.ui.h
? kcontrol/kicker/semantic.cache
? kcontrol/konqhtml/nsconfigwidget.cpp
? kcontrol/konqhtml/nsconfigwidget.h
? kdm/kfrontend/krootimage
? kicker/dummy_la.cpp
? kicker/buttons/semantic.cache
? kicker/core/semantic.cache
? nsplugins/control/Makefile
? nsplugins/control/Makefile.in
? nsplugins/control/configwidget.cpp
? nsplugins/control/configwidget.h
Index: kcontrol/kicker/lookandfeeltab.ui
===================================================================
RCS file: /home/kde/kdebase/kcontrol/kicker/lookandfeeltab.ui,v
retrieving revision 1.16
diff -u -3 -p -r1.16 lookandfeeltab.ui
--- kcontrol/kicker/lookandfeeltab.ui 2002/05/12 23:30:31 1.16
+++ kcontrol/kicker/lookandfeeltab.ui 2002/07/23 22:06:45
@@ -8,8 +8,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>441</width>
- <height>360</height>
+ <width>547</width>
+ <height>528</height>
</rect>
</property>
<property name="caption">
@@ -344,7 +344,18 @@
<property name="spacing">
<number>6</number>
</property>
- <widget class="QLabel" row="0" column="1" rowspan="2" colspan="1">
+ <widget class="QCheckBox" row="0" column="0">
+ <property name="name">
+ <cstring>m_backgroundImage</cstring>
+ </property>
+ <property name="text">
+ <string>Enable &background image</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>If this option is selected, you can choose a \
background image that will be displayed on the panel. If it is not selected, the \
default colors will be used, see the 'Colors' control module.</string> + \
</property> + </widget>
+ <widget class="QLabel" row="2" column="1">
<property name="name">
<cstring>m_backgroundLabel</cstring>
</property>
@@ -390,19 +401,8 @@
<property name="whatsThis" stdset="0">
<string>This is a preview for the selected background \
image.</string> </property>
- </widget>
- <widget class="QCheckBox" row="0" column="0">
- <property name="name">
- <cstring>m_backgroundImage</cstring>
- </property>
- <property name="text">
- <string>Enable &background image</string>
- </property>
- <property name="whatsThis" stdset="0">
- <string>If this option is selected, you can choose a \
background image that will be displayed on the panel. If it is not selected, the \
default colors will be used, see the 'Colors' control \
module.</string>
- </property>
</widget>
- <widget class="KURLRequester" row="1" column="0">
+ <widget class="KURLRequester" row="2" column="0">
<property name="name">
<cstring>m_backgroundInput</cstring>
</property>
@@ -421,6 +421,17 @@
<string>Here you can choose a theme to be displayed by the \
panel. Press the 'Browse' button to choose a theme using the file dialog.<p> \
This option is only active if 'Enable background image' is selected.</string> \
</property> </widget>
+ <widget class="QCheckBox" row="1" column="0">
+ <property name="name">
+ <cstring>m_transparent</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Make the panel transparent</string>
+ </property>
+ </widget>
</grid>
</widget>
<spacer>
@@ -455,6 +466,24 @@
<receiver>m_backgroundInput</receiver>
<slot>setEnabled(bool)</slot>
</connection>
+ <connection>
+ <sender>m_backgroundImage</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_transparent</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>m_transparent</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_backgroundInput</receiver>
+ <slot>setDisabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>m_transparent</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_backgroundLabel</receiver>
+ <slot>setDisabled(bool)</slot>
+ </connection>
</connections>
<tabstops>
<tabstop>m_zoom_cb</tabstop>
@@ -470,6 +499,7 @@
</tabstops>
<includes>
<include location="global" impldecl="in declaration">kurlrequester.h</include>
+ <include location="local" impldecl="in \
implementation">lookandfeeltab.ui.h</include> </includes>
<layoutdefaults spacing="6" margin="11"/>
</UI>
Index: kcontrol/kicker/lookandfeeltab_impl.cpp
===================================================================
RCS file: /home/kde/kdebase/kcontrol/kicker/lookandfeeltab_impl.cpp,v
retrieving revision 1.28
diff -u -3 -p -r1.28 lookandfeeltab_impl.cpp
--- kcontrol/kicker/lookandfeeltab_impl.cpp 2002/07/20 16:17:53 1.28
+++ kcontrol/kicker/lookandfeeltab_impl.cpp 2002/07/23 22:06:45
@@ -56,7 +56,7 @@ LookAndFeelTab::LookAndFeelTab( QWidget
{
connect(m_zoom_cb, SIGNAL(clicked()), SIGNAL(changed()));
connect(m_showToolTips, SIGNAL(clicked()), SIGNAL(changed()));
-
+
connect(m_kmenuTile, SIGNAL(activated(int)), SIGNAL(changed()));
connect(m_desktopTile, SIGNAL(activated(int)), SIGNAL(changed()));
connect(m_browserTile, SIGNAL(activated(int)), SIGNAL(changed()));
@@ -65,6 +65,7 @@ LookAndFeelTab::LookAndFeelTab( QWidget
connect(m_wlTile, SIGNAL(activated(int)), SIGNAL(changed()));
connect(m_backgroundImage, SIGNAL(clicked()), SIGNAL(changed()));
+ connect(m_transparent, SIGNAL(clicked()), SIGNAL(changed()));
m_backgroundInput->fileDialog()->setFilter(KImageIO::pattern(KImageIO::Reading));
m_backgroundInput->fileDialog()->setCaption(i18n("Select an Image File"));
@@ -102,7 +103,7 @@ int LookAndFeelTab::findComboEntry(QComb
{
int index = 0;
- for (int i = 0; i < combo->count(); i++)
+ for (int i = 0; i < combo->count(); i++)
{
if (searchFor == combo->text(i))
{
@@ -128,9 +129,12 @@ void LookAndFeelTab::load()
bool use_theme = c.readBoolEntry("UseBackgroundTheme", false);
theme = c.readEntry("BackgroundTheme", QString::null).stripWhiteSpace();
+ bool transparent = c.readBoolEntry("Transparent", false);
+
m_backgroundImage->setChecked(use_theme);
- m_backgroundInput->setEnabled(use_theme);
- m_backgroundLabel->setEnabled(use_theme);
+ m_transparent->setChecked(transparent);
+ m_backgroundInput->setEnabled((transparent)?false:use_theme);
+ m_backgroundLabel->setEnabled((transparent)?false:use_theme);
if (theme.length() > 0)
{
@@ -259,6 +263,7 @@ void LookAndFeelTab::save()
c.setGroup("General");
c.writeEntry("UseBackgroundTheme", m_backgroundImage->isChecked());
+ c.writeEntry("Transparent", m_transparent->isChecked());
c.writeEntry("BackgroundTheme", theme);
c.writeEntry( "ShowToolTips", m_showToolTips->isChecked() );
c.writeEntry( "FadeOutAppletHandles", m_fadeOutAppletHandles );
@@ -274,7 +279,7 @@ void LookAndFeelTab::save()
}
else
{
- c.writeEntry("EnableKMenuTiles", false);
+ c.writeEntry("EnableKMenuTiles", false);
}
tile = m_desktopTile->currentItem();
@@ -286,9 +291,9 @@ void LookAndFeelTab::save()
}
else
{
- c.writeEntry("EnableDesktopButtonTiles", false);
+ c.writeEntry("EnableDesktopButtonTiles", false);
}
-
+
tile = m_urlTile->currentItem();
if (tile > 0)
{
@@ -298,7 +303,7 @@ void LookAndFeelTab::save()
}
else
{
- c.writeEntry("EnableURLTiles", false);
+ c.writeEntry("EnableURLTiles", false);
}
tile = m_browserTile->currentItem();
@@ -322,7 +327,7 @@ void LookAndFeelTab::save()
}
else
{
- c.writeEntry("EnableExeTiles", false);
+ c.writeEntry("EnableExeTiles", false);
}
tile = m_wlTile->currentItem();
@@ -334,13 +339,13 @@ void LookAndFeelTab::save()
}
else
{
- c.writeEntry("EnableWindowListTiles", false);
+ c.writeEntry("EnableWindowListTiles", false);
}
c.setGroup("buttons");
c.writeEntry("EnableTileBackground", enableTiles);
c.writeEntry("EnableIconZoom", m_zoom_cb->isChecked());
-
+
c.sync();
}
@@ -359,6 +364,7 @@ void LookAndFeelTab::defaults()
theme = QString::null;
m_backgroundImage->setChecked(false);
+ m_transparent->setChecked(false);
m_backgroundInput->lineEdit()->setText(theme);
m_backgroundLabel->clear();
@@ -398,13 +404,13 @@ void LookAndFeelTab::fillTileCombos()
m_browserTile->insertItem(pix, tile);
m_exeTile->insertItem(pix, tile);
m_wlTile->insertItem(pix, tile);
-
- if (pix.height() > minHeight)
+
+ if (pix.height() > minHeight)
{
minHeight = pix.height();
}
}
-
+
minHeight += 6;
m_kmenuTile->setMinimumHeight(minHeight);
m_desktopTile->setMinimumHeight(minHeight);
Index: kicker/buttons/panelbuttonbase.cpp
===================================================================
RCS file: /home/kde/kdebase/kicker/buttons/panelbuttonbase.cpp,v
retrieving revision 1.17
diff -u -3 -p -r1.17 panelbuttonbase.cpp
--- kicker/buttons/panelbuttonbase.cpp 2002/05/25 02:15:57 1.17
+++ kicker/buttons/panelbuttonbase.cpp 2002/07/23 22:06:48
@@ -40,6 +40,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE
#include <kipc.h>
#include "kicker.h"
+#include "containerarea.h"
#include "panel.h"
#include "panelbuttonbase.h"
@@ -76,11 +77,11 @@ void ZoomButton::reconfigure()
void ZoomButton::updateIcon()
{
- if ( watch )
+ if ( watch )
{
_icon = watch->zoomIcon();
update();
- }
+ }
}
bool ZoomButton::isWatching( PanelButtonBase* btn )
@@ -93,7 +94,7 @@ void ZoomButton::watchMe( PanelButtonBas
PanelButtonBase* watch_old = watch;
watch = btn;
_icon = watch->zoomIcon();
- if ( watch_old )
+ if ( watch_old )
{
watch_old->repaint();
disconnect(watch_old,0, this,0);
@@ -240,14 +241,14 @@ bool ZoomButton::eventFilter( QObject *o
return FALSE;
}
-void ZoomButton::unFocus()
+void ZoomButton::unFocus()
{
hide();
if (watch) {
PanelButtonBase* tmp = watch;
watch = 0;
tmp->update();
- }
+ }
lower();
setEnabled(false);
}
@@ -382,6 +383,7 @@ void PanelButtonBase::setBackground()
{
KConfig* config = KGlobal::config();
config->setGroup("General");
+
if (config->readBoolEntry("UseBackgroundTheme", false))
{
// Get the pixmap from the container area object
@@ -424,7 +426,6 @@ void PanelButtonBase::setBackground()
else
{
// Need to do 2 seperate bitBlts to take care of the overlap
-
// Copy the left/top of the image first up to the wrap-
// around point
int x = 0;
@@ -479,9 +480,9 @@ void PanelButtonBase::resizeEvent(QResiz
void PanelButtonBase::setZoomEnabled(bool b)
{
- if (!zoomButton)
+ if (!zoomButton)
zoomButton = new ZoomButton();
-
+
if (!b)
zoomDisabled++;
else
@@ -490,7 +491,7 @@ void PanelButtonBase::setZoomEnabled(boo
if (zoomDisabled)
{
zoomButton->unFocus();
- }
+ }
}
void PanelButtonBase::enterEvent(QEvent* e)
@@ -604,13 +605,27 @@ void PanelButtonBase::drawButton(QPainte
QPixmap bg(size());
QPainter pbg;
pbg.begin(&bg);
-
// Draw the background. This is always needed, even when using tiles,
// because they don't have to cover the entire button.
- if ( !_bg.isNull() )
+ if ( !_bg.isNull() ) {
pbg.drawPixmap( 0, 0, _bg );
- else
- pbg.fillRect(rect(), colorGroup().brush(QColorGroup::Background));
+ }
+ else {
+ QPixmap *pm = colorGroup().brush( QColorGroup::Background).pixmap();
+ if ( pm ) {
+ QPixmap mbg( width(), height() );
+
+ QWidget *wid = static_cast<QWidget*>(Panel::the()->containerArea());
+ if ( !wid )
+ kdDebug()<<k_funcinfo<<" there was a serious kicker transparency \
error!"<<endl; + QPoint tl = mapTo(wid, rect().topLeft());
+ QPoint lr = mapTo(wid, rect().bottomRight());
+ bitBlt(&mbg, QPoint(0,0), pm, QRect(tl, lr), CopyROP);
+
+ pbg.drawPixmap( 0, 0, mbg);
+ } else
+ pbg.fillRect(rect(), colorGroup().brush(QColorGroup::Background));
+ }
QPixmap tile = (isDown() || isOn()) ? _down : _up;
if (!tile.isNull()) { // Draw the tile
Index: kicker/core/containerarea.cpp
===================================================================
RCS file: /home/kde/kdebase/kicker/core/containerarea.cpp,v
retrieving revision 1.126
diff -u -3 -p -r1.126 containerarea.cpp
--- kicker/core/containerarea.cpp 2002/07/02 22:12:03 1.126
+++ kicker/core/containerarea.cpp 2002/07/23 22:06:49
@@ -44,6 +44,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE
#include <kpixmap.h>
#include <klocale.h>
#include <kio/netaccess.h>
+#include <krootpixmap.h>
#include "kicker.h"
#include "pluginmanager.h"
@@ -70,6 +71,7 @@ ContainerArea::ContainerArea( KConfig* _
, _dragIndicator(0)
, _dragMoveAC(0)
, _dragMoveOffset(QPoint(0,0))
+ , _rootPixmap(0)
{
setAcceptDrops( !Kicker::kicker()->isImmutable() );
connect(&_autoScrollTimer, SIGNAL(timeout()), SLOT(autoScroll()));
@@ -233,7 +235,7 @@ void ContainerArea::saveContainerConfig(
// build the applet list
QStringList alist;
- for( ContainerIterator it(_containers); it.current(); ++it )
+ for( ContainerIterator it(_containers); it.current(); ++it )
{
BaseContainer* a = it.current();
@@ -258,7 +260,7 @@ void ContainerArea::loadContainerConfig(
QStringList alist = group.readListEntry("Applets");
// now restore the applets
- for( QStringList::Iterator it = alist.begin(); it != alist.end(); ++it )
+ for( QStringList::Iterator it = alist.begin(); it != alist.end(); ++it )
{
QString appletId(*it);
@@ -272,7 +274,7 @@ void ContainerArea::loadContainerConfig(
int sep = appletId.findRev('_');
Q_ASSERT(sep != -1);
QString appletType = appletId.left(sep);
-
+
// create a matching applet container
if (appletType == "KMenuButton")
a = new KMenuButtonContainer(viewport());
@@ -1377,52 +1379,63 @@ void ContainerArea::setBackgroundTheme()
KConfigGroupSaver saver(_config, "General");
if (_config->readBoolEntry("UseBackgroundTheme", false)) {
- QString bgStr = _config->readEntry("BackgroundTheme", "");
- bgStr = locate("appdata", bgStr);
- if(!bgStr.isEmpty()){
- QPixmap bgPix(bgStr);
- if(!bgPix.isNull()){
- // Do we need to rotate the image
- QPixmap bgPixNew;
-
- if ( _config->readBoolEntry("RotateBackground", false) &&
- orientation() == Vertical )
- {
- // Rotate the pixmap before scaling
- QWMatrix m;
- m.rotate( -90.0 );
- bgPixNew = bgPix.xForm( m );
- }
- else
- {
- // Don't rotate the image - just copy it
- bgPixNew = bgPix;
- }
-
- // Scale the image but keep the same aspect ratio
- QImage bgImage = bgPixNew.convertToImage();
- double dAspect = (double)bgPixNew.width() / (double)bgPixNew.height();
-
- int nNewWidth = width();
- int nNewHeight = height();
- if (orientation() == Vertical )
- nNewHeight = (int)( (double)nNewWidth / dAspect );
- else
- nNewWidth = (int)( (double)nNewHeight * dAspect);
- QImage bgImageNew = bgImage.smoothScale( nNewWidth, nNewHeight );
-
- // Convert back to a QPixmap
- bgPixNew.convertFromImage( bgImageNew );
-
- QBrush bgBrush(colorGroup().background(), bgPixNew);
- QPalette pal = kapp->palette();
- pal.setBrush(QColorGroup::Background, bgBrush);
- setPalette(pal);
- }
- else {
- unsetPalette();
- kdWarning() << "Kicker: Error loading background theme pixmap\n";
- }
+ if (_config->readBoolEntry("Transparent", false) ) {
+ if ( !_rootPixmap ) {
+ _rootPixmap = new KRootPixmap(this);
+ _rootPixmap->setCustomPainting(true);
+ connect(_rootPixmap, SIGNAL(backgroundUpdated(const QPixmap&)),
+ SLOT(updateBackground(const QPixmap&)));
+ _rootPixmap->start();
+ } else
+ _rootPixmap->repaint(true);
+ } else {
+ QString bgStr = _config->readEntry("BackgroundTheme", "");
+ bgStr = locate("appdata", bgStr);
+ if(!bgStr.isEmpty()){
+ QPixmap bgPix(bgStr);
+ if(!bgPix.isNull()){
+ // Do we need to rotate the image
+ QPixmap bgPixNew;
+
+ if ( _config->readBoolEntry("RotateBackground", false) &&
+ orientation() == Vertical )
+ {
+ // Rotate the pixmap before scaling
+ QWMatrix m;
+ m.rotate( -90.0 );
+ bgPixNew = bgPix.xForm( m );
+ }
+ else
+ {
+ // Don't rotate the image - just copy it
+ bgPixNew = bgPix;
+ }
+
+ // Scale the image but keep the same aspect ratio
+ QImage bgImage = bgPixNew.convertToImage();
+ double dAspect = (double)bgPixNew.width() / \
(double)bgPixNew.height(); +
+ int nNewWidth = width();
+ int nNewHeight = height();
+ if (orientation() == Vertical )
+ nNewHeight = (int)( (double)nNewWidth / dAspect );
+ else
+ nNewWidth = (int)( (double)nNewHeight * dAspect);
+ QImage bgImageNew = bgImage.smoothScale( nNewWidth, nNewHeight \
); +
+ // Convert back to a QPixmap
+ bgPixNew.convertFromImage( bgImageNew );
+
+ QBrush bgBrush(colorGroup().background(), bgPixNew);
+ QPalette pal = kapp->palette();
+ pal.setBrush(QColorGroup::Background, bgBrush);
+ setPalette(pal);
+ }
+ else {
+ unsetPalette();
+ kdWarning() << "Kicker: Error loading background theme \
pixmap\n"; + }
+ }
}
}
else {
@@ -1794,6 +1807,15 @@ void ContainerArea::autoScroll()
else if(_moveAC->pos().y() >= height() - _moveAC->height() - 80)
scrollBy(0, 10);
}
+}
+
+void ContainerArea::updateBackground( const QPixmap& pm )
+{
+ QBrush bgBrush(colorGroup().background(), pm);
+ QPalette pal = kapp->palette();
+ pal.setBrush(QColorGroup::Background, bgBrush);
+ setPalette(pal);
+ kdDebug()<<k_funcinfo<<"Making panel transparent"<<endl;
}
void ContainerArea::scrollTo(BaseContainer* b)
Index: kicker/core/containerarea.h
===================================================================
RCS file: /home/kde/kdebase/kicker/core/containerarea.h,v
retrieving revision 1.52
diff -u -3 -p -r1.52 containerarea.h
--- kicker/core/containerarea.h 2002/07/02 22:12:03 1.52
+++ kicker/core/containerarea.h 2002/07/23 22:06:49
@@ -34,6 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE
class KConfig;
class DragIndicator;
class PanelContainer;
+class KRootPixmap;
typedef QPtrList<BaseContainer> ContainerList;
typedef QPtrListIterator<BaseContainer> ContainerIterator;
@@ -92,7 +93,7 @@ protected slots:
void stopContainerMove(BaseContainer *a);
protected:
-
+
QString createUniqueId(const QString& appletType) const;
void layoutChildren();
@@ -138,6 +139,7 @@ protected slots:
void embeddedWindowDestroyed();
void slotRemoveContainer(BaseContainer*);
void autoScroll();
+ void updateBackground( const QPixmap &pm );
private:
ContainerList _containers;
@@ -151,6 +153,7 @@ private:
BaseContainer* _dragMoveAC;
QPoint _dragMoveOffset;
QTimer _autoScrollTimer;
+ KRootPixmap* _rootPixmap;
};
class DragIndicator : public QWidget
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic