Пример #1
0
int main(void) {
  CEXCEPTION_T err;
  Tlv_Session *session = NULL;
  User_Session *userSession = NULL;
  
  displayOptionMenu();
  
  Try {
    if(session == NULL) session = tlvCreateSession();
    while(!IS_HOST_EXIT(session)) {
      Try {
        tlvService(session);
        hostInterpreter(session);
        // 
        // Receive packet and handle it here
        //
      } Catch(err) {
        HOST_CHANGE_STATE(session, HOST_WAIT_USER_COMMAND);
        displayErrorMessage(err);
      }
    }
  } Catch(err) {
    displayErrorMessage(err);
  }
  
  printf("Closing port\n");
  closePort(session);

  return 0;
}
Пример #2
0
void GrlMedia::statusChanged(QMediaPlayer::MediaStatus status)
{
	handleCursor(status);

// handle status message
	switch (status)
	{
		case QMediaPlayer::UnknownMediaStatus:
		case QMediaPlayer::NoMedia:
		case QMediaPlayer::LoadedMedia:
		case QMediaPlayer::BufferingMedia:
		case QMediaPlayer::BufferedMedia:
			setStatusInfo("");
		break;
		case QMediaPlayer::LoadingMedia:
			setStatusInfo(tr("Loading..."));
		break;
		case QMediaPlayer::StalledMedia:
			setStatusInfo(tr("Media Stalled"));
		break;
		case QMediaPlayer::EndOfMedia:
			emit endOfMedia();
		break;
		case QMediaPlayer::InvalidMedia:
			displayErrorMessage();
		break;
	}
}
Пример #3
0
void Player::statusChanged(QMediaPlayer::MediaStatus status)
{
    handleCursor(status);

    // handle status message
    switch (status) {
    case QMediaPlayer::UnknownMediaStatus:
    case QMediaPlayer::NoMedia:
    case QMediaPlayer::LoadedMedia:
    case QMediaPlayer::BufferingMedia:
    case QMediaPlayer::BufferedMedia:
        setStatusInfo(QString());
        break;
    case QMediaPlayer::LoadingMedia:
        setStatusInfo(tr("Loading..."));
        break;
    case QMediaPlayer::StalledMedia:
        setStatusInfo(tr("Media Stalled"));
        break;
    case QMediaPlayer::EndOfMedia:
        QApplication::alert(this);
        break;
    case QMediaPlayer::InvalidMedia:
        displayErrorMessage();
        break;
    }
}
Пример #4
0
ImageProcessing::ImageProcessing(QWidget *parent) : QMainWindow(parent) {
	iImageIndex = 0;
	m_NetTimeout = 0;
	m_ImageTimeout = 0;

	lbImage = new QLabel(this);
    bTurnOff = false;
    m_notRunning = true;
	setWindowState(Qt::WindowFullScreen);

	player = new QMediaPlayer(this);
    playlist = new QMediaPlaylist();
    player->setPlaylist(playlist);

    m_contentList = new FileDownload(this);
    m_imageFile = new FileDownload(this);

	pNextImage = new QTimer();

	connect(pNextImage, SIGNAL(timeout()), this, SLOT(timeout()));
    connect(m_contentList, SIGNAL(downloaded()), this, SLOT(contentListDownloadComplete()));
    connect(m_contentList, SIGNAL(downloadError(QNetworkReply::NetworkError)), this, SLOT(fileDownloadError(QNetworkReply::NetworkError)));
    connect(m_imageFile, SIGNAL(downloaded()), this, SLOT(fileDownloadComplete()));
    connect(m_imageFile, SIGNAL(downloadError(QNetworkReply::NetworkError)), this, SLOT(fileDownloadError(QNetworkReply::NetworkError)));
    connect(player, SIGNAL(durationChanged(qint64)), this, SLOT(durationChanged(qint64)));
    connect(player, SIGNAL(positionChanged(qint64)), this, SLOT(positionChanged(qint64)));
    connect(player, SIGNAL(metaDataChanged()), this, SLOT(metaDataChanged()));
    connect(player, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(displayErrorMessage()));
    connect(this, SIGNAL(fileDownloadsComplete()), this, SLOT(unlockShowEvent()));

    videoWidget = new QVideoWidget(this);
    player->setVideoOutput(videoWidget);
    videoWidget->hide();
}
Пример #5
0
void TIGLViewerWindow::setBackgroundImage()
{
    QString        fileName;
    QString        fileType;
    QFileInfo    fileInfo;

    statusBar()->showMessage(tr("Invoked File|Load Background Image"));

    fileName = QFileDialog::getOpenFileName (    this,
                                                  tr("Open Background Image"),
                                                myLastFolder,
                                                tr( "Images (*.jpg *.png *.gif *.bmp);;" ) );
    if (!fileName.isEmpty()) {
        fileInfo.setFile(fileName);
        fileType = fileInfo.suffix();
        
        if (fileType.toLower() == tr("bmp") || fileType.toLower() == tr("gif") || fileType.toLower() == tr("jpg") || fileType.toLower() == tr("png")) {
            myOCC->setBGImage(fileName);
        }
        else {
            displayErrorMessage(tr("Invalid image format!"),tr("TIGL Error"));
        }

    }
}
Пример #6
0
 Player::Player(QWidget *parent)
     : QWidget(parent)
     , videoWidget(0)
     , coverLabel(0)
     , slider(0)
     , audioEndpointSelector(0)
 #ifdef Q_OS_SYMBIAN
