summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r--src/widgets/widgets/qdockarealayout.cpp6
-rw-r--r--src/widgets/widgets/qlineedit_p.cpp12
-rw-r--r--src/widgets/widgets/qplaintextedit_p.h3
-rw-r--r--src/widgets/widgets/qpushbutton.cpp13
-rw-r--r--src/widgets/widgets/qpushbutton_p.h4
-rw-r--r--src/widgets/widgets/qtextedit_p.h11
-rw-r--r--src/widgets/widgets/qtoolbox.cpp10
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp47
-rw-r--r--src/widgets/widgets/qwidgettextcontrol_p.h2
-rw-r--r--src/widgets/widgets/qwidgettextcontrol_p_p.h2
-rw-r--r--src/widgets/widgets/widgets.pri12
11 files changed, 101 insertions, 21 deletions
diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp
index fe1446660b..27ecc33dba 100644
--- a/src/widgets/widgets/qdockarealayout.cpp
+++ b/src/widgets/widgets/qdockarealayout.cpp
@@ -2082,15 +2082,15 @@ void QDockAreaLayoutInfo::reparentWidgets(QWidget *parent)
const QDockAreaLayoutItem &item = item_list.at(i);
if (item.flags & QDockAreaLayoutItem::GapItem)
continue;
- if (item.skip())
- continue;
if (item.subinfo)
item.subinfo->reparentWidgets(parent);
if (item.widgetItem) {
QWidget *w = item.widgetItem->widget();
+ if (qobject_cast<QDockWidgetGroupWindow *>(w))
+ continue;
if (w->parent() != parent) {
bool hidden = w->isHidden();
- w->setParent(parent);
+ w->setParent(parent, w->windowFlags());
if (!hidden)
w->show();
}
diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp
index 1d81d1fcb5..68be82c71d 100644
--- a/src/widgets/widgets/qlineedit_p.cpp
+++ b/src/widgets/widgets/qlineedit_p.cpp
@@ -534,7 +534,19 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE
#endif
}
// If there is a 'before' action, it takes preference
+
+ // There's a bug in GHS compiler that causes internal error on the following code.
+ // The affected GHS compiler versions are 2016.5.4 and 2017.1
+ // This temporary workaround allows to compile with GHS toolchain and should be
+ // removed when GHS provides a patch to fix the compiler issue.
+
+#if defined(Q_CC_GHS)
+ const SideWidgetLocation loc = {position, -1};
+ const auto location = before ? findSideWidget(before) : loc;
+#else
const auto location = before ? findSideWidget(before) : SideWidgetLocation{position, -1};
+#endif
+
SideWidgetEntryList &list = location.position == QLineEdit::TrailingPosition ? trailingSideWidgets : leadingSideWidgets;
list.insert(location.isValid() ? list.begin() + location.index : list.end(),
SideWidgetEntry(w, newAction, flags));
diff --git a/src/widgets/widgets/qplaintextedit_p.h b/src/widgets/widgets/qplaintextedit_p.h
index f0dd1c0ed4..803623c974 100644
--- a/src/widgets/widgets/qplaintextedit_p.h
+++ b/src/widgets/widgets/qplaintextedit_p.h
@@ -60,11 +60,12 @@
#include "QtWidgets/qmenu.h"
#include "QtGui/qabstracttextdocumentlayout.h"
#include "QtCore/qbasictimer.h"
-#include "private/qwidgettextcontrol_p.h"
#include "qplaintextedit.h"
#ifndef QT_NO_TEXTEDIT
+#include "private/qwidgettextcontrol_p.h"
+
QT_BEGIN_NAMESPACE
class QMimeData;
diff --git a/src/widgets/widgets/qpushbutton.cpp b/src/widgets/widgets/qpushbutton.cpp
index 1beea7edc5..a4318681c9 100644
--- a/src/widgets/widgets/qpushbutton.cpp
+++ b/src/widgets/widgets/qpushbutton.cpp
@@ -40,8 +40,9 @@
#include "qapplication.h"
#include "qbitmap.h"
#include "qdesktopwidget.h"
-#include "qdialog.h"
+#if QT_CONFIG(dialog)
#include <private/qdialog_p.h>
+#endif
#include "qdrawutil.h"
#include "qevent.h"
#include "qfontmetrics.h"
@@ -288,6 +289,7 @@ QPushButton::~QPushButton()
{
}
+#if QT_CONFIG(dialog)
QDialog *QPushButtonPrivate::dialogParent() const
{
Q_Q(const QPushButton);
@@ -299,6 +301,7 @@ QDialog *QPushButtonPrivate::dialogParent() const
}
return 0;
}
+#endif
/*!
Initialize \a option with the values from this QPushButton. This method is useful
@@ -362,10 +365,12 @@ void QPushButton::setDefault(bool enable)
if (d->defaultButton == enable)
return;
d->defaultButton = enable;
+#if QT_CONFIG(dialog)
if (d->defaultButton) {
if (QDialog *dlg = d->dialogParent())
dlg->d_func()->setMainDefault(this);
}
+#endif
update();
#ifndef QT_NO_ACCESSIBILITY
QAccessible::State s;
@@ -474,9 +479,11 @@ void QPushButton::focusInEvent(QFocusEvent *e)
Q_D(QPushButton);
if (e->reason() != Qt::PopupFocusReason && autoDefault() && !d->defaultButton) {
d->defaultButton = true;
+#if QT_CONFIG(dialog)
QDialog *dlg = qobject_cast<QDialog*>(window());
if (dlg)
dlg->d_func()->setDefault(this);
+#endif
}
QAbstractButton::focusInEvent(e);
}
@@ -488,11 +495,13 @@ void QPushButton::focusOutEvent(QFocusEvent *e)
{
Q_D(QPushButton);
if (e->reason() != Qt::PopupFocusReason && autoDefault() && d->defaultButton) {
+#if QT_CONFIG(dialog)
QDialog *dlg = qobject_cast<QDialog*>(window());
if (dlg)
dlg->d_func()->setDefault(0);
else
d->defaultButton = false;
+#endif
}
QAbstractButton::focusOutEvent(e);
@@ -657,10 +666,12 @@ bool QPushButton::event(QEvent *e)
{
Q_D(QPushButton);
if (e->type() == QEvent::ParentChange) {
+#if QT_CONFIG(dialog)
if (QDialog *dialog = d->dialogParent()) {
if (d->defaultButton)
dialog->d_func()->setMainDefault(this);
}
+#endif
} else if (e->type() == QEvent::StyleChange
#ifdef Q_OS_MAC
|| e->type() == QEvent::MacSizeChange
diff --git a/src/widgets/widgets/qpushbutton_p.h b/src/widgets/widgets/qpushbutton_p.h
index 198091503a..a32b599b94 100644
--- a/src/widgets/widgets/qpushbutton_p.h
+++ b/src/widgets/widgets/qpushbutton_p.h
@@ -81,7 +81,11 @@ public:
#endif
void resetLayoutItemMargins();
void _q_popupPressed();
+#if QT_CONFIG(dialog)
QDialog *dialogParent() const;
+#else
+ QDialog *dialogParent() const { return 0; };
+#endif
QPointer<QMenu> menu;
uint autoDefault : 2;
diff --git a/src/widgets/widgets/qtextedit_p.h b/src/widgets/widgets/qtextedit_p.h
index cca315ce30..13d0eb323a 100644
--- a/src/widgets/widgets/qtextedit_p.h
+++ b/src/widgets/widgets/qtextedit_p.h
@@ -61,13 +61,14 @@
#include "QtGui/qabstracttextdocumentlayout.h"
#include "QtCore/qbasictimer.h"
#include "QtCore/qurl.h"
-#include "private/qwidgettextcontrol_p.h"
#include "qtextedit.h"
-QT_BEGIN_NAMESPACE
-
#ifndef QT_NO_TEXTEDIT
+#include "private/qwidgettextcontrol_p.h"
+
+QT_BEGIN_NAMESPACE
+
class QMimeData;
class QTextEditPrivate : public QAbstractScrollAreaPrivate
{
@@ -135,9 +136,9 @@ public:
QBasicTimer deleteAllTimer;
#endif
};
-#endif // QT_NO_TEXTEDIT
-
QT_END_NAMESPACE
+#endif // QT_NO_TEXTEDIT
+
#endif // QTEXTEDIT_P_H
diff --git a/src/widgets/widgets/qtoolbox.cpp b/src/widgets/widgets/qtoolbox.cpp
index 2c74b5fa9d..8413827e30 100644
--- a/src/widgets/widgets/qtoolbox.cpp
+++ b/src/widgets/widgets/qtoolbox.cpp
@@ -117,7 +117,7 @@ public:
void _q_buttonClicked();
void _q_widgetDestroyed(QObject*);
- const Page *page(QWidget *widget) const;
+ const Page *page(const QObject *widget) const;
const Page *page(int index) const;
Page *page(int index);
@@ -129,7 +129,7 @@ public:
Page *currentPage;
};
-const QToolBoxPrivate::Page *QToolBoxPrivate::page(QWidget *widget) const
+const QToolBoxPrivate::Page *QToolBoxPrivate::page(const QObject *widget) const
{
if (!widget)
return 0;
@@ -449,11 +449,9 @@ void QToolBoxPrivate::relayout()
void QToolBoxPrivate::_q_widgetDestroyed(QObject *object)
{
Q_Q(QToolBox);
- // no verification - vtbl corrupted already
- QWidget *p = (QWidget*)object;
- const QToolBoxPrivate::Page *c = page(p);
- if (!p || !c)
+ const QToolBoxPrivate::Page * const c = page(object);
+ if (!c)
return;
layout->removeWidget(c->sv);
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index 9aec94d47f..9e848ca834 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -2055,16 +2055,59 @@ void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
preeditCursor = a.start;
hideCursor = !a.length;
} else if (a.type == QInputMethodEvent::TextFormat) {
- QTextCharFormat f = qvariant_cast<QTextFormat>(a.value).toCharFormat();
+ QTextCharFormat f = cursor.charFormat();
+ f.merge(qvariant_cast<QTextFormat>(a.value).toCharFormat());
if (f.isValid()) {
QTextLayout::FormatRange o;
o.start = a.start + cursor.position() - block.position();
o.length = a.length;
o.format = f;
- overrides.append(o);
+
+ // Make sure list is sorted by start index
+ QVector<QTextLayout::FormatRange>::iterator it = overrides.end();
+ while (it != overrides.begin()) {
+ QVector<QTextLayout::FormatRange>::iterator previous = it - 1;
+ if (o.start >= previous->start) {
+ overrides.insert(it, o);
+ break;
+ }
+ it = previous;
+ }
+
+ if (it == overrides.begin())
+ overrides.prepend(o);
}
}
}
+
+ if (cursor.charFormat().isValid()) {
+ int start = cursor.position() - block.position();
+ int end = start + e->preeditString().length();
+
+ QVector<QTextLayout::FormatRange>::iterator it = overrides.begin();
+ while (it != overrides.end()) {
+ QTextLayout::FormatRange range = *it;
+ int rangeStart = range.start;
+ if (rangeStart > start) {
+ QTextLayout::FormatRange o;
+ o.start = start;
+ o.length = rangeStart - start;
+ o.format = cursor.charFormat();
+ it = overrides.insert(it, o) + 1;
+ }
+
+ ++it;
+ start = range.start + range.length;
+ }
+
+ if (start < end) {
+ QTextLayout::FormatRange o;
+ o.start = start;
+ o.length = end - start;
+ o.format = cursor.charFormat();
+ overrides.append(o);
+ }
+ }
layout->setFormats(overrides);
cursor.endEditBlock();
diff --git a/src/widgets/widgets/qwidgettextcontrol_p.h b/src/widgets/widgets/qwidgettextcontrol_p.h
index f540a3c9ad..e2539a30e7 100644
--- a/src/widgets/widgets/qwidgettextcontrol_p.h
+++ b/src/widgets/widgets/qwidgettextcontrol_p.h
@@ -65,6 +65,8 @@
#include <QtCore/qmimedata.h>
#include <QtGui/private/qinputcontrol_p.h>
+QT_REQUIRE_CONFIG(widgettextcontrol);
+
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qwidgettextcontrol_p_p.h b/src/widgets/widgets/qwidgettextcontrol_p_p.h
index 35027ff82a..357ffdc6bd 100644
--- a/src/widgets/widgets/qwidgettextcontrol_p_p.h
+++ b/src/widgets/widgets/qwidgettextcontrol_p_p.h
@@ -62,6 +62,8 @@
#include "QtCore/qpointer.h"
#include "private/qobject_p.h"
+QT_REQUIRE_CONFIG(widgettextcontrol);
+
QT_BEGIN_NAMESPACE
class QMimeData;
diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri
index 22e083a3d4..086585f0e6 100644
--- a/src/widgets/widgets/widgets.pri
+++ b/src/widgets/widgets/widgets.pri
@@ -65,8 +65,6 @@ HEADERS += \
widgets/qfocusframe.h \
widgets/qscrollarea.h \
widgets/qwidgetanimator_p.h \
- widgets/qwidgettextcontrol_p.h \
- widgets/qwidgettextcontrol_p_p.h \
widgets/qwidgetlinecontrol_p.h \
widgets/qtoolbararealayout_p.h \
widgets/qplaintextedit.h \
@@ -120,7 +118,6 @@ SOURCES += \
widgets/qfocusframe.cpp \
widgets/qscrollarea.cpp \
widgets/qwidgetanimator.cpp \
- widgets/qwidgettextcontrol.cpp \
widgets/qwidgetlinecontrol.cpp \
widgets/qtoolbararealayout.cpp \
widgets/qplaintextedit.cpp
@@ -194,6 +191,15 @@ qtConfig(dialogbuttonbox) {
widgets/qdialogbuttonbox.cpp
}
+qtConfig(widgettextcontrol) {
+ HEADERS += \
+ widgets/qwidgettextcontrol_p.h \
+ widgets/qwidgettextcontrol_p_p.h
+
+ SOURCES += \
+ widgets/qwidgettextcontrol.cpp
+}
+
macx {
HEADERS += \
widgets/qmacnativewidget_mac.h \