diff --git a/tabbox/declarative.cpp b/tabbox/declarative.cpp index a470fe83fe..b579298ce8 100644 --- a/tabbox/declarative.cpp +++ b/tabbox/declarative.cpp @@ -273,13 +273,21 @@ void DeclarativeView::slotUpdateGeometry() } } -void DeclarativeView::setCurrentIndex(const QModelIndex &index) +void DeclarativeView::setCurrentIndex(const QModelIndex &index, bool disableAnimation) { if (tabBox->config().tabBoxMode() != m_mode) { return; } if (QObject *item = rootObject()->findChild("listView")) { + QVariant durationRestore; + if (disableAnimation) { + durationRestore = item->property("highlightMoveDuration"); + item->setProperty("highlightMoveDuration", QVariant(1)); + } item->setProperty("currentIndex", index.row()); + if (disableAnimation) { + item->setProperty("highlightMoveDuration", durationRestore); + } } } diff --git a/tabbox/declarative.h b/tabbox/declarative.h index 28b8a74739..0de08ba168 100644 --- a/tabbox/declarative.h +++ b/tabbox/declarative.h @@ -56,7 +56,7 @@ public: DeclarativeView(QAbstractItemModel *model, TabBoxConfig::TabBoxMode mode, QWidget *parent = NULL); virtual void showEvent(QShowEvent *event); virtual void resizeEvent(QResizeEvent *event); - void setCurrentIndex(const QModelIndex &index); + void setCurrentIndex(const QModelIndex &index, bool disableAnimation = false); protected: virtual void hideEvent(QHideEvent *event); diff --git a/tabbox/tabboxhandler.cpp b/tabbox/tabboxhandler.cpp index e91ea71da0..6dea794add 100644 --- a/tabbox/tabboxhandler.cpp +++ b/tabbox/tabboxhandler.cpp @@ -235,7 +235,7 @@ void TabBoxHandler::show() d->m_declarativeView = new DeclarativeView(d->clientModel(), TabBoxConfig::ClientTabBox); } d->m_declarativeView->show(); - d->m_declarativeView->setCurrentIndex(d->index); + d->m_declarativeView->setCurrentIndex(d->index, true); } else { if (!d->m_declarativeDesktopView) { d->m_declarativeDesktopView = new DeclarativeView(d->desktopModel(), TabBoxConfig::DesktopTabBox);