this is the actual bugfix from Gallium for the window decorations. This is

his part of the patch, works fine but there's just the re-check needed to
be added so when the effect for tooltips changes, the deco's tooltips take
this as well. There are no new strings except the Un-Sticky tooltip, all
others are translated. thd@kde.org agreed on the strings.

svn path=/trunk/kdebase/kwin/; revision=104585
This commit is contained in:
Ralf Nolden 2001-07-01 10:10:17 +00:00
parent c130a8cb4d
commit 278c511d4f
46 changed files with 837 additions and 290 deletions

View file

@ -8,14 +8,14 @@ lib_LTLIBRARIES = kwin.la
# workspace.cpp has to be first in order not to break --enable-final
kwin_la_SOURCES = workspace.cpp atoms.cpp client.cpp main.cpp \
tabbox.cpp options.cpp plugins.cpp events.cpp KWinInterface.skel \
killwindow.cpp
killwindow.cpp kwinbutton.cpp
kwin_la_LIBADD = $(LIB_KDEUI) $(LIBXINERAMA)
kwin_la_LDFLAGS = $(all_libraries) -module -avoid-version
include_HEADERS = KWinInterface.h
kwinincludedir = $(includedir)/kwin
kwininclude_HEADERS = options.h client.h workspace.h
kwininclude_HEADERS = options.h client.h workspace.h kwinbutton.h
kwin_SOURCES = kwin_main.cpp
kwin_LDADD = kwin.la

View file

