void imageEnhanceDialog::on_radioGrayScale_clicked(bool checked)
{
    QByteArray data;
    QPixmap map;

    if(checked)
    {
        disableSliders();

        data = imageEditor->enhanceImage(imageFileName, 100,0,100);

        map.loadFromData(data, "XPM");
        enhanceDialog->rightImage->clear();
        enhanceDialog->rightImage->setPixmap(map);

        eType = grayScale;
    }
}
Exemple #2
0
void MainWindow::done(bool ok)
{
    if(m_orgicons.size()){
        QPixmap flag;
        QByteArray raw = m_http->readAll();
        (m_orgicons.front().item)->setText(flag.loadFromData(raw,"JPG")?"success":"fail");
        ;
        (m_orgicons.front().item)->setIcon(QIcon(flag));


        m_orgicons.erase(m_orgicons.begin());
        if( m_orgicons.size() ){
            QUrl url(m_orgicons.front().url);
            m_http->setHost(url.host());
            m_http->get(url.path());
        }
    }
}
void PictureLoader::loadPictureData(QNetworkReply *reply) {
    if (reply->error() != QNetworkReply::NoError) {
        qDebug("Network error; show some feedback");
        // TODO
        return;
    }

    const QByteArray data(reply->readAll());

    if (data.isEmpty()) {
        qDebug("No data!");
        return;
    }

    QPixmap pixmap;
    pixmap.loadFromData(data);
    emit pictureReady(pixmap);
}
Exemple #4
0
void Radio::addStation(const QString &nazwa, const QString &URL, const QString &groupName, const QByteArray &img)
{
	QListWidgetItem *lWI = new QListWidgetItem(nazwa);
	lWI->setData(Qt::UserRole, URL);
	lWI->setData(Qt::ToolTipRole, groupName);
	if (img.isEmpty())
		lWI->setIcon(qmp2Icon);
	else
	{
		QPixmap pix;
		pix.loadFromData(img);
		lWI->setIcon(pix);
	}
	if (groupName == wlasneStacje)
		lW->insertItem(lW->row(nowaStacjaLWI), lWI);
	else
		lW->addItem(lWI);
}
Exemple #5
0
void MainUI::slotScreenshotAvailable(QNetworkReply *reply){
  qDebug() << "Screenshot retrieval finished:" << reply->error();
  if(reply->error() == QNetworkReply::NoError){
    QByteArray picdata = reply->readAll();
    QPixmap pix;
      pix.loadFromData(picdata);
    ui->label_app_screenshot->setText(""); //clear the text
    ui->label_app_screenshot->setPixmap( pix.scaled(ui->label_app_screenshot->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation) );
  }else{
    //Network error
    ui->label_app_screenshot->setText( tr("Could not load screenshot (network error)") );
  }
  //Now enable the prev/next buttons as necessary
  QStringList txt = ui->label_app_cScreen->text().split("/");
  if(txt.length()!=2){ return; } //invalid text for some reason
  if(txt[0]!="1"){ ui->tool_app_nextScreen->setEnabled(true); }
  if(txt[0] != txt[1]){ ui->tool_app_prevScreen->setEnabled(true); }
}
Exemple #6
0
void AvatarDefs::getOwnAvatar(QPixmap &avatar, const QString& defaultImage)
{
	unsigned char *data = NULL;
	int size = 0;

	/* get avatar */
	rsMsgs->getOwnAvatarData(data, size);

	if (size == 0) {
		avatar = QPixmap(defaultImage);
		return;
	}

	/* load image */
	avatar.loadFromData(data, size, "PNG") ;

	delete[] data;
}
void
KexiBlobTableEdit::setupContents(QPainter *p, bool focused, const QVariant& val,
                                 QString &txt, int &align, int &x, int &y_offset, int &w, int &h)
{
    Q_UNUSED(focused);
    Q_UNUSED(txt);
    Q_UNUSED(align);

//! @todo optimize: load to m_pixmap, downsize
    QPixmap pixmap;
    x = 0;
    w -= 1; //a place for border
    h -= 1; //a place for border
    if (p && val.canConvert(QVariant::ByteArray) && pixmap.loadFromData(val.toByteArray())) {
        KexiUtils::drawPixmap(*p, KexiUtils::WidgetMargins()/*lineWidth*/, QRect(x, y_offset, w, h),
                              pixmap, Qt::AlignCenter, true/*scaledContents*/, true/*keepAspectRatio*/);
    }
}
Exemple #8
0
void
SearchModel::bannerReceived(QtTvDB::Show *show, const QByteArray & data)
{
  int id;
  QPixmap pixmap;

  id = show->id();

  if (banners.contains(id))
    return ;

  pixmap.loadFromData(data);
  banners[id] = pixmap;
  //pixmap.scaled(QSize(256, 64), Qt::KeepAspectRatio, Qt::SmoothTransformation);

  QModelIndex idx = index(shows.indexOf(show));
  emit dataChanged(idx, idx);
}
Exemple #9
0
/**
* @return image for temporarily replacing a tile that is downloading and currently unavailable
* The 'patch' is a subsection of an available tile from a lower zoom level.
* The algorithm tries to find a suitable tile starting from level zoom -1, until level 0.
* The higher the zoom level difference the more pixelated the patch will be.
*/
QPixmap cacaMap::getTilePatch(int zoom, quint32 x, quint32 y, int offx, int offy, int tsize)
{
	//dont go beyond level 0 and 
	//dont use patches smaller than 16 px. They are unintelligible anyways.
	if (zoom>0 && tsize>=16*2)
	{
		int parentx, parenty, offsetx, offsety;
		QString tileid;
		QPixmap patch;
		QString sz,sx,sy;
		parentx = x/2;
		parenty = y/2;
		sz.setNum(zoom-1);
		sx.setNum(parentx);
		sy.setNum(parenty);
		offsetx = offx/2 + (x%2)*tileSize/2;
		offsety = offy/2 + (y%2)*tileSize/2;
		tileid = sz+"."+sx+"."+sy;
		if (tileCache.contains(tileid))
		{
			//render the tile
			QDir::setCurrent(folder);
			QString path= getTilePath(zoom-1,parentx) ;
			QString fileName = servermgr.fileName(parenty);
			QDir::setCurrent(path);
			QFile f(fileName);
			if (f.open(QIODevice::ReadOnly))
			{
				patch.loadFromData(f.readAll());
				f.close();
				return patch.copy(offsetx,offsety,tsize/2,tsize/2).scaledToHeight(tileSize);
			}
			else
			{
				cout<<"no file found "<<path.toStdString()<<fileName.toStdString()<<endl;
			}
		}
		else
		{
			return getTilePatch(zoom-1,parentx,parenty,offsetx,offsety,tsize/2);
		}
	}
	return loadingAnim.currentPixmap();
}
Exemple #10
0
void ViewerWidget::load(const QByteArray &data)
{
    scene->clear();
    QList<QGraphicsItem *> items;
    QPixmap pixmap;
    if (pixmap.loadFromData(data)) {
        items << new QGraphicsPixmapItem(pixmap);
    }
    else if (data.startsWith("%PDF")) {
        fz_stream *stream = fz_open_memory(context, (unsigned char *)data.constData(), data.length());
        fz_document *doc = fz_open_document_with_stream(context, ".pdf", stream);
        fz_close(stream);
        int pagecount = fz_count_pages(doc);
        for (int i = 0; i < pagecount; i++) {
            fz_page *page = fz_load_page(doc, i);
            fz_rect bounds;
            fz_bound_page(doc, page, &bounds);
            fz_display_list *list = fz_new_display_list(context);
            fz_device *dev = fz_new_list_device(context, list);
            fz_run_page(doc, page, dev, &fz_identity, NULL);
            fz_free_device(dev);
            fz_free_page(doc, page);
            PageItem *item = new PageItem(context, list, bounds.x1 - bounds.x0, bounds.y1 - bounds.y0);
            item->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
            items << item;
        }
        fz_close_document(doc);
    } else {
        scene->setSceneRect(0, 0, 0, 0);
        return;
    }
    int top = 0;
    QPen outline(Qt::lightGray, 2, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin);
    outline.setCosmetic(true);
    foreach (QGraphicsItem *item, items) {
        QGraphicsRectItem *rim = new QGraphicsRectItem(item->boundingRect());
        item->setPos(0, top);
        rim->setPos(0, top);
        rim->setPen(outline);
        rim->setBrush(Qt::NoBrush);
        scene->addItem(rim);
        scene->addItem(item);
        top += item->boundingRect().height() + SPACING;
    }
void Widget::displayJPEG()
{
    disconnect(reply,SIGNAL(readyRead()),this,SLOT(httpReadyRead()));

    QPixmap img;
    //    qDebug() << "jpegBA size: " << jpegBA.size();
    img.loadFromData(jpegBA);
    if(!img.isNull())
    {
        int w = ui->imgOutput->width();
        int h = ui->imgOutput->height();

        ui->imgOutput->setPixmap(img.scaled(w,h,Qt::KeepAspectRatio));
    }
    //        ui->imgOutput->setPixmap(img);
    imageReady=true;
    //    resizeImage();
    connect(reply,SIGNAL(readyRead()),this,SLOT(httpReadyRead()));
}
Exemple #12
0
void Core::setAvatar(uint8_t format, const QByteArray& data)
{
    if (tox_set_avatar(tox, format, (uint8_t*)data.constData(), data.size()) != 0)
    {
        qWarning() << "Core: Failed to set self avatar";
        return;
    }

    QPixmap pic;
    pic.loadFromData(data);
    Settings::getInstance().saveAvatar(pic, getSelfId().toString());
    emit selfAvatarChanged(pic);
    
    // Broadcast our new avatar!
    // according to tox.h, we need not broadcast this ourselves, but initial testing indicated elsewise
    const uint32_t friendCount = tox_count_friendlist(tox);;
    for (unsigned i=0; i<friendCount; i++)
        tox_send_avatar_info(tox, i);
}
Exemple #13
0
    void MapNetwork::requestFinished(void)
    {
	QNetworkReply *rep = (QNetworkReply *)sender();
	QPixmap pm;
	QString url;

	 // check if id is in map?
	if (!loadingMap.contains(rep))
	   return ;

	url = loadingMap[rep];
	loadingMap.remove(rep);

	if (pm.loadFromData(rep->readAll()))
	    parent->receivedImage(pm, url);

        if (loadingMap.isEmpty())
            parent->loadingQueueEmpty();
    }
void MrmlView::slotDownloadFinished( const KURL& url, const QByteArray& data )
{
    QPtrListIterator<MrmlViewItem> it( m_items );
    for( ; it.current(); ++it ) {
        MrmlViewItem *item = it.current();
        if ( item->thumbURL() == url )
        {
            QPixmap p;
            if ( data.isEmpty() || !p.loadFromData( data ) )
                p = m_unavailablePixmap;

            m_pixmapCache.insert( url.url(), p );
            item->setPixmap( p );

            slotLayout();
            return;
        }
    }
}
Exemple #15
0
void TexturesList::parse()
{
	clear();

	LBlockValuesList list = doc->getTexturesList();
	
	foreach(LBlockValues texture, list) {
		QString name = texture["name"];
		QString value = texture["value"];

		QByteArray array = QByteArray::fromBase64(value.toAscii());

		QPixmap pixmap;
		pixmap.loadFromData(array);

		QStandardItem *item = new QStandardItem(QIcon(pixmap), name);
		appendRow(item);
		items<<item;
	}
void JabberFileTransfer::askIncomingTransfer ( const QByteArray &thumbnail )
{
	if (mTransferId != -1)
		return;

	QPixmap preview;
	if (!thumbnail.isNull())
	{
		preview.loadFromData ( thumbnail );
	}

	mTransferId = Kopete::TransferManager::transferManager()->askIncomingTransfer ( mContact,
																				  mXMPPTransfer->fileName (),
																				  mXMPPTransfer->fileSize (),
																				  mXMPPTransfer->description () ,
																				QString(),
																				  preview);

}
Exemple #17
0
void Widget::onAvatarClicked()
{
    QString filename = QFileDialog::getOpenFileName(this, tr("Choose a profile picture"), QDir::homePath());
    if (filename.isEmpty())
        return;
    QFile file(filename);
    file.open(QIODevice::ReadOnly);
    if (!file.isOpen())
    {
        QMessageBox::critical(this, tr("Error"), tr("Unable to open this file"));
        return;
    }

    QPixmap pic;
    if (!pic.loadFromData(file.readAll()))
    {
        QMessageBox::critical(this, tr("Error"), tr("Unable to read this image"));
        return;
    }

    QByteArray bytes;
    QBuffer buffer(&bytes);
    buffer.open(QIODevice::WriteOnly);
    pic.save(&buffer, "PNG");
    buffer.close();

    if (bytes.size() >= TOX_AVATAR_MAX_DATA_LENGTH)
    {
        pic = pic.scaled(64,64, Qt::KeepAspectRatio, Qt::SmoothTransformation);
        bytes.clear();
        buffer.open(QIODevice::WriteOnly);
        pic.save(&buffer, "PNG");
        buffer.close();
    }

    if (bytes.size() >= TOX_AVATAR_MAX_DATA_LENGTH)
    {
        QMessageBox::critical(this, tr("Error"), tr("This image is too big"));
        return;
    }

    core->setAvatar(TOX_AVATAR_FORMAT_PNG, bytes);
}
GLErrorHistory::GLErrorHistory(QWidget* parent)
: QGLWidget(parent)
, View(tr("Error history"), this)
{
	// settings
	QPixmap img;
	img.loadFromData(g_icon_error_graph, sizeof(g_icon_error_graph), "PNG");
	setting_show->setIcon(QIcon(img));
	setting_show->setChecked(true);

	setting_keep = new QAction(tr("Keep previous notes"), this);
	setting_keep->setCheckable(true);
	setting_keep->setChecked(false);
	connect(setting_keep, SIGNAL(toggled(bool)), this, SLOT(keepPreviousNotes(bool)));
	m_popup_menu.addAction(setting_keep);

	setting_useCents = new QAction(tr("Use cents"), this);
	setting_useCents->setCheckable(true);
	setting_useCents->setChecked(true);
	connect(setting_useCents, SIGNAL(toggled(bool)), this, SLOT(update()));
	m_popup_menu.addAction(setting_useCents);

	QHBoxLayout* scaleActionLayout = new QHBoxLayout(&m_popup_menu);

	QLabel* scaleActionTitle = new QLabel(tr("Scale range"), &m_popup_menu);
	scaleActionLayout->addWidget(scaleActionTitle);

	setting_spinScale = new QSpinBox(&m_popup_menu);
	setting_spinScale->setMinimum(5);
	setting_spinScale->setMaximum(50);
	setting_spinScale->setSingleStep(1);
	setting_spinScale->setValue(50);
	setting_spinScale->setToolTip(tr("Scale range (in cents)"));
	connect(setting_spinScale, SIGNAL(valueChanged(int)), this, SLOT(update()));
	scaleActionLayout->addWidget(setting_spinScale);

	QWidget* scaleActionWidget = new QWidget(&m_popup_menu);
	scaleActionWidget->setLayout(scaleActionLayout);

	QWidgetAction* scaleAction = new QWidgetAction(&m_popup_menu);
	scaleAction->setDefaultWidget(scaleActionWidget);
	m_popup_menu.addAction(scaleAction);
}
Exemple #19
0
void PersonListJob::slotAvatarJobResult( KJob *job )
{
  m_job = 0;

  if ( job->error() ) {
    setError( job->error() );
    setErrorText( job->errorText() );
  } else {
    QPixmap pic;
    if ( !pic.loadFromData( m_avatarData ) ) {
      setError( UserDefinedError );
      setErrorText( i18n("Unable to parse avatar image data.") );
    } else {
//      m_person.setAvatar( pic );
    }
  }
  
  emitResult();
}
void ProfileWidget::displayCurrentProfile()
{
    QPixmap pic;

    /* Alimentation des widgets */
    p_name->setText(this->ctrl->getCurrentProfile().getName());
    p_siret->setText(this->ctrl->getCurrentProfile().getSiret());
    p_address->setText(this->ctrl->getCurrentProfile().getAddress());
    p_complement->setText(this->ctrl->getCurrentProfile().getAddressComplement());
    p_zip->setText(this->ctrl->getCurrentProfile().getZipCode());
    p_city->setText(this->ctrl->getCurrentProfile().getCity());
    p_phone->setText(this->ctrl->getCurrentProfile().getPhone());
    p_mail->setText(this->ctrl->getCurrentProfile().getMail());
    p_website->setText(this->ctrl->getCurrentProfile().getWebsite());

    /* Alimentation du widget logo */
    pic.loadFromData(this->ctrl->getCurrentProfile().getLogo());
    p_logo->setPixmap(pic);
}
Exemple #21
0
void
GraphicsScene::handleInputData(void)
{
  while (m_sock->hasPendingDatagrams())
  {
    m_dgram.resize(m_sock->pendingDatagramSize());
    m_sock->readDatagram(m_dgram.data(), m_dgram.size());

    IMC::Message* msg = IMC::Packet::deserialize((uint8_t*)m_dgram.data(), m_dgram.size());
    if (msg == 0)
      continue;

    if (msg->getId() == DUNE_IMC_COMPRESSEDIMAGE)
    {
      ++m_fps;

      IMC::CompressedImage* img = static_cast<IMC::CompressedImage*>(msg);

      QPixmap pix;
      pix.loadFromData((uchar*)img->data.data(), img->data.size(), "JPEG");

      QTransform t;
      pix = pix.transformed(t.rotate(m_rotate));

      m_item.setPixmap(pix);

      setMinimumSize(pix.width() + c_pad, pix.height() + c_pad);

      if (m_grid)
      {
        m_vline->setLine(0, pix.height() / 2, pix.width(), pix.height() / 2);
        m_hline->setLine(pix.width() / 2, 0, pix.width() / 2, pix.height());
      }
    }
    else if (msg->getId() == DUNE_IMC_EULERANGLES)
    {
      IMC::EulerAngles* ang = static_cast<IMC::EulerAngles*>(msg);
      // QString str("Roll: %0.2f | Pitch: %0.2f");
      // m_text.setText(str.arg(Angles::degrees(ang->roll), Angles::degrees(ang->pitch)));
    }
  }
}
Exemple #22
0
bool ImageInstance::dcm2bmpHelper(DicomImage &dcmImage, QPixmap &pixmap)
{
    BITMAPFILEHEADER lpfh;
    BITMAPINFOHEADER lpih;
    RGBQUAD palette[256];

    memset(&lpfh, 0, sizeof(BITMAPFILEHEADER));
    lpfh.bfType = 0x4d42;  //'B''M'
    lpfh.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + sizeof(palette);


    memset(&lpih, 0, sizeof(BITMAPINFOHEADER));
    lpih.biSize = sizeof(BITMAPINFOHEADER);
    lpih.biWidth = dcmImage.getWidth();
    lpih.biHeight = dcmImage.getHeight();
    lpih.biCompression = BI_RGB;
    lpih.biBitCount = 8;
    lpih.biPlanes = 1;

    memset(palette, 0, sizeof(palette));
    for (int i = 0; i < 256; ++i) {
        palette[i].rgbBlue = i;
        palette[i].rgbGreen = i;
        palette[i].rgbRed = i;
    }

    void *pDIB = NULL;

    int size = dcmImage.createWindowsDIB(pDIB, 0, 0, 8, 1, 1);

    //lpih.biSizeImage = size;
    lpfh.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + sizeof(palette) + size;

    QByteArray bmp;
    bmp.append((char*)&lpfh, sizeof(BITMAPFILEHEADER));
    bmp.append((char*)&lpih, sizeof(BITMAPINFOHEADER));
    bmp.append((char*)palette, sizeof(palette));
    bmp.append((char*)pDIB, size);

    delete pDIB;
    return pixmap.loadFromData(bmp);
}
Exemple #23
0
void MapIndicator::got_image(QNetworkReply* reply)
{
    if (reply->error() == QNetworkReply::NoError)
    {

        cout << "getting IMAGE"<<endl;

        QByteArray Data = reply->readAll();
        cout <<Data.size()<<"size"<<endl;
        QPixmap pixmap;

        cout << "Succes? " << pixmap.loadFromData(Data,0,Qt::ColorOnly	)<< endl;

        text.setPixmap(pixmap.scaled(text.size(), Qt::KeepAspectRatio));
        text.repaint();
        cout <<text.size().width()<<endl;
    }
    else
        this->mapValid = false;
}
Exemple #24
0
QSObject QSPixmapClass::construct( const QSList &args ) const
{
    if ( args.size() > 0 ) {
	QSObject v( args[ 0 ] );
	if ( v.isA( "Pixmap" ) ) {
	    return v;
	} else if ( v.isString() ) {
	    QPixmap pm( v.toString() );
	    return construct( pm );
        } else {
            QVariant var = v.toVariant(QVariant::ByteArray);
            if (var.type() == QVariant::ByteArray) {
                QPixmap pm;
                pm.loadFromData( v.toVariant(QVariant::ByteArray).toByteArray() );
                return construct( pm );
            }
        }
    }
    return construct( QPixmap() );
}
QIcon CachedIconFinder::getIcon(const QString &name, int size, const QString &type) const {
    QString tmp("%1-%2-%3");
    QString key = tmp.arg(QString::number(size), type, name);

    DPRINT("%s", qPrintable(key));
    if (this->m_hash.contains(key)) {
        QPixmap pixmap;

        if (!pixmap.loadFromData((const uchar *)(this->m_hash.value(key) + m_addr + sizeof(qint64)), *(qint64 *)(this->m_hash.value(key) + m_addr))) {
            DPRINT("can not load pixmap");
            return QIcon();
        }

        DPRINT("get icon.");
        return QIcon(pixmap);
    }

    DPRINT("non-exists");
    return QIcon();
}
Exemple #26
0
QPixmap* IconManager::getPixmap(int catId, const QString &iconName)
{
    QString sql = "SELECT id, iconData FROM icons WHERE catId = " + QString::number(catId) + " AND name = '" + iconName + "'";
    QSqlQuery *q = new QSqlQuery(db);
    QPixmap *pix = 0;
    if (!q)
        return NULL;
    if (q->exec(sql))
    {
        if (q->isActive())
        {
            q->first();
            QByteArray bytes = q->value(1).toByteArray();
            pix = new QPixmap;
            pix->loadFromData(bytes);
        }
    }
    delete q;
    return pix;
}
QPixmap GetAristPic::getAristPic(QString url)
{
    QNetworkRequest networkRequest;
    QNetworkAccessManager networkManager;

    networkRequest.setUrl(QUrl(url));

    QNetworkReply *reply = networkManager.get(networkRequest);

    QEventLoop loop;
    connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
    loop.exec();
    reply->deleteLater();


    QPixmap pic;
    pic.loadFromData(reply->readAll());

    return pic;
}
Exemple #28
0
void QQLogin::getCaptchaImg(QByteArray sum)
{
    QString captcha_str ="/getimage?uin=%1&vc_type=%2&aid=1003909&r=0.5354663109529408";

    Request req;
    req.create(kGet, captcha_str.arg(curr_user_info_.id()).arg(QString(sum)));
    req.addHeaderItem("Host", "captcha.qq.com");
    req.addHeaderItem("Connection", "Keep-Alive");

    fd_->connectToHost("captcha.qq.com", 80);

    fd_->write(req.toByteArray());

    QByteArray result;
    while (fd_->waitForReadyRead())
    {
        result.append(fd_->readAll());
    }

    int cookie_idx = result.indexOf("Set-Cookie") + 12;
    int idx = result.indexOf(';', cookie_idx)+1;
    captcha_info_.cookie_ = result.mid(cookie_idx, idx - cookie_idx);

    QDialog *captcha_dialog = new QDialog(this);
    Ui::QQCaptcha *ui = new Ui::QQCaptcha;
    QPixmap *pix = new QPixmap;
    pix->loadFromData(result.mid(result.indexOf("\r\n\r\n") + 4));
    ui->setupUi(captcha_dialog);
    ui->lbl_captcha_->setPixmap(*pix);

    if (captcha_dialog->exec())
    {
        vc_ = ui->le_captcha_->text().toUpper();
    }

    delete captcha_dialog;

    fd_->disconnectFromHost();

    login();
}
void FeedPropertiesDialog::selectIcon()
{
  QString filter;
  foreach (QByteArray imageFormat, QImageReader::supportedImageFormats()) {
    if (!filter.isEmpty()) filter.append(" ");
    filter.append("*.").append(imageFormat);
  }
  filter = tr("Image files") + QString(" (%1)").arg(filter);

  QString fileName = QFileDialog::getOpenFileName(this, tr("Select Image"),
                                                  QDir::homePath(),
                                                  filter);

  if (fileName.isNull()) return;

  QMessageBox msgBox;
  msgBox.setText(tr("Load icon: can't open a file!"));
  msgBox.setIcon(QMessageBox::Warning);

  QFile file(fileName);
  if (!file.open(QIODevice::ReadOnly)) {
    msgBox.exec();
    return;
  }

  QPixmap pixmap;
  if (pixmap.loadFromData(file.readAll())) {
    pixmap = pixmap.scaled(16, 16, Qt::IgnoreAspectRatio,
                           Qt::SmoothTransformation);
    QByteArray faviconData;
    QBuffer    buffer(&faviconData);
    buffer.open(QIODevice::WriteOnly);
    if (pixmap.save(&buffer, "ICO")) {
      slotFaviconUpdate(feedProperties.general.url, faviconData);
    }
  } else {
    msgBox.exec();
  }

  file.close();
}
void imageEnhanceDialog::on_sliderSaturation_sliderReleased()
{
    QByteArray data;
    QPixmap map;
    int localContrast;

    qDebug() << "Contrast : " << mContrast << endl;

    if ( mContrast )
        localContrast = mContrast * 500 + 500;
    else
        localContrast = 0;

    data = imageEditor->enhanceImage(imageFileName, (mBrightness+100), (mSaturation+100), localContrast);

    map.loadFromData(data, "XPM");
    enhanceDialog->rightImage->clear();
    enhanceDialog->rightImage->setPixmap(map);

    data.clear();
}