コード例 #1
0
ファイル: qcompanion.cpp プロジェクト: kwplummer/QCompanion
/*!
 * \brief Loads all the components.
 * \details Loads all the plugins and adds them to the main menu.
 * Additionally it creates the timers for the screenshot logger and components.
 * \return a menu with the component's options in it, to be added to the system
 * tray.
 */
QMenu *QCompanion::loadPlugins()
{
  QMenu *mainMenu = new QMenu(this);

  snapper = new QSnapper(this);
  QMenu *snapperMenu = new QMenu("QSnapper", this);
  snapperMenu->addActions(snapper->getMenuContents());
  plugins.push_back(snapper);
  mainMenu->addMenu(snapperMenu);
  connect(snapper, SIGNAL(wantsToSpeak(QString)), this,
          SLOT(sendToSpeaker(QString)));

  HourReader *hr = new HourReader(this);
  QMenu *hourMenu = new QMenu("HourReader", this);
  hourMenu->addActions(hr->getMenuContents());
  plugins.push_back(hr);
  mainMenu->addMenu(hourMenu);
  connect(hr, SIGNAL(wantsToSpeak(QString)), this,
          SLOT(sendToSpeaker(QString)));

  WaiterComponent *waiter = new WaiterComponent(this);
  QMenu *waiterMenu = new QMenu("QWaiter", this);
  waiterMenu->addActions(waiter->getMenuContents());
  plugins.push_back(waiter);
  mainMenu->addMenu(waiterMenu);
  connect(waiter, SIGNAL(wantsToSpeak(QString)), this,
          SLOT(sendToSpeaker(QString)));

  QlipperComponent *qlipper = new QlipperComponent(this);
  QMenu *qlipperMenu = new QMenu("Qlipper", this);
  qlipperMenu->addActions(qlipper->getMenuContents());
  plugins.push_back(qlipper);
  mainMenu->addMenu(qlipperMenu);
  connect(qlipper, SIGNAL(wantsToSpeak(QString)), this,
          SLOT(sendToSpeaker(QString)));
  return mainMenu;
}
コード例 #2
0
ファイル: dialog.cpp プロジェクト: tanhangbo/BinaryOverAudio
void Dialog::formFrame(QString str)
{

    //frame format:
    // PREMABLE  MAC_ADDR DATASIZE      DATA       CRC
    //          1                4                4           DATASIZE      1

    //3bit/s at least 11*8/3 = 29s
    //for 10B message 20*8/3 = 53.33s ~ = 1min
    int totalLen=0;//B
    totalLen+=1;//premable 0xAA
    totalLen+=4;//MAC
    char MAC[] = {0x02,0x00,0x00,0x00};
    QByteArray text = str.toLocal8Bit();
    int dataSize=text.size();
    totalLen+=4;//size hint
    totalLen+=dataSize;
    totalLen+=1;//CRC
    char *data = new char[totalLen];

    char crc=0x33;
    memcpy(data,&premable,1);
    memcpy(data+1,MAC,4);
    memcpy(data+5,&dataSize,4);
    memcpy(data+9, text.data(),dataSize);
    memcpy(data+totalLen-1,&crc,1);//add crc
    sendToSpeaker(data,totalLen);


    //debug data output
    QString debugOut;
    for(int i=0;i<totalLen;i++)
    {
        debugOut+=QString::number(data[i],16);
        debugOut+=",";
    }
    qDebug()<<debugOut;


    delete [] data;
}