Example #1
0
void PlayerLabel::setData(const QPixmap& icon, const QString& text)
{
    m_icon->setPixmap(icon.scaledToHeight(15, Qt::FastTransformation));
    m_name->setText(text);

    update();
}
void MathMainWindow::loadFromFile()
{
    QString fileName = QFileDialog::getOpenFileName(this,
        tr("Open a picture"), "",
        tr("All picture files (*)"));

    if (fileName.isEmpty())
        return;
    else {
        QFile file(fileName);
        if (!file.open(QIODevice::ReadOnly)) {
            QMessageBox::information(this, tr("Unable to open file"),
                file.errorString());
            return;
        }

		IplImage *image;
		const QByteArray text = fileName.toLocal8Bit();
		const char *data = text.data();
		image = cvLoadImage(data);
		c1->execute(image);

		QPixmap mp;
		mp.load(fileName);;
		label->setPixmap(mp.scaledToHeight(150));
		submitButton->setEnabled(true);
    }
}
Example #3
0
QPixmap SelectedObject::getImgCrop(
    shared_ptr<AnnotatorLib::Annotation> annotation, int size) const {
  // TODO: getImage changes position, this is an unexpected behaviour...
  // START ugly hack
  // long prev_pos = project->getImageSet()->getPosition();
  cv::Mat tmp = project->getImageSet()->getImage(
      annotation->getFrame()->getFrameNumber());
  // project->getImageSet()->gotoPosition(prev_pos);
  // END ugly hack

  float x = std::max(annotation->getX(), 0.f);
  float y = std::max(annotation->getY(), 0.f);
  float w = std::min(annotation->getWidth(), tmp.cols - x);
  float h = std::min(annotation->getHeight(), tmp.rows - y);

  cv::Rect rect(x, y, w, h);

  cv::Mat cropped;
  try {
    tmp(rect).copyTo(cropped);
  } catch (cv::Exception &e) {
    std::cout << e.what();
  }

  cropped.convertTo(cropped, CV_8U);
  cv::cvtColor(cropped, cropped, CV_BGR2RGB);

  QImage img((const unsigned char *)(cropped.data), cropped.cols, cropped.rows,
             cropped.step, QImage::Format_RGB888);

  QPixmap pim = QPixmap::fromImage(img);
  pim = pim.scaledToHeight(size);
  return pim;
}
Example #4
0
HRESULT PlaybackControls::LoadFile()
{
	QPixmap picture;
	picture = getPicture(mFile);
	if (!picture.isNull())
	{
		mpParentWindow->id3Art->setPixmap(picture.scaledToHeight(128));
	}

	HRESULT hr = 0;
	if (!mpGraph)
	{
		if (FAILED(hr = InitialiseFilterGraph()))
			return hr;
	}

	if (!mGraphValid)
	{
		hr = mpGraph->RenderFile(mFile.toStdWString().c_str(), NULL);
		if (SUCCEEDED(hr))
		{
			QString metadata = getArtist(mFile);
			mpParentWindow->artistLabel->setText("Artist : " + metadata);
			metadata = getAlbum(mFile);
			mpParentWindow->albumLabel->setText("Album : " + metadata);
			metadata = getTitle(mFile);
			mpParentWindow->titleLabel->setText("Title : " + metadata);
			mGraphValid = true;
			setVolume(mVolume);
			emit volumeChanged(mVolume);
		}
		return hr;
	}
	return S_OK;
}
Example #5
0
void ImageDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    QStyledItemDelegate::paint(painter,option, index);
    QString filename = index.data().toString();

    if(filename != "")
    {
        QStyleOptionViewItemV4 options = option;
        initStyleOption(&options, index);

        QImage image(filename);
        if (image.isNull())
            return;

        painter->save();
        QSize imageSize = options.icon.actualSize(options.rect.size());
        imageSize.scale(imageSize.width(), imageSize.height(), Qt::KeepAspectRatioByExpanding);

        painter->translate(options.rect.left() + imageSize.width(), options.rect.top());

        QPixmap pix = QPixmap::fromImage(image);
        pix = pix.scaledToHeight(options.rect.height(), Qt::SmoothTransformation);
        if (pix.width() > options.rect.width())
            pix = pix.scaledToWidth(options.rect.width(), Qt::SmoothTransformation);

        painter->drawPixmap(0,0,pix);

        painter->restore();
    }

}
Example #6
0
QPixmap Data::getPixmap(QString name, int height)
{
    QDirIterator it(appFolder->absolutePath(),QDir::Files,QDirIterator::Subdirectories);
    QPixmap pixi;
    QString pixiPath;
    bool gefunden = false;

    while(it.hasNext())
    {
        QString path = it.next();
        if(path.contains(name.toLower() + ".png") || path.contains(name + ".png"))
        {
            if(gefunden)
            {
                qDebug() << "Die Bilddatei " + name + ".png wurde mehrfach gefunden.";
                qDebug() << "Fundort 1: " + pixiPath;
                qDebug() << "Fundort 2: " + path;
            }
            else
                pixiPath = path;
            if(pixi.load(path))
            {
                pixi = pixi.scaledToHeight(height);
            }

            gefunden = true;
        }
    }
    return pixi;
}
void MovieTickets::on_edit_image_clicked(){
	QString image_name(this->window.edit_image_lineEdit->text());
	
	QPixmap* image;
	if(image_name.length() > 0){
		QString image_full_path(this->image_path);
		image_full_path.append(image_name);

		image = new QPixmap(image_full_path);

		if(image->isNull()){
			image = new QPixmap("..\\Data\\Images\\no_movie.jpg");
		}
	}
	else{
		image = new QPixmap("..\\Data\\Images\\no_movie.jpg");
	}
	
	QPixmap aux = image->scaledToWidth(this->window.edit_image_label->width());

	if(aux.height() > this->window.edit_image_label->height()){
		aux = image->scaledToHeight(this->window.edit_image_label->height());
	}

	this->window.edit_image_label->setPixmap(aux);
}
void PropertiesDialog::setMultipleCover()
{
	ComicDB lastComic = comics.last();
	QPixmap last = lastComic.info.getCover(basePath);
	last = last.scaledToHeight(444,Qt::SmoothTransformation);

	coverImage = QPixmap::fromImage(blurred(last.toImage(),QRect(0,0,last.width(),last.height()),15));
}
Example #9
0
void ThumbnailLabel::paintEvent(QPaintEvent *event)
{
   int w = width();
   int h = height();
   QStyleOption o;
   QPainter p;

   event->accept();

   o.initFrom(this);
   p.begin(this);
   style()->drawPrimitive(
     QStyle::PE_Widget, &o, &p, this);
   p.end();

   if (!m_pixmap || m_pixmap->isNull())
   {
      m_pixmap = new QPixmap(sizeHint());
      m_pixmap->fill(QColor(0, 0, 0, 0));
   }

   if (w > 0 && h > 0 && m_pixmap && !m_pixmap->isNull())
   {
      int newHeight = (m_pixmap->height() / static_cast<float>(m_pixmap->width())) * width();
      QPixmap pixmapScaled = *m_pixmap;
      QPixmap pixmap;
      QPainter pScale;
      int pw = 0;
      int ph = 0;
      unsigned *buf = new unsigned[w * h];

      if (newHeight > h)
         pixmapScaled = pixmapScaled.scaledToHeight(h, Qt::SmoothTransformation);
      else
         pixmapScaled = pixmapScaled.scaledToWidth(w, Qt::SmoothTransformation);

      pw = pixmapScaled.width();
      ph = pixmapScaled.height();

      pixmap = QPixmap(w, h);
      pixmap.fill(QColor(0, 0, 0, 0));

      pScale.begin(&pixmap);
      pScale.drawPixmap(QRect((w - pw) / 2, (h - ph) / 2, pw, ph), pixmapScaled, pixmapScaled.rect());
      pScale.end();

      if (!pixmap.isNull())
      {
         p.begin(this);
         p.drawPixmap(rect(), pixmap, pixmap.rect());
         p.end();
      }

      delete []buf;
   }
   else
      QWidget::paintEvent(event);
}
void MainWindow::setImg()
{
    if(!this->imgdir.dirExist || this->imgdir.fileList.length() == 0)
    {
        QPixmap empty;
        ui->imgLabel->setPixmap(empty);

        if(!this->imgdir.dirExist)
            ui->imgLabel->setText("Path is invalid, is not a directory?");
        else
            ui->imgLabel->setText("Couldn't find any image in the directory");
        return;
    }

    // in case index is outbounds, should not happen
    if(index > imgdir.fileList.count())
        return;

    QString temp = imgdir.dir.absoluteFilePath(imgdir.fileList.value(index));
    dbg << imgdir.fileList.value(index).toStdString().c_str() << std::endl;
    dbg << temp.toStdString().c_str() << std::endl;
    dbg << index << std::endl;
    QPixmap imgtemp;
    imgtemp.load(temp.toStdString().c_str());

    if(scaleImg)
    {
        if(imgtemp.height() > program_settings.retrive_as_int(MAX_HEIGHT_SETT))
            imgtemp = imgtemp.scaledToHeight(
                        program_settings.retrive_as_int(MAX_HEIGHT_SETT),
                        Qt::SmoothTransformation);
        if(imgtemp.width() > program_settings.retrive_as_int(MAX_WIDTH_SETT))
            imgtemp = imgtemp.scaledToWidth(
                        program_settings.retrive_as_int(MAX_WIDTH_SETT),
                        Qt::SmoothTransformation);

    }

    if(temp.endsWith(".gif",Qt::CaseInsensitive) ||
            temp.endsWith(".webm",Qt::CaseInsensitive)) // not yet support for webm
    {
        QMovie *movie = new QMovie(temp.toStdString().c_str());
        ui->imgLabel->setMovie(movie);
        movie->start();
        dbg << "movie" << std::endl;
    }else
    {
        ui->imgLabel->setPixmap(imgtemp);
    }

    adjustScrollArea();

    imgdir.saveIndex(imgdir.buildPath(
                         program_settings.retrive(DIR1_SETT),"i.txt").c_str(),
                         index);
   updateFileName();
   coutdebug();
}
Example #11
0
QPixmap MovieLabel::scaledPixmap(const QPixmap& pix)
{
    if (pix.isNull())
        return pix;
    if (pix.width()/(double)width() < pix.height()/(double)height())
        return pix.scaledToHeight(height());
    else
        return pix.scaledToWidth(width());
}
Example #12
0
QIcon IndigoTabbar::rotateIcon(const QIcon &icon, TabPosition tabPos){

    QSize sz;

    for (int var = 0; var < icon.availableSizes().count(); ++var) {
        if (icon.availableSizes().at(var).width() > sz.width())
        sz = icon.availableSizes().at(var);
    }
    QPixmap pix = icon.pixmap(sz);
    QTransform trans;

    switch(this->tabPosition()){
    case QTabWidget::East:{
        switch(tabPos){
            case QTabWidget::West:{
                trans.rotate(180);
                break;
            }
            case QTabWidget::North:{
                trans.rotate(-90);
                break;
            }
            default:
                break;
        }


        break;
    }
    case QTabWidget::West:{
        switch(tabPos){

            case QTabWidget::East:{
                trans.rotate(180);
                break;
            }
            case QTabWidget::North:{
                trans.rotate(+90);
                break;
            }
            default:
                break;
        }
        break;
    }
    default:
        break;
    }

    pix = pix.transformed(trans);
    pix = pix.scaledToWidth( iconScale );
    pix = pix.scaledToHeight( iconScale );
    return QIcon(pix);
}
Example #13
0
void DetailView::onImageLoaded()
{
    QPixmap pic;
    pic.loadFromData(reply->readAll());
    if (pic.height() > 300)
        pic = pic.scaledToHeight(300, Qt::SmoothTransformation);
    reply->deleteLater();
    reply = NULL;
    ui->picLabel->setPixmap(pic);
    ui->picLabel->setFixedSize(pic.size());
}
Example #14
0
void StatusScreen::RefreshLayout()
{
    Builds builds = m_builders->builds();
    int nCount = builds.count();
    if (nCount == 0)
        return;


    if (m_discoveredBuilds != nCount)
    {
        m_discoveredBuilds = nCount;
        m_DisplayLines.clear();
        m_Icons.clear();

        m_lineHeight = (height()-14* nCount) / nCount;

        QVBoxLayout * layout = new QVBoxLayout();
        for (int i=0; i<nCount; i++)
        {
            QHBoxLayout * line = new QHBoxLayout();
            QPixmap image;
            Build::TARGET_OS os = builds.at(i)->Target();
            switch (os)
            {
                case Build::Windows: image = QPixmap(":/resources/windows-logo.png"); break;
                case Build::Mac: image = QPixmap(":/resources/osx_logo.jpg"); break;
                case Build::Linux: image = QPixmap(":/resources/linux-logo.jpg"); break;
                default: image = QPixmap(":/resources/undefined.png");
            }

            QLabel * label = new QLabel(this);
            QPixmap scaled = image.scaledToHeight(m_lineHeight);

            label->setPixmap(scaled);
            label->resize(50, 50);
            line->addWidget(label);

            QLineEdit * pEdit = new QLineEdit(this);
            pEdit->setReadOnly(true);
            m_DisplayLines.push_back(pEdit);
            m_Icons.push_back(label);
            line->addWidget(pEdit);

            layout->addLayout(line);
        }
        m_mainWindow = new QWidget(this);
        m_mainWindow->setStyleSheet("QWidget {  background: white;}");
        m_mainWindow->setLayout(layout);
        setCentralWidget(m_mainWindow);

        InitDisplayMessage();
    }
 }
