summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp11
-rw-r--r--src/widgets/graphicsview/qgraphicsitem_p.h2
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.cpp2
-rw-r--r--src/widgets/itemviews/qheaderview.cpp16
-rw-r--r--src/widgets/itemviews/qlistwidget.cpp8
-rw-r--r--src/widgets/kernel/qopenglwidget.cpp3
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp5
-rw-r--r--src/widgets/util/qsystemtrayicon_p.h4
-rw-r--r--src/widgets/util/qsystemtrayicon_x11.cpp75
-rw-r--r--src/widgets/widgets/qplaintextedit.cpp16
-rw-r--r--src/widgets/widgets/qtextedit.cpp23
11 files changed, 118 insertions, 47 deletions
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index 6e53ea94f3..713f022bdd 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -11343,7 +11343,7 @@ void QGraphicsItemEffectSourcePrivate::draw(QPainter *painter)
}
// sourceRect must be in the given coordinate system
-QRect QGraphicsItemEffectSourcePrivate::paddedEffectRect(Qt::CoordinateSystem system, QGraphicsEffect::PixmapPadMode mode, const QRectF &sourceRect, bool *unpadded) const
+QRectF QGraphicsItemEffectSourcePrivate::paddedEffectRect(Qt::CoordinateSystem system, QGraphicsEffect::PixmapPadMode mode, const QRectF &sourceRect, bool *unpadded) const
{
QRectF effectRectF;
@@ -11371,7 +11371,7 @@ QRect QGraphicsItemEffectSourcePrivate::paddedEffectRect(Qt::CoordinateSystem sy
*unpadded = true;
}
- return effectRectF.toAlignedRect();
+ return effectRectF;
}
QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset,
@@ -11389,7 +11389,8 @@ QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QP
bool unpadded;
const QRectF sourceRect = boundingRect(system);
- QRect effectRect = paddedEffectRect(system, mode, sourceRect, &unpadded);
+ QRectF effectRectF = paddedEffectRect(system, mode, sourceRect, &unpadded);
+ QRect effectRect = effectRectF.toAlignedRect();
if (offset)
*offset = effectRect.topLeft();
@@ -11405,7 +11406,9 @@ QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QP
if (effectRect.isEmpty())
return QPixmap();
- QPixmap pixmap(effectRect.size());
+ const auto dpr = info ? info->painter->device()->devicePixelRatioF() : 1.0;
+ QPixmap pixmap(QRectF(effectRectF.topLeft(), effectRectF.size() * dpr).toAlignedRect().size());
+ pixmap.setDevicePixelRatio(dpr);
pixmap.fill(Qt::transparent);
QPainter pixmapPainter(&pixmap);
pixmapPainter.setRenderHints(info ? info->painter->renderHints() : QPainter::TextAntialiasing);
diff --git a/src/widgets/graphicsview/qgraphicsitem_p.h b/src/widgets/graphicsview/qgraphicsitem_p.h
index a2c3774f65..92d85f7125 100644
--- a/src/widgets/graphicsview/qgraphicsitem_p.h
+++ b/src/widgets/graphicsview/qgraphicsitem_p.h
@@ -644,7 +644,7 @@ public:
QPixmap pixmap(Qt::CoordinateSystem system,
QPoint *offset,
QGraphicsEffect::PixmapPadMode mode) const override;
- QRect paddedEffectRect(Qt::CoordinateSystem system, QGraphicsEffect::PixmapPadMode mode, const QRectF &sourceRect, bool *unpadded = nullptr) const;
+ QRectF paddedEffectRect(Qt::CoordinateSystem system, QGraphicsEffect::PixmapPadMode mode, const QRectF &sourceRect, bool *unpadded = nullptr) const;
QGraphicsItem *item;
QGraphicsItemPaintInfo *info;
diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp
index 19d9f25307..3897823e98 100644
--- a/src/widgets/graphicsview/qgraphicsscene.cpp
+++ b/src/widgets/graphicsview/qgraphicsscene.cpp
@@ -4852,7 +4852,7 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
&& painter->worldTransform().type() <= QTransform::TxTranslate)
{
QRectF sourceRect = sourced->boundingRect(Qt::DeviceCoordinates);
- QRect effectRect = sourced->paddedEffectRect(Qt::DeviceCoordinates, sourced->currentCachedMode(), sourceRect);
+ QRect effectRect = sourced->paddedEffectRect(Qt::DeviceCoordinates, sourced->currentCachedMode(), sourceRect).toAlignedRect();
sourced->setCachedOffset(effectRect.topLeft());
} else {
diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp
index 62abf56751..99309633a7 100644
--- a/src/widgets/itemviews/qheaderview.cpp
+++ b/src/widgets/itemviews/qheaderview.cpp
@@ -2283,13 +2283,15 @@ void QHeaderViewPrivate::_q_sectionsChanged(const QList<QPersistentModelIndex> &
: index.row());
// the new visualIndices are already adjusted / reset by initializeSections()
const int newVisualIndex = visualIndex(newLogicalIndex);
- auto &newSection = sectionItems[newVisualIndex];
- newSection = item.section;
-
- if (newSection.isHidden) {
- // otherwise setSectionHidden will return without doing anything
- newSection.isHidden = false;
- q->setSectionHidden(newLogicalIndex, true);
+ if (newVisualIndex < sectionItems.count()) {
+ auto &newSection = sectionItems[newVisualIndex];
+ newSection = item.section;
+
+ if (newSection.isHidden) {
+ // otherwise setSectionHidden will return without doing anything
+ newSection.isHidden = false;
+ q->setSectionHidden(newLogicalIndex, true);
+ }
}
}
diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp
index a9899983c2..e46d25bef1 100644
--- a/src/widgets/itemviews/qlistwidget.cpp
+++ b/src/widgets/itemviews/qlistwidget.cpp
@@ -650,11 +650,13 @@ QListWidgetItem::QListWidgetItem(const QString &text, QListWidget *listview, int
|Qt::ItemIsEnabled
|Qt::ItemIsDragEnabled)
{
+ QListModel *model = listModel();
{
QSignalBlocker b(view);
+ QSignalBlocker bm(model);
setData(Qt::DisplayRole, text);
}
- if (QListModel *model = listModel())
+ if (model)
model->insert(model->rowCount(), this);
}
@@ -683,12 +685,14 @@ QListWidgetItem::QListWidgetItem(const QIcon &icon,const QString &text,
|Qt::ItemIsEnabled
|Qt::ItemIsDragEnabled)
{
+ QListModel *model = listModel();
{
QSignalBlocker b(view);
+ QSignalBlocker bm(model);
setData(Qt::DisplayRole, text);
setData(Qt::DecorationRole, icon);
}
- if (QListModel *model = listModel())
+ if (model)
model->insert(model->rowCount(), this);
}
diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp
index cf15614680..374ea53726 100644
--- a/src/widgets/kernel/qopenglwidget.cpp
+++ b/src/widgets/kernel/qopenglwidget.cpp
@@ -1448,7 +1448,8 @@ bool QOpenGLWidget::event(QEvent *e)
{
// Special case: did grabFramebuffer() for a hidden widget that then became visible.
// Recreate all resources since the context now needs to share with the TLW's.
- d->reset();
+ if (!qGuiApp->testAttribute(Qt::AA_ShareOpenGLContexts))
+ d->reset();
}
if (!d->initialized && !size().isEmpty() && window()->windowHandle()) {
d->initialize();
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 956c2be3a9..9c744000bd 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -2908,7 +2908,10 @@ void QStyleSheetStyle::polish(QPalette &pal)
void QStyleSheetStyle::repolish(QWidget *w)
{
- QList<const QObject *> children = w->findChildren<const QObject *>(QString());
+ QList<const QObject *> children;
+ children.reserve(w->children().size() + 1);
+ for (auto child: qAsConst(w->children()))
+ children.append(child);
children.append(w);
styleSheetCaches->styleSheetCache.remove(w);
updateObjects(children);
diff --git a/src/widgets/util/qsystemtrayicon_p.h b/src/widgets/util/qsystemtrayicon_p.h
index 5bdf020a47..e31532ea19 100644
--- a/src/widgets/util/qsystemtrayicon_p.h
+++ b/src/widgets/util/qsystemtrayicon_p.h
@@ -69,6 +69,7 @@
QT_BEGIN_NAMESPACE
class QSystemTrayIconSys;
+class QSystemTrayWatcher;
class QPlatformSystemTrayIcon;
class QToolButton;
class QLabel;
@@ -90,6 +91,8 @@ public:
void showMessage_sys(const QString &title, const QString &msg, const QIcon &icon,
QSystemTrayIcon::MessageIcon msgIcon, int msecs);
+ void destroyIcon();
+
static bool isSystemTrayAvailable_sys();
static bool supportsMessages_sys();
@@ -101,6 +104,7 @@ public:
QSystemTrayIconSys *sys;
QPlatformSystemTrayIcon *qpa_sys;
bool visible;
+ QSystemTrayWatcher *trayWatcher;
private:
void install_sys_qpa();
diff --git a/src/widgets/util/qsystemtrayicon_x11.cpp b/src/widgets/util/qsystemtrayicon_x11.cpp
index 86532456c7..70e5f3678e 100644
--- a/src/widgets/util/qsystemtrayicon_x11.cpp
+++ b/src/widgets/util/qsystemtrayicon_x11.cpp
@@ -92,9 +92,6 @@ protected:
virtual void resizeEvent(QResizeEvent *) override;
virtual void moveEvent(QMoveEvent *) override;
-private slots:
- void systemTrayWindowChanged(QScreen *screen);
-
private:
QSystemTrayIcon *q;
};
@@ -116,15 +113,6 @@ QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *qIn)
setMouseTracking(true);
}
-void QSystemTrayIconSys::systemTrayWindowChanged(QScreen *)
-{
- if (!locateSystemTray()) {
- QBalloonTip::hideBalloon();
- hide(); // still no luck
- destroy();
- }
-}
-
QRect QSystemTrayIconSys::globalGeometry() const
{
return QRect(mapToGlobal(QPoint(0, 0)), size());
@@ -199,10 +187,41 @@ void QSystemTrayIconSys::resizeEvent(QResizeEvent *event)
}
////////////////////////////////////////////////////////////////////////////
+class QSystemTrayWatcher: public QObject
+{
+ Q_OBJECT
+public:
+ QSystemTrayWatcher(QSystemTrayIcon *trayIcon)
+ : QObject(trayIcon)
+ , mTrayIcon(trayIcon)
+ {
+ // This code uses string-based syntax because we want to connect to a signal
+ // which is defined in XCB plugin - QXcbNativeInterface::systemTrayWindowChanged().
+ connect(qGuiApp->platformNativeInterface(), SIGNAL(systemTrayWindowChanged(QScreen*)),
+ this, SLOT(systemTrayWindowChanged(QScreen*)));
+ }
+
+private slots:
+ void systemTrayWindowChanged(QScreen *)
+ {
+ auto icon = static_cast<QSystemTrayIconPrivate *>(QObjectPrivate::get(mTrayIcon));
+ icon->destroyIcon();
+ if (icon->visible && locateSystemTray()) {
+ icon->sys = new QSystemTrayIconSys(mTrayIcon);
+ icon->sys->show();
+ }
+ }
+
+private:
+ QSystemTrayIcon *mTrayIcon = nullptr;
+};
+////////////////////////////////////////////////////////////////////////////
+
QSystemTrayIconPrivate::QSystemTrayIconPrivate()
: sys(0),
qpa_sys(QGuiApplicationPrivate::platformTheme()->createPlatformSystemTrayIcon()),
- visible(false)
+ visible(false),
+ trayWatcher(nullptr)
{
}
@@ -213,16 +232,21 @@ QSystemTrayIconPrivate::~QSystemTrayIconPrivate()
void QSystemTrayIconPrivate::install_sys()
{
+ Q_Q(QSystemTrayIcon);
+
if (qpa_sys) {
install_sys_qpa();
return;
}
- Q_Q(QSystemTrayIcon);
- if (!sys && locateSystemTray()) {
- sys = new QSystemTrayIconSys(q);
- QObject::connect(QGuiApplication::platformNativeInterface(), SIGNAL(systemTrayWindowChanged(QScreen*)),
- sys, SLOT(systemTrayWindowChanged(QScreen*)));
- sys->show();
+
+ if (!sys) {
+ if (!trayWatcher)
+ trayWatcher = new QSystemTrayWatcher(q);
+
+ if (locateSystemTray()) {
+ sys = new QSystemTrayIconSys(q);
+ sys->show();
+ }
}
}
@@ -241,14 +265,21 @@ void QSystemTrayIconPrivate::remove_sys()
remove_sys_qpa();
return;
}
+
+ destroyIcon();
+}
+
+void QSystemTrayIconPrivate::destroyIcon()
+{
if (!sys)
return;
QBalloonTip::hideBalloon();
- sys->hide(); // this should do the trick, but...
- delete sys; // wm may resize system tray only for DestroyEvents
- sys = 0;
+ sys->hide();
+ delete sys;
+ sys = nullptr;
}
+
void QSystemTrayIconPrivate::updateIcon_sys()
{
if (qpa_sys) {
diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp
index dc8765ad88..bc1ff78de0 100644
--- a/src/widgets/widgets/qplaintextedit.cpp
+++ b/src/widgets/widgets/qplaintextedit.cpp
@@ -1239,6 +1239,8 @@ void QPlainTextEditPrivate::ensureViewportLayouted()
This property gets and sets the plain text editor's contents. The previous
contents are removed and undo/redo history is reset when this property is set.
+ currentCharFormat() is also reset, unless textCursor() is already at the
+ beginning of the document.
By default, for an editor with no contents, this property contains an empty string.
*/
@@ -1518,7 +1520,12 @@ void QPlainTextEdit::paste()
/*!
Deletes all the text in the text edit.
- Note that the undo/redo history is cleared by this function.
+ Notes:
+ \list
+ \li The undo/redo history is also cleared.
+ \li currentCharFormat() is reset, unless textCursor()
+ is already at the beginning of the document.
+ \endlist
\sa cut(), setPlainText()
*/
@@ -1651,7 +1658,12 @@ void QPlainTextEdit::timerEvent(QTimerEvent *e)
\a text is interpreted as plain text.
- Note that the undo/redo history is cleared by this function.
+ Notes:
+ \list
+ \li The undo/redo history is also cleared.
+ \li currentCharFormat() is reset, unless textCursor()
+ is already at the beginning of the document.
+ \endlist
\sa toPlainText()
*/
diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp
index 4a06f58b4a..9e134493b5 100644
--- a/src/widgets/widgets/qtextedit.cpp
+++ b/src/widgets/widgets/qtextedit.cpp
@@ -556,7 +556,8 @@ void QTextEditPrivate::_q_ensureVisible(const QRectF &_rect)
This property gets and sets the text editor's contents as plain
text. Previous contents are removed and undo/redo history is reset
- when the property is set.
+ when the property is set. currentCharFormat() is also reset, unless
+ textCursor() is already at the beginning of the document.
If the text edit has another content type, it will not be replaced
by plain text if you call toPlainText(). The only exception to this
@@ -1034,7 +1035,12 @@ void QTextEdit::paste()
/*!
Deletes all the text in the text edit.
- Note that the undo/redo history is cleared by this function.
+ Notes:
+ \list
+ \li The undo/redo history is also cleared.
+ \li currentCharFormat() is reset, unless textCursor()
+ is already at the beginning of the document.
+ \endlist
\sa cut(), setPlainText(), setHtml()
*/
@@ -1139,9 +1145,13 @@ void QTextEdit::timerEvent(QTimerEvent *e)
Changes the text of the text edit to the string \a text.
Any previous text is removed.
- \a text is interpreted as plain text.
-
- Note that the undo/redo history is cleared by this function.
+ Notes:
+ \list
+ \li \a text is interpreted as plain text.
+ \li The undo/redo history is also cleared.
+ \li currentCharFormat() is reset, unless textCursor()
+ is already at the beginning of the document.
+ \endlist
\sa toPlainText()
*/
@@ -1175,7 +1185,8 @@ QString QTextEdit::toPlainText() const
setHtml() changes the text of the text edit. Any previous text is
removed and the undo/redo history is cleared. The input text is
- interpreted as rich text in html format.
+ interpreted as rich text in html format. currentCharFormat() is also
+ reset, unless textCursor() is already at the beginning of the document.
\note It is the responsibility of the caller to make sure that the
text is correctly decoded when a QString containing HTML is created