Commit 389ea8fa authored by Robert Knight's avatar Robert Knight

Add a dialog to help the user edit the tab title format entry in the edit profile dialog.

svn path=/branches/work/konsole-split-view/; revision=659647
parent 933f433c
......@@ -58,6 +58,7 @@ set(konsole_KDEINIT_SRCS
BlockArray.cpp
ColorScheme.cpp
EditProfileDialog.cpp
EditTabTitleFormatDialog.cpp
Filter.cpp
HistorySizeDialog.cpp
IncrementalSearchBar.cpp
......@@ -96,6 +97,7 @@ set(konsole_KDEINIT_SRCS
kde4_add_ui_files(konsole_KDEINIT_SRCS
EditProfileDialog.ui
EditTabTitleFormatDialog.ui
ManageProfilesDialog.ui
RemoteConnectionDialog.ui
)
......@@ -128,6 +130,7 @@ set(konsolepart_PART_SRCS
BookmarkHandler.cpp
ColorScheme.cpp
EditProfileDialog.cpp
EditTabTitleFormatDialog.cpp
Emulation.cpp
Filter.cpp
History.cpp
......
......@@ -33,6 +33,7 @@
#include "ColorScheme.h"
#include "ui_EditProfileDialog.h"
#include "EditProfileDialog.h"
#include "EditTabTitleFormatDialog.h"
#include "SessionManager.h"
#include "ShellCommand.h"
......@@ -106,6 +107,32 @@ void EditProfileDialog::setupGeneralPage(const Profile* info)
SLOT(tabTitleFormatChanged(const QString&)) );
connect(_ui->remoteTabTitleEdit , SIGNAL(textChanged(const QString&)) , this ,
SLOT(remoteTabTitleFormatChanged(const QString&)));
connect(_ui->tabTitleEditButton , SIGNAL(clicked()) , this ,
SLOT(editTabTitle()) );
connect(_ui->remoteTabTitleEditButton , SIGNAL(clicked()) , this ,
SLOT(editRemoteTabTitle()) );
}
void EditProfileDialog::editTabTitle()
{
EditTabTitleFormatDialog dialog(this);
dialog.setContext(Session::LocalTabTitle);
dialog.setTabTitleFormat(_ui->tabTitleEdit->text());
if ( dialog.exec() == QDialog::Accepted )
{
_ui->tabTitleEdit->setText(dialog.tabTitleFormat());
}
}
void EditProfileDialog::editRemoteTabTitle()
{
EditTabTitleFormatDialog dialog(this);
dialog.setContext(Session::RemoteTabTitle);
dialog.setTabTitleFormat(_ui->remoteTabTitleEdit->text());
if ( dialog.exec() == QDialog::Accepted )
{
_ui->remoteTabTitleEdit->setText(dialog.tabTitleFormat());
}
}
void EditProfileDialog::tabTitleFormatChanged(const QString& format)
{
......
......@@ -76,6 +76,9 @@ private slots:
void tabTitleFormatChanged(const QString& text);
void remoteTabTitleFormatChanged(const QString& text);
void editTabTitle();
void editRemoteTabTitle();
// appearence page
void setFontSize(int pointSize);
void showFontDialog();
......
/*
Copyright (C) 2007 by 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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
*/
// KDE
#include <KLocale>
// Konsole
#include "EditTabTitleFormatDialog.h"
#include "ui_EditTabTitleFormatDialog.h"
using namespace Konsole;
const EditTabTitleFormatDialog::Element EditTabTitleFormatDialog::_localElements[] =
{
{ "%n" , i18n("Program Name") },
{ "%p" , i18n("Profile Name") },
{ "%d" , i18n("Current Directory (Short)") },
{ "%D" , i18n("Current Directory (Long)") }
};
const int EditTabTitleFormatDialog::_localElementCount = 4;
const EditTabTitleFormatDialog::Element EditTabTitleFormatDialog::_remoteElements[] =
{
{ "%p" , i18n("Profile Name") },
{ "%u" , i18n("User Name") },
{ "%h" , i18n("Remote Host") }
};
const int EditTabTitleFormatDialog::_remoteElementCount = 3;
EditTabTitleFormatDialog::EditTabTitleFormatDialog(QWidget* parent)
: KDialog(parent)
, _context(Session::LocalTabTitle)
{
setCaption(i18n("Edit Tab Title Format"));
_ui = new Ui::EditTabTitleFormatDialog();
_ui->setupUi(mainWidget());
connect( _ui->elementComboBox , SIGNAL(activated(int)) , this , SLOT(insertElement(int)) );
}
EditTabTitleFormatDialog::~EditTabTitleFormatDialog()
{
delete _ui;
}
void EditTabTitleFormatDialog::insertElement(int index)
{
if ( _context == Session::LocalTabTitle )
_ui->tabTitleFormatEdit->insert( _localElements[index].element );
else if ( _context == Session::RemoteTabTitle )
_ui->tabTitleFormatEdit->insert( _remoteElements[index].element );
}
void EditTabTitleFormatDialog::setTabTitleFormat(const QString& format)
{
_ui->tabTitleFormatEdit->setText(format);
}
QString EditTabTitleFormatDialog::tabTitleFormat() const
{
return _ui->tabTitleFormatEdit->text();
}
void EditTabTitleFormatDialog::setContext(Session::TabTitleContext context)
{
_context = context;
_ui->elementComboBox->clear();
QStringList list;
if ( context == Session::LocalTabTitle )
{
for ( int i = 0 ; i < _localElementCount ; i++ )
list << _localElements[i].description;
}
else if ( context == Session::RemoteTabTitle )
{
for ( int i = 0 ; i < _remoteElementCount ; i++ )
list << _remoteElements[i].description;
}
_ui->elementComboBox->addItems( list );
}
#include "EditTabTitleFormatDialog.moc"
/*
Copyright (C) 2007 by 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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
*/
#ifndef EDITTABTITLEFORMATDIALOG_H
#define EDITTABTITLEFORMATDIALOG_H
// KDE
#include <KDialog>
// Konsole
#include "Session.h"
namespace Ui
{
class EditTabTitleFormatDialog;
};
namespace Konsole
{
class EditTabTitleFormatDialog : public KDialog
{
Q_OBJECT
public:
EditTabTitleFormatDialog(QWidget* parent = 0);
virtual ~EditTabTitleFormatDialog();
void setContext(Session::TabTitleContext context);
void setTabTitleFormat(const QString& format);
QString tabTitleFormat() const;
private slots:
void insertElement(int index);
private:
Ui::EditTabTitleFormatDialog* _ui;
Session::TabTitleContext _context;
struct Element
{
QString element;
QString description;
};
static const Element _localElements[];
static const int _localElementCount;
static const Element _remoteElements[];
static const int _remoteElementCount;
};
};
#endif // EDITTABTITLEFORMATDIALOG_H
<ui version="4.0" >
<class>EditTabTitleFormatDialog</class>
<widget class="QWidget" name="EditTabTitleFormatDialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>138</height>
</rect>
</property>
<property name="windowTitle" >
<string>Edit Tab Format</string>
</property>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item row="1" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Insert element:</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QComboBox" name="elementComboBox" />
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Tab title format:</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QLineEdit" name="tabTitleFormatEdit" />
</item>
<item row="0" column="0" colspan="2" >
<widget class="QLabel" name="label_3" >
<property name="minimumSize" >
<size>
<width>380</width>
<height>0</height>
</size>
</property>
<property name="text" >
<string>Tab titles can contain a mixture of text and dynamic elements which update automatically as the programs running in the terminal change.</string>
</property>
<property name="wordWrap" >
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
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