Commit 2b11add4 authored by Robert Knight's avatar Robert Knight

* Use a sensible step value for the history size spinbox
* Remove some more old commented out code and tidy up some API documentation
* Add keyboard shortcuts for switching between tabs and views.  Currently:
    Shift+Left  - Previous Tab
    Shift+Right - Next Tab
    Shift+Tab   - Next View ( only applicable when in split-view mode )


svn path=/branches/work/konsole-split-view/; revision=646521
parent 9e58647a
......@@ -73,6 +73,8 @@ HistorySizeDialog::HistorySizeDialog( QWidget* parent )
// using that for now
lineCountBox->setValue( 1000 );
lineCountBox->setSingleStep( 100 );
QLabel* lineCountLabel = new QLabel(i18n("lines"),this);
QHBoxLayout* lineCountLayout = new QHBoxLayout();
......
......@@ -88,10 +88,12 @@ void MainWindow::setupActions()
QAction* newTabAction = collection->addAction("new-tab");
newTabAction->setIcon( KIcon("openterm") );
newTabAction->setText( i18n("New &Tab") );
newTabAction->setShortcut( QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_N) );
QAction* newWindowAction = collection->addAction("new-window");
newWindowAction->setIcon( KIcon("window-new") );
newWindowAction->setText( i18n("New &Window") );
newWindowAction->setShortcut( QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_M) );
connect( newTabAction , SIGNAL(triggered()) , this , SLOT(newTab()) );
connect( newWindowAction , SIGNAL(triggered()) , this , SLOT(newWindow()) );
......
......@@ -73,14 +73,16 @@ public:
/**
* Adds a new view for this session.
*
* The viewing widget will display the output from the terminal and input from the viewing widget
* (key presses, mouse activity etc.) will be sent to the terminal.
* The viewing widget will display the output from the terminal and
* input from the viewing widget (key presses, mouse activity etc.)
* will be sent to the terminal.
*
* Since terminal applications assume a single terminal screen, all views of a session
* will display the same number of lines and columns.
* Since terminal applications assume a single terminal screen,
* all views of a session will display the same number of lines and
* columns.
*
* When the Session instance is destroyed, any views which are still attached will also
* be deleted.
* When the Session instance is destroyed, any views which are still
* attached will also be deleted.
*/
void addView(TerminalDisplay* widget);
/**
......@@ -111,15 +113,18 @@ public:
int fontNo() const;
/**
* Returns the value of the TERM environment variable which will be used in the session's
* environment when it is started using the run() method.
* Returns the value of the TERM environment variable which will
* be used in the session's environment when it is started using
* the run() method.
*
* Defaults to "xterm".
*/
const QString& terminalType() const;
/**
* Sets the value of the TERM variable which will be used in the session's environment
* when it is started using the run() method. Changing this once the session has been
* started using run() has no effect
* Sets the value of the TERM variable which will be used in the
* session's environment when it is started using the run() method.
* Changing this once the session has been started using run() has no effect.
*
* Defaults to "xterm" if not set explicitly
*/
void setTerminalType(const QString& terminalType);
......@@ -130,8 +135,8 @@ public:
const QString& iconText() const;
/**
* Return the session title set by the user (ie. the program running in the terminal), or an
* empty string if the user has not set a custom title
* Return the session title set by the user (ie. the program running
* in the terminal), or an empty string if the user has not set a custom title
*/
QString userTitle() const;
/**
......@@ -171,8 +176,9 @@ public:
void setMasterMode(bool);
//TODO - Remove these functions which use indicies to reference keyboard layouts,
// encodings etc. and replace them either with methods that uses pointers or references
// to the font object / keyboard layout object etc. or a QString key
// encodings etc. and replace them either with methods that
// use pointers or references to the font object / keyboard
// layout object etc. or a QString key
void setEncodingNo(int index);
void setKeymapNo(int kn);
void setFontNo(int fn);
......
......@@ -306,22 +306,7 @@ void TerminalDisplay::fontChange(const QFont &)
font_w=1;
font_a = fm.ascent();
//printf("font: %s\n", font().toString().toLatin1().constData());
//printf("fixed: %s\n", font().fixedPitch() ? "yes" : "no");
//printf("fixed_font: %d\n", fixed_font);
//printf("font_h: %d\n",font_h);
//printf("font_w: %d\n",font_w);
//printf("fw: %d\n",fw);
//printf("font_a: %d\n",font_a);
//printf("rawname: %s\n",font().renditionawName().toAscii().constData());
/*
#if defined(Q_CC_GNU)
#warning TODO: Review/fix vt100 extended font-mapping
#endif
*/
// fontMap = identicalMap;
emit changedFontMetricSignal( font_h, font_w );
propagateSize();
update();
......@@ -418,13 +403,6 @@ TerminalDisplay::TerminalDisplay(QWidget *parent)
// konsole in opaque mode.
bY = bX = 1;
//Selection is no longer cleared automatically
//when the selection changes
//
//cb = QApplication::clipboard();
//QObject::connect( (QObject*)cb, SIGNAL(selectionChanged()),
// this, SLOT(onClearSelection()) );
scrollbar = new QScrollBar(this);
scrollbar->setCursor( Qt::ArrowCursor );
connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
......@@ -442,7 +420,7 @@ TerminalDisplay::TerminalDisplay(QWidget *parent)
setMouseTracking(true);
// Init DnD ////////////////////////////////////////////////////////////////
// Init DnD
setAcceptDrops(true); // attempt
dragInfo.state = diNone;
......
......@@ -88,6 +88,40 @@ const QList<QWidget*> ViewContainer::views()
return _views;
}
void ViewContainer::activateNextView()
{
QWidget* active = activeView();
int index = _views.indexOf(active);
if ( index == -1 )
return;
if ( index == _views.count() - 1 )
index = 0;
else
index++;
setActiveView( _views.at(index) );
}
void ViewContainer::activatePreviousView()
{
QWidget* active = activeView();
int index = _views.indexOf(active);
if ( index == -1 )
return;
if ( index == 0 )
index = _views.count() - 1;
else
index--;
setActiveView( _views.at(index) );
}
ViewProperties* ViewContainer::viewProperties( QWidget* widget )
{
Q_ASSERT( _navigation.contains(widget) );
......
......@@ -102,6 +102,18 @@ public:
* navigation aids to reflect the change.
*/
virtual void setActiveView(QWidget* widget) = 0;
/**
* Changes the active view to the next view
*/
void activateNextView();
/**
* Changes the active view to the previous view
*/
void activatePreviousView();
signals:
/** Emitted when the container is deleted */
void destroyed(ViewContainer* container);
......
......@@ -90,6 +90,48 @@ void ViewManager::setupActions()
mergeAction->setText( i18n("&Merge Windows") );
connect( mergeAction , SIGNAL(triggered()) , _mainWindow , SLOT(mergeWindows()) );
QAction* nextViewAction = collection->addAction("next-view");
nextViewAction->setText( i18n("Next View") );
nextViewAction->setShortcut( QKeySequence(Qt::SHIFT+Qt::Key_Right) );
connect( nextViewAction, SIGNAL(triggered()) , this , SLOT(nextView()) );
_mainWindow->addAction(nextViewAction);
QAction* previousViewAction = collection->addAction("previous-view");
previousViewAction->setText( i18n("Previous View") );
previousViewAction->setShortcut( QKeySequence(Qt::SHIFT+Qt::Key_Left) );
connect( previousViewAction, SIGNAL(triggered()) , this , SLOT(previousView()) );
_mainWindow->addAction(previousViewAction);
QAction* nextContainerAction = collection->addAction("next-container");
nextContainerAction->setText( i18n("Next View Container") );
nextContainerAction->setShortcut( QKeySequence(Qt::SHIFT+Qt::Key_Tab) );
connect( nextContainerAction , SIGNAL(triggered()) , this , SLOT(nextContainer()) );
_mainWindow->addAction(nextContainerAction);
}
void ViewManager::nextContainer()
{
_viewSplitter->activateNextContainer();
}
void ViewManager::nextView()
{
ViewContainer* container = _viewSplitter->activeContainer();
Q_ASSERT( container );
container->activateNextView();
}
void ViewManager::previousView()
{
ViewContainer* container = _viewSplitter->activeContainer();
Q_ASSERT( container );
container->activatePreviousView();
}
void ViewManager::detachActiveView()
......
......@@ -114,6 +114,16 @@ private slots:
// called when the title of the active view changes
void activeViewTitleChanged( ViewProperties* );
// called when "Next View" shortcut is activated
void nextView();
// called when "Previous View" shortcut is activated
void previousView();
// called when "Next View Container" shortcut is activated
void nextContainer();
private:
void setupActions();
void focusActiveView();
......
......@@ -166,6 +166,46 @@ void ViewSplitter::containerDestroyed(ViewContainer* object)
}
}
void ViewSplitter::activateNextContainer()
{
ViewContainer* active = activeContainer();
int index = _containers.indexOf(active);
if ( index == -1 )
return;
if ( index == _containers.count() -1 )
index = 0;
else
index++;
setActiveContainer( _containers.at(index) );
}
void ViewSplitter::activatePreviousContainer()
{
ViewContainer* active = activeContainer();
int index = _containers.indexOf(active);
if ( index == 0 )
index = _containers.count() - 1;
else
index--;
setActiveContainer( _containers.at(index) );
}
void ViewSplitter::setActiveContainer(ViewContainer* container)
{
QWidget* activeView = container->activeView();
if ( activeView )
activeView->setFocus( Qt::OtherFocusReason );
}
ViewContainer* ViewSplitter::activeContainer() const
{
if ( QWidget* focusW = focusWidget() )
......
......@@ -82,12 +82,27 @@ public:
* is the ViewSplitter widget at the top of the hierarchy.
*/
ViewContainer* activeContainer() const;
/**
* Gives the focus to the active view in the specified container
*/
void setActiveContainer(ViewContainer* container);
/**
* Returns a list of the containers held by this splitter
*/
QList<ViewContainer*> containers() const {return _containers;}
/**
* Gives the focus to the active view in the next container
*/
void activateNextContainer();
/**
* Gives the focus to the active view in the previous container
*/
void activatePreviousContainer();
signals:
/** Signal emitted when the last child widget is removed from the splitter */
void empty(ViewSplitter* splitter);
......
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