Esempio n. 1
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"));
	}
Esempio n. 2
0
	void Plugin::hookTabIsRemoving (IHookProxy_ptr, int index, int windowId)
	{
		const auto rootWM = Proxy_->GetRootWindowsManager ();
		const auto tabWidget = rootWM->GetTabWidget (windowId);
		const auto widget = tabWidget->Widget (index);

		handleRemoveTab (widget);
		SessionsMgr_->handleRemoveTab (widget);
	}
Esempio n. 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"));
	}
Esempio n. 4
0
void Plugin::hookTabIsRemoving (IHookProxy_ptr, int index, int windowId)
{
    if (!Mgrs_)
        return;

    const auto rootWM = Proxy_->GetRootWindowsManager ();
    const auto tabWidget = rootWM->GetTabWidget (windowId);
    const auto widget = tabWidget->Widget (index);

    Mgrs_->UncloseMgr_.HandleRemoveTab (widget);
    Mgrs_->SessionsMgr_.handleRemoveTab (widget);
}
Esempio n. 5
0
	void Plugin::hookTabIsRemoving (IHookProxy_ptr, int index, int windowId)
	{
		if (Proxy_->IsShuttingDown ())
			return;

		const auto rootWM = Proxy_->GetRootWindowsManager ();
		const auto tabWidget = rootWM->GetTabWidget (windowId);
		const auto widget = tabWidget->Widget (index);

		UncloseMgr_->HandleRemoveTab (widget);
		SessionsMgr_->handleRemoveTab (widget);
	}
Esempio n. 6
0
Uint32 cUITab::OnMouseClick( const eeVector2i &Pos, const Uint32 Flags ) {
    cUISelectButton::OnMouseClick( Pos, Flags );

    cUITabWidget * tTabW = GetTabWidget();

    if ( NULL != tTabW ) {
        if ( Flags & EE_BUTTON_LMASK ) {
            tTabW->SetTabSelected( this );
        }
    }

    return 1;
}
Esempio n. 7
0
void cUITab::SetRealSize() {
    if ( mFlags & UI_AUTO_SIZE ) {
        Uint32 w = mTextBox->GetTextWidth() + GetSkinSize().Width();

        cUITabWidget * tTabW = GetTabWidget();

        if ( NULL != tTabW ) {
            w = eemax( w, tTabW->mMinTabWidth );
            w = eemin( w, tTabW->mMaxTabWidth );
        }

        Size( w, mSize.Height() );
    }
}
Esempio n. 8
0
	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 ();
	}
Esempio n. 9
0
void cUITab::Text( const String &text ) {
    cUITabWidget * tTabW = GetTabWidget();

    if ( NULL != tTabW ) {
        if ( text.size() > tTabW->mMaxTextLength ) {
            cUIPushButton::Text( text.substr( 0, tTabW->mMaxTextLength ) );

            SetRealSize();

            return;
        }
    }

    cUIPushButton::Text( text );

    SetRealSize();
}
Esempio n. 10
0
void cUITab::OnStateChange() {
    cUISelectButton::OnStateChange();

    cUITabWidget * tTabW = GetTabWidget();

    if ( NULL != tTabW ) {
        Size( mSize.Width(), GetSkinSize( GetSkin(), mSkinState->GetState() ).Height() );

        if ( mSkinState->GetState() == cUISkinState::StateSelected ) {
            mTextBox->Color( tTabW->mFontSelectedColor );
        } else if ( mSkinState->GetState() == cUISkinState::StateMouseEnter ) {
            mTextBox->Color( tTabW->mFontOverColor );
        } else {
            mTextBox->Color( tTabW->mFontColor );
        }
    }
}
Esempio n. 11
0
void cUITab::SetTheme( cUITheme * Theme ) {
    std::string tabPos = "tab";

    cUITabWidget * tTabW = GetTabWidget();

    if ( NULL != tTabW ) {
        if ( tTabW->mSpecialBorderTabs ) {
            if ( 0 == tTabW->GetTabIndex( this ) ) {
                tabPos = "tab_left";
            } else if ( tTabW->Count() > 0 && ( tTabW->Count() - 1 ) == tTabW->GetTabIndex( this ) ) {
                tabPos = "tab_right";
            }
        }
    }

    cUIControl::SetThemeControl( Theme, tabPos );

    DoAfterSetTheme();
}
Esempio n. 12
0
	void Plugin::handleWindow (int index, bool init)
	{
		auto rootWM = Proxy_->GetRootWindowsManager ();
		auto win = rootWM->GetMainWindow (index);

		auto mgr = new ViewManager (Proxy_, ShortcutMgr_, win, this);
		auto view = mgr->GetView ();

		auto mwProxy = rootWM->GetMWProxy (index);
		auto ictw = rootWM->GetTabWidget (index);

		win->statusBar ()->hide ();

		mgr->RegisterInternalComponent ((new LCMenuComponent (mwProxy))->GetComponent ());

		auto launcher = new LauncherComponent (ictw, Proxy_, mgr);
		mgr->RegisterInternalComponent (launcher->GetComponent ());
		if (init)
			connect (this,
					SIGNAL (pluginsAvailable ()),
					launcher,
					SLOT (handlePluginsAvailable ()));
		else
			launcher->handlePluginsAvailable ();

		auto tray = new TrayComponent (Proxy_, view);
		mgr->RegisterInternalComponent (tray->GetComponent ());
		if (init)
			connect (this,
					SIGNAL (pluginsAvailable ()),
					tray,
					SLOT (handlePluginsAvailable ()));
		else
			tray->handlePluginsAvailable ();

		auto dock = new DockActionComponent (Proxy_, view);
		mgr->RegisterInternalComponent (dock->GetComponent ());

		if (!init)
			mgr->SecondInit ();

		Managers_.push_back ({ mgr, tray, dock });
	}
Esempio n. 13
0
void cUITab::Update() {
    cUISelectButton::Update();

    if ( mEnabled && mVisible ) {
        if ( IsMouseOver() ) {
            cUITabWidget * tTabW	= GetTabWidget();

            if ( NULL != tTabW ) {
                Uint32 Flags 			= cUIManager::instance()->GetInput()->ClickTrigger();

                if ( Flags & EE_BUTTONS_WUWD ) {
                    if ( Flags & EE_BUTTON_WUMASK ) {
                        tTabW->SelectPrev();
                    } else if ( Flags & EE_BUTTON_WDMASK ) {
                        tTabW->SelectNext();
                    }
                } else if ( tTabW->mTabsClosable && ( Flags & EE_BUTTON_MMASK ) ) {
                    tTabW->Remove( this );
                }
            }
        }
    }
}
Esempio n. 14
0
	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 ();
	}