diff --git a/clients/plastik/Makefile.am b/clients/plastik/Makefile.am index c5a2b0cf9d..a18fcd0705 100644 --- a/clients/plastik/Makefile.am +++ b/clients/plastik/Makefile.am @@ -9,7 +9,7 @@ INCLUDES = $(all_includes) kwindir = $(kde_datadir)/kwin/ kwin_DATA = plastik.desktop -noinst_HEADERS = plastik.h plastikclient.h plastikbutton.h misc.h shadow.h xpm/empty.xpm xpm/close.xpm xpm/help.xpm xpm/maximize.xpm xpm/restore.xpm xpm/minimize.xpm xpm/sticky.xpm xpm/unsticky.xpm +noinst_HEADERS = plastik.h plastikclient.h plastikbutton.h misc.h shadow.h xpm/empty.xpm xpm/close.xpm xpm/help.xpm xpm/maximize.xpm xpm/restore.xpm xpm/minimize.xpm xpm/sticky.xpm xpm/unsticky.xpm xpm/shade.xpm xpm/unshade.xpm xpm/keepabove.xpm xpm/notkeepabove.xpm xpm/keepbelow.xpm xpm/notkeepbelow.xpm kde_module_LTLIBRARIES = kwin3_plastik.la kwin3_plastik_la_SOURCES = plastik.cpp plastikclient.cpp plastikbutton.cpp misc.cpp shadow.cpp diff --git a/clients/plastik/plastik.h b/clients/plastik/plastik.h index da2c689e79..7e8567878c 100644 --- a/clients/plastik/plastik.h +++ b/clients/plastik/plastik.h @@ -37,6 +37,9 @@ enum ButtonType { CloseButton, MenuButton, OnAllDesktopsButton, + AboveButton, + BelowButton, + ShadeButton, NumButtons }; diff --git a/clients/plastik/plastikbutton.cpp b/clients/plastik/plastikbutton.cpp index bd12e5684b..ec719ecc94 100644 --- a/clients/plastik/plastikbutton.cpp +++ b/clients/plastik/plastikbutton.cpp @@ -39,6 +39,12 @@ #include "xpm/help.xpm" #include "xpm/sticky.xpm" #include "xpm/unsticky.xpm" +#include "xpm/shade.xpm" +#include "xpm/unshade.xpm" +#include "xpm/keepabove.xpm" +#include "xpm/notkeepabove.xpm" +#include "xpm/keepbelow.xpm" +#include "xpm/notkeepbelow.xpm" #include "xpm/empty.xpm" #include "plastikbutton.h" @@ -54,7 +60,8 @@ static const uint TIMERINTERVAL = 50; // msec static const uint ANIMATIONSTEPS = 4; PlastikButton::PlastikButton(PlastikClient *parent, const char *name, - const QString& tip, ButtonType type, int size, int btns) + const QString& tip, ButtonType type, + int size, bool toggle, int btns) : QButton(parent->widget(), name), m_client(parent), m_lastMouse(0), @@ -63,15 +70,15 @@ PlastikButton::PlastikButton(PlastikClient *parent, const char *name, m_type(type), m_aDecoLight(QImage() ), m_iDecoLight(QImage() ), m_aDecoDark(QImage() ), m_iDecoDark(QImage() ), - hover(false), - isOnAllDesktops(false), - isMaximized(false) + hover(false) { QToolTip::add( this, tip ); setCursor(ArrowCursor); setBackgroundMode(NoBackground); + setToggleButton(toggle); + if(m_size < 10) { m_size = 10; } setFixedSize(m_size, m_size); @@ -100,6 +107,12 @@ void PlastikButton::setSize(int s) setDeco(); } +void PlastikButton::setOn(bool on) +{ + QButton::setOn(on); + setDeco(); +} + void PlastikButton::setDeco() { QColor aDecoFgDark = alphaBlendColors(PlastikHandler::getColor(TitleGradientTo, true), @@ -134,19 +147,40 @@ void PlastikButton::setDeco() img = QImage(minimize_xpm); break; case MaxButton: - if (isMaximized) { + if (isOn()) { img = QImage(restore_xpm); } else { img = QImage(maximize_xpm); } break; case OnAllDesktopsButton: - if (isOnAllDesktops) { + if (isOn()) { img = QImage(unsticky_xpm); } else { img = QImage(sticky_xpm); } break; + case ShadeButton: + if (isOn()) { + img = QImage(unshade_xpm); + } else { + img = QImage(shade_xpm); + } + break; + case AboveButton: + if (isOn()) { + img = QImage(notkeepabove_xpm); + } else { + img = QImage(keepabove_xpm); + } + break; + case BelowButton: + if (isOn()) { + img = QImage(notkeepbelow_xpm); + } else { + img = QImage(keepbelow_xpm); + } + break; default: img = QImage(empty_xpm); break; diff --git a/clients/plastik/plastikbutton.h b/clients/plastik/plastikbutton.h index 236c47c74d..e7d709df55 100644 --- a/clients/plastik/plastikbutton.h +++ b/clients/plastik/plastikbutton.h @@ -37,15 +37,14 @@ class PlastikButton : public QButton { Q_OBJECT public: - PlastikButton(PlastikClient *parent, const char *name, const QString &tip, ButtonType type, int size, int btns = LeftButton); + PlastikButton(PlastikClient *parent, const char *name, const QString &tip, ButtonType type, int size, bool toggle = false, int btns = LeftButton); ~PlastikButton(); - void setOnAllDesktops(bool oad) { isOnAllDesktops = oad; repaint(false); } - void setMaximized(bool maximized) { isMaximized = maximized; repaint(false); } QSize sizeHint() const; ///< Return size hint. int lastMousePress() const { return m_lastMouse; } void reset() { repaint(false); } PlastikClient * client() { return m_client; } + virtual void setOn(bool on); void setDeco(); void setTipText(const QString &tip); void setSize(const int s); @@ -70,7 +69,6 @@ private: ButtonType m_type; QImage m_aDecoLight,m_iDecoLight,m_aDecoDark,m_iDecoDark; bool hover; - bool isOnAllDesktops, isMaximized; QTimer *animTmr; uint animProgress; diff --git a/clients/plastik/plastikclient.cpp b/clients/plastik/plastikclient.cpp index b3cee0643b..9b3cbce614 100644 --- a/clients/plastik/plastikclient.cpp +++ b/clients/plastik/plastikclient.cpp @@ -564,9 +564,10 @@ void PlastikClient::addButtons(QBoxLayout *layout, const QString& s, int buttonS case 'S': // OnAllDesktops button if (!m_button[OnAllDesktopsButton]){ const bool oad = isOnAllDesktops(); - m_button[OnAllDesktopsButton] = new PlastikButton(this, "on_all_desktops", oad?i18n("Not On All Desktops"):i18n("On All Desktops"), OnAllDesktopsButton, buttonSize); - m_button[OnAllDesktopsButton]->setOnAllDesktops( oad ); - m_button[OnAllDesktopsButton]->setDeco(); // update deco... + m_button[OnAllDesktopsButton] = new PlastikButton(this, "on_all_desktops", + oad?i18n("Not On All Desktops"):i18n("On All Desktops"), OnAllDesktopsButton, + buttonSize, true); + m_button[OnAllDesktopsButton]->setOn( oad ); connect(m_button[OnAllDesktopsButton], SIGNAL(clicked()), SLOT(toggleOnAllDesktops())); layout->addWidget(m_button[OnAllDesktopsButton], 0, Qt::AlignHCenter | Qt::AlignTop); } @@ -588,9 +589,10 @@ void PlastikClient::addButtons(QBoxLayout *layout, const QString& s, int buttonS case 'A': // Maximize button if ((!m_button[MaxButton]) && isMaximizable()){ const bool max = maximizeMode()!=MaximizeRestore; - m_button[MaxButton] = new PlastikButton(this, "maximize", max?i18n("Restore"):i18n("Maximize"), MaxButton, buttonSize, LeftButton|MidButton|RightButton); - m_button[MaxButton]->setMaximized( max ); - m_button[MaxButton]->setDeco(); // update deco... + m_button[MaxButton] = new PlastikButton(this, "maximize", + max?i18n("Restore"):i18n("Maximize"), MaxButton, buttonSize, + true, LeftButton|MidButton|RightButton); + m_button[MaxButton]->setOn( max ); connect(m_button[MaxButton], SIGNAL(clicked()), SLOT(slotMaximize())); layout->addWidget(m_button[MaxButton], 0, Qt::AlignHCenter | Qt::AlignTop); } @@ -602,6 +604,36 @@ void PlastikClient::addButtons(QBoxLayout *layout, const QString& s, int buttonS layout->addWidget(m_button[CloseButton], 0, Qt::AlignHCenter | Qt::AlignTop); } break; + case 'F': // AboveButton button + if (!m_button[AboveButton]){ + bool above = keepAbove(); + m_button[AboveButton] = new PlastikButton(this, "above", + above?i18n("Do Not Keep Above Others"):i18n("Keep Above Others"), AboveButton, buttonSize, true); + m_button[AboveButton]->setOn( above ); + connect(m_button[AboveButton], SIGNAL(clicked()), SLOT(slotKeepAbove())); + layout->addWidget(m_button[AboveButton], 0, Qt::AlignHCenter | Qt::AlignTop); + } + break; + case 'B': // BelowButton button + if (!m_button[BelowButton]){ + bool below = keepBelow(); + m_button[BelowButton] = new PlastikButton(this, "below", + below?i18n("Do Not Keep Below Others"):i18n("Keep Below Others"), BelowButton, buttonSize, true); + m_button[BelowButton]->setOn( below ); + connect(m_button[BelowButton], SIGNAL(clicked()), SLOT(slotKeepBelow())); + layout->addWidget(m_button[BelowButton], 0, Qt::AlignHCenter | Qt::AlignTop); + } + break; + case 'L': // Shade button + if ((!m_button[ShadeButton]) && isShadeable()){ + bool shaded = isShade(); + m_button[ShadeButton] = new PlastikButton(this, "shade", + shaded?i18n("Unshade"):i18n("Shade"), ShadeButton, buttonSize, true); + m_button[ShadeButton]->setOn( shaded ); + connect(m_button[ShadeButton], SIGNAL(clicked()), SLOT(slotShade())); + layout->addWidget(m_button[ShadeButton], 0, Qt::AlignHCenter | Qt::AlignTop); + } + break; case '_': // Spacer item layout->addSpacing(3); // add a 3 px spacing... } @@ -730,22 +762,31 @@ void PlastikClient::maximizeChange() if (!PlastikHandler::initialized()) return; if( m_button[MaxButton] ) { - m_button[MaxButton]->setMaximized( maximizeMode()!=MaximizeRestore); + m_button[MaxButton]->setOn( maximizeMode()!=MaximizeRestore); m_button[MaxButton]->setTipText( (maximizeMode()==MaximizeRestore) ? i18n("Maximize") : i18n("Restore")); - m_button[MaxButton]->setDeco(); // update the button icon... } } void PlastikClient::desktopChange() { if ( m_button[OnAllDesktopsButton] ) { - m_button[OnAllDesktopsButton]->setOnAllDesktops( isOnAllDesktops() ); + m_button[OnAllDesktopsButton]->setOn( isOnAllDesktops() ); m_button[OnAllDesktopsButton]->setTipText( isOnAllDesktops() ? i18n("Not On All Desktops") : i18n("On All Desktops")); - m_button[OnAllDesktopsButton]->setDeco(); // update icon/deco + } +} + +void PlastikClient::shadeChange() +{ + if ( m_button[ShadeButton] ) { + bool shaded = isShade(); + m_button[ShadeButton]->setOn( shaded ); + m_button[ShadeButton]->setTipText( shaded ? + i18n("Unshade") + : i18n("Shade")); } } @@ -768,6 +809,45 @@ void PlastikClient::slotMaximize() } } +void PlastikClient::slotShade() +{ + setShade( !isShade() ); +} + +void PlastikClient::slotKeepAbove() +{ + bool above = !keepAbove(); + setKeepAbove( above ); + if (m_button[AboveButton]) + { + m_button[AboveButton]->setOn(above); + m_button[AboveButton]->setTipText( above?i18n("Do Not Keep Above Others"):i18n("Keep Above Others") ); + } + + if (m_button[BelowButton] && m_button[BelowButton]->isOn()) + { + m_button[BelowButton]->setOn(false); + m_button[BelowButton]->setTipText( i18n("Keep Below Others") ); + } +} + +void PlastikClient::slotKeepBelow() +{ + bool below = !keepBelow(); + setKeepBelow( below ); + if (m_button[BelowButton]) + { + m_button[BelowButton]->setOn(below); + m_button[BelowButton]->setTipText( below?i18n("Do Not Keep Below Others"):i18n("Keep Below Others") ); + } + + if (m_button[AboveButton] && m_button[AboveButton]->isOn()) + { + m_button[AboveButton]->setOn(false); + m_button[AboveButton]->setTipText( i18n("Keep Above Others") ); + } +} + void PlastikClient::menuButtonPressed() { static QTime* t = NULL; diff --git a/clients/plastik/plastikclient.h b/clients/plastik/plastikclient.h index f0af52fc10..eb5318444f 100644 --- a/clients/plastik/plastikclient.h +++ b/clients/plastik/plastikclient.h @@ -62,7 +62,7 @@ protected: virtual void maximizeChange(); virtual void desktopChange(); - virtual void shadeChange() {}; + virtual void shadeChange(); virtual void doShape(); virtual void reset( unsigned long changed ); @@ -74,6 +74,9 @@ protected: private slots: void slotMaximize(); + void slotShade(); + void slotKeepAbove(); + void slotKeepBelow(); void menuButtonPressed(); void menuButtonReleased(); bool isTool(); diff --git a/clients/plastik/xpm/keepabove.xpm b/clients/plastik/xpm/keepabove.xpm new file mode 100644 index 0000000000..2a9971e74b --- /dev/null +++ b/clients/plastik/xpm/keepabove.xpm @@ -0,0 +1,37 @@ +/* XPM */ +const char * keepabove_xpm[] = { +"32 32 2 1", +" c None", +". c #0000FF", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" .. ", +" .... ", +" ...... ", +" ........ ", +" .......... ", +" ..... ..... ", +" ..... ..... ", +" ..... ..... ", +" ..... ..... ", +" ..... ..... ", +" ..... ..... ", +" ..... ..... ", +" ..... ..... ", +" ..... ..... ", +" .... .... ", +" .............................. ", +" .............................. ", +" ............................ ", +" .......................... ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/clients/plastik/xpm/keepbelow.xpm b/clients/plastik/xpm/keepbelow.xpm new file mode 100644 index 0000000000..11256d8e27 --- /dev/null +++ b/clients/plastik/xpm/keepbelow.xpm @@ -0,0 +1,37 @@ +/* XPM */ +const char * keepbelow_xpm[] = { +"32 32 2 1", +" c None", +". c #0000FF", +" ", +" ", +" ", +" ", +" ", +" ", +" .......................... ", +" ............................ ", +" .............................. ", +" .............................. ", +" .... .... ", +" ..... ..... ", +" ..... ..... ", +" ..... ..... ", +" ..... ..... ", +" ..... ..... ", +" ..... ..... ", +" ..... ..... ", +" ..... ..... ", +" ..... ..... ", +" .......... ", +" ........ ", +" ...... ", +" .... ", +" .. ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/clients/plastik/xpm/notkeepabove.xpm b/clients/plastik/xpm/notkeepabove.xpm new file mode 100644 index 0000000000..b0af72f2e1 --- /dev/null +++ b/clients/plastik/xpm/notkeepabove.xpm @@ -0,0 +1,37 @@ +/* XPM */ +const char * notkeepabove_xpm[] = { +"32 32 2 1", +" c None", +". c #0000FF", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" .. ", +" .... ", +" ...... ", +" ........ ", +" .......... ", +" ............ ", +" .............. ", +" ................ ", +" .................. ", +" .................... ", +" ...................... ", +" ........................ ", +" .......................... ", +" ............................ ", +" ............................ ", +" .............................. ", +" .............................. ", +" ............................ ", +" .......................... ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/clients/plastik/xpm/notkeepbelow.xpm b/clients/plastik/xpm/notkeepbelow.xpm new file mode 100644 index 0000000000..584c42f2cb --- /dev/null +++ b/clients/plastik/xpm/notkeepbelow.xpm @@ -0,0 +1,37 @@ +/* XPM */ +const char * notkeepbelow_xpm[] = { +"32 32 2 1", +" c None", +". c #0000FF", +" ", +" ", +" ", +" ", +" ", +" ", +" .......................... ", +" ............................ ", +" .............................. ", +" .............................. ", +" ............................ ", +" ............................ ", +" .......................... ", +" ........................ ", +" ...................... ", +" .................... ", +" .................. ", +" ................ ", +" .............. ", +" ............ ", +" .......... ", +" ........ ", +" ...... ", +" .... ", +" .. ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/clients/plastik/xpm/shade.xpm b/clients/plastik/xpm/shade.xpm new file mode 100644 index 0000000000..05acaeb3bb --- /dev/null +++ b/clients/plastik/xpm/shade.xpm @@ -0,0 +1,37 @@ +/* XPM */ +const char * shade_xpm[] = { +"32 32 2 1", +" c None", +". c #0000FF", +" ", +" ............................ ", +" .............................. ", +" .............................. ", +" .............................. ", +" .............................. ", +" .............................. ", +" ... ... ", +" ... ... ", +" ... ... ", +" ... ... ", +" ... ... ", +" .............................. ", +" .............................. ", +" ............................ ", +" ", +" ", +" ", +" ", +" .. ", +" .... ", +" ...... ", +" ........ ", +" .......... ", +" ............ ", +" .............. ", +" ................ ", +" .................. ", +" .................... ", +" ...................... ", +" ........................ ", +" "}; diff --git a/clients/plastik/xpm/unshade.xpm b/clients/plastik/xpm/unshade.xpm new file mode 100644 index 0000000000..abb883a941 --- /dev/null +++ b/clients/plastik/xpm/unshade.xpm @@ -0,0 +1,37 @@ +/* XPM */ +const char * unshade_xpm[] = { +"32 32 2 1", +" c None", +". c #0000FF", +" ", +" ............................ ", +" .............................. ", +" .............................. ", +" .............................. ", +" .............................. ", +" .............................. ", +" ... ... ", +" ... ... ", +" ... ... ", +" ... ... ", +" ... ... ", +" ... ... ", +" ... ... ", +" ... ... ", +" ... .................... ... ", +" ... .................. ... ", +" ... ................ ... ", +" ... .............. ... ", +" ... ............ ... ", +" ... .......... ... ", +" ... ........ ... ", +" ... ...... ... ", +" ... .... ... ", +" ... .. ... ", +" ... ... ", +" ... ... ", +" ... ... ", +" .............................. ", +" .............................. ", +" ............................ ", +" "};