diff --git a/clients/oxygen/oxygenbutton.cpp b/clients/oxygen/oxygenbutton.cpp index 0f89216fae..c75e9e33ea 100644 --- a/clients/oxygen/oxygenbutton.cpp +++ b/clients/oxygen/oxygenbutton.cpp @@ -36,13 +36,9 @@ #include "oxygenbutton.h" #include "oxygen.h" #include "definitions.cpp" -#include "lib/helper.h" namespace Oxygen { -#ifndef KDE_USE_FINAL -K_GLOBAL_STATIC_WITH_ARGS(OxygenHelper, globalHelper, ("OxygenDeco")) -#endif // class OxygenClient; /* extern int BUTTONSIZE; @@ -58,10 +54,11 @@ extern int DECOSIZE;*/ // --------------- // Constructor -OxygenButton::OxygenButton(OxygenClient *parent, +OxygenButton::OxygenButton(OxygenClient &parent, const QString& tip, ButtonType type) - : KCommonDecorationButton((::ButtonType)type,(KCommonDecoration*) parent) + : KCommonDecorationButton((::ButtonType)type, &parent) , client_(parent) + , helper_(parent.helper_) , type_(type) , lastmouse_(0) { @@ -135,12 +132,12 @@ void OxygenButton::paintEvent(QPaintEvent *) // we paint the mini icon (which is 16 pixels high) int dx = (width() - 16) / 2; int dy = (height() - 16) / 2; - painter.drawPixmap(dx, dy, client_->icon().pixmap(16)); + painter.drawPixmap(dx, dy, client_.icon().pixmap(16)); return; } - QColor bg = globalHelper->backgroundTopColor(palette().window()); - painter.drawPixmap(0, 0, globalHelper->windecoButton(palette().button())); + QColor bg = helper_.backgroundTopColor(palette().window()); + painter.drawPixmap(0, 0, helper_.windecoButton(palette().button())); painter.translate(1.5,1.5); painter.setRenderHints(QPainter::Antialiasing); @@ -148,7 +145,7 @@ void OxygenButton::paintEvent(QPaintEvent *) QLinearGradient lg(0, 6, 0, 12); lg.setColorAt(0.45, QColor(0,0,0,150)); lg.setColorAt(0.80, QColor(0,0,0,80)); - painter.setPen(QPen(lg,2)); + painter.setPen(QPen(lg, 2)); switch(type_) { case ButtonSticky: @@ -164,7 +161,7 @@ void OxygenButton::paintEvent(QPaintEvent *) painter.drawLine(9,11,12,8); break; case ButtonMax: - switch(client_->maximizeMode()) + switch(client_.maximizeMode()) { case OxygenClient::MaximizeRestore: case OxygenClient::MaximizeVertical: diff --git a/clients/oxygen/oxygenbutton.h b/clients/oxygen/oxygenbutton.h index 277cf14a54..2c22591334 100644 --- a/clients/oxygen/oxygenbutton.h +++ b/clients/oxygen/oxygenbutton.h @@ -30,6 +30,7 @@ #include #include "oxygen.h" +#include "oxygenclient.h" namespace Oxygen { @@ -45,7 +46,7 @@ Q_DECLARE_FLAGS(ButtonState, ButtonStatus) class OxygenButton : public KCommonDecorationButton { public: - explicit OxygenButton(OxygenClient *parent=0, + explicit OxygenButton(OxygenClient &parent, const QString &tip=NULL, ButtonType type=ButtonHelp); ~OxygenButton(); @@ -63,7 +64,8 @@ private Q_SLOTS: void pressSlot(); private: - OxygenClient *client_; + OxygenClient &client_; + OxygenHelper &helper_; ButtonType type_; ButtonState status_; int lastmouse_; diff --git a/clients/oxygen/oxygenclient.cpp b/clients/oxygen/oxygenclient.cpp index 31be4988a9..0e59a50155 100644 --- a/clients/oxygen/oxygenclient.cpp +++ b/clients/oxygen/oxygenclient.cpp @@ -34,8 +34,6 @@ #include #include -#include "lib/helper.h" - #include "oxygenclient.h" #include "oxygenclient.moc" #include "oxygenbutton.h" @@ -66,7 +64,7 @@ void renderDot(QPainter *p, const QPointF &point, qreal diameter) OxygenClient::OxygenClient(KDecorationBridge *b, KDecorationFactory *f) - : KCommonDecoration(b, f) { ; } + : KCommonDecoration(b, f), helper_(*globalHelper) { ; } OxygenClient::~OxygenClient() { @@ -92,7 +90,7 @@ void OxygenClient::init() widget()->setAutoFillBackground(false); widget()->setAttribute(Qt::WA_OpaquePaintEvent); - widget()->setAttribute( Qt::WA_PaintOnScreen, false); + widget()->setAttribute(Qt::WA_PaintOnScreen, false); } bool OxygenClient::decorationBehaviour(DecorationBehaviour behaviour) const @@ -183,19 +181,19 @@ KCommonDecorationButton *OxygenClient::createButton(::ButtonType type) { switch (type) { case MenuButton: - return new OxygenButton(this, i18n("Menu"), ButtonMenu); + return new OxygenButton(*this, i18n("Menu"), ButtonMenu); case HelpButton: - return new OxygenButton(this, i18n("Help"), ButtonHelp); + return new OxygenButton(*this, i18n("Help"), ButtonHelp); case MinButton: - return new OxygenButton(this, i18n("Minimize"), ButtonMin); + return new OxygenButton(*this, i18n("Minimize"), ButtonMin); case MaxButton: - return new OxygenButton(this, i18n("Minimize"), ButtonMax); + return new OxygenButton(*this, i18n("Minimize"), ButtonMax); case CloseButton: - return new OxygenButton(this, i18n("Minimize"), ButtonClose); + return new OxygenButton(*this, i18n("Minimize"), ButtonClose); default: return 0; @@ -241,21 +239,21 @@ void OxygenClient::paintEvent(QPaintEvent *e) int splitY = qMin(300, 3*frame.height()/4); - QPixmap tile = globalHelper->verticalGradient(color, splitY); + QPixmap tile = helper_.verticalGradient(color, splitY); painter.drawTiledPixmap(QRect(0, 0, frame.width(), titleHeight + TFRAMESIZE), tile); painter.drawTiledPixmap(QRect(0, 0, LFRAMESIZE, splitY), tile); - painter.fillRect(0, splitY, LFRAMESIZE, frame.height() - splitY, globalHelper->backgroundBottomColor(color)); + painter.fillRect(0, splitY, LFRAMESIZE, frame.height() - splitY, helper_.backgroundBottomColor(color)); painter.drawTiledPixmap(QRect(frame.width()-RFRAMESIZE, 0, RFRAMESIZE, splitY), tile, QPoint(frame.width()-RFRAMESIZE, 0)); - painter.fillRect(frame.width()-RFRAMESIZE, splitY, RFRAMESIZE, frame.height() - splitY, globalHelper->backgroundBottomColor(color)); + painter.fillRect(frame.width()-RFRAMESIZE, splitY, RFRAMESIZE, frame.height() - splitY, helper_.backgroundBottomColor(color)); - painter.fillRect(0, frame.height() - BFRAMESIZE, frame.width(), BFRAMESIZE, globalHelper->backgroundBottomColor(color)); + painter.fillRect(0, frame.height() - BFRAMESIZE, frame.width(), BFRAMESIZE, helper_.backgroundBottomColor(color)); int radialW = qMin(600, frame.width()); - tile = globalHelper->radialGradient(color, radialW); + tile = helper_.radialGradient(color, radialW); QRect radialRect = QRect((frame.width() - radialW) / 2, 0, radialW, 64); painter.drawPixmap(radialRect, tile); diff --git a/clients/oxygen/oxygenclient.h b/clients/oxygen/oxygenclient.h index 09758b81ed..161e3f2c39 100644 --- a/clients/oxygen/oxygenclient.h +++ b/clients/oxygen/oxygenclient.h @@ -31,7 +31,7 @@ #include -#include "oxygenbutton.h" +#include "lib/helper.h" class QPoint; @@ -56,6 +56,10 @@ public: private: void paintEvent(QPaintEvent *e); void doShape(); + +protected: + friend class OxygenButton; + OxygenHelper &helper_; };