Commit a748069d authored by Meenakshi Khorana's avatar Meenakshi Khorana Committed by Kevin Funk
Browse files

Provide a shortcut for switching split views

Provided a shortcut (key combination as well as on menu option)
for switching between split views. Implemented the same by providing
shortcut (Ctrl + Shift + P for moving to previous split and
Ctrl + Shift + N for moving to next split) along with menu options in
Window drop-down menu

BUG: 273385
REVIEW: 113264
parent 018df5e1
......@@ -122,6 +122,45 @@ void MainWindowPrivate::split(Qt::Orientation orientation)
m_mainWindow->activateView(newView);
}
static void gotoPrevNextSplit(bool next)
{
UiController* ui = Core::self()->uiControllerInternal();
if( !ui->activeSublimeWindow() )
return;
Sublime::Area* area = ui->activeSublimeWindow()->area();
if (!area)
return;
QList<Sublime::View*> topViews = ui->activeSublimeWindow()->getTopViews();
Sublime::View *activeView = ui->activeSublimeWindow()->activeView();
if (!activeView)
return;
int viewIndex = topViews.indexOf(activeView);
viewIndex = next ? viewIndex + 1 : viewIndex -1;
if (viewIndex < 0)
viewIndex = topViews.count() - 1;
else if (viewIndex >= topViews.count())
viewIndex = 0;
if (viewIndex >= 0 && viewIndex < topViews.count())
ui->activeSublimeWindow()->activateView(topViews.at(viewIndex));
}
void MainWindowPrivate::gotoNextSplit()
{
gotoPrevNextSplit(true);
}
void MainWindowPrivate::gotoPreviousSplit()
{
gotoPrevNextSplit(false);
}
void MainWindowPrivate::toggleFullScreen(bool fullScreen)
{
KToggleFullScreenAction::setFullScreen( m_mainWindow, fullScreen );
......
......@@ -281,6 +281,22 @@ void MainWindowPrivate::setupActions()
action->setToolTip( i18nc( "@info:tooltip", "Split vertical" ) );
action->setWhatsThis( i18nc( "@info:whatsthis", "Splits the current view vertically." ) );
action = actionCollection()->addAction( "view_next_split" );
action->setText( i18n( "&Next Split View" ) );
connect( action, SIGNAL(triggered(bool)), SLOT(gotoNextSplit()) );
action->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N );
action->setToolTip( i18nc( "@info:tooltip", "Next split view" ) );
action->setWhatsThis( i18nc( "@info:whatsthis", "Switches to the next split view." ) );
action->setIcon(KIcon("go-next"));
action = actionCollection()->addAction( "view_previous_split" );
action->setText( i18n( "&Previous Split View" ) );
connect( action, SIGNAL(triggered(bool)), SLOT(gotoPreviousSplit()) );
action->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_P );
action->setToolTip( i18nc( "@info:tooltip", "Previous split view" ) );
action->setWhatsThis( i18nc( "@info:whatsthis", "Switches to the previous split view." ) );
action->setIcon(KIcon("go-previous"));
action = KStandardAction::fullScreen( this, SLOT(toggleFullScreen(bool)), m_mainWindow, actionCollection() );
action = actionCollection()->addAction( "file_new" );
......
......@@ -90,6 +90,9 @@ public Q_SLOTS:
void split(Qt::Orientation orientation);
void toggleFullScreen(bool fullScreen);
void gotoNextSplit();
void gotoPreviousSplit();
void newToolbarConfig();
void settingsDialog();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment