summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/dialogs/qmessagebox.cpp4
-rw-r--r--src/widgets/itemviews/qitemdelegate.cpp5
-rw-r--r--src/widgets/itemviews/qtableview.cpp11
-rw-r--r--src/widgets/itemviews/qtreeview.cpp2
-rw-r--r--src/widgets/kernel/qapplication.cpp8
-rw-r--r--src/widgets/kernel/qapplication_qpa.cpp2
-rw-r--r--src/widgets/kernel/qboxlayout.cpp3
-rw-r--r--src/widgets/kernel/qformlayout.cpp4
-rw-r--r--src/widgets/kernel/qgridlayout.cpp6
-rw-r--r--src/widgets/kernel/qlayout.cpp10
-rw-r--r--src/widgets/kernel/qlayout.h1
-rw-r--r--src/widgets/kernel/qstandardgestures.cpp4
-rw-r--r--src/widgets/kernel/qwidget.cpp15
-rw-r--r--src/widgets/kernel/qwidget_qpa.cpp2
-rw-r--r--src/widgets/styles/qwindowsvistastyle.cpp2
-rw-r--r--src/widgets/widgets/qmenu.cpp8
-rw-r--r--src/widgets/widgets/qmenu_p.h5
17 files changed, 65 insertions, 27 deletions
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp
index 833320da16..4ec828ac83 100644
--- a/src/widgets/dialogs/qmessagebox.cpp
+++ b/src/widgets/dialogs/qmessagebox.cpp
@@ -133,10 +133,14 @@ public:
bool copy()
{
+#ifdef QT_NO_CLIPBOARD
+ return false;
+#else
if (!copyAvailable)
return false;
textEdit->copy();
return true;
+#endif
}
private slots:
diff --git a/src/widgets/itemviews/qitemdelegate.cpp b/src/widgets/itemviews/qitemdelegate.cpp
index f2c3c4702f..7d8512adc4 100644
--- a/src/widgets/itemviews/qitemdelegate.cpp
+++ b/src/widgets/itemviews/qitemdelegate.cpp
@@ -523,7 +523,10 @@ QWidget *QItemDelegate::createEditor(QWidget *parent,
const QItemEditorFactory *factory = d->f;
if (factory == 0)
factory = QItemEditorFactory::defaultFactory();
- return factory->createEditor(index.data(Qt::EditRole).userType(), parent);
+ QWidget *w = factory->createEditor(index.data(Qt::EditRole).userType(), parent);
+ if (w)
+ w->setFocusPolicy(Qt::WheelFocus);
+ return w;
}
/*!
diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp
index 37c52948b0..471f8b149c 100644
--- a/src/widgets/itemviews/qtableview.cpp
+++ b/src/widgets/itemviews/qtableview.cpp
@@ -1126,10 +1126,15 @@ void QTableView::doItemsLayout()
{
Q_D(QTableView);
QAbstractItemView::doItemsLayout();
- if (verticalScrollMode() == QAbstractItemView::ScrollPerItem)
- d->verticalHeader->setOffsetToSectionPosition(verticalScrollBar()->value());
- else
+ if (verticalScrollMode() == QAbstractItemView::ScrollPerItem) {
+ const int max = verticalScrollBar()->maximum();
+ if (max > 0 && verticalScrollBar()->value() == max)
+ d->verticalHeader->setOffsetToLastSection();
+ else
+ d->verticalHeader->setOffsetToSectionPosition(verticalScrollBar()->value());
+ } else {
d->verticalHeader->setOffset(verticalScrollBar()->value());
+ }
if (!d->verticalHeader->updatesEnabled())
d->verticalHeader->setUpdatesEnabled(true);
}
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp
index 962ed97762..dd450daaea 100644
--- a/src/widgets/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
@@ -879,7 +879,7 @@ bool QTreeView::isSortingEnabled() const
\property QTreeView::animated
\brief whether animations are enabled
- If this property is true the treeview will animate expandsion
+ If this property is true the treeview will animate expansion
and collapsing of branches. If this property is false, the treeview
will expand or collapse branches immediately without showing
the animation.
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index d036f6bada..b8d3117a41 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -72,6 +72,9 @@
#include <QtGui/qstylehints.h>
#include <QtGui/qinputmethod.h>
#include <qpa/qplatformtheme.h>
+#ifndef QT_NO_WHATSTHIS
+#include <QtWidgets/QWhatsThis>
+#endif
#include "private/qkeymapper_p.h"
@@ -1856,6 +1859,11 @@ bool QApplication::event(QEvent *e)
} else if (te->timerId() == d->toolTipFallAsleep.timerId()) {
d->toolTipFallAsleep.stop();
}
+#ifndef QT_NO_WHATSTHIS
+ } else if (e->type() == QEvent::EnterWhatsThisMode) {
+ QWhatsThis::enterWhatsThisMode();
+ return true;
+#endif
}
if(e->type() == QEvent::LanguageChange) {
diff --git a/src/widgets/kernel/qapplication_qpa.cpp b/src/widgets/kernel/qapplication_qpa.cpp
index 6567ef5c2f..2761c84a8d 100644
--- a/src/widgets/kernel/qapplication_qpa.cpp
+++ b/src/widgets/kernel/qapplication_qpa.cpp
@@ -415,7 +415,7 @@ void QApplication::beep()
void QApplication::alert(QWidget *widget, int duration)
{
if (widget) {
- if (widget->window()->isActiveWindow()&& !widget->window()->windowState() & Qt::WindowMinimized)
+ if (widget->window()->isActiveWindow() && !(widget->window()->windowState() & Qt::WindowMinimized))
return;
if (QWindow *window= QApplicationPrivate::windowForWidget(widget))
window->alert(duration);
diff --git a/src/widgets/kernel/qboxlayout.cpp b/src/widgets/kernel/qboxlayout.cpp
index e1a7903628..d0e7a16999 100644
--- a/src/widgets/kernel/qboxlayout.cpp
+++ b/src/widgets/kernel/qboxlayout.cpp
@@ -942,7 +942,8 @@ void QBoxLayout::insertSpacerItem(int index, QSpacerItem *spacerItem)
void QBoxLayout::insertLayout(int index, QLayout *layout, int stretch)
{
Q_D(QBoxLayout);
- addChildLayout(layout);
+ if (!adoptLayout(layout))
+ return;
if (index < 0) // append
index = d->list.count();
QBoxLayoutItem *it = new QBoxLayoutItem(layout, stretch);
diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp
index e2d25de537..669faac4f6 100644
--- a/src/widgets/kernel/qformlayout.cpp
+++ b/src/widgets/kernel/qformlayout.cpp
@@ -976,8 +976,8 @@ void QFormLayoutPrivate::setLayout(int row, QFormLayout::ItemRole role, QLayout
{
if (layout) {
Q_Q(QFormLayout);
- q->addChildLayout(layout);
- setItem(row, role, layout);
+ if (q->adoptLayout(layout))
+ setItem(row, role, layout);
}
}
diff --git a/src/widgets/kernel/qgridlayout.cpp b/src/widgets/kernel/qgridlayout.cpp
index 12049f3303..96820e3891 100644
--- a/src/widgets/kernel/qgridlayout.cpp
+++ b/src/widgets/kernel/qgridlayout.cpp
@@ -1505,7 +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);
- addChildLayout(layout);
+ if (!adoptLayout(layout))
+ return;
QGridBox *b = new QGridBox(layout);
b->setAlignment(alignment);
d->add(b, row, column);
@@ -1524,7 +1525,8 @@ void QGridLayout::addLayout(QLayout *layout, int row, int column,
int rowSpan, int columnSpan, Qt::Alignment alignment)
{
Q_D(QGridLayout);
- addChildLayout(layout);
+ if (!adoptLayout(layout))
+ return;
QGridBox *b = new QGridBox(layout);
b->setAlignment(alignment);
d->add(b, row, (rowSpan < 0) ? -1 : row + rowSpan - 1, column, (columnSpan < 0) ? -1 : column + columnSpan - 1);
diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp
index d59a9db75d..0402f9939a 100644
--- a/src/widgets/kernel/qlayout.cpp
+++ b/src/widgets/kernel/qlayout.cpp
@@ -806,6 +806,16 @@ void QLayout::addChildLayout(QLayout *l)
}
+/*!
+ \internal
+ */
+bool QLayout::adoptLayout(QLayout *layout)
+{
+ const bool ok = !layout->parent();
+ addChildLayout(layout);
+ return ok;
+}
+
#ifdef QT_DEBUG
static bool layoutDebug()
{
diff --git a/src/widgets/kernel/qlayout.h b/src/widgets/kernel/qlayout.h
index c293939bd3..6f43c2b28a 100644
--- a/src/widgets/kernel/qlayout.h
+++ b/src/widgets/kernel/qlayout.h
@@ -148,6 +148,7 @@ protected:
void childEvent(QChildEvent *e);
void addChildLayout(QLayout *l);
void addChildWidget(QWidget *w);
+ bool adoptLayout(QLayout *layout);
QRect alignmentRect(const QRect&) const;
protected:
diff --git a/src/widgets/kernel/qstandardgestures.cpp b/src/widgets/kernel/qstandardgestures.cpp
index e3131e7e56..f4307e9737 100644
--- a/src/widgets/kernel/qstandardgestures.cpp
+++ b/src/widgets/kernel/qstandardgestures.cpp
@@ -59,8 +59,8 @@ QPanGestureRecognizer::QPanGestureRecognizer()
QGesture *QPanGestureRecognizer::create(QObject *target)
{
if (target && target->isWidgetType()) {
-#if defined(Q_OS_WIN) && !defined(QT_NO_NATIVE_GESTURES)
- // for scroll areas on Windows we want to use native gestures instead
+#if ((defined(Q_OS_MAC) && !defined(Q_OS_IOS)) || defined(Q_OS_WIN)) && !defined(QT_NO_NATIVE_GESTURES)
+ // for scroll areas on Windows and Mac OS X we want to use native gestures instead
if (!qobject_cast<QAbstractScrollArea *>(target->parent()))
static_cast<QWidget *>(target)->setAttribute(Qt::WA_AcceptTouchEvents);
#else
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 90cfb3446f..cb7761add7 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -8434,8 +8434,6 @@ void QWidget::mouseReleaseEvent(QMouseEvent *event)
This event handler, for event \a event, can be reimplemented in a
subclass to receive mouse double click events for the widget.
- The default implementation generates a normal mouse press event.
-
\note The widget will also receive mouse press and mouse release
events in addition to the double click event. It is up to the
developer to ensure that the application interprets these events
@@ -9876,11 +9874,16 @@ void QWidget::update()
*/
void QWidget::update(const QRect &rect)
{
- if (!isVisible() || !updatesEnabled() || rect.isEmpty())
+ if (!isVisible() || !updatesEnabled())
+ return;
+
+ QRect r = rect & QWidget::rect();
+
+ if (r.isEmpty())
return;
if (testAttribute(Qt::WA_WState_InPaintEvent)) {
- QApplication::postEvent(this, new QUpdateLaterEvent(rect));
+ QApplication::postEvent(this, new QUpdateLaterEvent(r));
return;
}
@@ -9893,9 +9896,9 @@ void QWidget::update(const QRect &rect)
#endif // Q_WS_MAC
QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore)
- tlwExtra->backingStoreTracker->markDirty(rect, this);
+ tlwExtra->backingStoreTracker->markDirty(r, this);
} else {
- d_func()->repaint_sys(rect);
+ d_func()->repaint_sys(r);
}
}
diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp
index fdc72ee23c..a4da98815b 100644
--- a/src/widgets/kernel/qwidget_qpa.cpp
+++ b/src/widgets/kernel/qwidget_qpa.cpp
@@ -172,7 +172,7 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry()));
d->deactivateWidgetCleanup();
- if ((windowType() == Qt::Popup))
+ if ((windowType() == Qt::Popup) && qApp)
qApp->d_func()->closePopup(this);
if (this == QApplicationPrivate::active_window)
diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp
index f65e52305c..b08eab580d 100644
--- a/src/widgets/styles/qwindowsvistastyle.cpp
+++ b/src/widgets/styles/qwindowsvistastyle.cpp
@@ -314,7 +314,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
return;
}
- if (d->transitionsEnabled() && canAnimate(option)) {
+ if ((option->state & State_Enabled) && d->transitionsEnabled() && canAnimate(option)) {
{
QRect oldRect;
QRect newRect;
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index aaedd7ffee..fde46c9729 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -154,7 +154,7 @@ void QMenuPrivate::init()
}
platformMenu = QGuiApplicationPrivate::platformTheme()->createPlatformMenu();
- if (platformMenu) {
+ if (!platformMenu.isNull()) {
QObject::connect(platformMenu, SIGNAL(aboutToShow()), q, SIGNAL(aboutToShow()));
QObject::connect(platformMenu, SIGNAL(aboutToHide()), q, SIGNAL(aboutToHide()));
}
@@ -2411,7 +2411,7 @@ void QMenu::changeEvent(QEvent *e)
if (d->tornPopup) // torn-off menu
d->tornPopup->setEnabled(isEnabled());
d->menuAction->setEnabled(isEnabled());
- if (d->platformMenu)
+ if (!d->platformMenu.isNull())
d->platformMenu->setEnabled(isEnabled());
}
QWidget::changeEvent(e);
@@ -2992,7 +2992,7 @@ void QMenu::actionEvent(QActionEvent *e)
d->widgetItems.remove(e->action());
}
- if (d->platformMenu) {
+ if (!d->platformMenu.isNull()) {
if (e->type() == QEvent::ActionAdded) {
QPlatformMenuItem *menuItem =
QGuiApplicationPrivate::platformTheme()->createPlatformMenuItem();
@@ -3201,7 +3201,7 @@ void QMenu::setSeparatorsCollapsible(bool collapse)
d->updateActionRects();
update();
}
- if (d->platformMenu)
+ if (!d->platformMenu.isNull())
d->platformMenu->syncSeparatorsCollapsible(collapse);
}
diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h
index 6cc88c56e2..15f3c92127 100644
--- a/src/widgets/widgets/qmenu_p.h
+++ b/src/widgets/widgets/qmenu_p.h
@@ -101,7 +101,8 @@ public:
~QMenuPrivate()
{
delete scroll;
- delete platformMenu;
+ if (!platformMenu.isNull() && !platformMenu->parent())
+ delete platformMenu.data();
#if defined(Q_OS_WINCE) && !defined(QT_NO_MENUBAR)
delete wce_menu;
#endif
@@ -228,7 +229,7 @@ public:
//menu fading/scrolling effects
bool doChildEffects;
- QPlatformMenu *platformMenu;
+ QPointer<QPlatformMenu> platformMenu;
QPointer<QAction> actionAboutToTrigger;