diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/image/qimagewriter.cpp | 49 | ||||
-rw-r--r-- | src/gui/image/qjpeghandler.pri | 6 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 5 | ||||
-rw-r--r-- | src/gui/kernel/qplatformtheme.cpp | 3 | ||||
-rw-r--r-- | src/gui/kernel/qplatformtheme.h | 1 | ||||
-rw-r--r-- | src/gui/painting/qbezier.cpp | 31 | ||||
-rw-r--r-- | src/gui/text/qtextdocument.h | 2 |
7 files changed, 50 insertions, 47 deletions
diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp index 900093b51b..8dd5fdd111 100644 --- a/src/gui/image/qimagewriter.cpp +++ b/src/gui/image/qimagewriter.cpp @@ -245,6 +245,8 @@ class QImageWriterPrivate public: QImageWriterPrivate(QImageWriter *qq); + bool canWriteHelper(); + // device QByteArray format; QIODevice *device; @@ -282,6 +284,31 @@ QImageWriterPrivate::QImageWriterPrivate(QImageWriter *qq) q = qq; } +bool QImageWriterPrivate::canWriteHelper() +{ + if (!device) { + imageWriterError = QImageWriter::DeviceError; + errorString = QT_TRANSLATE_NOOP(QImageWriter, + QLatin1String("Device is not set")); + return false; + } + if (!device->isOpen()) + device->open(QIODevice::WriteOnly); + if (!device->isWritable()) { + imageWriterError = QImageWriter::DeviceError; + errorString = QT_TRANSLATE_NOOP(QImageWriter, + QLatin1String("Device not writable")); + return false; + } + if (!handler && (handler = createWriteHandlerHelper(device, format)) == 0) { + imageWriterError = QImageWriter::UnsupportedFormatError; + errorString = QT_TRANSLATE_NOOP(QImageWriter, + QLatin1String("Unsupported image format")); + return false; + } + return true; +} + /*! Constructs an empty QImageWriter object. Before writing, you must call setFormat() to set an image format, then setDevice() or @@ -561,21 +588,15 @@ void QImageWriter::setText(const QString &key, const QString &text) */ bool QImageWriter::canWrite() const { - if (d->device && !d->handler && (d->handler = createWriteHandlerHelper(d->device, d->format)) == 0) { - d->imageWriterError = QImageWriter::UnsupportedFormatError; - d->errorString = QT_TRANSLATE_NOOP(QImageWriter, - QLatin1String("Unsupported image format")); - return false; + if (QFile *file = qobject_cast<QFile *>(d->device)) { + const bool remove = !file->isOpen() && !file->exists(); + const bool result = d->canWriteHelper(); + if (!result && remove) + file->remove(); + return result; } - if (d->device && !d->device->isOpen()) - d->device->open(QIODevice::WriteOnly); - if (!d->device || !d->device->isWritable()) { - d->imageWriterError = QImageWriter::DeviceError; - d->errorString = QT_TRANSLATE_NOOP(QImageWriter, - QLatin1String("Device not writable")); - return false; - } - return true; + + return d->canWriteHelper(); } /*! diff --git a/src/gui/image/qjpeghandler.pri b/src/gui/image/qjpeghandler.pri index 3cb35c95ed..c8de33d8b4 100644 --- a/src/gui/image/qjpeghandler.pri +++ b/src/gui/image/qjpeghandler.pri @@ -3,8 +3,10 @@ INCLUDEPATH *= $$PWD HEADERS += $$PWD/qjpeghandler_p.h SOURCES += $$PWD/qjpeghandler.cpp contains(QT_CONFIG, system-jpeg) { - if(unix|win32-g++*): LIBS += -ljpeg - else:win32: LIBS += libjpeg.lib + msvc: \ + LIBS += libjpeg.lib + else: \ + LIBS += -ljpeg } else { include($$PWD/../../3rdparty/libjpeg.pri) } diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 9f95f2c234..ae956aaa19 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -2555,6 +2555,11 @@ void QGuiApplication::setFont(const QFont &font) void QGuiApplicationPrivate::notifyLayoutDirectionChange() { + const QWindowList list = QGuiApplication::topLevelWindows(); + for (int i = 0; i < list.size(); ++i) { + QEvent ev(QEvent::ApplicationLayoutDirectionChange); + QCoreApplication::sendEvent(list.at(i), &ev); + } } void QGuiApplicationPrivate::notifyActiveWindowChange(QWindow *) diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index 8b4b5c1812..628b2c9d12 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -145,6 +145,8 @@ QT_BEGIN_NAMESPACE \value DialogSnapToDefaultButton (bool) Whether the mouse should snap to the default button when a dialog becomes visible. + \value ContextMenuOnMouseRelease (bool) Whether the context menu should be shown on mouse release. + \sa themeHint(), QStyle::pixelMetric() */ @@ -492,6 +494,7 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint) case IconPixmapSizes: return QVariant::fromValue(QList<int>()); case DialogSnapToDefaultButton: + case ContextMenuOnMouseRelease: return QVariant(false); case MousePressAndHoldInterval: return QVariant(800); diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h index 6e27261922..2ab8cef760 100644 --- a/src/gui/kernel/qplatformtheme.h +++ b/src/gui/kernel/qplatformtheme.h @@ -107,6 +107,7 @@ public: IconPixmapSizes, PasswordMaskCharacter, DialogSnapToDefaultButton, + ContextMenuOnMouseRelease, MousePressAndHoldInterval }; diff --git a/src/gui/painting/qbezier.cpp b/src/gui/painting/qbezier.cpp index 2762560da7..33075b640d 100644 --- a/src/gui/painting/qbezier.cpp +++ b/src/gui/painting/qbezier.cpp @@ -119,37 +119,6 @@ QBezier QBezier::getSubRange(qreal t0, qreal t1) const return result; } -static inline int quadraticRoots(qreal a, qreal b, qreal c, - qreal *x1, qreal *x2) -{ - if (qFuzzyIsNull(a)) { - if (qFuzzyIsNull(b)) - return 0; - *x1 = *x2 = (-c / b); - return 1; - } else { - const qreal det = b * b - 4 * a * c; - if (qFuzzyIsNull(det)) { - *x1 = *x2 = -b / (2 * a); - return 1; - } - if (det > 0) { - if (qFuzzyIsNull(b)) { - *x2 = qSqrt(-c / a); - *x1 = -(*x2); - return 2; - } - const qreal stableA = b / (2 * a); - const qreal stableB = c / (a * stableA * stableA); - const qreal stableC = -1 - qSqrt(1 - stableB); - *x2 = stableA * stableC; - *x1 = (stableA * stableB) / stableC; - return 2; - } else - return 0; - } -} - void QBezier::addToPolygon(QPolygonF *polygon, qreal bezier_flattening_threshold) const { QBezier beziers[10]; diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h index 24e93b7e63..854cb29ed9 100644 --- a/src/gui/text/qtextdocument.h +++ b/src/gui/text/qtextdocument.h @@ -71,6 +71,7 @@ class QTextCursor; template<typename T> class QVector; +#ifndef Q_QDOC // Workaround for QTBUG-35230 namespace Qt { Q_GUI_EXPORT bool mightBeRichText(const QString&); @@ -80,6 +81,7 @@ namespace Qt Q_GUI_EXPORT QTextCodec *codecForHtml(const QByteArray &ba); #endif } +#endif // Q_QDOC class Q_GUI_EXPORT QAbstractUndoItem { |