equal
deleted
inserted
replaced
1692 // Be safe! |
1692 // Be safe! |
1693 if (d->pressedIndex != -1 && d->movable) |
1693 if (d->pressedIndex != -1 && d->movable) |
1694 d->moveTabFinished(d->pressedIndex); |
1694 d->moveTabFinished(d->pressedIndex); |
1695 |
1695 |
1696 d->pressedIndex = d->indexAtPos(event->pos()); |
1696 d->pressedIndex = d->indexAtPos(event->pos()); |
|
1697 #ifdef Q_WS_MAC |
|
1698 d->previousPressedIndex = d->pressedIndex; |
|
1699 #endif |
1697 if (d->validIndex(d->pressedIndex)) { |
1700 if (d->validIndex(d->pressedIndex)) { |
1698 QStyleOptionTabBarBaseV2 optTabBase; |
1701 QStyleOptionTabBarBaseV2 optTabBase; |
1699 optTabBase.init(this); |
1702 optTabBase.init(this); |
1700 optTabBase.documentMode = d->documentMode; |
1703 optTabBase.documentMode = d->documentMode; |
1701 if (event->type() == style()->styleHint(QStyle::SH_TabBar_SelectMouseType, &optTabBase, this)) |
1704 if (event->type() == style()->styleHint(QStyle::SH_TabBar_SelectMouseType, &optTabBase, this)) |
1772 // Buttons needs to follow the dragged tab |
1775 // Buttons needs to follow the dragged tab |
1773 d->layoutTab(d->pressedIndex); |
1776 d->layoutTab(d->pressedIndex); |
1774 |
1777 |
1775 update(); |
1778 update(); |
1776 } |
1779 } |
|
1780 #ifdef Q_WS_MAC |
|
1781 } else if (!d->documentMode && event->buttons() == Qt::LeftButton && d->previousPressedIndex != -1) { |
|
1782 int newPressedIndex = d->indexAtPos(event->pos()); |
|
1783 if (d->pressedIndex == -1 && d->previousPressedIndex == newPressedIndex) { |
|
1784 d->pressedIndex = d->previousPressedIndex; |
|
1785 update(tabRect(d->pressedIndex)); |
|
1786 } else if(d->pressedIndex != newPressedIndex) { |
|
1787 d->pressedIndex = -1; |
|
1788 update(tabRect(d->previousPressedIndex)); |
|
1789 } |
|
1790 #endif |
1777 } |
1791 } |
1778 |
1792 |
1779 if (event->buttons() != Qt::LeftButton) { |
1793 if (event->buttons() != Qt::LeftButton) { |
1780 event->ignore(); |
1794 event->ignore(); |
1781 return; |
1795 return; |
1796 grabRect.adjust(-taboverlap, 0, taboverlap, 0); |
1810 grabRect.adjust(-taboverlap, 0, taboverlap, 0); |
1797 |
1811 |
1798 QPixmap grabImage(grabRect.size()); |
1812 QPixmap grabImage(grabRect.size()); |
1799 grabImage.fill(Qt::transparent); |
1813 grabImage.fill(Qt::transparent); |
1800 QStylePainter p(&grabImage, q); |
1814 QStylePainter p(&grabImage, q); |
|
1815 p.initFrom(q); |
1801 |
1816 |
1802 QStyleOptionTabV3 tab; |
1817 QStyleOptionTabV3 tab; |
1803 q->initStyleOption(&tab, pressedIndex); |
1818 q->initStyleOption(&tab, pressedIndex); |
1804 tab.rect.moveTopLeft(QPoint(taboverlap, 0)); |
1819 tab.rect.moveTopLeft(QPoint(taboverlap, 0)); |
1805 p.drawControl(QStyle::CE_TabBarTab, tab); |
1820 p.drawControl(QStyle::CE_TabBarTab, tab); |
1863 Q_D(QTabBar); |
1878 Q_D(QTabBar); |
1864 if (event->button() != Qt::LeftButton) { |
1879 if (event->button() != Qt::LeftButton) { |
1865 event->ignore(); |
1880 event->ignore(); |
1866 return; |
1881 return; |
1867 } |
1882 } |
1868 |
1883 #ifdef Q_WS_MAC |
|
1884 d->previousPressedIndex = -1; |
|
1885 #endif |
1869 if (d->movable && d->dragInProgress && d->validIndex(d->pressedIndex)) { |
1886 if (d->movable && d->dragInProgress && d->validIndex(d->pressedIndex)) { |
1870 int length = d->tabList[d->pressedIndex].dragOffset; |
1887 int length = d->tabList[d->pressedIndex].dragOffset; |
1871 int width = verticalTabs(d->shape) |
1888 int width = verticalTabs(d->shape) |
1872 ? tabRect(d->pressedIndex).height() |
1889 ? tabRect(d->pressedIndex).height() |
1873 : tabRect(d->pressedIndex).width(); |
1890 : tabRect(d->pressedIndex).width(); |
1929 void QTabBar::changeEvent(QEvent *event) |
1946 void QTabBar::changeEvent(QEvent *event) |
1930 { |
1947 { |
1931 Q_D(QTabBar); |
1948 Q_D(QTabBar); |
1932 if (event->type() == QEvent::StyleChange) { |
1949 if (event->type() == QEvent::StyleChange) { |
1933 d->elideMode = Qt::TextElideMode(style()->styleHint(QStyle::SH_TabBar_ElideMode, 0, this)); |
1950 d->elideMode = Qt::TextElideMode(style()->styleHint(QStyle::SH_TabBar_ElideMode, 0, this)); |
1934 d->useScrollButtons = !style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, 0, this); |
1951 if (!d->useScrollButtonsSetByUser) |
|
1952 d->useScrollButtons = !style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, 0, this); |
1935 d->refresh(); |
1953 d->refresh(); |
1936 } else if (event->type() == QEvent::FontChange) { |
1954 } else if (event->type() == QEvent::FontChange) { |
1937 d->refresh(); |
1955 d->refresh(); |
1938 } |
1956 } |
1939 QWidget::changeEvent(event); |
1957 QWidget::changeEvent(event); |
1984 } |
2002 } |
1985 |
2003 |
1986 void QTabBar::setUsesScrollButtons(bool useButtons) |
2004 void QTabBar::setUsesScrollButtons(bool useButtons) |
1987 { |
2005 { |
1988 Q_D(QTabBar); |
2006 Q_D(QTabBar); |
|
2007 d->useScrollButtonsSetByUser = true; |
1989 if (d->useScrollButtons == useButtons) |
2008 if (d->useScrollButtons == useButtons) |
1990 return; |
2009 return; |
1991 d->useScrollButtons = useButtons; |
2010 d->useScrollButtons = useButtons; |
1992 d->refresh(); |
2011 d->refresh(); |
1993 } |
2012 } |