예제 #1
0
	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 ();
	}
예제 #2
0
	void UncloseManager::GenericRemoveTab (const RemoveTabParams& params)
	{
		TabRecoverInfo info
		{
			params.RecoverData_,
			GetSessionProps (params.Widget_)
		};

		const auto tab = qobject_cast<ITabWidget*> (params.Widget_);

		const auto rootWM = Proxy_->GetRootWindowsManager ();
		const auto winIdx = rootWM->GetWindowForTab (tab);
		const auto tabIdx = rootWM->GetTabWidget (winIdx)->IndexOf (params.Widget_);
		info.DynProperties_.append ({ "TabSessManager/Position", tabIdx });

		for (const auto& action : UncloseMenu_->actions ())
			if (action->property ("RecData") == params.RecoverData_)
			{
				UncloseMenu_->removeAction (action);
				action->deleteLater ();
				break;
			}

		const auto& fm = UncloseMenu_->fontMetrics ();
		const auto& elided = fm.elidedText (params.TabName_, Qt::ElideMiddle, 300);
		const auto action = new QAction { params.TabIcon_, elided, this };
		action->setProperty ("RecData", params.RecoverData_);

		const auto plugin = tab->ParentMultiTabs ();
		new Util::SlotClosure<Util::DeleteLaterPolicy>
		{
			[uncloser = params.Uncloser_, info, plugin, action, winIdx, this]
			{
				action->deleteLater ();

				if (UncloseMenu_->defaultAction () == action)
					if (const auto nextAct = UncloseMenu_->actions ().value (1))
					{
						UncloseMenu_->setDefaultAction (nextAct);
						nextAct->setShortcut (QString ("Ctrl+Shift+T"));
					}
				UncloseMenu_->removeAction (action);

				const auto propsGuard = TabsPropsMgr_->AppendProps (info.DynProperties_);
				const auto winGuard = TabsPropsMgr_->AppendWindow (winIdx);
				uncloser (plugin, info);
			},
			action,
			SIGNAL (triggered ()),
			action
		};

		if (UncloseMenu_->defaultAction ())
			UncloseMenu_->defaultAction ()->setShortcut (QKeySequence ());
		UncloseMenu_->insertAction (UncloseMenu_->actions ().value (0), action);
		UncloseMenu_->setDefaultAction (action);
		action->setShortcut (QString ("Ctrl+Shift+T"));
	}
예제 #3
0
	void Plugin::handleRemoveTab (QWidget *widget)
	{
		auto tab = qobject_cast<ITabWidget*> (widget);
		if (!tab)
			return;

		auto recTab = qobject_cast<IRecoverableTab*> (widget);
		if (!recTab)
			return;

		const auto& recoverData = recTab->GetTabRecoverData ();
		if (recoverData.isEmpty ())
			return;

		TabUncloseInfo info
		{
			{
				recoverData,
				GetSessionProps (widget)
			},
			qobject_cast<IHaveRecoverableTabs*> (tab->ParentMultiTabs ())
		};

		const auto rootWM = Proxy_->GetRootWindowsManager ();
		const auto winIdx = rootWM->GetWindowForTab (tab);
		const auto tabIdx = rootWM->GetTabWidget (winIdx)->IndexOf (widget);
		info.RecInfo_.DynProperties_.append ({ "TabSessManager/Position", tabIdx });

		const auto pos = std::find_if (UncloseAct2Data_.begin (), UncloseAct2Data_.end (),
				[&info] (const TabUncloseInfo& that) { return that.RecInfo_.Data_ == info.RecInfo_.Data_; });
		if (pos != UncloseAct2Data_.end ())
		{
			auto act = pos.key ();
			UncloseMenu_->removeAction (act);
			UncloseAct2Data_.erase (pos);
			delete act;
		}

		const auto& fm = UncloseMenu_->fontMetrics ();
		const QString& elided = fm.elidedText (recTab->GetTabRecoverName (), Qt::ElideMiddle, 300);
		QAction *action = new QAction (recTab->GetTabRecoverIcon (), elided, this);
		UncloseAct2Data_ [action] = info;

		connect (action,
				SIGNAL (triggered ()),
				this,
				SLOT (handleUnclose ()));

		if (UncloseMenu_->defaultAction ())
			UncloseMenu_->defaultAction ()->setShortcut (QKeySequence ());
		UncloseMenu_->insertAction (UncloseMenu_->actions ().value (0), action);
		UncloseMenu_->setDefaultAction (action);
		action->setShortcut (QString ("Ctrl+Shift+T"));
	}
예제 #4
0
	void UnreadQueueManager::ShowNext ()
	{
		QObject *entryObj = 0;
		while (!Queue_.isEmpty () && !entryObj)
			entryObj = Queue_.takeFirst ();
		if (!entryObj)
			return;

		ICLEntry *entry = qobject_cast<ICLEntry*> (entryObj);
		auto chatWidget = Core::Instance ().GetChatTabsManager ()->OpenChat (entry, true);

		auto rootWM = Core::Instance ().GetProxy ()->GetRootWindowsManager ();
		const auto idx = rootWM->GetWindowForTab (qobject_cast<ITabWidget*> (chatWidget));
		auto mw = rootWM->GetMainWindow (idx);
		if (mw)
		{
			mw->show ();
			mw->raise ();
			mw->activateWindow ();
		}
	}