Пример #1
0
	void Plugin::unPinTab (int index)
	{
		const int windowId = Proxy_->GetRootWindowsManager ()->GetPreferredWindowIndex ();
		auto window = Proxy_->GetRootWindowsManager ()->GetMainWindow (windowId);
		if (!window)
			return;
		auto tw = Proxy_->GetRootWindowsManager ()->GetTabWidget (windowId);
		if (!tw)
			return;

		if (index == -1)
			index = sender ()->property ("Leechcraft/PinTab/CurrentIndex").toInt ();

		if (index < 0 ||
				index >= tw->WidgetCount ())
		{
			qWarning () << Q_FUNC_INFO
					<< "invalid index "
					<< index;
			return;
		}

		int realIndex = tw->TabData (index).toInt ();
		tw->Widget (index)->
				setProperty ("SessionData/org.LeechCraft.PinTab.PinState", false);
		auto data = Window2PinTabsIndex2TabData_ [window].take (realIndex);

		tw->SetTabText (index, data.first);
		tw->SetTabClosable (index, true, data.second);

		tw->MoveTab (index, Window2PinTabsIndex2TabData_.value (window).count ());
	}
Пример #2
0
	void Plugin::pinTab (int index)
	{
		const int windowId = Proxy_->GetRootWindowsManager ()->GetPreferredWindowIndex ();
		auto window = Proxy_->GetRootWindowsManager ()->GetMainWindow (windowId);
		if (!window)
			return;
		auto tw = Proxy_->GetRootWindowsManager ()->GetTabWidget (windowId);
		if (!tw)
			return;

		if (index == -1)
			index = sender ()->property ("Leechcraft/PinTab/CurrentIndex").toInt ();

		if (index < 0 ||
				index >= tw->WidgetCount ())
		{
			qWarning () << Q_FUNC_INFO
					<< "invalid index "
					<< index;
			return;
		}

		tw->Widget (index)->
				setProperty ("SessionData/org.LeechCraft.PinTab.PinState", true);
		++Window2Id_ [window];
		auto pair = qMakePair (tw->TabText (index),
				tw->TabButton (index, CloseSide_));
		tw->SetTabData (index, Window2Id_ [window]);
		tw->SetTabText (index, "");
		tw->SetTabClosable (index, false);
		Window2PinTabsIndex2TabData_ [window] [Window2Id_.value (window, 0)] = pair;

		tw->MoveTab (index, Window2PinTabsIndex2TabData_ [window].count () - 1);
	}
Пример #3
0
	void SeparateTabBar::tabRemoved (int index)
	{
		QTabBar::tabRemoved (index);

		int length = 0;
		for (int i = 0; i < count (); ++i)
			length += tabRect (i).width ();

		if (length + 60 < width () && !IsLastTab_)
		{
			IsLastTab_ = true;

			addTab (QString ());
			SetTabClosable (count () - 1, false);

			emit showAddTabButton (false);
		}

		if (index != count () - 1 && !IsLastTab_)
			emit tabWasRemoved (index);
	}