Add bidirectional text-clipboard support

This commit is contained in:
Amandeep Singh
2013-10-28 02:25:17 +05:30
parent c558eaf9b6
commit e452d68f05
2 changed files with 15 additions and 1 deletions

View File

@@ -20,6 +20,8 @@
#include "rfbserver.h"
#include "rfbservermanager.h"
#include <QtCore/QSocketNotifier>
#include <QApplication>
#include <QClipboard>
#include <KDebug>
struct RfbServer::Private
@@ -136,6 +138,8 @@ bool RfbServer::start()
d->notifier = new QSocketNotifier(d->screen->listenSock, QSocketNotifier::Read, this);
d->notifier->setEnabled(true);
connect(d->notifier, SIGNAL(activated(int)), this, SLOT(onListenSocketActivated()));
connect(QApplication::clipboard(), SIGNAL(dataChanged()),
this, SLOT(krfbSendServerCutText()));
return true;
}
@@ -201,6 +205,15 @@ void RfbServer::updateCursorPosition(const QPoint & position)
}
}
void RfbServer::krfbSendServerCutText()
{
if(d->screen) {
QString text = QApplication::clipboard()->text();
rfbSendServerCutText(d->screen,
text.toLocal8Bit().data(),text.length());
}
}
void RfbServer::onListenSocketActivated()
{
rfbProcessNewConnection(d->screen);
@@ -263,7 +276,7 @@ void RfbServer::pointerHook(int bm, int x, int y, rfbClientPtr cl)
//static
void RfbServer::clipboardHook(char *str, int len, rfbClientPtr cl)
{
//TODO implement me
QApplication::clipboard()->setText(QString::fromLocal8Bit(str,len));
}
#include "rfbserver.moc"

View File

@@ -47,6 +47,7 @@ public Q_SLOTS:
void updateCursorPosition(const QPoint & position);
private Q_SLOTS:
void krfbSendServerCutText();
void onListenSocketActivated();
void pendingClientFinished(RfbClient *client);