Пример #1
0
void TabManager::remove (QWidget *contents)
{
	if (!TabWidget_->WidgetCount ())
		return;

	const int tabNumber = FindTabForWidget (contents);
	if (tabNumber == -1)
		return;
	TabWidget_->RemoveTab (tabNumber);
	OriginalTabNames_.removeAt (tabNumber);
	InvalidateName ();

	ITabWidget *itw = qobject_cast<ITabWidget*> (contents);
	if (!itw)
	{
		qWarning () << Q_FUNC_INFO
				<< contents
				<< "doesn't implement ITabWidget";
		return;
	}
	const auto& features = itw->GetTabClassInfo ().Features_;
	if (features & TFSingle)
		Core::Instance ().GetNewTabMenuManager ()->SingleRemoved (itw);
	if (features & TFByDefault)
		Core::Instance ().GetNewTabMenuManager ()->ToggleHide (itw, true);
}
Пример #2
0
	void SBWidget::RemoveCurTabAction (QAction *act, QWidget *w)
	{
		ITabWidget *tw = qobject_cast<ITabWidget*> (w);
		const auto& tabClass = tw->GetTabClassInfo ();
		TabClass2Action_ [tabClass.TabClass_].removeAll (act);
		TabAction2Tab_.remove (act);

		delete CurTab2Button_.take (act);

		if (TabClass2Action_ [tabClass.TabClass_].size () < FoldThreshold)
			UnfoldTabClass (tabClass);
	}
Пример #3
0
void TabManager::add (const QString& name, QWidget *contents,
		QIcon icon)
{
	if (icon.isNull ())
	{
		ITabWidget *itw = qobject_cast<ITabWidget*> (contents);
		if (!itw)
		{
			qWarning () << Q_FUNC_INFO
					<< contents
					<< "doesn't implement ITabWidget";
			return;
		}
		icon = itw->GetTabClassInfo ().Icon_;

		if (itw->GetTabClassInfo ().Features_ & TFSingle)
			Core::Instance ().GetNewTabMenuManager ()->HideAction (itw);
	}

	if (XmlSettingsManager::Instance ()->
			property ("OpenTabNext").toBool ())
	{
		const int current = TabWidget_->CurrentIndex ();
		OriginalTabNames_.insert (current + 1, name);
		TabWidget_->InsertTab (current + 1,
				contents,
				icon,
				name);
	}
	else
	{
		OriginalTabNames_ << name;
		TabWidget_->AddTab (contents, icon, name);
	}
	InvalidateName ();
}
Пример #4
0
	void SBWidget::AddCurTabAction (QAction *act, QWidget *w)
	{
		ITabWidget *tw = qobject_cast<ITabWidget*> (w);
		const auto& tabClass = tw->GetTabClassInfo ();
		TabClass2Action_ [tabClass.TabClass_] << act;
		TabAction2Tab_ [act] = w;

		if (TabClass2Action_ [tabClass.TabClass_].size () >= FoldThreshold)
			FoldTabClass (tabClass, act);
		else
		{
			auto but = AddTabButton (act, Ui_.TabsLay_);
			CurTab2Button_ [act] = but;
			but->setProperty ("Sidebar/TabPage", QVariant::fromValue<QWidget*> (w));
			but->setContextMenuPolicy (Qt::CustomContextMenu);
			connect (but,
					SIGNAL (customContextMenuRequested (QPoint)),
					this,
					SLOT (handleTabContextMenu (QPoint)));
		}
	}