Example #15
0
/*
 * Sets up the profile for alias and initializes wallDialog and friendDialog.
 */
void Facepamphlet::loginAlias(QString alias) {
    // Setup profile image
    QString profileImageSource = ":/images_section/";
    if(alias.compare("Cheryl/Carol/Cristal") == 0) {
        profileImageSource += "cheryl";
    }
    else if(alias.compare("Lana Kain") == 0) {
        profileImageSource += "lana";
    }
    else {
        profileImageSource += alias.toLower();
    }
    QPixmap image = QPixmap(profileImageSource);
    profileIcon->setPixmap(image.scaledToHeight(std::min(200, image.height())));
    
    // Setup selfInfo
    selfInfo.image = QIcon(profileImageSource);
    selfInfo.alias = alias;

    // Setup visual layout settings for wallPostList
    wallPostList->setIconSize(QSize(50,50));
    wallPostList->setSpacing(1);
    wallPostList->setWordWrap(true);

    // Setup visual layout settings for wallPostList
    friendsList->setIconSize(QSize(50,50));

    // Initialize dialogs
    // Initialize the wallDialog (for posts to wall by friends)
    wallDialog = new WallDialog;
    // Initialize the friendsDialog (for adding friends)
    friendDialog = new FriendDialog(alias);    

    // Setup connections
    connect(selfPostButton, SIGNAL(clicked()), this, SLOT(selfWallPost()));
    connect(friendRemoveButton, SIGNAL(clicked()), this, SLOT(friendRemove()));
    connect(friendAddButton, SIGNAL(clicked()), this, SLOT(showFriendDialog()));
    connect(friendWallButton, SIGNAL(clicked()), this, SLOT(showWallDialog()));
    // Connect with friendDialog
    connect(this, SIGNAL(setDefaults()), friendDialog, SLOT(addDefaultFriends()));
    connect(friendDialog, SIGNAL(addFriend(friendInfo)), this, SLOT(friendAdded(friendInfo)));
    connect(this, SIGNAL(friendRemoved(friendInfo)), friendDialog, SLOT(friendRemoved(friendInfo)));
    // Connect with wallDialog
    connect(this, SIGNAL(friendRemoved(friendInfo)), wallDialog, SLOT(friendRemoved(friendInfo)));
    connect(friendDialog, SIGNAL(addFriend(friendInfo)), wallDialog, SLOT(friendAdded(friendInfo)));

    // Emit signal to cause friendDialog to add a few default friends
    emit setDefaults();

    // Show main window
    show();
}
Example #16
0
void ComboBox::paintEvent( QPaintEvent * _pe )
{
	QPainter p( this );

	p.fillRect( 2, 2, width()-2, height()-4, *s_background );

	QColor shadow = palette().shadow().color();
	QColor highlight = palette().highlight().color();

	shadow.setAlpha( 124 );
	highlight.setAlpha( 124 );

	// button-separator
	p.setPen( shadow );
	p.drawLine( width() - CB_ARROW_BTN_WIDTH - 1, 1, width() - CB_ARROW_BTN_WIDTH - 1, height() - 3 );

	p.setPen( highlight );
	p.drawLine( width() - CB_ARROW_BTN_WIDTH, 1, width() - CB_ARROW_BTN_WIDTH, height() - 3 );

	// Border
	QStyleOptionFrame opt;
	opt.initFrom( this );
	opt.state = 0;

	style()->drawPrimitive( QStyle::PE_Frame, &opt, &p, this );

	QPixmap * arrow = m_pressed ? s_arrowSelected : s_arrow;

	p.drawPixmap( width() - CB_ARROW_BTN_WIDTH + 5, 4, *arrow );

	if( model() && model()->size() > 0 )
	{
		p.setFont( font() );
		p.setClipRect( QRect( 4, 2, width() - CB_ARROW_BTN_WIDTH - 8, height() - 2 ) );
		QPixmap pm = model()->currentData() ?  model()->currentData()->pixmap() : QPixmap();
		int tx = 5;
		if( !pm.isNull() )
		{
			if( pm.height() > 16 )
			{
				pm = pm.scaledToHeight( 16, Qt::SmoothTransformation );
			}
			p.drawPixmap( tx, 3, pm );
			tx += pm.width() + 3;
		}
		const int y = ( height()+p.fontMetrics().height() ) /2;
		p.setPen( QColor( 64, 64, 64 ) );
		p.drawText( tx+1, y-3, model()->currentText() );
		p.setPen( QColor( 224, 224, 224 ) );
		p.drawText( tx, y-4, model()->currentText() );
	}
}
Example #17
0
//Muestra la imagen central
void FicherosConf::MuestraImagen(QPixmap Imagen){
	QString dummy;
	//Escalo y muestro imagen central 
	QPixmap dummy2=Imagen.scaledToHeight(IMG_CENTRAL_SIZE);
	m_Imagen->setPixmap((QPixmap)(dummy2));
	m_Texto->setFont(QFont( "Arial", QFONT10, QFont::Bold ));
	dummy.append("- CARGAR CONFIGURACIÓN\n");
	dummy.append("Cargar los datos existentes en un fichero de configuración\n\n");
	dummy.append("- GUARDAR CONFIGURACIÓN\n");
	dummy.append("Guardar los datos existentes en un fichero de configuración\n\n");
	m_Texto->setText(dummy);
	m_Texto->show();
}
Example #18
0
QString VPreviewManager::imageResourceName(const ImageLinkInfo &p_link)
{
    // Add size info to the name.
    QString name = QString("%1_%2_%3").arg(p_link.m_linkShortUrl)
                                      .arg(p_link.m_width)
                                      .arg(p_link.m_height);
    if (m_editor->containsImage(name)) {
        return name;
    }

    // Add it to the resource.
    QPixmap image;
    QString imgPath = p_link.m_linkUrl;
    if (QFileInfo::exists(imgPath)) {
        // Local file.
        image = VUtils::pixmapFromFile(imgPath);
    } else {
        // URL. Try to download it.
        m_downloader->download(imgPath);
        m_urlToName.insert(imgPath, name);
    }

    if (image.isNull()) {
        return QString();
    }

    // Resize the image.
    Qt::TransformationMode tMode = Qt::SmoothTransformation;
    qreal sf = VUtils::calculateScaleFactor();
    if (p_link.m_width > 0) {
        if (p_link.m_height > 0) {
            m_editor->addImage(name, image.scaled(p_link.m_width * sf,
                                                  p_link.m_height * sf,
                                                  Qt::IgnoreAspectRatio,
                                                  tMode));
        } else {
            m_editor->addImage(name, image.scaledToWidth(p_link.m_width * sf, tMode));
        }
    } else if (p_link.m_height > 0) {
        m_editor->addImage(name, image.scaledToHeight(p_link.m_height * sf, tMode));
    } else {
        if (sf < 1.1) {
            m_editor->addImage(name, image);
        } else {
            m_editor->addImage(name, image.scaledToWidth(image.width() * sf, tMode));
        }
    }

    return name;
}
Example #19
0
void
BasicHeader::setPixmap( const QPixmap& pixmap, bool tinted )
{
    QFontMetrics fm( ui->captionLabel->font() );
    ui->iconLabel->setFixedHeight( fm.ascent() );

    QPixmap p = pixmap;
    if ( tinted )
        p = TomahawkUtils::tinted( p, Qt::white );
    ui->iconLabel->setPixmap( p.scaledToHeight( ui->iconLabel->height(), Qt::SmoothTransformation ) );

    if ( !p.isNull() )
        ui->iconLabel->show();
}
Example #20
0
ContactItemWidget::ContactItemWidget(const Contact * contact, bool displayPhoto, QWidget *parent)
 : QWidget(parent)
{
   if(!contact->getNickName().isEmpty()) {
      contactName = new QLabel(contact->getNickName());
   }
   else {
      contactName = new QLabel(contact->getFirstName());
   }
   if(displayPhoto) {
      if(!contact->getPhoto()->isEmpty()) {
         QPixmap pixmap;
         if(contact->getPhoto()->isIntern()) {
            contactPhoto = new QLabel();
            pixmap = QPixmap::fromImage(contact->getPhoto()->data());
         }
         else {
            contactPhoto = new QLabel();
            pixmap = QPixmap(contact->getPhoto()->url());
         }
         if(pixmap.height() > pixmap.width())
            contactPhoto->setPixmap(pixmap.scaledToHeight(CONTACT_ITEM_HEIGHT-4));
         else
            contactPhoto->setPixmap(pixmap.scaledToWidth(CONTACT_ITEM_HEIGHT-4));
      }
      else {
         contactPhoto = new QLabel();
         contactPhoto->setMinimumSize(CONTACT_ITEM_HEIGHT-4, 0);
      }
   }
   contactType = new QLabel(PhoneNumber::typeLabel(contact->getType()));
   contactNumber = new QLabel(contact->getPhoneNumber());
   QSpacerItem * horizontalSpacer = new QSpacerItem(16777215, 20, QSizePolicy::Preferred, QSizePolicy::Minimum);
   QHBoxLayout * hlayout = new QHBoxLayout(this);
   QVBoxLayout * vlayout = new QVBoxLayout();
   hlayout->setMargin(1);
   hlayout->setSpacing(4);
   vlayout->setMargin(1);
   vlayout->setSpacing(2);
   vlayout->addWidget(contactName);
   vlayout->addWidget(contactNumber);
   if(displayPhoto) {
      hlayout->addWidget(contactPhoto);
   }
   hlayout->addLayout(vlayout);
   hlayout->addItem(horizontalSpacer);
   hlayout->addWidget(contactType);
   this->setLayout(hlayout);
}
Example #21
0
PlayerLabel::PlayerLabel(const QPixmap& icon, const QString& text,
    KGameCanvasAbstract* parent)
