Commit 1c47b619 authored by Robert Knight's avatar Robert Knight

Focus newly opened views. Enable/disable 'Close Active/Other Views' menu...

Focus newly opened views.  Enable/disable 'Close Active/Other Views' menu items as appropriate.  Rename 'Edit Current Session...' to 'Terminal Options...'

svn path=/branches/work/konsole-split-view/; revision=657385
parent 394546f1
......@@ -22,10 +22,12 @@
<Menu name="view"><text>View</text>
<DefineGroup name="session-view-operations"/>
<Separator/>
<Menu name="view-split"><text>Split View</text>
<Action name="split-view-left-right"/>
<Action name="split-view-top-bottom"/>
<Action name="close-active-view"/>
<Action name="close-other-views"/>
</Menu>
<Separator/>
<Action name="detach-view"/>
<Action name="merge-windows"/>
......
......@@ -3,6 +3,7 @@
<kpartgui name="session">
<MenuBar>
<Menu name="file"><text>File</text>
<Action name="save-session" group="session-operations" />
<Action name="close-session" group="session-operations"/>
</Menu>
<Menu name="edit"><text>Edit</text>
......@@ -32,6 +33,9 @@
<Action name="increase-text-size"/>
<Action name="decrease-text-size"/>
</Menu>
<Menu name="settings"><text>Settings</text>
<Action name="terminal-options"/>
</Menu>
<!--<Menu name="debug"><text>Debug</text>
<Action name="debug-process"/>
</Menu>!-->
......@@ -42,7 +46,7 @@
<Action name="clear-history-and-reset"/>
<Separator/>
<Action name="show-menubar"/>
<Action name="edit-current-session" />
<Action name="terminal-options" />
<Separator/>
<Action name="close-session"/>
</Menu>
......
......@@ -30,6 +30,7 @@ class QStringList;
namespace Konsole
{
class Session;
class SessionController;
class ViewManager;
......@@ -72,10 +73,12 @@ protected:
virtual bool openFile();
private slots:
// creates a new session using the specified key.
// call the run() method on the returned Session instance to begin the session
Session* createSession(const QString& key);
void activeViewChanged(SessionController* controller);
private:
ViewManager* _viewManager;
SessionController* _pluggedController;
......
......@@ -234,6 +234,12 @@ void SessionController::setupActions()
KToggleAction* toggleAction = 0;
KActionCollection* collection = actionCollection();
// Save Session
action = collection->addAction("save-session");
action->setIcon( KIcon("save") );
action->setText( i18n("&Save Session") );
connect( action , SIGNAL(triggered()) , this , SLOT(saveSession()) );
// Close Session
action = collection->addAction("close-session");
action->setIcon( KIcon("window-close") ); // FIXME: Not the best icon for this
......@@ -330,10 +336,10 @@ void SessionController::setupActions()
action->setShortcut( QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_X) );
connect( action , SIGNAL(triggered()) , this , SLOT(clearHistoryAndReset()) );
// Edit Session
action = collection->addAction("edit-current-session");
action->setText( i18n("Edit Current Session...") );
connect( action , SIGNAL(triggered()) , this , SLOT(editCurrentSession()) );
// Terminal Options
action = collection->addAction("terminal-options");
action->setText( i18n("Terminal Options...") );
connect( action , SIGNAL(triggered()) , this , SLOT(showTerminalOptions()) );
// debugging tools
//action = collection->addAction("debug-process");
......@@ -380,13 +386,17 @@ void SessionController::debugProcess()
delete sessionProcess;
}
void SessionController::editCurrentSession()
void SessionController::showTerminalOptions()
{
EditSessionDialog dialog(_view);
dialog.setSessionType(_session->type());
int result = dialog.exec();
}
void SessionController::saveSession()
{
//SaveSessionDialog dialog(_view);
//int result = dialog.exec();
}
void SessionController::closeSession()
{
_session->closeSession();
......
......@@ -108,7 +108,7 @@ private slots:
void paste();
void clear();
void clearAndReset();
void editCurrentSession();
void showTerminalOptions();
void searchHistory();
void searchHistory(bool showSearchBar);
void findNextInHistory();
......@@ -122,6 +122,7 @@ private slots:
void monitorSilence(bool monitor);
void increaseTextSize();
void decreaseTextSize();
void saveSession();
void sendInputToAll();
// other
......
......@@ -40,6 +40,68 @@ namespace Konsole
class Session;
/** Replacement for SessionInfo */
class SessionSettings
{
public:
enum Property
{
// General session options
Name,
Title,
Icon,
Command,
Arguments,
Environment,
Directory,
// Appearence
Font,
ColorScheme,
// Keyboard
KeyBindings,
// Terminal Features
SelectWordCharacters
};
virtual ~SessionSettings() {}
/** Returns the current value of the specified @p property. */
virtual QVariant property(Property property);
/** Sets the value of the specified @p property to @p value. */
virtual void setProperty(Property property,const QVariant& value);
//
// Convenience methods for property() and setProperty() go here
//
/**
* Returns the element from the Property enum associated with the
* specified @p name.
*/
static Property lookupByName(QString name);
/**
* Returns the string names associated with the specified @p property from
* the Property enum, in the order the associations were created using
* registerName()
*/
static QList<QString> namesForProperty(Property property);
/**
* Adds an association between a string @p name and a @p property.
* Subsequent calls to lookupByName() with @p name as the argument
* will return @p property.
*/
static void registerName(Property property , const QString& name);
private:
static QHash<QString,Property> _propertyNames;
static QHash<Property,QVariant> _propertyValues;
};
/**
* Provides information about a type of
* session, including the title of the session
......
......@@ -116,13 +116,17 @@ void ViewManager::setupActions()
KAction* closeActiveAction = new KAction( i18n("Close Active") , this );
closeActiveAction->setShortcut( QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_S) );
closeActiveAction->setEnabled(false);
collection->addAction("close-active-view",closeActiveAction);
connect( closeActiveAction , SIGNAL(triggered()) , this , SLOT(closeActiveView()) );
connect( this , SIGNAL(splitViewToggle(bool)) , closeActiveAction , SLOT(setEnabled(bool)) );
KAction* closeOtherAction = new KAction( i18n("Close Others") , this );
closeOtherAction->setShortcut( QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_O) );
closeOtherAction->setEnabled(false);
collection->addAction("close-other-views",closeOtherAction);
connect( closeOtherAction , SIGNAL(triggered()) , this , SLOT(closeOtherViews()) );
connect( this , SIGNAL(splitViewToggle(bool)) , closeOtherAction , SLOT(setEnabled(bool)) );
QAction* detachViewAction = collection->addAction("detach-view");
detachViewAction->setIcon( KIcon("tab-breakoff") );
......@@ -205,7 +209,7 @@ void ViewManager::detachActiveView()
if ( _viewSplitter->containers().count() > 1 &&
container->views().count() == 0 )
{
delete container;
removeContainer(container);
// this will need to be removed if Konsole is modified so the menu item to
// split the view is no longer one toggle-able item
......@@ -271,53 +275,52 @@ void ViewManager::splitTopBottom()
void ViewManager::splitView(Qt::Orientation orientation)
{
if ( true )
// iterate over each session which has a view in the current active
// container and create a new view for that session in a new container
QListIterator<QWidget*> existingViewIter(_viewSplitter->activeContainer()->views());
ViewContainer* container = createContainer();
while (existingViewIter.hasNext())
{
// iterate over each session which has a view in the current active
// container and create a new view for that session in a new container
QListIterator<QWidget*> existingViewIter(_viewSplitter->activeContainer()->views());
ViewContainer* container = createContainer();
Session* session = _sessionMap[(TerminalDisplay*)existingViewIter.next()];
TerminalDisplay* display = createTerminalDisplay();
loadViewSettings(display,session);
ViewProperties* properties = createController(session,display);
while (existingViewIter.hasNext())
{
Session* session = _sessionMap[(TerminalDisplay*)existingViewIter.next()];
TerminalDisplay* display = createTerminalDisplay();
loadViewSettings(display,session);
ViewProperties* properties = createController(session,display);
_sessionMap[display] = session;
_sessionMap[display] = session;
container->addView(display,properties);
session->addView( display );
}
container->addView(display,properties);
session->addView( display );
}
_viewSplitter->addContainer(container,orientation);
emit splitViewToggle(_viewSplitter->containers().count() > 0);
_viewSplitter->addContainer(container,orientation);
}
else
{
// delete the active container when unsplitting the view unless it is the last
// one
if ( _viewSplitter->containers().count() > 1 )
{
ViewContainer* container = _viewSplitter->activeContainer();
delete container;
}
}
// focus the new container
container->containerWidget()->setFocus();
// ensure that the active view is focused after the split / unsplit
_viewSplitter->activeContainer()->activeView()->setFocus(Qt::OtherFocusReason);
}
void ViewManager::closeActiveView()
void ViewManager::removeContainer(ViewContainer* container)
{
ViewContainer* container = _viewSplitter->activeContainer();
delete container;
emit splitViewToggle(_viewSplitter->containers().count() > 1);
}
void ViewManager::closeActiveView()
{
// only do something if there is more than one container active
if ( _viewSplitter->containers().count() > 1 )
{
ViewContainer* container = _viewSplitter->activeContainer();
removeContainer(container);
// focus next container so that user can continue typing
// without having to manually focus it themselves
nextContainer();
// focus next container so that user can continue typing
// without having to manually focus it themselves
nextContainer();
}
}
void ViewManager::closeOtherViews()
{
......@@ -350,6 +353,7 @@ void ViewManager::createView(Session* session)
if (_viewSplitter->containers().count() == 0)
{
_viewSplitter->addContainer( createContainer() , Qt::Vertical );
emit splitViewToggle(false);
}
// notify this view manager when the session finishes so that its view
......
......@@ -126,6 +126,10 @@ signals:
*/
void viewPropertiesChanged(const QList<ViewProperties*>& propertiesList);
// internal
// 'multipleViews' - true if the manager has multiple containers or false otherwise
void splitViewToggle(bool multipleViews);
private slots:
// called when the "Split View Left/Right" menu item is selected
void splitLeftRight();
......@@ -168,6 +172,7 @@ private:
void focusActiveView();
void registerView(TerminalDisplay* view);
void unregisterView(TerminalDisplay* view);
// takes a view from a view container owned by a different manager and places it in
// newContainer owned by this manager
void takeView(ViewManager* otherManager , ViewContainer* otherContainer, ViewContainer* newContainer, TerminalDisplay* view);
......@@ -175,6 +180,9 @@ private:
// creates a new container which can hold terminal displays
ViewContainer* createContainer();
// removes a container and emits appropriate signals
void removeContainer(ViewContainer* container);
// creates a new terminal display
TerminalDisplay* createTerminalDisplay();
// applies the view-specific settings such as colour scheme associated
......
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