Esempio n. 1
0
bool PlasmaPreview::loadPlasmaPreview()
{
    if( isPlasmaPreviewShown() ) {
        return true;
    }

    // Add the desktop containment
    m_containment = m_corona.addContainment( "desktop" );
    if( !m_containment ) {
        KMessageBox::information( this, i18nc("@info", "The plasma desktop containment could not "
                                              "be added. Ensure that you have plasma installed.") );
        return false;
    }
    QGraphicsScene *oldScene = scene();
    setScene( m_containment->scene() );
    setSceneRect( m_containment->geometry() );
    oldScene->deleteLater();

    // Add the PublicTransport applet
    m_applet = m_containment->addApplet( "publictransport" );
    if( !m_applet ) {
        delete m_containment;
        m_containment = 0;
        KMessageBox::information( this, i18nc("@info", "The PublicTransport applet could not be "
                                              "added. Ensure that you have it installed.") );
        return false;
    }
    m_applet->setFlag( QGraphicsItem::ItemIsMovable, false );
    setAlignment( Qt::AlignLeft | Qt::AlignTop );
    return true;
}
void DREAM3DGraphicsView::loadBaseImageFile(const QString& filename)
{
  m_BaseImage = QImage(filename);
  if (m_BaseImage.isNull() == true)
  {
    return;
  }
  QSize pSize(0, 0);
  pSize = m_BaseImage.size();

  m_OverlayImage = m_BaseImage;
  m_CompositedImage = m_BaseImage;

  QVector<QRgb > colorTable(256);
  for (quint32 i = 0; i < 256; ++i)
  {
    colorTable[i] = qRgb(i, i, i);
  }
  m_BaseImage.setColorTable(colorTable);

  if (m_BaseImage.isNull() == true)
  {
    std::cout << "Base Image was NULL for some reason. Returning" << std::endl;
    return;
  }
  QGraphicsScene* gScene = scene();
  if (gScene == NULL)
  {
    gScene = new QGraphicsScene(this);
    setScene(gScene);
  }
  else
  {

    setScene(NULL);
    gScene->deleteLater();
    gScene = new QGraphicsScene(this);
    setScene(gScene);

    delete m_ImageGraphicsItem;
    m_ImageGraphicsItem = NULL;
  }
  if (NULL == m_ImageGraphicsItem)
  {
    QImageReader reader(filename);
    QPixmap pixmap = QPixmap::fromImageReader(&reader, 0);
    m_ImageGraphicsItem = gScene->addPixmap(pixmap);
  }
  m_ImageGraphicsItem->setAcceptDrops(true);
  m_ImageGraphicsItem->setZValue(-1);


  QRectF rect = m_ImageGraphicsItem->boundingRect();
  gScene->setSceneRect(rect);
  centerOn(m_ImageGraphicsItem);
  this->updateDisplay();
  emit fireBaseImageFileLoaded(filename);
}