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

Implement session renaming. Work on replacement session settings class.

svn path=/branches/work/konsole-split-view/; revision=657423
parent 1c47b619
......@@ -607,8 +607,11 @@ void Session::setFontNo(int fn)
void Session::setTitle(const QString& title)
{
_title = title;
//kDebug(1211)<<"Session setTitle " << _title <<endl;
if ( title != _title )
{
_title = title;
emit updateTitle();
}
}
const QString& Session::title() const
......
......@@ -2,6 +2,7 @@
// KDE
#include <KAction>
#include <KIcon>
#include <KInputDialog>
#include <KLocale>
#include <KRun>
#include <KToggleAction>
......@@ -236,7 +237,7 @@ void SessionController::setupActions()
// Save Session
action = collection->addAction("save-session");
action->setIcon( KIcon("save") );
action->setIcon( KIcon("document-save") );
action->setText( i18n("&Save Session") );
connect( action , SIGNAL(triggered()) , this , SLOT(saveSession()) );
......@@ -260,6 +261,12 @@ void SessionController::setupActions()
action->setShortcut( QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_V) );
connect( action , SIGNAL(triggered()) , this , SLOT(paste()) );
// Rename Session
action = collection->addAction("rename-session");
action->setText( i18n("&Rename Tab") );
action->setShortcut( QKeySequence(Qt::CTRL+Qt::ALT+Qt::Key_S) );
connect( action , SIGNAL(triggered()) , this , SLOT(renameSession()) );
// Send to All
toggleAction = new KToggleAction(i18n("Send Input to All"),this);
action = collection->addAction("send-input-to-all",toggleAction);
......@@ -390,10 +397,22 @@ void SessionController::showTerminalOptions()
{
EditSessionDialog dialog(_view);
dialog.setSessionType(_session->type());
int result = dialog.exec();
dialog.exec();
}
void SessionController::renameSession()
{
bool ok = false;
const QString& text = KInputDialog::getText( i18n("Rename Tab") ,
i18n("Enter new tab text:") ,
_session->title() ,
&ok );
if ( ok )
_session->setTitle(text);
}
void SessionController::saveSession()
{
Q_ASSERT(0); // not implemented yet
//SaveSessionDialog dialog(_view);
//int result = dialog.exec();
}
......@@ -609,7 +628,7 @@ void SessionController::sessionTitleChanged()
setTitle( _session->title() );
}
void SessionController::showDisplayContextMenu(TerminalDisplay* /*display*/ , int state, int x, int y)
void SessionController::showDisplayContextMenu(TerminalDisplay* /*display*/ , int /*state*/, int x, int y)
{
if ( factory() )
{
......
......@@ -122,6 +122,7 @@ private slots:
void monitorSilence(bool monitor);
void increaseTextSize();
void decreaseTextSize();
void renameSession();
void saveSession();
void sendInputToAll();
......
......@@ -41,6 +41,34 @@
using namespace Konsole;
SessionManager* SessionManager::_instance = 0;
QHash<QString,SessionSettings::Property> SessionSettings::_propertyNames;
QVariant SessionSettings::property(Property property) const
{
return _propertyValues[property];
}
void SessionSettings::setProperty(Property property , const QVariant& value)
{
_propertyValues.insert(property,value);
}
bool SessionSettings::isNameRegistered(const QString& name)
{
return _propertyNames.contains(name);
}
SessionSettings::Property SessionSettings::lookupByName(const QString& name)
{
return _propertyNames[name];
}
QList<QString> SessionSettings::namesForProperty(Property property)
{
return _propertyNames.keys(property);
}
void SessionSettings::registerName(Property property , const QString& name)
{
_propertyNames.insert(name,property);
}
SessionInfo::SessionInfo(const QString& path)
{
......
......@@ -70,7 +70,7 @@ public:
virtual ~SessionSettings() {}
/** Returns the current value of the specified @p property. */
virtual QVariant property(Property property);
virtual QVariant property(Property property) const;
/** Sets the value of the specified @p property to @p value. */
virtual void setProperty(Property property,const QVariant& value);
......@@ -79,11 +79,17 @@ public:
// Convenience methods for property() and setProperty() go here
//
/**
* Returns true if @p name has been associated with an element
* from the Property enum or false otherwise.
*/
static bool isNameRegistered(const QString& name);
/**
* Returns the element from the Property enum associated with the
* specified @p name.
*/
static Property lookupByName(QString name);
static Property lookupByName(const QString& name);
/**
* Returns the string names associated with the specified @p property from
* the Property enum, in the order the associations were created using
......@@ -98,8 +104,9 @@ public:
static void registerName(Property property , const QString& name);
private:
QHash<Property,QVariant> _propertyValues;
static QHash<QString,Property> _propertyNames;
static QHash<Property,QVariant> _propertyValues;
};
/**
......
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