Beispiel #1
0
// socat -d -d pty,raw,echo=0 pty,raw,echo=0
void Pong::slotSerialMode()
{
    mMode = MODE_SERIAL;

    //Zobrazenie formulára pre používateľa.
    SetPortForm pf((QWidget *)(this->parent()));
    if (!(pf.exec() == QDialog::Accepted)) return;

    //Inicializácia objektu reprezentujúceho port pre sériovú komunikáciu.
    mPort = new QextSerialPort(pf.getPortName().trimmed());

    if (!mPort->open(QIODevice::ReadWrite)) {
        qDebug() << "Cannot open serial port";
        return;
    }

    //Zavedenie slotu - Ak sú dáta pripravené na čítanie z portu,
    //zavolaj funkciu slotDataAvailable
    connect(mPort, SIGNAL(readyRead()), this, SLOT(slotDataAvailable()));

    //Nastav port na základe hodnôt získaných od používateľa.
    mPort->setBaudRate(pf.getBaudRate());
    mPort->setStopBits(pf.getStopBits());
    mPort->setParity(pf.getParity());
    mPort->setFlowControl(pf.getFlow());

    //Pošli zariadeniu na druhej strane portu informáciu o tom že
    //začala nová hra a seed ktorý vygenerovala táto aplikácia
    mPort->write(QByteArray(1, InitGame).append(QString::number(mSeed)));
    slotNewGame(false);
}
Beispiel #2
0
void BridgeConnection::doConnects()
{
    connect(m_localSocket, SIGNAL(disconnected()), SLOT(deleteLater()));
    connect(m_remoteSocket, &QAbstractSocket::disconnected, this, &QObject::deleteLater);
    connect(m_localSocket, &QIODevice::readyRead, this, &BridgeConnection::slotDataAvailable);
    connect(m_remoteSocket, &QIODevice::readyRead, this, &BridgeConnection::slotDataAvailable);
    connect(m_localSocket, SIGNAL(connected()), SLOT(slotDataAvailable()));
}
bool SensorfwMagnetometer::doConnect()
{
    Q_ASSERT(m_sensorInterface);
    if (m_bufferSize==1)
        return QObject::connect(m_sensorInterface, SIGNAL(dataAvailable(MagneticField)),
                                this, SLOT(slotDataAvailable(MagneticField)));
     return QObject::connect(m_sensorInterface, SIGNAL(frameAvailable(QVector<MagneticField>)),
                             this, SLOT(slotFrameAvailable(QVector<MagneticField>)));
}
Beispiel #4
0
// ### the code below is slightly modified from kdelibs/kate/part/katedialogs,
// class KateModOnHdPrompt.
void KateMwModOnHdDialog::slotDiff()
{
  if ( !btnDiff->isEnabled()) // diff button already pressed, proc not finished yet
    return;

  if ( ! twDocuments->currentItem() )
    return;

  KTextEditor::Document *doc = ((KateDocItem*)twDocuments->currentItem())->document;

  // don't try to diff a deleted file
  if ( KateDocManager::self()->documentInfo( doc )->modifiedOnDiscReason == KTextEditor::ModificationInterface::OnDiskDeleted )
    return;

  if (m_diffFile)
    return;

  m_diffFile = new KTemporaryFile();
  m_diffFile->open();

  // Start a KProcess that creates a diff
  m_proc = new KProcess( this );
  m_proc->setOutputChannelMode( KProcess::MergedChannels );
  *m_proc << "diff" << "-ub" << "-" << doc->url().toLocalFile();
  connect( m_proc, SIGNAL(readyRead()), this, SLOT(slotDataAvailable()) );
  connect( m_proc, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotPDone()) );

  setCursor( Qt::WaitCursor );
  btnDiff->setEnabled(false);

  m_proc->start();

  QTextStream ts(m_proc);
  int lastln = doc->lines();
  for ( int l = 0; l < lastln; ++l )
    ts << doc->line( l ) << '\n';
  ts.flush();
  m_proc->closeWriteChannel();
}
KNotesNetworkReceiver::KNotesNetworkReceiver( QTcpSocket *s )
  : QObject(), m_buffer( new QByteArray() ), m_sock( s )
{
  QString date =
    KGlobal::locale()->formatDateTime( QDateTime::currentDateTime(),
                                       KLocale::ShortDate, false );

  // Add the remote IP or hostname and the date to the title, to help the
  // user guess who wrote it.
  m_titleAddon = QString( " [%1, %2]" )
                  .arg( m_sock->peerAddress().toString() )
                  .arg( date );

  // Setup the communications
  connect( m_sock, SIGNAL(readyRead()), SLOT(slotDataAvailable()) );
  connect( m_sock, SIGNAL(disconnected()), SLOT(slotConnectionClosed()) );
  connect( m_sock, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(slotError(QAbstractSocket::SocketError)));

  // Setup the timer
  m_timer = new QTimer( this );
  m_timer->setSingleShot( true );
  connect( m_timer, SIGNAL(timeout()), SLOT(slotReceptionTimeout()) );
  m_timer->start( MAXTIME );
}
bool SensorfwCompass::doConnect()
{
    Q_ASSERT(m_sensorInterface);
    return QObject::connect(m_sensorInterface, SIGNAL(dataAvailable(Compass)),
                            this, SLOT(slotDataAvailable(Compass)));
}
void meegorotationsensor::slotFrameAvailable(const QVector<XYZ>&  frame)
{
    for (int i=0, l=frame.size(); i<l; i++){
        slotDataAvailable(frame.at(i));
    }
}
void meegomagnetometer::slotFrameAvailable(const QVector<MagneticField>&   frame)
{
    for (int i=0, l=frame.size(); i<l; i++){
        slotDataAvailable(frame.at(i));
    }
}
bool SensorfwRotationSensor::doConnect()
{
    Q_ASSERT(m_sensorInterface);
    if (m_bufferSize==1)
       return QObject::connect(m_sensorInterface, SIGNAL(dataAvailable(XYZ)), this, SLOT(slotDataAvailable(XYZ)));
    return QObject::connect(m_sensorInterface, SIGNAL(frameAvailable(QVector<XYZ>)),this, SLOT(slotFrameAvailable(QVector<XYZ>)));
}
bool SensorfwLightSensor::doConnect()
{
    return QObject::connect(m_sensorInterface, SIGNAL(ALSChanged(Unsigned)),
                            this, SLOT(slotDataAvailable(Unsigned)));
}
bool SensorfwOrientationSensor::doConnect()
{
    Q_ASSERT(m_sensorInterface);
    return QObject::connect(m_sensorInterface, SIGNAL(orientationChanged(Unsigned)),
                            this, SLOT(slotDataAvailable(Unsigned)));
}
Beispiel #12
0
void SensorfwGyroscope::slotFrameAvailable(const QVector<XYZ>&  frame)
{
    for (int i=0, l=frame.size(); i<l; i++) {
        slotDataAvailable(frame.at(i));
    }
}
Beispiel #13
0
void meegoaccelerometer::slotFrameAvailable(const QVector<XYZ>&  frame)
{
    for (int i=0, l=frame.size(); i<l; i++){
        slotDataAvailable(frame.at(i));
    }
}