From 4325f1414f99f44c0844ddd91f69e75b3c0811f3 Mon Sep 17 00:00:00 2001 From: ketmar Date: Sun, 14 Oct 2012 17:43:33 +0300 Subject: [PATCH] no more popup fading (got rid of it) --- src/k8popups/k8popups.cpp | 27 +++++++++++++++++++++++---- src/k8popups/k8popups.h | 9 ++++++++- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/k8popups/k8popups.cpp b/src/k8popups/k8popups.cpp index 7135d70..51f250d 100644 --- a/src/k8popups/k8popups.cpp +++ b/src/k8popups/k8popups.cpp @@ -63,6 +63,7 @@ QSize K8PopupLayout::sizeHint () const { /////////////////////////////////////////////////////////////////////////////// +#ifdef FADING K8PopupFader::K8PopupFader (QWidget *parent, bool aIn) : QWidget(parent), mPParent(parent), mIn(aIn) { mStartColor = parent ? parent->palette().window().color() : Qt::white; mCurrentAlpha = 0; @@ -104,6 +105,7 @@ void K8PopupFader::paintEvent (QPaintEvent * /*event*/) { close(); } } +#endif /////////////////////////////////////////////////////////////////////////////// @@ -111,8 +113,11 @@ K8PopupWin::K8PopupWin (K8PopupManager *aMan, int aWidth, int aHeight, K8PopupTy const QString &aId, const QString &msg, QWidget *parent) : QWidget(parent), mMan(aMan), mType(aType), mShouldClose(false), mMouseInside(false), mShowTime(0), - mId(aId), - mFaderIn(0), mFaderOut(0), mFadingOut(false), mMaskSet(false) + mId(aId) +#ifdef FADING + , mFaderIn(0), mFaderOut(0), mFadingOut(false) +#endif + //mMaskSet(false) { initUI(aWidth, aHeight); setData(msg); @@ -124,6 +129,7 @@ K8PopupWin::~K8PopupWin () { } +#ifdef FADING void K8PopupWin::onFaderInDies (QObject * /*obj*/) { mFaderIn = 0; } @@ -133,6 +139,7 @@ void K8PopupWin::onFaderOutDies (QObject * /*obj*/) { mFaderOut = 0; if (mFadingOut) close(); } +#endif void K8PopupWin::initUI (int width, int height) { @@ -205,7 +212,7 @@ void K8PopupWin::leaveEvent (QEvent *event) { void K8PopupWin::buildAndSetMask (QWidget *w) { - qDebug() << "size:" << size(); + //qDebug() << "size:" << size(); QPixmap pixmap(size()); pixmap.fill(Qt::transparent); render(&pixmap, QPoint(), QRegion(), QWidget::DrawChildren | QWidget::IgnoreMask); @@ -230,30 +237,37 @@ void K8PopupWin::rebuildMask () { QWidget::hide(); QWidget::show(); } - mMaskSet = true; + //mMaskSet = true; } void K8PopupWin::show () { +#ifdef FADING if (mFadingOut) return; +#endif // cut edges (if any) rebuildMask(); // +#ifdef FADING if (!mFaderIn) { mFaderIn = new K8PopupFader(this, false); connect(mFaderIn, SIGNAL(destroyed(QObject *)), this, SLOT(onFaderInDies(QObject *))); mFaderIn->setFadeColor(Qt::white); mFaderIn->start(); } +#endif QWidget::show(); +#ifdef FADING if (mFaderIn) { mFaderIn->resize(size()); buildAndSetMask(mFaderIn); } +#endif } void K8PopupWin::getOut () { +#ifdef FADING if (mFadingOut) return; if (mFaderIn) mFaderIn->close(); if (!mFaderOut) { @@ -264,6 +278,9 @@ void K8PopupWin::getOut () { mFaderOut->start(); } mFadingOut = true; +#else + close(); +#endif } @@ -462,7 +479,9 @@ void K8PopupManager::rearrange () { void K8PopupManager::emitClick (K8PopupWin *w, Qt::MouseButton button) { if (!w || !w->mMan) return; if (!w->mType) return; +#ifdef FADING if (w->mFadingOut) return; +#endif emit click(w->mType->name, w->mId, button); w->getOut(); } diff --git a/src/k8popups/k8popups.h b/src/k8popups/k8popups.h index 8c1b26c..977e8c7 100644 --- a/src/k8popups/k8popups.h +++ b/src/k8popups/k8popups.h @@ -49,6 +49,7 @@ public: /////////////////////////////////////////////////////////////////////////////// +#ifdef FADING class K8PopupFader : public QWidget { Q_OBJECT @@ -74,6 +75,7 @@ private: int mDuration; bool mIn; }; +#endif /////////////////////////////////////////////////////////////////////////////// @@ -102,9 +104,11 @@ private: void buildAndSetMask (QWidget *w); void rebuildMask (); +#ifdef FADING private slots: void onFaderInDies (QObject *obj); void onFaderOutDies (QObject *obj); +#endif private: K8PopupManager *mMan; @@ -119,10 +123,13 @@ private: QVBoxLayout *mLayout; QLabel *mContentLabel; +#ifdef FADING K8PopupFader *mFaderIn; K8PopupFader *mFaderOut; bool mFadingOut; - bool mMaskSet; +#endif + + //bool mMaskSet; }; -- 2.11.4.GIT