Rename QStyleOptionMenuItem::tabWidth to reservedShortcutWidth

As per ### Qt 6 comment, and the documentation for the variable.

Change-Id: I58df784a72129dc97c5f13eb54e34cb7feb9748c
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
Volker Hilsheimer 2020-08-26 16:40:56 +02:00
parent b63e99d041
commit d6d662bba5
11 changed files with 19 additions and 17 deletions

View File

@ -4279,7 +4279,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
yPos += 1;
const bool isSubMenu = mi->menuItemType == QStyleOptionMenuItem::SubMenu;
const int tabwidth = isSubMenu ? 9 : mi->tabWidth;
const int tabwidth = isSubMenu ? 9 : mi->reservedShortcutWidth;
QString rightMarginText;
if (isSubMenu)

View File

@ -1198,7 +1198,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
int x, y, w, h;
menuitem->rect.getRect(&x, &y, &w, &h);
int tab = menuitem->tabWidth;
int tab = menuitem->reservedShortcutWidth;
bool dis = !(menuitem->state & State_Enabled);
bool checked = menuitem->checkType != QStyleOptionMenuItem::NotCheckable
? menuitem->checked : false;

View File

@ -2130,7 +2130,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op
case CE_MenuItem:
if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(option))
{
int tab = menuitem->tabWidth;
int tab = menuitem->reservedShortcutWidth;
bool dis = !(menuitem->state & State_Enabled);
bool act = menuitem->state & State_Selected;
bool checkable = menuitem->menuHasCheckableItems;

View File

@ -1686,7 +1686,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
}
int x, y, w, h;
menuitem->rect.getRect(&x, &y, &w, &h);
int tab = menuitem->tabWidth;
int tab = menuitem->reservedShortcutWidth;
QColor discol;
if (dis) {
discol = menuitem->palette.text().color();

View File

@ -1668,7 +1668,8 @@ QStyleOptionProgressBar::QStyleOptionProgressBar(int version)
QStyleOptionMenuItem::QStyleOptionMenuItem()
: QStyleOption(QStyleOptionMenuItem::Version, SO_MenuItem), menuItemType(Normal),
checkType(NotCheckable), checked(false), menuHasCheckableItems(true), maxIconWidth(0), tabWidth(0)
checkType(NotCheckable), checked(false), menuHasCheckableItems(true), maxIconWidth(0),
reservedShortcutWidth(0)
{
}
@ -1677,7 +1678,8 @@ QStyleOptionMenuItem::QStyleOptionMenuItem()
*/
QStyleOptionMenuItem::QStyleOptionMenuItem(int version)
: QStyleOption(version, SO_MenuItem), menuItemType(Normal),
checkType(NotCheckable), checked(false), menuHasCheckableItems(true), maxIconWidth(0), tabWidth(0)
checkType(NotCheckable), checked(false), menuHasCheckableItems(true), maxIconWidth(0),
reservedShortcutWidth(0)
{
}
@ -1821,7 +1823,7 @@ QStyleOptionMenuItem::QStyleOptionMenuItem(int version)
*/
/*!
\variable QStyleOptionMenuItem::tabWidth
\variable QStyleOptionMenuItem::reservedShortcutWidth
\brief the reserved width for the menu item's shortcut
QMenu sets it to the width occupied by the widest shortcut among

View File

@ -366,7 +366,7 @@ public:
QString text;
QIcon icon;
int maxIconWidth;
int tabWidth; // ### Qt 6: rename to reservedShortcutWidth
int reservedShortcutWidth;
QFont font;
QStyleOptionMenuItem();

View File

@ -3789,7 +3789,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
QRect textRect = subRule.contentsRect(opt->rect);
textRect.setLeft(textRect.left() + textRectOffset);
textRect.setWidth(textRect.width() - mi.tabWidth);
textRect.setWidth(textRect.width() - mi.reservedShortcutWidth);
const QRect vTextRect = visualRect(opt->direction, m->rect, textRect);
QStringView s(mi.text);

View File

@ -1110,7 +1110,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
int x, y, w, h;
menuitem->rect.getRect(&x, &y, &w, &h);
int tab = menuitem->tabWidth;
int tab = menuitem->reservedShortcutWidth;
bool dis = !(menuitem->state & State_Enabled);
bool checked = menuitem->checkType != QStyleOptionMenuItem::NotCheckable
? menuitem->checked : false;

View File

@ -160,7 +160,7 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt
}
menuOption.text = index.model()->data(index, Qt::DisplayRole).toString()
.replace(QLatin1Char('&'), QLatin1String("&&"));
menuOption.tabWidth = 0;
menuOption.reservedShortcutWidth = 0;
menuOption.maxIconWidth = option.decorationSize.width() + 4;
menuOption.menuRect = option.rect;
menuOption.rect = option.rect;

View File

@ -117,7 +117,7 @@ protected:
menuOpt.checkType = QStyleOptionMenuItem::NotCheckable;
menuOpt.menuRect = e->rect();
menuOpt.maxIconWidth = 0;
menuOpt.tabWidth = 0;
menuOpt.reservedShortcutWidth = 0;
QPainter p(viewport());
combo->style()->drawControl(QStyle::CE_MenuEmptyArea, &menuOpt, &p, this);
}
@ -193,7 +193,7 @@ protected:
menuOpt.checkType = QStyleOptionMenuItem::NotCheckable;
menuOpt.menuRect = rect();
menuOpt.maxIconWidth = 0;
menuOpt.tabWidth = 0;
menuOpt.reservedShortcutWidth = 0;
menuOpt.menuItemType = QStyleOptionMenuItem::Scroller;
if (sliderAction == QAbstractSlider::SliderSingleStepAdd)
menuOpt.state |= QStyle::State_DownArrow;

View File

@ -961,7 +961,7 @@ void QMenuPrivate::drawScroller(QPainter *painter, QMenuPrivate::ScrollerTearOff
menuOpt.state = QStyle::State_None;
menuOpt.checkType = QStyleOptionMenuItem::NotCheckable;
menuOpt.maxIconWidth = 0;
menuOpt.tabWidth = 0;
menuOpt.reservedShortcutWidth = 0;
menuOpt.rect = rect;
menuOpt.menuItemType = QStyleOptionMenuItem::Scroller;
menuOpt.state |= QStyle::State_Enabled;
@ -986,7 +986,7 @@ void QMenuPrivate::drawTearOff(QPainter *painter, const QRect &rect)
menuOpt.state = QStyle::State_None;
menuOpt.checkType = QStyleOptionMenuItem::NotCheckable;
menuOpt.maxIconWidth = 0;
menuOpt.tabWidth = 0;
menuOpt.reservedShortcutWidth = 0;
menuOpt.rect = rect;
menuOpt.menuItemType = QStyleOptionMenuItem::TearOff;
if (tearoffHighlighted)
@ -1613,7 +1613,7 @@ void QMenu::initStyleOption(QStyleOptionMenuItem *option, const QAction *action)
}
#endif
option->text = textAndAccel;
option->tabWidth = d->tabWidth;
option->reservedShortcutWidth = d->tabWidth;
option->maxIconWidth = d->maxIconWidth;
option->menuRect = rect();
}
@ -2784,7 +2784,7 @@ void QMenu::paintEvent(QPaintEvent *e)
menuOpt.state = QStyle::State_None;
menuOpt.checkType = QStyleOptionMenuItem::NotCheckable;
menuOpt.maxIconWidth = 0;
menuOpt.tabWidth = 0;
menuOpt.reservedShortcutWidth = 0;
style()->drawPrimitive(QStyle::PE_PanelMenu, &menuOpt, &p, this);
//calculate the scroll up / down rect