diff --git a/clients/system/systemclient.cpp b/clients/system/systemclient.cpp index b7edaa323a..097fa60e17 100644 --- a/clients/system/systemclient.cpp +++ b/clients/system/systemclient.cpp @@ -175,10 +175,10 @@ static void create_pixmaps() SystemButton::SystemButton(Client *parent, const char *name, const unsigned char *bitmap) - : QButton(parent, name) + : QToolButton(parent, name) { resize(14, 14); - + connect( this, SIGNAL( clicked() ), this, SLOT( handleClicked() ) ); if(bitmap) setBitmap(bitmap); client = parent; @@ -239,8 +239,29 @@ 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 ); +} + +void SystemButton::mouseReleaseEvent( QMouseEvent* e ) +{ + QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() ); + QToolButton::mouseReleaseEvent( &me ); +} + +void SystemButton::handleClicked() +{ + emit clicked( last_button ); +} + + void SystemClient::slotReset() { if(aUpperGradient){ @@ -264,6 +285,21 @@ void SystemClient::slotReset() button[4]->reset(); } +void SystemClient::maxButtonClicked( int button ) +{ + switch ( button ){ + case MidButton: + maximize( MaximizeVertical ); + break; + case RightButton: + maximize( MaximizeHorizontal ); + break; + default: //LeftButton: + maximize( MaximizeFull ); + break; + } +} + SystemClient::SystemClient( Workspace *ws, WId w, QWidget *parent, const char *name ) : Client( ws, w, parent, name, WResizeNoErase ) @@ -299,7 +335,7 @@ SystemClient::SystemClient( Workspace *ws, WId w, QWidget *parent, connect( button[0], SIGNAL( clicked() ), this, ( SLOT( closeWindow() ) ) ); connect( button[1], SIGNAL( clicked() ), this, ( SLOT( toggleSticky() ) ) ); connect( button[2], SIGNAL( clicked() ), this, ( SLOT( iconify() ) ) ); - connect( button[3], SIGNAL( clicked() ), this, ( SLOT( maximize() ) ) ); + connect( button[3], SIGNAL( clicked(int) ), this, ( SLOT( maxButtonClicked(int) ) ) ); QHBoxLayout* hb = new QHBoxLayout(0); hb->setResizeMode(QLayout::FreeResize); diff --git a/clients/system/systemclient.h b/clients/system/systemclient.h index 4b3fc6277a..4aac90e5f2 100644 --- a/clients/system/systemclient.h +++ b/clients/system/systemclient.h @@ -2,27 +2,42 @@ #define __SYSTEMCLIENT_H #include +#include + #include #include #include "../../client.h" + + class QLabel; class QSpacerItem; - -// get rid of autohide :P -class SystemButton : public QButton +class SystemButton : public QToolButton { + Q_OBJECT public: SystemButton(Client *parent=0, const char *name=0, const unsigned char *bitmap=NULL); void setBitmap(const unsigned char *bitmap); void reset(); QSize sizeHint() const; +signals: + void clicked( int ); protected: virtual void drawButton(QPainter *p); void drawButtonLabel(QPainter *){;} QBitmap deco; Client *client; + + void mousePressEvent( QMouseEvent* e ); + void mouseReleaseEvent( QMouseEvent* e ); + +private slots: + void handleClicked(); + +private: + int last_button; + }; class SystemClient : public Client @@ -47,6 +62,9 @@ protected: void activeChange(bool); protected slots: void slotReset(); +private slots: + void maxButtonClicked( int ); + private: SystemButton* button[5]; QSpacerItem* titlebar; @@ -55,7 +73,4 @@ private: }; - - - #endif