585 } |
592 } |
586 |
593 |
587 return result; |
594 return result; |
588 } |
595 } |
589 |
596 |
590 QRect QToolBarAreaLayoutInfo::appendLineDropRect() const |
597 int QToolBarAreaLayoutInfo::distance(const QPoint &pos) const |
591 { |
598 { |
592 QRect result; |
|
593 |
|
594 switch (dockPos) { |
599 switch (dockPos) { |
595 case QInternal::LeftDock: |
600 case QInternal::LeftDock: |
596 result = QRect(rect.right(), rect.top(), |
601 if (pos.y() < rect.bottom()) |
597 EmptyDockAreaSize, rect.height()); |
602 return pos.x() - rect.right(); |
598 break; |
|
599 case QInternal::RightDock: |
603 case QInternal::RightDock: |
600 result = QRect(rect.left() - EmptyDockAreaSize, rect.top(), |
604 if (pos.y() < rect.bottom()) |
601 EmptyDockAreaSize, rect.height()); |
605 return rect.left() - pos.x(); |
602 break; |
|
603 case QInternal::TopDock: |
606 case QInternal::TopDock: |
604 result = QRect(rect.left(), rect.bottom() + 1, |
607 if (pos.x() < rect.right()) |
605 rect.width(), EmptyDockAreaSize); |
608 return pos.y() - rect.bottom(); |
606 break; |
|
607 case QInternal::BottomDock: |
609 case QInternal::BottomDock: |
608 result = QRect(rect.left(), rect.top() - EmptyDockAreaSize, |
610 if (pos.x() < rect.right()) |
609 rect.width(), EmptyDockAreaSize); |
611 return rect.top() - pos.y(); |
610 break; |
|
611 default: |
612 default: |
612 break; |
613 break; |
613 } |
614 } |
614 |
615 return -1; |
615 return result; |
|
616 } |
616 } |
617 |
617 |
618 /****************************************************************************** |
618 /****************************************************************************** |
619 ** QToolBarAreaLayout |
619 ** QToolBarAreaLayout |
620 */ |
620 */ |
1020 } |
1020 } |
1021 |
1021 |
1022 return result; |
1022 return result; |
1023 } |
1023 } |
1024 |
1024 |
|
1025 //this functions returns the path to the possible gapindex for the position pos |
1025 QList<int> QToolBarAreaLayout::gapIndex(const QPoint &pos) const |
1026 QList<int> QToolBarAreaLayout::gapIndex(const QPoint &pos) const |
1026 { |
1027 { |
1027 Qt::LayoutDirection dir = mainWindow->layoutDirection(); |
1028 Qt::LayoutDirection dir = mainWindow->layoutDirection(); |
|
1029 int minDistance = 80; // when a dock area is empty, how "wide" is it? |
|
1030 QList<int> ret; //return value |
1028 for (int i = 0; i < QInternal::DockCount; ++i) { |
1031 for (int i = 0; i < QInternal::DockCount; ++i) { |
1029 QPoint p = pos; |
1032 QPoint p = pos; |
1030 if (docks[i].o == Qt::Horizontal) |
1033 if (docks[i].o == Qt::Horizontal) |
1031 p = QStyle::visualPos(dir, docks[i].rect, p); |
1034 p = QStyle::visualPos(dir, docks[i].rect, p); |
1032 QList<int> result = docks[i].gapIndex(p); |
1035 QList<int> result = docks[i].gapIndex(p, &minDistance); |
1033 if (!result.isEmpty()) { |
1036 if (!result.isEmpty()) { |
1034 result.prepend(i); |
1037 result.prepend(i); |
1035 return result; |
1038 ret = result; |
1036 } |
1039 } |
1037 } |
1040 } |
1038 |
1041 |
1039 return QList<int>(); |
1042 return ret; |
1040 } |
1043 } |
1041 |
1044 |
1042 QList<int> QToolBarAreaLayout::currentGapIndex() const |
1045 QList<int> QToolBarAreaLayout::currentGapIndex() const |
1043 { |
1046 { |
1044 for (int i = 0; i < QInternal::DockCount; ++i) { |
1047 for (int i = 0; i < QInternal::DockCount; ++i) { |
1296 bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*> &_toolBars, uchar tmarker, bool pre43, bool testing) |
1299 bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*> &_toolBars, uchar tmarker, bool pre43, bool testing) |
1297 { |
1300 { |
1298 QList<QToolBar*> toolBars = _toolBars; |
1301 QList<QToolBar*> toolBars = _toolBars; |
1299 int lines; |
1302 int lines; |
1300 stream >> lines; |
1303 stream >> lines; |
|
1304 if (!testing) |
|
1305 testing = mainWindow->unifiedTitleAndToolBarOnMac(); |
1301 |
1306 |
1302 for (int j = 0; j < lines; ++j) { |
1307 for (int j = 0; j < lines; ++j) { |
1303 int pos; |
1308 int pos; |
1304 stream >> pos; |
1309 stream >> pos; |
1305 if (pos < 0 || pos >= QInternal::DockCount) |
1310 if (pos < 0 || pos >= QInternal::DockCount) |
1306 return false; |
1311 return false; |
1307 int cnt; |
1312 int cnt; |
1308 stream >> cnt; |
1313 stream >> cnt; |
1309 |
1314 |
1310 QToolBarAreaLayoutInfo &dock = docks[pos]; |
1315 QToolBarAreaLayoutInfo &dock = docks[pos]; |
|
1316 const bool applyingLayout = !testing && !(pos == QInternal::TopDock && mainWindow->unifiedTitleAndToolBarOnMac()); |
1311 QToolBarAreaLayoutLine line(dock.o); |
1317 QToolBarAreaLayoutLine line(dock.o); |
1312 |
1318 |
1313 for (int k = 0; k < cnt; ++k) { |
1319 for (int k = 0; k < cnt; ++k) { |
1314 QToolBarAreaLayoutItem item; |
1320 QToolBarAreaLayoutItem item; |
1315 |
1321 |
1346 } |
1352 } |
1347 if (toolBar == 0) { |
1353 if (toolBar == 0) { |
1348 continue; |
1354 continue; |
1349 } |
1355 } |
1350 |
1356 |
1351 if (!testing) { |
1357 if (applyingLayout) { |
1352 item.widgetItem = new QWidgetItemV2(toolBar); |
1358 item.widgetItem = new QWidgetItemV2(toolBar); |
1353 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o); |
1359 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o); |
1354 toolBar->setVisible(shown & 1); |
1360 toolBar->setVisible(shown & 1); |
1355 toolBar->d_func()->setWindowState(floating, true, rect); |
1361 toolBar->d_func()->setWindowState(floating, true, rect); |
1356 |
1362 |
1357 item.preferredSize = item.size; |
1363 item.preferredSize = item.size; |
1358 line.toolBarItems.append(item); |
1364 line.toolBarItems.append(item); |
1359 } |
1365 } |
1360 } |
1366 } |
1361 |
1367 |
1362 if (!testing) { |
1368 if (applyingLayout) { |
1363 dock.lines.append(line); |
1369 dock.lines.append(line); |
1364 } |
1370 } |
1365 } |
1371 } |
1366 |
1372 |
1367 |
1373 |