Пример #1
0
			void KinotifyWidget::mousePressEvent (QMouseEvent *event)
			{
				const QWebHitTestResult& r = page ()->mainFrame ()->hitTestContent (event->pos ());
				if (!r.linkUrl ().isEmpty ())
				{
					QWebView::mousePressEvent (event);
					return;
				}

				QWebElement elem = r.element ();
				if (elem.isNull () || elem.attribute ("type") != "button")
				{
					disconnect (CheckTimer_,
							SIGNAL (timeout ()),
							this,
							SIGNAL (checkNotificationQueue ()));

					disconnect (&Machine_,
							SIGNAL (finished ()),
							this,
							SLOT (closeNotification ()));

					emit checkNotificationQueue ();
					closeNotification ();
				}
				else
					QWebView::mousePressEvent (event);
			}
void KinotifyWidget::mouseReleaseEvent (QMouseEvent *)
{
    disconnect (CheckTimer_,
    SIGNAL (timeout ()),
    this,
    SIGNAL (checkNotificationQueue ()));

    disconnect (&Machine_,
    SIGNAL (finished ()),
    this,
    SLOT (closeNotification()));

    emit checkNotificationQueue ();
    closeNotification ();
}
Пример #3
0
			void Plugin::Handle (LeechCraft::Entity e)
			{
				Priority prio = static_cast<Priority> (e.Additional_ ["Priority"].toInt ());
				if (prio == PLog_)
					return;

				QString header = e.Entity_.toString ();
				QString text = e.Additional_ ["Text"].toString ();

				int timeout = Proxy_->GetSettingsManager ()->
						property ("FinishedDownloadMessageTimeout").toInt () * 1000;

 				KinotifyWidget *notificationWidget =
						new KinotifyWidget (timeout, Proxy_->GetMainWindow ());

				connect (notificationWidget,
						SIGNAL (checkNotificationQueue ()),
						this,
						SLOT (pushNotification ()));

				QString mi = "information";
				switch (prio)
				{
					case PWarning_:
						mi = "warning";
						break;
					case PCritical_:
						mi = "error";
					default:
						break;
				}

				QString path;
				QMap<int, QString> sizes = Proxy_->GetIconPath (mi);
				if (sizes.size ())
				{
					int size = 0;
					if (!sizes.contains (size))
						size = sizes.keys ().last ();
					path = sizes [size];
				}

				notificationWidget->SetContent (header, text, path);

				if (!ActiveNotifications_.size ())
					notificationWidget->PrepareNotification ();

				ActiveNotifications_ << notificationWidget;
			}
KinotifyWidget::KinotifyWidget (int timeout, QWidget *widget, int animationTimout)
: QWebView (widget)
, Timeout_ (timeout)
, AnimationTime_ (animationTimout)
{
    setWindowOpacity (0.0);
    this->setContextMenuPolicy(Qt::NoContextMenu);

    CloseTimer_ = new QTimer (this);
    CheckTimer_ = new QTimer (this);
    CloseTimer_->setSingleShot (true);
    CheckTimer_->setSingleShot (true);

    showStartState = new QState;
    showFinishState = new QState;
    closeStartState = new QState;
    closeFinishState = new QState;
    finalState = new QFinalState;

    QPropertyAnimation *opacityAmination = new QPropertyAnimation (this, "opacity");
    opacityAmination->setDuration (AnimationTime_);

    showStartState->assignProperty (this, "opacity", 0.0);
    showFinishState->assignProperty (this, "opacity", 0.8);
    closeStartState->assignProperty (this, "opacity", 0.8);
    closeFinishState->assignProperty (this, "opacity", 0.0);

    showStartState->addTransition (showFinishState);
    showFinishState->addTransition (this,
    SIGNAL (initiateCloseNotification ()), closeStartState);

    closeStartState->addTransition (closeFinishState);
    closeFinishState->addTransition (closeFinishState,
    SIGNAL (propertiesAssigned ()), finalState);


    Machine_.addState (showStartState);
    Machine_.addState (showFinishState);
    Machine_.addState (closeStartState);
    Machine_.addState (closeFinishState);
    Machine_.addState (finalState);

    Machine_.addDefaultAnimation (opacityAmination);
    Machine_.setInitialState (showStartState);

    connect (&Machine_,
    SIGNAL (finished ()),
    this,
    SLOT (closeNotification ()));

    connect (showFinishState,
    SIGNAL (entered ()),
    this,
    SLOT (stateMachinePause ()));

    connect (CloseTimer_,
    SIGNAL (timeout ()),
    this,
    SIGNAL (initiateCloseNotification ()));

    connect (CheckTimer_,
    SIGNAL (timeout ()),
    this,
    SIGNAL (checkNotificationQueue ()));
}