: KGameCanvasGroup(parent)
{
    m_icon = new KGameCanvasPixmap(icon.scaledToHeight(15, Qt::FastTransformation),
                                   this);
    m_icon->show();

    QFont font;
    font.setPixelSize(15);
    m_name = new KGameCanvasText(text, Qt::black, font,
                                 KGameCanvasText::HLeft,
                                 KGameCanvasText::VTop, this);
    m_name->show();
}
void TopPatchesWidget<TImage>::SetTargetRegion(const itk::ImageRegion<2>& targetRegion)
{
  this->TargetRegion = targetRegion;
  
  QImage patchImage = ITKQtHelpers::GetQImageColor(this->Image, targetRegion);

  QPixmap pixmap = QPixmap::fromImage(patchImage);
  //std::cout << "Set target patch display height to: "
  //          << this->gfxTargetPatch->size().height() << std::endl;
  pixmap = pixmap.scaledToHeight(this->gfxTargetPatch->size().height());

  this->TargetPatchScene = new QGraphicsScene();
  this->gfxTargetPatch->setScene(TargetPatchScene);

  this->TargetPatchScene->addPixmap(pixmap);
}
void ImageDisplayDialog::setPixmap(const QPixmap &image)
{
    if (! started)
    {
        started = true;
        myTimer.restart();
        overallTimer.restart();
        oldtitle = this->windowTitle();
        images = 0;
        cimages = 0;
    }

#ifdef RESIZEME
    QSize s = image.size();
    int maxval = 768;

    if ( s.width() > s.height())
        ui->label->setPixmap( image.scaledToWidth(maxval) );
    else
        ui->label->setPixmap (image.scaledToHeight(maxval) );
#else
    ui->label->setPixmap(image);
#endif

    images++;
    cimages++;

    if (images % 10 == 0)
    {
        QString fps;
        int time = myTimer.elapsed();
        int ctime = 1;
        if (time == 0)
            time = 1;

        if ( overallTimer.elapsed() > 2000 )
        {
            ctime = overallTimer.elapsed();
            fpsstr.sprintf("%5.2f", cimages * 1000.0 / ctime);
            cimages = 0;
            overallTimer.restart();
        }
        fps.sprintf(" - %s FPS - %d seconds running - %d images captured ", fpsstr.toStdString().c_str(), time / 1000, images);
        this->setWindowTitle(oldtitle + fps);
    }
}
Example #24
0
void LineEditWithIcon::setIcon(const QPixmap & pixmap) {
	QPixmap p = pixmap;
	//qDebug("height: %d, icon height: %d", height(), p.height());
	int max_height = 16;
	if (max_height > height()) max_height = height() - 4;
	if (pixmap.height() > max_height) p = pixmap.scaledToHeight(max_height, Qt::SmoothTransformation);
	button->setIcon(p);
	button->setStyleSheet("QToolButton { border: none; padding: 0px; }");

    int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
	//qDebug("frameWidth: %d", frameWidth);
    setStyleSheet(QString("QLineEdit { padding-right: %1px; } ").arg(button->sizeHint().width() + frameWidth + 1));
    /*
    QSize msz = minimumSizeHint();
    setMinimumSize(qMax(msz.width(), button->sizeHint().height() + frameWidth * 2 + 2),
                   qMax(msz.height(), button->sizeHint().height() + frameWidth * 2 + 2));
    */
}
QPixmap MeeGoThemedImageProvider::requestPixmap(const QString &id, QSize *size,
                                           const QSize &requestedSize)
{
    QPixmap pixmap;
    int width = requestedSize.width();
    int height = requestedSize.height();

    QString themeDir = QString("/usr/share/themes/") + themeItem->value().toString()  + "/";

    //  If we have a custom icon then use it
    if (QFile::exists(themeDir + id + ".png"))
    {
        pixmap.load(themeDir + id + ".png");

        if (width > 0 && height > 0)
        {
            pixmap = pixmap.scaled(QSize(width, height));
        }
        else if (width > 0)
        {
            pixmap = pixmap.scaledToWidth(width);
        }
        else if (height > 0)
        {
            pixmap = pixmap.scaledToHeight(height);
        }
    }
    else
    {
        qDebug() << QString("Failed to find theme image requested: %1").arg(themeDir + id + ".png");
        // Return a red pixmap to assist in finding missing images
        if (width <= 0)
            width = 100;
        if (height <= 0)
            height = 100;
        pixmap = QPixmap(QSize(width, height));
        pixmap.fill(Qt::red);
    }

    if (size)
        *size = pixmap.size();

    return pixmap;
}
Example #26
0
ItemWidget *ItemImageLoader::create(const QModelIndex &index, QWidget *parent) const
{
    // TODO: Just check if image provided and load it in different thread.
    QPixmap pix;
    if ( !getPixmapFromData(index, &pix) )
        return NULL;

    // scale pixmap
    const int w = m_settings.value("max_image_width", 320).toInt();
    const int h = m_settings.value("max_image_height", 240).toInt();
    if ( w > 0 && pix.width() > w && (h <= 0 || pix.width()/w > pix.height()/h) ) {
        pix = pix.scaledToWidth(w);
    } else if (h > 0 && pix.height() > h) {
        pix = pix.scaledToHeight(h);
    }

    return new ItemImage(pix, m_settings.value("image_editor").toString(),
                         m_settings.value("svg_editor").toString(), parent);
}
Example #27
0
//trigger when the selection in the model list combo box is changed, display the corresponding new image
void DBaseDlg::modelChanged(){
	if(inModelConstruction) return;
	QString psbModelThumbPath = QString( mModelList[mModelMap[modelsComboBox->currentText().toStdString()]]->
					     ThumbnailPath().c_str() );
	if(mModelScene) delete mModelScene;
	mModelScene = new QGraphicsScene;
	mModelScene->setBackgroundBrush(Qt::blue);
	QPixmap lPixmap;
	lPixmap.load(psbModelThumbPath);
	//resize so that it will fit in window
	if (lPixmap.width() > 160) {
		lPixmap = lPixmap.scaledToWidth(160);
	}
	if (lPixmap.height() > 120) {
		lPixmap = lPixmap.scaledToHeight(120);
	}
	mModelScene->addPixmap(lPixmap);
	this->objectGraph->setScene(mModelScene);
	this->objectGraph->show();
}
Example #28
0
void Notifications::notify(const QString &text) {
	if (Config::instance()->notifier() == FREEDESKTOP && m_dbus) {
		m_dbus = notifyDBus(text);
		if (m_dbus) // DBus notify succeeded
			return;
		DEBUG("DBus notify failed, falling back to custom notifier.");
	}

	// TODO: height and width set optionaly
	QPixmap icon;
	if (Config::instance()->showCoverArt() && m_coverArt->hasCoverArt()) {
		icon = m_coverArt->coverArt();
		if (icon.height() > 64) icon = icon.scaledToHeight(64, Qt::SmoothTransformation);
		if (icon.width() > 64) icon = icon.scaledToWidth(64, Qt::SmoothTransformation);
	} else {
		icon = QPixmap(":/icons/qmpdclient48.png");
	}

	PassivePopup::Position pos = static_cast<PassivePopup::Position>(Config::instance()->notificationsPosition());
	new PassivePopup("QMPDClient", text, icon, pos, Config::instance()->notificationsTimeout());
}
Example #29
0
void EWASiteDrawer::makeThumbnailFromImage( QPixmap& srcImg, qreal blurR )
{
    int iW = srcImg.width();
    int iH = srcImg.height();
    int iDstDemension = EWAApplication::getScreenSize().width()/5;
    
    if( qMax( iW, iH ) > iDstDemension )
    {
        srcImg = iW >= iH 
            ? srcImg.scaledToWidth( iDstDemension, Qt::SmoothTransformation )
            : srcImg.scaledToHeight( iDstDemension, Qt::SmoothTransformation );
    }
    
    QPixmap res( srcImg.width() + blurR + blurR, srcImg.height() + blurR + blurR);
    res.fill( QToolTip::palette().color( QPalette::Inactive, QPalette::AlternateBase ) );
    QPainter p( &res );
    p.setRenderHints( EWAApplication::getRenderHints() );
    
    drawShadowedPixmap( &p, srcImg, (res.width()-srcImg.width())/2-blurR/2, (res.height()-srcImg.height())/2-blurR/2, false );
    srcImg = res.copy();
}
Example #30
0
void AddCharacterDialog::init(Character* character)
{
    mUi.setupUi( this );
    setModal(true);

    mPrevName = "";
    mUi.lImage->setAlignment(Qt::AlignCenter);
    mUi.browseImageButton->setFilter(ChooseFileButton::ImageFilter);
    mUi.statusTreeWidget->header()->setSectionResizeMode(0, QHeaderView::Stretch);
    mUi.statusTreeWidget->setIconSize(QSize(32, 32));

    if (character) {
        this->setWindowTitle(tr("Edit Character"));
        mUi.nameEdit->setText(character->name());
        QHash<QString, ImageFile*> statesToImages = character->statesToImages();
        QHashIterator<QString, ImageFile*> it(statesToImages);
        while(it.hasNext()) {
            it.next();
            ImageFile* image = it.value();
            if (image) {
                QPixmap pixmap = image->pixmap();
                if (pixmap.height() > mUi.lImage->height())
                    pixmap = pixmap.scaledToHeight(mUi.lImage->height(), Qt::SmoothTransformation);
                mPixmapCache.insert(image->path(), pixmap);
                addState(it.key(), image->path());
            }
        }
    }

    connect(mUi.statusTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(onItemClicked(QTreeWidgetItem *, int)));
    connect(mUi.statusTreeWidget, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(onItemChanged(QTreeWidgetItem *, int)));

    connect(mUi.stateEdit, SIGNAL(textEdited(const QString&)), this, SLOT(onStateEdited(const QString&)));
    connect(mUi.browseImageButton, SIGNAL(fileSelected(const QString&)), this, SLOT(onImageSelected(const QString&)));
    connect(mUi.addStateButton, SIGNAL(clicked()), this, SLOT(addNewState()));

    show();
}