summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/accessible/simplewidgets.cpp2
-rw-r--r--src/widgets/dialogs/images/qtlogo-64.pngbin2991 -> 1676 bytes
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp2
-rw-r--r--src/widgets/dialogs/qfiledialog.ui3
-rw-r--r--src/widgets/dialogs/qfiledialog_embedded.ui207
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp2
-rw-r--r--src/widgets/dialogs/qwizard.cpp8
-rw-r--r--src/widgets/doc/snippets/code/doc_src_layout.cpp2
-rw-r--r--src/widgets/doc/snippets/qlistview-dnd/main.cpp2
-rw-r--r--src/widgets/doc/snippets/qlistview-dnd/mainwindow.cpp2
-rw-r--r--src/widgets/doc/snippets/qlistview-dnd/model.cpp21
-rw-r--r--src/widgets/doc/snippets/qlistview-dnd/model.h2
-rw-r--r--src/widgets/doc/snippets/qlistview-dnd/qlistview-dnd.pro1
-rw-r--r--src/widgets/doc/src/model-view-programming.qdoc3
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp38
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp6
-rw-r--r--src/widgets/itemviews/qabstractitemview_p.h16
-rw-r--r--src/widgets/itemviews/qlistview.cpp6
-rw-r--r--src/widgets/kernel/qapplication.cpp38
-rw-r--r--src/widgets/kernel/qapplication_p.h3
-rw-r--r--src/widgets/kernel/qgesture_p.h13
-rw-r--r--src/widgets/kernel/qgesturemanager.cpp20
-rw-r--r--src/widgets/kernel/qopenglwidget.cpp12
-rw-r--r--src/widgets/kernel/qstandardgestures.cpp76
-rw-r--r--src/widgets/kernel/qstandardgestures_p.h5
-rw-r--r--src/widgets/kernel/qwidget.cpp12
-rw-r--r--src/widgets/kernel/qwidgetbackingstore.cpp2
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp74
-rw-r--r--src/widgets/kernel/qwidgetwindow_p.h4
-rw-r--r--src/widgets/styles/qandroidstyle.cpp379
-rw-r--r--src/widgets/styles/qandroidstyle_p.h11
-rw-r--r--src/widgets/styles/qcommonstyle.cpp2
-rw-r--r--src/widgets/styles/qfusionstyle.cpp4
-rw-r--r--src/widgets/styles/qgtkstyle_p.cpp4
-rw-r--r--src/widgets/styles/qmacstyle_mac.mm265
-rw-r--r--src/widgets/styles/qmacstyle_mac_p_p.h6
-rw-r--r--src/widgets/styles/qstyle.cpp3
-rw-r--r--src/widgets/styles/qstyle.h2
-rw-r--r--src/widgets/styles/qwindowsstyle.cpp14
-rw-r--r--src/widgets/styles/qwindowsvistastyle.cpp6
-rw-r--r--src/widgets/styles/qwindowsxpstyle.cpp5
-rw-r--r--src/widgets/widgets/qlineedit.cpp7
-rw-r--r--src/widgets/widgets/qlineedit_p.cpp2
-rw-r--r--src/widgets/widgets/qmainwindow.cpp7
-rw-r--r--src/widgets/widgets/qmainwindowlayout.cpp22
-rw-r--r--src/widgets/widgets/qmainwindowlayout_p.h2
-rw-r--r--src/widgets/widgets/qmdiarea.cpp16
-rw-r--r--src/widgets/widgets/qmdiarea_p.h9
-rw-r--r--src/widgets/widgets/qmenu.cpp6
-rw-r--r--src/widgets/widgets/qplaintextedit.cpp14
-rw-r--r--src/widgets/widgets/qtextedit.cpp14
-rw-r--r--src/widgets/widgets/qtoolbararealayout.cpp24
-rw-r--r--src/widgets/widgets/qtoolbararealayout_p.h2
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol.cpp2
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol_p.h2
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp9
56 files changed, 666 insertions, 755 deletions
diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp
index ade5cfe3dc..41692d11bd 100644
--- a/src/widgets/accessible/simplewidgets.cpp
+++ b/src/widgets/accessible/simplewidgets.cpp
@@ -414,12 +414,14 @@ QString QAccessibleDisplay::text(QAccessible::Text t) const
if (qobject_cast<QLabel*>(object())) {
QLabel *label = qobject_cast<QLabel*>(object());
str = label->text();
+#ifndef QT_NO_TEXTHTMLPARSER
if (label->textFormat() == Qt::RichText
|| (label->textFormat() == Qt::AutoText && Qt::mightBeRichText(str))) {
QTextDocument doc;
doc.setHtml(str);
str = doc.toPlainText();
}
+#endif
if (label->buddy())
str = qt_accStripAmp(str);
#ifndef QT_NO_LCDNUMBER
diff --git a/src/widgets/dialogs/images/qtlogo-64.png b/src/widgets/dialogs/images/qtlogo-64.png
index 4f68e162de..af87e98cf5 100644
--- a/src/widgets/dialogs/images/qtlogo-64.png
+++ b/src/widgets/dialogs/images/qtlogo-64.png
Binary files differ
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 0ba3ea40e0..6065ad015e 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -510,7 +510,7 @@ bool QFileDialog::restoreState(const QByteArray &state)
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) {
+ if (list.count() >= 2 && (list.at(0) == 0 || list.at(1) == 0)) {
for (int i = 0; i < list.count(); ++i)
list[i] = d->qFileDialogUi->splitter->widget(i)->sizeHint().width();
d->qFileDialogUi->splitter->setSizes(list);
diff --git a/src/widgets/dialogs/qfiledialog.ui b/src/widgets/dialogs/qfiledialog.ui
index 89adaf530e..7f6e59c908 100644
--- a/src/widgets/dialogs/qfiledialog.ui
+++ b/src/widgets/dialogs/qfiledialog.ui
@@ -179,6 +179,9 @@
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
+ <property name="childrenCollapsible">
+ <bool>false</bool>
+ </property>
<widget class="QSidebar" name="sidebar">
<property name="accessibleName">
<string>Sidebar</string>
diff --git a/src/widgets/dialogs/qfiledialog_embedded.ui b/src/widgets/dialogs/qfiledialog_embedded.ui
index 16128dc0a0..4cdc620437 100644
--- a/src/widgets/dialogs/qfiledialog_embedded.ui
+++ b/src/widgets/dialogs/qfiledialog_embedded.ui
@@ -1,4 +1,5 @@
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
<comment>*********************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
@@ -40,8 +41,8 @@
**
*********************************************************************</comment>
<class>QFileDialog</class>
- <widget class="QDialog" name="QFileDialog" >
- <property name="geometry" >
+ <widget class="QDialog" name="QFileDialog">
+ <property name="geometry">
<rect>
<x>0</x>
<y>0</y>
@@ -49,14 +50,14 @@
<height>320</height>
</rect>
</property>
- <property name="sizeGripEnabled" >
+ <property name="sizeGripEnabled">
<bool>true</bool>
</property>
- <layout class="QVBoxLayout" >
+ <layout class="QVBoxLayout">
<item>
- <widget class="QFileDialogComboBox" name="lookInCombo" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
+ <widget class="QFileDialogComboBox" name="lookInCombo">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -64,45 +65,45 @@
</widget>
</item>
<item>
- <layout class="QHBoxLayout" >
+ <layout class="QHBoxLayout">
<item>
- <widget class="QToolButton" name="backButton" >
- <property name="toolTip" >
+ <widget class="QToolButton" name="backButton">
+ <property name="toolTip">
<string>Back</string>
</property>
</widget>
</item>
<item>
- <widget class="QToolButton" name="forwardButton" >
- <property name="toolTip" >
+ <widget class="QToolButton" name="forwardButton">
+ <property name="toolTip">
<string>Forward</string>
</property>
</widget>
</item>
<item>
- <widget class="QToolButton" name="toParentButton" >
- <property name="toolTip" >
+ <widget class="QToolButton" name="toParentButton">
+ <property name="toolTip">
<string>Parent Directory</string>
</property>
</widget>
</item>
<item>
- <widget class="QToolButton" name="newFolderButton" >
- <property name="toolTip" >
+ <widget class="QToolButton" name="newFolderButton">
+ <property name="toolTip">
<string>Create New Folder</string>
</property>
</widget>
</item>
<item>
- <widget class="QToolButton" name="listModeButton" >
- <property name="toolTip" >
+ <widget class="QToolButton" name="listModeButton">
+ <property name="toolTip">
<string>List View</string>
</property>
</widget>
</item>
<item>
- <widget class="QToolButton" name="detailModeButton" >
- <property name="toolTip" >
+ <widget class="QToolButton" name="detailModeButton">
+ <property name="toolTip">
<string>Detail View</string>
</property>
</widget>
@@ -110,75 +111,89 @@
</layout>
</item>
<item>
- <widget class="QSplitter" name="splitter" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
+ <widget class="QSplitter" name="splitter">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="orientation" >
+ <property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
- <widget class="QSidebar" name="sidebar" />
- <widget class="QFrame" name="frame" >
- <property name="frameShape" >
+ <property name="childrenCollapsible">
+ <bool>false</bool>
+ </property>
+ <widget class="QSidebar" name="sidebar"/>
+ <widget class="QFrame" name="frame">
+ <property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
- <property name="frameShadow" >
+ <property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
- <layout class="QVBoxLayout" >
- <property name="spacing" >
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
<number>0</number>
</property>
- <property name="margin" >
+ <property name="bottomMargin">
<number>0</number>
</property>
<item>
- <widget class="QStackedWidget" name="stackedWidget" >
- <property name="currentIndex" >
+ <widget class="QStackedWidget" name="stackedWidget">
+ <property name="currentIndex">
<number>0</number>
</property>
- <widget class="QWidget" name="page" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>108</width>
- <height>164</height>
- </rect>
- </property>
- <layout class="QVBoxLayout" >
- <property name="spacing" >
+ <widget class="QWidget" name="page">
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="leftMargin">
<number>0</number>
</property>
- <property name="margin" >
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
<number>0</number>
</property>
<item>
- <widget class="QFileDialogListView" name="listView" />
+ <widget class="QFileDialogListView" name="listView"/>
</item>
</layout>
</widget>
- <widget class="QWidget" name="page_2" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>100</width>
- <height>30</height>
- </rect>
- </property>
- <layout class="QVBoxLayout" >
- <property name="spacing" >
+ <widget class="QWidget" name="page_2">
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
<number>0</number>
</property>
- <property name="margin" >
+ <property name="bottomMargin">
<number>0</number>
</property>
<item>
- <widget class="QFileDialogTreeView" name="treeView" />
+ <widget class="QFileDialogTreeView" name="treeView"/>
</item>
</layout>
</widget>
@@ -189,31 +204,31 @@
</widget>
</item>
<item>
- <layout class="QGridLayout" >
- <item row="0" column="0" >
- <widget class="QFileDialogLineEdit" name="fileNameEdit" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
+ <layout class="QGridLayout">
+ <item row="0" column="0">
+ <widget class="QFileDialogLineEdit" name="fileNameEdit">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
- <item rowspan="2" row="0" column="1" >
- <widget class="QDialogButtonBox" name="buttonBox" >
- <property name="orientation" >
+ <item row="0" column="1" rowspan="2">
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
<enum>Qt::Vertical</enum>
</property>
- <property name="standardButtons" >
+ <property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
- <item row="1" column="0" >
- <widget class="QComboBox" name="fileTypeCombo" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
+ <item row="1" column="0">
+ <widget class="QComboBox" name="fileTypeCombo">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -223,23 +238,23 @@
</layout>
</item>
<item>
- <widget class="QLabel" name="fileNameLabel" >
- <property name="enabled" >
+ <widget class="QLabel" name="fileNameLabel">
+ <property name="enabled">
<bool>false</bool>
</property>
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="minimumSize" >
+ <property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
- <property name="maximumSize" >
+ <property name="maximumSize">
<size>
<width>0</width>
<height>0</height>
@@ -248,45 +263,45 @@
</widget>
</item>
<item>
- <widget class="QLabel" name="fileTypeLabel" >
- <property name="enabled" >
+ <widget class="QLabel" name="fileTypeLabel">
+ <property name="enabled">
<bool>false</bool>
</property>
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="maximumSize" >
+ <property name="maximumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
- <property name="text" >
+ <property name="text">
<string>Files of type:</string>
</property>
</widget>
</item>
<item>
- <widget class="QLabel" name="lookInLabel" >
- <property name="enabled" >
+ <widget class="QLabel" name="lookInLabel">
+ <property name="enabled">
<bool>false</bool>
</property>
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="maximumSize" >
+ <property name="maximumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
- <property name="text" >
+ <property name="text">
<string>Look in:</string>
</property>
</widget>
@@ -297,27 +312,27 @@
<customwidget>
<class>QFileDialogTreeView</class>
<extends>QTreeView</extends>
- <header>qfiledialog_p.h</header>
+ <header>private/qfiledialog_p.h</header>
</customwidget>
<customwidget>
<class>QFileDialogListView</class>
<extends>QListView</extends>
- <header>qfiledialog_p.h</header>
+ <header>private/qfiledialog_p.h</header>
</customwidget>
<customwidget>
<class>QSidebar</class>
<extends>QListWidget</extends>
- <header>qsidebar_p.h</header>
+ <header>private/qsidebar_p.h</header>
</customwidget>
<customwidget>
<class>QFileDialogLineEdit</class>
<extends>QLineEdit</extends>
- <header>qfiledialog_p.h</header>
+ <header>private/qfiledialog_p.h</header>
</customwidget>
<customwidget>
<class>QFileDialogComboBox</class>
<extends>QComboBox</extends>
- <header>qfiledialog_p.h</header>
+ <header>private/qfiledialog_p.h</header>
</customwidget>
</customwidgets>
<tabstops>
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp
index 988d3ad3c7..baa55cb88f 100644
--- a/src/widgets/dialogs/qfilesystemmodel.cpp
+++ b/src/widgets/dialogs/qfilesystemmodel.cpp
@@ -76,7 +76,7 @@ QT_BEGIN_NAMESPACE
QFileSystemModel can be accessed using the standard interface provided by
QAbstractItemModel, but it also provides some convenience functions that are
specific to a directory model.
- The fileInfo(), isDir(), name(), and path() functions provide information
+ The fileInfo(), isDir(), fileName() and filePath() functions provide information
about the underlying files and directories related to items in the model.
Directories can be created and removed using mkdir(), rmdir().
diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp
index 1f7b18e824..a378daa3d3 100644
--- a/src/widgets/dialogs/qwizard.cpp
+++ b/src/widgets/dialogs/qwizard.cpp
@@ -2571,6 +2571,14 @@ void QWizard::setWizardStyle(WizardStyle style)
d->disableUpdates();
d->wizStyle = style;
d->updateButtonTexts();
+#if !defined(QT_NO_STYLE_WINDOWSVISTA)
+ if (aeroStyleChange) {
+ //Send a resizeevent since the antiflicker widget probably needs a new size
+ //because of the backbutton in the window title
+ QResizeEvent ev(geometry().size(), geometry().size());
+ QApplication::sendEvent(this, &ev);
+ }
+#endif
d->updateLayout();
updateGeometry();
d->enableUpdates();
diff --git a/src/widgets/doc/snippets/code/doc_src_layout.cpp b/src/widgets/doc/snippets/code/doc_src_layout.cpp
index 5ea8ce5a5f..a10cd52e2e 100644
--- a/src/widgets/doc/snippets/code/doc_src_layout.cpp
+++ b/src/widgets/doc/snippets/code/doc_src_layout.cpp
@@ -42,7 +42,7 @@
#ifndef CARD_H
#define CARD_H
-#include <QtGui>
+#include <QtWidgets>
#include <QList>
class CardLayout : public QLayout
diff --git a/src/widgets/doc/snippets/qlistview-dnd/main.cpp b/src/widgets/doc/snippets/qlistview-dnd/main.cpp
index c4a8aebb01..422ce35c6b 100644
--- a/src/widgets/doc/snippets/qlistview-dnd/main.cpp
+++ b/src/widgets/doc/snippets/qlistview-dnd/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
diff --git a/src/widgets/doc/snippets/qlistview-dnd/mainwindow.cpp b/src/widgets/doc/snippets/qlistview-dnd/mainwindow.cpp
index ed06819dd9..3b19295676 100644
--- a/src/widgets/doc/snippets/qlistview-dnd/mainwindow.cpp
+++ b/src/widgets/doc/snippets/qlistview-dnd/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
#include "model.h"
diff --git a/src/widgets/doc/snippets/qlistview-dnd/model.cpp b/src/widgets/doc/snippets/qlistview-dnd/model.cpp
index 6ebeb2eb56..aa12cef3a2 100644
--- a/src/widgets/doc/snippets/qlistview-dnd/model.cpp
+++ b/src/widgets/doc/snippets/qlistview-dnd/model.cpp
@@ -65,18 +65,31 @@ DragDropListModel::DragDropListModel(const QStringList &strings,
}
//! [0]
-bool DragDropListModel::dropMimeData(const QMimeData *data,
+bool DragDropListModel::canDropMimeData(const QMimeData *data,
Qt::DropAction action, int row, int column, const QModelIndex &parent)
{
- if (action == Qt::IgnoreAction)
- return true;
+ Q_UNUSED(action);
+ Q_UNUSED(row);
+ Q_UNUSED(parent);
if (!data->hasFormat("application/vnd.text.list"))
return false;
if (column > 0)
-//! [0] //! [1]
return false;
+
+ return true;
+}
+//! [0]
+//! [1]
+bool DragDropListModel::dropMimeData(const QMimeData *data,
+ Qt::DropAction action, int row, int column, const QModelIndex &parent)
+{
+ if (!canDropMimeData(data, action, row, column, parent))
+ return false;
+
+ if (action == Qt::IgnoreAction)
+ return true;
//! [1]
//! [2]
diff --git a/src/widgets/doc/snippets/qlistview-dnd/model.h b/src/widgets/doc/snippets/qlistview-dnd/model.h
index 9b667ad4a3..9217052971 100644
--- a/src/widgets/doc/snippets/qlistview-dnd/model.h
+++ b/src/widgets/doc/snippets/qlistview-dnd/model.h
@@ -63,6 +63,8 @@ public:
Qt::ItemFlags flags(const QModelIndex &index) const;
+ bool canDropMimeData(const QMimeData *data, Qt::DropAction action,
+ int row, int column, const QModelIndex &parent);
bool dropMimeData(const QMimeData *data, Qt::DropAction action,
int row, int column, const QModelIndex &parent);
QMimeData *mimeData(const QModelIndexList &indexes) const;
diff --git a/src/widgets/doc/snippets/qlistview-dnd/qlistview-dnd.pro b/src/widgets/doc/snippets/qlistview-dnd/qlistview-dnd.pro
index 71fa273a69..bc2a1f0dce 100644
--- a/src/widgets/doc/snippets/qlistview-dnd/qlistview-dnd.pro
+++ b/src/widgets/doc/snippets/qlistview-dnd/qlistview-dnd.pro
@@ -3,3 +3,4 @@ SOURCES = main.cpp \
model.cpp
HEADERS = mainwindow.h \
model.h
+QT += widgets
diff --git a/src/widgets/doc/src/model-view-programming.qdoc b/src/widgets/doc/src/model-view-programming.qdoc
index 8978efa1e3..ada0460689 100644
--- a/src/widgets/doc/src/model-view-programming.qdoc
+++ b/src/widgets/doc/src/model-view-programming.qdoc
@@ -1769,6 +1769,9 @@
dropped onto existing items separately to data dropped into the top level
of the model (i.e., onto an invalid item).
+ Models can forbid dropping on certain items, or depending on the dropped data,
+ by reimplementing QAbstractItemModel::canDropMimeData().
+
The model first has to make sure that the operation should be acted on,
the data supplied is in a format that can be used, and that its destination
within the model is valid:
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index 67d135271c..03f22a270f 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -1968,8 +1968,10 @@ QGraphicsItem::CacheMode QGraphicsItem::cacheMode() const
Caching can speed up rendering if your item spends a significant time
redrawing itself. In some cases the cache can also slow down rendering, in
particular when the item spends less time redrawing than QGraphicsItem
- spends redrawing from the cache. When enabled, the item's paint() function
- will be called only once for each call to update(); for any subsequent
+ spends redrawing from the cache.
+
+ When caching is enabled, an item's paint() function will generally draw into an
+ offscreen pixmap cache; for any subsequent
repaint requests, the Graphics View framework will redraw from the
cache. This approach works particularly well with QGLWidget, which stores
all the cache as OpenGL textures.
@@ -1980,6 +1982,12 @@ QGraphicsItem::CacheMode QGraphicsItem::cacheMode() const
You can read more about the different cache modes in the CacheMode
documentation.
+ \note Enabling caching does not imply that the item's paint() function will be
+ called only in response to an explicit update() call. For instance, under
+ memory pressure, Qt may decide to drop some of the cache information;
+ in such cases an item's paint() function will be called even if there
+ was no update() call (that is, exactly as if there were no caching enabled).
+
\sa CacheMode, QPixmapCache::setCacheLimit()
*/
void QGraphicsItem::setCacheMode(CacheMode mode, const QSize &logicalCacheSize)
@@ -2439,7 +2447,12 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly,
Items are visible by default; it is unnecessary to call
setVisible() on a new item.
- \sa isVisible(), show(), hide()
+ \note An item with opacity set to 0 will still be considered visible,
+ although it will be treated like an invisible item: mouse events will pass
+ through it, it will not be included in the items returned by
+ QGraphicsView::items(), and so on. However, the item will retain the focus.
+
+ \sa isVisible(), show(), hide(), setOpacity()
*/
void QGraphicsItem::setVisible(bool visible)
{
@@ -2707,7 +2720,11 @@ qreal QGraphicsItem::effectiveOpacity() const
with the parent: ItemIgnoresParentOpacity and
ItemDoesntPropagateOpacityToChildren.
- \sa opacity(), effectiveOpacity()
+ \note Setting the opacity of an item to 0 will not make the item invisible
+ (according to isVisible()), but the item will be treated like an invisible
+ one. See the documentation of setVisible() for more information.
+
+ \sa opacity(), effectiveOpacity(), setVisible()
*/
void QGraphicsItem::setOpacity(qreal opacity)
{
@@ -4487,7 +4504,7 @@ void QGraphicsItem::resetTransform()
Use
\code
- setRotation(rotation() + angle);
+ item->setTransform(QTransform().rotate(angle), true);
\endcode
instead.
@@ -5337,6 +5354,16 @@ void QGraphicsItem::setBoundingRegionGranularity(qreal granularity)
All painting is done in local coordinates.
+ \note It is mandatory that an item will always redraw itself in the exact
+ same way, unless update() was called; otherwise visual artifacts may
+ occur. In other words, two subsequent calls to paint() must always produce
+ the same output, unless update() was called between them.
+
+ \note Enabling caching for an item does not guarantee that paint()
+ will be invoked only once by the Graphics View framework,
+ even without any explicit call to update(). See the documentation of
+ setCacheMode() for more details.
+
\sa setCacheMode(), QPen::width(), {Item Coordinates}, ItemUsesExtendedStyleOption
*/
@@ -9764,6 +9791,7 @@ QVariant QGraphicsPixmapItem::extension(const QVariant &variant) const
using textWidth().
\note In order to align HTML text in the center, the item's text width must be set.
+ Otherwise, you can call adjustSize() after setting the item's text.
\image graphicsview-textitem.png
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index a6361bd750..9d38a330c8 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -1905,7 +1905,7 @@ void QAbstractItemView::dragEnterEvent(QDragEnterEvent *event)
&& (event->source() != this|| !(event->possibleActions() & Qt::MoveAction)))
return;
- if (d_func()->canDecode(event)) {
+ if (d_func()->canDrop(event)) {
event->accept();
setState(DraggingState);
} else {
@@ -1934,7 +1934,7 @@ void QAbstractItemView::dragMoveEvent(QDragMoveEvent *event)
QModelIndex index = indexAt(event->pos());
d->hover = index;
if (!d->droppingOnItself(event, index)
- && d->canDecode(event)) {
+ && d->canDrop(event)) {
if (index.isValid() && d->showDropIndicator) {
QRect rect = visualRect(index);
@@ -1979,7 +1979,7 @@ void QAbstractItemView::dragMoveEvent(QDragMoveEvent *event)
}
}
d->viewport->update();
- } // can decode
+ } // can drop
if (d->shouldAutoScroll(event->pos()))
startAutoScroll();
diff --git a/src/widgets/itemviews/qabstractitemview_p.h b/src/widgets/itemviews/qabstractitemview_p.h
index 047533b22c..c3bd1fb504 100644
--- a/src/widgets/itemviews/qabstractitemview_p.h
+++ b/src/widgets/itemviews/qabstractitemview_p.h
@@ -164,13 +164,15 @@ public:
#ifndef QT_NO_DRAGANDDROP
virtual QAbstractItemView::DropIndicatorPosition position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const;
- inline bool canDecode(QDropEvent *e) const {
- QStringList modelTypes = model->mimeTypes();
- const QMimeData *mime = e->mimeData();
- for (int i = 0; i < modelTypes.count(); ++i)
- if (mime->hasFormat(modelTypes.at(i))
- && (e->dropAction() & model->supportedDropActions()))
- return true;
+ inline bool canDrop(QDropEvent *event) {
+ QModelIndex index;
+ int col = -1;
+ int row = -1;
+ if (dropOn(event, &row, &col, &index)) {
+ return model->canDropMimeData(event->mimeData(),
+ dragDropMode == QAbstractItemView::InternalMove ? Qt::MoveAction : event->dropAction(),
+ row, col, index);
+ }
return false;
}
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp
index a097228846..e7d18092f1 100644
--- a/src/widgets/itemviews/qlistview.cpp
+++ b/src/widgets/itemviews/qlistview.cpp
@@ -1977,7 +1977,7 @@ void QListModeViewBase::dragMoveEvent(QDragMoveEvent *event)
? intersectVector.last() : QModelIndex();
dd->hover = index;
if (!dd->droppingOnItself(event, index)
- && dd->canDecode(event)) {
+ && dd->canDrop(event)) {
if (index.isValid() && dd->showDropIndicator) {
QRect rect = qq->visualRect(index);
@@ -2023,7 +2023,7 @@ void QListModeViewBase::dragMoveEvent(QDragMoveEvent *event)
}
}
dd->viewport->update();
- } // can decode
+ } // can drop
if (dd->shouldAutoScroll(event->pos()))
qq->startAutoScroll();
@@ -2757,7 +2757,7 @@ bool QIconModeViewBase::filterDragLeaveEvent(QDragLeaveEvent *e)
bool QIconModeViewBase::filterDragMoveEvent(QDragMoveEvent *e)
{
- if (e->source() != qq || !dd->canDecode(e))
+ if (e->source() != qq || !dd->canDrop(e))
return false;
// ignore by default
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 9abec13b5b..500e812e28 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -53,6 +53,7 @@
#include "qtranslator.h"
#include "qvariant.h"
#include "qwidget.h"
+#include "qgraphicssceneevent.h"
#include "private/qdnd_p.h"
#include "private/qguiapplication_p.h"
#include "qcolormap.h"
@@ -2291,6 +2292,31 @@ QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool
return w;
}
+Qt::MouseEventSource QApplicationPrivate::mouseEventSource(const QEvent *e)
+{
+ switch (e->type()) {
+ case QEvent::NonClientAreaMouseButtonDblClick:
+ case QEvent::NonClientAreaMouseButtonPress:
+ case QEvent::NonClientAreaMouseButtonRelease:
+ case QEvent::NonClientAreaMouseMove:
+ case QEvent::MouseButtonDblClick:
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseMove:
+ return static_cast<const QMouseEvent *>(e)->source();
+#ifndef QT_NO_GRAPHICSVIEW
+ case QEvent::GraphicsSceneMouseDoubleClick:
+ case QEvent::GraphicsSceneMousePress:
+ case QEvent::GraphicsSceneMouseRelease:
+ case QEvent::GraphicsSceneMouseMove:
+ return static_cast<const QGraphicsSceneMouseEvent *>(e)->source();
+#endif // !QT_NO_GRAPHICSVIEW
+ default:
+ break;
+ }
+ return Qt::MouseEventNotSynthesized;
+}
+
/*!
\fn void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, const QPointF &globalPosF)
\internal
@@ -4211,8 +4237,9 @@ bool QApplicationPrivate::shouldSetFocus(QWidget *w, Qt::FocusPolicy policy)
return true;
}
-void QApplicationPrivate::updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent)
+bool QApplicationPrivate::updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent)
{
+ bool containsPress = false;
for (int i = 0; i < touchEvent->touchPoints().count(); ++i) {
QTouchEvent::TouchPoint &touchPoint = touchEvent->_touchPoints[i];
@@ -4225,7 +4252,11 @@ void QApplicationPrivate::updateTouchPointsForWidget(QWidget *widget, QTouchEven
touchPoint.d->rect = rect;
touchPoint.d->startPos = widget->mapFromGlobal(touchPoint.startScreenPos().toPoint()) + delta;
touchPoint.d->lastPos = widget->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta;
+
+ if (touchPoint.state() == Qt::TouchPointPressed)
+ containsPress = true;
}
+ return containsPress;
}
void QApplicationPrivate::initializeMultitouch()
@@ -4372,11 +4403,14 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window,
QApplication::keyboardModifiers(),
it.value().first,
it.value().second);
- updateTouchPointsForWidget(widget, &touchEvent);
+ bool containsPress = updateTouchPointsForWidget(widget, &touchEvent);
touchEvent.setTimestamp(timestamp);
touchEvent.setWindow(window->windowHandle());
touchEvent.setTarget(widget);
+ if (containsPress)
+ widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent);
+
switch (touchEvent.type()) {
case QEvent::TouchBegin:
{
diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h
index 156bf34194..b24b592fbe 100644
--- a/src/widgets/kernel/qapplication_p.h
+++ b/src/widgets/kernel/qapplication_p.h
@@ -168,6 +168,7 @@ public:
static void setFocusWidget(QWidget *focus, Qt::FocusReason reason);
static QWidget *focusNextPrevChild_helper(QWidget *toplevel, bool next,
bool *wrappingOccurred = 0);
+ static Qt::MouseEventSource mouseEventSource(const QEvent *e);
#ifndef QT_NO_GRAPHICSVIEW
// Maintain a list of all scenes to ensure font and palette propagation to
@@ -275,7 +276,7 @@ public:
QPixmap *ignore_cursor;
#endif
- static void updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent);
+ static bool updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent);
void initializeMultitouch();
void initializeMultitouch_sys();
void cleanupMultitouch();
diff --git a/src/widgets/kernel/qgesture_p.h b/src/widgets/kernel/qgesture_p.h
index 8668145d8a..26d9ede59d 100644
--- a/src/widgets/kernel/qgesture_p.h
+++ b/src/widgets/kernel/qgesture_p.h
@@ -80,7 +80,7 @@ class QPanGesturePrivate : public QGesturePrivate
public:
QPanGesturePrivate()
- : acceleration(0), xVelocity(0), yVelocity(0)
+ : acceleration(0), xVelocity(0), yVelocity(0), pointCount(2)
{
}
@@ -95,6 +95,7 @@ public:
qreal acceleration;
qreal xVelocity;
qreal yVelocity;
+ int pointCount; // ### fixme Qt 5.5: Add accessor to QPanGesture.
};
class QPinchGesturePrivate : public QGesturePrivate
@@ -134,11 +135,17 @@ class QSwipeGesturePrivate : public QGesturePrivate
Q_DECLARE_PUBLIC(QSwipeGesture)
public:
+ enum State {
+ NoGesture,
+ Started,
+ ThreePointsReached
+ };
+
QSwipeGesturePrivate()
: horizontalDirection(QSwipeGesture::NoDirection),
verticalDirection(QSwipeGesture::NoDirection),
swipeAngle(0),
- started(false), velocityValue(0)
+ state(NoGesture), velocityValue(0)
{
}
@@ -150,7 +157,7 @@ public:
qreal swipeAngle;
QPoint lastPositions[3];
- bool started;
+ State state;
qreal velocityValue;
QElapsedTimer time;
};
diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp
index 739e6b1870..c9af3062d3 100644
--- a/src/widgets/kernel/qgesturemanager.cpp
+++ b/src/widgets/kernel/qgesturemanager.cpp
@@ -63,6 +63,24 @@
QT_BEGIN_NAMESPACE
+static inline int panTouchPoints()
+{
+ // Override by environment variable for testing.
+ static const char panTouchPointVariable[] = "QT_PAN_TOUCHPOINTS";
+ if (qEnvironmentVariableIsSet(panTouchPointVariable)) {
+ bool ok;
+ const int result = qgetenv(panTouchPointVariable).toInt(&ok);
+ if (ok && result >= 1)
+ return result;
+ qWarning() << "Ignoring invalid value of " << panTouchPointVariable;
+ }
+ // Pan should use 1 finger on a touch screen and 2 fingers on touch pads etc.
+ // where 1 finger movements are used for mouse event synthetization. For now,
+ // default to 2 until all classes inheriting QScrollArea are fixed to handle it
+ // correctly.
+ return 2;
+}
+
QGestureManager::QGestureManager(QObject *parent)
: QObject(parent), state(NotGesture), m_lastCustomGestureId(Qt::CustomGesture)
{
@@ -73,7 +91,7 @@ QGestureManager::QGestureManager(QObject *parent)
registerGestureRecognizer(new QMacPinchGestureRecognizer);
registerGestureRecognizer(new QMacPanGestureRecognizer);
#else
- registerGestureRecognizer(new QPanGestureRecognizer);
+ registerGestureRecognizer(new QPanGestureRecognizer(panTouchPoints()));
registerGestureRecognizer(new QPinchGestureRecognizer);
registerGestureRecognizer(new QSwipeGestureRecognizer);
registerGestureRecognizer(new QTapGestureRecognizer);
diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp
index 8a4e0c8ffd..db116b070c 100644
--- a/src/widgets/kernel/qopenglwidget.cpp
+++ b/src/widgets/kernel/qopenglwidget.cpp
@@ -471,7 +471,7 @@ class QOpenGLWidgetPaintDevice : public QOpenGLPaintDevice
{
public:
QOpenGLWidgetPaintDevice(QOpenGLWidget *widget)
- : QOpenGLPaintDevice(new QOpenGLWidgetPaintDevicePrivate(widget)) { }
+ : QOpenGLPaintDevice(*new QOpenGLWidgetPaintDevicePrivate(widget)) { }
void ensureActiveTarget() Q_DECL_OVERRIDE;
};
@@ -578,12 +578,22 @@ GLuint QOpenGLWidgetPrivate::textureId() const
void QOpenGLWidgetPrivate::reset()
{
+ Q_Q(QOpenGLWidget);
+
+ // Destroy the OpenGL resources first. These need the context to be current.
+ if (initialized)
+ q->makeCurrent();
+
delete paintDevice;
paintDevice = 0;
delete fbo;
fbo = 0;
delete resolvedFbo;
resolvedFbo = 0;
+
+ if (initialized)
+ q->doneCurrent();
+
// Delete the context first, then the surface. Slots connected to
// the context's aboutToBeDestroyed() may still call makeCurrent()
// to perform some cleanup.
diff --git a/src/widgets/kernel/qstandardgestures.cpp b/src/widgets/kernel/qstandardgestures.cpp
index 0822c04033..53e5d091fa 100644
--- a/src/widgets/kernel/qstandardgestures.cpp
+++ b/src/widgets/kernel/qstandardgestures.cpp
@@ -38,16 +38,13 @@
#include "qwidget.h"
#include "qabstractscrollarea.h"
#include <qgraphicssceneevent.h>
+#include <QtGui/QTouchDevice>
#include "qdebug.h"
#ifndef QT_NO_GESTURES
QT_BEGIN_NAMESPACE
-QPanGestureRecognizer::QPanGestureRecognizer()
-{
-}
-
QGesture *QPanGestureRecognizer::create(QObject *target)
{
if (target && target->isWidgetType()) {
@@ -62,8 +59,35 @@ QGesture *QPanGestureRecognizer::create(QObject *target)
return new QPanGesture;
}
+static QPointF panOffset(const QList<QTouchEvent::TouchPoint> &touchPoints, int maxCount)
+{
+ QPointF result;
+ const int count = qMin(touchPoints.size(), maxCount);
+ for (int p = 0; p < count; ++p)
+ result += touchPoints.at(p).pos() - touchPoints.at(p).startPos();
+ return result / qreal(count);
+}
+
+// ### fixme: Remove this
+// Use single finger pan to scroll QPlainTextEdit/QTextEdit
+// by changing the number of pan points to 1 for these classes.
+// This used to be Qt 4's behavior on Windows which was achieved using native
+// Windows gesture recognizers for these classes.
+// The other classes inheriting QScrollArea still use standard 2 finger pan.
+// In the long run, they should also use single finger pan to
+// scroll on touch screens, however, this requires a distinct Tap&Hold-followed-by-pan
+// type gesture to avoid clashes with item view selection and DnD.
+
+static inline int panTouchPoints(const QTouchEvent *event, const QObject *object,
+ int defaultTouchPoints)
+{
+ return event->device()->type() == QTouchDevice::TouchScreen && object && object->parent()
+ && (object->parent()->inherits("QPlainTextEdit") || object->parent()->inherits("QTextEdit"))
+ ? 1 : defaultTouchPoints;
+}
+
QGestureRecognizer::Result QPanGestureRecognizer::recognize(QGesture *state,
- QObject *,
+ QObject *object,
QEvent *event)
{
QPanGesture *q = static_cast<QPanGesture *>(state);
@@ -76,18 +100,15 @@ QGestureRecognizer::Result QPanGestureRecognizer::recognize(QGesture *state,
result = QGestureRecognizer::MayBeGesture;
QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
d->lastOffset = d->offset = QPointF();
+ d->pointCount = panTouchPoints(ev, object, m_pointCount);
break;
}
case QEvent::TouchEnd: {
if (q->state() != Qt::NoGesture) {
const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
- if (ev->touchPoints().size() == 2) {
- QTouchEvent::TouchPoint p1 = ev->touchPoints().at(0);
- QTouchEvent::TouchPoint p2 = ev->touchPoints().at(1);
+ if (ev->touchPoints().size() == d->pointCount) {
d->lastOffset = d->offset;
- d->offset =
- QPointF(p1.pos().x() - p1.startPos().x() + p2.pos().x() - p2.startPos().x(),
- p1.pos().y() - p1.startPos().y() + p2.pos().y() - p2.startPos().y()) / 2;
+ d->offset = panOffset(ev->touchPoints(), d->pointCount);
}
result = QGestureRecognizer::FinishGesture;
} else {
@@ -97,16 +118,12 @@ QGestureRecognizer::Result QPanGestureRecognizer::recognize(QGesture *state,
}
case QEvent::TouchUpdate: {
const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
- if (ev->touchPoints().size() >= 2) {
- QTouchEvent::TouchPoint p1 = ev->touchPoints().at(0);
- QTouchEvent::TouchPoint p2 = ev->touchPoints().at(1);
+ if (ev->touchPoints().size() >= d->pointCount) {
d->lastOffset = d->offset;
- d->offset =
- QPointF(p1.pos().x() - p1.startPos().x() + p2.pos().x() - p2.startPos().x(),
- p1.pos().y() - p1.startPos().y() + p2.pos().y() - p2.startPos().y()) / 2;
+ d->offset = panOffset(ev->touchPoints(), d->pointCount);
if (d->offset.x() > 10 || d->offset.y() > 10 ||
d->offset.x() < -10 || d->offset.y() < -10) {
- q->setHotSpot(p1.startScreenPos());
+ q->setHotSpot(ev->touchPoints().first().startScreenPos());
result = QGestureRecognizer::TriggerGesture;
} else {
result = QGestureRecognizer::MayBeGesture;
@@ -283,7 +300,7 @@ QGestureRecognizer::Result QSwipeGestureRecognizer::recognize(QGesture *state,
case QEvent::TouchBegin: {
d->velocityValue = 1;
d->time.start();
- d->started = true;
+ d->state = QSwipeGesturePrivate::Started;
result = QGestureRecognizer::MayBeGesture;
break;
}
@@ -297,9 +314,10 @@ QGestureRecognizer::Result QSwipeGestureRecognizer::recognize(QGesture *state,
}
case QEvent::TouchUpdate: {
const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
- if (!d->started)
+ if (d->state == QSwipeGesturePrivate::NoGesture)
result = QGestureRecognizer::CancelGesture;
else if (ev->touchPoints().size() == 3) {
+ d->state = QSwipeGesturePrivate::ThreePointsReached;
QTouchEvent::TouchPoint p1 = ev->touchPoints().at(0);
QTouchEvent::TouchPoint p2 = ev->touchPoints().at(1);
QTouchEvent::TouchPoint p3 = ev->touchPoints().at(2);
@@ -354,12 +372,18 @@ QGestureRecognizer::Result QSwipeGestureRecognizer::recognize(QGesture *state,
} else if (ev->touchPoints().size() > 3) {
result = QGestureRecognizer::CancelGesture;
} else { // less than 3 touch points
- if (d->started && (ev->touchPointStates() & Qt::TouchPointPressed))
- result = QGestureRecognizer::CancelGesture;
- else if (d->started)
- result = QGestureRecognizer::Ignore;
- else
+ switch (d->state) {
+ case QSwipeGesturePrivate::NoGesture:
result = QGestureRecognizer::MayBeGesture;
+ break;
+ case QSwipeGesturePrivate::Started:
+ result = QGestureRecognizer::Ignore;
+ break;
+ case QSwipeGesturePrivate::ThreePointsReached:
+ result = (ev->touchPointStates() & Qt::TouchPointPressed)
+ ? QGestureRecognizer::CancelGesture : QGestureRecognizer::Ignore;
+ break;
+ }
}
break;
}
@@ -378,7 +402,7 @@ void QSwipeGestureRecognizer::reset(QGesture *state)
d->swipeAngle = 0;
d->lastPositions[0] = d->lastPositions[1] = d->lastPositions[2] = QPoint();
- d->started = false;
+ d->state = QSwipeGesturePrivate::NoGesture;
d->velocityValue = 0;
d->time.invalidate();
diff --git a/src/widgets/kernel/qstandardgestures_p.h b/src/widgets/kernel/qstandardgestures_p.h
index aeabd9cc7e..15ba31f26a 100644
--- a/src/widgets/kernel/qstandardgestures_p.h
+++ b/src/widgets/kernel/qstandardgestures_p.h
@@ -55,11 +55,14 @@ QT_BEGIN_NAMESPACE
class QPanGestureRecognizer : public QGestureRecognizer
{
public:
- QPanGestureRecognizer();
+ explicit QPanGestureRecognizer(int pointCount = 2) : m_pointCount(pointCount) {}
QGesture *create(QObject *target);
QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event);
void reset(QGesture *state);
+
+private:
+ const int m_pointCount;
};
class QPinchGestureRecognizer : public QGestureRecognizer
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 63497ce745..7f2e5a5e17 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -1403,6 +1403,8 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
if (q->testAttribute(Qt::WA_ShowWithoutActivating))
win->setProperty("_q_showWithoutActivating", QVariant(true));
+ if (q->testAttribute(Qt::WA_MacAlwaysShowToolWindow))
+ win->setProperty("_q_macAlwaysShowToolWindow", QVariant::fromValue(QVariant(true)));
win->setFlags(data.window_flags);
fixPosIncludesFrame();
if (q->testAttribute(Qt::WA_Moved)
@@ -7151,10 +7153,7 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
}
}
- // generate a move event for QWidgets without window handles. QWidgets with native
- // window handles already receive a move event from
- // QGuiApplicationPrivate::processGeometryChangeEvent.
- if (isMove && (!q->windowHandle() || q->testAttribute(Qt::WA_DontShowOnScreen))) {
+ if (isMove) {
QMoveEvent e(q->pos(), oldPos);
QApplication::sendEvent(q, &e);
}
@@ -10510,8 +10509,9 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
QWidget *parentWithWindow =
newparent ? (newparent->windowHandle() ? newparent : newparent->nativeParentWidget()) : 0;
if (parentWithWindow) {
- if (f & Qt::Window) {
- q->windowHandle()->setTransientParent(parentWithWindow->windowHandle());
+ QWidget *topLevel = parentWithWindow->window();
+ if ((f & Qt::Window) && topLevel && topLevel->windowHandle()) {
+ q->windowHandle()->setTransientParent(topLevel->windowHandle());
q->windowHandle()->setParent(0);
} else {
q->windowHandle()->setTransientParent(0);
diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp
index 2f2db32852..38f02b2ed9 100644
--- a/src/widgets/kernel/qwidgetbackingstore.cpp
+++ b/src/widgets/kernel/qwidgetbackingstore.cpp
@@ -863,7 +863,7 @@ void QWidgetPrivate::scrollRect(const QRect &rect, int dx, int dy)
QRect scrollRect = rect & clipRect();
bool overlapped = false;
- bool accelerateScroll = accelEnv && isOpaque
+ bool accelerateScroll = accelEnv && isOpaque && !q_func()->testAttribute(Qt::WA_WState_InPaintEvent)
&& !(overlapped = isOverlapped(scrollRect.translated(data.crect.topLeft())));
if (!accelerateScroll) {
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index 7b52638e28..de8f11e5ec 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -434,14 +434,19 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
QWindow *win = w->windowHandle();
if (!win)
win = w->nativeParentWidget()->windowHandle();
- if (win && win->geometry().contains(event->globalPos())) {
- // Use postEvent() to ensure the local QEventLoop terminates when called from QMenu::exec()
- const QPoint localPos = win->mapFromGlobal(event->globalPos());
- QMouseEvent *e = new QMouseEvent(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(), event->button(), event->buttons(), event->modifiers());
- QCoreApplicationPrivate::setEventSpontaneous(e, true);
- QGuiApplicationPrivate::setMouseEventSource(e, QGuiApplicationPrivate::mouseEventSource(event));
- e->setTimestamp(event->timestamp());
- QCoreApplication::postEvent(win, e);
+ if (win) {
+ const QRect globalGeometry = win->isTopLevel()
+ ? win->geometry()
+ : QRect(win->mapToGlobal(QPoint(0, 0)), win->size());
+ if (globalGeometry.contains(event->globalPos())) {
+ // Use postEvent() to ensure the local QEventLoop terminates when called from QMenu::exec()
+ const QPoint localPos = win->mapFromGlobal(event->globalPos());
+ QMouseEvent *e = new QMouseEvent(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(), event->button(), event->buttons(), event->modifiers());
+ QCoreApplicationPrivate::setEventSpontaneous(e, true);
+ QGuiApplicationPrivate::setMouseEventSource(e, QGuiApplicationPrivate::mouseEventSource(event));
+ e->setTimestamp(event->timestamp());
+ QCoreApplication::postEvent(win, e);
+ }
}
}
}
@@ -539,14 +544,36 @@ void QWidgetWindow::handleKeyEvent(QKeyEvent *event)
QGuiApplication::sendSpontaneousEvent(receiver, event);
}
-void QWidgetWindow::updateGeometry()
+bool QWidgetWindow::updateSize()
{
+ bool changed = false;
if (m_widget->testAttribute(Qt::WA_OutsideWSRange))
- return;
+ return changed;
+ if (m_widget->data->crect.size() != geometry().size()) {
+ changed = true;
+ m_widget->data->crect.setSize(geometry().size());
+ }
- const QMargins margins = frameMargins();
+ updateMargins();
+ return changed;
+}
+
+bool QWidgetWindow::updatePos()
+{
+ bool changed = false;
+ if (m_widget->testAttribute(Qt::WA_OutsideWSRange))
+ return changed;
+ if (m_widget->data->crect.topLeft() != geometry().topLeft()) {
+ changed = true;
+ m_widget->data->crect.moveTopLeft(geometry().topLeft());
+ }
+ updateMargins();
+ return changed;
+}
- m_widget->data->crect = geometry();
+void QWidgetWindow::updateMargins()
+{
+ const QMargins margins = frameMargins();
QTLWExtra *te = m_widget->d_func()->topData();
te->posIncludesFrame= false;
te->frameStrut.setCoords(margins.left(), margins.top(), margins.right(), margins.bottom());
@@ -605,24 +632,25 @@ void QWidgetWindow::updateNormalGeometry()
void QWidgetWindow::handleMoveEvent(QMoveEvent *event)
{
- updateGeometry();
- QGuiApplication::sendSpontaneousEvent(m_widget, event);
+ if (updatePos())
+ QGuiApplication::sendSpontaneousEvent(m_widget, event);
}
void QWidgetWindow::handleResizeEvent(QResizeEvent *event)
{
QSize oldSize = m_widget->data->crect.size();
- updateGeometry();
- QGuiApplication::sendSpontaneousEvent(m_widget, event);
+ if (updateSize()) {
+ QGuiApplication::sendSpontaneousEvent(m_widget, event);
- if (m_widget->d_func()->paintOnScreen()) {
- QRegion updateRegion(geometry());
- if (m_widget->testAttribute(Qt::WA_StaticContents))
- updateRegion -= QRect(0, 0, oldSize.width(), oldSize.height());
- m_widget->d_func()->syncBackingStore(updateRegion);
- } else {
- m_widget->d_func()->syncBackingStore();
+ if (m_widget->d_func()->paintOnScreen()) {
+ QRegion updateRegion(geometry());
+ if (m_widget->testAttribute(Qt::WA_StaticContents))
+ updateRegion -= QRect(0, 0, oldSize.width(), oldSize.height());
+ m_widget->d_func()->syncBackingStore(updateRegion);
+ } else {
+ m_widget->d_func()->syncBackingStore();
+ }
}
}
diff --git a/src/widgets/kernel/qwidgetwindow_p.h b/src/widgets/kernel/qwidgetwindow_p.h
index 7f12ae8e20..0632a5c364 100644
--- a/src/widgets/kernel/qwidgetwindow_p.h
+++ b/src/widgets/kernel/qwidgetwindow_p.h
@@ -108,7 +108,9 @@ private slots:
private:
void repaintWindow();
- void updateGeometry();
+ bool updateSize();
+ bool updatePos();
+ void updateMargins();
void updateNormalGeometry();
enum FocusWidgets {
diff --git a/src/widgets/styles/qandroidstyle.cpp b/src/widgets/styles/qandroidstyle.cpp
index 38c7497ffa..5b4b346da9 100644
--- a/src/widgets/styles/qandroidstyle.cpp
+++ b/src/widgets/styles/qandroidstyle.cpp
@@ -38,7 +38,6 @@
#include <QFile>
#include <QFont>
#include <QApplication>
-#include <QTime>
#include <qdrawutil.h>
#include <QPixmapCache>
#include <QFileInfo>
@@ -55,105 +54,33 @@
QT_BEGIN_NAMESPACE
namespace {
- const int textStyle_bold = 1;
- const int textStyle_italic = 2;
-
- const int typeface_sans = 1;
- const int typeface_serif = 2;
- const int typeface_monospace = 3;
-
const quint32 NO_COLOR = 1;
const quint32 TRANSPARENT_COLOR = 0;
}
-static int fontType(const QString &androidControl)
-{
- if (androidControl == QLatin1String("textViewStyle"))
- return QPlatformTheme::SystemFont;
- else if (androidControl == QLatin1String("buttonStyle"))
- return QPlatformTheme::PushButtonFont;
- else if (androidControl == QLatin1String("checkboxStyle"))
- return QPlatformTheme::CheckBoxFont;
- else if (androidControl == QLatin1String("radioButtonStyle"))
- return QPlatformTheme::RadioButtonFont;
- else if (androidControl == QLatin1String("simple_list_item_single_choice"))
- return QPlatformTheme::ItemViewFont;
- else if (androidControl == QLatin1String("simple_spinner_dropdown_item"))
- return QPlatformTheme::ComboMenuItemFont;
- else if (androidControl == QLatin1String("spinnerStyle"))
- return QPlatformTheme::ComboLineEditFont;
- else if (androidControl == QLatin1String("simple_list_item"))
- return QPlatformTheme::ListViewFont;
- return -1;
-}
-
-static int paletteType(const QString &androidControl)
-{
- if (androidControl == QLatin1String("textViewStyle"))
- return QPlatformTheme::SystemPalette;
- else if (androidControl == QLatin1String("buttonStyle"))
- return QPlatformTheme::ButtonPalette;
- else if (androidControl == QLatin1String("checkboxStyle"))
- return QPlatformTheme::CheckBoxPalette;
- else if (androidControl == QLatin1String("radioButtonStyle"))
- return QPlatformTheme::RadioButtonPalette;
- else if (androidControl == QLatin1String("simple_list_item_single_choice"))
- return QPlatformTheme::ItemViewPalette;
- else if (androidControl == QLatin1String("editTextStyle"))
- return QPlatformTheme::TextLineEditPalette;
- else if (androidControl == QLatin1String("spinnerStyle"))
- return QPlatformTheme::ComboBoxPalette;
- return -1;
-}
-
QAndroidStyle::QAndroidStyle()
: QFusionStyle()
{
QPixmapCache::clear();
checkBoxControl = NULL;
- QString stylePath(QLatin1String(qgetenv("MINISTRO_ANDROID_STYLE_PATH")));
- const QLatin1Char slashChar('/');
- if (!stylePath.isEmpty() && !stylePath.endsWith(slashChar))
- stylePath += slashChar;
-
- QString androidTheme = QLatin1String(qgetenv("QT_ANDROID_THEME"));
- if (!androidTheme.isEmpty() && !androidTheme.endsWith(slashChar))
- androidTheme += slashChar;
-
- if (stylePath.isEmpty()) {
- stylePath = QLatin1String("/data/data/org.kde.necessitas.ministro/files/dl/style/")
- + QLatin1String(qgetenv("QT_ANDROID_THEME_DISPLAY_DPI")) + slashChar;
- }
- Q_ASSERT(!stylePath.isEmpty());
-
- if (!androidTheme.isEmpty() && QFileInfo(stylePath + androidTheme + QLatin1String("style.json")).exists())
- stylePath += androidTheme;
-
- QFile f(stylePath + QLatin1String("style.json"));
- if (!f.open(QIODevice::ReadOnly))
- return;
-
- QJsonParseError error;
- QJsonDocument document = QJsonDocument::fromJson(f.readAll(), &error);
- if (document.isNull()) {
- qCritical() << error.errorString();
- return;
+ QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
+ QPalette *standardPalette = reinterpret_cast<QPalette *>(nativeInterface->nativeResourceForIntegration("AndroidStandardPalette"));
+ if (standardPalette)
+ m_standardPalette = *standardPalette;
+
+ QHash<QByteArray, QFont> *qwidgetsFonts = reinterpret_cast<QHash<QByteArray, QFont> *>(nativeInterface->nativeResourceForIntegration("AndroidQWidgetFonts"));
+ if (qwidgetsFonts) {
+ for (auto it = qwidgetsFonts->constBegin(); it != qwidgetsFonts->constEnd(); ++it)
+ QApplication::setFont(it.value(), it.key());
+ qwidgetsFonts->clear(); // free the memory
}
- if (!document.isObject()) {
- qCritical() << "Style.json does not contain a valid style.";
+ QJsonObject *object = reinterpret_cast<QJsonObject *>(nativeInterface->nativeResourceForIntegration("AndroidStyleData"));
+ if (!object)
return;
- }
- QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
-
- QHash<int, QPalette> *palettes = reinterpret_cast<QHash<int, QPalette> *>(nativeInterface->nativeResourceForIntegration("AndroidStylePalettes"));
- QHash<int, QFont> *fonts = reinterpret_cast<QHash<int, QFont> *>(nativeInterface->nativeResourceForIntegration("AndroidStyleFonts"));
- palettes->clear();
- fonts->clear();
- QJsonObject object = document.object();
- for (QJsonObject::const_iterator objectIterator = object.constBegin();
- objectIterator != object.constEnd();
+ for (QJsonObject::const_iterator objectIterator = object->constBegin();
+ objectIterator != object->constEnd();
++objectIterator) {
QString key = objectIterator.key();
QJsonValue value = objectIterator.value();
@@ -163,85 +90,6 @@ QAndroidStyle::QAndroidStyle()
}
QJsonObject item = value.toObject();
- QJsonObject::const_iterator attributeIterator = item.find(QLatin1String("qtClass"));
- QString qtClassName;
- if (attributeIterator != item.constEnd()) {
- // The item has palette and font information for a specific Qt Class (e.g. QWidget, QPushButton, etc.)
- qtClassName = attributeIterator.value().toString();
- }
- const int ft = fontType(key);
- if (ft > -1 || !qtClassName.isEmpty()) {
- // Extract font information
- QFont font;
-
- // Font size (in pixels)
- attributeIterator = item.find(QLatin1String("TextAppearance_textSize"));
- if (attributeIterator != item.constEnd())
- font.setPixelSize(int(attributeIterator.value().toDouble()));
-
- // Font style
- attributeIterator = item.find(QLatin1String("TextAppearance_textStyle"));
- if (attributeIterator != item.constEnd()) {
- const int style = int(attributeIterator.value().toDouble());
- font.setBold(style & textStyle_bold);
- font.setItalic(style & textStyle_italic);
- }
-
- // Font typeface
- attributeIterator = item.find(QLatin1String("TextAppearance_typeface"));
- if (attributeIterator != item.constEnd()) {
- QFont::StyleHint styleHint = QFont::AnyStyle;
- switch (int(attributeIterator.value().toDouble())) {
- case typeface_sans:
- styleHint = QFont::SansSerif;
- break;
- case typeface_serif:
- styleHint = QFont::Serif;
- break;
- case typeface_monospace:
- styleHint = QFont::Monospace;
- break;
- }
- font.setStyleHint(styleHint, QFont::PreferMatch);
- }
- if (!qtClassName.isEmpty())
- QApplication::setFont(font, qtClassName.toUtf8());
- if (ft > -1)
- fonts->insert(ft, font);
- // Extract font information
- }
-
- const int pt = paletteType(key);
- if (pt > -1 || !qtClassName.isEmpty()) {
- // Extract palette information
- QPalette palette;
- attributeIterator = item.find(QLatin1String("defaultTextColorPrimary"));
- if (attributeIterator != item.constEnd())
- palette.setColor(QPalette::WindowText, QRgb(int(attributeIterator.value().toDouble())));
-
- attributeIterator = item.find(QLatin1String("defaultBackgroundColor"));
- if (attributeIterator != item.constEnd())
- palette.setColor(QPalette::Background, QRgb(int(attributeIterator.value().toDouble())));
-
- attributeIterator = item.find(QLatin1String("TextAppearance_textColor"));
- if (attributeIterator != item.constEnd())
- setPaletteColor(attributeIterator.value().toObject().toVariantMap(), palette, QPalette::WindowText);
-
- attributeIterator = item.find(QLatin1String("TextAppearance_textColorLink"));
- if (attributeIterator != item.constEnd())
- setPaletteColor(attributeIterator.value().toObject().toVariantMap(), palette, QPalette::Link);
-
- attributeIterator = item.find(QLatin1String("TextAppearance_textColorHighlight"));
- if (attributeIterator != item.constEnd())
- palette.setColor(QPalette::Highlight, QRgb(int(attributeIterator.value().toDouble())));
-
- if (QLatin1String("QWidget") == qtClassName)
- m_standardPalette = palette;
-
- if (pt > -1)
- palettes->insert(pt, palette);
- // Extract palette information
- }
QAndroidStyle::ItemType itemType = qtControl(key);
if (QC_UnknownType == itemType)
continue;
@@ -277,6 +125,7 @@ QAndroidStyle::QAndroidStyle()
break;
}
}
+ *object = QJsonObject(); // free memory
}
QAndroidStyle::~QAndroidStyle()
@@ -284,81 +133,6 @@ QAndroidStyle::~QAndroidStyle()
qDeleteAll(m_androidControlsHash);
}
-
-void QAndroidStyle::setPaletteColor(const QVariantMap &object,
- QPalette &palette,
- QPalette::ColorRole role)
-{
- // QPalette::Active -> ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET
- palette.setColor(QPalette::Active,
- role,
- QRgb(object.value(QLatin1String("ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET")).toInt()));
-
- // QPalette::Inactive -> ENABLED_STATE_SET
- palette.setColor(QPalette::Inactive,
- role,
- QRgb(object.value(QLatin1String("ENABLED_STATE_SET")).toInt()));
-
- // QPalette::Disabled -> EMPTY_STATE_SET
- palette.setColor(QPalette::Disabled,
- role,
- QRgb(object.value(QLatin1String("EMPTY_STATE_SET")).toInt()));
-
- palette.setColor(QPalette::Current, role, palette.color(QPalette::Active, role));
-
- if (role == QPalette::WindowText) {
- // QPalette::BrightText -> PRESSED
- // QPalette::Active -> PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET
- palette.setColor(QPalette::Active,
- QPalette::BrightText,
- QRgb(object.value(QLatin1String("PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET")).toInt()));
-
- // QPalette::Inactive -> PRESSED_ENABLED_STATE_SET
- palette.setColor(QPalette::Inactive,
- QPalette::BrightText,
- QRgb(object.value(QLatin1String("PRESSED_ENABLED_STATE_SET")).toInt()));
-
- // QPalette::Disabled -> PRESSED_STATE_SET
- palette.setColor(QPalette::Disabled,
- QPalette::BrightText,
- QRgb(object.value(QLatin1String("PRESSED_STATE_SET")).toInt()));
-
- palette.setColor(QPalette::Current, QPalette::BrightText, palette.color(QPalette::Active, QPalette::BrightText));
-
- // QPalette::HighlightedText -> SELECTED
- // QPalette::Active -> ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET
- palette.setColor(QPalette::Active,
- QPalette::HighlightedText,
- QRgb(object.value(QLatin1String("ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET")).toInt()));
-
- // QPalette::Inactive -> ENABLED_SELECTED_STATE_SET
- palette.setColor(QPalette::Inactive,
- QPalette::HighlightedText,
- QRgb(object.value(QLatin1String("ENABLED_SELECTED_STATE_SET")).toInt()));
-
- // QPalette::Disabled -> SELECTED_STATE_SET
- palette.setColor(QPalette::Disabled,
- QPalette::HighlightedText,
- QRgb(object.value(QLatin1String("SELECTED_STATE_SET")).toInt()));
-
- palette.setColor(QPalette::Current,
- QPalette::HighlightedText,
- palette.color(QPalette::Active, QPalette::HighlightedText));
-
- // Same colors for Text
- palette.setColor(QPalette::Active, QPalette::Text, palette.color(QPalette::Active, role));
- palette.setColor(QPalette::Inactive, QPalette::Text, palette.color(QPalette::Inactive, role));
- palette.setColor(QPalette::Disabled, QPalette::Text, palette.color(QPalette::Disabled, role));
- palette.setColor(QPalette::Current, QPalette::Text, palette.color(QPalette::Current, role));
-
- // And for ButtonText
- palette.setColor(QPalette::Active, QPalette::ButtonText, palette.color(QPalette::Active, role));
- palette.setColor(QPalette::Inactive, QPalette::ButtonText, palette.color(QPalette::Inactive, role));
- palette.setColor(QPalette::Disabled, QPalette::ButtonText, palette.color(QPalette::Disabled, role));
- palette.setColor(QPalette::Current, QPalette::ButtonText, palette.color(QPalette::Current, role));
- }
-}
-
QAndroidStyle::ItemType QAndroidStyle::qtControl(const QString &android)
{
if (android == QLatin1String("buttonStyle"))
@@ -470,6 +244,10 @@ QAndroidStyle::ItemType QAndroidStyle::qtControl(QStyle::PrimitiveElement primit
case QStyle::PE_FrameLineEdit:
return QC_EditText;
+ case QStyle::PE_IndicatorViewItemCheck:
+ case QStyle::PE_IndicatorCheckBox:
+ return QC_Checkbox;
+
case QStyle::PE_FrameWindow:
case QStyle::PE_Widget:
case QStyle::PE_Frame:
@@ -583,37 +361,8 @@ void QAndroidStyle::drawControl(QStyle::ControlElement element,
}
break;
default:
- break;
- }
- } else if (element == CE_ItemViewItem) {
- const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt);
- if (vopt && vopt->features & QStyleOptionViewItem::HasCheckIndicator) {
- p->save();
- p->setClipRect(opt->rect);
-
- QRect checkRect = proxy()->subElementRect(SE_ItemViewItemCheckIndicator, vopt, w);
-
- // draw the background
- proxy()->drawPrimitive(PE_PanelItemViewItem, opt, p, w);
-
- // draw the check mark
- QStyleOptionViewItem option(*vopt);
- option.rect = checkRect;
- option.state = option.state & ~QStyle::State_HasFocus;
-
- switch (vopt->checkState) {
- case Qt::Unchecked:
- option.state |= QStyle::State_Off;
- break;
- default:
- option.state |= QStyle::State_On;
- break;
- }
- QPixmap pixmap = checkBoxControl->imgCheckBox(&option);
- p->drawPixmap(checkRect, pixmap);
- p->restore();
- } else {
QFusionStyle::drawControl(element, opt, p, w);
+ break;
}
} else {
QFusionStyle::drawControl(element, opt, p, w);
@@ -758,7 +507,7 @@ QRect QAndroidStyle::subControlRect(ComplexControl cc,
case CC_GroupBox: {
if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
QSize textSize = opt->fontMetrics.boundingRect(groupBox->text).size() + QSize(2, 2);
- QSize checkBoxSize = checkBoxControl->sizeCheckBox(opt);
+ QSize checkBoxSize = checkBoxControl->size(opt);
int indicatorWidth = checkBoxSize.width();
int indicatorHeight = checkBoxSize.height();
QRect checkBoxRect;
@@ -815,9 +564,9 @@ int QAndroidStyle::pixelMetric(PixelMetric metric, const QStyleOption *option,
case PM_ScrollBarExtent:
return 0;
case PM_IndicatorWidth:
- return checkBoxControl->sizeCheckBox(option).width();
+ return checkBoxControl->size(option).width();
case PM_IndicatorHeight:
- return checkBoxControl->sizeCheckBox(option).height();
+ return checkBoxControl->size(option).height();
default:
return QFusionStyle::pixelMetric(metric, option, widget);
}
@@ -834,7 +583,7 @@ QSize QAndroidStyle::sizeFromContents(ContentsType ct,
if (const QStyleOptionHeader *hdr = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
bool nullIcon = hdr->icon.isNull();
int margin = pixelMetric(QStyle::PM_HeaderMargin, hdr, w);
- int iconSize = nullIcon ? 0 : checkBoxControl->sizeCheckBox(opt).width();
+ int iconSize = nullIcon ? 0 : checkBoxControl->size(opt).width();
QSize txt;
/*
* These next 4 lines are a bad hack to fix a bug in case a QStyleSheet is applied at QApplication level.
@@ -868,7 +617,7 @@ QSize QAndroidStyle::sizeFromContents(ContentsType ct,
if (ct == CT_GroupBox) {
if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
QSize textSize = opt->fontMetrics.boundingRect(groupBox->text).size() + QSize(2, 2);
- QSize checkBoxSize = checkBoxControl->sizeCheckBox(opt);
+ QSize checkBoxSize = checkBoxControl->size(opt);
int indicatorWidth = checkBoxSize.width();
int indicatorHeight = checkBoxSize.height();
QRect checkBoxRect;
@@ -964,13 +713,6 @@ QSize QAndroidStyle::AndroidDrawable::size() const
return QSize();
}
-QPixmap QAndroidStyle::AndroidDrawable::img() const
-{
- if (type() == Image || type() == NinePatch)
- return static_cast<const QAndroidStyle::AndroidImageDrawable *>(this)->img();
-
- return QPixmap();
-}
QAndroidStyle::AndroidDrawable * QAndroidStyle::AndroidDrawable::fromMap(const QVariantMap &drawable,
ItemType itemType)
@@ -1036,19 +778,7 @@ void QAndroidStyle::AndroidImageDrawable::draw(QPainter *painter, const QStyleOp
QPixmapCache::insert(m_hashKey, pm);
}
- painter->drawPixmap(opt->rect.x(), (opt->rect.height() - pm.height()) / 2, pm);
-}
-QPixmap QAndroidStyle::AndroidImageDrawable::img() const
-{
- if (m_hashKey.isEmpty())
- m_hashKey = QFileInfo(m_filePath).fileName();
-
- QPixmap pm;
- if (!QPixmapCache::find(m_hashKey, &pm)) {
- pm.load(m_filePath);
- QPixmapCache::insert(m_hashKey, pm);
- }
- return pm;
+ painter->drawPixmap(opt->rect.x(), opt->rect.y() + (opt->rect.height() - pm.height()) / 2, pm);
}
QSize QAndroidStyle::AndroidImageDrawable::size() const
@@ -1446,14 +1176,6 @@ QSize QAndroidStyle::AndroidStateDrawable::sizeImage(const QStyleOption *opt) co
s = drawable->size();
return s;
}
-QPixmap QAndroidStyle::AndroidStateDrawable::img(const QStyleOption *opt) const
-{
- QPixmap pm;
- const AndroidDrawable *drawable = bestAndroidStateMatch(opt);
- if (drawable)
- pm = drawable->img();
- return pm;
-}
const QAndroidStyle::AndroidDrawable * QAndroidStyle::AndroidStateDrawable::bestAndroidStateMatch(const QStyleOption *opt) const
{
@@ -1733,7 +1455,6 @@ QRect QAndroidStyle::AndroidControl::subElementRect(QStyle::SubElement /* subEle
return visualRect(option->direction, option->rect, r);
}
return option->rect;
-
}
QRect QAndroidStyle::AndroidControl::subControlRect(const QStyleOptionComplex *option,
@@ -1778,6 +1499,16 @@ QMargins QAndroidStyle::AndroidControl::padding()
return QMargins();
}
+QSize QAndroidStyle::AndroidControl::size(const QStyleOption *option)
+{
+ if (const AndroidDrawable *drawable = backgroundDrawable()) {
+ if (drawable->type() == State)
+ drawable = static_cast<const AndroidStateDrawable *>(backgroundDrawable())->bestAndroidStateMatch(option);
+ return drawable->size();
+ }
+ return QSize();
+}
+
const QAndroidStyle::AndroidDrawable *QAndroidStyle::AndroidControl::backgroundDrawable() const
{
return m_background;
@@ -1788,11 +1519,12 @@ QAndroidStyle::AndroidCompoundButtonControl::AndroidCompoundButtonControl(const
: AndroidControl(control, itemType)
{
QVariantMap::const_iterator it = control.find(QLatin1String("CompoundButton_button"));
- if (it != control.end())
+ if (it != control.end()) {
m_button = AndroidDrawable::fromMap(it.value().toMap(), itemType);
- else
+ const_cast<AndroidDrawable *>(m_button)->setPaddingLeftToSizeWidth();
+ } else {
m_button = 0;
- const_cast<AndroidDrawable *>(m_button)->setPaddingLeftToSizeWidth();
+ }
}
QAndroidStyle::AndroidCompoundButtonControl::~AndroidCompoundButtonControl()
@@ -1808,16 +1540,24 @@ void QAndroidStyle::AndroidCompoundButtonControl::drawControl(const QStyleOption
if (m_button)
m_button->draw(p, opt);
}
-QSize QAndroidStyle::AndroidCompoundButtonControl::sizeCheckBox(const QStyleOption *opt) const
+
+QMargins QAndroidStyle::AndroidCompoundButtonControl::padding()
{
- const AndroidDrawable *drawable = m_button;
- return static_cast<const QAndroidStyle::AndroidStateDrawable *>(drawable)->sizeImage(opt);
+ if (m_button)
+ return m_button->padding();
+ return AndroidControl::padding();
}
-QPixmap QAndroidStyle::AndroidCompoundButtonControl::imgCheckBox(const QStyleOption *opt) const
+
+QSize QAndroidStyle::AndroidCompoundButtonControl::size(const QStyleOption *option)
{
- const AndroidDrawable *drawable = m_button;
- return static_cast<const QAndroidStyle::AndroidStateDrawable *>(drawable)->img(opt);
+ if (m_button) {
+ if (m_button->type() == State)
+ return static_cast<const AndroidStateDrawable *>(m_button)->bestAndroidStateMatch(option)->size();
+ return m_button->size();
+ }
+ return AndroidControl::size(option);
}
+
const QAndroidStyle::AndroidDrawable * QAndroidStyle::AndroidCompoundButtonControl::backgroundDrawable() const
{
return m_background ? m_background : m_button;
@@ -1908,7 +1648,6 @@ QRect QAndroidStyle::AndroidProgressBarControl::subElementRect(QStyle::SubElemen
p |= QRect(padding.left(), padding.top(), padding.right() - padding.left(), padding.bottom() - padding.top());
padding = m_progressDrawable->padding();
p |= QRect(padding.left(), padding.top(), padding.right() - padding.left(), padding.bottom() - padding.top());
-
QRect r = option->rect.adjusted(p.left(), p.top(), -p.right(), -p.bottom());
if (horizontal) {
@@ -1991,15 +1730,15 @@ void QAndroidStyle::AndroidSeekBarControl::drawControl(const QStyleOption *optio
if (drawable->type() == State)
drawable = static_cast<const QAndroidStyle::AndroidStateDrawable *>(m_seekBarThumb)->bestAndroidStateMatch(option);
QStyleOption copy(*option);
- copy.rect.setY((copy.rect.height() - m_minSize.height()) / 2);
- copy.rect.setHeight(m_minSize.height());
+ copy.rect.setHeight(m_progressDrawable->size().height());
copy.rect.setWidth(copy.rect.width() - drawable->size().width());
- copy.rect.translate(drawable->size().width() / 2, 0);
+ const int yTranslate = abs(drawable->size().height() - copy.rect.height()) / 2;
+ copy.rect.translate(drawable->size().width() / 2, yTranslate);
m_progressDrawable->draw(p, &copy);
if (styleOption->orientation == Qt::Vertical)
qCritical() << "Vertical slider are not supported";
- int pos = copy.rect.width()*factor - drawable->size().width() / 2;
- copy.rect.translate(pos, 0);
+ int pos = copy.rect.width() * factor - drawable->size().width() / 2;
+ copy.rect.translate(pos, -yTranslate);
copy.rect.setSize(drawable->size());
m_seekBarThumb->draw(p, &copy);
}
diff --git a/src/widgets/styles/qandroidstyle_p.h b/src/widgets/styles/qandroidstyle_p.h
index 65fa4cd096..d8e7768380 100644
--- a/src/widgets/styles/qandroidstyle_p.h
+++ b/src/widgets/styles/qandroidstyle_p.h
@@ -124,7 +124,6 @@ public:
static AndroidDrawable *fromMap(const QVariantMap &drawable, ItemType itemType);
static QMargins extractMargins(const QVariantMap &value);
virtual void setPaddingLeftToSizeWidth();
- QPixmap img() const;
protected:
ItemType m_itemType;
QMargins m_padding;
@@ -149,7 +148,6 @@ public:
virtual void draw(QPainter *painter,const QStyleOption *opt) const;
virtual QSize size() const;
- QPixmap img() const;
protected:
QString m_filePath;
mutable QString m_hashKey;
@@ -223,7 +221,6 @@ public:
static int extractState(const QVariantMap &value);
virtual void setPaddingLeftToSizeWidth();
QSize sizeImage(const QStyleOption *opt) const;
- QPixmap img(const QStyleOption *opt) const;
private:
typedef QPair<int, const AndroidDrawable *> StateType;
QList<StateType> m_states;
@@ -263,6 +260,7 @@ public:
const QSize &contentsSize,
const QWidget *w) const;
virtual QMargins padding();
+ virtual QSize size(const QStyleOption *option);
protected:
virtual const AndroidDrawable * backgroundDrawable() const;
const AndroidDrawable *m_background;
@@ -276,8 +274,8 @@ public:
AndroidCompoundButtonControl(const QVariantMap &control, ItemType itemType);
virtual ~AndroidCompoundButtonControl();
virtual void drawControl(const QStyleOption *opt, QPainter *p, const QWidget *w);
- QSize sizeCheckBox(const QStyleOption *opt) const;
- QPixmap imgCheckBox(const QStyleOption *opt) const;
+ virtual QMargins padding();
+ virtual QSize size(const QStyleOption *option);
protected:
virtual const AndroidDrawable * backgroundDrawable() const;
const AndroidDrawable *m_button;
@@ -376,9 +374,6 @@ private:
static ItemType qtControl(QStyle::SubElement subElement);
static ItemType qtControl(const QString &android);
- static void setPaletteColor(const QVariantMap &object,
- QPalette &palette,
- QPalette::ColorRole role);
private:
typedef QHash<int, AndroidControl *> AndroidControlsHash;
AndroidControlsHash m_androidControlsHash;
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index 815b10c921..7e9a631c5e 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -1114,7 +1114,7 @@ void QCommonStylePrivate::tabLayout(const QStyleOptionTabV3 *opt, const QWidget
(opt->state & QStyle::State_Enabled) ? QIcon::Normal : QIcon::Disabled,
(opt->state & QStyle::State_Selected) ? QIcon::On : QIcon::Off );
// High-dpi icons do not need adjustmet; make sure tabIconSize is not larger than iconSize
- tabIconSize = QSize(qMin(tabIconSize.width(), iconSize.width()), qMin(tabIconSize.height(), iconSize.width()));
+ tabIconSize = QSize(qMin(tabIconSize.width(), iconSize.width()), qMin(tabIconSize.height(), iconSize.height()));
*iconRect = QRect(tr.left(), tr.center().y() - tabIconSize.height() / 2,
tabIconSize.width(), tabIconSize .height());
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index ef3795c9a1..817f16b297 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -553,7 +553,9 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem,
arrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), arrowColor);
} else if (header->sortIndicator & QStyleOptionHeader::SortDown) {
arrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), arrowColor, 180);
- } if (!arrow.isNull()) {
+ }
+
+ if (!arrow.isNull()) {
r.setSize(QSize(arrow.width()/2, arrow.height()/2));
r.moveCenter(header->rect.center());
painter->drawPixmap(r.translated(offset), arrow);
diff --git a/src/widgets/styles/qgtkstyle_p.cpp b/src/widgets/styles/qgtkstyle_p.cpp
index 06ee74bdfe..61d1cd796e 100644
--- a/src/widgets/styles/qgtkstyle_p.cpp
+++ b/src/widgets/styles/qgtkstyle_p.cpp
@@ -701,10 +701,12 @@ GtkWidget* QGtkStylePrivate::getTextColorWidget() const
void QGtkStylePrivate::setupGtkWidget(GtkWidget* widget)
{
if (Q_GTK_IS_WIDGET(widget)) {
- static GtkWidget* protoLayout = 0;
+ GtkWidget *protoLayout = gtkWidgetMap()->value("GtkContainer");
if (!protoLayout) {
protoLayout = QGtkStylePrivate::gtk_fixed_new();
QGtkStylePrivate::gtk_container_add((GtkContainer*)(gtkWidgetMap()->value("GtkWindow")), protoLayout);
+ QHashableLatin1Literal widgetPath = QHashableLatin1Literal::fromData(strdup("GtkContainer"));
+ gtkWidgetMap()->insert(widgetPath, protoLayout);
}
Q_ASSERT(protoLayout);
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm
index fb0bafa66d..328378cb8e 100644
--- a/src/widgets/styles/qmacstyle_mac.mm
+++ b/src/widgets/styles/qmacstyle_mac.mm
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtWidgets module of the Qt Toolkit.
@@ -296,14 +296,12 @@ void drawTabShape(QPainter *p, const QStyleOptionTabV3 *tabOpt, bool isUnified)
p->fillRect(rect, QColor(Qt::transparent));
p->restore();
} else if (active) {
- int d = (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) ? 16 : 0;
- p->fillRect(rect, QColor(151 + d, 151 + d, 151 + d));
+ p->fillRect(rect, QColor(167, 167, 167));
} else {
- int d = (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) ? 9 : 0;
QLinearGradient gradient(rect.topLeft(), rect.bottomLeft());
- gradient.setColorAt(0, QColor(207 + d, 207 + d, 207 + d));
- gradient.setColorAt(0.5, QColor(206 + d, 206 + d, 206 + d));
- gradient.setColorAt(1, QColor(201 + d, 201 + d, 201 + d));
+ gradient.setColorAt(0, QColor(216, 216, 216));
+ gradient.setColorAt(0.5, QColor(215, 215, 215));
+ gradient.setColorAt(1, QColor(210, 210, 210));
p->fillRect(rect, gradient);
}
@@ -881,13 +879,6 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg
gbi.size = sz == QAquaSizeSmall ? kHIThemeGrowBoxSizeSmall : kHIThemeGrowBoxSizeNormal;
if (HIThemeGetGrowBoxBounds(&p, &gbi, &r) == noErr) {
int width = 0;
- // Snow Leopard and older get a size grip, as well as QMdiSubWindows.
- if (QSysInfo::MacintoshVersion <= QSysInfo::MV_10_6
-#ifndef QT_NO_MDIAREA
- || (widg && widg->parentWidget() && qobject_cast<QMdiSubWindow *>(widg->parentWidget()))
-#endif
- )
- width = r.size.width;
ret = QSize(width, r.size.height);
}
}
@@ -1830,7 +1821,7 @@ static QCocoaWidget cocoaWidgetFromHIThemeButtonKind(ThemeButtonKind kind)
return w;
}
-NSView *QMacStylePrivate::cocoaControl(QCocoaWidget widget, QPoint *offset) const
+NSView *QMacStylePrivate::cocoaControl(QCocoaWidget widget) const
{
NSView *bv = cocoaControls[widget];
if (!bv) {
@@ -1903,37 +1894,39 @@ NSView *QMacStylePrivate::cocoaControl(QCocoaWidget widget, QPoint *offset) cons
const_cast<QMacStylePrivate *>(this)->cocoaControls.insert(widget, bv);
}
- if (offset) {
- if (widget == QCocoaWidget(QCocoaRadioButton, QAquaSizeLarge))
- offset->setY(2);
- else if (widget == QCocoaWidget(QCocoaRadioButton, QAquaSizeSmall))
- *offset = QPoint(-1, 2);
- else if (widget == QCocoaWidget(QCocoaRadioButton, QAquaSizeMini))
- offset->setY(2);
- else if (widget == QCocoaWidget(QCocoaPopupButton, QAquaSizeSmall)
- || widget == QCocoaWidget(QCocoaCheckBox, QAquaSizeLarge))
- offset->setY(1);
- else if (widget == QCocoaWidget(QCocoaCheckBox, QAquaSizeSmall))
- offset->setX(-1);
- else if (widget == QCocoaWidget(QCocoaCheckBox, QAquaSizeMini))
- *offset = QPoint(7, 5);
- else if (widget == QCocoaWidget(QCocoaPopupButton, QAquaSizeMini))
- *offset = QPoint(2, -1);
- else if (widget == QCocoaWidget(QCocoaPullDownButton, QAquaSizeLarge))
- *offset = QPoint(3, -1);
- else if (widget == QCocoaWidget(QCocoaPullDownButton, QAquaSizeSmall))
- *offset = QPoint(2, 1);
- else if (widget == QCocoaWidget(QCocoaPullDownButton, QAquaSizeMini))
- *offset = QPoint(5, 0);
- }
-
return bv;
}
-void QMacStylePrivate::drawNSViewInRect(NSView *view, const QRect &qtRect, QPainter *p, QCocoaDrawRectBlock drawRectBlock) const
+void QMacStylePrivate::drawNSViewInRect(QCocoaWidget widget, NSView *view, const QRect &qtRect, QPainter *p, bool isQWidget, QCocoaDrawRectBlock drawRectBlock) const
{
+ QPoint offset;
+ if (widget == QCocoaWidget(QCocoaRadioButton, QAquaSizeLarge))
+ offset.setY(2);
+ else if (widget == QCocoaWidget(QCocoaRadioButton, QAquaSizeSmall))
+ offset = QPoint(-1, 2);
+ else if (widget == QCocoaWidget(QCocoaRadioButton, QAquaSizeMini))
+ offset.setY(2);
+ else if (widget == QCocoaWidget(QCocoaPopupButton, QAquaSizeSmall)
+ || widget == QCocoaWidget(QCocoaCheckBox, QAquaSizeLarge))
+ offset.setY(1);
+ else if (widget == QCocoaWidget(QCocoaCheckBox, QAquaSizeSmall))
+ offset.setX(-1);
+ else if (widget == QCocoaWidget(QCocoaCheckBox, QAquaSizeMini))
+ offset = QPoint(7, 5);
+ else if (widget == QCocoaWidget(QCocoaPopupButton, QAquaSizeMini))
+ offset = QPoint(2, -1);
+ else if (widget == QCocoaWidget(QCocoaPullDownButton, QAquaSizeLarge))
+ offset = isQWidget ? QPoint(3, -1) : QPoint(-1, -3);
+ else if (widget == QCocoaWidget(QCocoaPullDownButton, QAquaSizeSmall))
+ offset = QPoint(2, 1);
+ else if (widget == QCocoaWidget(QCocoaPullDownButton, QAquaSizeMini))
+ offset = QPoint(5, 0);
+ else if (widget == QCocoaWidget(QCocoaComboBox, QAquaSizeLarge))
+ offset = QPoint(3, 0);
+
QMacCGContext ctx(p);
CGContextSaveGState(ctx);
+ CGContextTranslateCTM(ctx, offset.x(), offset.y());
[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext:[NSGraphicsContext
@@ -2046,8 +2039,8 @@ void QMacStylePrivate::drawColorlessButton(const HIRect &macRect, HIThemeButtonD
}
pm = QPixmap::fromImage(image);
} else if ((usingYosemiteOrLater && combo && !editableCombo) || button) {
- QPoint offset;
- NSButton *bc = (NSButton *)cocoaControl(cocoaWidgetFromHIThemeButtonKind(bdi->kind), &offset);
+ QCocoaWidget cw = cocoaWidgetFromHIThemeButtonKind(bdi->kind);
+ NSButton *bc = (NSButton *)cocoaControl(cw);
[bc highlight:pressed];
bc.enabled = bdi->state != kThemeStateUnavailable && bdi->state != kThemeStateUnavailableInactive;
bc.allowsMixedState = YES;
@@ -2057,9 +2050,7 @@ void QMacStylePrivate::drawColorlessButton(const HIRect &macRect, HIThemeButtonD
QRect rect = opt->rect;
if (bdi->kind == kThemePopupButtonMini)
rect.adjust(0, 0, -5, 0);
- p->translate(offset);
- drawNSViewInRect(bc, rect, p);
- p->translate(-offset);
+ drawNSViewInRect(cw, bc, rect, p);
return;
} else if (usingYosemiteOrLater && editableCombo) {
QImage image = activePixmap.toImage();
@@ -2131,34 +2122,26 @@ QMacStyle::QMacStyle()
: QCommonStyle(*new QMacStylePrivate)
{
Q_D(QMacStyle);
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
- d->receiver = [[NotificationReceiver alloc] initWithPrivate:d];
- NotificationReceiver *receiver = static_cast<NotificationReceiver *>(d->receiver);
+ d->receiver = [[NotificationReceiver alloc] initWithPrivate:d];
+ NotificationReceiver *receiver = static_cast<NotificationReceiver *>(d->receiver);
- [[NSNotificationCenter defaultCenter] addObserver:receiver
- selector:@selector(scrollBarStyleDidChange:)
- name:NSPreferredScrollerStyleDidChangeNotification
- object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:receiver
+ selector:@selector(scrollBarStyleDidChange:)
+ name:NSPreferredScrollerStyleDidChangeNotification
+ object:nil];
- d->nsscroller = [[NSScroller alloc] init];
- }
-#endif
+ d->nsscroller = [[NSScroller alloc] init];
d->indicatorBranchButtonCell = nil;
}
QMacStyle::~QMacStyle()
{
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
Q_D(QMacStyle);
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
- [reinterpret_cast<NSScroller*>(d->nsscroller) release];
+ [reinterpret_cast<NSScroller*>(d->nsscroller) release];
- NotificationReceiver *receiver = static_cast<NotificationReceiver *>(d->receiver);
- [[NSNotificationCenter defaultCenter] removeObserver:receiver];
- [receiver release];
- }
-#endif
+ NotificationReceiver *receiver = static_cast<NotificationReceiver *>(d->receiver);
+ [[NSNotificationCenter defaultCenter] removeObserver:receiver];
+ [receiver release];
delete qt_mac_backgroundPattern;
qt_mac_backgroundPattern = 0;
@@ -2256,7 +2239,7 @@ void QMacStyle::polish(QWidget* w)
}
if (qobject_cast<QMenu*>(w) || qobject_cast<QComboBoxPrivateContainer *>(w)) {
- w->setWindowOpacity(QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5 ? 0.985 : 0.94);
+ w->setWindowOpacity(0.985);
if (!w->testAttribute(Qt::WA_SetPalette)) {
QPixmap px(64, 64);
px.fill(Qt::white);
@@ -2541,9 +2524,7 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW
}
break;
case PM_ScrollBarExtent: {
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7 &&
- [NSScroller preferredScrollerStyle] == NSScrollerStyleOverlay) {
+ if ([NSScroller preferredScrollerStyle] == NSScrollerStyleOverlay) {
switch (d->aquaSizeConstrain(opt, widget)) {
case QAquaSizeUnknown:
case QAquaSizeLarge:
@@ -2556,7 +2537,6 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW
}
break;
}
-#endif
switch (d->aquaSizeConstrain(opt, widget)) {
case QAquaSizeUnknown:
case QAquaSizeLarge:
@@ -2747,13 +2727,8 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW
ret = 1;
break;
case PM_ScrollView_ScrollBarOverlap:
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- ret = (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7 &&
- [NSScroller preferredScrollerStyle] == NSScrollerStyleOverlay) ?
+ ret = [NSScroller preferredScrollerStyle] == NSScrollerStyleOverlay ?
pixelMetric(PM_ScrollBarExtent, opt, widget) : 0;
-#else
- ret = 0;
-#endif
break;
default:
ret = QCommonStyle::pixelMetric(metric, opt, widget);
@@ -3083,11 +3058,7 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w
|| (opt && QStyleHelper::hasAncestor(opt->styleObject, QAccessible::ScrollBar))
#endif
) {
- ret = QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- if (ret)
- ret = [NSScroller preferredScrollerStyle] == NSScrollerStyleOverlay;
-#endif
+ ret = [NSScroller preferredScrollerStyle] == NSScrollerStyleOverlay;
}
break;
default:
@@ -3795,9 +3766,8 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
alignment |= Qt::TextHideMnemonic;
if (down)
cr.translate(shiftX, shiftY);
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5
- && (tbstyle == Qt::ToolButtonTextOnly
- || (tbstyle != Qt::ToolButtonTextOnly && !down))) {
+ if (tbstyle == Qt::ToolButtonTextOnly
+ || (tbstyle != Qt::ToolButtonTextOnly && !down)) {
QPen pen = p->pen();
QColor light = down ? Qt::black : Qt::white;
light.setAlphaF(0.375f);
@@ -3812,12 +3782,6 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
}
proxy()->drawItemText(p, cr, alignment, pal,
tb->state & State_Enabled, tb->text, role);
- if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_5 &&
- (tb->state & State_Sunken)) {
- // Draw a "drop shadow" in earlier versions.
- proxy()->drawItemText(p, cr.adjusted(0, 1, 0, 1), alignment,
- tb->palette, tb->state & State_Enabled, tb->text);
- }
}
} else {
QCommonStyle::drawControl(ce, &myTb, p, w);
@@ -3938,17 +3902,15 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
}
if (hasMenu && yosemiteOrLater && bdi.kind != kThemeBevelButton) {
- QCocoaWidget w = cocoaWidgetFromHIThemeButtonKind(bdi.kind);
- QPoint offset;
- NSPopUpButton *pdb = (NSPopUpButton *)d->cocoaControl(QCocoaWidget(QCocoaPullDownButton, w.second), &offset);
+ QCocoaWidget cw = cocoaWidgetFromHIThemeButtonKind(bdi.kind);
+ cw.first = QCocoaPullDownButton;
+ NSPopUpButton *pdb = (NSPopUpButton *)d->cocoaControl(cw);
[pdb highlight:(bdi.state == kThemeStatePressed)];
pdb.enabled = bdi.state != kThemeStateUnavailable && bdi.state != kThemeStateUnavailableInactive;
QRect rect = opt->rect;
- rect.adjust(0, 0, w.second == QAquaSizeSmall ? -4 : w.second == QAquaSizeMini ? -9 : -6, 0);
- p->translate(offset);
- d->drawNSViewInRect(pdb, rect, p);
- p->translate(-offset);
- } else if (hasMenu && bdi.state == kThemeStatePressed && QSysInfo::macVersion() > QSysInfo::MV_10_6)
+ rect.adjust(0, 0, cw.second == QAquaSizeSmall ? -4 : cw.second == QAquaSizeMini ? -9 : -6, 0);
+ d->drawNSViewInRect(cw, pdb, rect, p, w != 0);
+ } else if (hasMenu && bdi.state == kThemeStatePressed)
d->drawColorlessButton(newRect, &bdi, p, opt);
else
HIThemeDrawButton(&newRect, &bdi, cg, kHIThemeOrientationNormal, 0);
@@ -3987,16 +3949,10 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
if (hasMenu && (!yosemiteOrLater || bdi.kind == kThemeBevelButton)) {
int mbi = proxy()->pixelMetric(QStyle::PM_MenuButtonIndicator, btn, w);
QRect ir = btn->rect;
- int arrowXOffset = 0;
- if (QSysInfo::macVersion() > QSysInfo::MV_10_6)
- arrowXOffset = bdi.kind == kThemePushButton ? 6 :
+ int arrowXOffset = bdi.kind == kThemePushButton ? 6 :
bdi.kind == kThemePushButtonSmall ? 7 : 8;
- int arrowYOffset;
- if (QSysInfo::macVersion() > QSysInfo::MV_10_6)
- arrowYOffset = bdi.kind == kThemePushButton ? 3 :
+ int arrowYOffset = bdi.kind == kThemePushButton ? 3 :
bdi.kind == kThemePushButtonSmall ? 1 : 2;
- else
- arrowYOffset = bdi.kind == kThemePushButton ? 4 : 2;
if (!w) {
// adjustment for Qt Quick Controls
arrowYOffset -= ir.top();
@@ -4012,17 +3968,10 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
pdi.version = qt_mac_hitheme_version;
pdi.state = tds == kThemeStateInactive ? kThemeStateActive : tds;
pdi.orientation = kThemeArrowDown;
- if (QSysInfo::macVersion() > QSysInfo::MV_10_6) {
- if (bdi.kind == kThemePushButtonMini)
- pdi.size = kThemeArrow5pt;
- else if (bdi.kind == kThemePushButton || bdi.kind == kThemePushButtonSmall)
- pdi.size = kThemeArrow7pt;
- } else {
- if (arrowRect.size.width < 8.)
- pdi.size = kThemeArrow5pt;
- else
- pdi.size = kThemeArrow9pt;
- }
+ if (bdi.kind == kThemePushButtonMini)
+ pdi.size = kThemeArrow5pt;
+ else if (bdi.kind == kThemePushButton || bdi.kind == kThemePushButtonSmall)
+ pdi.size = kThemeArrow7pt;
HIThemeDrawPopupArrow(&arrowRect, &pdi, cg, kHIThemeOrientationNormal);
}
}
@@ -4101,10 +4050,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
QRect textRect = itemTextRect(
btn.fontMetrics, freeContentRect, Qt::AlignCenter, btn.state & State_Enabled, btn.text);
if (hasMenu) {
- if (QSysInfo::macVersion() > QSysInfo::MV_10_6)
- textRect.moveTo(w ? 15 : 11, textRect.top()); // Supports Qt Quick Controls
- else
- textRect.adjust(-1, 0, -1, 0);
+ textRect.moveTo(w ? 15 : 11, textRect.top()); // Supports Qt Quick Controls
}
// Draw the icon:
if (hasIcon) {
@@ -4145,9 +4091,10 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
QStyleOptionComboBox comboCopy = *cb;
comboCopy.direction = Qt::LeftToRight;
- if ((opt->state & QStyle::State_Small) && QSysInfo::macVersion() > QSysInfo::MV_10_6)
- comboCopy.rect.translate(0, w ? (QSysInfo::macVersion() > QSysInfo::MV_10_8 ? 0 : -1) : -2); // Supports Qt Quick Controls
- else if (QSysInfo::macVersion() > QSysInfo::MV_10_8)
+ if (opt->state & QStyle::State_Small)
+ comboCopy.rect.translate(0, w ? (QSysInfo::macVersion() > QSysInfo::MV_10_8 ? 0 : -1) :
+ (QSysInfo::macVersion() > QSysInfo::MV_10_9 ? 0 : -2)); // Supports Qt Quick Controls
+ else if (QSysInfo::macVersion() == QSysInfo::MV_10_9)
comboCopy.rect.translate(0, 1);
QCommonStyle::drawControl(CE_ComboBoxLabel, &comboCopy, p, w);
}
@@ -4284,10 +4231,9 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
ThemeTabDirection ttd = getTabDirection(myTab.shape);
bool verticalTabs = ttd == kThemeTabWest || ttd == kThemeTabEast;
bool selected = (myTab.state & QStyle::State_Selected);
- bool usingLionOrLater = QSysInfo::MacintoshVersion > QSysInfo::MV_10_6;
bool usingYosemiteOrLater = QSysInfo::MacintoshVersion > QSysInfo::MV_10_9;
- if (usingLionOrLater && selected && !myTab.documentMode
+ if (selected && !myTab.documentMode
&& (!usingYosemiteOrLater || myTab.state & State_Active))
myTab.palette.setColor(QPalette::WindowText, Qt::white);
@@ -4296,7 +4242,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
// outside world, unless they read the source, in which case, it's
// their own fault).
bool nonDefaultFont = p->font() != qt_app_fonts_hash()->value("QComboMenuItem");
- bool isSelectedAndNeedsShadow = selected && usingLionOrLater && !usingYosemiteOrLater;
+ bool isSelectedAndNeedsShadow = selected && !usingYosemiteOrLater;
if (isSelectedAndNeedsShadow || verticalTabs || nonDefaultFont || !tab->icon.isNull()
|| !myTab.leftButtonSize.isEmpty() || !myTab.rightButtonSize.isEmpty()) {
int heightOffset = 0;
@@ -4768,14 +4714,6 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
case CE_ProgressBarGroove:
break;
case CE_SizeGrip: {
- // We do not draw size grips on versions > 10.6 unless it's a QMdiSubWindow
- if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_6
-#ifndef QT_NO_MDIAREA
- && !(w && w->parentWidget() && qobject_cast<QMdiSubWindow *>(w->parentWidget()))
-#endif
- )
- break;
-
if (w && w->testAttribute(Qt::WA_MacOpaqueSizeGrip)) {
HIThemeGrowBoxDrawInfo gdi;
gdi.version = qt_mac_hitheme_version;
@@ -5444,7 +5382,6 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
const bool usingYosemiteOrLater = QSysInfo::MacintoshVersion > QSysInfo::MV_10_9;
const bool isHorizontal = slider->orientation == Qt::Horizontal;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
if (cc == CC_ScrollBar && proxy()->styleHint(SH_ScrollBar_Transient, opt, widget)) {
bool wasActive = false;
CGFloat opacity = 0.0;
@@ -5607,9 +5544,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
[NSGraphicsContext restoreGraphicsState];
CGContextRestoreGState(cg);
- } else
-#endif
- {
+ } else {
d->stopAnimation(opt->styleObject);
if (usingYosemiteOrLater && cc == CC_Slider) {
@@ -5641,12 +5576,13 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
// Yosemite demands its blue progress track when no tickmarks are present
if (!(slider->subControls & SC_SliderTickmarks)) {
QCocoaWidgetKind sliderKind = slider->orientation == Qt::Horizontal ? QCocoaHorizontalSlider : QCocoaVerticalSlider;
- NSSlider *sl = (NSSlider *)d->cocoaControl(QCocoaWidget(sliderKind, QAquaSizeLarge), 0);
+ QCocoaWidget cw = QCocoaWidget(sliderKind, QAquaSizeLarge);
+ NSSlider *sl = (NSSlider *)d->cocoaControl(cw);
sl.minValue = slider->minimum;
sl.maxValue = slider->maximum;
sl.intValue = slider->sliderValue;
sl.enabled = slider->state & QStyle::State_Enabled;
- d->drawNSViewInRect(sl, opt->rect, p, ^(NSRect rect, CGContextRef ctx) {
+ d->drawNSViewInRect(cw, sl, opt->rect, p, widget != 0, ^(NSRect rect, CGContextRef ctx) {
if (slider->upsideDown) {
if (isHorizontal) {
CGContextTranslateCTM(ctx, rect.size.width, 0);
@@ -5819,12 +5755,21 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
break;
case CC_ComboBox:
if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox *>(opt)){
+ const bool usingYosemiteOrLater = QSysInfo::MacintoshVersion > QSysInfo::MV_10_9;
HIThemeButtonDrawInfo bdi;
- d->initComboboxBdi(combo, &bdi, widget, d->getDrawState(opt->state));
+ d->initComboboxBdi(combo, &bdi, widget, tds);
+ HIRect rect = qt_hirectForQRect(combo->rect);
+ if (combo->editable && usingYosemiteOrLater)
+ rect.origin.y += tds == kThemeStateInactive ? 1 : 2;
if (tds != kThemeStateInactive)
- QMacStylePrivate::drawCombobox(qt_hirectForQRect(combo->rect), bdi, p);
- else
- d->drawColorlessButton(qt_hirectForQRect(combo->rect), &bdi, p, opt);
+ QMacStylePrivate::drawCombobox(rect, bdi, p);
+ else if (!widget && combo->editable && usingYosemiteOrLater) {
+ QCocoaWidget cw = cocoaWidgetFromHIThemeButtonKind(bdi.kind);
+ NSView *cb = d->cocoaControl(cw);
+ QRect r = combo->rect.adjusted(3, 0, 0, 0);
+ d->drawNSViewInRect(cw, cb, r, p, widget != 0);
+ } else
+ d->drawColorlessButton(rect, &bdi, p, opt);
}
break;
case CC_TitleBar:
@@ -5880,11 +5825,6 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
uint sc = SC_TitleBarMinButton;
ThemeTitleBarWidget tbw = kThemeWidgetCollapseBox;
bool active = titlebar->state & State_Active;
- if (QSysInfo::macVersion() < QSysInfo::MV_10_6) {
- int border = 2;
- titleBarRect.origin.x += border;
- titleBarRect.origin.y -= border;
- }
while (sc <= SC_TitleBarCloseButton) {
if (sc & titlebar->subControls) {
@@ -6023,23 +5963,12 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
path.addRoundedRect(QRectF(tb->rect.x(), tb->rect.y(), tb->rect.width(), tb->rect.height() + 4), 4, 4);
p->setRenderHint(QPainter::Antialiasing);
p->fillPath(path, brush);
- } else if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
+ } else {
static QPixmap pm(QLatin1String(":/qt-project.org/mac/style/images/leopard-unified-toolbar-on.png"));
p->save();
p->setRenderHint(QPainter::SmoothPixmapTransform);
QStyleHelper::drawBorderPixmap(pm, p, tb->rect, 2, 2, 2, 2);
p->restore();
- } else {
- QPen oldPen = p->pen();
- p->setPen(QColor(0, 0, 0, 0x3a));
- p->fillRect(tb->rect.adjusted(1, 1, -1, -1), QColor(0, 0, 0, 0x12));
- p->drawLine(tb->rect.left() + 1, tb->rect.top(),
- tb->rect.right() - 1, tb->rect.top());
- p->drawLine(tb->rect.left() + 1, tb->rect.bottom(),
- tb->rect.right() - 1, tb->rect.bottom());
- p->drawLine(tb->rect.topLeft(), tb->rect.bottomLeft());
- p->drawLine(tb->rect.topRight(), tb->rect.bottomRight());
- p->setPen(oldPen);
}
}
proxy()->drawControl(CE_ToolButtonLabel, opt, p, widget);
@@ -6192,10 +6121,7 @@ QStyle::SubControl QMacStyle::hitTestComplexControl(ComplexControl cc,
HIRect macSBRect = qt_hirectForQRect(sb->rect);
ControlPartCode part;
bool reverseHorizontal = (sb->direction == Qt::RightToLeft
- && sb->orientation == Qt::Horizontal
- && (!sb->upsideDown ||
- (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4
- && sb->upsideDown)));
+ && sb->orientation == Qt::Horizontal);
if (HIThemeHitTestScrollBarArrows(&macSBRect, &sbi, sb->orientation == Qt::Horizontal,
&pos, 0, &part)) {
if (part == kControlUpButtonPart)
@@ -6381,6 +6307,8 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op
switch (sc) {
case SC_ComboBoxEditField:{
ret = QMacStylePrivate::comboboxEditBounds(combo->rect, bdi);
+ if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_9)
+ ret.setHeight(ret.height() - 1);
break; }
case SC_ComboBoxArrow:{
ret = QMacStylePrivate::comboboxEditBounds(combo->rect, bdi);
@@ -6822,10 +6750,13 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
sz.rwidth() += 10;
sz.rheight() += 10;
return sz;
- case CT_ComboBox:
+ case CT_ComboBox: {
sz.rwidth() += 50;
- sz.rheight() += 2;
+ const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt);
+ if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_10 || (cb && !cb->editable))
+ sz.rheight() += 2;
break;
+ }
case CT_Menu: {
QStyleHintReturnMask menuMask;
QStyleOption myOption = *opt;
diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h
index 080f944ef8..89a95713b7 100644
--- a/src/widgets/styles/qmacstyle_mac_p_p.h
+++ b/src/widgets/styles/qmacstyle_mac_p_p.h
@@ -204,9 +204,9 @@ public:
void setAutoDefaultButton(QObject *button) const;
- NSView *cocoaControl(QCocoaWidget widget, QPoint *offset) const;
+ NSView *cocoaControl(QCocoaWidget widget) const;
- void drawNSViewInRect(NSView *view, const QRect &rect, QPainter *p, QCocoaDrawRectBlock drawRectBlock = nil) const;
+ void drawNSViewInRect(QCocoaWidget widget, NSView *view, const QRect &rect, QPainter *p, bool isQWidget = true, QCocoaDrawRectBlock drawRectBlock = nil) const;
void resolveCurrentNSView(QWindow *window);
public:
@@ -222,10 +222,8 @@ public:
mutable QPointer<QFocusFrame> focusWidget;
CFAbsoluteTime defaultButtonStart;
bool mouseDown;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
void* receiver;
void *nsscroller;
-#endif
void *indicatorBranchButtonCell;
NSView *backingStoreNSView;
QHash<QCocoaWidget, NSView *> cocoaControls;
diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp
index 7c4d239894..109a0ea451 100644
--- a/src/widgets/styles/qstyle.cpp
+++ b/src/widgets/styles/qstyle.cpp
@@ -1772,8 +1772,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
\value SH_ComboBox_Popup Allows popups as a combobox drop-down
menu.
- \omitvalue SH_ComboBox_UseNativePopup Whether we should use a native popup.
- Only supported for non-editable combo boxes on Mac OS X so far.
+ \omitvalue SH_ComboBox_UseNativePopup
\value SH_Workspace_FillSpaceOnMaximize The workspace should
maximize the client area.
diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h
index 12ada3f6e4..fa15a0d4c4 100644
--- a/src/widgets/styles/qstyle.h
+++ b/src/widgets/styles/qstyle.h
@@ -698,6 +698,8 @@ public:
SH_ToolTip_FallAsleepDelay,
SH_Widget_Animate,
SH_Splitter_OpaqueResize,
+ // Whether we should use a native popup.
+ // Only supported for non-editable combo boxes on Mac OS X so far.
SH_ComboBox_UseNativePopup,
SH_LineEdit_PasswordMaskDelay,
SH_TabBar_ChangeCurrentDelay,
diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp
index 3619c3ff29..9deeb725f9 100644
--- a/src/widgets/styles/qwindowsstyle.cpp
+++ b/src/widgets/styles/qwindowsstyle.cpp
@@ -1832,6 +1832,20 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
}
return;
#endif // QT_NO_DOCKWIDGET
+#ifndef QT_NO_COMBOBOX
+ case CE_ComboBoxLabel:
+ if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
+ if (cb->state & State_HasFocus) {
+ p->setPen(cb->palette.highlightedText().color());
+ p->setBackground(cb->palette.highlight());
+ } else {
+ p->setPen(cb->palette.text().color());
+ p->setBackground(cb->palette.background());
+ }
+ }
+ QCommonStyle::drawControl(ce, opt, p, widget);
+ break;
+#endif // QT_NO_COMBOBOX
default:
QCommonStyle::drawControl(ce, opt, p, widget);
}
diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp
index 007952192a..463b120e04 100644
--- a/src/widgets/styles/qwindowsvistastyle.cpp
+++ b/src/widgets/styles/qwindowsvistastyle.cpp
@@ -1473,7 +1473,11 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
break;
}
#endif // QT_NO_ITEMVIEWS
-
+#ifndef QT_NO_COMBOBOX
+ case CE_ComboBoxLabel:
+ QCommonStyle::drawControl(element, option, painter, widget);
+ break;
+#endif // QT_NO_COMBOBOX
default:
QWindowsXPStyle::drawControl(element, option, painter, widget);
break;
diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp
index c18bbb3431..c1f7b599b3 100644
--- a/src/widgets/styles/qwindowsxpstyle.cpp
+++ b/src/widgets/styles/qwindowsxpstyle.cpp
@@ -963,7 +963,8 @@ void QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa
QImage img;
if (!haveCachedPixmap) { // If the pixmap is not cached, generate it! -------------------------
- buffer(w, h); // Ensure a buffer of at least (w, h) in size
+ if (!buffer(w, h)) // Ensure a buffer of at least (w, h) in size
+ return;
HDC dc = bufferHDC();
// Clear the buffer
@@ -2539,7 +2540,7 @@ QRect QWindowsXPStylePrivate::scrollBarGripperBounds(QStyle::State flags, const
const int hSpace = theme->rect.width() - size.width();
const int vSpace = theme->rect.height() - size.height();
- const bool sufficientSpace = horizontal && hSpace > (contentsMargin.left() + contentsMargin.right())
+ const bool sufficientSpace = (horizontal && hSpace > (contentsMargin.left() + contentsMargin.right()))
|| vSpace > contentsMargin.top() + contentsMargin.bottom();
return sufficientSpace ? QRect(theme->rect.topLeft() + QPoint(hSpace, vSpace) / 2, size) : QRect();
}
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index 815afe85f2..3db7781acc 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -1520,13 +1520,16 @@ void QLineEdit::mouseMoveEvent(QMouseEvent * e)
#else
const bool select = (d->imHints & Qt::ImhNoPredictiveText);
#endif
+#ifndef QT_NO_IM
if (d->control->composeMode() && select) {
int startPos = d->xToPos(d->mousePressPos.x());
int currentPos = d->xToPos(e->pos().x());
if (startPos != currentPos)
d->control->setSelection(startPos, currentPos - startPos);
- } else {
+ } else
+#endif
+ {
d->control->moveCursor(d->xToPos(e->pos().x()), select);
}
}
@@ -1577,6 +1580,7 @@ void QLineEdit::mouseDoubleClickEvent(QMouseEvent* e)
int position = d->xToPos(e->pos().x());
// exit composition mode
+#ifndef QT_NO_IM
if (d->control->composeMode()) {
int preeditPos = d->control->cursor();
int posInPreedit = position - d->control->cursor();
@@ -1601,6 +1605,7 @@ void QLineEdit::mouseDoubleClickEvent(QMouseEvent* e)
position += (sizeChange - preeditLength);
}
}
+#endif
if (position >= 0)
d->control->selectWordAtPos(position);
diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp
index 0731c89094..f1126322d8 100644
--- a/src/widgets/widgets/qlineedit_p.cpp
+++ b/src/widgets/widgets/qlineedit_p.cpp
@@ -47,8 +47,8 @@
#ifndef QT_NO_IM
#include "qinputmethod.h"
#include "qlist.h"
-#include <qpropertyanimation.h>
#endif
+#include <qpropertyanimation.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index f9376a78d5..ddecea81bf 100644
--- a/src/widgets/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
@@ -1500,6 +1500,13 @@ bool QMainWindow::event(QEvent *event)
/*!
\property QMainWindow::unifiedTitleAndToolBarOnMac
\brief whether the window uses the unified title and toolbar look on Mac OS X
+
+ Note that the Qt 5 implementation has several limitations compared to Qt 4:
+ \list
+ \li Use in windows with OpenGL content is not supported. This includes QGLWidget and QOpenGLWidget.
+ \li Using dockable or movable toolbars may result in painting errors and is not recommended
+ \endlist
+
\since 5.2
*/
void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set)
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp
index 43f168ecd8..8f8642a72a 100644
--- a/src/widgets/widgets/qmainwindowlayout.cpp
+++ b/src/widgets/widgets/qmainwindowlayout.cpp
@@ -68,7 +68,7 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_DOCKWIDGET
+#ifdef QT_NO_DOCKWIDGET
extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);
#endif
@@ -615,11 +615,8 @@ static QList<T> findChildrenHelper(const QObject *o)
}
//pre4.3 tests the format that was used before 4.3
-bool QMainWindowLayoutState::checkFormat(QDataStream &stream, bool pre43)
+bool QMainWindowLayoutState::checkFormat(QDataStream &stream)
{
-#ifdef QT_NO_TOOLBAR
- Q_UNUSED(pre43);
-#endif
while (!stream.atEnd()) {
uchar marker;
stream >> marker;
@@ -630,8 +627,7 @@ bool QMainWindowLayoutState::checkFormat(QDataStream &stream, bool pre43)
case QToolBarAreaLayout::ToolBarStateMarkerEx:
{
QList<QToolBar *> toolBars = findChildrenHelper<QToolBar*>(mainWindow);
- if (!toolBarAreaLayout.restoreState(stream, toolBars, marker,
- pre43 /*testing 4.3 format*/, true /*testing*/)) {
+ if (!toolBarAreaLayout.restoreState(stream, toolBars, marker, true /*testing*/)) {
return false;
}
}
@@ -672,14 +668,8 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream,
}
QDataStream ds(copy);
- const bool oldFormat = !checkFormat(ds, false);
- if (oldFormat) {
- //we should try with the old format
- QDataStream ds2(copy);
- if (!checkFormat(ds2, true)) {
- return false; //format unknown
- }
- }
+ if (!checkFormat(ds))
+ return false;
QDataStream stream(copy);
@@ -719,7 +709,7 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream,
case QToolBarAreaLayout::ToolBarStateMarkerEx:
{
QList<QToolBar *> toolBars = findChildrenHelper<QToolBar*>(mainWindow);
- if (!toolBarAreaLayout.restoreState(stream, toolBars, marker, oldFormat))
+ if (!toolBarAreaLayout.restoreState(stream, toolBars, marker))
return false;
for (int i = 0; i < toolBars.size(); ++i) {
diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h
index abec34af14..d9e18b03f4 100644
--- a/src/widgets/widgets/qmainwindowlayout_p.h
+++ b/src/widgets/widgets/qmainwindowlayout_p.h
@@ -133,7 +133,7 @@ public:
QLayoutItem *unplug(const QList<int> &path, QMainWindowLayoutState *savedState = 0);
void saveState(QDataStream &stream) const;
- bool checkFormat(QDataStream &stream, bool pre43);
+ bool checkFormat(QDataStream &stream);
bool restoreState(QDataStream &stream, const QMainWindowLayoutState &oldState);
};
diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp
index 1e291f469e..3553baf68a 100644
--- a/src/widgets/widgets/qmdiarea.cpp
+++ b/src/widgets/widgets/qmdiarea.cpp
@@ -1511,7 +1511,7 @@ void QMdiAreaPrivate::highlightNextSubWindow(int increaseFactor)
#ifndef QT_NO_RUBBERBAND
if (!rubberBand) {
- rubberBand = new QRubberBand(QRubberBand::Rectangle, viewport);
+ rubberBand = new QRubberBand(QRubberBand::Rectangle, q);
// For accessibility to identify this special widget.
rubberBand->setObjectName(QLatin1String("qt_rubberband"));
rubberBand->setWindowFlags(rubberBand->windowFlags() | Qt::WindowStaysOnTopHint);
@@ -1528,6 +1528,20 @@ void QMdiAreaPrivate::highlightNextSubWindow(int increaseFactor)
Q_ASSERT(indexToHighlighted >= 0);
}
+void QMdiAreaPrivate::showRubberBandFor(QMdiSubWindow *subWindow)
+{
+ if (!subWindow || !rubberBand)
+ return;
+
+ if (viewMode == QMdiArea::TabbedView)
+ rubberBand->setGeometry(tabBar->tabRect(childWindows.indexOf(subWindow)));
+ else
+ rubberBand->setGeometry(subWindow->geometry());
+
+ rubberBand->raise();
+ rubberBand->show();
+}
+
/*!
\internal
\since 4.4
diff --git a/src/widgets/widgets/qmdiarea_p.h b/src/widgets/widgets/qmdiarea_p.h
index 1092fd9a30..ba531adaad 100644
--- a/src/widgets/widgets/qmdiarea_p.h
+++ b/src/widgets/widgets/qmdiarea_p.h
@@ -248,14 +248,7 @@ public:
}
#ifndef QT_NO_RUBBERBAND
- inline void showRubberBandFor(QMdiSubWindow *subWindow)
- {
- if (!subWindow || !rubberBand)
- return;
- rubberBand->setGeometry(subWindow->geometry());
- rubberBand->raise();
- rubberBand->show();
- }
+ void showRubberBandFor(QMdiSubWindow *subWindow);
inline void hideRubberBand()
{
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index a4c22de15b..2c27344a4a 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -3189,8 +3189,10 @@ void QMenu::actionEvent(QActionEvent *e)
delete menuItem;
} else if (e->type() == QEvent::ActionChanged) {
QPlatformMenuItem *menuItem = d->platformMenu->menuItemForTag(reinterpret_cast<quintptr>(e->action()));
- copyActionToPlatformItem(e->action(), menuItem);
- d->platformMenu->syncMenuItem(menuItem);
+ if (menuItem) {
+ copyActionToPlatformItem(e->action(), menuItem);
+ d->platformMenu->syncMenuItem(menuItem);
+ }
}
d->platformMenu->syncSeparatorsCollapsible(d->collapsibleSeparators);
diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp
index b6a21f183a..72a556db7c 100644
--- a/src/widgets/widgets/qplaintextedit.cpp
+++ b/src/widgets/widgets/qplaintextedit.cpp
@@ -2042,11 +2042,13 @@ void QPlainTextEdit::mouseMoveEvent(QMouseEvent *e)
d->sendControlEvent(e);
if (!(e->buttons() & Qt::LeftButton))
return;
- QRect visible = d->viewport->rect();
- if (visible.contains(pos))
- d->autoScrollTimer.stop();
- else if (!d->autoScrollTimer.isActive())
- d->autoScrollTimer.start(100, this);
+ if (e->source() == Qt::MouseEventNotSynthesized) {
+ const QRect visible = d->viewport->rect();
+ if (visible.contains(pos))
+ d->autoScrollTimer.stop();
+ else if (!d->autoScrollTimer.isActive())
+ d->autoScrollTimer.start(100, this);
+ }
}
/*! \reimp
@@ -2055,7 +2057,7 @@ void QPlainTextEdit::mouseReleaseEvent(QMouseEvent *e)
{
Q_D(QPlainTextEdit);
d->sendControlEvent(e);
- if (d->autoScrollTimer.isActive()) {
+ if (e->source() == Qt::MouseEventNotSynthesized && d->autoScrollTimer.isActive()) {
d->autoScrollTimer.stop();
d->ensureCursorVisible();
}
diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp
index 2d95009eb3..7ef864139f 100644
--- a/src/widgets/widgets/qtextedit.cpp
+++ b/src/widgets/widgets/qtextedit.cpp
@@ -1574,11 +1574,13 @@ void QTextEdit::mouseMoveEvent(QMouseEvent *e)
d->sendControlEvent(e);
if (!(e->buttons() & Qt::LeftButton))
return;
- QRect visible = d->viewport->rect();
- if (visible.contains(pos))
- d->autoScrollTimer.stop();
- else if (!d->autoScrollTimer.isActive())
- d->autoScrollTimer.start(100, this);
+ if (e->source() == Qt::MouseEventNotSynthesized) {
+ const QRect visible = d->viewport->rect();
+ if (visible.contains(pos))
+ d->autoScrollTimer.stop();
+ else if (!d->autoScrollTimer.isActive())
+ d->autoScrollTimer.start(100, this);
+ }
}
/*! \reimp
@@ -1587,7 +1589,7 @@ void QTextEdit::mouseReleaseEvent(QMouseEvent *e)
{
Q_D(QTextEdit);
d->sendControlEvent(e);
- if (d->autoScrollTimer.isActive()) {
+ if (e->source() == Qt::MouseEventNotSynthesized && d->autoScrollTimer.isActive()) {
d->autoScrollTimer.stop();
ensureCursorVisible();
}
diff --git a/src/widgets/widgets/qtoolbararealayout.cpp b/src/widgets/widgets/qtoolbararealayout.cpp
index 5494d49232..1dd39174ac 100644
--- a/src/widgets/widgets/qtoolbararealayout.cpp
+++ b/src/widgets/widgets/qtoolbararealayout.cpp
@@ -1286,21 +1286,15 @@ void QToolBarAreaLayout::saveState(QDataStream &stream) const
}
}
-static inline int getInt(QDataStream &stream, Qt::Orientation o, bool pre43)
+static inline int getInt(QDataStream &stream)
{
- if (pre43) {
- QPoint p;
- stream >> p;
- return pick(o, p);
- } else {
- int x;
- stream >> x;
- return x;
- }
+ int x;
+ stream >> x;
+ return x;
}
-bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*> &_toolBars, uchar tmarker, bool pre43, bool testing)
+bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*> &_toolBars, uchar tmarker, bool testing)
{
QList<QToolBar*> toolBars = _toolBars;
int lines;
@@ -1325,8 +1319,8 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
stream >> objectName;
uchar shown;
stream >> shown;
- item.pos = getInt(stream, dock.o, pre43);
- item.size = getInt(stream, dock.o, pre43);
+ item.pos = getInt(stream);
+ item.size = getInt(stream);
/*
4.3.0 added floating toolbars, but failed to add the ability to restore them.
@@ -1339,9 +1333,9 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
QRect rect;
bool floating = false;
uint geom0, geom1;
- geom0 = getInt(stream, dock.o, pre43);
+ geom0 = getInt(stream);
if (tmarker == ToolBarStateMarkerEx) {
- geom1 = getInt(stream, dock.o, pre43);
+ geom1 = getInt(stream);
rect = unpackRect(geom0, geom1, &floating);
}
diff --git a/src/widgets/widgets/qtoolbararealayout_p.h b/src/widgets/widgets/qtoolbararealayout_p.h
index 63a0924bcb..ad377876b4 100644
--- a/src/widgets/widgets/qtoolbararealayout_p.h
+++ b/src/widgets/widgets/qtoolbararealayout_p.h
@@ -230,7 +230,7 @@ public:
QLayoutItem *unplug(const QList<int> &path, QToolBarAreaLayout *other);
void saveState(QDataStream &stream) const;
- bool restoreState(QDataStream &stream, const QList<QToolBar*> &toolBars, uchar tmarker, bool pre43, bool testing = false);
+ bool restoreState(QDataStream &stream, const QList<QToolBar*> &toolBars, uchar tmarker, bool testing = false);
bool isEmpty() const;
};
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
index a82dd99591..e6385ba390 100644
--- a/src/widgets/widgets/qwidgetlinecontrol.cpp
+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
@@ -179,6 +179,7 @@ void QWidgetLineControl::paste(QClipboard::Mode clipboardMode)
*/
void QWidgetLineControl::commitPreedit()
{
+#ifndef QT_NO_IM
if (!composeMode())
return;
@@ -190,6 +191,7 @@ void QWidgetLineControl::commitPreedit()
setPreeditArea(-1, QString());
m_textLayout.clearAdditionalFormats();
updateDisplayText(/*force*/ true);
+#endif
}
diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h
index 328faf7926..f21d88177c 100644
--- a/src/widgets/widgets/qwidgetlinecontrol_p.h
+++ b/src/widgets/widgets/qwidgetlinecontrol_p.h
@@ -228,8 +228,10 @@ public:
}
void setText(const QString &txt)
{
+#ifndef QT_NO_IM
if (composeMode())
qApp->inputMethod()->reset();
+#endif
internalSetText(txt, -1, false);
}
void commitPreedit();
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index 954cae345f..93835156da 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -1582,8 +1582,10 @@ void QWidgetTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton butto
cursor.clearSelection();
}
}
+ // Do not start selection on a mouse event synthesized from a touch event.
if (!(button & Qt::LeftButton) ||
- !((interactionFlags & Qt::TextSelectableByMouse) || (interactionFlags & Qt::TextEditable))) {
+ !((interactionFlags & Qt::TextSelectableByMouse) || (interactionFlags & Qt::TextEditable))
+ || QApplicationPrivate::mouseEventSource(e) != Qt::MouseEventNotSynthesized) {
e->ignore();
return;
}
@@ -1754,6 +1756,11 @@ void QWidgetTextControlPrivate::mouseReleaseEvent(QEvent *e, Qt::MouseButton but
{
Q_Q(QWidgetTextControl);
+ if (QApplicationPrivate::mouseEventSource(e) != Qt::MouseEventNotSynthesized) {
+ setCursorPosition(pos); // Emulate Tap to set cursor for events synthesized from touch.
+ return;
+ }
+
const QTextCursor oldSelection = cursor;
if (sendMouseEventToInputContext(
e, QEvent::MouseButtonRelease, button, pos, modifiers, buttons, globalPos)) {