@ -1,6 +1,4 @@
#include "b2client.h"
#include <qapplication.h>
#include <qcursor.h>
#include <qabstractlayout.h>
#include <qlayout.h>
#include <qtoolbutton.h>
@ -8,6 +6,7 @@
#include <qdrawutil.h>
#include <kpixmapeffect.h>
#include <kdrawutil.h>
#include <klocale.h>
#include <qbitmap.h>
#include "../../workspace.h"
#include "../../options.h"
@ -116,17 +115,17 @@ static void delete_pixmaps()
pixmaps_created = false;
}
B2Button::B2Button(KPixmap *pix, KPixmap *pixDown, KPixmap *iPix,
/*B2Button::B2Button(KPixmap *pix, KPixmap *pixDown, KPixmap *iPix,
KPixmap *iPixDown, Client *_client, QWidget *parent,
const char *name)
: QButton(parent, name),
const char *name, const QString& tip)
: KWinButton(parent, name, tip),
pNorm(pix), pDown(pixDown), iNorm(iPix), iDown(iPixDown),
client(_client)
{
setFixedSize(16, 16);
setFocusPolicy(NoFocus);
resize(16, 16);
}
}*/
QSize B2Button::sizeHint() const
{
@ -188,13 +187,13 @@ void B2Button::mousePressEvent( QMouseEvent* e )
{
last_button = e->button();
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QButton::mousePressEvent( &me );
KWinButton::mousePressEvent( &me );
}
void B2Button::mouseReleaseEvent( QMouseEvent* e )
{
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QButton::mouseReleaseEvent( &me );
KWinButton::mouseReleaseEvent( &me );
}
B2Titlebar::B2Titlebar(B2Client *parent)
@ -377,6 +376,10 @@ B2Client::B2Client( Workspace *ws, WId w, QWidget *parent,
: Client( ws, w, parent, name, WResizeNoErase ),
bar_x_ofs(0), in_unobs(0)
{
const QString tips[] = { QString(i18n("Menu")), QString(i18n("Sticky")),
QString(i18n("Minimize")), QString(i18n("Maximize")),
QString(i18n("Close")), QString(i18n("Help")) };
g = new QGridLayout( this, 0, 0);
g->addMultiCellWidget(windowWrapper(), 1, 1, 1, 2);
@ -399,7 +402,7 @@ B2Client::B2Client( Workspace *ws, WId w, QWidget *parent,
int i;
for(i=0; i < 6; ++i){
button[i] = new B2Button(this, titlebar/*this*/);
button[i] = new B2Button(this, titlebar, tips[i]);
button[i]->setFixedSize(16, 16);
}
@ -704,6 +707,7 @@ void B2Client::titleMoveRel(int xdiff)
void B2Client::stickyChange(bool on)
{
button[BtnSticky]->setDown(on);
button[BtnSticky]->setTipText(on ? i18n("Un-Sticky") : i18n("Sticky"));
}
void B2Client::maximizeChange(bool m)
@ -715,9 +719,9 @@ void B2Client::maximizeChange(bool m)
button[BtnMax]->setPixmaps(P_MAX);
}
button[BtnMax]->repaint();
button[BtnMax]->setTipText(m ? i18n("Restore") : i18n("Maximize"));
}
void B2Client::activeChange(bool on)
{
int i;
@ -902,6 +906,8 @@ extern "C"
void reset()
{
redraw_pixmaps();
// Ensure change in tooltip state gets applied
Workspace::self()->slotResetAllClientsDelayed();
}
void deinit()
{

View file

@ -5,6 +5,7 @@
#include <qbitmap.h>
#include <kpixmap.h>
#include "../../client.h"
#include "../../kwinbutton.h"
class QLabel;
//class QSpacerItem;
//class QHBoxLayout;
@ -12,14 +13,16 @@ class QGridLayout;
namespace KWinInternal {
class B2Button : public QButton
class B2Button : public KWinInternal::KWinButton
{
Q_OBJECT
public:
B2Button(Client *_client=0, QWidget *parent=0, const char *name=0)
: QButton(parent, name){useMiniIcon = false; client = _client;}
B2Button(KPixmap *pix, KPixmap *pixDown, KPixmap *iPix, KPixmap *iPixDown,
Client *_client=0, QWidget *parent=0, const char *name=0);
B2Button(Client *_client=0, QWidget *parent=0, const QString& tip=NULL)
: KWinButton(parent, 0, tip) {client = _client; useMiniIcon = false;}
// B2Button(KPixmap *pix, KPixmap *pixDown, KPixmap *iPix, KPixmap *iPixDown,
// Client *_client=0, QWidget *parent=0, const char *name=0, const QString& tip=NULL);
void setBg(const QColor &c){bg = c;}
void setPixmaps(KPixmap *pix, KPixmap *pixDown, KPixmap *iPix,
KPixmap *iPixDown);
@ -36,13 +39,13 @@ protected:
bool useMiniIcon;
KPixmap *pNorm, *pDown, *iNorm, *iDown;
QColor bg; //only use one color (the rest is pixmap) so forget QPalette ;)
Client *client;
void mousePressEvent( QMouseEvent* e );
void mouseReleaseEvent( QMouseEvent* e );
public:
int last_button;
Client* client;
};
class B2Client;

View file

@ -15,6 +15,7 @@
#include <kglobal.h>
#include <kpixmapeffect.h>
#include <kdrawutil.h>
#include <klocale.h>
#include <qlayout.h>
#include <qdrawutil.h>
#include <qbitmap.h>
@ -148,10 +149,11 @@ void KDEDefaultHandler::readConfig()
KConfig* conf = KGlobal::config();
conf->setGroup("KDEDefault");
showGrabBar = conf->readBoolEntry("ShowGrabBar", true);
showGrabBar = conf->readBoolEntry("ShowGrabBar", true);
showTitleBarStipple = conf->readBoolEntry("ShowTitleBarStipple", true);
useGradients = conf->readBoolEntry("UseGradients", true);
int size = conf->readNumEntry("TitleBarSize", 0);
useGradients = conf->readBoolEntry("UseGradients", true);
int size = conf->readNumEntry("TitleBarSize", 0);
if (size < 0) size = 0;
if (size > 2) size = 2;
@ -386,28 +388,25 @@ void KDEDefaultHandler::drawButtonBackground(KPixmap *pix,
KDEDefaultButton::KDEDefaultButton(Client *parent, const char *name,
bool largeButton, bool isLeftButton, bool isStickyButton,
const unsigned char *bitmap )
: QButton(parent, name, WStyle_Customize | WRepaintNoErase |
WResizeNoErase | WStyle_NoBorder )
const unsigned char *bitmap, const QString& tip )
: KWinButton(parent, name, tip)
{
// Eliminate any possible background flicker
setBackgroundMode( QWidget::NoBackground );
setToggleButton( isStickyButton );
isMouseOver = false;
client = parent;
deco = NULL;
deco = NULL;
large = largeButton;
isLeft = isLeftButton;
isSticky = isStickyButton;
client = parent;
large = largeButton;
isLeft = isLeftButton;
isSticky = isStickyButton;
if ( large )
if (large)
setFixedSize(16, 16);
else
setFixedSize(12, 12);
if(bitmap)
if (bitmap)
setBitmap(bitmap);
}
@ -546,12 +545,28 @@ void KDEDefaultButton::turnOn( bool isOn )
}
void KDEDefaultButton::enterEvent(QEvent *e)
{
isMouseOver=true;
repaint(false);
KWinButton::enterEvent(e);
}
void KDEDefaultButton::leaveEvent(QEvent *e)
{
isMouseOver=false;
repaint(false);
KWinButton::leaveEvent(e);
}
void KDEDefaultButton::mousePressEvent( QMouseEvent* e )
{
last_button = e->button();
QMouseEvent me( e->type(), e->pos(), e->globalPos(),
LeftButton, e->state() );
QButton::mousePressEvent( &me );
KWinButton::mousePressEvent( &me );
}
@ -560,7 +575,7 @@ void KDEDefaultButton::mouseReleaseEvent( QMouseEvent* e )
last_button = e->button();
QMouseEvent me( e->type(), e->pos(), e->globalPos(),
LeftButton, e->state() );
QButton::mouseReleaseEvent( &me );
KWinButton::mouseReleaseEvent( &me );
}
@ -634,7 +649,7 @@ void KDEDefaultClient::addClientButtons( const QString& s, bool isLeft )
if (!button[BtnMenu])
{
button[BtnMenu] = new KDEDefaultButton(this, "menu",
largeButtons, isLeft, false, NULL);
largeButtons, isLeft, false, NULL, i18n("Menu"));
connect( button[BtnMenu], SIGNAL(pressed()),
this, SLOT(menuButtonPressed()) );
hb->addWidget( button[BtnMenu] );
@ -646,7 +661,7 @@ void KDEDefaultClient::addClientButtons( const QString& s, bool isLeft )
if (!button[BtnSticky])
{
button[BtnSticky] = new KDEDefaultButton(this, "sticky",
largeButtons, isLeft, true, NULL);
largeButtons, isLeft, true, NULL, i18n("Sticky"));
button[BtnSticky]->turnOn( isSticky() );
connect( button[BtnSticky], SIGNAL(clicked()),
this, SLOT(toggleSticky()) );
@ -659,7 +674,8 @@ void KDEDefaultClient::addClientButtons( const QString& s, bool isLeft )
if( providesContextHelp() && (!button[BtnHelp]) )
{
button[BtnHelp] = new KDEDefaultButton(this, "help",
largeButtons, isLeft, true, question_bits);
largeButtons, isLeft, true, question_bits,
i18n("Help"));
connect( button[BtnHelp], SIGNAL( clicked() ),
this, SLOT( contextHelp() ));
hb->addWidget( button[BtnHelp] );
@ -671,7 +687,8 @@ void KDEDefaultClient::addClientButtons( const QString& s, bool isLeft )
if ( (!button[BtnIconify]) && isMinimizable())
{
button[BtnIconify] = new KDEDefaultButton(this, "iconify",
largeButtons, isLeft, true, iconify_bits);
largeButtons, isLeft, true, iconify_bits,
i18n("Minimize"));
connect( button[BtnIconify], SIGNAL( clicked()),
this, SLOT(iconify()) );
hb->addWidget( button[BtnIconify] );
@ -683,7 +700,8 @@ void KDEDefaultClient::addClientButtons( const QString& s, bool isLeft )
if ( (!button[BtnMax]) && isMaximizable())
{
button[BtnMax] = new KDEDefaultButton(this, "maximize",
largeButtons, isLeft, true, maximize_bits);
largeButtons, isLeft, true, maximize_bits,
i18n("Maximize"));
connect( button[BtnMax], SIGNAL( clicked()),
this, SLOT(slotMaximize()) );
hb->addWidget( button[BtnMax] );
@ -695,7 +713,8 @@ void KDEDefaultClient::addClientButtons( const QString& s, bool isLeft )
if (!button[BtnClose])
{
button[BtnClose] = new KDEDefaultButton(this, "close",
largeButtons, isLeft, true, close_bits);
largeButtons, isLeft, true, close_bits,
i18n("Close"));
connect( button[BtnClose], SIGNAL( clicked()),
this, SLOT(closeWindow()) );
hb->addWidget( button[BtnClose] );
@ -722,6 +741,7 @@ void KDEDefaultClient::stickyChange(bool on)
if (button[BtnSticky]) {
button[BtnSticky]->turnOn(on);
button[BtnSticky]->repaint(false);
button[BtnSticky]->setTipText(on ? i18n("Un-Sticky") : i18n("Sticky"));
}
}
@ -957,8 +977,10 @@ void KDEDefaultClient::mouseDoubleClickEvent( QMouseEvent * e )
void KDEDefaultClient::maximizeChange(bool m)
{
if (button[BtnMax])
if (button[BtnMax]) {
button[BtnMax]->setBitmap(m ? minmax_bits : maximize_bits);
button[BtnMax]->setTipText(m ? i18n("Restore") : i18n("Maximize"));
}
}

View file

@ -18,13 +18,14 @@
#include <qbitmap.h>
#include <kpixmap.h>
#include "../../client.h"
#include "../../kwinbutton.h"
class QSpacerItem;
class QHBoxLayout;
namespace KWinInternal {
class KDEDefaultHandler: public QObject
{
public:
@ -36,36 +37,39 @@ class KDEDefaultHandler: public QObject
void readConfig();
void createPixmaps();
void freePixmaps();
void drawButtonBackground(KPixmap *pix, const QColorGroup &g, bool sunken);
void drawButtonBackground(KPixmap *pix,
const QColorGroup &g, bool sunken);
};
class KDEDefaultButton : public QButton
class KDEDefaultButton : public KWinInternal::KWinButton
{
public:
KDEDefaultButton(Client *parent=0, const char *name=0, bool largeButton=true,
bool isLeftButton=true, bool isStickyButton=false,
const unsigned char *bitmap=NULL);
~KDEDefaultButton();
KDEDefaultButton(Client *parent=0, const char *name=0,
bool largeButton=true, bool isLeftButton=true,
bool isStickyButton=false, const unsigned char *bitmap=NULL,
const QString& tip=NULL);
~KDEDefaultButton();
int last_button;
void turnOn( bool isOn );
void setBitmap(const unsigned char *bitmap);
QSize sizeHint() const;
int last_button;
void turnOn( bool isOn );
protected:
void enterEvent(QEvent *){ isMouseOver=true; repaint(false); }
void leaveEvent(QEvent *){ isMouseOver=false; repaint(false); }
void enterEvent(QEvent *);
void leaveEvent(QEvent *);
void mousePressEvent( QMouseEvent* e );
void mouseReleaseEvent( QMouseEvent* e );
void drawButton(QPainter *p);
void drawButtonLabel(QPainter*) {;}
Client* client;
QBitmap* deco;
bool large;
bool isLeft;
bool isSticky;
bool isMouseOver;
Client* client;
};

View file

@ -27,10 +27,10 @@
#include <kstddirs.h>
#include <kglobal.h>
#include <klocale.h>
#include <kdrawutil.h>
#include <qlabel.h>
#include <qdrawutil.h>
#include <qdatetime.h>
#include <kdrawutil.h>
#include <qbitmap.h>
#include <qstring.h>
#include "../../workspace.h"
@ -594,9 +594,9 @@ void ThemeHandler::slotReset()
// IceWM button class
////////////////////////////////////////////////////////////////////////////////////////////
IceWMButton::IceWMButton(Client *parent, const char *name, QPixmap* (*p)[2], bool isToggle )
: QButton(parent, name, WStyle_Customize | WRepaintNoErase |
WResizeNoErase | WStyle_NoBorder)
IceWMButton::IceWMButton(Client *parent, const char *name, QPixmap* (*p)[2],
bool isToggle, const QString& tip )
: KWinButton(parent, name, tip)
{
// Eliminate any possible background flicker
setBackgroundMode( QWidget::NoBackground );
@ -621,15 +621,12 @@ QSize IceWMButton::sizeHint() const
void IceWMButton::usePixmap( QPixmap* (*p)[2] )
{
if ( validPixmaps( *p ) )
{
if (validPixmaps( *p )) {
pix = p;
setFixedSize( (*pix)[Active]->width(), titleBarHeight );
repaint( false );
} else
{
pix = NULL;
}
pix = NULL;
}
@ -666,7 +663,7 @@ void IceWMButton::mousePressEvent( QMouseEvent* e )
last_button = e->button();
QMouseEvent me ( e->type(), e->pos(), e->globalPos(),
LeftButton, e->state() );
QButton::mousePressEvent( &me );
KWinButton::mousePressEvent( &me );
}
@ -675,7 +672,7 @@ void IceWMButton::mouseReleaseEvent( QMouseEvent* e )
last_button = e->button();
QMouseEvent me ( e->type(), e->pos(), e->globalPos(),
LeftButton, e->state() );
QButton::mouseReleaseEvent( &me );
KWinButton::mouseReleaseEvent( &me );
}
@ -782,12 +779,15 @@ void IceWMClient::addClientButtons( const QString& s )
{
if (showMenuButtonIcon) {
renderMenuIcons();
button[BtnSysMenu] = new IceWMButton(this, "menu", &menuButtonWithIconPix);
button[BtnSysMenu] = new IceWMButton(this, "menu",
&menuButtonWithIconPix, false, i18n("Menu"));
}
else
button[BtnSysMenu] = new IceWMButton(this, "menu", &menuButtonPix);
button[BtnSysMenu] = new IceWMButton(this, "menu",
&menuButtonPix, false, i18n("Menu"));
connect( button[BtnSysMenu], SIGNAL(pressed()), this, SLOT(menuButtonPressed()));
connect( button[BtnSysMenu], SIGNAL(pressed()),
this, SLOT(menuButtonPressed()));
hb->addWidget( button[BtnSysMenu] );
}
break;
@ -795,27 +795,34 @@ void IceWMClient::addClientButtons( const QString& s )
case 'x':
if ( validPixmaps(closePix) && !button[BtnClose] )
{
button[BtnClose] = new IceWMButton(this, "close", &closePix);
button[BtnClose] = new IceWMButton(this, "close",
&closePix, false, i18n("Close"));
hb->addWidget( button[BtnClose] );
connect( button[BtnClose], SIGNAL(clicked()), this, SLOT(closeWindow()));
connect( button[BtnClose], SIGNAL(clicked()),
this, SLOT(closeWindow()));
}
break;
case 'm':
if ( validPixmaps(maximizePix) && !button[BtnMaximize] && isMaximizable() )
{
button[BtnMaximize] = new IceWMButton(this, "maximize", &maximizePix);
button[BtnMaximize] = new IceWMButton(this, "maximize",
&maximizePix, false, i18n("Maximize"));
hb->addWidget( button[BtnMaximize] );
connect( button[BtnMaximize], SIGNAL(clicked()), this, SLOT(slotMaximize()));
connect( button[BtnMaximize], SIGNAL(clicked()),
this, SLOT(slotMaximize()));
}
break;
case 'i':
if ( validPixmaps(minimizePix) && !button[BtnMinimize] && isMinimizable() )
if ( validPixmaps(minimizePix) && !button[BtnMinimize] &&
isMinimizable() )
{
button[BtnMinimize] = new IceWMButton(this, "minimize", &minimizePix);
button[BtnMinimize] = new IceWMButton(this, "minimize",
&minimizePix, false, i18n("Minimize"));
hb->addWidget( button[BtnMinimize] );
connect( button[BtnMinimize], SIGNAL(clicked()), this, SLOT(iconify()));
connect( button[BtnMinimize], SIGNAL(clicked()),
this, SLOT(iconify()));
}
break;
@ -825,13 +832,16 @@ void IceWMClient::addClientButtons( const QString& s )
hb->addWidget( button[BtnHide] );
break; */
/* Re-enable this when kwin has void shadeChange(bool s) in clients.cpp
/* Re-enable this when kwin has void shadeChange(bool s)
in clients.cpp
case 'r':
// NOTE: kwin doesn't have toggleShade() in clients.h !
if ( validPixmaps(rollupPix) && !button[BtnRollup] )
{
button[BtnRollup] = new IceWMButton(this, "shade", isShade() ? &rolldownPix : &rollupPix);
connect( button[BtnRollup], SIGNAL(clicked()), this, SLOT(toggleShade()) );
button[BtnRollup] = new IceWMButton(this, "shade",
isShade() ? &rolldownPix : &rollupPix);
connect( button[BtnRollup], SIGNAL(clicked()),
this, SLOT(toggleShade()) );
hb->addWidget( button[BtnRollup] );
}
break; */
@ -840,10 +850,12 @@ void IceWMClient::addClientButtons( const QString& s )
// Make depth == sticky
if ( validPixmaps(depthPix) && !button[BtnDepth] )
{
button[BtnDepth] = new IceWMButton(this, "sticky", &depthPix, true );
button[BtnDepth] = new IceWMButton(this, "sticky",
&depthPix, true, i18n("Sticky"));
button[BtnDepth]->turnOn( isSticky() );
hb->addWidget( button[BtnDepth] );
connect( button[BtnDepth], SIGNAL(clicked()), this, SLOT(toggleSticky()));
connect( button[BtnDepth], SIGNAL(clicked()),
this, SLOT(toggleSticky()));
}
break;
}
@ -1189,6 +1201,7 @@ void IceWMClient::stickyChange(bool on)
{
button[BtnDepth]->turnOn(on);
button[BtnDepth]->repaint(false);
button[BtnDepth]->setTipText(on ? i18n("Un-Sticky") : i18n("Sticky"));
}
}
@ -1210,7 +1223,10 @@ void IceWMClient::maximizeChange(bool m)
{
// Change the button pixmap to restore if required
if (button[BtnMaximize] && validPixmaps(restorePix))
{
button[BtnMaximize]->usePixmap( m ? &restorePix : &maximizePix );
button[BtnMaximize]->setTipText(m ? i18n("Restore") : i18n("Maximize"));
}
}

View file

@ -30,6 +30,7 @@
#include <qlayout.h>
#include <kpixmap.h>
#include "../../client.h"
#include "../../kwinbutton.h"
class QLabel;
class QSpacerItem;
class QHBoxLayout;
@ -75,11 +76,12 @@ class ThemeHandler: public QObject
};
class IceWMButton : public QButton
class IceWMButton : public KWinInternal::KWinButton
{
public:
IceWMButton( Client *parent=0, const char *name=0,
QPixmap* (*p)[2]=0L, bool isToggle=false );
QPixmap* (*p)[2]=0L, bool isToggle=false,
const QString& tip=NULL );
void usePixmap( QPixmap* (*p)[2] );
QSize sizeHint() const;
void turnOn( bool isOn );
@ -93,8 +95,8 @@ class IceWMButton : public QButton
void drawButtonLabel( QPainter * ) {;}
private:
Client* client;
QPixmap* (*pix)[2]; // Points to active/inactive pixmap array
Client* client;
};

