>
>
> >  * When more tabs are open than can fit on the screen ithe tab bar has a
> habit
> > of jumping around the horizontal position of tabs
>
>
> This is a “bug” in Qt: https://bugs.kde.org/show_bug.cgi?id=223184
>
>
I suspect you guys are talking about this one:
http://bugreports.qt.nokia.com/browse/QTBUG-2360

I refined the testcase a little bit, and came up with a first "draft" patch
for it, I'll try to get it into Qt, but well, it's gonna be 4.8 at the best,
so don't hold your breath...
If some of you are brave and/or nice enough to patch their version of Qt and
let me know if that's any better, that's cool !

Cheers,
--
Pierre
#include <QtGui>

class MyTabBar : public QTabBar
{
    Q_OBJECT
public:
    MyTabBar(QWidget *parent = 0) : QTabBar(parent), count(0), tabIndex(0)
    {
        addTab("Foo");
        tabIndex = addTab("Progress: 0%");
        addTab("Bar");
        addTab("Baz");
        addTab("Long tab, long tab");
        addTab("Long tab, long tab");
        setMovable(true);

        values = (QStringList() << "*foo" << "*a long string" << "*bar" << "*some more foobar"
                              << "*test" << "*awesomeness is not a crime !");

        timer = new QTimer(this);
        connect(timer, SIGNAL(timeout()), this, SLOT(changeText()));
        timer->setInterval(1000);
        timer->start();
        connect(this, SIGNAL(tabMoved(int,int)), SLOT(updateIndex(int,int)));
    }

public slots:
    void changeText()
    {
        count++;
        if (count == values.size())
            count = 0;
        setTabText(tabIndex, values.at(count));
    }

    void updateIndex(int from, int to)
    {
        qDebug() << Q_FUNC_INFO <<from <<tabText(to) << to;
        if (from == tabIndex) {
            tabIndex = to;
        } else if (to == tabIndex) { // we lost it
            if (to > from)
                tabIndex--;
            else
                tabIndex++;
        }
    }

    void toggleTimer(bool on)
    {
        if (!timer)
            return;
        if (!on)
            timer->stop();
        else
            timer->start();
    }

private:
    QStringList values;
    QTimer *timer;
    int count;
    int tabIndex;
};

#include "main.moc"

int main(int argc, char **argv)
{
    QApplication a(argc, argv);
    QWidget w;
    w.setLayout(new QVBoxLayout);
    QPushButton b("Toggle timer");
    b.setCheckable(true);
    b.setChecked(true);
    w.layout()->addWidget(&b);

    MyTabBar *mtb = new MyTabBar(&w);
    w.layout()->addWidget(mtb);

    w.show();
    QObject::connect(&b, SIGNAL(clicked(bool)), mtb, SLOT(toggleTimer(bool)) );
    return a.exec();
}
diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp
index bbc7e5d..95f25ba 100644
--- a/src/gui/widgets/qtabbar.cpp
+++ b/src/gui/widgets/qtabbar.cpp
@@ -720,8 +720,12 @@ void QTabBarPrivate::refresh()
     if (!q->isVisible()) {
         layoutDirty = true;
     } else {
+        const int oldLeft = q->tabRect(currentIndex).left();
         layoutTabs();
         makeVisible(currentIndex);
+        const int offsetAdjustment = q->tabRect(currentIndex).left() - oldLeft;
+        if (scrollOffset && (scrollOffset - offsetAdjustment) >= 0)
+            scrollOffset += offsetAdjustment;
         q->update();
         q->updateGeometry();
     }
_______________________________________________
rekonq mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/rekonq

Reply via email to