[kde-freebsd] konsole session title limited to 20 chars in tab bar

Andriy Gapon avg at icyb.net.ua
Wed May 26 11:55:31 CEST 2010


I know that this is an upstream question, but let me start here.
Why have
http://people.freebsd.org/~avg/konsole1.png
when you can have
http://people.freebsd.org/~avg/konsole2.png

I like to have many sessions open in one konsole window and I also like having
meaningful/useful titles for them (set via %w plus shell magic).  Having a title
*always* limited to 20 characters (regardless of number of tabs or tab width)
really sucks.

The change was trivial, in apps/konsole/src/ViewContainer.cpp first add
setElideMode() to constructor of ViewContainerTabBar, so that it looks like this:

ViewContainerTabBar::ViewContainerTabBar(QWidget* parent,TabbedViewContainer*
container)
    : KTabBar(parent)
    , _container(container)
    , _dropIndicator(0)
    , _dropIndicatorIndex(-1)
    , _drawIndicatorDisabled(false)
{
    setElideMode(Qt::ElideLeft);
}

And then drop the stupid limiting code:
void TabbedViewContainer::updateTitle(ViewProperties* item)
{
    // prevent tab titles from becoming overly-long as this limits the number
    // of tabs which can fit in the tab bar.
    //
    // if the view's title is overly long then trim it and select the
    // right-most 20 characters (assuming they contain the most useful
    // information) and insert an elide at the front
    const int MAX_TAB_TEXT_LENGTH = 20;

    QListIterator<QWidget*> iter(widgetsForItem(item));
    while ( iter.hasNext() )
    {
        const int index = _stackWidget->indexOf( iter.next() );

        QString tabText = item->title();
#if 0
        if (tabText.count() > MAX_TAB_TEXT_LENGTH)
            tabText = tabText.right(MAX_TAB_TEXT_LENGTH).prepend("...");
#endif
        _tabBar->setTabText( index , tabText );
    }
}


Proper diff is coming later ;-)

-- 
Andriy Gapon


More information about the kde-freebsd mailing list