fixed speed in os x qt, added langs for report spam confirm, fixed os x drag n drop forward

This commit is contained in:
John Preston 2015-09-12 22:00:56 +03:00
parent 8f0606c9b6
commit f431591bef
16 changed files with 2412 additions and 3 deletions

View File

@ -488,6 +488,9 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
"lng_report_spam" = "Report Spam";
"lng_report_spam_hide" = "Hide";
"lng_report_spam_thanks" = "Thank you for your report!";
"lng_report_spam_sure" = "Are you sure you want\nto report spam from this user?";
"lng_report_spam_sure_group" = "Are you sure you want\nto report spam in this group?";
"lng_report_spam_ok" = "Report";
"lng_cant_send_to_not_contact" = "Sorry, you can only send messages to\nmutual contacts at the moment. {more_info}";
"lng_cant_invite_not_contact" = "Sorry, you can only add mutual contacts\nto groups at the moment. {more_info}";
"lng_cant_more_info" = "More info »";

View File

@ -6057,7 +6057,7 @@ bool HistoryReply::updateReplyTo(bool force) {
}
if (force) {
initDimensions();
if (App::main()) App::main()->msgUpdated(history()->peer->id, this);
if (App::main()) App::main()->itemResized(this);
}
return (replyToMsg || !replyToMsgId);
}

View File

