Commit c43d476a authored by Robert Knight's avatar Robert Knight

Menu items and keyboard shortcuts to change the size of the current view in...

Menu items and keyboard shortcuts to change the size of the current view in split-view mode.  Use Ctrl+Shift+[ to shrink the size of the current view by 10% and Ctrl+Shift+] to increase the size of the current view by 10%

svn path=/trunk/KDE/kdebase/apps/konsole/; revision=663091
parent 9ea32273
...@@ -142,7 +142,19 @@ void ViewManager::setupActions() ...@@ -142,7 +142,19 @@ void ViewManager::setupActions()
detachViewAction->setShortcut( QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_H) ); detachViewAction->setShortcut( QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_H) );
connect( detachViewAction , SIGNAL(triggered()) , this , SLOT(detachActiveView()) ); connect( detachViewAction , SIGNAL(triggered()) , this , SLOT(detachActiveView()) );
// Expand & Shrink Active View
KAction* expandActiveAction = new KAction( i18n("Expand View") , this );
expandActiveAction->setShortcut( QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_BracketRight) );
collection->addAction("expand-active-view",expandActiveAction);
connect( expandActiveAction , SIGNAL(triggered()) , this , SLOT(expandActiveView()) );
KAction* shrinkActiveAction = new KAction( i18n("Shrink View") , this );
shrinkActiveAction->setShortcut( QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_BracketLeft) );
collection->addAction("shrink-active-view",shrinkActiveAction);
connect( shrinkActiveAction , SIGNAL(triggered()) , this , SLOT(shrinkActiveView()) );
// Next / Previous View , Next Container
collection->addAction("next-view",nextViewAction); collection->addAction("next-view",nextViewAction);
collection->addAction("previous-view",previousViewAction); collection->addAction("previous-view",previousViewAction);
collection->addAction("next-container",nextContainerAction); collection->addAction("next-container",nextContainerAction);
...@@ -316,6 +328,14 @@ void ViewManager::removeContainer(ViewContainer* container) ...@@ -316,6 +328,14 @@ void ViewManager::removeContainer(ViewContainer* container)
container->deleteLater(); container->deleteLater();
emit splitViewToggle(_viewSplitter->containers().count() > 1); emit splitViewToggle(_viewSplitter->containers().count() > 1);
} }
void ViewManager::expandActiveView()
{
_viewSplitter->adjustContainerSize(_viewSplitter->activeContainer(),10);
}
void ViewManager::shrinkActiveView()
{
_viewSplitter->adjustContainerSize(_viewSplitter->activeContainer(),-10);
}
void ViewManager::closeActiveView() void ViewManager::closeActiveView()
{ {
// only do something if there is more than one container active // only do something if there is more than one container active
...@@ -498,7 +518,6 @@ TerminalDisplay* ViewManager::createTerminalDisplay() ...@@ -498,7 +518,6 @@ TerminalDisplay* ViewManager::createTerminalDisplay()
display->setCutToBeginningOfLine(true); display->setCutToBeginningOfLine(true);
display->setTerminalSizeStartup(false); display->setTerminalSizeStartup(false);
display->setScrollBarLocation(TerminalDisplay::SCROLLBAR_RIGHT); display->setScrollBarLocation(TerminalDisplay::SCROLLBAR_RIGHT);
return display; return display;
} }
......
...@@ -140,6 +140,8 @@ private slots: ...@@ -140,6 +140,8 @@ private slots:
void splitTopBottom(); void splitTopBottom();
void closeActiveView(); void closeActiveView();
void closeOtherViews(); void closeOtherViews();
void expandActiveView();
void shrinkActiveView();
// called when the "Detach View" menu item is selected // called when the "Detach View" menu item is selected
void detachActiveView(); void detachActiveView();
......
...@@ -49,6 +49,38 @@ void ViewSplitter::childEmpty(ViewSplitter* splitter) ...@@ -49,6 +49,38 @@ void ViewSplitter::childEmpty(ViewSplitter* splitter)
emit empty(this); emit empty(this);
} }
void ViewSplitter::adjustContainerSize(ViewContainer* container , int percentage)
{
int containerIndex = indexOf(container->containerWidget());
Q_ASSERT( containerIndex != -1 );
QList<int> containerSizes = sizes();
int oldSize = containerSizes[containerIndex];
int newSize = oldSize * ( 1.0 + percentage/100.0 );
// qDebug() << "Old container size:" << oldSize << ", new size:" << newSize;
int perContainerDelta = ( (newSize-oldSize) / (count()-1) ) * (-1);
// qDebug() << "Changing sizes of other containers by " << perContainerDelta << "pixels.";
for ( int i = 0 ; i < containerSizes.count() ; i++ )
{
//qDebug() << "Container" << i << "old size =" << containerSizes[i];
if ( i == containerIndex )
containerSizes[i] = newSize;
else
containerSizes[i] = containerSizes[i] + perContainerDelta;
//qDebug() << "Container" << i << "new size =" << containerSizes[i];
}
setSizes(containerSizes);
}
ViewSplitter* ViewSplitter::activeSplitter() ViewSplitter* ViewSplitter::activeSplitter()
{ {
// qDebug() << "BEGIN activeSplitter" ; // qDebug() << "BEGIN activeSplitter" ;
......
...@@ -98,6 +98,17 @@ public: ...@@ -98,6 +98,17 @@ public:
*/ */
void activateNextContainer(); void activateNextContainer();
/**
* Changes the size of the specified @p container by a given @p percentage.
* @p percentage may be positive ( in which case the size of the container
* is increased ) or negative ( in which case the size of the container
* is decreased ).
*
* The sizes of the remaining containers are increased or decreased
* uniformly to maintain the width of the splitter.
*/
void adjustContainerSize(ViewContainer* container , int percentage);
/** /**
* Gives the focus to the active view in the previous container * Gives the focus to the active view in the previous container
*/ */
......
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