summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-08-16 07:58:32 +0200
committerLiang Qi <liang.qi@qt.io>2016-08-16 07:58:32 +0200
commit17198e03ab36e5f579a1477b09cc3e601975eb5f (patch)
tree61ba826e9edd53469abdc1e1f58b1223d0336c56 /src/widgets/widgets
parenta5e89005445ac8ca18ac046eaf55fe2230e47cd6 (diff)
parent2e2b32a9ab459f6618d02e4b454c75a787172def (diff)
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts: qmake/doc/src/qmake-manual.qdoc src/corelib/global/qglobal.cpp src/corelib/tools/qstring.cpp src/network/socket/qabstractsocket.cpp src/network/socket/qnativesocketengine_unix.cpp src/plugins/platforms/eglfs/api/qeglfsglobal.h Change-Id: Id5dfdbd30fa996f9b4b66a0b030b7d3b8c0ef288
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r--src/widgets/widgets/qdialogbuttonbox.cpp4
-rw-r--r--src/widgets/widgets/qmaccocoaviewcontainer_mac.mm6
-rw-r--r--src/widgets/widgets/qmacnativewidget_mac.mm4
-rw-r--r--src/widgets/widgets/qmainwindow.cpp2
-rw-r--r--src/widgets/widgets/qmenu.cpp2
-rw-r--r--src/widgets/widgets/qmenu_mac.mm8
-rw-r--r--src/widgets/widgets/qmenubar.cpp14
-rw-r--r--src/widgets/widgets/qrubberband.cpp2
-rw-r--r--src/widgets/widgets/qtabbar.cpp89
-rw-r--r--src/widgets/widgets/qtabbar_p.h3
-rw-r--r--src/widgets/widgets/qtabwidget.cpp2
-rw-r--r--src/widgets/widgets/qtoolbar.cpp2
-rw-r--r--src/widgets/widgets/qtoolbutton.cpp2
13 files changed, 83 insertions, 57 deletions
diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp
index 0d369eb28c..657eda3c68 100644
--- a/src/widgets/widgets/qdialogbuttonbox.cpp
+++ b/src/widgets/widgets/qdialogbuttonbox.cpp
@@ -124,7 +124,7 @@ QT_BEGIN_NAMESPACE
\endtable
Additionally, button boxes that contain only buttons with ActionRole or
- HelpRole can be considered modeless and have an alternate look on OS X:
+ HelpRole can be considered modeless and have an alternate look on \macos:
\table
\row \li modeless horizontal MacLayout
@@ -579,7 +579,7 @@ QDialogButtonBox::~QDialogButtonBox()
contained in the button box.
\value WinLayout Use a policy appropriate for applications on Windows.
- \value MacLayout Use a policy appropriate for applications on OS X.
+ \value MacLayout Use a policy appropriate for applications on \macos.
\value KdeLayout Use a policy appropriate for applications on KDE.
\value GnomeLayout Use a policy appropriate for applications on GNOME.
diff --git a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
index 2d19780461..725cc637d6 100644
--- a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
+++ b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
@@ -49,7 +49,7 @@
\class QMacCocoaViewContainer
\since 4.5
- \brief The QMacCocoaViewContainer class provides a widget for OS X that can be used to wrap arbitrary
+ \brief The QMacCocoaViewContainer class provides a widget for \macos that can be used to wrap arbitrary
Cocoa views (i.e., NSView subclasses) and insert them into Qt hierarchies.
\ingroup advanced
@@ -64,10 +64,10 @@
of the underlying NSView.
QMacCocoaViewContainer works regardless if Qt is built against Carbon or
- Cocoa. However, QCocoaContainerView requires Mac OS X 10.5 or better to be
+ Cocoa. However, QCocoaContainerView requires \macos 10.5 or better to be
used with Carbon.
- It should be also noted that at the low level on OS X, there is a
+ It should be also noted that at the low level on \macos, there is a
difference between windows (top-levels) and view (widgets that are inside a
window). For this reason, make sure that the NSView that you are wrapping
doesn't end up as a top-level. The best way to ensure this is to make sure
diff --git a/src/widgets/widgets/qmacnativewidget_mac.mm b/src/widgets/widgets/qmacnativewidget_mac.mm
index b6c5179989..936bd35187 100644
--- a/src/widgets/widgets/qmacnativewidget_mac.mm
+++ b/src/widgets/widgets/qmacnativewidget_mac.mm
@@ -48,13 +48,13 @@
/*!
\class QMacNativeWidget
\since 4.5
- \brief The QMacNativeWidget class provides a widget for OS X that provides
+ \brief The QMacNativeWidget class provides a widget for \macos that provides
a way to put Qt widgets into Cocoa hierarchies.
\ingroup advanced
\inmodule QtWidgets
- On OS X, there is a difference between a window and view;
+ On \macos, there is a difference between a window and view;
normally expressed as widgets in Qt. Qt makes assumptions about its
parent-child hierarchy that make it complex to put an arbitrary Qt widget
into a hierarchy of "normal" views from Apple frameworks. QMacNativeWidget
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index c31e9750bf..2477510520 100644
--- a/src/widgets/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
@@ -1559,7 +1559,7 @@ bool QMainWindow::event(QEvent *event)
/*!
\property QMainWindow::unifiedTitleAndToolBarOnMac
- \brief whether the window uses the unified title and toolbar look on OS X
+ \brief whether the window uses the unified title and toolbar look on \macos
Note that the Qt 5 implementation has several limitations compared to Qt 4:
\list
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index cb99b58d97..e2271f3d62 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -1441,7 +1441,7 @@ void QMenu::initStyleOption(QStyleOptionMenuItem *option, const QAction *action)
do not support the signals: aboutToHide (), aboutToShow () and hovered ().
It is not possible to display an icon in a native menu on Windows Mobile.
- \section1 QMenu on OS X with Qt Build Against Cocoa
+ \section1 QMenu on \macos with Qt Build Against Cocoa
QMenu can be inserted only once in a menu/menubar. Subsequent insertions will
have no effect or will result in a disabled menu item.
diff --git a/src/widgets/widgets/qmenu_mac.mm b/src/widgets/widgets/qmenu_mac.mm
index d48041b385..fef1eb2cf4 100644
--- a/src/widgets/widgets/qmenu_mac.mm
+++ b/src/widgets/widgets/qmenu_mac.mm
@@ -73,7 +73,7 @@ inline QPlatformNativeInterface::NativeResourceForIntegrationFunction resolvePla
/*!
\since 5.2
- Returns the native NSMenu for this menu. Available on OS X only.
+ Returns the native NSMenu for this menu. Available on \macos only.
\note Qt sets the delegate on the native menu. If you need to set your own
delegate, make sure you save the original one and forward any calls to it.
@@ -94,7 +94,7 @@ NSMenu *QMenu::toNSMenu()
\since 5.2
Set this menu to be the dock menu available by option-clicking
- on the application dock icon. Available on OS X only.
+ on the application dock icon. Available on \macos only.
*/
void QMenu::setAsDockMenu()
{
@@ -112,7 +112,7 @@ void QMenu::setAsDockMenu()
\deprecated
Sets this \a menu to be the dock menu available by option-clicking
- on the application dock icon. Available on OS X only.
+ on the application dock icon. Available on \macos only.
Deprecated; use \l QMenu::setAsDockMenu() instead.
*/
@@ -142,7 +142,7 @@ void QMenuPrivate::moveWidgetToPlatformItem(QWidget *widget, QPlatformMenuItem*
/*!
\since 5.2
- Returns the native NSMenu for this menu bar. Available on OS X only.
+ Returns the native NSMenu for this menu bar. Available on \macos only.
\note Qt may set the delegate on the native menu bar. If you need to set your
own delegate, make sure you save the original one and forward any calls to it.
diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp
index 3a90e14655..45b7b3091a 100644
--- a/src/widgets/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
@@ -612,15 +612,15 @@ void QMenuBar::initStyleOption(QStyleOptionMenuItem *option, const QAction *acti
for items in the menu bar are only shown when the \uicontrol{Alt} key is
pressed.
- \section1 QMenuBar on OS X
+ \section1 QMenuBar on \macos
- QMenuBar on OS X is a wrapper for using the system-wide menu bar.
+ QMenuBar on \macos is a wrapper for using the system-wide menu bar.
If you have multiple menu bars in one dialog the outermost menu bar
(normally inside a widget with widget flag Qt::Window) will
be used for the system-wide menu bar.
- Qt for OS X also provides a menu bar merging feature to make
- QMenuBar conform more closely to accepted OS X menu bar layout.
+ Qt for \macos also provides a menu bar merging feature to make
+ QMenuBar conform more closely to accepted \macos menu bar layout.
The merging functionality is based on string matching the title of
a QMenu entry. These strings are translated (using QObject::tr())
in the "QMenuBar" context. If an entry is moved its slots will still
@@ -659,7 +659,7 @@ void QMenuBar::initStyleOption(QStyleOptionMenuItem *option, const QAction *acti
\b{Note:} The text used for the application name in the menu
bar is obtained from the value set in the \c{Info.plist} file in
- the application's bundle. See \l{Qt for OS X - Deployment}
+ the application's bundle. See \l{Qt for macOS - Deployment}
for more information.
\section1 QMenuBar on Windows CE
@@ -889,7 +889,7 @@ void QMenuBar::setActiveAction(QAction *act)
/*!
Removes all the actions from the menu bar.
- \note On OS X, menu items that have been merged to the system
+ \note On \macos, menu items that have been merged to the system
menu bar are not removed by this function. One way to handle this
would be to remove the extra actions yourself. You can set the
\l{QAction::MenuRole}{menu role} on the different menus, so that
@@ -1794,7 +1794,7 @@ QWidget *QMenuBar::cornerWidget(Qt::Corner corner) const
\since 4.6
This property specifies whether or not the menubar should be used as a native menubar on platforms
- that support it. The currently supported platforms are OS X and Windows CE. On these platforms
+ that support it. The currently supported platforms are \macos and Windows CE. On these platforms
if this property is \c true, the menubar is used in the native menubar and is not in the window of
its parent, if false the menubar remains in the window. On other platforms the value of this
attribute has no effect.
diff --git a/src/widgets/widgets/qrubberband.cpp b/src/widgets/widgets/qrubberband.cpp
index 13aa66dec7..123c955684 100644
--- a/src/widgets/widgets/qrubberband.cpp
+++ b/src/widgets/widgets/qrubberband.cpp
@@ -132,7 +132,7 @@ void QRubberBand::initStyleOption(QStyleOptionRubberBand *option) const
By default a rectangular rubber band (\a s is \c Rectangle) will
use a mask, so that a small border of the rectangle is all
- that is visible. Some styles (e.g., native OS X) will
+ that is visible. Some styles (e.g., native \macos) will
change this and call QWidget::setWindowOpacity() to make a
semi-transparent filled selection rectangle.
*/
diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp
index fe04299b92..d56c6b39d1 100644
--- a/src/widgets/widgets/qtabbar.cpp
+++ b/src/widgets/widgets/qtabbar.cpp
@@ -140,60 +140,59 @@ void QTabBarPrivate::updateMacBorderMetrics()
}
/*!
- Initialize \a option with the values from the tab at \a tabIndex. This method
- is useful for subclasses when they need a QStyleOptionTab,
- but don't want to fill in all the information themselves.
-
- \sa QStyleOption::initFrom(), QTabWidget::initStyleOption()
+ \internal
+ This is basically QTabBar::initStyleOption() but
+ without the expensive QFontMetrics::elidedText() call.
*/
-void QTabBar::initStyleOption(QStyleOptionTab *option, int tabIndex) const
+
+void QTabBarPrivate::initBasicStyleOption(QStyleOptionTab *option, int tabIndex) const
{
- Q_D(const QTabBar);
- int totalTabs = d->tabList.size();
+ Q_Q(const QTabBar);
+ const int totalTabs = tabList.size();
if (!option || (tabIndex < 0 || tabIndex >= totalTabs))
return;
- const QTabBarPrivate::Tab &tab = d->tabList.at(tabIndex);
- option->initFrom(this);
+ const QTabBarPrivate::Tab &tab = tabList.at(tabIndex);
+ option->initFrom(q);
option->state &= ~(QStyle::State_HasFocus | QStyle::State_MouseOver);
- option->rect = tabRect(tabIndex);
- bool isCurrent = tabIndex == d->currentIndex;
+ option->rect = q->tabRect(tabIndex);
+ const bool isCurrent = tabIndex == currentIndex;
option->row = 0;
- if (tabIndex == d->pressedIndex)
+ if (tabIndex == pressedIndex)
option->state |= QStyle::State_Sunken;
if (isCurrent)
option->state |= QStyle::State_Selected;
- if (isCurrent && hasFocus())
+ if (isCurrent && q->hasFocus())
option->state |= QStyle::State_HasFocus;
if (!tab.enabled)
option->state &= ~QStyle::State_Enabled;
- if (isActiveWindow())
+ if (q->isActiveWindow())
option->state |= QStyle::State_Active;
- if (!d->dragInProgress && option->rect == d->hoverRect)
+ if (!dragInProgress && option->rect == hoverRect)
option->state |= QStyle::State_MouseOver;
- option->shape = d->shape;
+ option->shape = shape;
option->text = tab.text;
if (tab.textColor.isValid())
- option->palette.setColor(foregroundRole(), tab.textColor);
+ option->palette.setColor(q->foregroundRole(), tab.textColor);
option->icon = tab.icon;
- option->iconSize = iconSize(); // Will get the default value then.
+ option->iconSize = q->iconSize(); // Will get the default value then.
option->leftButtonSize = tab.leftWidget ? tab.leftWidget->size() : QSize();
option->rightButtonSize = tab.rightWidget ? tab.rightWidget->size() : QSize();
- option->documentMode = d->documentMode;
+ option->documentMode = documentMode;
- if (tabIndex > 0 && tabIndex - 1 == d->currentIndex)
+ if (tabIndex > 0 && tabIndex - 1 == currentIndex)
option->selectedPosition = QStyleOptionTab::PreviousIsSelected;
- else if (tabIndex + 1 < totalTabs && tabIndex + 1 == d->currentIndex)
+ else if (tabIndex + 1 < totalTabs && tabIndex + 1 == currentIndex)
option->selectedPosition = QStyleOptionTab::NextIsSelected;
else
option->selectedPosition = QStyleOptionTab::NotAdjacent;
- bool paintBeginning = (tabIndex == 0) || (d->dragInProgress && tabIndex == d->pressedIndex + 1);
- bool paintEnd = (tabIndex == totalTabs - 1) || (d->dragInProgress && tabIndex == d->pressedIndex - 1);
+ const bool paintBeginning = (tabIndex == 0) || (dragInProgress && tabIndex == pressedIndex + 1);
+ const bool paintEnd = (tabIndex == totalTabs - 1) || (dragInProgress && tabIndex == pressedIndex - 1);
if (paintBeginning) {
if (paintEnd)
option->position = QStyleOptionTab::OnlyOneTab;
@@ -206,7 +205,7 @@ void QTabBar::initStyleOption(QStyleOptionTab *option, int tabIndex) const
}
#ifndef QT_NO_TABWIDGET
- if (const QTabWidget *tw = qobject_cast<const QTabWidget *>(parentWidget())) {
+ if (const QTabWidget *tw = qobject_cast<const QTabWidget *>(q->parentWidget())) {
option->features |= QStyleOptionTab::HasFrame;
if (tw->cornerWidget(Qt::TopLeftCorner) || tw->cornerWidget(Qt::BottomLeftCorner))
option->cornerWidgets |= QStyleOptionTab::LeftCornerWidget;
@@ -214,6 +213,19 @@ void QTabBar::initStyleOption(QStyleOptionTab *option, int tabIndex) const
option->cornerWidgets |= QStyleOptionTab::RightCornerWidget;
}
#endif
+}
+
+/*!
+ Initialize \a option with the values from the tab at \a tabIndex. This method
+ is useful for subclasses when they need a QStyleOptionTab,
+ but don't want to fill in all the information themselves.
+
+ \sa QStyleOption::initFrom(), QTabWidget::initStyleOption()
+*/
+void QTabBar::initStyleOption(QStyleOptionTab *option, int tabIndex) const
+{
+ Q_D(const QTabBar);
+ d->initBasicStyleOption(option, tabIndex);
QRect textRect = style()->subElementRect(QStyle::SE_TabBarTabText, option, this);
option->text = fontMetrics().elidedText(option->text, d->elideMode, textRect.width(),
@@ -1094,6 +1106,7 @@ void QTabBar::setTabText(int index, const QString &text)
{
Q_D(QTabBar);
if (QTabBarPrivate::Tab *tab = d->at(index)) {
+ d->textSizes.remove(tab->text);
tab->text = text;
#ifndef QT_NO_SHORTCUT
releaseShortcut(tab->shortcutId);
@@ -1453,7 +1466,7 @@ QSize QTabBar::tabSizeHint(int index) const
Q_D(const QTabBar);
if (const QTabBarPrivate::Tab *tab = d->at(index)) {
QStyleOptionTab opt;
- initStyleOption(&opt, index);
+ d->initBasicStyleOption(&opt, index);
opt.text = d->tabList.at(index).text;
QSize iconSize = tab->icon.isNull() ? QSize(0, 0) : opt.iconSize;
int hframe = style()->pixelMetric(QStyle::PM_TabBarTabHSpace, &opt, this);
@@ -1479,13 +1492,16 @@ QSize QTabBar::tabSizeHint(int index) const
if (!opt.icon.isNull())
padding += 4;
+ QHash<QString, QSize>::iterator it = d->textSizes.find(tab->text);
+ if (it == d->textSizes.end())
+ it = d->textSizes.insert(tab->text, fm.size(Qt::TextShowMnemonic, tab->text));
+ const int textWidth = it.value().width();
QSize csz;
if (verticalTabs(d->shape)) {
csz = QSize( qMax(maxWidgetWidth, qMax(fm.height(), iconSize.height())) + vframe,
- fm.size(Qt::TextShowMnemonic, tab->text).width() + iconSize.width() + hframe + widgetHeight + padding);
+ textWidth + iconSize.width() + hframe + widgetHeight + padding);
} else {
- csz = QSize(fm.size(Qt::TextShowMnemonic, tab->text).width() + iconSize.width() + hframe
- + widgetWidth + padding,
+ csz = QSize(textWidth + iconSize.width() + hframe + widgetWidth + padding,
qMax(maxWidgetHeight, qMax(fm.height(), iconSize.height())) + vframe);
}
@@ -2157,15 +2173,21 @@ void QTabBarPrivate::setCurrentNextEnabledIndex(int offset)
void QTabBar::changeEvent(QEvent *event)
{
Q_D(QTabBar);
- if (event->type() == QEvent::StyleChange) {
+ switch (event->type()) {
+ case QEvent::StyleChange:
if (!d->elideModeSetByUser)
d->elideMode = Qt::TextElideMode(style()->styleHint(QStyle::SH_TabBar_ElideMode, 0, this));
if (!d->useScrollButtonsSetByUser)
d->useScrollButtons = !style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, 0, this);
+ // fallthrough
+ case QEvent::FontChange:
+ d->textSizes.clear();
d->refresh();
- } else if (event->type() == QEvent::FontChange) {
- d->refresh();
+ break;
+ default:
+ break;
}
+
QWidget::changeEvent(event);
}
@@ -2208,6 +2230,7 @@ void QTabBar::setElideMode(Qt::TextElideMode mode)
Q_D(QTabBar);
d->elideMode = mode;
d->elideModeSetByUser = true;
+ d->textSizes.clear();
d->refresh();
}
@@ -2398,7 +2421,7 @@ void QTabBar::setMovable(bool movable)
\since 4.5
This property is used as a hint for styles to draw the tabs in a different
- way then they would normally look in a tab widget. On OS X this will
+ way then they would normally look in a tab widget. On \macos this will
look similar to the tabs in Safari or Leopard's Terminal.app.
\sa QTabWidget::documentMode
diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h
index 04adf96881..0e9dce84b3 100644
--- a/src/widgets/widgets/qtabbar_p.h
+++ b/src/widgets/widgets/qtabbar_p.h
@@ -169,6 +169,7 @@ public:
#endif //QT_NO_ANIMATION
};
QList<Tab> tabList;
+ mutable QHash<QString, QSize> textSizes;
int calculateNewPosition(int from, int to, int index) const;
void slide(int from, int to);
@@ -202,6 +203,8 @@ public:
void autoHideTabs();
QRect normalizedScrollRect(int index = -1);
+ void initBasicStyleOption(QStyleOptionTab *option, int tabIndex) const;
+
void makeVisible(int index);
QSize iconSize;
Qt::TextElideMode elideMode;
diff --git a/src/widgets/widgets/qtabwidget.cpp b/src/widgets/widgets/qtabwidget.cpp
index 3ddf4df624..5dce76056c 100644
--- a/src/widgets/widgets/qtabwidget.cpp
+++ b/src/widgets/widgets/qtabwidget.cpp
@@ -1322,7 +1322,7 @@ void QTabWidget::setUsesScrollButtons(bool useButtons)
/*!
\property QTabWidget::documentMode
\brief Whether or not the tab widget is rendered in a mode suitable for document
- pages. This is the same as document mode on OS X.
+ pages. This is the same as document mode on \macos.
\since 4.5
When this property is set the tab widget frame is not rendered. This mode is useful
diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp
index b93cefd867..61bc6d19cf 100644
--- a/src/widgets/widgets/qtoolbar.cpp
+++ b/src/widgets/widgets/qtoolbar.cpp
@@ -405,7 +405,7 @@ void QToolBarPrivate::plug(const QRect &r)
When a toolbar is resized in such a way that it is too small to
show all the items it contains, an extension button will appear as
the last item in the toolbar. Pressing the extension button will
- pop up a menu containing the items that does not currently fit in
+ pop up a menu containing the items that do not currently fit in
the toolbar.
When a QToolBar is not a child of a QMainWindow, it loses the ability
diff --git a/src/widgets/widgets/qtoolbutton.cpp b/src/widgets/widgets/qtoolbutton.cpp
index aef4634a9a..8b40325a24 100644
--- a/src/widgets/widgets/qtoolbutton.cpp
+++ b/src/widgets/widgets/qtoolbutton.cpp
@@ -876,7 +876,7 @@ QToolButton::ToolButtonPopupMode QToolButton::popupMode() const
The default is disabled (i.e. false).
- This property is currently ignored on OS X when using QMacStyle.
+ This property is currently ignored on \macos when using QMacStyle.
*/
void QToolButton::setAutoRaise(bool enable)
{