summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets/qtabbar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets/qtabbar.cpp')
-rw-r--r--src/gui/widgets/qtabbar.cpp96
1 files changed, 50 insertions, 46 deletions
diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp
index 7d970ad..b562b1f 100644
--- a/src/gui/widgets/qtabbar.cpp
+++ b/src/gui/widgets/qtabbar.cpp
@@ -131,7 +131,7 @@ void QTabBar::initStyleOption(QStyleOptionTab *option, int tabIndex) const
option->state &= ~QStyle::State_Enabled;
if (isActiveWindow())
option->state |= QStyle::State_Active;
- if (option->rect == d->hoverRect)
+ if (!d->dragInProgress && option->rect == d->hoverRect)
option->state |= QStyle::State_MouseOver;
option->shape = d->shape;
option->text = tab.text;
@@ -454,9 +454,6 @@ void QTabBarPrivate::layoutTabs()
maxExtent = maxWidth;
}
- if (pressedIndex != -1 && movable)
- grabCache(0, tabList.count(), true);
-
Q_ASSERT(tabChainIndex == tabChain.count() - 1); // add an assert just to make sure.
// Mirror our front item.
tabChain[tabChainIndex].init();
@@ -1170,13 +1167,13 @@ void QTabBar::setCurrentIndex(int index)
d->currentIndex = index;
update();
d->makeVisible(index);
+ d->tabList[index].lastTab = oldIndex;
+ d->layoutWidgets(oldIndex);
+ d->layoutWidgets(index);
#ifdef QT3_SUPPORT
emit selected(index);
#endif
emit currentChanged(index);
- d->tabList[index].lastTab = oldIndex;
- d->layoutWidgets(oldIndex);
- d->layoutWidgets(index);
}
}
@@ -1484,6 +1481,8 @@ void QTabBar::paintEvent(QPaintEvent *)
bool vertical = verticalTabs(d->shape);
QStyleOptionTab cutTab;
selected = d->currentIndex;
+ if (d->dragInProgress)
+ selected = d->pressedIndex;
for (int i = 0; i < d->tabList.count(); ++i)
optTabBase.tabBarRect |= tabRect(i);
@@ -1522,11 +1521,7 @@ void QTabBar::paintEvent(QPaintEvent *)
if (i == selected)
continue;
- if (!d->tabList[i].animatingCache.isNull() && d->paintWithOffsets) {
- p.drawPixmap(tab.rect, d->tabList[i].animatingCache);
- } else {
- p.drawControl(QStyle::CE_TabBarTab, tab);
- }
+ p.drawControl(QStyle::CE_TabBarTab, tab);
}
// Draw the selected tab last to get it "on top"
@@ -1539,7 +1534,11 @@ void QTabBar::paintEvent(QPaintEvent *)
else
tab.rect.moveLeft(tab.rect.x() + d->tabList[selected].dragOffset);
}
- p.drawControl(QStyle::CE_TabBarTab, tab);
+ if (!d->dragInProgress)
+ p.drawControl(QStyle::CE_TabBarTab, tab);
+ else
+ d->movingTab->setGeometry(tab.rect);
+
}
// Only draw the tear indicator if necessary. Most of the time we don't need too.
@@ -1680,6 +1679,7 @@ void QTabBarPrivate::_q_moveTab(int offset)
if (!validIndex(index))
return;
tabList[index].dragOffset = offset;
+ layoutTab(index); // Make buttons follow tab
q->update();
}
}
@@ -1727,8 +1727,7 @@ void QTabBar::mouseMoveEvent(QMouseEvent *event)
if (!d->dragInProgress && d->pressedIndex != -1) {
if ((event->pos() - d->dragStartPosition).manhattanLength() > QApplication::startDragDistance()) {
d->dragInProgress = true;
- if (d->animations.isEmpty())
- d->grabCache(0, d->tabList.count(), false);
+ d->setupMovableTab();
}
}
@@ -1773,7 +1772,6 @@ void QTabBar::mouseMoveEvent(QMouseEvent *event)
if (dragDistance > needsToBeOver)
d->slide(i + offset, d->pressedIndex);
}
-
}
// Buttons needs to follow the dragged tab
d->layoutTab(d->pressedIndex);
@@ -1801,32 +1799,41 @@ void QTabBarPrivate::_q_moveTabFinished()
}
}
-void QTabBarPrivate::grabCache(int start, int end, bool unhide)
+void QTabBarPrivate::setupMovableTab()
{
Q_Q(QTabBar);
- paintWithOffsets = false;
- bool showButtonsAgain = rightB->isVisible();
- rightB->hide();
- leftB->hide();
-
- QWidget *topLevel = q->window();
- QPoint topLevelOffset(q->mapTo(topLevel, QPoint()));
- for (int i = start; i < end; ++i) {
- QRect tabRect = q->tabRect(i);
- tabRect.translate(topLevelOffset);
- if (unhide) {
- tabList[i].unHideWidgets();
- layoutWidgets(i);
- }
- tabList[i].animatingCache = QPixmap::grabWidget(topLevel, tabRect);
- if (i != pressedIndex)
- tabList[i].hideWidgets();
- }
- if (showButtonsAgain) {
- rightB->show();
- leftB->show();
- }
- paintWithOffsets = true;
+ if (!movingTab)
+ movingTab = new QWidget(q);
+
+ QRect grabRect = q->tabRect(pressedIndex);
+
+ QPixmap grabImage(grabRect.size());
+ grabImage.fill(Qt::transparent);
+ QStylePainter p(&grabImage, q);
+
+ QStyleOptionTabV3 tab;
+ q->initStyleOption(&tab, pressedIndex);
+ tab.rect.moveTopLeft(QPoint(0, 0));
+ p.drawControl(QStyle::CE_TabBarTab, tab);
+ p.end();
+
+ QPalette pal;
+ pal.setBrush(QPalette::All, QPalette::Window, grabImage);
+ movingTab->setPalette(pal);
+ movingTab->setGeometry(grabRect);
+ movingTab->setAutoFillBackground(true);
+ movingTab->raise();
+
+ // Re-arrange widget order to avoid overlaps
+ if (tabList[pressedIndex].leftWidget)
+ tabList[pressedIndex].leftWidget->raise();
+ if (tabList[pressedIndex].rightWidget)
+ tabList[pressedIndex].rightWidget->raise();
+ if (leftB)
+ leftB->raise();
+ if (rightB)
+ rightB->raise();
+ movingTab->setVisible(true);
}
void QTabBarPrivate::_q_moveTabFinished(int index)
@@ -1834,10 +1841,9 @@ void QTabBarPrivate::_q_moveTabFinished(int index)
Q_Q(QTabBar);
bool cleanup = (pressedIndex == index) || (pressedIndex == -1) || !validIndex(index);
if (animations.isEmpty() && cleanup) {
+ movingTab->setVisible(false); // We might not get a mouse release
for (int i = 0; i < tabList.count(); ++i) {
tabList[i].dragOffset = 0;
- tabList[i].unHideWidgets();
- tabList[i].animatingCache = QPixmap();
}
if (pressedIndex != -1 && movable) {
pressedIndex = -1;
@@ -1881,6 +1887,7 @@ void QTabBar::mouseReleaseEvent(QMouseEvent *event)
d->_q_moveTabFinished(d->pressedIndex);
}
d->dragInProgress = false;
+ d->movingTab->setVisible(false);
d->dragStartPosition = QPoint();
}
@@ -2203,19 +2210,16 @@ void QTabBar::setTabButton(int index, ButtonPosition position, QWidget *widget)
widget->setParent(this);
// make sure our left and right widgets stay on top
widget->lower();
+ widget->show();
}
if (position == LeftSide) {
if (d->tabList[index].leftWidget)
d->tabList[index].leftWidget->hide();
d->tabList[index].leftWidget = widget;
- if(!d->tabList[index].hidLeft && widget)
- widget->show();
} else {
if (d->tabList[index].rightWidget)
d->tabList[index].rightWidget->hide();
d->tabList[index].rightWidget = widget;
- if(!d->tabList[index].hidRight && widget)
- widget->show();
}
d->layoutTabs();
update();
dules/CMakeCXXCompiler.cmake.in?h=v3.26.5&id=52584050c2bb0d65b60b0164af6a28c2761d1598'>CMakeCXXCompiler.cmake.in2439logstatsplain -rw-r--r--CMakeCXXCompilerABI.cpp450logstatsplain -rw-r--r--CMakeCXXCompilerId.cpp.in1297logstatsplain -rw-r--r--CMakeCXXInformation.cmake10570logstatsplain -rw-r--r--CMakeCheckCompilerFlagCommonPatterns.cmake2206logstatsplain -rw-r--r--CMakeClDeps.cmake1650logstatsplain -rw-r--r--CMakeCommonLanguageInclude.cmake5491logstatsplain -rw-r--r--CMakeCompilerABI.h1205logstatsplain -rw-r--r--CMakeCompilerIdDetection.cmake5049logstatsplain -rw-r--r--CMakeConfigurableFile.in34logstatsplain -rw-r--r--CMakeDependentOption.cmake2147logstatsplain -rw-r--r--CMakeDetermineASM-ATTCompiler.cmake859logstatsplain -rw-r--r--CMakeDetermineASMCompiler.cmake6523logstatsplain -rw-r--r--CMakeDetermineASM_MASMCompiler.cmake942logstatsplain -rw-r--r--CMakeDetermineASM_NASMCompiler.cmake1011logstatsplain -rw-r--r--CMakeDetermineCCompiler.cmake6517logstatsplain -rw-r--r--CMakeDetermineCXXCompiler.cmake6559logstatsplain -rw-r--r--CMakeDetermineCompileFeatures.cmake3496logstatsplain -rw-r--r--CMakeDetermineCompiler.cmake4932logstatsplain -rw-r--r--CMakeDetermineCompilerABI.cmake5938logstatsplain -rw-r--r--CMakeDetermineCompilerId.cmake22430logstatsplain -rw-r--r--CMakeDetermineFortranCompiler.cmake8611logstatsplain -rw-r--r--CMakeDetermineJavaCompiler.cmake4232logstatsplain -rw-r--r--CMakeDetermineRCCompiler.cmake2572logstatsplain -rw-r--r--CMakeDetermineSystem.cmake7838logstatsplain -rw-r--r--CMakeDetermineVSServicePack.cmake6561logstatsplain -rw-r--r--CMakeExpandImportedTargets.cmake6190logstatsplain -rw-r--r--CMakeExportBuildSettings.cmake1699logstatsplain -rw-r--r--CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake5061logstatsplain -rw-r--r--CMakeFindBinUtils.cmake3266logstatsplain -rw-r--r--CMakeFindCodeBlocks.cmake1084logstatsplain -rw-r--r--CMakeFindDependencyMacro.cmake2980logstatsplain -rw-r--r--CMakeFindEclipseCDT4.cmake5132logstatsplain -rw-r--r--CMakeFindFrameworks.cmake1234logstatsplain -rw-r--r--CMakeFindJavaCommon.cmake1493logstatsplain -rw-r--r--CMakeFindKDevelop3.cmake934logstatsplain -rw-r--r--CMakeFindKate.cmake1506logstatsplain -rw-r--r--CMakeFindPackageMode.cmake6425logstatsplain -rw-r--r--CMakeFindWMake.cmake737logstatsplain -rw-r--r--CMakeFindXCode.cmake720logstatsplain -rw-r--r--CMakeForceCompiler.cmake3159logstatsplain -rw-r--r--CMakeFortranCompiler.cmake.in2268logstatsplain -rw-r--r--CMakeFortranCompilerABI.F1347logstatsplain -rw-r--r--CMakeFortranCompilerId.F.in5062logstatsplain -rw-r--r--CMakeFortranInformation.cmake9774logstatsplain -rw-r--r--CMakeGenericSystem.cmake6817logstatsplain -rw-r--r--CMakeGraphVizOptions.cmake3493logstatsplain -rw-r--r--CMakeImportBuildSettings.cmake1000logstatsplain -rw-r--r--CMakeJOMFindMake.cmake736logstatsplain -rw-r--r--CMakeJavaCompiler.cmake.in538logstatsplain -rw-r--r--CMakeJavaInformation.cmake2247logstatsplain -rw-r--r--CMakeMSYSFindMake.cmake954logstatsplain -rw-r--r--CMakeMinGWFindMake.cmake1265logstatsplain -rw-r--r--CMakeNMakeFindMake.cmake738logstatsplain -rw-r--r--CMakeNinjaFindMake.cmake734logstatsplain -rw-r--r--CMakePackageConfigHelpers.cmake13790logstatsplain -rw-r--r--CMakeParseArguments.cmake5903logstatsplain -rw-r--r--CMakeParseImplicitLinkInfo.cmake6950logstatsplain -rw-r--r--CMakePlatformId.h.in5421logstatsplain -rw-r--r--CMakePrintHelpers.cmake4519logstatsplain -rw-r--r--CMakePrintSystemInformation.cmake2499logstatsplain -rw-r--r--CMakePushCheckState.cmake3713logstatsplain -rw-r--r--CMakeRCCompiler.cmake.in270logstatsplain -rw-r--r--CMakeRCInformation.cmake1942logstatsplain -rw-r--r--CMakeSystem.cmake.in537logstatsplain -rw-r--r--CMakeSystemSpecificInformation.cmake2855logstatsplain -rw-r--r--CMakeSystemSpecificInitialize.cmake837logstatsplain -rw-r--r--CMakeTestASM-ATTCompiler.cmake992logstatsplain -rw-r--r--CMakeTestASMCompiler.cmake1330logstatsplain -rw-r--r--CMakeTestASM_MASMCompiler.cmake1021logstatsplain -rw-r--r--CMakeTestASM_NASMCompiler.cmake989logstatsplain -rw-r--r--CMakeTestCCompiler.cmake3684logstatsplain -rw-r--r--CMakeTestCXXCompiler.cmake3579logstatsplain -rw-r--r--CMakeTestCompilerCommon.cmake894logstatsplain -rw-r--r--CMakeTestFortranCompiler.cmake4806logstatsplain -rw-r--r--CMakeTestGNU.c175logstatsplain -rw-r--r--CMakeTestJavaCompiler.cmake950logstatsplain -rw-r--r--CMakeTestRCCompiler.cmake1039logstatsplain -rw-r--r--CMakeTestWatcomVersion.c20logstatsplain -rw-r--r--CMakeUnixFindMake.cmake1040logstatsplain -rw-r--r--CMakeVS6BackwardCompatibility.cmake1430logstatsplain -rw-r--r--CMakeVS7BackwardCompatibility.cmake1430logstatsplain -rw-r--r--CMakeVerifyManifest.cmake4317logstatsplain -rw-r--r--CPack.DS_Store.in12292logstatsplain -rw-r--r--CPack.Description.plist.in438logstatsplain -rw-r--r--CPack.Info.plist.in1131logstatsplain -rwxr-xr-xCPack.OSXScriptLauncher.in29592logstatsplain -rw-r--r--CPack.OSXScriptLauncher.rsrc.in362logstatsplain -rw-r--r--CPack.OSXX11.Info.plist.in1603logstatsplain -rw-r--r--CPack.OSXX11.main.scpt.in1870logstatsplain -rwxr-xr-xCPack.RuntimeScript.in1896logstatsplain -rwxr-xr-xCPack.STGZ_Header.sh.in3855logstatsplain -rw-r--r--CPack.VolumeIcon.icns.in45739logstatsplain -rw-r--r--CPack.background.png.in47076logstatsplain -rw-r--r--CPack.cmake24359logstatsplain -rw-r--r--CPack.distribution.dist.in448logstatsplain -rw-r--r--CPackBundle.cmake1864logstatsplain -rw-r--r--CPackComponent.cmake21214logstatsplain -rw-r--r--CPackCygwin.cmake1205logstatsplain -rw-r--r--CPackDMG.cmake2753logstatsplain -rw-r--r--CPackDeb.cmake15889logstatsplain -rw-r--r--CPackIFW.cmake12615logstatsplain -rw-r--r--CPackNSIS.cmake4616logstatsplain -rw-r--r--CPackPackageMaker.cmake1662logstatsplain -rw-r--r--CPackRPM.cmake42965logstatsplain -rw-r--r--CPackWIX.cmake8441logstatsplain -rw-r--r--CPackZIP.cmake1452logstatsplain -rw-r--r--CTest.cmake10183logstatsplain -rw-r--r--CTestScriptMode.cmake1038logstatsplain -rw-r--r--CTestTargets.cmake3506logstatsplain -rw-r--r--CTestUseLaunchers.cmake3169logstatsplain -rw-r--r--CheckCCompilerFlag.cmake2494logstatsplain -rw-r--r--CheckCSourceCompiles.cmake3816logstatsplain -rw-r--r--CheckCSourceRuns.cmake3796logstatsplain -rw-r--r--CheckCXXCompilerFlag.cmake2539logstatsplain -rw-r--r--CheckCXXSourceCompiles.cmake3847logstatsplain -rw-r--r--CheckCXXSourceRuns.cmake3826logstatsplain -rw-r--r--CheckCXXSymbolExists.cmake2109logstatsplain -rw-r--r--CheckForPthreads.c701logstatsplain -rw-r--r--CheckFortranFunctionExists.cmake2595logstatsplain -rw-r--r--CheckFunctionExists.c380logstatsplain -rw-r--r--CheckFunctionExists.cmake3303logstatsplain -rw-r--r--CheckIncludeFile.c.in130logstatsplain -rw-r--r--CheckIncludeFile.cmake3323logstatsplain -rw-r--r--CheckIncludeFile.cxx.in65logstatsplain -rw-r--r--CheckIncludeFileCXX.cmake3401logstatsplain -rw-r--r--CheckIncludeFiles.cmake3815logstatsplain -rw-r--r--CheckLanguage.cmake2785logstatsplain -rw-r--r--CheckLibraryExists.cmake3134logstatsplain -rw-r--r--CheckLibraryExists.lists.in298logstatsplain -rw-r--r--CheckPrototypeDefinition.c.in514logstatsplain -rw-r--r--CheckPrototypeDefinition.cmake4408logstatsplain -rw-r--r--CheckSizeOf.cmake813logstatsplain -rw-r--r--CheckStructHasMember.cmake2666logstatsplain -rw-r--r--CheckSymbolExists.cmake4503logstatsplain -rw-r--r--CheckTypeSize.c.in801logstatsplain -rw-r--r--CheckTypeSize.cmake9688logstatsplain -rw-r--r--CheckTypeSizeMap.cmake.in31logstatsplain -rw-r--r--CheckVariableExists.c363logstatsplain -rw-r--r--CheckVariableExists.cmake2815logstatsplain d---------Compiler4962logstatsplain d---------CompilerId309logstatsplain -rw-r--r--Dart.cmake4200logstatsplain -rw-r--r--DartConfiguration.tcl.in3027logstatsplain -rw-r--r--DeployQt4.cmake13628logstatsplain -rw-r--r--Documentation.cmake1528logstatsplain -rw-r--r--DummyCXXFile.cxx27logstatsplain -rw-r--r--ExternalData.cmake31733logstatsplain -rw-r--r--ExternalData_config.cmake.in268logstatsplain -rw-r--r--ExternalProject.cmake69032logstatsplain -rw-r--r--FLTKCompatibility.cmake635logstatsplain -rw-r--r--FeatureSummary.cmake21239logstatsplain -rw-r--r--FindALSA.cmake2244logstatsplain -rw-r--r--FindASPELL.cmake1552logstatsplain -rw-r--r--FindAVIFile.cmake1830logstatsplain -rw-r--r--FindArmadillo.cmake3980logstatsplain -rw-r--r--FindBISON.cmake7212logstatsplain -rw-r--r--FindBLAS.cmake19827logstatsplain -rw-r--r--FindBZip2.cmake2647logstatsplain -rw-r--r--FindBacktrace.cmake3787logstatsplain -rw-r--r--FindBoost.cmake51190logstatsplain -rw-r--r--FindBullet.cmake3342logstatsplain -rw-r--r--FindCABLE.cmake2956logstatsplain -rw-r--r--FindCUDA.cmake72240logstatsplain d---------FindCUDA131logstatsplain -rw-r--r--FindCURL.cmake2388logstatsplain