[Konsole-devel] Request for Advice: Possible fixes for #183963
Andrea Solis
andreaks310 at gmail.com
Fri May 28 00:54:58 UTC 2010
Hi All,
I am a novice in the open source community, please let me know if I
should post this somewhere else... (Should I post directly in the bug
report itslef?)
This is in regards to konsole bug #183963: A renamed tab is being reset.
The problem -- If a konsole tab name is set using this command:
qdbus org.kde.konsole $KONSOLE_DBUS_SESSION
org.kde.konsole.Session.setTitle 1 "foo"
then the tab name changes, but then almost immedately reverts back to
it's previous name.
I checked out and examined the code, as far as I can tell this is what occurs:
1. The qdbus command is processed by Session::setTitle which sets the
new value in Session::_displayTitle:
Session::_displayTitle = "foo"
2. SessionController::snapshot is called, it obtains the current
title by calling Session::getDynamicTitle
3. Session::getDynamicTitle formats the title by calling
ProcessInfo::format and passing either _localTabTitleFormat or
_remoteTabTitleFormat. It does *not* use _displayTitle!
4. ProcessInfo::format replaces the formatting characters in
_localTabTitleFormat (or _remoteTabTitleFormat). Since _displayTitle
is not used, and _localTabTitleFormat is not changed by
Session::setTitle, the previous title is returned.
Therefore, the previous title is displayed in the tab by
SessionController::snapshot
I was able to come up with two possiblie solutions, and would like an
opinion on which to persue. If none of them seem optimal, I'd
appreciate any advice or suggestions on how to best proceed.
1. Modify Session::setTitle so that it sets tabTitleFormat as well as
displayTitle:
--------------------------- start code snippet ---------------------
void Session::setTitle(TitleRole role , const QString& newTitle)
{
if ( title(role) != newTitle )
{
if ( role == NameRole )
_nameTitle = newTitle;
else if ( role == DisplayedTitleRole )
{
_displayTitle = newTitle;
setTabTitleFormat(LocalTabTitle, newTitle);
// Check if process=="ssh" before changing RemoteTabTitle?
setTabTitleFormat(RemoteTabTitle, newTitle);
}
emit titleChanged();
}
}
--------------------------- end code snippet ---------------------
This would be the easiest to implement, and would almost mimic the
behavior of SessionController::renameSession. However, it doesn't
seem ideal because it changes more than just the title. Also, it
changes the Local format as well as the Remote format, is that a good
idea?
2. Add a new binding to the Session class so the tab title format can
be controlled independently of the session title:
Q_SCRIPTABLE void Session::setTabTitleFormat(int context, const
QString& format)
This seems more reasonable, as it is very clear as to what is being
set. Script writers can use qdbus to set exactly what they want to
set, be it the session title or the tab format. Setting one would not
override the other.
If solution #2 is recommended, here's a feature idea:
Add a "pre-formatting" method to Session::getDynamicTitle. Introduce
two new formatting characters, one would be replaced by _nameTitle and
another by _displayTitle:
--------------------------- start code snippet ---------------------
QString Session::formatDynamicTitle(const QString &input)
{
QString output(input);
// Make sure "%S" and "%T" are unique (or come up with somethig else)
output.replace("%S", title(NameRole));
output.replace("%T", title(DisplayedTitleRole));
return output;
}
QString Session::getDynamicTitle()
{
// update current directory from process
ProcessInfo* process = updateWorkingDirectory();
// format tab titles using process info
bool ok = false;
QString title;
QString format;
if ( process->name(&ok) == "ssh" && ok )
{
format = formatDynamicTitle(tabTitleFormat(Session::RemoteTabTitle));
SSHProcessInfo sshInfo(*process);
title = sshInfo.format(format);
}
else
{
format = formatDynamicTitle(tabTitleFormat(Session::LocalTabTitle));
title = process->format(format);
}
return title;
}
--------------------------- end code snippet ---------------------
That would give the most control, but would have to be implemented
along with solution #2 so that the format string could be changed via
qdbus.
Note that I have not yet attempted to compile or test any of the above
code. Therefore, I do not think that either solution is ready to
offer as a patch.
Any feedback would be greatly appreciated, Thanks!
Andrea
More information about the konsole-devel
mailing list