Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 42dce037 authored by Robert Knight's avatar Robert Knight

Changes:

* Add a passive warning widget which is displayed when a color scheme is selected which 
  uses transparency but the system does not support transparency 
* Always show the vertical scroll bar in the color scheme list
* Remove quotes around links and email addresses in mouse-over tooltip

Bug Fixes:

* Fix a few odd behaviours with the live color scheme preview
* Fix the 'Show in Menu' status of newly added profiles not being
  saved when Konsole exits.

  ( Update Profile's path property when saving the profile to 
    a new location )


Internal: 

* Removed many debugging statements and dead / commented out code
* Fix several unused parameter warnings
* API documentation corrections in Emulation class

svn path=/trunk/KDE/kdebase/apps/konsole/; revision=706986
parent 38458e79
......@@ -82,8 +82,6 @@ EditProfileDialog::EditProfileDialog(QWidget* parent)
SLOT(preparePage(int)) );
_tempProfile = new Profile;
qDebug() << "Is modal = " << isModal();
}
EditProfileDialog::~EditProfileDialog()
{
......@@ -352,7 +350,6 @@ void EditProfileDialog::commandChanged(const QString& command)
{
ShellCommand shellCommand(command);
//TODO Split into command and arguments
_tempProfile->setProperty(Profile::Command,shellCommand.command());
_tempProfile->setProperty(Profile::Arguments,shellCommand.arguments());
}
......@@ -376,13 +373,15 @@ void EditProfileDialog::setupAppearancePage(const Profile* info)
connect( _colorSchemeAnimationTimeLine , SIGNAL(valueChanged(qreal)) , this ,
SLOT(colorSchemeAnimationUpdate()) );
_ui->transparencyWarningWidget->setVisible(false);
// setup color list
updateColorSchemeList(true);
_ui->colorSchemeList->setMouseTracking(true);
_ui->colorSchemeList->installEventFilter(this);
_ui->colorSchemeList->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
connect( _ui->colorSchemeList->selectionModel() ,
SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&))
......@@ -442,8 +441,8 @@ void EditProfileDialog::updateColorSchemeList(bool selectCurrentScheme)
item->setFlags( item->flags() );
if ( currentScheme == colors )
selectedItem = item;
selectedItem = item;
model->appendRow(item);
}
......@@ -458,6 +457,9 @@ void EditProfileDialog::updateColorSchemeList(bool selectCurrentScheme)
_ui->colorSchemeList->updateGeometry();
_ui->colorSchemeList->selectionModel()->setCurrentIndex( selectedItem->index() ,
QItemSelectionModel::Select );
// update transparency warning label
updateTransparencyWarning();
}
}
void EditProfileDialog::updateKeyBindingsList(bool selectCurrentTranslator)
......@@ -471,8 +473,6 @@ void EditProfileDialog::updateKeyBindingsList(bool selectCurrentTranslator)
const KeyboardTranslator* currentTranslator = keyManager->findTranslator(name);
qDebug() << "Current translator = " << currentTranslator << ", name: " << name;
QStandardItemModel* model = new QStandardItemModel(this);
QStandardItem* selectedItem = 0;
......@@ -485,11 +485,6 @@ void EditProfileDialog::updateKeyBindingsList(bool selectCurrentTranslator)
const KeyboardTranslator* translator = keyManager->findTranslator(name);
qDebug() << "Translator:" << translator << ", name = " <<
translator->name() << "description = " <<
translator->description();
// TODO Use translator->description() here
QStandardItem* item = new QStandardItem(translator->description());
item->setData(QVariant::fromValue(translator),Qt::UserRole+1);
item->setIcon( KIcon("keyboard") );
......@@ -525,8 +520,6 @@ bool EditProfileDialog::eventFilter( QObject* watched , QEvent* event )
}
void EditProfileDialog::unpreviewAll()
{
//qDebug() << "unpreviewing";
QHash<Profile::Property,QVariant> map;
QHashIterator<int,QVariant> iter(_previewedProperties);
while ( iter.hasNext() )
......@@ -617,19 +610,9 @@ void EditProfileDialog::showColorSchemeEditor(bool isNewScheme)
ColorSchemeManager::instance()->addColorScheme( newScheme );
updateColorSchemeList();
const Profile* profile = lookupProfile();
const QString& currentScheme = profile->colorScheme();
updateColorSchemeList(true);
// the next couple of lines may seem slightly odd,
// but they force any open views based on the current profile
// to update their color schemes
if ( newScheme->name() == currentScheme )
{
_tempProfile->setProperty(Profile::ColorScheme,newScheme->name());
preview(Profile::ColorScheme,newScheme->name());
}
preview(Profile::ColorScheme,newScheme->name());
}
}
void EditProfileDialog::newColorScheme()
......@@ -650,12 +633,24 @@ void EditProfileDialog::colorSchemeSelected()
const ColorScheme* colors = model->data(selected.first(),Qt::UserRole+1).value<const ColorScheme*>();
_tempProfile->setProperty(Profile::ColorScheme,colors->name());
updateTransparencyWarning();
}
}
void EditProfileDialog::updateTransparencyWarning()
{
// zero or one indexes can be selected
foreach( const QModelIndex& index , _ui->colorSchemeList->selectionModel()->selectedIndexes() )
{
bool hasTransparency = index.data(Qt::UserRole+1).value<const ColorScheme*>()->opacity() < 1.0;
_ui->transparencyWarningWidget->setHidden(KWindowSystem::compositingActive() || !hasTransparency);
_ui->transparencyWarningIcon->setPixmap( KIcon("dialog-warning").pixmap(QSize(48,48)) );
}
}
void EditProfileDialog::setupKeyboardPage(const Profile* info)
void EditProfileDialog::setupKeyboardPage(const Profile* /* info */)
{
// setup translator list
updateKeyBindingsList(true);
connect( _ui->keyBindingList->selectionModel() ,
......@@ -730,9 +725,6 @@ void EditProfileDialog::showKeyBindingEditor(bool isNewTranslator)
if ( isNewTranslator )
newTranslator->setName(newTranslator->description());
qDebug() << "Adding new or modified translator to manager" <<
newTranslator->name() << ", " << newTranslator->description();
KeyboardTranslatorManager::instance()->addTranslator( newTranslator );
updateKeyBindingsList();
......@@ -931,7 +923,6 @@ void EditProfileDialog::toggleResizeWindow(bool enable)
}
void EditProfileDialog::fontSelected(const QFont& font)
{
//qDebug() << "font selected";
QSlider* slider = _ui->fontSizeSlider;
_ui->fontSizeSlider->setRange( qMin(slider->minimum(),font.pointSize()) ,
......@@ -1108,29 +1099,4 @@ QSize ColorSchemeViewDelegate::sizeHint( const QStyleOptionViewItem& option,
return QSize(width,(int)heightForWidth);
}
/*bool ColorSchemeViewDelegate::editorEvent(QEvent* event,QAbstractItemModel* model,
const QStyleOptionViewItem& option, const QModelIndex& index)
{
qDebug() << "event: " << event->type() << " at row " << index.row() << " column " <<
index.column();
return false;
}*/
KeyBindingViewDelegate::KeyBindingViewDelegate(QObject* parent)
: QAbstractItemDelegate(parent)
{
}
void KeyBindingViewDelegate::paint(QPainter* /*painter*/,
const QStyleOptionViewItem& /*option*/,
const QModelIndex& /*index*/) const
{
}
QSize KeyBindingViewDelegate::sizeHint( const QStyleOptionViewItem& /*option*/,
const QModelIndex& /*index*/) const
{
// temporary
return QSize(100,100);
}
#include "EditProfileDialog.moc"
......@@ -188,6 +188,8 @@ private:
void updateCaption(const QString& profileName);
void updateTransparencyWarning();
struct RadioOption
{
QAbstractButton* button;
......@@ -248,27 +250,6 @@ public:
private:
QPointer<QTimeLine> _entryTimeLine;
// virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,
// const QModelIndex& index) const;
// virtual bool editorEvent(QEvent* event,QAbstractItemModel* model,
// const QStyleOptionViewItem& option, const QModelIndex& index);
};
/**
* A delegate which can display and edit key bindings in a view.
*/
class KeyBindingViewDelegate : public QAbstractItemDelegate
{
public:
KeyBindingViewDelegate(QObject* parent = 0);
// reimplemented
virtual void paint(QPainter* painter, const QStyleOptionViewItem& option,
const QModelIndex& index) const;
virtual QSize sizeHint( const QStyleOptionViewItem& option,
const QModelIndex& index) const;
};
}
......
......@@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>441</width>
<height>505</height>
<height>485</height>
</rect>
</property>
<layout class="QHBoxLayout" >
......@@ -362,7 +362,7 @@
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
<height>10</height>
</size>
</property>
</spacer>
......@@ -443,12 +443,59 @@
</property>
<property name="sizeHint" >
<size>
<width>75</width>
<height>201</height>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="0" >
<widget class="QWidget" native="1" name="transparencyWarningWidget" >
<property name="autoFillBackground" >
<bool>false</bool>
</property>
<property name="styleSheet" >
<string>* { background-color: #FFCCCC ; border-radius: 3px }</string>
</property>
<layout class="QHBoxLayout" >
<property name="leftMargin" >
<number>4</number>
</property>
<property name="topMargin" >
<number>4</number>
</property>
<property name="rightMargin" >
<number>4</number>
</property>
<property name="bottomMargin" >
<number>4</number>
</property>
<item>
<widget class="QLabel" name="transparencyWarningIcon" >
<property name="styleSheet" >
<string/>
</property>
<property name="text" >
<string>TextLabel</string>
</property>
<property name="alignment" >
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="transparencyWarningLabel" >
<property name="text" >
<string>This colour scheme has a transparent background which does not appear to be supported on your desktop.</string>
</property>
<property name="wordWrap" >
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
......@@ -612,7 +659,7 @@
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<width>20</width>
<height>20</height>
</size>
</property>
......@@ -707,7 +754,7 @@
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
<height>20</height>
</size>
</property>
</spacer>
......@@ -795,8 +842,8 @@
</property>
<property name="sizeHint" >
<size>
<width>71</width>
<height>101</height>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
......
......@@ -183,9 +183,9 @@ void Emulation::setCodec(EmulationCodec codec)
setCodec( QTextCodec::codecForLocale() );
}
void Emulation::setKeyBindings(const QString &id)
void Emulation::setKeyBindings(const QString& name)
{
_keyTranslator = KeyboardTranslatorManager::instance()->findTranslator(id);
_keyTranslator = KeyboardTranslatorManager::instance()->findTranslator(name);
}
QString Emulation::keyBindings()
......
......@@ -88,7 +88,7 @@ enum
* output. Each screen window covers the same number of lines and columns as the
* image size returned by imageSize(). The screen window can be moved up and down
* and provides transparent access to both the current on-screen image and the
* previous output. The screen windows emit and outputChanged signal
* previous output. The screen windows emit an outputChanged signal
* when the section of the image they are looking at changes.
* Graphical views can then render the contents of a screen window, listening for notifications
* of output changes from the screen window which they are associated with and updating
......@@ -191,9 +191,9 @@ public:
* ( received through sendKeyEvent() ) into character
* streams to send to the terminal.
*/
void setKeyBindings(const QString &id);
void setKeyBindings(const QString& name);
/**
* Returns the emulation's current key bindings.
* Returns the name of the emulation's current key bindings.
* See setKeyBindings()
*/
QString keyBindings();
......@@ -222,19 +222,19 @@ public slots:
/**
* Interprets a sequence of characters and sends the result to the terminal.
* This is equivalent to calling onKeyPress for each character in @p text in succession.
* This is equivalent to calling sendKeyEvent() for each character in @p text in succession.
*/
virtual void sendText(const QString& text) = 0;
/**
* Interprets a key press event and emits the sendString() signal with
* Interprets a key press event and emits the sendData() signal with
* the resulting character stream.
*/
virtual void sendKeyEvent(QKeyEvent*);
/**
* Converts information about a mouse event into an xterm-compatible escape
* sequence and emits the character sequence via sendString()
* sequence and emits the character sequence via sendData()
*/
virtual void sendMouseEvent(int buttons, int column, int line, int eventType);
......@@ -247,8 +247,19 @@ public slots:
*/
virtual void sendString(const char* string, int length = -1) = 0;
/** Processes an incoming block of text. */
void receiveData(const char* txt,int len);
/**
* Processes an incoming stream of characters. receiveData() decodes the incoming
* character buffer using the current codec(), and then calls receiveChar() for
* each unicode character in the resulting buffer.
*
* receiveData() also starts a timer which causes the outputChanged() signal
* to be emitted when it expires. The timer allows multiple updates in quick
* succession to be buffered into a single outputChanged() signal emission.
*
* @param buffer A string of characters received from the terminal program.
* @param len The length of @p buffer
*/
void receiveData(const char* buffer,int len);
signals:
......@@ -339,18 +350,21 @@ signals:
* the user-title of the session.
*
* @param title Specifies what to change.
* 0 - Set window icon text and session title to @p newTitle
* 1 - Set window icon text to @p newTitle
* 2 - Set session title to @p newTitle
* 11 - Set the session's default background color to @p newTitle,
* <ul>
* <li>0 - Set window icon text and session title to @p newTitle</li>
* <li>1 - Set window icon text to @p newTitle</li>
* <li>2 - Set session title to @p newTitle</li>
* <li>11 - Set the session's default background color to @p newTitle,
* where @p newTitle can be an HTML-style string (#RRGGBB) or a named
* color (eg 'red', 'blue').
* See http://doc.trolltech.com/4.2/qcolor.html#setNamedColor for more
* details.
* 31 - Supposedly treats @p newTitle as a URL and opens it (NOT IMPLEMENTED)
* 32 - Sets the icon associated with the session. @p newTitle is the name
* </li>
* <li>31 - Supposedly treats @p newTitle as a URL and opens it (NOT IMPLEMENTED)</li>
* <li>32 - Sets the icon associated with the session. @p newTitle is the name
* of the icon to use, which can be the name of any icon in the current KDE icon
* theme (eg: 'konsole', 'kate', 'folder_home')
* theme (eg: 'konsole', 'kate', 'folder_home')</li>
* </ul>
* @param newTitle Specifies the new title
*/
......@@ -363,10 +377,15 @@ signals:
void imageSizeChanged(int lineCount , int columnCount);
/**
* Emitted when the terminal program emits a profile change
* command sequence
* Emitted when the terminal program requests to change various properties
* of the terminal display.
*
* A profile change command occurs when a special escape sequence, followed
* by a string containing a series of name and value pairs is received.
* This string can be parsed using a ProfileCommandParser instance.
*
* @param text The text of the command
* @param text A string expected to contain a series of key and value pairs in
* the form: name=value;name2=value2 ...
*/
void profileChangeCommandReceived(const QString& text);
......@@ -375,13 +394,15 @@ protected:
virtual void resetMode(int mode) = 0;
/**
* Processes an incoming character. See onReceiveBlock()
* Processes an incoming character. See receiveData()
* @p ch A unicode character code.
*/
virtual void receiveChar(int ch);
/**
* Sets the active screen
* Sets the active screen. The terminal has two screens, primary and alternate.
* The primary screen is used by default. When certain interactive programs such
* as Vim are run, they trigger a switch to the alternate screen.
*
* @param index 0 to switch to the primary screen, or 1 to switch to the alternate screen
*/
......
......@@ -431,9 +431,9 @@ QString UrlFilter::HotSpot::tooltip() const
const UrlType kind = urlType();
if ( kind == StandardUrl )
return i18n("Click to open '%1' in your browser.",url);
return i18n("Click to open %1 in your browser.",url);
else if ( kind == Email )
return i18n("Click to send an email to '%1'.",url);
return i18n("Click to send an email to %1.",url);
else
return QString();
}
......
......@@ -282,11 +282,6 @@ void KeyboardTranslatorReader::readNext()
_nextEntry = newEntry;
//qDebug() << "Any modifier state: " << (int)(flags & KeyboardTranslator::AnyModifierState);
//qDebug() << "Any modifier mask: " << (int)(flagMask & KeyboardTranslator::AnyModifierState);
// qDebug() << "Parsed entry:" << _nextEntry.conditionToString();
_hasNext = true;
return;
......@@ -312,8 +307,6 @@ bool KeyboardTranslatorReader::decodeSequence(const QString& text,
KeyboardTranslator::States tempFlags = flags;
KeyboardTranslator::States tempFlagMask = flagMask;
// qDebug() << "Input text:" << text;
for ( int i = 0 ; i < text.count() ; i++ )
{
const QChar& ch = text[i];
......@@ -341,16 +334,6 @@ bool KeyboardTranslatorReader::decodeSequence(const QString& text,
}
else if ( parseAsStateFlag(buffer,itemFlag) )
{
#if 0
if ( itemFlag == KeyboardTranslator::AnyModifierState )
{
qDebug() << "Flag mask: " << (int)(tempFlagMask & KeyboardTranslator::AnyModifierState);
qDebug() << "Flags: " << (int)(tempFlags & KeyboardTranslator::AnyModifierState);
qDebug() << "Wanted: " << isWanted;
}
#endif
tempFlagMask |= itemFlag;
if ( isWanted )
......@@ -435,80 +418,6 @@ bool KeyboardTranslatorReader::parseAsKeyCode(const QString& item , int& keyCode
return true;
}
#if 0
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());
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;
}
#endif
QString KeyboardTranslatorReader::description() const
{
return _description;
......@@ -572,11 +481,8 @@ QList<KeyboardTranslatorReader::Token> KeyboardTranslatorReader::tokenize(const
QList<Token> list;
// qDebug() << "line: " << text;
if ( text.isEmpty() || comment.exactMatch(text) )
{
// qDebug() << "This is a comment";
return list;
}
......@@ -635,24 +541,6 @@ KeyboardTranslator::Entry::Entry()
{
}
#if 0
QKeySequence KeyboardTranslator::Entry::keySequence() const
{
int code = _keyCode;
if ( _modifiers & Qt::AltModifier )
code += Qt::ALT;
if ( _modifiers & Qt::ControlModifier )
code += Qt::CTRL;
if ( _modifiers & Qt::ShiftModifier )
code += Qt::SHIFT;
if ( _modifiers & Qt::MetaModifier )
code += Qt::META;
return QKeySequence(code);
}
#endif
bool KeyboardTranslator::Entry::operator==(const Entry& rhs) const
{
return _keyCode == rhs._keyCode &&
......@@ -668,20 +556,12 @@ bool KeyboardTranslator::Entry::matches(int keyCode ,
Qt::KeyboardModifiers modifiers,
States state) const
{
//qDebug() << "Checking for match" << conditionToString();
//qDebug() << "Checking entry. test key code = " << keyCode << " entry key code =" << _keyCode;
if ( _keyCode != keyCode )
return false;
//qDebug() << "Checking modifiers";
if ( (modifiers & _modifierMask) != (_modifiers & _modifierMask) )
return false;
//qDebug() << "Checking state";
// if modifiers is non-zero, the 'any modifier' state is implicit
if ( modifiers != 0 )
state |= AnyModifierState;
......@@ -689,8 +569,6 @@ bool KeyboardTranslator::Entry::matches(int keyCode ,
if ( (state & _stateMask) != (_state & _stateMask) )
return false;
//qDebug() << "Checking any mod state";
// special handling for the 'Any Modifier' state, which checks for the presence of
// any or no modifiers
if ( _stateMask & KeyboardTranslator::AnyModifierState )
......@@ -704,8 +582,6 @@ bool KeyboardTranslator::Entry::matches(int keyCode ,
return false;
}
//qDebug() << "Entry matches" << conditionToString();
return true;
}
QByteArray KeyboardTranslator::Entry::escapedText() const
......@@ -790,11 +666,7 @@ QByteArray KeyboardTranslator::Entry::unescape(const QByteArray& input) const
result.replace(i,charsToRemove,replacement);
}
}
//qDebug() << "Unescaped" << input;
//for ( int i = 0 ; i < result.count() ; i++ )
// qDebug() << (int)result[i] << ";" << result[i];
return result;
}
......@@ -880,16 +752,6 @@ KeyboardTranslator::KeyboardTranslator(const QString& name)
{
}
#if 0
KeyboardTranslator::KeyboardTranslator(const KeyboardTranslator& other)
: _name(other._name)
{
_description = other._description;
// TODO: Copy keyboard entries
}
#endif
void KeyboardTranslator::setDescription(const QString& description)
{
_description = description;
......@@ -929,17 +791,10 @@ void KeyboardTranslator::removeEntry(const Entry& entry)
}
KeyboardTranslator::Entry KeyboardTranslator::findEntry(int keyCode, Qt::KeyboardModifiers modifiers, States state) const
{
// qDebug() << "Searching for entry for key code =" << keyCode << ", modifiers =" << modifiers;
// printf("modifiers in hex %x\n",(int)modifiers);
//qDebug() << "Translator keys, count: " << _entries.count() << _entries.keys();
if ( _entries.contains(keyCode) )
{
QList<Entry> entriesForKey = _entries.values(keyCode);
//qDebug() << "Found" << entriesForKey.count() << "matches for key code" << keyCode;