QMenu: Refactor column layout logic
Change-Id: I30f1c87092447abf1c94e69c0124eeeee43666e2 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
parent
60865878e4
commit
46543bb462
@ -327,8 +327,8 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const
|
|||||||
const int deskFw = style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, &opt, q);
|
const int deskFw = style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, &opt, q);
|
||||||
const int tearoffHeight = tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, &opt, q) : 0;
|
const int tearoffHeight = tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, &opt, q) : 0;
|
||||||
const int base_y = vmargin + fw + topmargin + (scroll ? scroll->scrollOffset : 0) + tearoffHeight;
|
const int base_y = vmargin + fw + topmargin + (scroll ? scroll->scrollOffset : 0) + tearoffHeight;
|
||||||
|
const int column_max_y = screen.height() - 2 * deskFw - (vmargin + bottommargin + fw);
|
||||||
int max_column_width = 0;
|
int max_column_width = 0;
|
||||||
int dh = screen.height();
|
|
||||||
int y = base_y;
|
int y = base_y;
|
||||||
|
|
||||||
//for compatibility now - will have to refactor this away
|
//for compatibility now - will have to refactor this away
|
||||||
@ -406,8 +406,7 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const
|
|||||||
if (!sz.isEmpty()) {
|
if (!sz.isEmpty()) {
|
||||||
max_column_width = qMax(max_column_width, sz.width());
|
max_column_width = qMax(max_column_width, sz.width());
|
||||||
//wrapping
|
//wrapping
|
||||||
if (!scroll &&
|
if (!scroll && y + sz.height() > column_max_y) {
|
||||||
y + sz.height() + vmargin + bottommargin + fw > dh - (deskFw * 2)) {
|
|
||||||
ncols++;
|
ncols++;
|
||||||
y = base_y;
|
y = base_y;
|
||||||
} else {
|
} else {
|
||||||
@ -433,8 +432,7 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const
|
|||||||
QRect &rect = actionRects[i];
|
QRect &rect = actionRects[i];
|
||||||
if (rect.isNull())
|
if (rect.isNull())
|
||||||
continue;
|
continue;
|
||||||
if (!scroll &&
|
if (!scroll && y + rect.height() > column_max_y) {
|
||||||
y + rect.height() + vmargin + bottommargin + fw > dh - deskFw * 2) {
|
|
||||||
x += max_column_width + hmargin;
|
x += max_column_width + hmargin;
|
||||||
y = base_y;
|
y = base_y;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user