Bug 151735 - [PATCH] Unless renamed, make userTitle fully override tab/window/icon text rather than prepend the default
Summary: [PATCH] Unless renamed, make userTitle fully override tab/window/icon text ra...
Status: RESOLVED LATER
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-02 11:19 UTC by Christopher Layne
Modified: 2008-09-22 04:35 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christopher Layne 2007-11-02 11:19:02 UTC
Version:            (using KDE KDE 3.5.7)
Installed from:    Compiled From Sources
Compiler:          gcc 4.2 
OS:                Linux

Earlier bug from 2001, which is indirectly related:

http://bugs.kde.org/show_bug.cgi?id=33641

Anyways, in cases where the user has specified their own userTitle via escape sequences, etc, the userTitle will override the default title, and not append, e.g. "- Shell" to said userTitle.

However, if a user specifically renames a session via the tab rename or dcop rename, that title will then be sticky and fully override whatever title is there (default or userTitle).

Rationale for this is that a userTitle should, in an intuitive fashion, overwrite the default title by nature. Additionally, the current behaviour of prepending it to the default session title just ends up taking way too much horizontal room in each tab title.

Example:
Current behaviour:

def: [ Shell No. 2 ]
usr: [ user@host:/var/log/httpd - Shell No. 2 ]
ren: [ user@host:/var/log/httpd - httpd logs ]

Patched behaviour:

def: [ Shell No. 2 ]
usr: [ user@host:/var/log/httpd ]
ren: [ httpd logs ]

I think it's quite apparent which one will take up the least space when one has, for example, 6+ tabs in a given konsole window. Also, as a long time user of konsole on a day to day basis, I think it would be prudent to remove the "No. x" code present in konsole.cpp (the double while loop deal). For one, it adds complexity to the code, but more importantly there is really no advantage to knowing which session number a given tab is. It's arbitrary and not something that one even takes note of - hence it just steals valuable horizontal space in the tab bar.

Patch for previously discussed changes:

Index: kdebase/konsole/konsole/session.cpp
===================================================================
--- kdebase/konsole/konsole/session.cpp (revision 722255)
+++ kdebase/konsole/konsole/session.cpp (working copy)
@@ -246,8 +246,8 @@
 QString TESession::fullTitle() const
 {
     QString res = title;
-    if ( !userTitle.isEmpty() )
-        res = userTitle + " - " + res;
+    if ( !titleSticky && !userTitle.isEmpty() )
+        res = userTitle;
     return res;
 }

@@ -334,7 +334,8 @@

 void TESession::renameSession(const QString &name)
 {
-  title=name;
+  setTitleSticky(name);
+
   emit renameSession(this,name);
 }

@@ -464,6 +465,12 @@
   font_no = fn;
 }

+void TESession::setTitleSticky(const QString& _title)
+{
+  title = _title;
+  titleSticky = true;
+}
+
 void TESession::setTitle(const QString& _title)
 {
   title = _title;
Index: kdebase/konsole/konsole/konsole.cpp
===================================================================
--- kdebase/konsole/konsole/konsole.cpp (revision 722255)
+++ kdebase/konsole/konsole/konsole.cpp (working copy)
@@ -3790,7 +3790,7 @@

   if (!ok) return;

-  ses->setTitle(title);
+  ses->setTitleSticky(title);
   slotRenameSession(ses,title);
 }

Index: kdebase/konsole/konsole/session.h
===================================================================
--- kdebase/konsole/konsole/session.h   (revision 722255)
+++ kdebase/konsole/konsole/session.h   (working copy)
@@ -85,6 +85,7 @@
   void setKeymap(const QString& _id);
   void setFontNo(int fn);
   void setTitle(const QString& _title);
+  void setTitleSticky(const QString& _title);
   void setIconName(const QString& _iconName);
   void setIconText(const QString& _iconText);
   void setAddToUtmp(bool);
@@ -186,6 +187,7 @@
   bool           masterMode;
   bool           autoClose;
   bool           wantedClose;
+  bool           titleSticky;
   QTimer*        monitorTimer;

   //FIXME: using the indices here
Comment 1 Robert Knight 2008-06-02 08:00:02 UTC
Tab titles are handled somewhat differently in KDE 4 so this patch no longer applies.  
Comment 2 Robert Knight 2008-09-22 04:35:08 UTC
Closing as per comment #1 - Thank-you for writing the patch though.