Example #1
0
JabberPicture::JabberPicture(QWidget *parent, struct JabberUserData *data, JabberClient *client, bool bPhoto)
        : JabberPictureBase(parent)
{
    m_data   = data;
    m_client = client;
    m_bPhoto = bPhoto;
    tabPict->changeTab(tab, m_bPhoto ? i18n("&Photo") : i18n("&Logo"));
    if (m_data){
        edtPict->hide();
        btnClear->hide();
    }else{
        QString format = "*.bmp *.gif *.jpg *.jpeg";
#ifdef USE_KDE
        edtPict->setFilter(i18n("%1|Graphics") .arg(format));
#else
        edtPict->setFilter(i18n("Graphics(%1)") .arg(format));
        edtPict->setFilePreview(createPreview);
#endif
        edtPict->setReadOnly(true);
        connect(btnClear, SIGNAL(clicked()), this, SLOT(clearPicture()));
        connect(edtPict, SIGNAL(textChanged(const QString&)), this, SLOT(pictSelected(const QString&)));
        QString pict = m_bPhoto ? client->getPhoto() : client->getLogo();
        edtPict->setText(pict);
        pictSelected(pict);
    }
    fill();
}
ICQPicture::ICQPicture(QWidget *parent, struct ICQUserData *data, ICQClient *client)
        : QWidget( parent)
{
    setupUi( this);
    m_data   = data;
    m_client = client;
    if (m_data){
        edtPict->hide();
        btnClear->hide();
    }else{
        QString format = "*.bmp *.gif *.jpg *.jpeg";
#ifdef USE_KDE
        edtPict->setFilter(i18n("%1|Graphics") .arg(format));
#else
        edtPict->setFilter(i18n("Graphics(%1)") .arg(format));
        edtPict->setFilePreview(createPreview);
#endif
        edtPict->setReadOnly(true);
        connect(btnClear, SIGNAL(clicked()), this, SLOT(clearPicture()));
        connect(edtPict, SIGNAL(textChanged(const QString&)), this, SLOT(pictSelected(const QString&)));
        edtPict->setText(client->getPicture());
        pictSelected(client->getPicture());
    }
    fill();
}
Example #3
0
void QgsPhotoWidgetWrapper::setValue( const QVariant& value )
{
  if ( mLineEdit )
  {
    if ( value.isNull() )
    {
      whileBlocking( mLineEdit )->setText( QSettings().value( "qgis/nullValue", "NULL" ).toString() );
      clearPicture();
    }
    else
      mLineEdit->setText( value.toString() );
  }
  else
  {
    loadPixmap( value.toString() );
  }
}
Example #4
0
void QgsPhotoWidgetWrapper::loadPixmap( const QString& fileName )
{
  if ( fileName.isEmpty() )
  {
#ifdef WITH_QTWEBKIT
    if ( mWebView )
    {
      mWebView->setUrl( QString() );
    }
#endif
    clearPicture();
    return;
  }

  QString filePath = fileName;

  if ( QUrl( fileName ).isRelative() )
    filePath = QDir( QgsProject::instance()->fileInfo().absolutePath() ).filePath( fileName );

#ifdef WITH_QTWEBKIT
  if ( mWebView )
  {
    mWebView->setUrl( filePath );
  }
#endif

  QPixmap pm( filePath );
  if ( !pm.isNull() && mPhotoLabel )
  {
    QSize size( config( "Width" ).toInt(), config( "Height" ).toInt() );
    if ( size.width() == 0 && size.height() > 0 )
    {
      size.setWidth( size.height() * pm.size().width() / pm.size().height() );
    }
    else if ( size.width() > 0 && size.height() == 0 )
    {
      size.setHeight( size.width() * pm.size().height() / pm.size().width() );
    }

    if ( mPhotoPixmapLabel )
    {
      mPhotoPixmapLabel->setPixmap( pm );

      if ( size.width() != 0 || size.height() != 0 )
      {
        mPhotoPixmapLabel->setMinimumSize( size );
        mPhotoPixmapLabel->setMaximumSize( size );
      }
    }
    else // mPhotoLabel is checked in the outer if branch
    {
      mPhotoLabel->setMinimumSize( size );
      pm = pm.scaled( size, Qt::KeepAspectRatio, Qt::SmoothTransformation );
      mPhotoLabel->setPixmap( pm );
    }
  }
  else
  {
    clearPicture();
  }
}