Add support for above, below and shade buttons.

svn path=/trunk/kdebase/kwin/; revision=331725
This commit is contained in:
Luboš Luňák 2004-07-22 11:23:28 +00:00
parent 5f2d4c57de
commit 0c4afbf8be
2 changed files with 148 additions and 4 deletions

View file

@ -111,6 +111,47 @@ namespace Keramik
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00}; 0x00, 0x00, 0x00};
const unsigned char above_on_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0xf0, 0x0f, 0x00,
0x80, 0x01, 0x00, 0xe0, 0x07, 0x00, 0xc0, 0x03, 0x00, 0x80, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00 };
const unsigned char above_off_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0xc0, 0x03, 0x00,
0xe0, 0x07, 0x00, 0x80, 0x01, 0x00, 0xf0, 0x0f, 0x00, 0xf0, 0x0f, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00 };
const unsigned char below_on_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0xc0, 0x03, 0x00,
0xe0, 0x07, 0x00, 0x80, 0x01, 0x00, 0xf0, 0x0f, 0x00, 0xf0, 0x0f, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00 };
const unsigned char below_off_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0xf0, 0x0f, 0x00,
0x80, 0x01, 0x00, 0xe0, 0x07, 0x00, 0xc0, 0x03, 0x00, 0x80, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00 };
const unsigned char shade_on_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0xf0, 0x0f, 0x00,
0x10, 0x08, 0x00, 0x10, 0x08, 0x00, 0x10, 0x08, 0x00, 0x10, 0x08, 0x00,
0x10, 0x08, 0x00, 0x10, 0x08, 0x00, 0x10, 0x08, 0x00, 0xf0, 0x0f, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00 };
const unsigned char shade_off_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0xf0, 0x0f, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00 };
KeramikHandler *clientHandler = NULL; KeramikHandler *clientHandler = NULL;
bool keramik_initialized = false; bool keramik_initialized = false;
@ -141,6 +182,12 @@ KeramikHandler::KeramikHandler()
buttonDecos[ Maximize ] = new QBitmap( 17, 17, maximize_bits, true ); buttonDecos[ Maximize ] = new QBitmap( 17, 17, maximize_bits, true );
buttonDecos[ Restore ] = new QBitmap( 17, 17, restore_bits, true ); buttonDecos[ Restore ] = new QBitmap( 17, 17, restore_bits, true );
buttonDecos[ Close ] = new QBitmap( 17, 17, close_bits, true ); buttonDecos[ Close ] = new QBitmap( 17, 17, close_bits, true );
buttonDecos[ AboveOn ] = new QBitmap( 17, 17, above_on_bits, true );
buttonDecos[ AboveOff ] = new QBitmap( 17, 17, above_off_bits, true );
buttonDecos[ BelowOn ] = new QBitmap( 17, 17, below_on_bits, true );
buttonDecos[ BelowOff ] = new QBitmap( 17, 17, below_off_bits, true );
buttonDecos[ ShadeOn ] = new QBitmap( 17, 17, shade_on_bits, true );
buttonDecos[ ShadeOff ] = new QBitmap( 17, 17, shade_off_bits, true );
// Selfmask the bitmaps // Selfmask the bitmaps
for ( int i = 0; i < NumButtonDecos; i++ ) for ( int i = 0; i < NumButtonDecos; i++ )
@ -776,7 +823,7 @@ void KeramikButton::drawButton( QPainter *p )
break; break;
case OnAllDesktopsButton: case OnAllDesktopsButton:
deco = clientHandler->buttonDeco( isOn() ? NotOnAllDesktops : OnAllDesktops ); deco = clientHandler->buttonDeco( client->isOnAllDesktops() ? NotOnAllDesktops : OnAllDesktops );
break; break;
case HelpButton: case HelpButton:
@ -800,6 +847,18 @@ void KeramikButton::drawButton( QPainter *p )
deco = clientHandler->buttonDeco( Close ); deco = clientHandler->buttonDeco( Close );
break; break;
case AboveButton:
deco = clientHandler->buttonDeco( client->keepAbove() ? AboveOn : AboveOff );
break;
case BelowButton:
deco = clientHandler->buttonDeco( client->keepBelow() ? BelowOn : BelowOff );
break;
case ShadeButton:
deco = clientHandler->buttonDeco( client->isSetShade() ? ShadeOn : ShadeOff );
break;
default: default:
deco = NULL; deco = NULL;
} }
@ -822,6 +881,9 @@ KeramikClient::KeramikClient( KDecorationBridge* bridge, KDecorationFactory* fac
void KeramikClient::init() void KeramikClient::init()
{ {
connect( this, SIGNAL( keepAboveChanged( bool )), SLOT( keepAboveChange( bool )));
connect( this, SIGNAL( keepBelowChanged( bool )), SLOT( keepBelowChange( bool )));
createMainWidget( WStaticContents | WResizeNoErase | WRepaintNoErase ); createMainWidget( WStaticContents | WResizeNoErase | WRepaintNoErase );
widget()->installEventFilter( this ); widget()->installEventFilter( this );
@ -1000,6 +1062,34 @@ void KeramikClient::addButtons( QBoxLayout *layout, const QString &s )
} }
break; break;
// Above button
case 'F' :
if ( !button[AboveButton]) {
button[AboveButton] = new KeramikButton( this, "above", AboveButton, i18n("Keep Above Others") );
connect( button[AboveButton], SIGNAL( clicked() ), SLOT( slotAbove() ) );
layout->addWidget( button[AboveButton] );
}
break;
// Below button
case 'B' :
if ( !button[BelowButton]) {
button[BelowButton] = new KeramikButton( this, "below", BelowButton, i18n("Keep Below Others") );
connect( button[BelowButton], SIGNAL( clicked() ), SLOT( slotBelow() ) );
layout->addWidget( button[BelowButton] );
}
break;
// Shade button
case 'L' :
if ( !button[ShadeButton] && isShadeable() ) {
button[ShadeButton] = new KeramikButton( this, "shade", ShadeButton,
isSetShade() ? i18n("Unshade") : i18n( "Shade" ));
connect( button[ShadeButton], SIGNAL( clicked() ), SLOT( slotShade() ) );
layout->addWidget( button[ShadeButton] );
}
break;
// Additional spacing // Additional spacing
case '_' : case '_' :
layout->addSpacing( buttonSpacing ); layout->addSpacing( buttonSpacing );
@ -1308,12 +1398,38 @@ void KeramikClient::desktopChange()
{ {
if ( button[ OnAllDesktopsButton ] ) if ( button[ OnAllDesktopsButton ] )
{ {
button[ OnAllDesktopsButton ]->repaint( true );
QToolTip::remove( button[ OnAllDesktopsButton ] ); QToolTip::remove( button[ OnAllDesktopsButton ] );
QToolTip::add( button[ OnAllDesktopsButton ], isOnAllDesktops() ? i18n("Not on all desktops") : i18n("On all desktops") ); QToolTip::add( button[ OnAllDesktopsButton ], isOnAllDesktops() ? i18n("Not on all desktops") : i18n("On all desktops") );
} }
} }
void KeramikClient::shadeChange()
{
if ( button[ ShadeButton ] )
{
button[ ShadeButton ]->repaint( true );
QToolTip::remove( button[ ShadeButton ] );
QToolTip::add( button[ ShadeButton ], isSetShade() ? i18n("Unshade") : i18n("Shade") );
}
}
void KeramikClient::keepAboveChange( bool )
{
if ( button[ AboveButton ] )
button[ AboveButton ]->repaint( true );
}
void KeramikClient::keepBelowChange( bool )
{
if ( button[ BelowButton ] )
button[ BelowButton ]->repaint( true );
}
void KeramikClient::menuButtonPressed() void KeramikClient::menuButtonPressed()
{ {
QPoint menuTop ( button[MenuButton]->rect().topLeft() ); QPoint menuTop ( button[MenuButton]->rect().topLeft() );
@ -1348,6 +1464,27 @@ void KeramikClient::slotMaximize()
} }
void KeramikClient::slotAbove()
{
setKeepAbove( !keepAbove());
button[ AboveButton ]->repaint( true );
}
void KeramikClient::slotBelow()
{
setKeepBelow( !keepBelow());
button[ BelowButton ]->repaint( true );
}
void KeramikClient::slotShade()
{
setShade( !isSetShade());
button[ ShadeButton ]->repaint( true );
}
void KeramikClient::paintEvent( QPaintEvent *e ) void KeramikClient::paintEvent( QPaintEvent *e )
{ {
if ( !keramik_initialized ) if ( !keramik_initialized )

View file

@ -41,10 +41,12 @@ namespace Keramik {
BorderLeft, BorderRight, NumTiles }; BorderLeft, BorderRight, NumTiles };
enum Button { MenuButton=0, OnAllDesktopsButton, HelpButton, MinButton, enum Button { MenuButton=0, OnAllDesktopsButton, HelpButton, MinButton,
MaxButton, CloseButton, NumButtons }; MaxButton, CloseButton, AboveButton, BelowButton, ShadeButton,
NumButtons };
enum ButtonDeco { Menu=0, OnAllDesktops, NotOnAllDesktops, Help, Minimize, Maximize, enum ButtonDeco { Menu=0, OnAllDesktops, NotOnAllDesktops, Help, Minimize, Maximize,
Restore, Close, NumButtonDecos }; Restore, Close, AboveOn, AboveOff, BelowOn, BelowOff, ShadeOn, ShadeOff,
NumButtonDecos };
struct SettingsCache struct SettingsCache
{ {
@ -152,7 +154,7 @@ namespace Keramik {
virtual void captionChange(); virtual void captionChange();
virtual void maximizeChange(); virtual void maximizeChange();
virtual void desktopChange(); virtual void desktopChange();
virtual void shadeChange() {}; virtual void shadeChange();
private: private:
void createLayout(); void createLayout();
@ -175,6 +177,11 @@ namespace Keramik {
private slots: private slots:
void menuButtonPressed(); void menuButtonPressed();
void slotMaximize(); void slotMaximize();
void slotAbove();
void slotBelow();
void slotShade();
void keepAboveChange( bool );
void keepBelowChange( bool );
private: private:
QSpacerItem *topSpacer, *titlebar; QSpacerItem *topSpacer, *titlebar;