@ -544,6 +544,7 @@ void HistoryList::onDragExec() {
}
drag->setMimeData(mimeData);
drag->exec(Qt::CopyAction);
if (App::main()) App::main()->updateAfterDrag();
return;
} else {
HistoryItem *pressedLnkItem = App::pressedLinkItem(), *pressedItem = App::pressedItem();
@ -575,6 +576,7 @@ void HistoryList::onDragExec() {
drag->setMimeData(mimeData);
drag->exec(Qt::CopyAction);
if (App::main()) App::main()->updateAfterDrag();
return;
}
}
@ -2967,6 +2969,10 @@ void HistoryWidget::contactsReceived() {
updateControlsVisibility();
}
void HistoryWidget::updateAfterDrag() {
if (_list) _list->dragActionUpdate(QCursor::pos());
}
void HistoryWidget::updateReportSpamStatus() {
if (!_peer || (!_peer->chat && (App::userFromPeer(_peer->id) == MTP::authedId() || isNotificationsUser(_peer->id) || isServiceUser(_peer->id)))) {
_reportSpamStatus = dbiprsNoButton;

View File

@ -506,6 +506,8 @@ public:
void contactsReceived();
void updateAfterDrag();
~HistoryWidget();
signals:

View File

@ -1312,6 +1312,7 @@ void MainWidget::itemResized(HistoryItem *row, bool scrollToIt) {
if (overview) {
overview->itemResized(row, scrollToIt);
}
if (row) msgUpdated(row->history()->peer->id, row);
}
bool MainWidget::overviewFailed(PeerData *peer, const RPCError &error, mtpRequestId req) {
@ -1988,6 +1989,14 @@ void MainWidget::contactsReceived() {
history.contactsReceived();
}
void MainWidget::updateAfterDrag() {
if (overview) {
overview->updateAfterDrag();
} else {
history.updateAfterDrag();
}
}
void MainWidget::showPeerHistory(quint64 peerId, qint32 showAtMsgId, bool back) {
if (!back && (!peerId || (_stack.size() == 1 && _stack[0]->type() == HistoryStackItem && _stack[0]->peer->id == peerId))) {
back = true;

View File

@ -380,6 +380,8 @@ public:
void contactsReceived();
void updateAfterDrag();
~MainWidget();
signals:

View File

@ -803,7 +803,7 @@ void OverviewInner::onDragExec() {
}
drag->setMimeData(mimeData);
drag->exec(Qt::CopyAction);
dragActionUpdate(QCursor::pos());
if (App::main()) App::main()->updateAfterDrag();
return;
} else {
HistoryItem *pressedLnkItem = App::pressedLinkItem(), *pressedItem = App::pressedItem();
@ -828,7 +828,7 @@ void OverviewInner::onDragExec() {
drag->setMimeData(mimeData);
drag->exec(Qt::CopyAction);
dragActionUpdate(QCursor::pos());
if (App::main()) App::main()->updateAfterDrag();
return;
}
}
@ -2820,6 +2820,10 @@ void OverviewWidget::updateScrollColors() {
_scroll.updateColors(App::historyScrollBarColor(), App::historyScrollBgColor(), App::historyScrollBarOverColor(), App::historyScrollBgOverColor());
}
void OverviewWidget::updateAfterDrag() {
_inner.dragActionUpdate(QCursor::pos());
}
OverviewWidget::~OverviewWidget() {
onClearSelected();
updateTopBarSelection();

View File

@ -311,6 +311,8 @@ public:
void updateScrollColors();
void updateAfterDrag();
~OverviewWidget();
public slots:

View File

@ -0,0 +1,285 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <qbackingstore.h>
#include <qwindow.h>
#include <qpixmap.h>
#include <qpa/qplatformbackingstore.h>
#include <qpa/qplatformintegration.h>
#include <qscreen.h>
#include <qdebug.h>
#include <private/qguiapplication_p.h>
#include <private/qwindow_p.h>
QT_BEGIN_NAMESPACE
class QBackingStorePrivate
{
public:
QBackingStorePrivate(QWindow *w)
: window(w)
{
}
QWindow *window;
QPlatformBackingStore *platformBackingStore;
QRegion staticContents;
QSize size;
};
/*!
\class QBackingStore
\since 5.0
\inmodule QtGui
\brief The QBackingStore class provides a drawing area for QWindow.
QBackingStore enables the use of QPainter to paint on a QWindow with type
RasterSurface. The other way of rendering to a QWindow is through the use
of OpenGL with QOpenGLContext.
A QBackingStore contains a buffered representation of the window contents,
and thus supports partial updates by using QPainter to only update a sub
region of the window contents.
QBackingStore might be used by an application that wants to use QPainter
without OpenGL acceleration and without the extra overhead of using the
QWidget or QGraphicsView UI stacks. For an example of how to use
QBackingStore see the \l{Raster Window Example}.
*/
/*!
Flushes the given \a region from the specified window \a win onto the
screen.
Note that the \a offset parameter is currently unused.
*/
void QBackingStore::flush(const QRegion &region, QWindow *win, const QPoint &offset)
{
if (!win)
win = window();
if (!win->handle()) {
qWarning() << "QBackingStore::flush() called for "
<< win << " which does not have a handle.";
return;
}
#ifdef QBACKINGSTORE_DEBUG
if (win && win->isTopLevel() && !qt_window_private(win)->receivedExpose) {
qWarning().nospace() << "QBackingStore::flush() called with non-exposed window "
<< win << ", behavior is undefined";
}
#endif
d_ptr->platformBackingStore->flush(win, region, offset);
}
/*!
\fn QPaintDevice* QBackingStore::paintDevice()
Implement this function to return the appropriate paint device.
*/
QPaintDevice *QBackingStore::paintDevice()
{
return d_ptr->platformBackingStore->paintDevice();
}
/*!
Constructs an empty surface for the given top-level \a window.
*/
QBackingStore::QBackingStore(QWindow *window)
: d_ptr(new QBackingStorePrivate(window))
{
d_ptr->platformBackingStore = QGuiApplicationPrivate::platformIntegration()->createPlatformBackingStore(window);
}
/*!
Destroys this surface.
*/
QBackingStore::~QBackingStore()
{
delete d_ptr->platformBackingStore;
}
/*!
Returns a pointer to the top-level window associated with this
surface.
*/
QWindow* QBackingStore::window() const
{
return d_ptr->window;
}
/*!
This function is called before painting onto the surface begins,
with the \a region in which the painting will occur.
\sa endPaint(), paintDevice()
*/
void QBackingStore::beginPaint(const QRegion &region)
{
d_ptr->platformBackingStore->beginPaint(region);
}
void QBackingStore::beforeBeginPaint(QWindow *win)
{
if (!win)
win = window();
if (!win->handle())
return;
d_ptr->platformBackingStore->beforeBeginPaint(win);
}
/*!
This function is called after painting onto the surface has ended.
\sa beginPaint(), paintDevice()
*/
void QBackingStore::endPaint()
{
d_ptr->platformBackingStore->endPaint();
}
void QBackingStore::afterEndPaint(QWindow *win)
{
if (!win)
win = window();
if (!win->handle())
return;
d_ptr->platformBackingStore->afterEndPaint(win);
}
/*!
Sets the size of the windowsurface to be \a size.
\sa size()
*/
void QBackingStore::resize(const QSize &size)
{
d_ptr->size = size;
d_ptr->platformBackingStore->resize(size, d_ptr->staticContents);
}
/*!
Returns the current size of the windowsurface.
*/
QSize QBackingStore::size() const
{
return d_ptr->size;
}
/*!
Scrolls the given \a area \a dx pixels to the right and \a dy
downward; both \a dx and \a dy may be negative.
Returns \c true if the area was scrolled successfully; false otherwise.
*/
bool QBackingStore::scroll(const QRegion &area, int dx, int dy)
{
Q_UNUSED(area);
Q_UNUSED(dx);
Q_UNUSED(dy);
return d_ptr->platformBackingStore->scroll(area, dx, dy);
}
void QBackingStore::setStaticContents(const QRegion &region)
{
d_ptr->staticContents = region;
}
QRegion QBackingStore::staticContents() const
{
return d_ptr->staticContents;
}
bool QBackingStore::hasStaticContents() const
{
return !d_ptr->staticContents.isEmpty();
}
void Q_GUI_EXPORT qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset)
{
// make sure we don't detach
uchar *mem = const_cast<uchar*>(const_cast<const QImage &>(img).bits());
int lineskip = img.bytesPerLine();
int depth = img.depth() >> 3;
const QRect imageRect(0, 0, img.width(), img.height());
const QRect r = rect & imageRect & imageRect.translated(-offset);
const QPoint p = rect.topLeft() + offset;
if (r.isEmpty())
return;
const uchar *src;
uchar *dest;
if (r.top() < p.y()) {
src = mem + r.bottom() * lineskip + r.left() * depth;
dest = mem + (p.y() + r.height() - 1) * lineskip + p.x() * depth;
lineskip = -lineskip;
} else {
src = mem + r.top() * lineskip + r.left() * depth;
dest = mem + p.y() * lineskip + p.x() * depth;
}
const int w = r.width();
int h = r.height();
const int bytes = w * depth;
// overlapping segments?
if (offset.y() == 0 && qAbs(offset.x()) < w) {
do {
::memmove(dest, src, bytes);
dest += lineskip;
src += lineskip;
} while (--h);
} else {
do {
::memcpy(dest, src, bytes);
dest += lineskip;
src += lineskip;
} while (--h);
}
}
QPlatformBackingStore *QBackingStore::handle() const
{
return d_ptr->platformBackingStore;
}
QT_END_NAMESPACE

View File

@ -0,0 +1,88 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBACKINGSTORE_H
#define QBACKINGSTORE_H
#include <QtCore/qrect.h>
#include <QtGui/qwindow.h>
#include <QtGui/qregion.h>
QT_BEGIN_NAMESPACE
class QRegion;
class QRect;
class QPoint;
class QImage;
class QBackingStorePrivate;
class QPlatformBackingStore;
class Q_GUI_EXPORT QBackingStore
{
public:
explicit QBackingStore(QWindow *window);
~QBackingStore();
QWindow *window() const;
QPaintDevice *paintDevice();
// 'window' can be a child window, in which case 'region' is in child window coordinates and
// offset is the (child) window's offset in relation to the window surface.
void flush(const QRegion &region, QWindow *window = 0, const QPoint &offset = QPoint());
void resize(const QSize &size);
QSize size() const;
bool scroll(const QRegion &area, int dx, int dy);
void beginPaint(const QRegion &);
void beforeBeginPaint(QWindow *window);
void endPaint();
void afterEndPaint(QWindow *window);
void setStaticContents(const QRegion &region);
QRegion staticContents() const;
bool hasStaticContents() const;
QPlatformBackingStore *handle() const;
private:
QScopedPointer<QBackingStorePrivate> d_ptr;
};
QT_END_NAMESPACE
#endif // QBACKINGSTORE_H

View File

@ -0,0 +1,150 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QPLATFORMBACKINGSTORE_H
#define QPLATFORMBACKINGSTORE_H
//
// W A R N I N G
// -------------
//
// This file is part of the QPA API and is not meant to be used
// in applications. Usage of this API may make your code
// source and binary incompatible with future versions of Qt.
//
#include <QtCore/qrect.h>
#include <QtCore/qobject.h>
#include <QtGui/qwindow.h>
#include <QtGui/qregion.h>
#include <QtGui/qopengl.h>
QT_BEGIN_NAMESPACE
class QRegion;
class QRect;
class QPoint;
class QImage;
class QPlatformBackingStorePrivate;
class QPlatformWindow;
class QPlatformTextureList;
class QPlatformTextureListPrivate;
class QOpenGLContext;
class QPlatformGraphicsBuffer;
#ifndef QT_NO_OPENGL
class Q_GUI_EXPORT QPlatformTextureList : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QPlatformTextureList)
public:
enum Flag {
StacksOnTop = 0x01
};
Q_DECLARE_FLAGS(Flags, Flag)
explicit QPlatformTextureList(QObject *parent = 0);
~QPlatformTextureList();
int count() const;
bool isEmpty() const { return count() == 0; }
GLuint textureId(int index) const;
QRect geometry(int index) const;
QRect clipRect(int index) const;
void *source(int index);
Flags flags(int index) const;
void lock(bool on);
bool isLocked() const;
void appendTexture(void *source, GLuint textureId, const QRect &geometry,
const QRect &clipRect = QRect(), Flags flags = 0);
void clear();
Q_SIGNALS:
void locked(bool);
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformTextureList::Flags)
#endif
class Q_GUI_EXPORT QPlatformBackingStore
{
public:
explicit QPlatformBackingStore(QWindow *window);
virtual ~QPlatformBackingStore();
QWindow *window() const;
virtual QPaintDevice *paintDevice() = 0;
// 'window' can be a child window, in which case 'region' is in child window coordinates and
// offset is the (child) window's offset in relation to the window surface.
virtual void flush(QWindow *window, const QRegion &region, const QPoint &offset) = 0;
#ifndef QT_NO_OPENGL
virtual void composeAndFlush(QWindow *window, const QRegion &region, const QPoint &offset,
QPlatformTextureList *textures, QOpenGLContext *context,
bool translucentBackground);
virtual QImage toImage() const;
enum TextureFlag {
TextureSwizzle = 0x01,
TextureFlip = 0x02
};
Q_DECLARE_FLAGS(TextureFlags, TextureFlag)
virtual GLuint toTexture(const QRegion &dirtyRegion, QSize *textureSize, TextureFlags *flags) const;
#endif
virtual QPlatformGraphicsBuffer *graphicsBuffer() const;
virtual void resize(const QSize &size, const QRegion &staticContents) = 0;
virtual bool scroll(const QRegion &area, int dx, int dy);
virtual void beginPaint(const QRegion &);
virtual void beforeBeginPaint(QWindow *window) {
}
virtual void endPaint();
virtual void afterEndPaint(QWindow *window) {
}
private:
QPlatformBackingStorePrivate *d_ptr;
};
#ifndef QT_NO_OPENGL
Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformBackingStore::TextureFlags)
#endif
QT_END_NAMESPACE
#endif // QPLATFORMBACKINGSTORE_H

View File

@ -0,0 +1,70 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBACKINGSTORE_COCOA_H
#define QBACKINGSTORE_COCOA_H
#include <Cocoa/Cocoa.h>
#include "qcocoawindow.h"
#include "qnsview.h"
#include <qpa/qplatformbackingstore.h>
QT_BEGIN_NAMESPACE
class QCocoaBackingStore : public QPlatformBackingStore
{
public:
QCocoaBackingStore(QWindow *window);
~QCocoaBackingStore();
QPaintDevice *paintDevice();
void flush(QWindow *widget, const QRegion &region, const QPoint &offset);
QImage toImage() const;
void resize (const QSize &size, const QRegion &);
bool scroll(const QRegion &area, int dx, int dy);
void beginPaint(const QRegion &region);
void beforeBeginPaint(QWindow *widget);
void afterEndPaint(QWindow *widget);
qreal getBackingStoreDevicePixelRatio();
private:
QImage m_qImage;
QSize m_requestedSize;
bool m_imageWasEqual;
};
QT_END_NAMESPACE
#endif

View File

@ -0,0 +1,136 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qcocoabackingstore.h"
#include <QtGui/QPainter>
#include "qcocoahelpers.h"
QT_BEGIN_NAMESPACE
QCocoaBackingStore::QCocoaBackingStore(QWindow *window)
: QPlatformBackingStore(window), m_imageWasEqual(false)
{
}
QCocoaBackingStore::~QCocoaBackingStore()
{
}
QPaintDevice *QCocoaBackingStore::paintDevice()
{
QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window()->handle());
int windowDevicePixelRatio = int(cocoaWindow->devicePixelRatio());
// Receate the backing store buffer if the effective buffer size has changed,
// either due to a window resize or devicePixelRatio change.
QSize effectiveBufferSize = m_requestedSize * windowDevicePixelRatio;
if (m_qImage.size() != effectiveBufferSize) {
QImage::Format format = (window()->format().hasAlpha() || cocoaWindow->m_drawContentBorderGradient)
? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
m_qImage = QImage(effectiveBufferSize, format);
m_qImage.setDevicePixelRatio(windowDevicePixelRatio);
if (format == QImage::Format_ARGB32_Premultiplied)
m_qImage.fill(Qt::transparent);
}
return &m_qImage;
}
void QCocoaBackingStore::flush(QWindow *win, const QRegion &region, const QPoint &offset)
{
if (!m_qImage.isNull()) {
if (QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(win->handle()))
[cocoaWindow->m_qtView flushBackingStore:this region:region offset:offset];
}
}
QImage QCocoaBackingStore::toImage() const
{
return m_qImage;
}
void QCocoaBackingStore::resize(const QSize &size, const QRegion &)
{
m_requestedSize = size;
}
bool QCocoaBackingStore::scroll(const QRegion &area, int dx, int dy)
{
extern void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset);
const qreal devicePixelRatio = m_qImage.devicePixelRatio();
QPoint qpoint(dx * devicePixelRatio, dy * devicePixelRatio);
const QVector<QRect> qrects = area.rects();
for (int i = 0; i < qrects.count(); ++i) {
const QRect &qrect = QRect(qrects.at(i).topLeft() * devicePixelRatio, qrects.at(i).size() * devicePixelRatio);
qt_scrollRectInImage(m_qImage, qrect, qpoint);
}
return true;
}
void QCocoaBackingStore::beginPaint(const QRegion &region)
{
if (m_qImage.hasAlphaChannel()) {
QPainter p(&m_qImage);
p.setCompositionMode(QPainter::CompositionMode_Source);
const QVector<QRect> rects = region.rects();
const QColor blank = Qt::transparent;
for (QVector<QRect>::const_iterator it = rects.begin(), end = rects.end(); it != end; ++it)
p.fillRect(*it, blank);
}
}
void QCocoaBackingStore::beforeBeginPaint(QWindow *win) {
m_imageWasEqual = false;
if (!m_qImage.isNull()) {
if (QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(win->handle())) {
if ([cocoaWindow->m_qtView beforeBeginPaint:this])
m_imageWasEqual = true;
}
}
}
void QCocoaBackingStore::afterEndPaint(QWindow *win) {
if (!m_qImage.isNull()) {
if (QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(win->handle())) {
if (m_imageWasEqual)
[cocoaWindow->m_qtView afterEndPaint:this];
}
}
m_imageWasEqual = false;
}
qreal QCocoaBackingStore::getBackingStoreDevicePixelRatio()
{
return m_qImage.devicePixelRatio();
}
QT_END_NAMESPACE

