Commit d36b16c6 authored by Robert Knight's avatar Robert Knight
Browse files

Rename Session->Profile is manage profiles dialog. Add tooltips in edit...

Rename Session->Profile is manage profiles dialog.  Add tooltips in edit profile dialog.  Some progress on loading and displaying keyboard bindings.

svn path=/branches/work/konsole-split-view/; revision=661246
parent 544a0811
......@@ -143,6 +143,7 @@ set(konsolepart_PART_SRCS
IncrementalSearchBar.cpp
KeyBindingEditor.cpp
KeyTrans.cpp
KeyboardTranslator.cpp
MainWindow.cpp
Part.cpp
ProcessInfo.cpp
......
......@@ -436,10 +436,11 @@ void EditProfileDialog::setupKeyboardPage(const Profile* info)
const KeyboardTranslator* translator = KeyboardTranslatorManager::instance()->findTranslator(name);
qDebug() << "Translator:" << translator << ", name = " << translator->name();
qDebug() << "Translator:" << translator << ", name = " << translator->name() << "description = " <<
translator->description();
// TODO Use translator->description() here
QStandardItem* item = new QStandardItem(translator->name());
QStandardItem* item = new QStandardItem(translator->description());
item->setData(QVariant::fromValue(translator),Qt::UserRole+1);
item->setFlags( item->flags() | Qt::ItemIsUserCheckable );
......
......@@ -46,7 +46,11 @@
</widget>
</item>
<item row="0" column="1" colspan="2" >
<widget class="QLineEdit" name="profileNameEdit" />
<widget class="QLineEdit" name="profileNameEdit" >
<property name="toolTip" >
<string>A descriptive name for the profile</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_3" >
......@@ -56,7 +60,11 @@
</widget>
</item>
<item row="1" column="1" colspan="2" >
<widget class="KLineEdit" name="commandEdit" />
<widget class="KLineEdit" name="commandEdit" >
<property name="toolTip" >
<string>The command to execute when new terminal sessions are created using this profile</string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_9" >
......@@ -66,10 +74,17 @@
</widget>
</item>
<item row="2" column="1" colspan="2" >
<widget class="KLineEdit" name="initialDirEdit" />
<widget class="KLineEdit" name="initialDirEdit" >
<property name="toolTip" >
<string>The initial working directory for new terminal sessions using this profile</string>
</property>
</widget>
</item>
<item row="2" column="3" >
<widget class="QToolButton" name="dirSelectButton" >
<property name="toolTip" >
<string>Browse for initial directory</string>
</property>
<property name="text" >
<string>...</string>
</property>
......@@ -102,6 +117,9 @@
<height>0</height>
</size>
</property>
<property name="toolTip" >
<string>Select the icon displayed on tabs using this profile</string>
</property>
<property name="text" >
<string/>
</property>
......@@ -143,10 +161,17 @@
</widget>
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="tabTitleEdit" />
<widget class="QLineEdit" name="tabTitleEdit" >
<property name="toolTip" >
<string>Normal tab title format </string>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QPushButton" name="tabTitleEditButton" >
<property name="toolTip" >
<string>Edit normal tab title format</string>
</property>
<property name="text" >
<string>Edit...</string>
</property>
......@@ -160,10 +185,17 @@
</widget>
</item>
<item row="1" column="1" >
<widget class="QLineEdit" name="remoteTabTitleEdit" />
<widget class="QLineEdit" name="remoteTabTitleEdit" >
<property name="toolTip" >
<string>Tab title format used when a remote command (eg. connection to another computer via SSH) is being executed</string>
</property>
</widget>
</item>
<item row="1" column="2" >
<widget class="QPushButton" name="remoteTabTitleEditButton" >
<property name="toolTip" >
<string>Edit tab title format used when executing remote commands</string>
</property>
<property name="text" >
<string>Edit..</string>
</property>
......@@ -183,6 +215,9 @@
<layout class="QVBoxLayout" >
<item>
<widget class="QCheckBox" name="showMenuBarButton" >
<property name="toolTip" >
<string>Show or hide the menu bar in terminal windows using this profile</string>
</property>
<property name="text" >
<string>Show Menu Bar</string>
</property>
......@@ -190,6 +225,9 @@
</item>
<item>
<widget class="QRadioButton" name="alwaysHideTabBarButton" >
<property name="toolTip" >
<string>Never show the tab bar</string>
</property>
<property name="text" >
<string>Always hide tab bar</string>
</property>
......@@ -197,6 +235,9 @@
</item>
<item>
<widget class="QRadioButton" name="autoShowTabBarButton" >
<property name="toolTip" >
<string>Hide or show the tab bar automatically depending on the number of tabs open</string>
</property>
<property name="text" >
<string>Show tab bar when more than one tab is open</string>
</property>
......@@ -204,6 +245,9 @@
</item>
<item>
<widget class="QRadioButton" name="alwaysShowTabBarButton" >
<property name="toolTip" >
<string>Always show the tab bar</string>
</property>
<property name="text" >
<string>Always show tab bar</string>
</property>
......@@ -256,6 +300,9 @@
</item>
<item row="0" column="1" >
<widget class="QPushButton" name="newColorSchemeButton" >
<property name="toolTip" >
<string>Create a new color scheme based upon the selected scheme</string>
</property>
<property name="text" >
<string>New...</string>
</property>
......@@ -263,6 +310,9 @@
</item>
<item row="1" column="1" >
<widget class="QPushButton" name="editColorSchemeButton" >
<property name="toolTip" >
<string>Edit the selected color scheme</string>
</property>
<property name="text" >
<string>Edit...</string>
</property>
......@@ -270,6 +320,9 @@
</item>
<item row="2" column="1" >
<widget class="QPushButton" name="removeColorSchemeButton" >
<property name="toolTip" >
<string>Delete the selected color scheme</string>
</property>
<property name="text" >
<string>Remove</string>
</property>
......@@ -277,6 +330,9 @@
</item>
<item row="3" column="1" >
<widget class="QPushButton" name="selectColorSchemeButton" >
<property name="toolTip" >
<string>Use the selected color scheme for this profile</string>
</property>
<property name="text" >
<string>Select</string>
</property>
......@@ -349,6 +405,9 @@
</item>
<item>
<widget class="QSlider" name="fontSizeSlider" >
<property name="toolTip" >
<string>Adjust the font size used in this profile</string>
</property>
<property name="minimum" >
<number>9</number>
</property>
......@@ -369,6 +428,9 @@
</item>
<item>
<widget class="QPushButton" name="editFontButton" >
<property name="toolTip" >
<string>Change the font used in this profile</string>
</property>
<property name="text" >
<string>Edit Font...</string>
</property>
......@@ -391,6 +453,9 @@
</item>
<item row="0" column="1" >
<widget class="QPushButton" name="newKeyBindingsButton" >
<property name="toolTip" >
<string>Create a new key bindings list based upon the selected bindings</string>
</property>
<property name="text" >
<string>New...</string>
</property>
......@@ -398,6 +463,9 @@
</item>
<item row="1" column="1" >
<widget class="QPushButton" name="editKeyBindingsButton" >
<property name="toolTip" >
<string>Edit the selected key bindings list</string>
</property>
<property name="text" >
<string>Edit...</string>
</property>
......@@ -405,6 +473,9 @@
</item>
<item row="2" column="1" >
<widget class="QPushButton" name="removeKeyBindingsButton" >
<property name="toolTip" >
<string>Delete the selected key bindings list</string>
</property>
<property name="text" >
<string>Remove</string>
</property>
......@@ -412,6 +483,9 @@
</item>
<item row="3" column="1" >
<widget class="QPushButton" name="selectKeyBindingsButton" >
<property name="toolTip" >
<string>Use the selected key bindings list in this profile</string>
</property>
<property name="text" >
<string>Select</string>
</property>
......@@ -448,6 +522,9 @@
<layout class="QVBoxLayout" >
<item>
<widget class="QRadioButton" name="disableScrollbackButton" >
<property name="toolTip" >
<string>Disable scroll bar and do not remember previous output</string>
</property>
<property name="text" >
<string>Disable scrollback</string>
</property>
......@@ -457,6 +534,9 @@
<layout class="QHBoxLayout" >
<item>
<widget class="QRadioButton" name="fixedScrollbackButton" >
<property name="toolTip" >
<string>Limit the remembered output to a fixed number of lines</string>
</property>
<property name="text" >
<string>Fixed number of lines: </string>
</property>
......@@ -464,6 +544,9 @@
</item>
<item>
<widget class="QSpinBox" name="scrollBackLinesSpinner" >
<property name="toolTip" >
<string>Number of lines of output to remember</string>
</property>
<property name="minimum" >
<number>1</number>
</property>
......@@ -489,6 +572,9 @@
</item>
<item>
<widget class="QRadioButton" name="unlimitedScrollbackButton" >
<property name="toolTip" >
<string>Remember all output produced by the terminal</string>
</property>
<property name="text" >
<string>Unlimited scrollback</string>
</property>
......@@ -508,6 +594,9 @@
<layout class="QVBoxLayout" >
<item>
<widget class="QRadioButton" name="scrollBarLeftButton" >
<property name="toolTip" >
<string>Show the scroll bar on the left side of the terminal window</string>
</property>
<property name="text" >
<string>Show on left side</string>
</property>
......@@ -515,6 +604,9 @@
</item>
<item>
<widget class="QRadioButton" name="scrollBarRightButton" >
<property name="toolTip" >
<string>Show the scroll bar on the right side of the terminal window</string>
</property>
<property name="text" >
<string>Show on right side</string>
</property>
......@@ -522,6 +614,9 @@
</item>
<item>
<widget class="QRadioButton" name="scrollBarHiddenButton" >
<property name="toolTip" >
<string>Hide the scroll bar</string>
</property>
<property name="text" >
<string>Hidden</string>
</property>
......@@ -561,6 +656,9 @@
<layout class="QVBoxLayout" >
<item>
<widget class="QCheckBox" name="enableBlinkingTextButton" >
<property name="toolTip" >
<string>Allow terminal programs to create blinking sections of text</string>
</property>
<property name="text" >
<string>Allow blinking text</string>
</property>
......@@ -568,6 +666,9 @@
</item>
<item>
<widget class="QCheckBox" name="enableFlowControlButton" >
<property name="toolTip" >
<string>Allow the output to be suspended by pressing Ctrl+S</string>
</property>
<property name="text" >
<string>Enable flow control using Ctrl+S , Ctrl+Q</string>
</property>
......@@ -575,6 +676,9 @@
</item>
<item>
<widget class="QCheckBox" name="enableResizeWindowButton" >
<property name="toolTip" >
<string>Allow terminal programs to resize the window</string>
</property>
<property name="text" >
<string>Allow programs to resize terminal window</string>
</property>
......@@ -602,7 +706,11 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="wordCharacterEdit" />
<widget class="QLineEdit" name="wordCharacterEdit" >
<property name="toolTip" >
<string>Characters which are considered part of a word when double-clicking to select whole words in the terminal</string>
</property>
</widget>
</item>
</layout>
</item>
......@@ -620,6 +728,9 @@
<layout class="QVBoxLayout" >
<item>
<widget class="QCheckBox" name="enableBlinkingCursorButton" >
<property name="toolTip" >
<string>Make the cursor blink regularly</string>
</property>
<property name="text" >
<string>Blinking cursor</string>
</property>
......@@ -636,6 +747,9 @@
</item>
<item>
<widget class="QComboBox" name="cursorShapeCombo" >
<property name="toolTip" >
<string>Change the shape of the cursor</string>
</property>
<item>
<property name="text" >
<string>Block</string>
......@@ -657,6 +771,9 @@
</item>
<item>
<widget class="QRadioButton" name="autoCursorColorButton" >
<property name="toolTip" >
<string>Set the cursor to match the color of the character underneath it.</string>
</property>
<property name="text" >
<string>Set cursor color to match current character</string>
</property>
......@@ -666,6 +783,9 @@
<layout class="QHBoxLayout" >
<item>
<widget class="QRadioButton" name="customCursorColorButton" >
<property name="toolTip" >
<string>Use a custom, fixed color for the cursor</string>
</property>
<property name="text" >
<string>Custom cursor color:</string>
</property>
......@@ -673,6 +793,9 @@
</item>
<item>
<widget class="KColorButton" name="customColorSelectButton" >
<property name="toolTip" >
<string>Select the color used to draw the cursor</string>
</property>
<property name="text" >
<string/>
</property>
......
......@@ -71,18 +71,21 @@ KeyboardTranslator* KeyBindingEditor::translator() const
void KeyBindingEditor::setupKeyBindingTable(const KeyboardTranslator* translator)
{
QList<const KeyboardTranslator::Entry*> entries = translator->entries();
QList<KeyboardTranslator::Entry> entries = translator->entries();
_ui->keyBindingTable->setRowCount(entries.count());
qDebug() << "Keyboard translator has" << entries.count() << "entries.";
for ( int row = 0 ; row < entries.count() ; row++ )
{
const KeyboardTranslator::Entry* entry = entries.at(row);
const KeyboardTranslator::Entry& entry = entries.at(row);
QTableWidgetItem* keyItem = new QTableWidgetItem(QString::number(entry->keyCode()));
QTableWidgetItem* textItem = new QTableWidgetItem(entry->text());
QTableWidgetItem* keyItem = new QTableWidgetItem(entry.keySequence().toString());
QTableWidgetItem* textItem = new QTableWidgetItem(QString(entry.text()));
_ui->keyBindingTable->setItem(row,0,keyItem);
_ui->keyBindingTable->setItem(row,1,textItem);
}
_ui->keyBindingTable->sortItems(0);
}
#include "KeyBindingEditor.moc"
......
......@@ -25,6 +25,7 @@
// Qt
#include <QFile>
#include <QFileInfo>
#include <QKeySequence>
#include <QTextStream>
#include <QtDebug>
......@@ -87,10 +88,11 @@ KeyboardTranslator* KeyboardTranslatorManager::loadTranslator(const QString& nam
const QString& path = findTranslatorPath(name);
QFile source(path); // TODO get correct path here
QFile source(path);
source.open(QIODevice::ReadOnly);
KeyboardTranslatorReader reader(&source);
translator->setDescription( reader.description() );
while ( reader.hasNextEntry() )
translator->addEntry(reader.nextEntry());
......@@ -127,7 +129,248 @@ KeyboardTranslator* KeyboardTranslatorManager::loadTranslator(const QString& nam
// already been removed)
//
KeyboardTranslatorReader::KeyboardTranslatorReader( QIODevice* source )
: _source(source)
, _hasNext(false)
{
// read input until we find the description
while ( _description.isEmpty() && !source->atEnd() )
{
const QList<Token>& tokens = tokenize( QString(source->readLine()) );
if ( !tokens.isEmpty() && tokens.first().type == Token::TitleKeyword )
{
qDebug() << "Found description: " << tokens[1].text;
_description = tokens[1].text;
}
}
readNext();
}
void KeyboardTranslatorReader::readNext()
{
// find next entry
while ( !_source->atEnd() )
{
const QList<Token>& tokens = tokenize( QString(_source->readLine()) );
if ( !tokens.isEmpty() && tokens.first().type == Token::KeyKeyword )
{
KeyboardTranslator::State flags = KeyboardTranslator::NoState;
QKeySequence sequence = decodeSequence(tokens[1].text,flags);
qDebug() << sequence << ", count:" << sequence.count() << " text = " << tokens[1].text;
int keyCode = Qt::Key_unknown;
int modifiers = Qt::NoModifier;
QByteArray text;
KeyboardTranslator::Command command = KeyboardTranslator::NoCommand;
// get keycode and modifiers
if ( sequence.count() == 1 )
{
int code = sequence[0];
if ( code & Qt::SHIFT )
modifiers |= Qt::ShiftModifier;
if ( code & Qt::CTRL )
modifiers |= Qt::ControlModifier;
if ( code & Qt::ALT )
modifiers |= Qt::AltModifier;
if ( code & Qt::META )
modifiers |= Qt::MetaModifier;
keyCode = code & ~Qt::SHIFT & ~Qt::CTRL & ~Qt::ALT & ~Qt::META;
}
// get text or command
if ( tokens[2].type == Token::OutputText )
{
qDebug() << "Setting text of length: " << tokens[2].text.length();
text = tokens[2].text.toLocal8Bit();
}
else if ( tokens[2].type == Token::Command )
{
// identify command
if ( tokens[2].text.compare("scrollpageup",Qt::CaseInsensitive) == 0 )
command = KeyboardTranslator::ScrollPageUpCommand;
else if ( tokens[2].text.compare("scrollpagedown",Qt::CaseInsensitive) == 0 )
command = KeyboardTranslator::ScrollPageDownCommand;
else if ( tokens[2].text.compare("scrolllineup",Qt::CaseInsensitive) == 0 )
command = KeyboardTranslator::ScrollLineUpCommand;
else if ( tokens[2].text.compare("scrolllinedown",Qt::CaseInsensitive) == 0 )
command = KeyboardTranslator::ScrollLineDownCommand;
else if ( tokens[2].text.compare("scrolllock",Qt::CaseInsensitive) == 0 )
command = KeyboardTranslator::ScrollLockCommand;
else
qDebug() << "Command not understood:" << tokens[2].text;
qDebug() << "No text";
}
qDebug() << "About to create entry";
_nextEntry = KeyboardTranslator::Entry(keyCode,(Qt::KeyboardModifier)modifiers,flags,text,command);
qDebug() << "Created new entry";
_hasNext = true;
return;
}
}
_hasNext = false;
}
QKeySequence KeyboardTranslatorReader::decodeSequence(const QString& text , KeyboardTranslator::State& stateFlags )
{
int state = KeyboardTranslator::NoState;
stateFlags = (KeyboardTranslator::State)state;
QKeySequence sequence = QKeySequence::fromString(text);
if ( sequence.count() > 0 )
return sequence;
// if the sequence is empty, it failed to decode properly
// this can happen if the file was produced by a KDE 3 version
// of Konsole
//
// possible reasons:
// - Key sequence includes names not known to Qt
// ( eg "Ansi" , "NewLine" )
// - Key sequence has modifiers at the end of the line ( eg "F10+Shift" )
// instead of at the start, which QKeySequence requires
// - Use of '-' in front of modifiers to indicate that they are
// not required
int modifiers = Qt::NoModifier;
// first pass
// rearrange modifers and try decoding again
if ( text.contains("+shift",Qt::CaseInsensitive) )
modifiers |= Qt::ShiftModifier;
if ( text.contains("+ctrl",Qt::CaseInsensitive) )
modifiers |= Qt::ControlModifier;
if ( text.contains("+control",Qt::CaseInsensitive) )
modifiers |= Qt::ControlModifier;
if ( text.contains("+alt",Qt::CaseInsensitive) )
modifiers |= Qt::AltModifier;
if ( text.contains("+meta",Qt::CaseInsensitive) )
modifiers |= Qt::MetaModifier;
if ( text.contains("+ansi",Qt::CaseInsensitive) )
state |= KeyboardTranslator::AnsiState;
if ( text.contains("+appcukeys",Qt::CaseInsensitive) )
state |= KeyboardTranslator::CursorKeysState;
if ( text.contains("+newline",Qt::CaseInsensitive) )
state |= KeyboardTranslator::NewLineState;
static QRegExp modifierRemover("((\\+|\\-)shift|"
"(\\+|\\-)ctrl|"
"(\\+|\\-)control|"
"(\\+|\\-)alt|"
"(\\+|\\-)ansi|"
"(\\+|\\-)appcukeys|"
"(\\+|\\-)newline|"
"(\\+|\\-)meta)",Qt::CaseInsensitive);
QString newText(text);
newText.replace(modifierRemover,QString::null);
if ( modifiers & Qt::ShiftModifier )
newText.prepend("shift+");
if ( modifiers & Qt::ControlModifier )
newText.prepend("ctrl+");
if ( modifiers & Qt::AltModifier )
newText.prepend("alt+");
if ( modifiers & Qt::MetaModifier )
newText.prepend("meta+");
qDebug() << "modifier: " << newText;
sequence = QKeySequence::fromString(newText);
qDebug() << "after: " << sequence;
stateFlags = (KeyboardTranslator::State)state;
return sequence;
}
QString KeyboardTranslatorReader::description() const
{
return _description;
}
bool KeyboardTranslatorReader::hasNextEntry()
{
return _hasNext;
}
KeyboardTranslator::Entry KeyboardTranslatorReader::nextEntry()
{
Q_ASSERT( _hasNext );
qDebug() << "About to return entry";
KeyboardTranslator::Entry entry = _nextEntry;
readNext();
return entry;
}
bool KeyboardTranslatorReader::parseError()
{
return false;
}
QList<KeyboardTranslatorReader::Token> KeyboardTranslatorReader::tokenize(const QString& line)
{