QMdiArea: Fix positioning of cascaded sub windows.
Take PM_FocusFrameVMargin into account. Task-number: QTBUG-35146 Change-Id: I1499790537ddf9fbb912ab764b7d049ee11af95d Reviewed-by: Andy Shaw <andy.shaw@digia.com>
This commit is contained in:
parent
c55324aee0
commit
289b4ed705
@ -347,7 +347,8 @@ void SimpleCascader::rearrange(QList<QWidget *> &widgets, const QRect &domain) c
|
||||
options.initFrom(widgets.at(0));
|
||||
int titleBarHeight = widgets.at(0)->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options, widgets.at(0));
|
||||
const QFontMetrics fontMetrics = QFontMetrics(QApplication::font("QMdiSubWindowTitleBar"));
|
||||
const int dy = qMax(titleBarHeight - (titleBarHeight - fontMetrics.height()) / 2, 1);
|
||||
const int dy = qMax(titleBarHeight - (titleBarHeight - fontMetrics.height()) / 2, 1)
|
||||
+ widgets.at(0)->style()->pixelMetric(QStyle::PM_FocusFrameVMargin, 0, widgets.at(0));
|
||||
|
||||
const int n = widgets.size();
|
||||
const int nrows = qMax((domain.height() - (topOffset + bottomOffset)) / dy, 1);
|
||||
|
@ -136,6 +136,22 @@ static inline QTabBar::Shape tabBarShapeFrom(QTabWidget::TabShape shape, QTabWid
|
||||
return QTabBar::RoundedNorth;
|
||||
}
|
||||
|
||||
static int cascadedDeltaY(const QMdiArea *area)
|
||||
{
|
||||
// Calculate the delta (dx, dy) between two cascaded subwindows.
|
||||
const QWidget *subWindow = area->subWindowList().first();
|
||||
const QStyle *style = subWindow->style();
|
||||
QStyleOptionTitleBar options;
|
||||
options.initFrom(subWindow);
|
||||
int titleBarHeight = style->pixelMetric(QStyle::PM_TitleBarHeight, &options);
|
||||
// ### Remove this after the QMacStyle has been fixed
|
||||
if (style->inherits("QMacStyle"))
|
||||
titleBarHeight -= 4;
|
||||
const QFontMetrics fontMetrics = QFontMetrics(QApplication::font("QMdiSubWindowTitleBar"));
|
||||
return qMax(titleBarHeight - (titleBarHeight - fontMetrics.height()) / 2, 1)
|
||||
+ style->pixelMetric(QStyle::PM_FocusFrameVMargin);
|
||||
}
|
||||
|
||||
enum Arrangement {
|
||||
Tiled,
|
||||
Cascaded
|
||||
@ -147,7 +163,6 @@ static bool verifyArrangement(QMdiArea *mdiArea, Arrangement arrangement, const
|
||||
return false;
|
||||
|
||||
const QList<QMdiSubWindow *> subWindows = mdiArea->subWindowList();
|
||||
const QMdiSubWindow *const firstSubWindow = subWindows.at(0);
|
||||
|
||||
switch (arrangement) {
|
||||
case Tiled:
|
||||
@ -179,17 +194,7 @@ static bool verifyArrangement(QMdiArea *mdiArea, Arrangement arrangement, const
|
||||
}
|
||||
case Cascaded:
|
||||
{
|
||||
// Calculate the delta (dx, dy) between two cascaded subwindows.
|
||||
QStyleOptionTitleBar options;
|
||||
options.initFrom(firstSubWindow);
|
||||
int titleBarHeight = firstSubWindow->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options);
|
||||
#ifdef Q_OS_MAC
|
||||
// ### Remove this after the mac style has been fixed
|
||||
if (firstSubWindow->style()->inherits("QMacStyle"))
|
||||
titleBarHeight -= 4;
|
||||
#endif
|
||||
const QFontMetrics fontMetrics = QFontMetrics(QApplication::font("QMdiSubWindowTitleBar"));
|
||||
const int dy = qMax(titleBarHeight - (titleBarHeight - fontMetrics.height()) / 2, 1);
|
||||
const int dy = cascadedDeltaY(mdiArea);
|
||||
const int dx = 10;
|
||||
|
||||
// Current activation/stacking order.
|
||||
@ -1790,14 +1795,7 @@ void tst_QMdiArea::cascadeAndTileSubWindows()
|
||||
qApp->processEvents();
|
||||
|
||||
// Check dy between two cascaded windows
|
||||
QStyleOptionTitleBar options;
|
||||
options.initFrom(windows.at(1));
|
||||
int titleBarHeight = windows.at(1)->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options);
|
||||
// ### Remove this after the mac style has been fixed
|
||||
if (windows.at(1)->style()->inherits("QMacStyle"))
|
||||
titleBarHeight -= 4;
|
||||
const QFontMetrics fontMetrics = QFontMetrics(QApplication::font("QMdiSubWindowTitleBar"));
|
||||
const int dy = qMax(titleBarHeight - (titleBarHeight - fontMetrics.height()) / 2, 1);
|
||||
const int dy = cascadedDeltaY(&workspace);
|
||||
#ifdef Q_OS_MAC
|
||||
QEXPECT_FAIL("", "QTBUG-25298", Abort);
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user