View File

@ -0,0 +1,145 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QNSVIEW_H
#define QNSVIEW_H
#include <Cocoa/Cocoa.h>
#include <QtCore/QPointer>
#include <QtGui/QImage>
#include <QtGui/QAccessible>
#include "private/qcore_mac_p.h"
QT_BEGIN_NAMESPACE
class QCocoaWindow;
class QCocoaBackingStore;
class QCocoaGLContext;
QT_END_NAMESPACE
Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper));
@interface QT_MANGLE_NAMESPACE(QNSView) : NSView <NSTextInputClient> {
QImage m_backingStore;
qreal m_pixelRatio;
QPoint m_backingStoreOffset;
CGImageRef m_maskImage;
uchar *m_maskData;
bool m_shouldInvalidateWindowShadow;
QWindow *m_window;
QCocoaWindow *m_platformWindow;
NSTrackingArea *m_trackingArea;
Qt::MouseButtons m_buttons;
Qt::MouseButtons m_frameStrutButtons;
QString m_composingText;
bool m_sendKeyEvent;
QStringList *currentCustomDragTypes;
bool m_sendUpAsRightButton;
Qt::KeyboardModifiers currentWheelModifiers;
bool m_subscribesForGlobalFrameNotifications;
#ifndef QT_NO_OPENGL
QCocoaGLContext *m_glContext;
bool m_shouldSetGLContextinDrawRect;
#endif
NSString *m_inputSource;
QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) *m_mouseMoveHelper;
bool m_resendKeyEvent;
bool m_scrolling;
bool m_exposedOnMoveToWindow;
}
- (id)init;
- (id)initWithQWindow:(QWindow *)window platformWindow:(QCocoaWindow *) platformWindow;
- (void) clearQWindowPointers;
#ifndef QT_NO_OPENGL
- (void)setQCocoaGLContext:(QCocoaGLContext *)context;
#endif
- (void)flushBackingStore:(QCocoaBackingStore *)backingStore region:(const QRegion &)region offset:(QPoint)offset;
- (BOOL)beforeBeginPaint:(QCocoaBackingStore *)backingStore;
- (void)afterEndPaint:(QCocoaBackingStore *)backingStore;
- (void)setMaskRegion:(const QRegion *)region;
- (void)invalidateWindowShadowIfNeeded;
- (void)drawRect:(NSRect)dirtyRect;
- (void)updateGeometry;
- (void)notifyWindowStateChanged:(Qt::WindowState)newState;
- (void)windowNotification : (NSNotification *) windowNotification;
- (void)notifyWindowWillZoom:(BOOL)willZoom;
- (void)viewDidHide;
- (void)viewDidUnhide;
- (BOOL)isFlipped;
- (BOOL)acceptsFirstResponder;
- (BOOL)becomeFirstResponder;
- (BOOL)hasMask;
- (BOOL)isOpaque;
- (void)convertFromScreen:(NSPoint)mouseLocation toWindowPoint:(QPointF *)qtWindowPoint andScreenPoint:(QPointF *)qtScreenPoint;
- (void)resetMouseButtons;
- (void)handleMouseEvent:(NSEvent *)theEvent;
- (void)mouseDown:(NSEvent *)theEvent;
- (void)mouseDragged:(NSEvent *)theEvent;
- (void)mouseUp:(NSEvent *)theEvent;
- (void)mouseMovedImpl:(NSEvent *)theEvent;
- (void)mouseEnteredImpl:(NSEvent *)theEvent;
- (void)mouseExitedImpl:(NSEvent *)theEvent;
- (void)cursorUpdateImpl:(NSEvent *)theEvent;
- (void)rightMouseDown:(NSEvent *)theEvent;
- (void)rightMouseDragged:(NSEvent *)theEvent;
- (void)rightMouseUp:(NSEvent *)theEvent;
- (void)otherMouseDown:(NSEvent *)theEvent;
- (void)otherMouseDragged:(NSEvent *)theEvent;
- (void)otherMouseUp:(NSEvent *)theEvent;
- (void)handleFrameStrutMouseEvent:(NSEvent *)theEvent;
- (void)handleTabletEvent: (NSEvent *)theEvent;
- (void)tabletPoint: (NSEvent *)theEvent;
- (void)tabletProximity: (NSEvent *)theEvent;
- (int) convertKeyCode : (QChar)keyCode;
+ (Qt::KeyboardModifiers) convertKeyModifiers : (ulong)modifierFlags;
- (void)handleKeyEvent:(NSEvent *)theEvent eventType:(int)eventType;
- (void)keyDown:(NSEvent *)theEvent;
- (void)keyUp:(NSEvent *)theEvent;
- (BOOL)performKeyEquivalent:(NSEvent *)theEvent;
- (void)registerDragTypes;
- (NSDragOperation)handleDrag:(id <NSDraggingInfo>)sender;
@end
QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSView);
#endif //QNSVIEW_H

View File

@ -484,6 +484,20 @@ QT_WARNING_POP
}
}
- (BOOL) beforeBeginPaint:(QCocoaBackingStore *)backingStore
{
if (!m_backingStore.isNull() && m_backingStore.constBits() == backingStore->toImage().constBits()) {
m_backingStore = QImage();
return true;
}
return false;
}
- (void) afterEndPaint:(QCocoaBackingStore *)backingStore
{
m_backingStore = backingStore->toImage();
}
- (BOOL) hasMask
{
return m_maskImage != 0;

File diff suppressed because it is too large Load Diff