fix(chatinput/mentions) added clipboard proxy to prevent paste text missbehavior
This commit is contained in:
parent
18b87996eb
commit
1008ea78b0
|
@ -0,0 +1,39 @@
|
|||
#ifndef QCLIPBOARDPROXY_HPP
|
||||
#define QCLIPBOARDPROXY_HPP
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QQmlEngine>
|
||||
#include <QJSEngine>
|
||||
|
||||
class QClipboard;
|
||||
|
||||
class QClipboardProxy : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(QClipboardProxy)
|
||||
Q_PROPERTY(QString text READ text NOTIFY textChanged)
|
||||
|
||||
QClipboardProxy() {}
|
||||
|
||||
public:
|
||||
explicit QClipboardProxy(QClipboard*);
|
||||
|
||||
QString text() const;
|
||||
|
||||
static QObject *qmlInstance(QQmlEngine *engine, QJSEngine *scriptEngine)
|
||||
{
|
||||
Q_UNUSED(engine);
|
||||
Q_UNUSED(scriptEngine);
|
||||
|
||||
return new QClipboardProxy;
|
||||
}
|
||||
|
||||
signals:
|
||||
void textChanged();
|
||||
|
||||
private:
|
||||
QClipboard* clipboard;
|
||||
};
|
||||
|
||||
#endif // QCLIPBOARDPROXY_HPP
|
|
@ -69,6 +69,7 @@
|
|||
#include "DOtherSide/Status/OSNotification.h"
|
||||
#include "DOtherSide/Status/KeychainManager.h"
|
||||
#include "DOtherSide/Status/SoundManager.h"
|
||||
#include "DOtherSide/Status/QClipboardProxy.h"
|
||||
#include "DOtherSide/DosSpellchecker.h"
|
||||
|
||||
namespace {
|
||||
|
@ -79,6 +80,8 @@ void register_meta_types()
|
|||
qmlRegisterType<StatusWindow>("DotherSide", 0 , 1, "StatusWindow");
|
||||
qmlRegisterType<StatusSyntaxHighlighterHelper>("DotherSide", 0 , 1, "StatusSyntaxHighlighter");
|
||||
qmlRegisterType<SpellChecker>("DotherSide", 0, 1, "SpellChecker");
|
||||
qmlRegisterSingletonType<QClipboardProxy>("DotherSide", 0 , 1, "QClipboardProxy", &QClipboardProxy::qmlInstance);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1562,4 +1565,4 @@ void dos_app_make_it_active(::DosQQmlApplicationEngine* vptr)
|
|||
window->requestActivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
#include "DOtherSide/Status/QClipboardProxy.h"
|
||||
|
||||
#include <QClipboard>
|
||||
|
||||
QClipboardProxy::QClipboardProxy(QClipboard* c) : clipboard(c)
|
||||
{
|
||||
QObject::connect(c, SIGNAL (dataChanged()), this, SLOT(textChanged()));
|
||||
}
|
||||
|
||||
QString QClipboardProxy::text() const
|
||||
{
|
||||
return clipboard->text();
|
||||
}
|
Loading…
Reference in New Issue