void WMUrgentHandler::Handle (const Entity& e, const NotificationRule&) { if (e.Additional_ ["org.LC.AdvNotifications.EventCategory"].toString () == "org.LC.AdvNotifications.Cancel") return; bool ok = false; auto winIdx = e.Additional_ ["org.LC.AdvNotifications.WindowIndex"].toInt (&ok); auto rootWM = Core::Instance ().GetProxy ()->GetRootWindowsManager (); if (winIdx < 0 || winIdx >= rootWM->GetWindowsCount ()) { qWarning () << Q_FUNC_INFO << "invalid window index" << winIdx << "for notification" << e.Additional_; winIdx = rootWM->GetPreferredWindowIndex (); } auto win = rootWM->GetMainWindow (ok ? winIdx : rootWM->GetPreferredWindowIndex ()); if (!win->isActiveWindow ()) QApplication::alert (win); }
void BuildNotification (Entity& e, ICLEntry *other) { e.Additional_ ["NotificationPixmap"] = QVariant::fromValue<QPixmap> (QPixmap::fromImage (other->GetAvatar ())); e.Additional_ ["org.LC.AdvNotifications.SenderID"] = "org.LeechCraft.Azoth"; e.Additional_ ["org.LC.AdvNotifications.EventCategory"] = AN::CatIM; e.Additional_ ["org.LC.AdvNotifications.EventID"] = "org.LC.Plugins.Azoth.IncomingMessageFrom/" + other->GetEntryID (); e.Additional_ ["org.LC.AdvNotifications.VisualPath"] = QStringList (other->GetEntryName ()); int win = 0; const auto tab = Core::Instance () .GetChatTabsManager ()->GetChatTab (other->GetEntryID ()); const auto rootWM = Core::Instance ().GetProxy ()->GetRootWindowsManager (); if (tab) win = rootWM->GetWindowForTab (tab); if (!tab || win == -1) { const auto& tc = other->GetEntryType () == ICLEntry::ETMUC ? ChatTab::GetMUCTabClassInfo () : ChatTab::GetChatTabClassInfo (); win = rootWM->GetPreferredWindowIndex (tc.TabClass_); } e.Additional_ ["org.LC.AdvNotifications.WindowIndex"] = win; e.Additional_ ["org.LC.Plugins.Azoth.SourceName"] = other->GetEntryName (); e.Additional_ ["org.LC.Plugins.Azoth.SourceID"] = other->GetEntryID (); e.Additional_ ["org.LC.Plugins.Azoth.SourceGroups"] = other->Groups (); }
void Plugin::on_ActionGlance__triggered () { Glance_ = new GlanceShower; auto rootWM = Core::Instance ().GetProxy ()->GetRootWindowsManager (); Glance_->SetTabWidget (rootWM->GetTabWidget (rootWM->GetPreferredWindowIndex ())); connect (Glance_, SIGNAL (finished (bool)), ActionGlance_, SLOT (setEnabled (bool))); ActionGlance_->setEnabled (false); Glance_->Start (); }
void Plugin::handleShowList () { auto rootWM = Proxy_->GetRootWindowsManager (); ICoreTabWidget *tw = rootWM->GetTabWidget (rootWM->GetPreferredWindowIndex ()); if (tw->WidgetCount () < 2) return; QWidget *widget = new QWidget (nullptr, Qt::Popup | Qt::FramelessWindowHint); widget->setAttribute (Qt::WA_TranslucentBackground); widget->setWindowModality (Qt::ApplicationModal); QVBoxLayout *layout = new QVBoxLayout (); layout->setSpacing (1); layout->setContentsMargins (1, 1, 1, 1); const int currentIdx = tw->CurrentIndex (); QToolButton *toFocus = 0; QList<QToolButton*> allButtons; for (int i = 0, count = tw->WidgetCount (); i < count; ++i) { const QString& origText = tw->TabText (i); QString title = QString ("[%1] ").arg (i + 1) + origText; if (title.size () > 100) title = title.left (100) + "..."; QAction *action = new QAction (tw->TabIcon (i), title, this); action->setToolTip (origText); action->setProperty ("TabIndex", i); action->setProperty ("ICTW", QVariant::fromValue<ICoreTabWidget*> (tw)); connect (action, SIGNAL (triggered ()), this, SLOT (navigateToTab ())); connect (action, SIGNAL (triggered ()), widget, SLOT (deleteLater ())); auto button = new QToolButton (); button->setDefaultAction (action); button->setToolButtonStyle (Qt::ToolButtonTextBesideIcon); button->setSizePolicy (QSizePolicy::Expanding, button->sizePolicy ().verticalPolicy ()); button->setProperty ("OrigText", origText); layout->addWidget (button); if (currentIdx == i) toFocus = button; allButtons << button; } widget->installEventFilter (new ListEventFilter (allButtons, this, widget)); widget->setLayout (layout); layout->update (); layout->activate (); const QRect& rect = QApplication::desktop ()-> screenGeometry (rootWM->GetPreferredWindow ()); QPoint pos = rect.center (); const QSize& size = widget->sizeHint () / 2; pos -= QPoint (size.width (), size.height ()); widget->move (pos); widget->show (); if (toFocus) toFocus->setFocus (); }