Exemplo n.º 1
0
void VideoPlayerTool::initPlayer()
{
	fprintf(stderr, "[VideoPlayerT] %s:%d : initializing video codecs... FFMPEG version '"
			LIBAVCODEC_IDENT
			"'\n", __func__, __LINE__);

	m_fileVA = NULL;
	m_editBookmarksForm = NULL;
	playTimer = NULL;
	playSpeed = 1.f;
	playContinuous = false;

	QFileInfo fi(VideoFile);
	pWin->setCaption(tr("Movie:") + fi.fileName());

	// buttons
	chdir(":/images/pixmaps");

	playerVBox = new Q3VBox(pWin);
	playerVBox->resize(320, 266);

	playHBox = new Q3HBox(playerVBox);
	playHBox->setSpacing(1);

	rewindMovie = new QPushButton( playHBox);
	{
		QPixmap pixIcon;
		if(pixIcon.load(":/images/pixmaps/VcrRewind.png"))
			rewindMovie->setPixmap(pixIcon);
		else
			rewindMovie->setText(tr("Rewind"));
	}
	rewindMovie->setFlat(true);
	rewindMovie->setToggleButton(false);



	connect(rewindMovie, SIGNAL(clicked()), this, SLOT(slotRewindMovie()));


	QPushButton * stepBackMovie = new QPushButton( playHBox);
	{
		QPixmap pixIcon;
		if(pixIcon.load(":/images/pixmaps/VcrStepBackward.png"))
			stepBackMovie->setPixmap(pixIcon);
		else
			stepBackMovie->setText(tr("Back"));
	}
	stepBackMovie->setFlat(true);
	stepBackMovie->setToggleButton(false);
	connect(stepBackMovie, SIGNAL(clicked()), this, SLOT(slotStepBackwardMovie()));

	playMovie = new QPushButton( playHBox);
	{
		QPixmap pixIcon;
		if(pixIcon.load(":/images/pixmaps/VcrPlay.png"))
			playMovie->setPixmap(pixIcon);
		else
			playMovie->setText(tr("Play"));
	}
	playMovie->setFlat(true);
	playMovie->setToggleButton(false);
	connect(playMovie, SIGNAL(clicked()), this, SLOT(slotPlayPauseMovie()));

	stepMovie = new QPushButton( playHBox);
	{
		QPixmap pixIcon;
		if(pixIcon.load(":/images/pixmaps/VcrStepForward.png"))
			stepMovie->setPixmap(pixIcon);
		else
			stepMovie->setText(tr("Step"));
	}

	stepMovie->setFlat(true);
	stepMovie->setToggleButton(false);
	connect(stepMovie, SIGNAL(clicked()), this, SLOT(slotStepMovie()));

	playCombo = new QComboBox(playHBox);
	playCombo->insertItem("x 1/4", -1);
	playCombo->insertItem("x 1/2", -1);
	playCombo->insertItem("x 1", -1);
	playCombo->insertItem("x 2", -1);
	playCombo->insertItem("x 4", -1);
	playCombo->setCurrentItem(2);
	connect( playCombo, SIGNAL( activated( const QString &) ), this, SLOT( slotSpeedMovie( const QString & ) ) );

	// play as grayscale
	grayButton = new QPushButton( playHBox);
	{
		QPixmap pixIcon;
		if(pixIcon.load(":/images/pixmaps/:images/22x22/view-color.png"))
			grayButton->setPixmap(pixIcon);
		else
			grayButton->setText(tr("Rewind"));
	}
	grayButton->setFlat(true);
	grayButton->setToggleButton(true);
	QToolTip::add(grayButton, tr("Toggle grayscale/color"));
	playGrayscale = false;
	connect(grayButton, SIGNAL(toggled(bool)), this, SLOT(on_grayButton_toggled(bool)));


	// Scrollbar
	playScrollBar = new QSlider(Qt::Horizontal, playHBox);
	//playScrollBar->setOrientation( Qt::Horizontal );
	playScrollBar->setMinimum(0);
	playScrollBar->setPageStep(1);
	//playScrollBar->setRange(0, 100);
	playScrollBar->setMaximum(100);
	playScrollBar->setValue( 0 );
	playScrollBar->setTracking(false);

	connect(playScrollBar, SIGNAL(sliderReleased()), this, SLOT(slotReleaseScrollbar()));
	connect(playScrollBar, SIGNAL(valueChanged(int)), this, SLOT(slotChangedScrollbar(int)));




	// bookmarks button and menu
	buttonBookmarks = new QPushButton( playHBox);
	{
		QPixmap pixMap;
		if(pixMap.load(":/images/pixmaps/IconBookmark.png"))
			buttonBookmarks->setPixmap(pixMap);
		else
			buttonBookmarks->setText(tr("Bkmk"));
	}
	buttonBookmarks->setFlat(true);
	buttonBookmarks->setToggleButton(true);
	buttonBookmarks->setToolTip(tr("Bookmarks"));

	menuBookmarks = new QMenu(playHBox);
	buttonBookmarks->setPopup(menuBookmarks);

	// Append add and edit buttons
	QIcon pixIcon("IconBookmark.png");
	actAddBookmark = menuBookmarks->addAction(pixIcon, tr("Add"));
	actAddBookmark->setToolTip(tr("Add a bookmark at this position in movie"));
	actAddBookmark->setIconVisibleInMenu(true);

	QIcon editIcon("IconBookmarkEdit.png");
	actEditBookmark = menuBookmarks->addAction(editIcon, tr("Edit"));
	actEditBookmark->setIconVisibleInMenu(true);
	actEditBookmark->setToolTip(tr("Edit bookmarks list"));

	QIcon playIcon("IconBookmarkPlay.png");
	actPlayToBookmark = menuBookmarks->addAction(playIcon, tr("Play until bmrk"));
	actPlayToBookmark->setIconVisibleInMenu(true);
	actPlayToBookmark->setToolTip(tr("Play video until next bookmark"));

	menuBookmarks->addSeparator();

	connect(menuBookmarks, SIGNAL(triggered(QAction *)), this, SLOT(on_menuBookmarks_triggered(QAction *)));

	play_period_ms = 40; // 25 fps

	// image
	detailsImage = new WorkshopImage( "full size image" );
	detailsImage->QImage::create(320, 240, 32);

//	detailsView = new WorkshopImageTool( detailsImage, containerWorkshopImageTool,
	detailsView = new WorkshopImageTool( detailsImage, playerVBox,
										 true, // show snap button
										 true, // show record button
										 "FullsizeImageViewer", Qt::WA_DeleteOnClose //WDestructiveClose
										 );

	// This won't force the image to be on workspace because it already has a parent
	detailsView->setWorkspace((QWorkspace *)pWorkspace);
	detailsView->display()->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	detailsView->display()->update();

	connect(pWin, SIGNAL(signalResizeEvent(QResizeEvent *)), this, SLOT(slotResizeTool(QResizeEvent *)));
	pWin->resize(380,320);
}
QVariant ActivityTableModel::data(const QModelIndex &index, int role) const
{
  QSharedPointer<Activity> activity = activityAt(index.row());
  switch (role) {
    case Qt::DisplayRole:
      switch (index.column()) {
        case 0:
          if (activity->isUntimed()) {
            return QVariant();
          }
          return activity->startedAtHM();

        case 1:
          if (activity->isUntimed()) {
            return QVariant();
          }
          return s_timeSeparator;

        case 2:
          if (activity->isUntimed()) {
            return QVariant();
          }
          return activity->endedAtHM();

        case 3:
          return activity->name();

        case 4:
          return activity->projectName();

        case 5:
          /* Tags */
          return activity->tagNames();

        case 6:
          return activity->durationInWords();
      }
      break;

    case Qt::DecorationRole:
      switch (index.column()) {
        case 7:
          return editIcon();

        case 8:
          return trashIcon();
      }
      break;

    case Qt::TextAlignmentRole:
      switch (index.column()) {
        case 0:
        case 6:
          return (int) (Qt::AlignVCenter | Qt::AlignRight);
        case 2:
        case 3:
        case 4:
        case 5:
          return (int) (Qt::AlignVCenter | Qt::AlignLeft);
        default:
          return Qt::AlignCenter;
      }
      break;

    case Qt::ForegroundRole:
      if (index.column() == 4) {
        return Qt::gray;
      }
      break;

    default:
      break;
  }
  return QVariant();
}