summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp21
-rw-r--r--src/widgets/dialogs/qfiledialog_p.h5
-rw-r--r--src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h11
-rw-r--r--src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h11
-rw-r--r--src/widgets/itemviews/qfileiconprovider_p.h11
-rw-r--r--src/widgets/itemviews/qstyleditemdelegate.cpp3
-rw-r--r--src/widgets/kernel/qboxlayout.cpp18
-rw-r--r--src/widgets/kernel/qformlayout.cpp22
-rw-r--r--src/widgets/kernel/qgridlayout.cpp23
-rw-r--r--src/widgets/kernel/qlayout.cpp41
-rw-r--r--src/widgets/kernel/qlayout_p.h2
-rw-r--r--src/widgets/kernel/qwidgetwindow_qpa_p.h11
-rw-r--r--src/widgets/kernel/qwindowcontainer_p.h11
-rw-r--r--src/widgets/styles/qfusionstyle_p.h11
-rw-r--r--src/widgets/styles/qgtkstyle_p.h11
-rw-r--r--src/widgets/styles/qmacstyle_mac.mm150
-rw-r--r--src/widgets/styles/qmacstyle_mac_p.h11
-rw-r--r--src/widgets/styles/qmacstyle_mac_p_p.h8
-rw-r--r--src/widgets/styles/qstylehelper.cpp10
-rw-r--r--src/widgets/styles/qstylehelper_p.h2
-rw-r--r--src/widgets/styles/qwindowscestyle_p.h11
-rw-r--r--src/widgets/styles/qwindowsmobilestyle_p.h11
-rw-r--r--src/widgets/styles/qwindowsstyle_p.h11
-rw-r--r--src/widgets/styles/qwindowsvistastyle_p.h11
-rw-r--r--src/widgets/styles/qwindowsxpstyle_p.h11
-rw-r--r--src/widgets/widgets/qkeysequenceedit_p.h11
-rw-r--r--src/widgets/widgets/qplaintextedit.cpp3
-rw-r--r--src/widgets/widgets/qsizegrip.cpp2
-rw-r--r--src/widgets/widgets/qtoolbutton.cpp4
29 files changed, 412 insertions, 56 deletions
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 9219757dbf..e53cdeac29 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -454,15 +454,15 @@ QByteArray QFileDialog::saveState() const
stream << d->qFileDialogUi->splitter->saveState();
stream << d->qFileDialogUi->sidebar->urls();
} else {
- stream << QByteArray();
- stream << QList<QUrl>();
+ stream << d->splitterState;
+ stream << d->sidebarUrls;
}
stream << history();
stream << *lastVisitedDir();
if (d->usingWidgets())
stream << d->qFileDialogUi->treeView->header()->saveState();
else
- stream << QByteArray();
+ stream << d->headerData;
stream << qint32(viewMode());
return data;
}
@@ -484,9 +484,6 @@ bool QFileDialog::restoreState(const QByteArray &state)
QDataStream stream(&sd, QIODevice::ReadOnly);
if (stream.atEnd())
return false;
- QByteArray splitterState;
- QByteArray headerData;
- QList<QUrl> bookmarks;
QStringList history;
QString currentDirectory;
qint32 marker;
@@ -497,11 +494,11 @@ bool QFileDialog::restoreState(const QByteArray &state)
if (marker != QFileDialogMagic || v != version)
return false;
- stream >> splitterState
- >> bookmarks
+ stream >> d->splitterState
+ >> d->sidebarUrls
>> history
>> currentDirectory
- >> headerData
+ >> d->headerData
>> viewMode;
setDirectory(lastVisitedDir()->isEmpty() ? currentDirectory : *lastVisitedDir());
@@ -510,7 +507,7 @@ bool QFileDialog::restoreState(const QByteArray &state)
if (!d->usingWidgets())
return true;
- if (!d->qFileDialogUi->splitter->restoreState(splitterState))
+ if (!d->qFileDialogUi->splitter->restoreState(d->splitterState))
return false;
QList<int> list = d->qFileDialogUi->splitter->sizes();
if (list.count() >= 2 && list.at(0) == 0 && list.at(1) == 0) {
@@ -519,12 +516,12 @@ bool QFileDialog::restoreState(const QByteArray &state)
d->qFileDialogUi->splitter->setSizes(list);
}
- d->qFileDialogUi->sidebar->setUrls(bookmarks);
+ d->qFileDialogUi->sidebar->setUrls(d->sidebarUrls);
while (history.count() > 5)
history.pop_front();
setHistory(history);
QHeaderView *headerView = d->qFileDialogUi->treeView->header();
- if (!headerView->restoreState(headerData))
+ if (!headerView->restoreState(d->headerData))
return false;
QList<QAction*> actions = headerView->actions();
diff --git a/src/widgets/dialogs/qfiledialog_p.h b/src/widgets/dialogs/qfiledialog_p.h
index 632bbca5a4..89c6414b71 100644
--- a/src/widgets/dialogs/qfiledialog_p.h
+++ b/src/widgets/dialogs/qfiledialog_p.h
@@ -273,6 +273,11 @@ public:
QSharedPointer<QFileDialogOptions> options;
+ // Memory of what was read from QSettings in restoreState() in case widgets are not used
+ QByteArray splitterState;
+ QByteArray headerData;
+ QList<QUrl> sidebarUrls;
+
~QFileDialogPrivate();
private:
diff --git a/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h b/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h
index 1338114d96..1c12f15744 100644
--- a/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h
+++ b/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h
@@ -42,6 +42,17 @@
#ifndef QGRAPHICSGRIDLAYOUTENGINE_P_H
#define QGRAPHICSGRIDLAYOUTENGINE_P_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include <QtGui/private/qgridlayoutengine_p.h>
#ifndef QT_NO_GRAPHICSVIEW
diff --git a/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h b/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h
index 275ebab6a1..8770e96136 100644
--- a/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h
+++ b/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h
@@ -41,6 +41,17 @@
#ifndef QGRAPHICSLAYOUTSTYLEINFO_P_H
#define QGRAPHICSLAYOUTSTYLEINFO_P_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include <QtGui/private/qabstractlayoutstyleinfo_p.h>
#include <QtWidgets/qstyleoption.h>
diff --git a/src/widgets/itemviews/qfileiconprovider_p.h b/src/widgets/itemviews/qfileiconprovider_p.h
index 9b2d536258..1c50a7e772 100644
--- a/src/widgets/itemviews/qfileiconprovider_p.h
+++ b/src/widgets/itemviews/qfileiconprovider_p.h
@@ -42,6 +42,17 @@
#ifndef QFILEICONPROVIDER_P_H
#define QFILEICONPROVIDER_P_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include "qfileiconprovider.h"
#include <QtCore/qstring.h>
diff --git a/src/widgets/itemviews/qstyleditemdelegate.cpp b/src/widgets/itemviews/qstyleditemdelegate.cpp
index da5aeb3290..b5fc8d7d63 100644
--- a/src/widgets/itemviews/qstyleditemdelegate.cpp
+++ b/src/widgets/itemviews/qstyleditemdelegate.cpp
@@ -627,6 +627,9 @@ void QStyledItemDelegate::setItemEditorFactory(QItemEditorFactory *factory)
\li \uicontrol Esc
\endlist
+ If the \a editor's type is QTextEdit or QPlainTextEdit then \uicontrol Enter and
+ \uicontrol Return keys are \e not handled.
+
In the case of \uicontrol Tab, \uicontrol Backtab, \uicontrol Enter and \uicontrol Return
key press events, the \a editor's data is comitted to the model
and the editor is closed. If the \a event is a \uicontrol Tab key press
diff --git a/src/widgets/kernel/qboxlayout.cpp b/src/widgets/kernel/qboxlayout.cpp
index 157fa55d2e..a186326551 100644
--- a/src/widgets/kernel/qboxlayout.cpp
+++ b/src/widgets/kernel/qboxlayout.cpp
@@ -51,20 +51,6 @@
QT_BEGIN_NAMESPACE
-/*
- Returns \c true if the \a widget can be added to the \a layout;
- otherwise returns \c false.
-*/
-static bool checkWidget(QLayout *layout, QWidget *widget)
-{
- if (!widget) {
- qWarning("QLayout: Cannot add null widget to %s/%s", layout->metaObject()->className(),
- layout->objectName().toLocal8Bit().data());
- return false;
- }
- return true;
-}
-
struct QBoxLayoutItem
{
QBoxLayoutItem(QLayoutItem *it, int stretch_ = 0)
@@ -958,6 +944,8 @@ void QBoxLayout::insertSpacerItem(int index, QSpacerItem *spacerItem)
void QBoxLayout::insertLayout(int index, QLayout *layout, int stretch)
{
Q_D(QBoxLayout);
+ if (!d->checkLayout(layout))
+ return;
if (!adoptLayout(layout))
return;
if (index < 0) // append
@@ -991,7 +979,7 @@ void QBoxLayout::insertWidget(int index, QWidget *widget, int stretch,
Qt::Alignment alignment)
{
Q_D(QBoxLayout);
- if (!checkWidget(this, widget))
+ if (!d->checkWidget(widget))
return;
addChildWidget(widget);
if (index < 0) // append
diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp
index 239e1ce1e2..9f545b858a 100644
--- a/src/widgets/kernel/qformlayout.cpp
+++ b/src/widgets/kernel/qformlayout.cpp
@@ -1280,6 +1280,8 @@ void QFormLayout::addRow(QLayout *layout)
void QFormLayout::insertRow(int row, QWidget *label, QWidget *field)
{
Q_D(QFormLayout);
+ if ((label && !d->checkWidget(label)) || (field && !d->checkWidget(field)))
+ return;
row = d->insertRow(row);
if (label)
@@ -1295,6 +1297,8 @@ void QFormLayout::insertRow(int row, QWidget *label, QWidget *field)
void QFormLayout::insertRow(int row, QWidget *label, QLayout *field)
{
Q_D(QFormLayout);
+ if ((label && !d->checkWidget(label)) || (field && !d->checkLayout(field)))
+ return;
row = d->insertRow(row);
if (label)
@@ -1313,6 +1317,10 @@ void QFormLayout::insertRow(int row, QWidget *label, QLayout *field)
*/
void QFormLayout::insertRow(int row, const QString &labelText, QWidget *field)
{
+ Q_D(QFormLayout);
+ if (field && !d->checkWidget(field))
+ return;
+
QLabel *label = 0;
if (!labelText.isEmpty()) {
label = new QLabel(labelText);
@@ -1331,6 +1339,10 @@ void QFormLayout::insertRow(int row, const QString &labelText, QWidget *field)
*/
void QFormLayout::insertRow(int row, const QString &labelText, QLayout *field)
{
+ Q_D(QFormLayout);
+ if (field && !d->checkLayout(field))
+ return;
+
insertRow(row, labelText.isEmpty() ? 0 : new QLabel(labelText), field);
}
@@ -1344,11 +1356,8 @@ void QFormLayout::insertRow(int row, const QString &labelText, QLayout *field)
void QFormLayout::insertRow(int row, QWidget *widget)
{
Q_D(QFormLayout);
-
- if (!widget) {
- qWarning("QFormLayout: Cannot add null field to %s", qPrintable(objectName()));
+ if (!d->checkWidget(widget))
return;
- }
row = d->insertRow(row);
d->setWidget(row, SpanningRole, widget);
@@ -1365,11 +1374,8 @@ void QFormLayout::insertRow(int row, QWidget *widget)
void QFormLayout::insertRow(int row, QLayout *layout)
{
Q_D(QFormLayout);
-
- if (!layout) {
- qWarning("QFormLayout: Cannot add null field to %s", qPrintable(objectName()));
+ if (!d->checkLayout(layout))
return;
- }
row = d->insertRow(row);
d->setLayout(row, SpanningRole, layout);
diff --git a/src/widgets/kernel/qgridlayout.cpp b/src/widgets/kernel/qgridlayout.cpp
index 5434c40f97..6782e4a9f8 100644
--- a/src/widgets/kernel/qgridlayout.cpp
+++ b/src/widgets/kernel/qgridlayout.cpp
@@ -1430,20 +1430,6 @@ void QGridLayout::addItem(QLayoutItem *item, int row, int column, int rowSpan, i
invalidate();
}
-/*
- Returns \c true if the widget \a w can be added to the layout \a l;
- otherwise returns \c false.
-*/
-static bool checkWidget(QLayout *l, QWidget *w)
-{
- if (!w) {
- qWarning("QLayout: Cannot add null widget to %s/%s", l->metaObject()->className(),
- l->objectName().toLocal8Bit().data());
- return false;
- }
- return true;
-}
-
/*!
Adds the given \a widget to the cell grid at \a row, \a column. The
top-left position is (0, 0) by default.
@@ -1454,7 +1440,8 @@ static bool checkWidget(QLayout *l, QWidget *w)
*/
void QGridLayout::addWidget(QWidget *widget, int row, int column, Qt::Alignment alignment)
{
- if (!checkWidget(this, widget))
+ Q_D(QGridLayout);
+ if (!d->checkWidget(widget))
return;
if (row < 0 || column < 0) {
qWarning("QGridLayout: Cannot add %s/%s to %s/%s at row %d column %d",
@@ -1483,7 +1470,7 @@ void QGridLayout::addWidget(QWidget *widget, int fromRow, int fromColumn,
int rowSpan, int columnSpan, Qt::Alignment alignment)
{
Q_D(QGridLayout);
- if (!checkWidget(this, widget))
+ if (!d->checkWidget(widget))
return;
int toRow = (rowSpan < 0) ? -1 : fromRow + rowSpan - 1;
int toColumn = (columnSpan < 0) ? -1 : fromColumn + columnSpan - 1;
@@ -1518,6 +1505,8 @@ void QGridLayout::addWidget(QWidget *widget, int fromRow, int fromColumn,
void QGridLayout::addLayout(QLayout *layout, int row, int column, Qt::Alignment alignment)
{
Q_D(QGridLayout);
+ if (!d->checkLayout(layout))
+ return;
if (!adoptLayout(layout))
return;
QGridBox *b = new QGridBox(layout);
@@ -1538,6 +1527,8 @@ void QGridLayout::addLayout(QLayout *layout, int row, int column,
int rowSpan, int columnSpan, Qt::Alignment alignment)
{
Q_D(QGridLayout);
+ if (!d->checkLayout(layout))
+ return;
if (!adoptLayout(layout))
return;
QGridBox *b = new QGridBox(layout);
diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp
index eb21a580b1..778514f47a 100644
--- a/src/widgets/kernel/qlayout.cpp
+++ b/src/widgets/kernel/qlayout.cpp
@@ -858,6 +858,47 @@ void QLayoutPrivate::reparentChildWidgets(QWidget *mw)
}
/*!
+ Returns \c true if the \a widget can be added to the \a layout;
+ otherwise returns \c false.
+*/
+bool QLayoutPrivate::checkWidget(QWidget *widget) const
+{
+ Q_Q(const QLayout);
+ if (!widget) {
+ qWarning("QLayout: Cannot add a null widget to %s/%s", q->metaObject()->className(),
+ qPrintable(q->objectName()));
+ return false;
+ }
+ if (widget == q->parentWidget()) {
+ qWarning("QLayout: Cannot add parent widget %s/%s to its child layout %s/%s",
+ widget->metaObject()->className(), qPrintable(widget->objectName()),
+ q->metaObject()->className(), qPrintable(q->objectName()));
+ return false;
+ }
+ return true;
+}
+
+/*!
+ Returns \c true if the \a otherLayout can be added to the \a layout;
+ otherwise returns \c false.
+*/
+bool QLayoutPrivate::checkLayout(QLayout *otherLayout) const
+{
+ Q_Q(const QLayout);
+ if (!otherLayout) {
+ qWarning("QLayout: Cannot add a null layout to %s/%s", q->metaObject()->className(),
+ qPrintable(q->objectName()));
+ return false;
+ }
+ if (otherLayout == q) {
+ qWarning("QLayout: Cannot add layout %s/%s to itself", q->metaObject()->className(),
+ qPrintable(q->objectName()));
+ return false;
+ }
+ return true;
+}
+
+/*!
This function is called from \c addWidget() functions in
subclasses to add \a w as a managed widget of a layout.
diff --git a/src/widgets/kernel/qlayout_p.h b/src/widgets/kernel/qlayout_p.h
index 2100d86aba..71e0f9bcd3 100644
--- a/src/widgets/kernel/qlayout_p.h
+++ b/src/widgets/kernel/qlayout_p.h
@@ -76,6 +76,8 @@ public:
void getMargin(int *result, int userMargin, QStyle::PixelMetric pm) const;
void doResize(const QSize &);
void reparentChildWidgets(QWidget *mw);
+ bool checkWidget(QWidget *widget) const;
+ bool checkLayout(QLayout *otherLayout) const;
static QWidgetItem *createWidgetItem(const QLayout *layout, QWidget *widget);
static QSpacerItem *createSpacerItem(const QLayout *layout, int w, int h, QSizePolicy::Policy hPolicy = QSizePolicy::Minimum, QSizePolicy::Policy vPolicy = QSizePolicy::Minimum);
diff --git a/src/widgets/kernel/qwidgetwindow_qpa_p.h b/src/widgets/kernel/qwidgetwindow_qpa_p.h
index 06ba8ea646..76ba618afe 100644
--- a/src/widgets/kernel/qwidgetwindow_qpa_p.h
+++ b/src/widgets/kernel/qwidgetwindow_qpa_p.h
@@ -42,6 +42,17 @@
#ifndef QWIDGETWINDOW_QPA_P_H
#define QWIDGETWINDOW_QPA_P_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include <QtGui/qwindow.h>
#include <QtCore/private/qobject_p.h>
diff --git a/src/widgets/kernel/qwindowcontainer_p.h b/src/widgets/kernel/qwindowcontainer_p.h
index 014b163f97..45b3cc021f 100644
--- a/src/widgets/kernel/qwindowcontainer_p.h
+++ b/src/widgets/kernel/qwindowcontainer_p.h
@@ -42,6 +42,17 @@
#ifndef QWINDOWCONTAINER_H
#define QWINDOWCONTAINER_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include <QtWidgets/qwidget.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/styles/qfusionstyle_p.h b/src/widgets/styles/qfusionstyle_p.h
index 9e5a55918d..ceee6f8b03 100644
--- a/src/widgets/styles/qfusionstyle_p.h
+++ b/src/widgets/styles/qfusionstyle_p.h
@@ -42,6 +42,17 @@
#ifndef QFUSIONSTYLE_P_H
#define QFUSIONSTYLE_P_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include <QtWidgets/qcommonstyle.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/styles/qgtkstyle_p.h b/src/widgets/styles/qgtkstyle_p.h
index 525d7f840a..93bb0d309b 100644
--- a/src/widgets/styles/qgtkstyle_p.h
+++ b/src/widgets/styles/qgtkstyle_p.h
@@ -42,6 +42,17 @@
#ifndef QGTKSTYLE_P_H
#define QGTKSTYLE_P_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include <private/qwindowsstyle_p.h>
#include <QtGui/QPalette>
#include <QtGui/QFont>
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm
index 0845a5eb02..d74e032412 100644
--- a/src/widgets/styles/qmacstyle_mac.mm
+++ b/src/widgets/styles/qmacstyle_mac.mm
@@ -1335,7 +1335,7 @@ void QMacStylePrivate::initComboboxBdi(const QStyleOptionComboBox *combo, HIThem
bdi->adornment = kThemeAdornmentFocus;
if (combo->activeSubControls & QStyle::SC_ComboBoxArrow)
bdi->state = kThemeStatePressed;
- else if (tds == kThemeStateInactive)
+ else if (tds == kThemeStateInactive && QSysInfo::MacintoshVersion <= QSysInfo::MV_10_9)
bdi->state = kThemeStateActive;
else
bdi->state = tds;
@@ -1702,7 +1702,7 @@ void QMacStylePrivate::setAutoDefaultButton(QObject *button) const
}
QMacStylePrivate::QMacStylePrivate()
- : mouseDown(false)
+ : mouseDown(false), backingStoreNSView(nil)
{
defaultButtonStart = CFAbsoluteTimeGetCurrent();
memset(&buttonState, 0, sizeof(ButtonState));
@@ -1715,6 +1715,12 @@ QMacStylePrivate::QMacStylePrivate()
}
+QMacStylePrivate::~QMacStylePrivate()
+{
+ Q_FOREACH (NSView *b, buttons)
+ [b release];
+}
+
ThemeDrawState QMacStylePrivate::getDrawState(QStyle::State flags)
{
ThemeDrawState tds = kThemeStateActive;
@@ -1732,6 +1738,97 @@ ThemeDrawState QMacStylePrivate::getDrawState(QStyle::State flags)
return tds;
}
+NSView *QMacStylePrivate::buttonOfKind(ThemeButtonKind kind) const
+{
+ NSView *bv = buttons[kind];
+ if (!bv) {
+ if (kind == kThemePopupButton)
+ bv = [[NSPopUpButton alloc] init];
+ else if (kind == kThemeComboBox)
+ bv = [[NSComboBox alloc] init];
+ else
+ bv = [[NSButton alloc] init];
+
+ switch (kind) {
+ case kThemeArrowButton: {
+ NSButton *bc = (NSButton *)bv;
+ bc.buttonType = NSOnOffButton;
+ bc.bezelStyle = NSDisclosureBezelStyle;
+ break;
+ }
+ case kThemeCheckBox:
+ case kThemeCheckBoxSmall:
+ case kThemeCheckBoxMini: {
+ NSButton *bc = (NSButton *)bv;
+ bc.buttonType = NSSwitchButton;
+ break;
+ }
+ case kThemeRadioButton:
+ case kThemeRadioButtonSmall:
+ case kThemeRadioButtonMini: {
+ NSButton *bc = (NSButton *)bv;
+ bc.buttonType = NSRadioButton;
+ break;
+ }
+ case kThemePushButton:
+ case kThemePushButtonSmall:
+ case kThemePushButtonMini: {
+ NSButton *bc = (NSButton *)bv;
+ bc.buttonType = NSMomentaryPushButton;
+ bc.bezelStyle = NSRoundedBezelStyle;
+ break;
+ }
+ default:
+ break;
+ }
+
+// if (kind == kThemePushButtonSmall
+// || kind == kThemePopupButtonSmall
+// || kind == kThemeCheckBoxSmall
+// || kind == kThemeRadioButtonSmall)
+// bc.controlSize = NSSmallControlSize;
+// else if (kind == kThemePushButtonMini
+// || kind == kThemePopupButtonMini
+// || kind == kThemeCheckBoxMini
+// || kind == kThemeRadioButtonMini)
+// bc.controlSize = NSMiniControlSize;
+
+ if ([bv isKindOfClass:[NSButton class]]) {
+ NSButton *bc = (NSButton *)bv;
+ bc.title = nil;
+ }
+
+ const_cast<QMacStylePrivate *>(this)->buttons.insert(kind, bv);
+ }
+
+ return bv;
+}
+
+void QMacStylePrivate::drawNSViewInRect(NSView *view, const QRect &qtRect, QPainter *p) const
+{
+ QMacCGContext ctx(p);
+ CGContextSaveGState(ctx);
+
+ [NSGraphicsContext saveGraphicsState];
+ [NSGraphicsContext setCurrentContext:[NSGraphicsContext
+ graphicsContextWithGraphicsPort:ctx flipped:YES]];
+
+ CGRect rect = CGRectMake(qtRect.x() + 1, qtRect.y(), qtRect.width(), qtRect.height());
+
+ [backingStoreNSView addSubview:view];
+ view.frame = rect;
+ [view drawRect:rect];
+ [view removeFromSuperviewWithoutNeedingDisplay];
+
+ [NSGraphicsContext restoreGraphicsState];
+ CGContextRestoreGState(ctx);
+}
+
+void QMacStylePrivate::resolveCurrentNSView(QWindow *window)
+{
+ backingStoreNSView = window ? (NSView *)window->winId() : nil;
+}
+
void QMacStylePrivate::drawColorlessButton(const HIRect &macRect, HIThemeButtonDrawInfo *bdi,
QPainter *p, const QStyleOption *opt) const
{
@@ -1742,8 +1839,12 @@ void QMacStylePrivate::drawColorlessButton(const HIRect &macRect, HIThemeButtonD
finalyoff = 0;
const bool combo = opt->type == QStyleOption::SO_ComboBox;
+ const bool editableCombo = bdi->kind == kThemeComboBox
+ || bdi->kind == kThemeComboBoxSmall
+ || bdi->kind == kThemeComboBoxMini;
const bool button = opt->type == QStyleOption::SO_Button;
const bool pressed = bdi->state == kThemeStatePressed;
+ const bool usingYosemiteOrLater = QSysInfo::MacintoshVersion > QSysInfo::MV_10_9;
if (button && pressed) {
if (bdi->kind == kThemePushButton) {
@@ -1788,7 +1889,7 @@ void QMacStylePrivate::drawColorlessButton(const HIRect &macRect, HIThemeButtonD
if (!combo && !button && bdi->value == kThemeButtonOff) {
pm = activePixmap;
- } else if (combo || button) {
+ } else if (!usingYosemiteOrLater && (combo || button)) {
QImage image = activePixmap.toImage();
for (int y = 0; y < height; ++y) {
@@ -1815,6 +1916,40 @@ void QMacStylePrivate::drawColorlessButton(const HIRect &macRect, HIThemeButtonD
}
}
pm = QPixmap::fromImage(image);
+ } else if ((usingYosemiteOrLater && combo && !editableCombo) || button) {
+ NSButton *bc = (NSButton *)buttonOfKind(bdi->kind);
+ [bc highlight:pressed];
+ bc.enabled = bdi->state != kThemeStateUnavailable && bdi->state != kThemeStateUnavailableInactive;
+ bc.state = bdi->value == kThemeButtonOn ? NSOnState :
+ bdi->value == kThemeButtonMixed ? NSMixedState : NSOffState;
+ p->translate(0, 1);
+ drawNSViewInRect(bc, opt->rect, p);
+ p->translate(0, -1);
+ return;
+ } else if (usingYosemiteOrLater && editableCombo) {
+ QImage image = activePixmap.toImage();
+
+ for (int y = 0; y < height; ++y) {
+ QRgb *scanLine = reinterpret_cast<QRgb *>(image.scanLine(y));
+
+ for (int x = 0; x < width; ++x) {
+ QRgb &pixel = scanLine[x];
+ int gray = qRed(pixel); // We know the image is grayscale
+ int alpha = qAlpha(pixel);
+
+ if (gray == 128 && alpha == 128) {
+ pixel = qRgba(255, 255, 255, 255);
+ } else if (alpha == 0) {
+ pixel = 0;
+ } else {
+ bool belowThreshold = (alpha * gray) / 255 + 255 - alpha < 128;
+ gray = belowThreshold ? 0 : 2 * gray - 255;
+ alpha = belowThreshold ? 0 : 2 * alpha - 255;
+ pixel = qRgba(gray, gray, gray, alpha);
+ }
+ }
+ }
+ pm = QPixmap::fromImage(image);
} else {
QImage activeImage = activePixmap.toImage();
QImage colorlessImage;
@@ -2919,6 +3054,9 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
Q_D(const QMacStyle);
ThemeDrawState tds = d->getDrawState(opt->state);
QMacCGContext cg(p);
+ QWindow *window = w && w->window() ? w->window()->windowHandle() :
+ QStyleHelper::styleObjectWindow(opt->styleObject);
+ const_cast<QMacStylePrivate *>(d)->resolveCurrentNSView(window);
switch (pe) {
case PE_IndicatorArrowUp:
case PE_IndicatorArrowDown:
@@ -3333,6 +3471,9 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
Q_D(const QMacStyle);
ThemeDrawState tds = d->getDrawState(opt->state);
QMacCGContext cg(p);
+ QWindow *window = w && w->window() ? w->window()->windowHandle() :
+ QStyleHelper::styleObjectWindow(opt->styleObject);
+ const_cast<QMacStylePrivate *>(d)->resolveCurrentNSView(window);
switch (ce) {
case CE_HeaderSection:
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
@@ -5050,6 +5191,9 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
Q_D(const QMacStyle);
ThemeDrawState tds = d->getDrawState(opt->state);
QMacCGContext cg(p);
+ QWindow *window = widget && widget->window() ? widget->window()->windowHandle() :
+ QStyleHelper::styleObjectWindow(opt->styleObject);
+ const_cast<QMacStylePrivate *>(d)->resolveCurrentNSView(window);
switch (cc) {
case CC_Slider:
case CC_ScrollBar:
diff --git a/src/widgets/styles/qmacstyle_mac_p.h b/src/widgets/styles/qmacstyle_mac_p.h
index 305bcf871c..b0fb9e06be 100644
--- a/src/widgets/styles/qmacstyle_mac_p.h
+++ b/src/widgets/styles/qmacstyle_mac_p.h
@@ -42,6 +42,17 @@
#ifndef QMACSTYLE_MAC_P_H
#define QMACSTYLE_MAC_P_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include <QtWidgets/qcommonstyle.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h
index 6f42f0ea79..3bbff61340 100644
--- a/src/widgets/styles/qmacstyle_mac_p_p.h
+++ b/src/widgets/styles/qmacstyle_mac_p_p.h
@@ -145,6 +145,7 @@ class QMacStylePrivate : public QCommonStylePrivate
Q_DECLARE_PUBLIC(QMacStyle)
public:
QMacStylePrivate();
+ ~QMacStylePrivate();
// Ideally these wouldn't exist, but since they already exist we need some accessors.
static const int PushButtonLeftOffset;
@@ -194,6 +195,11 @@ public:
void setAutoDefaultButton(QObject *button) const;
+ NSView *buttonOfKind(ThemeButtonKind kind) const;
+
+ void drawNSViewInRect(NSView *view, const QRect &rect, QPainter *p) const;
+ void resolveCurrentNSView(QWindow *window);
+
public:
mutable QPointer<QObject> pressedButton;
mutable QPointer<QObject> defaultButton;
@@ -212,6 +218,8 @@ public:
void *nsscroller;
#endif
void *indicatorBranchButtonCell;
+ NSView *backingStoreNSView;
+ QHash<ThemeButtonKind , NSView *> buttons;
};
QT_END_NAMESPACE
diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp
index 6be07a3f45..49e406a8b7 100644
--- a/src/widgets/styles/qstylehelper.cpp
+++ b/src/widgets/styles/qstylehelper.cpp
@@ -47,6 +47,7 @@
#include <qmath.h>
#include <qscrollbar.h>
#include <qabstractscrollarea.h>
+#include <qwindow.h>
#include "qstylehelper_p.h"
#include <qstringbuilder.h>
@@ -397,5 +398,14 @@ QColor backgroundColor(const QPalette &pal, const QWidget* widget)
return widget->parentWidget()->parentWidget()->palette().color(QPalette::Base);
return pal.color(QPalette::Base);
}
+
+QWindow *styleObjectWindow(QObject *so)
+{
+ if (so)
+ return so->property("_q_styleObjectWindow").value<QWindow *>();
+
+ return 0;
+}
+
}
QT_END_NAMESPACE
diff --git a/src/widgets/styles/qstylehelper_p.h b/src/widgets/styles/qstylehelper_p.h
index 73e5c94dcd..1229af7497 100644
--- a/src/widgets/styles/qstylehelper_p.h
+++ b/src/widgets/styles/qstylehelper_p.h
@@ -68,6 +68,7 @@ class QPainter;
class QPixmap;
class QStyleOptionSlider;
class QStyleOption;
+class QWindow;
namespace QStyleHelper
{
@@ -87,6 +88,7 @@ namespace QStyleHelper
bool hasAncestor(QObject *obj, QAccessible::Role role);
#endif
QColor backgroundColor(const QPalette &pal, const QWidget* widget = 0);
+ QWindow *styleObjectWindow(QObject *so);
}
diff --git a/src/widgets/styles/qwindowscestyle_p.h b/src/widgets/styles/qwindowscestyle_p.h
index 73fb2b7ab7..d5e2ee84ed 100644
--- a/src/widgets/styles/qwindowscestyle_p.h
+++ b/src/widgets/styles/qwindowscestyle_p.h
@@ -42,6 +42,17 @@
#ifndef QWINDOWSCESTYLE_P_H
#define QWINDOWSCESTYLE_P_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include <private/qwindowsstyle_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/styles/qwindowsmobilestyle_p.h b/src/widgets/styles/qwindowsmobilestyle_p.h
index 4262bf5c73..75a4e45ea9 100644
--- a/src/widgets/styles/qwindowsmobilestyle_p.h
+++ b/src/widgets/styles/qwindowsmobilestyle_p.h
@@ -42,6 +42,17 @@
#ifndef QWINDOWSMOBILESTYLE_P_H
#define QWINDOWSMOBILESTYLE_P_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include <private/qwindowsstyle_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/styles/qwindowsstyle_p.h b/src/widgets/styles/qwindowsstyle_p.h
index 1107e70061..39b85ec148 100644
--- a/src/widgets/styles/qwindowsstyle_p.h
+++ b/src/widgets/styles/qwindowsstyle_p.h
@@ -42,6 +42,17 @@
#ifndef QWINDOWSSTYLE_P_H
#define QWINDOWSSTYLE_P_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include <QtWidgets/qcommonstyle.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/styles/qwindowsvistastyle_p.h b/src/widgets/styles/qwindowsvistastyle_p.h
index f7914f1645..1b3201c026 100644
--- a/src/widgets/styles/qwindowsvistastyle_p.h
+++ b/src/widgets/styles/qwindowsvistastyle_p.h
@@ -42,6 +42,17 @@
#ifndef QWINDOWSVISTASTYLE_P_H
#define QWINDOWSVISTASTYLE_P_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include <private/qwindowsxpstyle_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/styles/qwindowsxpstyle_p.h b/src/widgets/styles/qwindowsxpstyle_p.h
index d61132295c..4bb7c73660 100644
--- a/src/widgets/styles/qwindowsxpstyle_p.h
+++ b/src/widgets/styles/qwindowsxpstyle_p.h
@@ -42,6 +42,17 @@
#ifndef QWINDOWSXPSTYLE_P_H
#define QWINDOWSXPSTYLE_P_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include <private/qwindowsstyle_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qkeysequenceedit_p.h b/src/widgets/widgets/qkeysequenceedit_p.h
index f74433bb71..adb3dc7a55 100644
--- a/src/widgets/widgets/qkeysequenceedit_p.h
+++ b/src/widgets/widgets/qkeysequenceedit_p.h
@@ -43,6 +43,17 @@
#ifndef QKEYSEQUENCEEDIT_P_H
#define QKEYSEQUENCEEDIT_P_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include "qkeysequenceedit.h"
#include <private/qwidget_p.h>
diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp
index 23c1e99231..bd7f844eca 100644
--- a/src/widgets/widgets/qplaintextedit.cpp
+++ b/src/widgets/widgets/qplaintextedit.cpp
@@ -998,7 +998,8 @@ void QPlainTextEditPrivate::_q_adjustScrollbars()
} else {
vmax = qMax(0, doc->lineCount() - 1);
- vSliderLength = viewport->height() / q->fontMetrics().lineSpacing();
+ int lineSpacing = q->fontMetrics().lineSpacing();
+ vSliderLength = lineSpacing != 0 ? viewport->height() / lineSpacing : 0;
}
diff --git a/src/widgets/widgets/qsizegrip.cpp b/src/widgets/widgets/qsizegrip.cpp
index e46de3958f..5994071bfc 100644
--- a/src/widgets/widgets/qsizegrip.cpp
+++ b/src/widgets/widgets/qsizegrip.cpp
@@ -83,7 +83,7 @@ public:
int dyMax;
Qt::Corner m_corner;
bool gotMousePress;
- QWidget *tlw;
+ QPointer<QWidget> tlw;
#ifdef Q_WS_MAC
void updateMacSizer(bool hide) const;
#endif
diff --git a/src/widgets/widgets/qtoolbutton.cpp b/src/widgets/widgets/qtoolbutton.cpp
index 497bc52109..cb441d6c6e 100644
--- a/src/widgets/widgets/qtoolbutton.cpp
+++ b/src/widgets/widgets/qtoolbutton.cpp
@@ -652,6 +652,10 @@ void QToolButton::setMenu(QMenu* menu)
} else {
d->menuAction = 0;
}
+
+ // changing the menu set may change the size hint, so reset it
+ d->sizeHint = QSize();
+ updateGeometry();
update();
}