Disable Ctrl+Tab (and Ctrl+Shift+Tab) when we are dragging tabs

This commit is contained in:
David Capello 2015-04-17 09:49:49 -03:00
parent 61fa0b454f
commit 39859e9858
5 changed files with 29 additions and 2 deletions

View File

@ -23,7 +23,8 @@ public:
Command* clone() const override { return new GotoNextTabCommand(*this); } Command* clone() const override { return new GotoNextTabCommand(*this); }
protected: protected:
void onExecute(Context* context); bool onEnabled(Context* context) override;
void onExecute(Context* context) override;
}; };
GotoNextTabCommand::GotoNextTabCommand() GotoNextTabCommand::GotoNextTabCommand()
@ -33,6 +34,11 @@ GotoNextTabCommand::GotoNextTabCommand()
{ {
} }
bool GotoNextTabCommand::onEnabled(Context* context)
{
return App::instance()->getMainWindow()->getWorkspace()->canSelectOtherTab();
}
void GotoNextTabCommand::onExecute(Context* context) void GotoNextTabCommand::onExecute(Context* context)
{ {
App::instance()->getMainWindow()->getWorkspace()->selectNextTab(); App::instance()->getMainWindow()->getWorkspace()->selectNextTab();
@ -44,7 +50,8 @@ public:
Command* clone() const override { return new GotoPreviousTabCommand(*this); } Command* clone() const override { return new GotoPreviousTabCommand(*this); }
protected: protected:
void onExecute(Context* context); bool onEnabled(Context* context) override;
void onExecute(Context* context) override;
}; };
GotoPreviousTabCommand::GotoPreviousTabCommand() GotoPreviousTabCommand::GotoPreviousTabCommand()
@ -54,6 +61,11 @@ GotoPreviousTabCommand::GotoPreviousTabCommand()
{ {
} }
bool GotoPreviousTabCommand::onEnabled(Context* context)
{
return App::instance()->getMainWindow()->getWorkspace()->canSelectOtherTab();
}
void GotoPreviousTabCommand::onExecute(Context* context) void GotoPreviousTabCommand::onExecute(Context* context)
{ {
App::instance()->getMainWindow()->getWorkspace()->selectPreviousTab(); App::instance()->getMainWindow()->getWorkspace()->selectPreviousTab();

View File

@ -172,6 +172,12 @@ void Tabs::updateTabs()
invalidate(); invalidate();
} }
// Returns true if the user can select other tab.
bool Tabs::canSelectOtherTab() const
{
return (m_selected && !m_isDragging);
}
void Tabs::selectTab(TabView* tabView) void Tabs::selectTab(TabView* tabView)
{ {
ASSERT(tabView != NULL); ASSERT(tabView != NULL);

View File

@ -126,6 +126,9 @@ namespace app {
void removeTab(TabView* tabView, bool with_animation); void removeTab(TabView* tabView, bool with_animation);
void updateTabs(); void updateTabs();
// Returns true if the user can select other tab.
bool canSelectOtherTab() const;
void selectTab(TabView* tabView); void selectTab(TabView* tabView);
void selectNextTab(); void selectNextTab();
void selectPreviousTab(); void selectPreviousTab();

View File

@ -106,6 +106,11 @@ void Workspace::setMainPanelAsActive()
ActiveViewChanged(); // Fire ActiveViewChanged event ActiveViewChanged(); // Fire ActiveViewChanged event
} }
bool Workspace::canSelectOtherTab() const
{
return m_activePanel->tabs()->canSelectOtherTab();
}
void Workspace::selectNextTab() void Workspace::selectNextTab()
{ {
m_activePanel->tabs()->selectNextTab(); m_activePanel->tabs()->selectNextTab();

View File

@ -41,6 +41,7 @@ namespace app {
WorkspaceView* activeView(); WorkspaceView* activeView();
void setActiveView(WorkspaceView* view); void setActiveView(WorkspaceView* view);
void setMainPanelAsActive(); void setMainPanelAsActive();
bool canSelectOtherTab() const;
void selectNextTab(); void selectNextTab();
void selectPreviousTab(); void selectPreviousTab();
void duplicateActiveView(); void duplicateActiveView();