[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Transparent panel.
From: Zack Rusin <zack () kde ! org>
Date: 2002-07-22 0:16:50
[Download RAW message or body]
Ave,
I feel like I'm going to be mutilated for this one, but I made Kicker
transparent (optionally). I was going through kde-look.org today and
noticed that people tend to create backgrounds for Kicker that make it
look like it would be transparent. Someone even provided a hacked
Keramik style with a transparent panel, I though that it would be lot
more useful to just have a simple option like:
[x] Make that sucka transparent
So I added one to the Kicker KControl module (appearance->background
group), added a KRootPixmap to the ContainerArea and made Kicker
transparent.
http://www.personal.psu.edu/mkr137/snapshot1.png
http://www.personal.psu.edu/mkr137/snapshot2.png
The only problem that I noticed is that buttons background is sometimes
a little off, leaving them a little more noticable, but I think it
looks better this way anyway. Oh, and I didn't add an option to
customize the fade effect since it seemed to me totally useless - "Oh,
cool, I want a transparent panel, but let's make it not transparent by
fading the background" and I'm not a big fan of having tens of widgets
to configure one thing. Any objections or can I commit?
Zack Rusin
--
Jesus saves...Passes to Gretzky...Gretzky shoots...He SCORES!
["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/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/22 00:00:16
@@ -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/22 00:00:16
@@ -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/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/22 00:00:23
@@ -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,16 @@ void ContainerArea::autoScroll()
else if(_moveAC->pos().y() >= height() - _moveAC->height() - 80)
scrollBy(0, 10);
}
+}
+
+void ContainerArea::updateBackground( const QPixmap& pm )
+{
+ kdDebug()<<k_funcinfo<<"Making panel transparent"<<endl;
+
+ QBrush bgBrush(colorGroup().background(), pm);
+ QPalette pal = kapp->palette();
+ pal.setBrush(QColorGroup::Background, bgBrush);
+ setPalette(pal);
}
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/22 00:00:23
@@ -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