//     , mediaKeysObserver(0)
     , playlistDialog(0)
     , toggleAspectRatio(0)
     , showYoutubeDialog(0)
     , youtubeDialog(0)
 #else
     , colorDialog(0)
 #endif
 {
     player = new QMediaPlayer(this);
     // owned by PlaylistModel
     playlist = new QMediaPlaylist();
     player->setPlaylist(playlist);

     connect(player, SIGNAL(durationChanged(qint64)), SLOT(durationChanged(qint64)));
     connect(player, SIGNAL(positionChanged(qint64)), SLOT(positionChanged(qint64)));
     connect(player, SIGNAL(metaDataChanged()), SLOT(metaDataChanged()));
     connect(playlist, SIGNAL(currentIndexChanged(int)), SLOT(playlistPositionChanged(int)));
     connect(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
             this, SLOT(statusChanged(QMediaPlayer::MediaStatus)));
     connect(player, SIGNAL(bufferStatusChanged(int)), this, SLOT(bufferingProgress(int)));
     connect(player, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(displayErrorMessage()));

     videoWidget = new VideoWidget(this);
     player->setVideoOutput(videoWidget);

     playlistModel = new PlaylistModel(this);
     playlistModel->setPlaylist(playlist);

     playlistView = new QListView(this);
     playlistView->setModel(playlistModel);
     playlistView->setCurrentIndex(playlistModel->index(playlist->currentIndex(), 0));

     connect(playlistView, SIGNAL(activated(QModelIndex)), this, SLOT(jump(QModelIndex)));

     slider = new QSlider(Qt::Horizontal, this);
     slider->setRange(0, player->duration() / 1000);

     connect(slider, SIGNAL(sliderMoved(int)), this, SLOT(seek(int)));

     QMediaService *service = player->service();
     if (service) {
         QMediaControl *control = service->requestControl(QAudioEndpointSelector_iid);
         if (control) {
             audioEndpointSelector = qobject_cast<QAudioEndpointSelector*>(control);
             if (audioEndpointSelector) {
                 connect(audioEndpointSelector, SIGNAL(activeEndpointChanged(const QString&)),
                         this, SLOT(handleAudioOutputChangedSignal(const QString&)));
             } else {
                 service->releaseControl(control);
             }
         }
     }
Пример #7
0
GameEngine::GameEngine(QObject *parent) :
    QObject(parent)
{
    s_dlg = new SetUp();
    m_talker = new Talker(this);

    //setup_dlg and talker
    connect(s_dlg, SIGNAL(toDiscoverServer(QString,QString,QString)),
            m_talker, SLOT(discoverServer(QString,QString,QString)));
    connect(m_talker, SIGNAL(connected(QString, QString, QString)),
            s_dlg, SLOT(hideThis(QString, QString, QString)));
    connect(m_talker, SIGNAL(problemwithInput(QString)), s_dlg, SLOT(displayErrorMessage(QString)));

    // talker and this
    connect(m_talker, SIGNAL(matchReceived(QString)), this, SLOT(playMatch(QString)));
    connect(m_talker, SIGNAL(moveReceived(int,int,QString)), this, SLOT(playMove(int,int,QString)));
    connect(this, SIGNAL(ready()), m_talker, SLOT(sendReady()));
    connect(m_talker, SIGNAL(newGame()), this, SLOT(reset()));
    connect(m_talker, SIGNAL(startSatup()), this, SLOT(showSatup()));

    s_dlg->show();

    m_dlg = new InfoDialog();
    connect(m_talker, SIGNAL(connected(QString,QString,QString)),
            this, SLOT(startInfodialog(QString,QString,QString)));
    connect(m_dlg, SIGNAL(authenticateRequest(QString, int, int)), m_talker, SLOT(identify(QString, int, int)));
    connect(m_talker, SIGNAL(authenticated(bool)), m_dlg, SLOT(updateLabelAuthenticated(bool)));

    qmlView = 0;
    //reset();
}
void BatteryChargerCalibrate::on_commitButton_clicked()
{
    bool ok = channelUnit->programInformationBlock(channelUnit->getAdcPrecision(),
                                         0,false,
                                         channelUnit->getMulScaleFactor(),
                                         channelUnit->getOffScaleFactor());
    if (! ok) displayErrorMessage("Could not program device");
}
Пример #9
0
void mkFileNames(char ** (&argv), optFlags &opts, string &i_fn,string &o_fn,string &p_fn,
                 string &n_fn,string &c_fn,ScalarFieldType &cpt)
{
   //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   /*
      If you need more names to be created by this function, you need to add the new
      string in the arguments list here and in the corresponding header file.
    */
   //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   i_fn=string(argv[1]);
   size_t pos;
   //string sl="wfn";
   //pos=i_fn.find(sl);
   if (!((i_fn.find("wfn")!=string::npos)||
       (i_fn.find("WFN")!=string::npos)||
       (i_fn.find("wfx")!=string::npos)||
       (i_fn.find("WFX")!=string::npos))) {
      setScrRedBoldFont();
      cout << "\nError: the file " << i_fn << " is not a valid wave function file." << endl << endl;
      setScrNormalFont();
      exit(1);
   }
   o_fn=i_fn.substr(0,(i_fn.length()-3));
   p_fn=n_fn=c_fn=o_fn;
   o_fn.append("log");
   p_fn.append("pov");
   n_fn.append("png");
   c_fn.append("cpx");
   pos=o_fn.find_last_of('.');
   if (pos!=string::npos) {
      string plbl;
      switch (cpt) {
         case LOLD:
            plbl=string("LOLCP");
            break;
         case DENS:
            plbl=string("RhoCP");
            break;
         default:
            displayErrorMessage("Not implemented/unknown field type.");
            break;
      }
      o_fn.insert(pos,plbl);
      p_fn.insert(pos,plbl);
      n_fn.insert(pos,plbl);
      c_fn.insert(pos,plbl);
   }
   if (opts.outfname) {
      o_fn=argv[opts.outfname];
      p_fn=n_fn=c_fn=o_fn;
      o_fn.append(".log");
      p_fn.append(".pov");
      n_fn.append(".png");
      c_fn.append(".cpx");
   }
   return;
}
void DownloadUpdateDialog::handleSslErrors(QNetworkReply *reply, const QList<QSslError> &errors)
{
    QString errorString;
    for(int i = 0; i < errors.count(); i++)
    {
        errorString.append(errors.at(i).errorString() + ", ");
    }
    WARNING(tr("Got SSL errors while connecting to ") + reply->request().url().host() + "." + errorString);
    displayErrorMessage(tr("Got SSL errors while connecting to ") + reply->request().url().host() + "." + errorString);
}
Пример #11
0
QString ContentDisplay::generateFileMD5(QString fileName)
{
    QFile contentFile(fileName);
    if(!contentFile.open(QFile::ReadOnly)) {
        displayErrorMessage("Could not open content file: \n" + fileName);
        return QString("");
    }
    QString hashData(QCryptographicHash::hash(contentFile.readAll(), QCryptographicHash::Md5).toHex().constData());
    contentFile.close();

    return hashData;
}
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: senderStringWrote((*reinterpret_cast< QByteArray(*)>(_a[1]))); break;
        case 1: receiverStringWrote((*reinterpret_cast< QByteArray(*)>(_a[1]))); break;
        case 2: on_receiverRegexpReplaceRemove_clicked(); break;
        case 3: on_receiverRegexpReplaceAdd_clicked(); break;
        case 4: on_senderRegexpReplaceRemove_clicked(); break;
        case 5: on_senderRegexpReplaceAdd_clicked(); break;
        case 6: on_receiverRegexpBlockRemove_clicked(); break;
        case 7: on_receiverRegexpBlockAdd_clicked(); break;
        case 8: on_senderRegexpBlockRemove_clicked(); break;
        case 9: on_senderRegexpBlockAdd_clicked(); break;
        case 10: on_connectButton_toggled((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 11: on_receiverDeleteItemButton_clicked(); break;
        case 12: on_forwardOnlyButton_toggled((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 13: on_receiverFollowButton_toggled((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 14: on_senderFollowButton_toggled((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 15: on_receiverPassAllButton_toggled((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 16: on_senderPassAllButton_toggled((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 17: on_senderDeleteItemButton_clicked(); break;
        case 18: on_receiverPassResponseButton_clicked(); break;
        case 19: on_receiverMessageList_itemSelectionChanged(); break;
        case 20: on_senderPassRequestButton_clicked(); break;
        case 21: on_receiverSyntaxHighlightCombo_currentIndexChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 22: on_senderSyntaxHighlightCombo_currentIndexChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 23: on_receiverConnectionOptionGroup_toggled((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 24: on_senderConnectionOptionGroup_toggled((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 25: on_senderMessageList_itemSelectionChanged(); break;
        case 26: displayInfo(); break;
        case 27: displayHelp(); break;
        case 28: saveSession(); break;
        case 29: loadSession(); break;
        case 30: displayErrorMessage((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 31: senderStringRead((*reinterpret_cast< QByteArray(*)>(_a[1]))); break;
        case 32: receiverStringRead((*reinterpret_cast< QByteArray(*)>(_a[1]))); break;
        case 33: senderStringWrite((*reinterpret_cast< QByteArray(*)>(_a[1]))); break;
        case 34: receiverStringWrite((*reinterpret_cast< QByteArray(*)>(_a[1]))); break;
        case 35: senderConnectionReady(); break;
        case 36: receiverConnectionReady(); break;
        case 37: senderConnectionNotReady(); break;
        case 38: receiverConnectionNotReady(); break;
        default: ;
        }
        _id -= 39;
    }
    return _id;
}
Пример #13
0
void test_uartInit_should_throw_error_if_no_COMPORT_is_found_else_hSerial_shouldnt_null(void)
{
  CEXCEPTION_T err;
  void *hSerial = NULL;
  
  Try {
    uartInit(&hSerial);
    TEST_ASSERT_NOT_NULL(hSerial);
  } Catch(err) {
    displayErrorMessage(err);
    TEST_ASSERT_NULL(hSerial);
  }
}
void BatteryChargerCalibrate::on_firstValueSetButton_clicked()
{
    unsigned char s;
    unsigned char stateVariables[100];
    unsigned char item = (channelUnit->getChannel() << 1);
    bool ok = channelUnit->getUnit()->getStateVariables(0,stateVariables,s);
    firstSample = (stateVariables[item+1] << 8) + stateVariables[item];
    if (ok)
    {
        BatteryChargerCalibrateDialogueUi.secondValueSetButton->setEnabled(true);
        BatteryChargerCalibrateDialogueUi.firstValueSetButton->setEnabled(false);
        firstEntered = true;
    }
    if (! ok) displayErrorMessage("Could not read state measurement");
}
void DownloadUpdateDialog::downloadFinished(QNetworkReply *reply)
{
    if(reply->error() == QNetworkReply::NoError)
    {
        tmpFile->open(QIODevice::WriteOnly);
        tmpFile->write(reply->readAll());
        tmpFile->flush();
        tmpFile->close();
        INFO(tr("Successfully downloaded update"));
        ui->button_install->setEnabled(true);
        ui->button_install->setDefault(true);
    }else
    {
        WARNING(tr("Error while downloading update. ") + reply->errorString());
        displayErrorMessage(tr("Error while downloading update. ") + reply->errorString());
    }
}
Пример #16
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow)
    , _inProgress(false)
{
    // Preload icons for faster switching
    iconMicrophone = new QIcon(":/images/microphone.png");
    iconRecord = new QIcon(":/images/record.png");
    iconProcess = new QIcon(":/images/process.png");
    iconNetwork = new QIcon(":/images/network.png");

    connect(QApplication::desktop(), SIGNAL(resized(int)),
            this, SLOT(orientationChanged()));
#ifdef Q_WS_MAEMO_5
    setAttribute(Qt::WA_Maemo5StackedWindow);
    setAttribute(Qt::WA_Maemo5AutoOrientation);
#endif
    ui->setupUi(this);

    QAction * aboutAction = new QAction(tr("About EchoPrint"), this);
    connect(aboutAction, SIGNAL(triggered()), this, SLOT(on_echoNestButton_clicked()));

    ui->menuBar->addAction(aboutAction);


    nam = new QNetworkAccessManager(this);

    recorder = new RecorderMobility(this, DEFAULT_FILE);
    connect(recorder, SIGNAL(durationChanged(qint64)),
            this, SLOT(updateProgress(qint64)));
    connect(recorder, SIGNAL(error(QMediaRecorder::Error)),
            this, SLOT(displayErrorMessage()));

    connect(this, SIGNAL(captureFinished()), this, SLOT(processAudio()));
    connect(this, SIGNAL(resultReady(const EchoNestSong *)),
            this, SLOT(showResult(const EchoNestSong *)));

#ifdef USE_LIBECHONEST
    Echonest::Config::instance()->setAPIKey(API_KEY.toLatin1());
#endif

    timer = new QTimer(this);
    timer->setSingleShot(true);
    connect(timer, SIGNAL(timeout()), this, SLOT(stopCapture()));
}
void AllegroFlasher::reportSetupError(InitializationStatus status)
{
	switch (status)
	{
	case ALLEGRO_INITIALISATION_ERROR:
		displayErrorMessage("Failed to initialize Allegro!");
		break;
	case PRIMITIVES_ADDON_ERROR:
		displayErrorMessage("Failed to initialize primitives add-on!");
		break;
	case TTF_ADDON_ERROR:
		displayErrorMessage("Failed to initialize TTF add-on!");
		break;
	case KEYBOARD_ERROR:
		displayErrorMessage("Failed to install keyboard driver!");
		break;
	case MOUSE_ERROR:
		displayErrorMessage("Failed to install mouse driver!");
		break;
	case AUDIO_ERROR:
		displayErrorMessage("Failed to install audio driver!");
		break;
	case CODEC_ERROR:
		displayErrorMessage("Failed to install audio codecs!");
		break;
	case RESERVE_SAMPLES_ERROR:
		displayErrorMessage("Failed to reserve sampples!");
		break;
	case FONT_LOADING_ERROR:
		displayErrorMessage("A font could not be loaded! Make sure that you copy the 'data' directory with the font file to the directory containing your project file.");
		break;
	default:
		break;
		//should never reach here
	}
}
Пример #18
0
int Player::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: hideWindow(); break;
        case 1: open(); break;
        case 2: durationChanged((*reinterpret_cast< qint64(*)>(_a[1]))); break;
        case 3: positionChanged((*reinterpret_cast< qint64(*)>(_a[1]))); break;
        case 4: metaDataChanged(); break;
        case 5: previousClicked(); break;
        case 6: seek((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 7: jump((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 8: playlistPositionChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 9: statusChanged((*reinterpret_cast< QMediaPlayer::MediaStatus(*)>(_a[1]))); break;
        case 10: bufferingProgress((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 11: displayErrorMessage(); break;
        case 12: handleAspectRatio((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 13: handleStateChange((*reinterpret_cast< QMediaPlayer::State(*)>(_a[1]))); break;
        case 14: showPlayList(); break;
        case 15: hideOrShowCoverArt(); break;
        case 16: launchYoutubeDialog(); break;
        case 17: youtubeHttpRequestFinished((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< bool(*)>(_a[2]))); break;
        case 18: youtubeReadResponseHeader((*reinterpret_cast< const QHttpResponseHeader(*)>(_a[1]))); break;
        case 19: searchYoutubeVideo(); break;
        case 20: addYoutubeVideo(); break;
        case 21: handleAudioOutputDefault(); break;
        case 22: handleAudioOutputAll(); break;
        case 23: handleAudioOutputNone(); break;
        case 24: handleAudioOutputEarphone(); break;
        case 25: handleAudioOutputSpeaker(); break;
        case 26: handleAudioOutputChangedSignal((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 27;
    }
    return _id;
}
Пример #19
0
GrlMedia::GrlMedia(QWidget *parent) : QWidget(parent)
{
	m_brush.setStyle(Qt::SolidPattern);
	m_brush.setColor(Qt::black);
	setMouseTracking(true);

	playerState  = QMediaPlayer::StoppedState;
	m_isPlaying  = false;
	m_playIcon   = true;
	m_fullScreen = false;

	m_videoWidget = new MediaVideoWidget(this);
	m_videoWidget->setMinimumSize(100, 100);
	m_videoWidget->setFocusPolicy(Qt::NoFocus);
	m_videoWidget->hide();

	QVBoxLayout *videoLayout = new QVBoxLayout(this);
	videoLayout->addWidget(m_videoWidget);
	videoLayout->setSpacing(0);
	videoLayout->setContentsMargins(0, 0, 0, 0);
	this->setLayout(videoLayout);

	m_player = new QMediaPlayer(this);
	m_player->setVideoOutput(m_videoWidget);

	connect(m_player, SIGNAL(durationChanged(qint64)), SLOT(durationChanged(qint64)));
	connect(m_player, SIGNAL(positionChanged(qint64)), SLOT(positionChanged(qint64)));
	connect(m_player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(statusChanged(QMediaPlayer::MediaStatus)));
	connect(m_player, SIGNAL(bufferStatusChanged(int)), this, SLOT(bufferingProgress(int)));
	connect(m_player, SIGNAL(videoAvailableChanged(bool)), this, SLOT(videoAvailableChanged(bool)));
	connect(m_player, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(displayErrorMessage()));
	connect(m_player, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(setState(QMediaPlayer::State)));
	connect(m_player, SIGNAL(volumeChanged(int)), this, SIGNAL(volumeChanged(int)));
	connect(m_player, SIGNAL(mutedChanged(bool)), this, SIGNAL(mutedChanged(bool)));
	connect(m_player, SIGNAL(metaDataChanged()), this, SLOT(setMetaData()));

	emit isVideoVisible(false);
}
Пример #20
0
void TIGLViewerWindow::makeScreenShot()
{
    QString fileName = QFileDialog::getSaveFileName(this, tr("Save Screenshot"), myLastFolder,
                                                    tr("PNG-Image (*.png);;") +
                                                    tr("JPEG-Image (*.jpg);;") +
                                                    tr("Windows-BMP-Image (*.bmp)"));

    if (!fileName.isEmpty() && myOCC) {
        
        TIGLViewerScreenshotDialog dialog(fileName, this);
        dialog.setQualityValue(80);
        dialog.setImageSize(myOCC->width(), myOCC->height());
        if (dialog.exec() != QDialog::Accepted) {
            return;
        }
        
        int width, height;
        dialog.getImageSize(width, height);
        if (!myOCC->makeScreenshot(fileName, dialog.getWhiteBGEnabled(), width, height, dialog.getQualityValue())) {
            displayErrorMessage("Error saving screenshot.", "Error");
        }
    }
}
void BatteryChargerCalibrate::on_secondValueSetButton_clicked()
{
    unsigned char s;
    unsigned char stateVariables[100];
    unsigned char item = (channelUnit->getChannel() << 1);
    bool ok = channelUnit->getUnit()->getStateVariables(0,stateVariables,s);
    secondSample = (stateVariables[item+1] << 8) + stateVariables[item];
    if (ok)
    {
        BatteryChargerCalibrateDialogueUi.firstValueSetButton->setEnabled(false);
        BatteryChargerCalibrateDialogueUi.secondValueSetButton->setEnabled(false);
        BatteryChargerCalibrateDialogueUi.commitButton->setEnabled(true);
        float VL = (secondValue*firstSample - firstValue*secondSample)/((float)firstSample - (float)secondSample);
        float VHmVL = (firstValue - secondValue)/((float)firstSample - (float)secondSample)*(1 << channelUnit->getAdcPrecision());
        qDebug() << "Low" << VL << "High-Low" << VHmVL;
        BatteryChargerCalibrateDialogueUi.maximumLcdNumber->display(VHmVL+VL);
        BatteryChargerCalibrateDialogueUi.minimumLcdNumber->display(VL);
        channelUnit->setMulScaleFactor((unsigned int)(VHmVL*655.36));
        channelUnit->setOffScaleFactor((unsigned int)(VL*655.36));
        BatteryChargerCalibrateDialogueUi.commitButton->setEnabled(true);    
    }
    if (! ok) displayErrorMessage("Could not read state measurement");
}
/** @brief Constructor.

Check if the channel exists in the unit. If not, create a default entry.
We need to do this because the unit will not present any measurements until it
has a channel to work on.

@param u Acquisition Unit Object
@param parent Parent widget.
*/
BatteryChargerCalibrate::BatteryChargerCalibrate(AcqSimpleAdcUnit* u,
          QWidget* parent) : QDialog(parent)
{
    channelUnit = u;
// Create a dummy entry if necessary
    if (! channelUnit->isConfigured())
    {
        bool ok = channelUnit->programInformationBlock(DEFAULT_AD_PRECISION,0,false,0,0);
        if (! ok) displayErrorMessage("Could not program device with default channel");
    }
//! Build the User Interface display from Ui object.
    BatteryChargerCalibrateDialogueUi.setupUi(this);
    if (channelUnit->getChannel() == 0)
        BatteryChargerCalibrateDialogueUi.subTitle->setText("Panel Voltage");
    else if (channelUnit->getChannel() == 1)
        BatteryChargerCalibrateDialogueUi.subTitle->setText("Battery Voltage");
    else if (channelUnit->getChannel() == 2)
        BatteryChargerCalibrateDialogueUi.subTitle->setText("Panel Current");
    else if (channelUnit->getChannel() == 3)
        BatteryChargerCalibrateDialogueUi.subTitle->setText("Load Current");
    firstEntered = false;
// Blank out the buttons until some entries are made
    on_clearEntriesButton_clicked();
}
Пример #23
0
/* ************************************************************************************** */
void displayErrorMessage(const char* word)
{
   displayErrorMessage(std::string(word));
   return;
}
Пример #24
0
void TIGLViewerWindow::openFile(const QString& fileName)
{
    QString        fileType;
    QFileInfo    fileInfo;

    TIGLViewerInputOutput::FileFormat format;
    TIGLViewerInputOutput reader;
    bool triangulation = false;
    bool success = false;

    TIGLViewerScopedCommand command(getConsole());
    Q_UNUSED(command);
    statusBar()->showMessage(tr("Invoked File|Open"));

    if (!fileName.isEmpty()) {
        fileInfo.setFile(fileName);
        fileType = fileInfo.suffix();
        
        if (fileType.toLower() == tr("xml")) {
            TIGLViewerDocument* config = new TIGLViewerDocument(this);
            TiglReturnCode tiglRet = config->openCpacsConfiguration(fileInfo.absoluteFilePath());
            if (tiglRet != TIGL_SUCCESS) {
                delete config;
                return;
            }
            delete cpacsConfiguration;
            cpacsConfiguration = config;
            
            connectConfiguration();
            updateMenus();
            success = true;
        }
        else {

            if (fileType.toLower() == tr("brep")) {
                format = TIGLViewerInputOutput::FormatBREP;
            }
            if (fileType.toLower() == tr("step") || fileType.toLower() == tr("stp")) {
                format = TIGLViewerInputOutput::FormatSTEP;
            }
            if (fileType.toLower() == tr("iges") || fileType.toLower() == tr("igs")) {
                format = TIGLViewerInputOutput::FormatIGES;
            }
            if (fileType.toLower() == tr("stl")) {
                format = TIGLViewerInputOutput::FormatSTL;
            }
            if (fileType.toLower() == tr("mesh")) {
                format = TIGLViewerInputOutput::FormatMESH;
                triangulation = true;
            }
            if (triangulation) {
                success = reader.importTriangulation( fileInfo.absoluteFilePath(), format, *getScene() );
            }
            else {
                success = reader.importModel ( fileInfo.absoluteFilePath(), format, *getScene() );
            }
        }
        watcher = new QFileSystemWatcher();
        watcher->addPath(fileInfo.absoluteFilePath());
        QObject::connect(watcher, SIGNAL(fileChanged(QString)), openTimer, SLOT(start()));
        myLastFolder = fileInfo.absolutePath();
        if (success) {
            setCurrentFile(fileName);
            myOCC->viewAxo();
            myOCC->fitAll();
        }
        else {
            displayErrorMessage("Error opening file " + fileName, "Error");
        }
    }
}
Пример #25
0
/**
* Static method to handle error messages from messages from Artistic Style.
* This method is called only if there are errors when AStyleMain is called.
* This is for debugging and there should be no errors when the calling
* parameters are correct.
*
* @param  errorNumber   The error number from Artistic Style.
* @param  errorMessage  The error message from Artistic Style.
*/
void STDCALL AStyleInterface::errorHandler(int errorNumber, const char* errorMessage)
{   displayErrorMessage(string("astyle error "
                               + intToString(errorNumber)
                               + "\n" + errorMessage));
}
Пример #26
0
/* ************************************************************************************** */
void printFancyMemoryUsage(int memus_,std::string msg)
{
   if ( memus_<0 ) {displayErrorMessage("Memory usage cannot be negative!"); return;}
   else {printFancyMemoryUsage(size_t(memus_),msg);}
}
Пример #27
0
AudioRecorder::AudioRecorder(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::AudioRecorder),
    outputLocationSet(false)
{
    ui->setupUi(this);

    audioRecorder = new QAudioRecorder(this);
    probe = new QAudioProbe;
    connect(probe, SIGNAL(audioBufferProbed(QAudioBuffer)),
            this, SLOT(processBuffer(QAudioBuffer)));
    probe->setSource(audioRecorder);

    //audio devices
    ui->audioDeviceBox->addItem(tr("Default"), QVariant(QString()));
    foreach (const QString &device, audioRecorder->audioInputs()) {
        ui->audioDeviceBox->addItem(device, QVariant(device));
    }

    //audio codecs
    ui->audioCodecBox->addItem(tr("Default"), QVariant(QString()));
    foreach (const QString &codecName, audioRecorder->supportedAudioCodecs()) {
        ui->audioCodecBox->addItem(codecName, QVariant(codecName));
    }

    //containers
    ui->containerBox->addItem(tr("Default"), QVariant(QString()));
    foreach (const QString &containerName, audioRecorder->supportedContainers()) {
        ui->containerBox->addItem(containerName, QVariant(containerName));
    }

    //sample rate
    ui->sampleRateBox->addItem(tr("Default"), QVariant(0));
    foreach (int sampleRate, audioRecorder->supportedAudioSampleRates()) {
        ui->sampleRateBox->addItem(QString::number(sampleRate), QVariant(
                sampleRate));
    }

    //channels
    ui->channelsBox->addItem(tr("Default"), QVariant(-1));
    ui->channelsBox->addItem(QStringLiteral("1"), QVariant(1));
    ui->channelsBox->addItem(QStringLiteral("2"), QVariant(2));
    ui->channelsBox->addItem(QStringLiteral("4"), QVariant(4));

    //quality
    ui->qualitySlider->setRange(0, int(QMultimedia::VeryHighQuality));
    ui->qualitySlider->setValue(int(QMultimedia::NormalQuality));

    //bitrates:
    ui->bitrateBox->addItem(tr("Default"), QVariant(0));
    ui->bitrateBox->addItem(QStringLiteral("32000"), QVariant(32000));
    ui->bitrateBox->addItem(QStringLiteral("64000"), QVariant(64000));
    ui->bitrateBox->addItem(QStringLiteral("96000"), QVariant(96000));
    ui->bitrateBox->addItem(QStringLiteral("128000"), QVariant(128000));

    connect(audioRecorder, SIGNAL(durationChanged(qint64)), this,
            SLOT(updateProgress(qint64)));
    connect(audioRecorder, SIGNAL(statusChanged(QMediaRecorder::Status)), this,
            SLOT(updateStatus(QMediaRecorder::Status)));
    connect(audioRecorder, SIGNAL(stateChanged(QMediaRecorder::State)),
            this, SLOT(onStateChanged(QMediaRecorder::State)));
    connect(audioRecorder, SIGNAL(error(QMediaRecorder::Error)), this,
            SLOT(displayErrorMessage()));
}
Player::Player(QWidget *parent)
    : QWidget(parent)
    , videoWidget(0)
    , coverLabel(0)
    , slider(0)
#ifndef PLAYER_NO_COLOROPTIONS
    , colorDialog(0)
#endif
{
//! [create-objs]
    player = new QMediaPlayer(this);
    // owned by PlaylistModel
    playlist = new QMediaPlaylist();
    player->setPlaylist(playlist);
//! [create-objs]

    connect(player, SIGNAL(durationChanged(qint64)), SLOT(durationChanged(qint64)));
    connect(player, SIGNAL(positionChanged(qint64)), SLOT(positionChanged(qint64)));
    connect(player, SIGNAL(metaDataChanged()), SLOT(metaDataChanged()));
    connect(playlist, SIGNAL(currentIndexChanged(int)), SLOT(playlistPositionChanged(int)));
    connect(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
            this, SLOT(statusChanged(QMediaPlayer::MediaStatus)));
    connect(player, SIGNAL(bufferStatusChanged(int)), this, SLOT(bufferingProgress(int)));
    connect(player, SIGNAL(videoAvailableChanged(bool)), this, SLOT(videoAvailableChanged(bool)));
    connect(player, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(displayErrorMessage()));

//! [2]
    videoWidget = new VideoWidget(this);
    player->setVideoOutput(videoWidget);

    playlistModel = new PlaylistModel(this);
    playlistModel->setPlaylist(playlist);
//! [2]

    playlistView = new QListView(this);
    playlistView->setModel(playlistModel);
    playlistView->setCurrentIndex(playlistModel->index(playlist->currentIndex(), 0));

    connect(playlistView, SIGNAL(activated(QModelIndex)), this, SLOT(jump(QModelIndex)));

    slider = new QSlider(Qt::Horizontal, this);
    slider->setRange(0, player->duration() / SLIDER_DIVISOR);

    labelDuration = new QLabel(this);
    connect(slider, SIGNAL(sliderMoved(int)), this, SLOT(seek(int)));

    labelHistogram = new QLabel(this);
    labelHistogram->setText("Histogram:");
    histogram = new HistogramWidget(this);
    QHBoxLayout *histogramLayout = new QHBoxLayout;
    histogramLayout->addWidget(labelHistogram);
    histogramLayout->addWidget(histogram, 1);

    probe = new QVideoProbe(this);
    connect(probe, SIGNAL(videoFrameProbed(QVideoFrame)), histogram, SLOT(processFrame(QVideoFrame)));
    probe->setSource(player);

    QPushButton *openButton = new QPushButton(tr("Open"), this);

    connect(openButton, SIGNAL(clicked()), this, SLOT(open()));

    PlayerControls *controls = new PlayerControls(this);
    controls->setState(player->state());
    controls->setVolume(player->volume());
    controls->setMuted(controls->isMuted());

    connect(controls, SIGNAL(play()), player, SLOT(play()));
    connect(controls, SIGNAL(pause()), player, SLOT(pause()));
    connect(controls, SIGNAL(stop()), player, SLOT(stop()));
    connect(controls, SIGNAL(next()), playlist, SLOT(next()));
    connect(controls, SIGNAL(previous()), this, SLOT(previousClicked()));
    connect(controls, SIGNAL(changeVolume(int)), player, SLOT(setVolume(int)));
    connect(controls, SIGNAL(changeMuting(bool)), player, SLOT(setMuted(bool)));
    connect(controls, SIGNAL(changeRate(qreal)), player, SLOT(setPlaybackRate(qreal)));

    connect(controls, SIGNAL(stop()), videoWidget, SLOT(update()));

    connect(player, SIGNAL(stateChanged(QMediaPlayer::State)),
            controls, SLOT(setState(QMediaPlayer::State)));
    connect(player, SIGNAL(volumeChanged(int)), controls, SLOT(setVolume(int)));
    connect(player, SIGNAL(mutedChanged(bool)), controls, SLOT(setMuted(bool)));

    fullScreenButton = new QPushButton(tr("FullScreen"), this);
    fullScreenButton->setCheckable(true);

#ifndef PLAYER_NO_COLOROPTIONS
    colorButton = new QPushButton(tr("Color Options..."), this);
    colorButton->setEnabled(false);
    connect(colorButton, SIGNAL(clicked()), this, SLOT(showColorDialog()));
#endif

    QBoxLayout *displayLayout = new QHBoxLayout;
    displayLayout->addWidget(videoWidget, 2);
    displayLayout->addWidget(playlistView);

    QBoxLayout *controlLayout = new QHBoxLayout;
    controlLayout->setMargin(0);
    controlLayout->addWidget(openButton);
    controlLayout->addStretch(1);
    controlLayout->addWidget(controls);
    controlLayout->addStretch(1);
    controlLayout->addWidget(fullScreenButton);
#ifndef PLAYER_NO_COLOROPTIONS
    controlLayout->addWidget(colorButton);
#endif

    QBoxLayout *layout = new QVBoxLayout;
    layout->addLayout(displayLayout);
    QHBoxLayout *hLayout = new QHBoxLayout;
    hLayout->addWidget(slider);
    hLayout->addWidget(labelDuration);
    layout->addLayout(hLayout);
    layout->addLayout(controlLayout);
    layout->addLayout(histogramLayout);

    setLayout(layout);

    if (!player->isAvailable()) {
        QMessageBox::warning(this, tr("Service not available"),
                             tr("The QMediaPlayer object does not have a valid service.\n"\
                                "Please check the media service plugins are installed."));

        controls->setEnabled(false);
        playlistView->setEnabled(false);
        openButton->setEnabled(false);
#ifndef PLAYER_NO_COLOROPTIONS
        colorButton->setEnabled(false);
#endif
        fullScreenButton->setEnabled(false);
    }

    metaDataChanged();

    QStringList arguments = qApp->arguments();
    arguments.removeAt(0);
    addToPlaylist(arguments);
}
Пример #29
0
Player::Player(QWidget *parent)
    : QWidget(parent)
    , videoWidget(0)
    , coverLabel(0)
    , slider(0)
#ifndef PLAYER_NO_COLOROPTIONS
    , colorDialog(0)
#endif
	//, ioDevice(0)
{
//! [create-objs]
    player = new QMediaPlayer(this);
    // owned by PlaylistModel
//! [create-objs]

    connect(player, SIGNAL(durationChanged(qint64)), SLOT(durationChanged(qint64)));
    connect(player, SIGNAL(positionChanged(qint64)), SLOT(positionChanged(qint64)));
    connect(player, SIGNAL(metaDataChanged()), SLOT(metaDataChanged()));
    connect(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
            this, SLOT(statusChanged(QMediaPlayer::MediaStatus)));
    connect(player, SIGNAL(bufferStatusChanged(int)), this, SLOT(bufferingProgress(int)));
    connect(player, SIGNAL(videoAvailableChanged(bool)), this, SLOT(videoAvailableChanged(bool)));
    connect(player, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(displayErrorMessage()));

//! [2]
    videoWidget = new VideoWidget(this);
    player->setVideoOutput(videoWidget);
//! [2]

    slider = new QSlider(Qt::Horizontal, this);
    slider->setRange(0, player->duration() / 1000);

    labelDuration = new QLabel(this);
    connect(slider, SIGNAL(sliderMoved(int)), this, SLOT(seek(int)));
    
    //QPushButton *openButton = new QPushButton(tr("Open"), this);

    //connect(openButton, SIGNAL(clicked()), this, SLOT(open()));

    PlayerControls *controls = new PlayerControls(this);
    controls->setState(player->state());
    controls->setVolume(player->volume());
    controls->setMuted(controls->isMuted());

    connect(controls, SIGNAL(play()), player, SLOT(play()));
    connect(controls, SIGNAL(pause()), player, SLOT(pause()));
    connect(controls, SIGNAL(stop()), player, SLOT(stop()));
    connect(controls, SIGNAL(changeVolume(int)), player, SLOT(setVolume(int)));
    connect(controls, SIGNAL(changeMuting(bool)), player, SLOT(setMuted(bool)));
    connect(controls, SIGNAL(changeRate(qreal)), player, SLOT(setPlaybackRate(qreal)));

    connect(controls, SIGNAL(stop()), videoWidget, SLOT(update()));

    connect(player, SIGNAL(stateChanged(QMediaPlayer::State)),
            controls, SLOT(setState(QMediaPlayer::State)));
    connect(player, SIGNAL(volumeChanged(int)), controls, SLOT(setVolume(int)));
    connect(player, SIGNAL(mutedChanged(bool)), controls, SLOT(setMuted(bool)));

    fullScreenButton = new QPushButton(tr("FullScreen"), this);
    fullScreenButton->setCheckable(true);

#ifndef PLAYER_NO_COLOROPTIONS
    colorButton = new QPushButton(tr("Color Options..."), this);
    colorButton->setEnabled(false);
    connect(colorButton, SIGNAL(clicked()), this, SLOT(showColorDialog()));
#endif

    QBoxLayout *displayLayout = new QHBoxLayout;
    videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    displayLayout->addWidget(videoWidget, 2);

    QBoxLayout *controlLayout = new QHBoxLayout;
    controlLayout->setMargin(0);
    //controlLayout->addWidget(openButton);
    controlLayout->addStretch(1);
    controlLayout->addWidget(controls);
    controlLayout->addStretch(1);
    controlLayout->addWidget(fullScreenButton);
#ifndef PLAYER_NO_COLOROPTIONS
    controlLayout->addWidget(colorButton);
#endif

    QBoxLayout *layout = new QVBoxLayout;
    layout->addLayout(displayLayout);
    QHBoxLayout *hLayout = new QHBoxLayout;
    hLayout->addWidget(slider);
    hLayout->addWidget(labelDuration);
    layout->addLayout(hLayout);
    layout->addLayout(controlLayout);

    setLayout(layout);

    if (!player->isAvailable()) {
        QMessageBox::warning(this, tr("Service not available"),
                             tr("The QMediaPlayer object does not have a valid service.\n"\
                                "Please check the media service plugins are installed."));

        controls->setEnabled(false);
        //openButton->setEnabled(false);
#ifndef PLAYER_NO_COLOROPTIONS
        colorButton->setEnabled(false);
#endif
        fullScreenButton->setEnabled(false);
    }

    metaDataChanged();
}