Commit 576d1c39 authored by Robert Knight's avatar Robert Knight

* Moved session action layout into a separate XML file.  I'm still a bit new to this 
  XMLGUI thingie.
* Call 'close()' rather than 'deleteLater()' on main window when last session is closed,
  makes Konsole app close when last session finishes.
* Added ViewProperties class from which SessionController inherits.  The ViewContainer has
  a ViewProperties instance associated with each view, which it uses to determine the title 
  and icon associated with that view.  Icons and session titles now show in the tabs.
* Added "Monitor for Activity" and "Monitor for Silence" in the new front-end.
* Set value of TERM variable before creating session in SessionManager, fixes lots of problems
  with Linux Console session type.
* Add a few CMakeLists.txt files from the new other/ directories to SVN which I forgot in the 
  previous commit.

svn path=/branches/work/konsole-split-view/; revision=618811
parent b7b9e626
......@@ -7,4 +7,4 @@ install( FILES terminalemulator.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR
install( FILES konsolepart.desktop kwrited.desktop konsole-script.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
install( FILES konsolehere.desktop DESTINATION ${DATA_INSTALL_DIR}/konqueror/servicemenus )
install( FILES kwrited.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kded )
install( FILES konsole.notifyrc tips konsoleui.rc DESTINATION ${DATA_INSTALL_DIR}/konsole )
install( FILES konsole.notifyrc tips konsoleui.rc sessionui.rc DESTINATION ${DATA_INSTALL_DIR}/konsole )
......@@ -8,29 +8,17 @@
<Separator/>
<ActionList name="new-session-types"/>
<Separator/>
<Action name="close-session"/>
<DefineGroup name="session-operations"/>
<Action name="exit" />
</Menu>
<Menu name="edit"><text>Edit</text>
<Action name="copy"/>
<Action name="paste"/>
<Separator/>
<Action name="zmodem-upload"/>
<Separator/>
<Action name="clear"/>
<Action name="clear-and-reset"/>
<DefineGroup name="session-edit-operations" />
</Menu>
<Menu name="history"><text>History</text>
<Action name="search-history"/>
<Action name="find-next"/>
<Action name="find-previous"/>
<Action name="save-history"/>
<Separator/>
<Action name="clear-history"/>
<DefineGroup name="session-history-operations"/>
</Menu>
<Menu name="view"><text>View</text>
<Action name="monitor-activity"/>
<Action name="monitor-silence" />
<DefineGroup name="session-view-operations"/>
<Separator/>
<Action name="split-view"/>
<Action name="detach-view"/>
......@@ -49,3 +37,4 @@
</Menu>
</MenuBar>
</kpartgui>
<!DOCTYPE kpartgui>
<kpartgui name="session">
<MenuBar>
<Menu name="file"><text>File</text>
<Action name="close-session" group="session-operations"/>
</Menu>
<Menu name="edit"><text>Edit</text>
<Action name="copy" group="session-edit-operations" />
<Action name="paste" group="session-edit-operations" />
<Separator group="session-edit-operations"/>
<Action name="clear" group="session-edit-operations" />
<Action name="clear-and-reset" group="session-edit-operations" />
</Menu>
<Menu name="history"><text>History</text>
<Action name="search-history" group="session-history-operations"/>
<Action name="find-next" group="session-history-operations"/>
<Action name="find-previous" group="session-history-operations"/>
<Action name="save-history" group="session-history-operations"/>
<Separator group="session-history-operations"/>
<Action name="clear-history" group="session-history-operations"/>
</Menu>
<Menu name="view"><text>View</text>
<Action name="monitor-silence" group="session-view-operations" />
<Action name="monitor-activity" group="session-view-operations" />
</Menu>
</MenuBar>
</kpartgui>
This folder contains historic documentation for Konsole for KDE 4. Historic documentation may provide interesting ideas or background information but is no longer consistent with the actual code or future plans.
......@@ -65,6 +65,7 @@ set(konsole_KDEINIT_SRCS
TEWidget.cpp
ViewContainer.cpp
ViewManager.cpp
ViewProperties.cpp
ViewSplitter.cpp
KonsoleBookmarkHandler.cpp
ZModemDialog.cpp
......
......@@ -87,10 +87,6 @@ void KonsoleApp::createSession(const QString& key , ViewManager* view)
{
TESession* session = _sessionManager->createSession(key);
session->setConnect(true);
//temporary - test history feature
//session->setHistory( HistoryTypeBuffer(1000) );
session->run();
view->createView(session);
}
......
......@@ -46,11 +46,11 @@ KonsoleMainWindow::KonsoleMainWindow()
setupActions();
// create view manager
setXMLFile("konsoleui.rc");
_viewManager = new ViewManager(this);
connect( _viewManager , SIGNAL(empty()) , this , SLOT(deleteLater()) );
connect( _viewManager , SIGNAL(empty()) , this , SLOT(close()) );
// create menus
setXMLFile("konsoleui.rc");
createGUI();
}
......
// KDE
#include <KAction>
#include <KIcon>
#include <KLocale>
#include <KToggleAction>
#include <kdebug.h>
// Konsole
......@@ -9,16 +11,29 @@
#include "TEWidget.h"
#include "SessionController.h"
KIcon SessionController::_activityIcon;
KIcon SessionController::_silenceIcon;
SessionController::SessionController(TESession* session , TEWidget* view, QObject* parent)
: QObject(parent)
/*ViewProperties(parent) */
: ViewProperties(parent)
, KXMLGUIClient()
, _session(session)
, _view(view)
, _previousState(-1)
{
setXMLFile("sessionui.rc");
setupActions();
sessionTitleChanged();
view->installEventFilter(this);
// listen to activity / silence notifications from session
connect( _session , SIGNAL(notifySessionState(TESession*,int)) , this ,
SLOT(sessionStateChanged(TESession*,int) ));
// list to title and icon changes
connect( _session , SIGNAL(updateTitle()) , this , SLOT(sessionTitleChanged()) );
}
bool SessionController::eventFilter(QObject* watched , QEvent* event)
......@@ -39,8 +54,6 @@ void SessionController::setupActions()
KAction* action = 0;
KActionCollection* collection = actionCollection();
setXMLFile("konsoleui.rc");
// Close Session
action = new KAction( KIcon("fileclose"), i18n("&Close Tab") , collection , "close-session" );
connect( action , SIGNAL(triggered()) , this , SLOT(closeSession()) );
......@@ -59,6 +72,12 @@ void SessionController::setupActions()
action = new KAction( i18n("Clear and Reset") , collection , "clear-and-reset" );
connect( action , SIGNAL(triggered()) , this , SLOT(clearAndReset()) );
// Monitor
action = new KToggleAction( i18n("Monitor for &Activity") , collection , "monitor-activity" );
connect( action , SIGNAL(toggled(bool)) , this , SLOT(monitorActivity(bool)) );
action = new KToggleAction( i18n("Monitor for &Silence") , collection , "monitor-silence" );
connect( action , SIGNAL(toggled(bool)) , this , SLOT(monitorSilence(bool)) );
// History
action = new KAction( KIcon("find") , i18n("Search History") , collection , "search-history" );
......@@ -122,5 +141,63 @@ void SessionController::clearHistory()
{
_session->clearHistory();
}
void SessionController::monitorActivity(bool monitor)
{
_session->setMonitorActivity(monitor);
}
void SessionController::monitorSilence(bool monitor)
{
_session->setMonitorSilence(monitor);
}
void SessionController::sessionTitleChanged()
{
if ( _sessionIconName != _session->iconName() )
{
_sessionIconName = _session->iconName();
_sessionIcon = KIcon( _sessionIconName );
setIcon( _sessionIcon );
}
setTitle( _session->displayTitle() );
}
void SessionController::sessionStateChanged(TESession* /*session*/ , int state)
{
//TODO - Share icons across sessions ( possible using a static QHash<QString,QIcon> variable
// to create a cache of icons mapped from icon names? )
if ( state == _previousState )
return;
_previousState = state;
if ( state == NOTIFYACTIVITY )
{
if (_activityIcon.isNull())
{
_activityIcon = KIcon("activity");
}
setIcon(_activityIcon);
}
else if ( state == NOTIFYSILENCE )
{
if (_silenceIcon.isNull())
{
_silenceIcon = KIcon("silence");
}
setIcon(_silenceIcon);
}
else if ( state == NOTIFYNORMAL )
{
if ( _sessionIconName != _session->iconName() )
{
_sessionIconName = _session->iconName();
_sessionIcon = KIcon( _sessionIconName );
}
setIcon( _sessionIcon );
}
}
#include "SessionController.moc"
......@@ -10,43 +10,21 @@
#include <KActionCollection>
#include <KXMLGUIClient>
// Konsole
#include "ViewProperties.h"
class QAction;
class TESession;
class TEWidget;
/**
* Provides information (such as the title and icon) associated with
*/
/*class ViewProperties : public QObject
{
public:
ViewProperties(QObject* parent) : QObject(parent) {}
QIcon icon();
QString title();
signals:
void iconChanged(const QIcon& icon);
void titleChanged(const QString& title);
protected:
void setTitle(const QString& title);
void setIcon(const QIcon& icon);
private:
QIcon _icon;
QString _title;
};*/
/**
* Provides the actions associated with a session in the Konsole main menu
* and exposes information such as the title and icon associated with the session to view containers.
*
* Each view should have one SessionController associated with it
*/
class SessionController : /*public ViewProperties ,*/ public QObject , public KXMLGUIClient
class SessionController : public ViewProperties , public KXMLGUIClient
{
Q_OBJECT
......@@ -81,6 +59,11 @@ private slots:
void saveHistory();
void clearHistory();
void closeSession();
void monitorActivity(bool monitor);
void monitorSilence(bool monitor);
void sessionStateChanged(TESession* session,int state);
void sessionTitleChanged();
private:
void setupActions();
......@@ -88,6 +71,12 @@ private:
private:
TESession* _session;
TEWidget* _view;
KIcon _sessionIcon;
QString _sessionIconName;
int _previousState;
static KIcon _activityIcon;
static KIcon _silenceIcon;
};
#endif //SESSIONCONTROLLER_H
......@@ -249,13 +249,14 @@ TESession* SessionManager::createSession(QString configPath )
while (iter.hasNext())
kDebug() << "running " << info->command(false) << ": argument " << iter.next() << endl;
session->setWorkingDirectory( activeSetting(InitialWorkingDirectory).toString() );
session->setInitialWorkingDirectory( activeSetting(InitialWorkingDirectory).toString() );
session->setProgram( info->command(false) );
session->setArguments( info->arguments() );
session->setTitle( info->name() );
session->setIconName( info->icon() );
session->setSchema( _colorSchemeList->find(activeSetting(ColorScheme).toString()) );
session->setTerminalType( info->terminal() );
//temporary
session->setHistory( HistoryTypeBuffer(1000) );
......@@ -276,8 +277,6 @@ TESession* SessionManager::createSession(QString configPath )
void SessionManager::sessionTerminated(TESession* session)
{
// kDebug() << __FILE__ << ": session finished " << endl;
_sessions.remove(session);
}
......
......@@ -73,7 +73,6 @@ TESession::TESession() :
, zmodemProc(0)
, zmodemProgress(0)
, encoding_no(0)
, _navigationItem(0)
, _colorScheme(0)
{
//prepare DBus communication
......@@ -215,17 +214,6 @@ TEWidget* TESession::primaryView()
return 0;
}
NavigationItem* TESession::navigationItem()
{
/*if (!_navigationItem)
{
_navigationItem = new SessionNavigationItem(this);
}
return _navigationItem;*/
assert(0);
return 0;
}
void TESession::addView(TEWidget* widget)
{
Q_ASSERT( !_views.contains(widget) );
......@@ -462,14 +450,6 @@ QString TESession::displayTitle() const
return title();
}
/*QString TESession::fullTitle() const
{
QString res = _title;
if ( !_userTitle.isEmpty() )
res = _userTitle + " - " + res;
return res;
}*/
void TESession::monitorTimerDone()
{
//FIXME: The idea here is that the notification popup will appear to tell the user than output from
......@@ -525,7 +505,7 @@ void TESession::notifySessionState(int state)
emit notifySessionState(this, state);
}
void TESession::onContentSizeChange(int height, int width)
void TESession::onContentSizeChange(int /*height*/, int /*width*/)
{
updateTerminalSize();
}
......@@ -670,11 +650,6 @@ TEmulation* TESession::getEmulation()
// following interfaces might be misplaced ///
//int TESession::schemaNo()
//{
// return schema_no;
//}
int TESession::encodingNo()
{
return encoding_no;
......@@ -695,20 +670,20 @@ int TESession::fontNo()
return _fontNo;
}
const QString & TESession::Term() const
const QString& TESession::terminalType() const
{
return term;
}
const QString & TESession::SessionId() const
void TESession::setTerminalType(const QString& terminalType)
{
return sessionId;
term = terminalType;
}
/*void TESession::setSchemaNo(int sn)
const QString & TESession::SessionId() const
{
schema_no = sn;
}*/
return sessionId;
}
void TESession::setEncodingNo(int index)
{
......@@ -804,7 +779,7 @@ QString TESession::getPgm()
return _program;
}
QString TESession::getCwd()
QString TESession::currentWorkingDirectory()
{
#ifdef HAVE_PROC_CWD
if (cwd.isEmpty()) {
......@@ -1021,18 +996,6 @@ ColorSchema* TESession::schema()
return _colorScheme;
}
/*QString TESession::schema()
{
QString currentSchema;
emit getSessionSchema(this, currentSchema);
return currentSchema;
}*/
//void TESession::setSchema(const QString &schema)
//{
// emit setSessionSchema(this, schema);
//}
void TESession::setSchema(ColorSchema* schema)
{
_colorScheme = schema;
......
......@@ -40,7 +40,6 @@ class KProcess;
class ZModemDialog;
class ColorSchema;
class NavigationItem;
/**
* TESession represents a Konsole session.
......@@ -105,16 +104,6 @@ public:
*/
TEWidget* primaryView();
/**
* Returns the navigation item for this session.
* The navigation item provides information about the session such as associated title and icon
* for use by widgets which allow the user to select between views belonging to different sessions.
*
* The navigation item also provides actions which can be placed in a menu
* to allow the user to control various aspects of the session.
*/
NavigationItem* navigationItem();
/**
* Returns true if the session has created child processes which have not yet terminated
* This call may be expensive if there are a large number of processes running.
......@@ -131,7 +120,21 @@ public:
int schemaNo();
int encodingNo();
int fontNo();
const QString& Term() 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.
* 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
* Defaults to "xterm" if not set explicitly
*/
void setTerminalType(const QString& terminalType);
const QString& SessionId() const;
const QString& title() const;
const QString& iconName() const;
......@@ -161,18 +164,15 @@ public:
void setProgram(const QString& program);
/** Returns the session's current working directory. */
QString getCwd();
QString getInitial_cwd() { return initial_cwd; }
QString currentWorkingDirectory();
QString initialWorkingDirectory() { return initial_cwd; }
/**
* Sets the initial working directory for the session when it is run
* This has no effect once the session has been started.
*/
void setWorkingDirectory( const QString& dir ) { initial_cwd = dir; }
//void setInitial_cwd(const QString& _cwd) { initial_cwd=_cwd; }
void setInitialWorkingDirectory( const QString& dir ) { initial_cwd = dir; }
void setHistory(const HistoryType&);
const HistoryType& history();
......@@ -180,11 +180,15 @@ public:
void setMonitorSilence(bool);
void setMonitorSilenceSeconds(int seconds);
void setMasterMode(bool);
// void setSchemaNo(int sn);
void setEncodingNo(int index);
void setKeymapNo(int kn);
//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
void setEncodingNo(int index);
void setKeymapNo(int kn);
void setFontNo(int fn);
void setKeymap(const QString& _id);
void setFontNo(int fn);
void setTitle(const QString& _title);
void setIconName(const QString& _iconName);
void setIconText(const QString& _iconText);
......@@ -196,7 +200,6 @@ public:
void setAutoClose(bool b) { autoClose = b; }
void renameSession(const QString &name);
// Additional functions for DCOP
bool closeSession();
void clearHistory();
void feedSession(const QString &text);
......@@ -331,8 +334,6 @@ private:
QColor modifiedBackground; // as set by: echo -en '\033]11;Color\007
int encoding_no;
NavigationItem* _navigationItem;
ColorSchema* _colorScheme;
static int lastSessionId;
......
/*
This file is part of the Konsole Terminal.
Copyright (C) 2006 Robert Knight <robertknight@gmail.com>
Copyright (C) 2006-2007 Robert Knight <robertknight@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -36,10 +36,12 @@
// Konsole
#include "ViewContainer.h"
#include "ViewProperties.h"
void ViewContainer::addView(QWidget* view) //, NavigationItem* item)
void ViewContainer::addView(QWidget* view , ViewProperties* item)
{
_views << view;
_navigation[view] = item;
connect( view , SIGNAL(destroyed(QObject*)) , this , SLOT( viewDestroyed(QObject*) ) );
......@@ -71,14 +73,14 @@ const QList<QWidget*> ViewContainer::views()
return _views;
}
NavigationItem* ViewContainer::navigationItem( QWidget* widget )
ViewProperties* ViewContainer::viewProperties( QWidget* widget )
{
Q_ASSERT( _navigation.contains(widget) );
return _navigation[widget];
}
QList<QWidget*> ViewContainer::widgetsForItem(NavigationItem* item) const
QList<QWidget*> ViewContainer::widgetsForItem(ViewProperties* item) const
{
return _navigation.keys(item);
}
......@@ -177,10 +179,10 @@ void TabbedViewContainer::prepareColorCells()
void TabbedViewContainer::viewAdded( QWidget* view )
{
// NavigationItem* item = navigationItem(view);
// connect( item , SIGNAL(titleChanged(NavigationItem*)) , this , SLOT(updateTitle(NavigationItem*)));
// connect( item , SIGNAL(iconChanged(NavigationItem*) ) , this ,SLOT(updateIcon(NavigationItem*)));
_tabWidget->addTab( view , "Tab" ); //, item->icon() , item->title() );
ViewProperties* item = viewProperties(view);
connect( item , SIGNAL(titleChanged(ViewProperties*)) , this , SLOT(updateTitle(ViewProperties*)));
connect( item , SIGNAL(iconChanged(ViewProperties*) ) , this ,SLOT(updateIcon(ViewProperties*)));
_tabWidget->addTab( view , item->icon() , item->title() );
}
void TabbedViewContainer::viewRemoved( QWidget* view )
{
......@@ -189,7 +191,7 @@ void TabbedViewContainer::viewRemoved( QWidget* view )
_tabWidget->removeTab( _tabWidget->indexOf(view) );
}
void TabbedViewContainer::updateIcon(NavigationItem* item)
void TabbedViewContainer::updateIcon(ViewProperties* item)
{
kDebug() << __FUNCTION__ << ": icon changed." << endl;
......@@ -198,11 +200,11 @@ void TabbedViewContainer::updateIcon(NavigationItem* item)
while ( itemIter.hasNext() )
{
//int index = _tabWidget->indexOf( itemIter.next() );
// _tabWidget->setTabIcon( index , item->icon() );
int index = _tabWidget->indexOf( itemIter.next() );
_tabWidget->setTabIcon( index , item->icon() );
}
}
void TabbedViewContainer::updateTitle(NavigationItem* item)
void TabbedViewContainer::updateTitle(ViewProperties* item)
{
kDebug() << __FUNCTION__ << ": title changed." << endl;
......@@ -211,8 +213,8 @@ void TabbedViewContainer::updateTitle(NavigationItem* item)
while ( itemIter.hasNext() )
{
//int index = _tabWidget->indexOf( itemIter.next() );
//_tabWidget->setTabText( index , item->title() );
int index = _tabWidget->indexOf( itemIter.next() );
_tabWidget->setTabText( index , item->title() );
}
}
......
......@@ -30,7 +30,7 @@
class QStackedWidget;
class QWidget;