View file

@ -4,8 +4,6 @@ kwin - the KDE window manager
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
******************************************************************/
#include "kde1client.h"
#include <qapplication.h>
#include <qcursor.h>
#include <qabstractlayout.h>
#include <qlayout.h>
#include <qtoolbutton.h>
@ -13,6 +11,7 @@ Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
#include <qdrawutil.h>
#include <qbitmap.h>
#include <kdrawutil.h>
#include <klocale.h>
#include <qdatetime.h>
#include <qimage.h>
#include "../../workspace.h"
@ -190,18 +189,19 @@ StdClient::StdClient( Workspace *ws, WId w, QWidget *parent, const char *name )
g->addRowSpacing(2, 2);
button[0] = new QToolButton( this );
button[1] = new QToolButton( this );
button[2] = new QToolButton( this );
button[3] = new QToolButton( this );
button[4] = new ThreeButtonButton( this );
button[5] = new QToolButton( this );
button[0] = new KWinToolButton( this, 0, i18n("Menu") );
button[1] = new KWinToolButton( this, 0, i18n("Sticky") );
// button[2] = new KWinToolButton( this, 0, i18n("?") );
button[2] = NULL;
button[3] = new KWinToolButton( this, 0, i18n("Minimize") );
button[4] = new ThreeButtonButton( this, 0, i18n("Maximize") );
button[5] = new KWinToolButton( this, 0, i18n("Close") );
QHBoxLayout* hb = new QHBoxLayout;
g->addLayout( hb, 0, 1 );
hb->addWidget( button[0] );
hb->addWidget( button[1] );
hb->addWidget( button[2] );
// hb->addWidget( button[2] );
int fh = fontMetrics().lineSpacing();
@ -211,7 +211,7 @@ StdClient::StdClient( Workspace *ws, WId w, QWidget *parent, const char *name )
button[6] = 0;
if ( providesContextHelp() ) {
button[6] = new QToolButton( this );
button[6] = new KWinToolButton( this, 0, i18n("Help") );
hb->addWidget( button[6] ); // help button
hb->addItem( new QSpacerItem( 5, 0, QSizePolicy::Fixed, QSizePolicy::Expanding ) );
button[6]->setIconSet( *question_mark_pix );
@ -243,7 +243,7 @@ StdClient::StdClient( Workspace *ws, WId w, QWidget *parent, const char *name )
button[1]->setIconSet(isSticky() ? isActive() ? *pindown_pix : *dis_pindown_pix :
isActive() ? *pinup_pix : *dis_pinup_pix );
connect( button[1], SIGNAL( clicked() ), this, ( SLOT( toggleSticky() ) ) );
button[2]->hide();
// button[2]->hide();
button[3]->setIconSet(isActive() ? *minimize_pix : *dis_minimize_pix);
connect( button[3], SIGNAL( clicked() ), this, ( SLOT( iconify() ) ) );
@ -259,7 +259,7 @@ StdClient::StdClient( Workspace *ws, WId w, QWidget *parent, const char *name )
if ( isTransient() ) {
// lighter decoration for transient windows
button[1]->hide();
button[2]->hide();
// button[2]->hide();
button[3]->hide();
button[4]->hide();
}
@ -312,6 +312,7 @@ void StdClient::captionChange( const QString& )
void StdClient::maximizeChange( bool m )
{
button[4]->setIconSet( m?*normalize_pix:*maximize_pix );
button[4]->setTipText( m ? i18n("Restore") : i18n("Maximize") );
}
@ -320,6 +321,7 @@ void StdClient::maximizeChange( bool m )
void StdClient::stickyChange( bool s)
{
button[1]->setIconSet( s?*pindown_pix:*pinup_pix );
button[1]->setTipText( s ? i18n("Un-Sticky") : i18n("Sticky") );
}
void StdClient::paintEvent( QPaintEvent* )
@ -424,7 +426,7 @@ StdToolClient::StdToolClient( Workspace *ws, WId w, QWidget *parent, const char
g->addColSpacing(2, 1);
g->addRowSpacing(2, 2);
closeBtn = new QToolButton( this );
closeBtn = new KWinToolButton( this, 0, i18n("Close") );
connect( closeBtn, SIGNAL( clicked() ), this, ( SLOT( closeWindow() ) ) );
closeBtn->setFixedSize( 13, 13);
slotReset();
@ -523,6 +525,8 @@ extern "C"
{
delete_pixmaps();
create_pixmaps();
// Ensure change in tooltip state gets applied
Workspace::self()->slotResetAllClientsDelayed();
}
void deinit()
{

View file

@ -6,7 +6,7 @@ Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
#ifndef STDCLIENT_H
#define STDCLIENT_H
#include "../../client.h"
#include <qtoolbutton.h>
#include "../../kwinbutton.h"
class QLabel;
class QSpacerItem;
@ -36,7 +36,7 @@ private slots:
void slotReset();
private:
QToolButton* button[7];
KWinToolButton* button[7];
QSpacerItem* titlebar;
};
@ -58,7 +58,7 @@ protected:
private slots:
void slotReset();
private:
QToolButton* closeBtn;
KWinToolButton* closeBtn;
QSpacerItem* titlebar;
};
@ -68,17 +68,17 @@ private:
Like QToolButton, but provides a clicked(int) signals that
has the last pressed mouse button as argument
*/
class ThreeButtonButton: public QToolButton
class ThreeButtonButton: public KWinInternal:: KWinToolButton
{
Q_OBJECT
public:
ThreeButtonButton ( QWidget *parent = 0, const char* name = 0)
: QToolButton( parent, name )
ThreeButtonButton ( QWidget *parent = 0, const char* name = 0,
const QString& tip = 0 )
: KWinToolButton( parent, name, tip )
{
connect( this, SIGNAL( clicked() ), this, SLOT( handleClicked() ) );
}
~ThreeButtonButton ()
{}
~ThreeButtonButton () {}
signals:
void clicked( int );
@ -88,13 +88,13 @@ protected:
{
last_button = e->button();
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QToolButton::mousePressEvent( &me );
KWinToolButton::mousePressEvent( &me );
}
void mouseReleaseEvent( QMouseEvent* e )
{
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QToolButton::mouseReleaseEvent( &me );
KWinToolButton::mouseReleaseEvent( &me );
}
private slots:

View file

@ -1,12 +1,9 @@
#include "nextclient.h"
#include <qapplication.h>
#include <qcursor.h>
#include <qabstractlayout.h>
#include <qlayout.h>
#include <qtoolbutton.h>
#include <qlabel.h>
#include <qdrawutil.h>
#include <kpixmapeffect.h>
#include <klocale.h>
#include <qbitmap.h>
#include "../../workspace.h"
#include "../../options.h"
@ -178,8 +175,9 @@ void NextClient::slotReset()
}
NextButton::NextButton(Client *parent, const char *name,
const unsigned char *bitmap, int bw, int bh)
: QButton(parent, name)
const unsigned char *bitmap, int bw, int bh,
const QString& tip)
: KWinButton(parent, name, tip)
{
setBackgroundMode( NoBackground );
client = parent;
@ -232,10 +230,10 @@ NextClient::NextClient( Workspace *ws, WId w, QWidget *parent,
windowLayout->addSpacing(1);
button[0] = new NextButton(this, "close", close_bits, 10, 10);
button[1] = new NextButton(this, "sticky");
button[0] = new NextButton(this, "close", close_bits, 10, 10, i18n("Close"));
button[1] = new NextButton(this, "sticky", NULL, 0, 0, i18n("Sticky"));
stickyChange(isSticky());
button[2] = new NextButton(this, "iconify", iconify_bits, 10, 10);
button[2] = new NextButton(this, "iconify", iconify_bits, 10, 10, i18n("Minimize"));
connect( button[0], SIGNAL( clicked() ), this, ( SLOT( closeWindow() ) ) );
connect( button[1], SIGNAL( clicked() ), this, ( SLOT( toggleSticky() ) ) );
@ -292,14 +290,14 @@ void NextClient::paintEvent( QPaintEvent* )
p.setClipRegion( r );
p.setClipping( FALSE );
t.setTop( 2 );
t.setHeight(t.height()-4);
t.setTop( 1 );
t.setHeight(t.height()-2);
t.setLeft( t.left() + 4 );
t.setRight( t.right() - 2 );
p.setPen(options->color(Options::Font, isActive()));
p.setFont(options->font(isActive()));
p.drawText( t, AlignCenter, caption() );
p.drawText( t, AlignCenter | AlignVCenter, caption() );
qDrawShadePanel(&p, rect().x()+1, rect().bottom()-6, 24, 6,
@ -327,10 +325,8 @@ void NextClient::mouseDoubleClickEvent( QMouseEvent * e )
void NextClient::stickyChange(bool on)
{
if(on)
button[1]->setBitmap(unsticky_bits, 10, 10);
else
button[1]->setBitmap(sticky_bits, 10, 10);
button[1]->setBitmap( on ? unsticky_bits : sticky_bits, 10, 10);
button[1]->setTipText( on ? i18n("Un-Sticky") : i18n("Sticky") );
}
@ -381,6 +377,8 @@ extern "C"
{
delete_pixmaps();
create_pixmaps();
// Ensure change in tooltip state gets applied
Workspace::self()->slotResetAllClientsDelayed();
}
void deinit()
{

View file

@ -1,21 +1,21 @@
#ifndef __NEXTCLIENT_H
#define __NEXTCLIENT_H
#include <qbutton.h>
#include <qbitmap.h>
#include <kpixmap.h>
#include "../../client.h"
#include "../../kwinbutton.h"
class QLabel;
class QSpacerItem;
namespace KWinInternal {
// get rid of autohide :P
class NextButton : public QButton
class NextButton : public KWinInternal::KWinButton
{
public:
NextButton(Client *parent=0, const char *name=0,
const unsigned char *bitmap=NULL, int bw=0, int bh=0);
const unsigned char *bitmap=NULL, int bw=0, int bh=0,
const QString& tip=NULL);
void setBitmap(const unsigned char *bitmap, int bw, int bh);
void reset();
protected:

View file

@ -280,7 +280,7 @@ KWMThemeClient::KWMThemeClient( Workspace *ws, WId w, QWidget *parent,
key += QChar(keyOffsets[i]);
val = config->readEntry(key, defaultButtons[i]);
if(val == "Menu"){
mnuBtn = new MyButton(this, "menu");
mnuBtn = new MyButton(this, "menu", i18n("Menu"));
iconChange();
hb->addWidget(mnuBtn);
mnuBtn->setFixedSize(20, 20);
@ -288,7 +288,7 @@ KWMThemeClient::KWMThemeClient( Workspace *ws, WId w, QWidget *parent,
SLOT(menuButtonPressed()));
}
else if(val == "Sticky"){
stickyBtn = new MyButton(this, "sticky");
stickyBtn = new MyButton(this, "sticky", i18n("Sticky"));
if (isSticky())
stickyBtn->setPixmap(*pindownPix);
else
@ -298,21 +298,21 @@ KWMThemeClient::KWMThemeClient( Workspace *ws, WId w, QWidget *parent,
stickyBtn->setFixedSize(20, 20);
}
else if((val == "Iconify") && isMinimizable()){
btn = new MyButton(this, "iconify");
btn = new MyButton(this, "iconify", i18n("Minimize"));
btn->setPixmap(*iconifyPix);
connect(btn, SIGNAL(clicked()), this, SLOT(iconify()));
hb->addWidget(btn);
btn->setFixedSize(20, 20);
}
else if((val == "Maximize") && isMaximizable()){
maxBtn = new MyButton(this, "max");
maxBtn = new MyButton(this, "max", i18n("Maximize"));
maxBtn->setPixmap(*maxPix);
connect(maxBtn, SIGNAL(clicked()), this, SLOT(maximize()));
hb->addWidget(maxBtn);
maxBtn->setFixedSize(20, 20);
}
else if(val == "Close"){
btn = new MyButton(this, "close");
btn = new MyButton(this, "close", i18n("Close"));
btn->setPixmap(*closePix);
connect(btn, SIGNAL(clicked()), this, SLOT(closeWindow()));
hb->addWidget(btn);
@ -729,14 +729,18 @@ void KWMThemeClient::mouseDoubleClickEvent( QMouseEvent * e )
void KWMThemeClient::stickyChange(bool on)
{
if (stickyBtn)
if (stickyBtn) {
stickyBtn->setPixmap(on ? *pindownPix : *pinupPix);
stickyBtn->setTipText(on ? i18n("Un-Sticky") : i18n("Sticky") );
}
}
void KWMThemeClient::maximizeChange(bool m)
{
if (maxBtn)
if (maxBtn) {
maxBtn->setPixmap(m ? *minmaxPix : *maxPix);
maxBtn->setTipText(m ? i18n("Restore") : i18n("Maximize"));
}
}
Client::MousePosition KWMThemeClient::mousePosition(const QPoint &p) const

View file

@ -5,18 +5,18 @@
#include <qtoolbutton.h>
#include <kpixmap.h>
#include "../../client.h"
#include "../../kwinbutton.h"
class QLabel;
class QSpacerItem;
class QGridLayout;
namespace KWinInternal{
// QToolButton uses a 1 pixel border :P
class MyButton : public QToolButton
class MyButton : public KWinInternal::KWinToolButton
{
public:
MyButton(QWidget *parent=0, const char *name=0)
: QToolButton(parent, name){setAutoRaise(true);}
MyButton(QWidget *parent=0, const char *name=0, const QString& tip=NULL)
: KWinToolButton(parent, name, tip){setAutoRaise(true);}
protected:
void drawButtonLabel(QPainter *p);
};

View file

@ -1,17 +1,14 @@
#include <kconfig.h> // up here to avoid X11 header conflict :P
#include "laptopclient.h"
#include <qapplication.h>
#include <qcursor.h>
#include <qabstractlayout.h>
#include <qlayout.h>
#include <qtoolbutton.h>
#include <qlabel.h>
#include <qdrawutil.h>
#include <kpixmapeffect.h>
#include <kdrawutil.h>
#include <kglobal.h>
#include <kapp.h>
#include <klocale.h>
#include <qbitmap.h>
#include "../../workspace.h"
#include "../../options.h"
@ -222,9 +219,10 @@ static void delete_pixmaps()
}
LaptopClientButton::LaptopClientButton(int w, int h, Client *parent, const char *name,
const unsigned char *bitmap)
: QButton(parent, name)
LaptopClientButton::LaptopClientButton(int w, int h, Client *parent,
const char *name, const unsigned char *bitmap,
const QString& tip)
: KWinButton(parent, name, tip)
{
client = parent;
defaultSize = QSize(w, h);
@ -324,19 +322,21 @@ LaptopClient::LaptopClient( Workspace *ws, WId w, QWidget *parent,
if ( isTool() )
th -= 2;
button[BtnClose] = new LaptopClientButton(27, th, this, "close", close_bits);
button[BtnSticky] = new LaptopClientButton(17, th, this, "sticky");
button[BtnClose] = new LaptopClientButton(27, th, this, "close",
close_bits, i18n("Close"));
button[BtnSticky] = new LaptopClientButton(17, th, this, "sticky",
NULL, i18n("Sticky"));
if(isSticky())
button[BtnSticky]->setBitmap(unsticky_bits);
else
button[BtnSticky]->setBitmap(sticky_bits);
button[BtnIconify] = new LaptopClientButton(27, th, this, "iconify",
iconify_bits);
iconify_bits, i18n("Minimize"));
button[BtnMax] = new LaptopClientButton(27, th, this, "maximize",
maximize_bits);
maximize_bits, i18n("Maximize"));
if(help){
button[BtnHelp] = new LaptopClientButton(17, th, this, "help",
question_bits);
question_bits, i18n("Help"));
connect(button[BtnHelp], SIGNAL( clicked() ), this, ( SLOT( contextHelp() ) ) );
}
else
@ -533,11 +533,13 @@ void LaptopClient::mouseDoubleClickEvent( QMouseEvent * e )
void LaptopClient::stickyChange(bool on)
{
button[BtnSticky]->setBitmap(on ? unsticky_bits : sticky_bits);
button[BtnSticky]->setTipText(on ? i18n("Un-Sticky") : i18n("Sticky"));
}
void LaptopClient::maximizeChange(bool m)
{
button[BtnMax]->setBitmap(m ? minmax_bits : maximize_bits);
button[BtnMax]->setTipText(m ? i18n("Restore") : i18n("Maximize"));
}
void LaptopClient::init()
@ -694,6 +696,8 @@ extern "C"
{
delete_pixmaps();
create_pixmaps();
// Ensure change in tooltip state gets applied
Workspace::self()->slotResetAllClientsDelayed();
}
void deinit()
{

View file

@ -1,22 +1,21 @@
#ifndef __KDECLIENT_H
#define __KDECLIENT_H
#include <qbutton.h>
#include <qbitmap.h>
#include <kpixmap.h>
#include "../../client.h"
#include "../../kwinbutton.h"
class QLabel;
class QSpacerItem;
class QHBoxLayout;
namespace KWinInternal {
// get rid of autohide :P
class LaptopClientButton : public QButton
class LaptopClientButton : public KWinInternal::KWinButton
{
public:
LaptopClientButton(int w, int h, Client *parent=0, const char *name=0,
const unsigned char *bitmap=NULL);
const unsigned char *bitmap=NULL, const QString& tip=NULL);
void setBitmap(const unsigned char *bitmap);
void reset();
QSize sizeHint() const;
@ -27,13 +26,13 @@ protected:
{
last_button = e->button();
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QButton::mousePressEvent( &me );
KWinButton::mousePressEvent( &me );
}
void mouseReleaseEvent( QMouseEvent* e )
{
last_button = e->button();
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QButton::mouseReleaseEvent( &me );
KWinButton::mouseReleaseEvent( &me );
}
virtual void drawButton(QPainter *p);
void drawButtonLabel(QPainter *) {}

View file

@ -4,6 +4,7 @@
#include <kconfig.h>
#include <kglobal.h>
#include <klocale.h>
#include <qlayout.h>
#include <qdrawutil.h>
#include <kpixmapeffect.h>
@ -66,7 +67,6 @@ static QString *button_pattern = NULL;
static bool show_handle;
static int handle_size;
static int handle_width;
static bool config_changed;
static void make_button_fx(const QColorGroup &g, QPixmap *pix, bool light=false)
{
@ -218,8 +218,8 @@ static bool read_config()
}
ModernButton::ModernButton(Client *parent, const char *name,
const unsigned char *bitmap)
: QButton(parent, name)
const unsigned char *bitmap, const QString& tip)
: KWinButton(parent, name, tip)
{
setBackgroundMode( NoBackground );
QBitmap mask(14, 15, QPixmap::defaultDepth() > 8 ?
@ -229,8 +229,8 @@ ModernButton::ModernButton(Client *parent, const char *name,
if(bitmap)
setBitmap(bitmap);
setMask(mask);
client = parent;
hide();
client = parent;
}
QSize ModernButton::sizeHint() const
@ -270,22 +270,19 @@ void ModernButton::mousePressEvent( QMouseEvent* e )
{
last_button = e->button();
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QButton::mousePressEvent( &me );
KWinButton::mousePressEvent( &me );
}
void ModernButton::mouseReleaseEvent( QMouseEvent* e )
{
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QButton::mouseReleaseEvent( &me );
KWinButton::mouseReleaseEvent( &me );
}
void ModernSys::slotReset()
{
if (config_changed) {
workspace()->slotResetAllClientsDelayed();
config_changed = false;
}
workspace()->slotResetAllClientsDelayed();
titleBuffer.resize(0, 0);
recalcTitleBuffer();
for (int i = 0; i < 5; button[i++]->reset());
@ -314,17 +311,17 @@ ModernSys::ModernSys( Workspace *ws, WId w, QWidget *parent,
titlebar = new QSpacerItem(10, 16, QSizePolicy::Expanding,
QSizePolicy::Minimum);
button[BtnClose] = new ModernButton(this, "close", close_bits);
button[BtnSticky] = new ModernButton(this, "sticky");
button[BtnMinimize] = new ModernButton(this, "iconify", iconify_bits);
button[BtnMaximize] = new ModernButton(this, "maximize", maximize_bits);
button[BtnHelp] = new ModernButton(this, "help", question_bits);
button[BtnClose] = new ModernButton(this, "close", close_bits, i18n("Close"));
button[BtnSticky] = new ModernButton(this, "sticky", NULL, i18n("Sticky"));
button[BtnMinimize] = new ModernButton(this, "iconify", iconify_bits, i18n("Minimize"));
button[BtnMaximize] = new ModernButton(this, "maximize", maximize_bits, i18n("Maximize"));
button[BtnHelp] = new ModernButton(this, "help", question_bits, i18n("Help"));
connect( button[BtnClose], SIGNAL( clicked() ), this, ( SLOT( closeWindow() ) ) );
connect( button[BtnSticky], SIGNAL( clicked() ), this, ( SLOT( toggleSticky() ) ) );
connect( button[BtnMinimize], SIGNAL( clicked() ), this, ( SLOT( iconify() ) ) );
connect( button[BtnMaximize], SIGNAL( clicked() ), this, ( SLOT( maxButtonClicked() ) ) );
connect( button[BtnHelp], SIGNAL( clicked() ), this, ( SLOT( contextHelp() ) ) );
connect( button[BtnClose], SIGNAL(clicked()), this, SLOT( closeWindow() ) );
connect( button[BtnSticky], SIGNAL(clicked()), this, SLOT( toggleSticky() ) );
connect( button[BtnMinimize], SIGNAL(clicked()), this, SLOT( iconify() ) );
connect( button[BtnMaximize], SIGNAL(clicked()), this, SLOT( maxButtonClicked() ) );
connect( button[BtnHelp], SIGNAL(clicked()), this, SLOT( contextHelp() ) );
for (int i = 0; i < (int)button_pattern->length();) {
QChar c = (*button_pattern)[i++];
@ -575,11 +572,13 @@ void ModernSys::mouseDoubleClickEvent( QMouseEvent * e )
void ModernSys::stickyChange(bool on)
{
button[BtnSticky]->setBitmap(on ? unsticky_bits : sticky_bits);
button[BtnSticky]->setTipText(on ? i18n("Un-Sticky") : i18n("Sticky"));
}
void ModernSys::maximizeChange(bool m)
{
button[BtnMaximize]->setBitmap(m ? minmax_bits : maximize_bits);
button[BtnMaximize]->setTipText(m ? i18n("Restore") : i18n("Maximize"));
}
void ModernSys::init()
@ -626,12 +625,10 @@ extern "C"
button_pattern = new QString;
create_pixmaps();
read_config();
config_changed = true;
}
void reset()
{
if (read_config())
config_changed = true;
read_config();
delete_pixmaps();
create_pixmaps();
}

View file

@ -6,18 +6,19 @@
#include <qbitmap.h>
#include <kpixmap.h>
#include "../../client.h"
#include "../../kwinbutton.h"
class QLabel;
class QSpacerItem;
namespace KWinInternal {
// get rid of autohide :P
class ModernButton : public QButton
class ModernButton : public KWinInternal::KWinButton
{
Q_OBJECT
public:
ModernButton(Client *parent=0, const char *name=0,
const unsigned char *bitmap=NULL);
const unsigned char *bitmap=NULL,
const QString& tip=NULL);
void setBitmap(const unsigned char *bitmap);
void reset();
QSize sizeHint() const;
@ -28,7 +29,7 @@ protected:
virtual void drawButton(QPainter *p);
void drawButtonLabel(QPainter *){;}
QBitmap deco;
Client *client;
Client* client;
public:
int last_button;
};

View file

@ -1,16 +1,13 @@
#include <qapplication.h>
#include <qdatetime.h>
#include <qlayout.h>
#include <qbutton.h>
#include <qdrawutil.h>
#include <klocale.h>
#include "../../workspace.h"
#include "../../options.h"
#include "mwmclient.h"
#include <kdebug.h>
using namespace KWinInternal;
static const int s_frameWidth = 5;
@ -41,13 +38,13 @@ static void fixColorGroup(QColorGroup & colorGroup)
}
}
MwmButton::MwmButton( MwmClient* parent, const char* name, int btnType )
: QButton( parent, name , WStyle_Customize | WStyle_NoBorder
| WRepaintNoErase | WResizeNoErase ), m_parent(parent), m_btnType(btnType)
MwmButton::MwmButton( MwmClient* parent, const char* name, int btnType, const QString& tip )
: KWinButton( parent, name, tip ), m_btnType(btnType)
{
setBackgroundMode( QWidget::NoBackground );
setFixedSize( s_buttonSize, s_buttonSize );
resize( s_buttonSize, s_buttonSize );
m_parent = parent;
}
void MwmButton::reset()
@ -102,9 +99,9 @@ MwmClient::MwmClient( Workspace* ws, WId w, QWidget* parent, const char* name )
windowLayout->addWidget( windowWrapper(), 1 );
windowLayout->addSpacing( s_frameWidth+1 );
button[BtnMenu] = new MwmButton( this, "menu", BtnMenu );
button[BtnIconify] = new MwmButton( this, "iconify", BtnIconify );
button[BtnMax] = new MwmButton( this, "maximize", BtnMax );
button[BtnMenu] = new MwmButton( this, "menu", BtnMenu, i18n("Menu") );
button[BtnIconify] = new MwmButton( this, "iconify", BtnIconify, i18n("Minimize") );
button[BtnMax] = new MwmButton( this, "maximize", BtnMax, i18n("Maximize") );
connect( button[BtnMenu], SIGNAL( pressed() ),
this, ( SLOT( menuButtonPressed() ) ) );
@ -155,6 +152,11 @@ void MwmClient::slotMaximize()
maximize();
}
void MwmClient::maximizeChange(bool m)
{
button[BtnMax]->setTipText(m ? i18n("Restore") : i18n("Maximize"));
}
void MwmClient::menuButtonPressed()
{
static QTime* t = 0;
@ -502,6 +504,8 @@ extern "C"
}
void reset()
{
// Ensure changes in tooltip state get applied
Workspace::self()->slotResetAllClientsDelayed();
}
void deinit()
{

View file

@ -5,28 +5,29 @@
#include <qbitmap.h>
#include <kpixmap.h>
#include "../../client.h"
#include "../../kwinbutton.h"
class QLabel;
class QSpacerItem;
namespace KWinInternal {
class MwmClient;
enum Buttons { BtnMenu=0, BtnIconify=1, BtnMax=2 };
class MwmClient;
class MwmButton : public QButton
class MwmButton : public KWinInternal::KWinButton
{
public:
MwmButton( MwmClient* parent=0, const char* name=0, int btnType=0 );
MwmButton( MwmClient* parent=0, const char* name=0, int btnType=0,
const QString& tip=NULL );
void reset();
protected:
virtual void drawButton( QPainter *p );
private:
MwmClient* m_parent;
int m_btnType;
Client* m_parent;
};
class MwmClient : public KWinInternal::Client
@ -43,6 +44,7 @@ protected:
void mouseDoubleClickEvent( QMouseEvent* );
void init();
void captionChange( const QString& );
void maximizeChange( bool m );
void activeChange( bool );
MousePosition mousePosition( const QPoint& p ) const;

View file

@ -19,6 +19,7 @@
#include <kglobal.h>
#include <kpixmapeffect.h>
#include <kdrawutil.h>
#include <klocale.h>
#include <qlayout.h>
#include <qdrawutil.h>
#include <qbitmap.h>
@ -268,20 +269,19 @@ void QuartzHandler::freePixmaps()
QuartzButton::QuartzButton(Client *parent, const char *name, bool largeButton,
bool isLeftButton, bool isStickyButton, const unsigned char *bitmap )
: QButton(parent, name, WStyle_Customize | WRepaintNoErase |
WResizeNoErase | WStyle_NoBorder )
bool isLeftButton, bool isStickyButton, const unsigned char *bitmap,
const QString& tip)
: KWinButton(parent, name, tip)
{
// Eliminate any possible background flicker
setBackgroundMode( QWidget::NoBackground );
setToggleButton( isStickyButton );
client = parent;
deco = NULL;
large = largeButton;
isLeft = isLeftButton;
deco = NULL;
large = largeButton;
isLeft = isLeftButton;
isSticky = isStickyButton;
client = parent;
if ( large )
setFixedSize(16, 16);
@ -392,7 +392,7 @@ void QuartzButton::mousePressEvent( QMouseEvent* e )
last_button = e->button();
QMouseEvent me( e->type(), e->pos(), e->globalPos(),
LeftButton, e->state() );
QButton::mousePressEvent( &me );
KWinButton::mousePressEvent( &me );
}
@ -401,7 +401,7 @@ void QuartzButton::mouseReleaseEvent( QMouseEvent* e )
last_button = e->button();
QMouseEvent me( e->type(), e->pos(), e->globalPos(),
LeftButton, e->state() );
QButton::mouseReleaseEvent( &me );
KWinButton::mouseReleaseEvent( &me );
}
@ -471,8 +471,9 @@ void QuartzClient::addClientButtons( const QString& s, bool isLeft )
if (!button[BtnMenu])
{
button[BtnMenu] = new QuartzButton(this, "menu",
largeButtons, isLeft, false, NULL);
connect( button[BtnMenu], SIGNAL(pressed()), this, SLOT(menuButtonPressed()) );
largeButtons, isLeft, false, NULL, i18n("Menu"));
connect( button[BtnMenu], SIGNAL(pressed()),
this, SLOT(menuButtonPressed()) );
hb->addWidget( button[BtnMenu] );
}
break;
@ -481,10 +482,11 @@ void QuartzClient::addClientButtons( const QString& s, bool isLeft )
case 'S':
if (!button[BtnSticky])
{
button[BtnSticky] = new QuartzButton(this, "menu",
largeButtons, isLeft, true, NULL);
button[BtnSticky] = new QuartzButton(this, "sticky",
largeButtons, isLeft, true, NULL, i18n("Sticky"));
button[BtnSticky]->turnOn( isSticky() );
connect( button[BtnSticky], SIGNAL(clicked()), this, SLOT(toggleSticky()) );
connect( button[BtnSticky], SIGNAL(clicked()),
this, SLOT(toggleSticky()) );
hb->addSpacing(1);
hb->addWidget( button[BtnSticky] );
hb->addSpacing(1);
@ -496,8 +498,9 @@ void QuartzClient::addClientButtons( const QString& s, bool isLeft )
if( providesContextHelp() && (!button[BtnHelp]) )
{
button[BtnHelp] = new QuartzButton(this, "help",
largeButtons, isLeft, true, question_bits);
connect( button[BtnHelp], SIGNAL( clicked() ), this, SLOT(contextHelp()));
largeButtons, isLeft, true, question_bits, i18n("Help"));
connect( button[BtnHelp], SIGNAL( clicked() ),
this, SLOT(contextHelp()));
hb->addWidget( button[BtnHelp] );
}
break;
@ -507,8 +510,9 @@ void QuartzClient::addClientButtons( const QString& s, bool isLeft )
if ( (!button[BtnIconify]) && isMinimizable())
{
button[BtnIconify] = new QuartzButton(this, "iconify",
largeButtons, isLeft, true, iconify_bits);
connect( button[BtnIconify], SIGNAL( clicked()), this, SLOT(iconify()) );
largeButtons, isLeft, true, iconify_bits, i18n("Minimize"));
connect( button[BtnIconify], SIGNAL( clicked()),
this, SLOT(iconify()) );
hb->addWidget( button[BtnIconify] );
}
break;
@ -518,8 +522,9 @@ void QuartzClient::addClientButtons( const QString& s, bool isLeft )
if ( (!button[BtnMax]) && isMaximizable())
{
button[BtnMax] = new QuartzButton(this, "maximize",
largeButtons, isLeft, true, maximize_bits);
connect( button[BtnMax], SIGNAL( clicked()), this, SLOT(slotMaximize()) );
largeButtons, isLeft, true, maximize_bits, i18n("Maximize"));
connect( button[BtnMax], SIGNAL( clicked()),
this, SLOT(slotMaximize()) );
hb->addWidget( button[BtnMax] );
}
break;
@ -529,8 +534,9 @@ void QuartzClient::addClientButtons( const QString& s, bool isLeft )
if (!button[BtnClose])
{
button[BtnClose] = new QuartzButton(this, "close",
largeButtons, isLeft, true, close_bits);
connect( button[BtnClose], SIGNAL( clicked()), this, SLOT(closeWindow()) );
largeButtons, isLeft, true, close_bits, i18n("Close"));
connect( button[BtnClose], SIGNAL( clicked()),
this, SLOT(closeWindow()) );
hb->addWidget( button[BtnClose] );
}
}
@ -551,6 +557,7 @@ void QuartzClient::stickyChange(bool on)
{
button[BtnSticky]->turnOn(on);
button[BtnSticky]->repaint(false);
button[BtnSticky]->setTipText(on ? i18n("Un-Sticky") : i18n("Sticky"));
}
}
@ -725,8 +732,10 @@ void QuartzClient::mouseDoubleClickEvent( QMouseEvent * e )
void QuartzClient::maximizeChange(bool m)
{
if (button[BtnMax])
if (button[BtnMax]) {
button[BtnMax]->setBitmap(m ? minmax_bits : maximize_bits);
button[BtnMax]->setTipText(m ? i18n("Restore") : i18n("Maximize"));
}
}

View file

@ -22,6 +22,7 @@
#include <qbitmap.h>
#include <kpixmap.h>
#include "../../client.h"
#include "../../kwinbutton.h"
class QSpacerItem;
class QHBoxLayout;
@ -47,12 +48,12 @@ class QuartzHandler: public QObject
};
class QuartzButton : public QButton
class QuartzButton : public KWinInternal::KWinButton
{
public:
QuartzButton(Client *parent=0, const char *name=0, bool largeButton=true,
bool isLeftButton=true, bool isStickyButton=false,
const unsigned char *bitmap=NULL);
const unsigned char *bitmap=NULL, const QString& tip=NULL);
~QuartzButton();
void setBitmap(const unsigned char *bitmap);
QSize sizeHint() const;
@ -65,11 +66,11 @@ class QuartzButton : public QButton
void drawButton(QPainter *p);
void drawButtonLabel(QPainter*) {;}
Client* client;
QBitmap* deco;
bool large;
bool isLeft;
bool isSticky;
Client* client;
};

View file

@ -29,8 +29,8 @@ using namespace KWinInternal;
namespace RiscOS
{
Button::Button(QWidget * parent)
: QWidget (parent, "Button"),
Button::Button(QWidget * parent, const QString& tip)
: KWinWidgetButton (parent, "Button", 0, tip),
alignment_(Left),
down_ (false),
active_ (false)
@ -72,17 +72,19 @@ Button::alignment() const
}
void
Button::mousePressEvent(QMouseEvent *)
Button::mousePressEvent(QMouseEvent *e)
{
down_ = true;
repaint();
KWinWidgetButton::mousePressEvent(e);
}
void
Button::mouseReleaseEvent(QMouseEvent *)
Button::mouseReleaseEvent(QMouseEvent *e)
{
down_ = false;
repaint();
KWinWidgetButton::mouseReleaseEvent(e);
}
void

View file

@ -25,11 +25,13 @@
#include <qpixmap.h>
#include <qwidget.h>
#include <klocale.h>
#include "../../kwinbutton.h"
namespace RiscOS
{
class Button : public QWidget
class Button : public KWinInternal::KWinWidgetButton
{
Q_OBJECT
@ -39,7 +41,7 @@ class Button : public QWidget
enum Alignment { Left, Right };
Button(QWidget * parent);
Button(QWidget * parent, const QString& tip);
virtual ~Button();
void setAlignment(Alignment);

View file

@ -45,7 +45,7 @@ static const char * const close_xpm[] = {
" . . "};
CloseButton::CloseButton(QWidget * parent)
: Button(parent)
: Button(parent, i18n("Close"))
{
setPixmap(QPixmap((const char **)close_xpm));
connect(this, SIGNAL(closeWindow()), parent, SLOT(closeWindow()));

View file

@ -45,7 +45,7 @@ static const char * const help_xpm[] = {
" ++ "};
HelpButton::HelpButton(QWidget * parent)
: Button(parent)
: Button(parent, i18n("Help"))
{
setPixmap(QPixmap((const char **)help_xpm));
connect(this, SIGNAL(help()), parent, SLOT(slotHelp()));

View file

@ -45,7 +45,7 @@ static const char * const iconify_xpm[] = {
" "};
IconifyButton::IconifyButton(QWidget * parent)
: Button(parent)
: Button(parent, i18n("Minimize"))
{
setPixmap(QPixmap((const char **)iconify_xpm));
connect(this, SIGNAL(iconify()), parent, SLOT(iconify()));

View file

@ -45,7 +45,7 @@ static const char * const lower_xpm[] = {
" "};
LowerButton::LowerButton(QWidget * parent)
: Button(parent)
: Button(parent, i18n("Lower"))
{
setPixmap(QPixmap((const char **)lower_xpm));
connect(this, SIGNAL(lower()), parent, SLOT(lower()));

View file

@ -64,7 +64,7 @@ static const char * const unmaximise_xpm[] = {
" "};
MaximiseButton::MaximiseButton(QWidget * parent)
: Button(parent),
: Button(parent, i18n("Maximize")),
on_(false)
{
setPixmap(QPixmap((const char **)maximise_xpm));
@ -84,6 +84,11 @@ MaximiseButton::setOn(bool on)
QPixmap((const char **)maximise_xpm)
);
repaint();
setTipText(
on_ ?
i18n("Restore") :
i18n("Maximize")
);
}
void

View file

@ -65,7 +65,7 @@ static const char * const sticky_xpm[] = {
StickyButton::StickyButton(QWidget * parent)
: Button(parent),
: Button(parent, i18n("Sticky")),
on_(false)
{
setPixmap(QPixmap((const char **)sticky_xpm));
@ -83,6 +83,11 @@ StickyButton::setOn(bool on)
QPixmap((const char **)sticky_xpm)
);
repaint();
setTipText(
on_ ?
i18n("Un-Sticky") :
i18n("Sticky")
);
}
void

View file

@ -1,13 +1,10 @@
#include "systemclient.h"
#include <qapplication.h>
#include <qcursor.h>
#include <qabstractlayout.h>
#include <qlayout.h>
#include <qtoolbutton.h>
#include <qlabel.h>
#include <qdrawutil.h>
#include <kpixmapeffect.h>
#include <kdrawutil.h>
#include <klocale.h>
#include <kapp.h>
#include <qbitmap.h>
#include "../../workspace.h"
@ -183,8 +180,8 @@ static void delete_pixmaps()
}
SystemButton::SystemButton(Client *parent, const char *name,
const unsigned char *bitmap)
: QToolButton(parent, name)
const unsigned char *bitmap, const QString& tip)
: KWinButton(parent, name, tip)
{
setBackgroundMode( NoBackground );
resize(14, 14);
@ -249,21 +246,19 @@ void SystemButton::drawButton(QPainter *p)
p->setPen(*btnForeground);
p->drawPixmap(isDown() ? 4 : 3, isDown() ? 4 : 3, deco);
}
}
void SystemButton::mousePressEvent( QMouseEvent* e )
{
last_button = e->button();
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QToolButton::mousePressEvent( &me );
KWinButton::mousePressEvent( &me );
}
void SystemButton::mouseReleaseEvent( QMouseEvent* e )
{
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QToolButton::mouseReleaseEvent( &me );
KWinButton::mouseReleaseEvent( &me );
}
void SystemButton::handleClicked()
@ -316,16 +311,17 @@ SystemClient::SystemClient( Workspace *ws, WId w, QWidget *parent,
g->addColSpacing(2, 2);
g->addRowSpacing(2, 6);
button[0] = new SystemButton(this, "close"/*, close_bits*/);
button[1] = new SystemButton(this, "sticky");
button[0] = new SystemButton(this, "close", NULL, i18n("Close"));
button[1] = new SystemButton(this, "sticky", NULL, i18n("Sticky"));
if(isSticky())
button[1]->setBitmap(unsticky_bits);
else
button[1]->setBitmap(sticky_bits);
button[2] = new SystemButton(this, "iconify", iconify_bits);
button[3] = new SystemButton(this, "maximize", maximize_bits);
button[2] = new SystemButton(this, "iconify", iconify_bits, i18n("Minimize"));
button[3] = new SystemButton(this, "maximize", maximize_bits, i18n("Maximize"));
if(help){
button[4] = new SystemButton(this, "help", question_bits);
button[4] = new SystemButton(this, "help", question_bits, i18n("Help"));
connect( button[4], SIGNAL( clicked() ), this, ( SLOT( contextHelp() ) ) );
}
else
@ -352,10 +348,18 @@ SystemClient::SystemClient( Workspace *ws, WId w, QWidget *parent,
}
hb->addWidget( button[1]);
hb->addSpacing(1);
hb->addWidget( button[2]);
hb->addSpacing(1);
hb->addWidget( button[3]);
hb->addSpacing(3);
if (isMinimizable()) {
hb->addWidget(button[2]);
hb->addSpacing(1);
} else
button[2]->hide();
if (isMaximizable()) {
hb->addWidget(button[3]);
hb->addSpacing(3);
} else
button[3]->hide();
setBackgroundMode(NoBackground);
recalcTitleBuffer();
@ -508,11 +512,13 @@ void SystemClient::mouseDoubleClickEvent( QMouseEvent * e )
void SystemClient::stickyChange(bool on)
{
button[1]->setBitmap(on ? unsticky_bits : sticky_bits);
button[1]->setTipText(on ? i18n("Un-Sticky") : i18n("Sticky"));
}
void SystemClient::maximizeChange(bool m)
{
button[3]->setBitmap(m ? minmax_bits : maximize_bits);
button[3]->setTipText(m ? i18n("Restore") : i18n("Maximize"));
}
void SystemClient::init()
@ -545,6 +551,8 @@ extern "C"
{
delete_pixmaps();
create_pixmaps();
// Ensure changes in tooltip state get applied
Workspace::self()->slotResetAllClientsDelayed();
}
void deinit()
{

View file

@ -1,12 +1,10 @@
#ifndef __SYSTEMCLIENT_H
#define __SYSTEMCLIENT_H
#include <qbutton.h>
#include <qtoolbutton.h>
#include <qbitmap.h>
#include <kpixmap.h>
#include "../../client.h"
#include "../../kwinbutton.h"
class QLabel;
@ -14,12 +12,12 @@ class QSpacerItem;
namespace KWinInternal {
class SystemButton : public QToolButton
class SystemButton : public KWinInternal::KWinButton
{
Q_OBJECT
public:
SystemButton(Client *parent=0, const char *name=0,
const unsigned char *bitmap=NULL);
const unsigned char *bitmap=NULL, const QString& tip=NULL);
void setBitmap(const unsigned char *bitmap);
void reset();
QSize sizeHint() const;
@ -29,7 +27,6 @@ protected:
virtual void drawButton(QPainter *p);
void drawButtonLabel(QPainter *){;}
QBitmap deco;
Client *client;
void mousePressEvent( QMouseEvent* e );
void mouseReleaseEvent( QMouseEvent* e );
@ -39,7 +36,7 @@ private slots:
private:
int last_button;
Client* client;
};
class SystemClient : public KWinInternal::Client

View file

@ -60,6 +60,7 @@ extern "C"
void reset()
{
Workspace::self()->slotResetAllClientsDelayed();
// Empty.
}

View file

@ -25,8 +25,8 @@
using namespace KWinInternal;
WebButton::WebButton(QWidget * parent)
: QWidget (parent),
WebButton::WebButton(QWidget * parent, const QString& tip)
: KWinWidgetButton (parent, 0, 0, tip),
mouseOver_ (false),
mouseDown_ (false),
position_ (Mid),
@ -49,10 +49,11 @@ WebButton::setShape(bool b)
}
void
WebButton::mousePressEvent(QMouseEvent *)
WebButton::mousePressEvent(QMouseEvent * e)
{
mouseDown_ = true;
repaint();
KWinWidgetButton::mousePressEvent(e);
}
void
@ -65,20 +66,23 @@ WebButton::mouseReleaseEvent(QMouseEvent * e)
{
clickEvent(e->button());
}
KWinWidgetButton::mouseReleaseEvent(e);
}
void
WebButton::enterEvent(QEvent *)
WebButton::enterEvent(QEvent * e)
{
mouseOver_ = true;
repaint();
KWinWidgetButton::enterEvent(e);
}
void
WebButton::leaveEvent(QEvent *)
WebButton::leaveEvent(QEvent * e)
{
mouseOver_ = false;
repaint();
KWinWidgetButton::leaveEvent(e);
}
void

View file

@ -24,10 +24,12 @@
#include <qwidget.h>
#include <qbitmap.h>
#include <klocale.h>
#include "../../kwinbutton.h"
namespace KWinInternal
{
class WebButton : public QWidget
class WebButton : public KWinInternal::KWinWidgetButton
{
Q_OBJECT
@ -38,7 +40,7 @@ namespace KWinInternal
Left, Mid, Right
};
WebButton(QWidget * parent);
WebButton(QWidget * parent, const QString& tip);
virtual ~WebButton();

View file

@ -29,7 +29,7 @@ static unsigned char close_bits[] =
};
WebButtonClose::WebButtonClose(QWidget * parent)
: WebButton(parent)
: WebButton(parent, i18n("Close"))
{
QBitmap b(8, 8, close_bits, true /* isXBitmap */);
b.setMask(b);

View file

@ -29,7 +29,7 @@ static unsigned char help_bits[] =
};
WebButtonHelp::WebButtonHelp(QWidget * parent)
: WebButton(parent)
: WebButton(parent, i18n("Help"))
{
QBitmap b(8, 8, help_bits, true /* isXBitmap */);
b.setMask(b);

View file

@ -29,7 +29,7 @@ static unsigned char iconify_bits[] =
};
WebButtonIconify::WebButtonIconify(QWidget * parent)
: WebButton(parent)
: WebButton(parent, i18n("Minimize"))
{
QBitmap b(8, 8, iconify_bits, true /* isXBitmap */);
b.setMask(b);

View file

@ -29,7 +29,7 @@ static unsigned char lower_bits[] =
};
WebButtonLower::WebButtonLower(QWidget * parent)
: WebButton(parent)
: WebButton(parent, i18n("Lower"))
{
QBitmap b(8, 8, lower_bits, true /* isXBitmap */);
b.setMask(b);

View file

@ -34,7 +34,7 @@ static unsigned char unmaximize_bits[] =
};
WebButtonMaximize::WebButtonMaximize(bool max, QWidget * parent)
: WebButton(parent)
: WebButton(parent, i18n("Maximize"))
{
QBitmap b(8, 8, max ? unmaximize_bits : maximize_bits, true /* isXBitmap */);
b.setMask(b);
@ -47,6 +47,7 @@ WebButtonMaximize::slotMaximizeChange(bool max)
QBitmap b(8, 8, max ? unmaximize_bits : maximize_bits, true /* isXBitmap */);
b.setMask(b);
setBitmap(b);
setTipText(max ? i18n("Restore") : i18n("Maximize"));
}
void

View file

@ -34,7 +34,7 @@ static unsigned char unsticky_bits[] =
};
WebButtonSticky::WebButtonSticky(bool sticky, QWidget * parent)
: WebButton(parent)
: WebButton(parent, i18n("Sticky"))
{
QBitmap b(8, 8, sticky ? unsticky_bits : sticky_bits, true /* isXBitmap */);
b.setMask(b);
@ -47,6 +47,7 @@ WebButtonSticky::slotStickyChange(bool sticky)
QBitmap b(8, 8, sticky ? unsticky_bits : sticky_bits, true /* isXBitmap */);
b.setMask(b);
setBitmap(b);
setTipText(sticky ? i18n("Un-Sticky") : i18n("Sticky"));
}
void

View file

@ -19,6 +19,7 @@
#include <qdatetime.h>
#include <kpixmapeffect.h>
#include <kdrawutil.h>
#include <klocale.h>
#include <qbitmap.h>
#include "../../workspace.h"
#include "../../options.h"
@ -227,17 +228,15 @@ void delete_pixmaps()
GalliumButton::GalliumButton(Client *parent, const char *name,
const unsigned char *bitmap, bool menuButton, bool isMini)
: QButton(parent, name, WStyle_Customize | WRepaintNoErase |
WResizeNoErase | WStyle_NoBorder )
const unsigned char *bitmap, bool menuButton, bool isMini, const QString& tip)
: KWinButton(parent, name, tip)
{
// Eliminate background flicker
setBackgroundMode( QWidget::NoBackground );
client = parent;
menuBtn = menuButton;
miniBtn = isMini;
client = parent;
// Use larger button for the menu, or mini-buttons for toolwindows.
if ( isMini )
@ -378,10 +377,14 @@ GalliumClient::GalliumClient( Workspace *ws, WId w, QWidget *parent,
g->addColSpacing(0, 4);
g->addColSpacing(2, 4);
button[BtnMenu] = new GalliumButton(this, "menu", NULL, true, smallButtons);
button[BtnClose] = new GalliumButton(this, "close", close_bits, false, smallButtons);
button[BtnIconify] = new GalliumButton(this, "iconify", iconify_bits, false, smallButtons);
button[BtnMax] = new GalliumButton(this, "maximize", maximize_bits, false, smallButtons);
button[BtnMenu] = new GalliumButton(this, "menu", NULL, true, smallButtons,
i18n("Menu"));
button[BtnClose] = new GalliumButton(this, "close", close_bits, false, smallButtons,
i18n("Close"));
button[BtnIconify] = new GalliumButton(this, "iconify", iconify_bits, false, smallButtons,
i18n("Minimize"));
button[BtnMax] = new GalliumButton(this, "maximize", maximize_bits, false, smallButtons,
i18n("Maximize"));
// Connect required stuff together
connect( button[BtnMenu], SIGNAL(pressed()), this, SLOT( menuButtonPressed() ));
@ -402,7 +405,8 @@ GalliumClient::GalliumClient( Workspace *ws, WId w, QWidget *parent,
if( providesContextHelp() )
{
button[BtnHelp] = new GalliumButton(this, "help", question_bits, false, smallButtons);
button[BtnHelp] = new GalliumButton(this, "help", question_bits, false, smallButtons,
i18n("Help"));
connect( button[BtnHelp], SIGNAL( clicked() ), this, SLOT( contextHelp() ));
hb->addWidget( button[BtnHelp] );
}
@ -637,6 +641,7 @@ void GalliumClient::mouseDoubleClickEvent( QMouseEvent * e )
void GalliumClient::maximizeChange(bool m)
{
button[BtnMax]->setBitmap(m ? minmax_bits : maximize_bits);
button[BtnMax]->setTipText(m ? i18n("Restore") : i18n("Maximize"));
}
@ -755,6 +760,7 @@ extern "C"
{
delete_pixmaps();
create_pixmaps();
Workspace::self()->slotResetAllClientsDelayed();
}
void deinit()

View file

@ -20,19 +20,21 @@
#include <qbitmap.h>
#include <kpixmap.h>
#include "../../client.h"
#include "../../kwinbutton.h"
class QLabel;
class QSpacerItem;
class QHBoxLayout;
namespace KWinInternal {
class GalliumButton : public QButton
class GalliumButton : public KWinInternal::KWinButton
{
public:
GalliumButton(Client *parent=0, const char *name=0,
const unsigned char *bitmap=NULL,
bool menuButton=false, bool isMini=false );
bool menuButton=false, bool isMini=false,
const QString& tip=NULL);
void setBitmap(const unsigned char *bitmap);
void setPixmap(const QPixmap &p);
void reset();
@ -46,7 +48,7 @@ protected:
last_button = e->button();
QMouseEvent me ( e->type(), e->pos(), e->globalPos(),
LeftButton, e->state() );
QButton::mousePressEvent( &me );
KWinButton::mousePressEvent( &me );
}
void mouseReleaseEvent( QMouseEvent* e )
@ -54,7 +56,7 @@ protected:
last_button = e->button();
QMouseEvent me ( e->type(), e->pos(), e->globalPos(),
LeftButton, e->state() );
QButton::mouseReleaseEvent( &me );
KWinButton::mouseReleaseEvent( &me );
}
virtual void drawButton(QPainter *p);
@ -62,9 +64,9 @@ protected:
QBitmap deco;
QPixmap pix;
Client* client;
bool menuBtn;
bool miniBtn;
Client* client;
};

304
kwinbutton.cpp Normal file
View file

@ -0,0 +1,304 @@
/*
* $Id$
*
* KWin client button tooltip support module
*
* Copyright (c) 2001
* Karol Szwed <gallium@kde.org>
*
* Uses portions of QToolTip code
* Copyright (c) TrollTech AS
*
* Since Qt installs its own internal event filter when using
* a QToolTip, kwin doesn't obtain the necessary events and hence
* focus problems and loss of window frames occur if they are used
* for kwin styles. Thus, this small class implements a bare subset
* of QToolTip designed especially for kwin client buttons without
* installing any event filters that confuse kwin.
*
* For all normal clients, simply use the KWinButton class instead
* of QButton, which will use a KWinToolTip internally. Other clients
* which rely on QToolButton or QWidget for client buttons may use the
* KWinToolButton and KWinWidgetButton classes to automatically take
* care of tooltips.
*
*/
#include <qpoint.h>
#include "kwinbutton.h"
#include "options.h"
#include "workspace.h"
// This is a hack to ensure that we use Qt fade and scroll effects
#warning: Using extracts from qeffects_p.h for kwinbutton tooltip fade and scroll effects
// This code is copied directly from qeffects_p.h
struct QEffects
{
enum Direction {
LeftScroll = 0x0001,
RightScroll = 0x0002,
UpScroll = 0x0004,
DownScroll = 0x0008
};
typedef uint DirFlags;
};
extern void Q_EXPORT qScrollEffect( QWidget*,
QEffects::DirFlags dir = QEffects::DownScroll, int time = -1 );
extern void Q_EXPORT qFadeEffect( QWidget*, int time = -1 );
// end qeffects_p.h code
using namespace KWinInternal;
KWinToolTip::KWinToolTip( QWidget* parent, const QString& tip )
: QLabel( NULL, "KWinToolTip", WStyle_StaysOnTop +
WStyle_Customize + WStyle_NoBorder + WStyle_Tool )
{
setMargin(1);
setIndent(0);
setFrameStyle( QFrame::Plain | QFrame::Box );
setLineWidth(1);
setAlignment( AlignLeft | AlignTop );
setText(tip);
adjustSize();
// Use stock Qt tooltip colors as defined in qapplication.cpp
QColorGroup clrGroup( Qt::black, QColor(255,255,220),
QColor(96,96,96), Qt::black, Qt::black,
Qt::black, QColor(255,255,220) );
setPalette( QPalette( clrGroup, clrGroup, clrGroup ) );
btn = parent;
connect(&hideTimer, SIGNAL(timeout()), SLOT(hideTip()));
connect(&showTimer, SIGNAL(timeout()), SLOT(showTip()));
}
KWinToolTip::~KWinToolTip()
{
}
void KWinToolTip::setTipText( const QString& tip )
{
bool visible = isVisible();
if (visible)
hide();
setText(tip);
adjustSize();
positionTip();
if (visible)
showTip();
}
void KWinToolTip::enterTip()
{
// Show after 1 second
showTimer.start( 1000, TRUE );
}
void KWinToolTip::leaveTip()
{
if (hideTimer.isActive())
hideTimer.stop();
if (showTimer.isActive())
showTimer.stop();
if (isVisible())
hide();
}
/* Internal */
void KWinToolTip::showTip()
{
if (isVisible())
return;
// Ignore empty tooltips
if (text().isEmpty())
return;
positionTip();
// Display the tooltip the Qt way
if (QApplication::isEffectEnabled(UI_AnimateTooltip) == FALSE)
show();
else if (QApplication::isEffectEnabled(UI_FadeTooltip))
qFadeEffect(this);
else
qScrollEffect(this);
raise();
// Hide after 10 seconds
hideTimer.start( 10000, TRUE );
}
/* Internal */
void KWinToolTip::hideTip()
{
if (isVisible())
hide();
}
/* Internal */
void KWinToolTip::positionTip()
{
QPoint p = btn->mapToGlobal(btn->rect().bottomLeft()) + QPoint(0, 16);
// Ensure the tooltip is displayed within the current desktop
if ( p.x() + width() > Workspace::self()->desktopWidget()->width() )
p.setX( Workspace::self()->desktopWidget()->width() - width());
if ( p.y() + height() > Workspace::self()->desktopWidget()->height() )
p.setY( Workspace::self()->desktopWidget()->height() - height() );
if (p.x() < 0) p.setX(0);
if (p.y() < 0) p.setY(0);
move(p);
// Ensure we don't get enter/leave event race conditions when a
// tooltip is over a button.
QRect btnGlobalRect( btn->mapToGlobal(btn->rect().topLeft()),
btn->mapToGlobal(btn->rect().bottomRight()) );
QRect tipGlobalRect( mapToGlobal(rect().topLeft()),
mapToGlobal(rect().bottomRight()) );
if (btnGlobalRect.intersects( tipGlobalRect ))
{
// Only intersects when button is at lower part of screen
p.setY( btn->mapToGlobal(btn->rect().topLeft()).y() - height() - 5 );
move(p);
}
}
// KWinButton class
KWinButton::KWinButton(QWidget *parent, const char *name, const QString& tip)
: QButton(parent, name, WStyle_Customize | WRepaintNoErase |
WResizeNoErase | WStyle_NoBorder )
{
buttonTip = options->showToolTips() ? new KWinToolTip(this, tip) : NULL;
}
KWinButton::~KWinButton()
{
if (buttonTip)
delete buttonTip;
}
void KWinButton::setTipText(const QString& newTip)
{
if (buttonTip)
buttonTip->setTipText( newTip );
}
void KWinButton::enterEvent(QEvent *e)
{
if (buttonTip)
buttonTip->enterTip();
QButton::enterEvent( e );
}
void KWinButton::leaveEvent(QEvent *e)
{
if (buttonTip)
buttonTip->leaveTip();
QButton::leaveEvent( e );
}
void KWinButton::mousePressEvent(QMouseEvent* e)
{
// Hide tooltips if a button is pressed
if (buttonTip)
buttonTip->leaveTip();
QButton::mousePressEvent( e );
}
// KWinToolButton class
KWinToolButton::KWinToolButton(QWidget *parent, const char *name, const QString& tip)
: QToolButton(parent, name)
{
buttonTip = options->showToolTips() ? new KWinToolTip(this, tip) : NULL;
}
KWinToolButton::~KWinToolButton()
{
if (buttonTip)
delete buttonTip;
}
void KWinToolButton::setTipText(const QString& newTip)
{
if (buttonTip)
buttonTip->setTipText( newTip );
}
void KWinToolButton::enterEvent(QEvent *e)
{
if (buttonTip)
buttonTip->enterTip();
QToolButton::enterEvent( e );
}
void KWinToolButton::leaveEvent(QEvent *e)
{
if (buttonTip)
buttonTip->leaveTip();
QToolButton::leaveEvent( e );
}
void KWinToolButton::mousePressEvent(QMouseEvent* e)
{
// Hide tooltips if a button is pressed
if (buttonTip)
buttonTip->leaveTip();
QToolButton::mousePressEvent( e );
}
// KWinWidgetButton class
KWinWidgetButton::KWinWidgetButton(QWidget *parent, const char *name,
WFlags f, const QString& tip)
: QWidget(parent, name, f)
{
buttonTip = options->showToolTips() ? new KWinToolTip(this, tip) : NULL;
}
KWinWidgetButton::~KWinWidgetButton()
{
if (buttonTip)
delete buttonTip;
}
void KWinWidgetButton::setTipText(const QString& newTip)
{
if (buttonTip)
buttonTip->setTipText( newTip );
}
void KWinWidgetButton::enterEvent(QEvent *e)
{
if (buttonTip)
buttonTip->enterTip();
QWidget::enterEvent( e );
}
void KWinWidgetButton::leaveEvent(QEvent *e)
{
if (buttonTip)
buttonTip->leaveTip();
QWidget::leaveEvent( e );
}
void KWinWidgetButton::mousePressEvent(QMouseEvent* e)
{
// Hide tooltips if a button is pressed
if (buttonTip)
buttonTip->leaveTip();
QWidget::mousePressEvent( e );
}
#include "kwinbutton.moc"
// vim: ts=4

118
kwinbutton.h Normal file
View file

@ -0,0 +1,118 @@
/*
* $Id$
*
* KWin client button tooltip support module
*
* Copyright (c) 2001
* Karol Szwed <gallium@kde.org>
*
* Uses portions of QToolTip code
* Copyright (c) TrollTech AS
*
* Since Qt installs its own internal event filter when using
* a QToolTip, kwin doesn't obtain the necessary events and hence
* focus problems and loss of window frames occur if they are used
* for kwin styles. Thus, this small class implements a bare subset
* of QToolTip designed especially for kwin client buttons without
* installing any event filters that confuse kwin.
*
* For all normal clients, simply use the KWinButton class instead
* of QButton, which will use a KWinToolTip internally. Other clients
* which rely on QToolButton or QWidget for client buttons may use the
* KWinToolButton and KWinWidgetButton classes to automatically take
* care of tooltips.
*
*/
#ifndef _KWIN_BUTTON_H
#define _KWIN_BUTTON_H
#include <qlabel.h>
#include <qtimer.h>
#include <qtoolbutton.h>
namespace KWinInternal {
class KWinToolTip: public QLabel
{
Q_OBJECT
public:
KWinToolTip( QWidget* parent, const QString& tip );
~KWinToolTip();
void setTipText( const QString& tip );
void enterTip();
void leaveTip();
private slots:
void showTip();
void hideTip();
private:
void positionTip();
QTimer showTimer;
QTimer hideTimer;
QWidget* btn;
};
class KWinButton: public QButton
{
Q_OBJECT
public:
KWinButton( QWidget *parent, const char *name,
const QString& tip );
~KWinButton();
void setTipText(const QString& newTip);
protected:
/* Ensure you call these event handlers from derived classes */
void enterEvent(QEvent *);
void leaveEvent(QEvent *);
void mousePressEvent( QMouseEvent* e );
private:
KWinToolTip* buttonTip;
};
class KWinToolButton: public QToolButton
{
Q_OBJECT
public:
KWinToolButton( QWidget *parent, const char *name,
const QString& tip );
~KWinToolButton();
void setTipText(const QString& newTip);
protected:
/* Ensure you call these event handlers from derived classes */
void enterEvent(QEvent *);
void leaveEvent(QEvent *);
void mousePressEvent( QMouseEvent* e );
private:
KWinToolTip* buttonTip;
};
class KWinWidgetButton: public QWidget
{
Q_OBJECT
public:
KWinWidgetButton( QWidget *parent, const char *name,
WFlags f, const QString& tip );
~KWinWidgetButton();
void setTipText(const QString& newTip);
protected:
/* Ensure you call these event handlers from derived classes */
void enterEvent(QEvent *);
void leaveEvent(QEvent *);
void mousePressEvent( QMouseEvent* e );
private:
KWinToolTip* buttonTip;
};
};
#endif
// vim: ts=4

View file

@ -26,6 +26,7 @@ public:
QString title_buttons_left;
QString title_buttons_right;
bool custom_button_positions;
bool show_tooltips;
};
};
@ -257,6 +258,9 @@ void Options::reload()
d->title_buttons_right = "HIAX";
}
// button tooltips
d->show_tooltips = config->readBoolEntry("ShowToolTips", true);
emit resetPlugin();
emit resetClients();
}
@ -321,5 +325,10 @@ bool Options::customButtonPositions()
return d->custom_button_positions;
}
bool Options::showToolTips()
{
return d->show_tooltips;
}
#include "options.moc"

View file

@ -288,6 +288,10 @@ public:
*/
QString titleButtonsRight();
/**
* @returns true if the style should use tooltips for window buttons
*/
bool showToolTips();
public slots:
void reload();