summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2016-04-04 08:59:11 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2016-04-04 08:59:18 +0200
commit216f57ef8682f74b72ae4e39cf1fd23abddf6a51 (patch)
tree9d1dc12e0944ec0252dac843fbadaf1dc4693888 /src/widgets/widgets
parent36bc2477753d19a14c587b97d4ec4f263e9e16c0 (diff)
parent8ce657d0279566ef327af1b88339534041ddc012 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r--src/widgets/widgets/qplaintextedit.cpp32
-rw-r--r--src/widgets/widgets/qprogressbar.cpp2
-rw-r--r--src/widgets/widgets/qtabbar.cpp27
-rw-r--r--src/widgets/widgets/qtabbar_p.h15
-rw-r--r--src/widgets/widgets/qtextedit.cpp30
5 files changed, 65 insertions, 41 deletions
diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp
index 3772a7866e..17eac9db58 100644
--- a/src/widgets/widgets/qplaintextedit.cpp
+++ b/src/widgets/widgets/qplaintextedit.cpp
@@ -2194,27 +2194,25 @@ QVariant QPlainTextEdit::inputMethodQuery(Qt::InputMethodQuery property) const
/*!\internal
*/
-QVariant QPlainTextEdit::inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const
+QVariant QPlainTextEdit::inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const
{
Q_D(const QPlainTextEdit);
- QVariant v;
- switch (property) {
- case Qt::ImHints:
- v = QWidget::inputMethodQuery(property);
- break;
+ if (query == Qt::ImHints)
+ return QWidget::inputMethodQuery(query);
+ const QVariant v = d->control->inputMethodQuery(query, argument);
+ const QPointF offset = contentOffset();
+ switch (v.type()) {
+ case QVariant::RectF:
+ return v.toRectF().translated(offset);
+ case QVariant::PointF:
+ return v.toPointF() + offset;
+ case QVariant::Rect:
+ return v.toRect().translated(offset.toPoint());
+ case QVariant::Point:
+ return v.toPoint() + offset.toPoint();
default:
- v = d->control->inputMethodQuery(property, argument);
- const QPoint offset(-d->horizontalOffset(), -0);
- if (v.type() == QVariant::RectF)
- v = v.toRectF().toRect().translated(offset);
- else if (v.type() == QVariant::PointF)
- v = v.toPointF().toPoint() + offset;
- else if (v.type() == QVariant::Rect)
- v = v.toRect().translated(offset);
- else if (v.type() == QVariant::Point)
- v = v.toPoint() + offset;
+ break;
}
-
return v;
}
diff --git a/src/widgets/widgets/qprogressbar.cpp b/src/widgets/widgets/qprogressbar.cpp
index 1ba0d78622..10f005e6d3 100644
--- a/src/widgets/widgets/qprogressbar.cpp
+++ b/src/widgets/widgets/qprogressbar.cpp
@@ -161,7 +161,7 @@ bool QProgressBarPrivate::repaintRequired() const
QStyleOptionProgressBar opt;
q->initStyleOption(&opt);
int cw = q->style()->pixelMetric(QStyle::PM_ProgressBarChunkWidth, &opt, q);
- QRect groove = q->style()->subElementRect(QStyle::SE_ProgressBarGroove, &opt, q);
+ QRect groove = q->style()->subElementRect(QStyle::SE_ProgressBarGroove, &opt, q);
// This expression is basically
// (valueDifference / (maximum - minimum) > cw / groove.width())
// transformed to avoid integer division.
diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp
index f56830c14b..6c748c09bb 100644
--- a/src/widgets/widgets/qtabbar.cpp
+++ b/src/widgets/widgets/qtabbar.cpp
@@ -70,6 +70,23 @@
QT_BEGIN_NAMESPACE
+QMovableTabWidget::QMovableTabWidget(QWidget *parent)
+ : QWidget(parent)
+{
+}
+
+void QMovableTabWidget::setPixmap(const QPixmap &pixmap)
+{
+ m_pixmap = pixmap;
+ update();
+}
+
+void QMovableTabWidget::paintEvent(QPaintEvent *e)
+{
+ Q_UNUSED(e);
+ QPainter p(this);
+ p.drawPixmap(0, 0, m_pixmap);
+}
inline static bool verticalTabs(QTabBar::Shape shape)
{
@@ -1992,13 +2009,14 @@ void QTabBarPrivate::setupMovableTab()
{
Q_Q(QTabBar);
if (!movingTab)
- movingTab = new QWidget(q);
+ movingTab = new QMovableTabWidget(q);
int taboverlap = q->style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0 ,q);
QRect grabRect = q->tabRect(pressedIndex);
grabRect.adjust(-taboverlap, 0, taboverlap, 0);
- QPixmap grabImage(grabRect.size());
+ QPixmap grabImage(grabRect.size() * q->devicePixelRatioF());
+ grabImage.setDevicePixelRatio(q->devicePixelRatioF());
grabImage.fill(Qt::transparent);
QStylePainter p(&grabImage, q);
p.initFrom(q);
@@ -2009,11 +2027,8 @@ void QTabBarPrivate::setupMovableTab()
p.drawControl(QStyle::CE_TabBarTab, tab);
p.end();
- QPalette pal;
- pal.setBrush(QPalette::All, QPalette::Window, grabImage);
- movingTab->setPalette(pal);
+ movingTab->setPixmap(grabImage);
movingTab->setGeometry(grabRect);
- movingTab->setAutoFillBackground(true);
movingTab->raise();
// Re-arrange widget order to avoid overlaps
diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h
index c5eb0d42d7..48f235f050 100644
--- a/src/widgets/widgets/qtabbar_p.h
+++ b/src/widgets/widgets/qtabbar_p.h
@@ -67,6 +67,19 @@
QT_BEGIN_NAMESPACE
+class QMovableTabWidget : public QWidget
+{
+public:
+ explicit QMovableTabWidget(QWidget *parent = Q_NULLPTR);
+ void setPixmap(const QPixmap &pixmap);
+
+protected:
+ void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
+
+private:
+ QPixmap m_pixmap;
+};
+
class QTabBarPrivate : public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QTabBar)
@@ -207,7 +220,7 @@ public:
int switchTabCurrentIndex;
int switchTabTimerId;
- QWidget *movingTab;
+ QMovableTabWidget *movingTab;
#ifdef Q_DEAD_CODE_FROM_QT4_MAC
int previousPressedIndex;
#endif
diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp
index 3f2e4728ed..1dd774cf7a 100644
--- a/src/widgets/widgets/qtextedit.cpp
+++ b/src/widgets/widgets/qtextedit.cpp
@@ -1727,24 +1727,22 @@ QVariant QTextEdit::inputMethodQuery(Qt::InputMethodQuery property) const
QVariant QTextEdit::inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const
{
Q_D(const QTextEdit);
- QVariant v;
- switch (query) {
- case Qt::ImHints:
- v = QWidget::inputMethodQuery(query);
- break;
+ if (query == Qt::ImHints)
+ return QWidget::inputMethodQuery(query);
+ const QVariant v = d->control->inputMethodQuery(query, argument);
+ const QPointF offset(-d->horizontalOffset(), -d->verticalOffset());
+ switch (v.type()) {
+ case QVariant::RectF:
+ return v.toRectF().translated(offset);
+ case QVariant::PointF:
+ return v.toPointF() + offset;
+ case QVariant::Rect:
+ return v.toRect().translated(offset.toPoint());
+ case QVariant::Point:
+ return v.toPoint() + offset.toPoint();
default:
- v = d->control->inputMethodQuery(query, argument);
- const QPoint offset(-d->horizontalOffset(), -d->verticalOffset());
- if (v.type() == QVariant::RectF)
- v = v.toRectF().toRect().translated(offset);
- else if (v.type() == QVariant::PointF)
- v = v.toPointF().toPoint() + offset;
- else if (v.type() == QVariant::Rect)
- v = v.toRect().translated(offset);
- else if (v.type() == QVariant::Point)
- v = v.toPoint() + offset;
+ break;
}
-
return v;
}