コード例 #1
0
ファイル: systemtray.cpp プロジェクト: tytycoon/basket
void SystemTray::updateToolTip()
{
//	return; /////////////////////////////////////////////////////

	Basket *basket = Global::bnpView->currentBasket();
	if (!basket)
		return;

	if (basket->icon().isEmpty() || basket->icon() == "basket" || ! Settings::showIconInSystray())
		setPixmap(basket->isLocked() ? m_lockedIconPixmap : m_iconPixmap);
	else {
		// Code that comes from JuK:
		QPixmap bgPix = loadIcon("basket");
		QPixmap fgPix = SmallIcon(basket->icon());

		QImage bgImage = bgPix.convertToImage(); // Probably 22x22
		QImage fgImage = fgPix.convertToImage(); // Should be 16x16
		QImage lockOverlayImage = loadIcon("lockoverlay").convertToImage();

		KIconEffect::semiTransparent(bgImage);
		copyImage(bgImage, fgImage, (bgImage.width() - fgImage.width()) / 2,
                  (bgImage.height() - fgImage.height()) / 2);
		if (basket->isLocked())
			KIconEffect::overlay(bgImage, lockOverlayImage);

		bgPix.convertFromImage(bgImage);
		setPixmap(bgPix);
	}

	//QTimer::singleShot( Container::c_delayTooltipTime, this, SLOT(updateToolTipDelayed()) );
	// No need to delay: it's be called when notes are changed:
	updateToolTipDelayed();
}
コード例 #2
0
QIconSet menuIconSet(const QString& icon)
{
    QIconSet iconset;
    int iconSize = KickerSettings::menuEntryHeight();

    if (iconSize < 0)
    {
        return iconset;
    }

    if (icon != "unknown")
    {
        if (iconSize > 0)
        {
            iconset = KGlobal::iconLoader()->loadIconSet(icon,
                                                     KIcon::NoGroup,
                                                     iconSize, true);
        }
        else if (iconSize == 0)
        {
            QPixmap normal = KGlobal::iconLoader()->loadIcon(icon,
                                                         KIcon::Small,
                                                         0,
                                                         KIcon::DefaultState,
                                                         0,
                                                         true);

            QPixmap active = KGlobal::iconLoader()->loadIcon(icon,
                                                         KIcon::Small,
                                                         0,
                                                         KIcon::ActiveState,
                                                         0,
                                                         true);

            // make sure they are not larger than 20x20
            if (normal.width() > 20 || normal.height() > 20)
            {
                normal.convertFromImage(normal.convertToImage().smoothScale(20,20));
            }

            if (active.width() > 20 || active.height() > 20)
            {
                active.convertFromImage(active.convertToImage().smoothScale(20,20));
            }

            iconset.setPixmap(normal, QIconSet::Small, QIconSet::Normal);
            iconset.setPixmap(active, QIconSet::Small, QIconSet::Active);
        }
    }

    if (iconset.isNull())
    {
        QPixmap pix(iconSize, iconSize);
        QBitmap map(iconSize, iconSize, true);
        pix.setMask(map);
        iconset = QIconSet(pix, pix);
    }

    return iconset;
}
コード例 #3
0
// return pixmap for a given zoom != 100
QPixmap * get_pixmap(const char * path, double zoom)
{
  QPixmap * px = get_pixmap(path);
  
  if (px == 0)
    return 0;
    
  if (((int) (zoom * 100)) == 100)
    return px;
  
  QPtrDict<QPixmap> * d = DiagramScaledPixmap[path]; // != 0
  int scaled_w = (int) (px->width() * zoom);
  void * k = (void *) scaled_w;
  QPixmap * scaled_px = d->find(k);
  
  if (scaled_px == 0) {
    QImage img = 
      px->convertToImage().smoothScale(scaled_w, (int) (px->height() * zoom));

    scaled_px = new QPixmap();
    scaled_px->convertFromImage(img);
    d->insert(k, scaled_px);
  }
  
  return scaled_px;
}
コード例 #4
0
void createPixmapNode( QDomDocument& doc, QDomNode& parent,
                       const QString& elementName, const QPixmap& pixmap )
{
    QDomElement pixmapElement = doc.createElement( elementName );
    parent.appendChild( pixmapElement );

    // Convert the pixmap to an image, save that image to an in-memory
    // XPM representation and compress this representation. This
    // conforms to the file format Qt Designer uses.
    QByteArray ba;
    QBuffer buffer( ba );
    buffer.open( IO_WriteOnly );
    QImageIO imgio( &buffer, "XPM" );
    QImage image = pixmap.convertToImage();
    imgio.setImage( image );
    imgio.write();
    buffer.close();
    ulong len = ba.size() * 2;
    QByteArray bazip( len );
    ::compress(  (uchar*) bazip.data(), &len, (uchar*) ba.data(), ba.size() );
    QString dataString;
    static const char hexchars[] = "0123456789abcdef";
    for ( int i = 0; i < (int)len; ++i ) {
        uchar c = (uchar) bazip[i];
        dataString += hexchars[c >> 4];
        dataString += hexchars[c & 0x0f];
    }

    createStringNode( doc, pixmapElement, "Format", "XPM.GZ" );
    createIntNode( doc, pixmapElement, "Length", ba.size() );
    createStringNode( doc, pixmapElement, "Data", dataString );
}
コード例 #5
0
void mgrui::append2_skin_ui(ZListBox *target, QList<struct skinObj> objList)
{
	struct skinObj *obj = objList.first();
	ZSettingItem *pItem = NULL;
	QPixmap pm;
	while(obj != NULL)
	{	
		pItem = new ZSettingItem(target);//, QString("%I%M") );
		pItem->appendSubItem(1, obj->skinName, SETTINGITEM_REGION_A );
		if(obj->isInPH == true)
			pItem->appendSubItem(1, obj->skinAuthor+ctr(",Phone,")+obj->skinDir,false, SETTINGITEM_REGION_B );
		else
			pItem->appendSubItem(1, obj->skinAuthor+ctr(",MMCA2,")+obj->skinDir, false, SETTINGITEM_REGION_B );
	
		if( QFile::exists( obj->skinWall ) )
			pm = QPixmap( obj->skinWall );
		else
			pm = QPixmap( QString("%1/img/skin.png").arg(appdir) );
			
		QImage img = pm.convertToImage();
		img = img.smoothScale(48, 48);
		pm.convertFromImage(img);
		pItem->setPixmap(0, pm);	
		
		target->insertItem(pItem);
		
		obj = objList.next();
	}
}
コード例 #6
0
void mgrui::buildMgrList()
{
	mgrListBox->clear();
	
	ZConfig cfg(appdir+"/settings.ini");
	
	int i, tNum;
    tNum = cfg.readNumEntry("LIST", "Items", 1);
	QPixmap pm;
	
	ZSettingItem *pItem = NULL;
	
	for(i=1;i<=tNum;i++)
	{
		printf("==== build item %d =====\n", i);
		pItem = new ZSettingItem(mgrListBox, QString("%I%M") );
		pItem->appendSubItem(1, sctr( cfg.readEntry( "LIST", "Option"+QString::number(i), "") ), false, SETTINGITEM_REGION_A );
		pItem->appendSubItem(1, sctr( cfg.readEntry( "LIST", "Option"+QString::number(i)+"b", "") ), false, SETTINGITEM_REGION_B );
		//pItem->setPixmap(0, pm);		
		//icon = appdir+cfg.readEntry( "LIST", "Icon"+QString::number(i)+"b", "");
		pm = QPixmap(appdir+cfg.readEntry( "LIST", "Icon"+QString::number(i), "") );
		QImage img = pm.convertToImage();
		img = img.smoothScale(48, 48);
		pm.convertFromImage(img);
		pItem->setPixmap(0, pm);	
		
		mgrListBox->insertItem(pItem);
	}
}
コード例 #7
0
QPixmap KasTaskItem::icon()
{
    int sizes[] = { KIcon::SizeEnormous,
		    KIcon::SizeHuge,
		    KIcon::SizeLarge,
		    KIcon::SizeMedium,
		    KIcon::SizeSmall };

    if ( kasbar()->embedThumbnails() && task_->hasThumbnail() ) {
	usedIconLoader = true;

	QPixmap thumb = task_->thumbnail();
	QSize sz = thumb.size();
	sz.scale( sizes[kasbar()->itemSize()], sizes[kasbar()->itemSize()], QSize::ScaleMin );

	QImage img = thumb.convertToImage();
	img = img.smoothScale( sz );

	bool ok = thumb.convertFromImage( img );
	if ( ok )
	    return thumb;
    }

    usedIconLoader = false;
    QPixmap p = task_->bestIcon( sizes[kasbar()->itemSize()], usedIconLoader );
    if ( !p.isNull() )
	return p;

    return task_->icon( sizes[kasbar()->itemSize()], sizes[kasbar()->itemSize()], true );
}
コード例 #8
0
int LapsusIcons::loadNewIcon(const QString &first, const QString &second, int size)
{
	if (first.length() < 1) return -1;

	QPixmap imgFirst = UserIcon(first);

	if (imgFirst.isNull()) return -1;

	if (second.length() > 0)
	{
		QPixmap imgSecond = UserIcon(second);

		if (!imgSecond.isNull())
		{
			QPainter p;

			p.begin( &imgFirst);
			p.drawPixmap (0, 0, imgSecond);
		}
	}

	int idx = _cachedIcons.count();

	_cachedIcons.push_back(
		QPixmap(imgFirst.convertToImage().smoothScale(size, size)));

	return idx;
}
コード例 #9
0
static QPixmap makeInvisible(unsigned flags, const QPixmap &p)
{
	unsigned swapColor = flags & ICON_COLOR_MASK;
	char shift = (flags >> 8) & 0xFF;
    QImage image = p.convertToImage();
	if (image.depth() != 32)
		image = image.convertDepth(32);
    unsigned int *data = (unsigned int*)image.bits();
	for (int y = 0; y < image.width(); y++){
		int x = image.width() / 2 - (y - image.height() / 2) * 2 / 3 + shift;
		if (x < 0)
			x = 0;
		if (x > image.width())
			x = image.width();
		unsigned int *line = data + y * (image.width()) + x;
		for (; x < image.width(); x++, line++){
	        QColor c(qRed(*line), qGreen(*line), qBlue(*line));
			int a = qAlpha(*line);
			int h, s, v;
			c.hsv(&h, &s, &v);
			if (swapColor){
				h = (swapColor * 2 - h) & 0xFF;
				c.setHsv(h, s / 2, v * 3 / 4);
			}else{
				c.setHsv(h, s / 2, v * 3 / 4);
			}
	        *line = qRgba(c.red(), c.green(), c.blue(), a);
		}
	}
    QPixmap pict;
    pict.convertFromImage(image);
    return pict;
}
コード例 #10
0
void KGridWidget::drawIcon(const QPixmap &icon, bool hitBlend, bool waterBlend, bool rotate)
{
	QPainter painter;
	painter.begin(m_doubleBuffer);
	if(!hitBlend && waterBlend)
	{
		QImage first = icon.convertToImage();
		QImage second = seaPng.convertToImage();
		painter.drawPixmap(m_x, m_y, seaPng);
		if(rotate)
			painter.drawImage(m_x, m_y, KImageEffect::blend(first, second, KImageEffect::VerticalGradient, 30, 30));
		else
			painter.drawImage(m_x, m_y, KImageEffect::blend(first, second, KImageEffect::HorizontalGradient, 30, 30));

	}
	else if(hitBlend && !waterBlend)
	{
		painter.drawPixmap(m_x, m_y, icon);
		painter.drawPixmap(m_x, m_y, hitPng);
	}
	else
		painter.drawPixmap(m_x, m_y, icon);

	if(!m_drawGrid)
		painter.end();
	else
	{
		painter.setBrush(Qt::NoBrush);
		painter.setPen(Qt::black);
		painter.drawRect(m_x, m_y, m_size, m_size);
		painter.end();
	}
}
コード例 #11
0
static QPixmap makeOffline(unsigned flags, const QPixmap &p)
{
	unsigned swapColor = flags & ICON_COLOR_MASK;
    QImage image = p.convertToImage();
    unsigned int *data = (image.depth() > 8) ? (unsigned int *)image.bits() :
                         (unsigned int *)image.colorTable();
    int pixels = (image.depth() > 8) ? image.width()*image.height() :
                 image.numColors();
    for (int i = 0; i < pixels; i++){
        QColor c(qRed(data[i]), qGreen(data[i]), qBlue(data[i]));
        int a = qAlpha(data[i]);
		int h, s, v;
		c.hsv(&h, &s, &v);
		if (swapColor){
			h = (swapColor * 2 - h) & 0xFF;
			c.setHsv(h, s, v);
		}else{
			c.setHsv(h, 0, v * 3 / 4);
		}
        data[i] = qRgba(c.red(), c.green(), c.blue(), a);
    }
    QPixmap pict;
    pict.convertFromImage(image);
    return pict;
}
コード例 #12
0
void SimpleButton::drawButtonLabel( QPainter *p )
{
    if (!pixmap())
    {
        return;
    }

    QPixmap pix = m_highlight? m_activeIcon : m_normalIcon;

    if (isOn() || isDown())
    {
        pix = pix.convertToImage().smoothScale(pix.width() - 2,
                                               pix.height() - 2);
    }

    int h = height();
    int w = width();
    int ph = pix.height();
    int pw = pix.width();
    int margin = KDialog::spacingHint();
    QPoint origin(margin / 2, margin / 2);

    if (ph < (h - margin))
    {
        origin.setY((h - ph) / 2);
    }

    if (pw < (w - margin))
    {
        origin.setX((w - pw) / 2);
    }

    p->drawPixmap(origin, pix);
}
コード例 #13
0
ファイル: quickbutton.cpp プロジェクト: serghei/kde3-kdebase
// similar to MimeType::pixmapForURL
QPixmap QuickURL::pixmap(mode_t _mode, KIcon::Group _group, int _force_size, int _state, QString *) const
{ // Load icon
    QPixmap pxmap = KMimeType::pixmapForURL(_kurl, _mode, _group, _force_size, _state);
    // Resize to fit button
    pxmap.convertFromImage(pxmap.convertToImage().smoothScale(_force_size, _force_size, QImage::ScaleMin));
    return pxmap;
}
コード例 #14
0
void KPrEffectPreview::setPixmap( const QPixmap& pixmap )
{
    // find the right size
    QRect rect = pixmap.rect();
    int w = rect.width();
    int h = rect.height();
    if ( w > h ) {
        w = 297;
        h = 210;
    }
    else if ( w < h ) {
        w = 210;
        h = 297;
    }
    else if ( w == h ) {
        w = 297;
        h = 297;
    }

    setMinimumSize( w, h );

    // create smaller pixmap for preview
    const QImage img( pixmap.convertToImage().smoothScale( w, h, QImage::ScaleFree ) );
    m_pixmap.convertFromImage( img );

    QLabel::setPixmap( m_pixmap );
}
コード例 #15
0
void QuartzButton::drawButton(QPainter *p)
{
	// Never paint if the pixmaps have not been created
	if (!quartz_initialized)
		return;

	QColor c;

	if (isLeft() )
		c = KDecoration::options()->color(KDecoration::ColorTitleBar, decoration()->isActive()).light(130);
	else
		c = KDecoration::options()->color(KDecoration::ColorTitleBlend, decoration()->isActive());

	// Fill the button background with an appropriate color
	p->fillRect(0, 0, width(), height(), c );

	// If we have a decoration bitmap, then draw that
	// otherwise we paint a menu button (with mini icon), or a onAllDesktops button.
	if( deco )
	{
		int xOff = (width()-10)/2;
		int yOff = (height()-10)/2;
		p->setPen( Qt::black );
		p->drawPixmap(isDown() ? xOff+2: xOff+1, isDown() ? yOff+2 : yOff+1, *deco);
		p->setPen( KDecoration::options()->color(KDecoration::ColorButtonBg, decoration()->isActive()).light(150) );
		p->drawPixmap(isDown() ? xOff+1: xOff, isDown() ? yOff+1 : yOff, *deco);
	} else
		{
			QPixmap btnpix;
			int Offset = 0;

			if (type() == OnAllDesktopsButton)
			{
				if (isDown())
					Offset = 1;

				// Select the right onAllDesktops button to paint
				if (decoration()->isActive())
					btnpix = isOn() ? *pinDownPix : *pinUpPix;
				else
					btnpix = isOn() ? *ipinDownPix : *ipinUpPix;

			} else
				btnpix = decoration()->icon().pixmap( QIconSet::Small, QIconSet::Normal);

			// Shrink the miniIcon for tiny titlebars.
			if ( height() < 16)
			{
				QPixmap tmpPix;

				// Smooth scale the image
				tmpPix.convertFromImage( btnpix.convertToImage().smoothScale(height(), height()));
				p->drawPixmap( 0, 0, tmpPix );
			} else {
				Offset += (height() - 16)/2;
				p->drawPixmap( Offset, Offset, btnpix );
			}
	}
}
コード例 #16
0
ファイル: FLUtil.cpp プロジェクト: AliYousuf/abanq-port
QImage FLUtil::snapShotUI( const QString &n ) {
  QWidget * w = FLSqlConnections::database()->managerModules()->createUI( n );

  if ( w ) {
    QPixmap pix = QPixmap::grabWidget( w );
    return pix.convertToImage();
  }
}
コード例 #17
0
ファイル: marklist.cpp プロジェクト: serghei/kde3-kdegraphics
void MarkListItem::setPixmap( QPixmap thumbnail )
{
    // The line below is needed to work around certain "features" of styles such as liquid
    // see bug:61711 for more info (LPC, 20 Aug '03)
    _thumbnailW->setBackgroundOrigin( QWidget::WidgetOrigin );
    _thumbnailW->setPaletteBackgroundPixmap( thumbnail.convertToImage().smoothScale( _thumbnailW->size() ) );
    _requested = false;
}
コード例 #18
0
ファイル: photo.cpp プロジェクト: BackupTheBerlios/enixs
//=============================================================================
// Set the pixmap of the photo.
//=============================================================================
void CPhoto::setPixmap (const QPixmap &p)
{
  if (p.isNull())
    return;
  
  QPixmap image = p;
  image.convertFromImage (image.convertToImage().smoothScale (size()));
  QLabel::setPixmap (image);
}
コード例 #19
0
static QPixmap merge(const QPixmap &p1, const QPixmap &p2)
{
	QImage img1 = p1.convertToImage();
	if (img1.depth() != 32)
		img1 = img1.convertDepth(32);
	QImage img2 = p2.convertToImage();
	if (img2.depth() != 32)
		img2 = img2.convertDepth(32);
    unsigned int *data1 = (unsigned int*)img1.bits();
    unsigned int *data2 = (unsigned int*)img2.bits();
	for (int y1 = 0; y1 < img1.height(); y1++){
		int y2 = y1 - (img1.height() - img2.height()); 
		if ((y2 < 0) || (y2 >= img2.height()))
			continue;
		unsigned int *line1 = data1 + y1 * img1.width();
		unsigned int *line2 = data2 + y2 * img2.width();
		int w = img1.width();
		if (w < img2.width()){
			line2 += (img2.width() - w) / 2;
		}else if (w > img2.width()){
			w = img2.width();
			line1 += (img1.width() - w) / 2;
		}
		for (int i = 0; i < w; i++, line1++, line2++){
			int r1 = qRed(*line1);
			int g1 = qGreen(*line1);
			int b1 = qBlue(*line1);
			int a1 = qAlpha(*line1);
			int r2 = qRed(*line2);
			int g2 = qGreen(*line2);
			int b2 = qBlue(*line2);
			int a2 = qAlpha(*line2);
			r1 = (r2 * a2 + r1 * (255 - a2)) / 255;
			g1 = (g2 * a2 + g1 * (255 - a2)) / 255;
			b1 = (b2 * a2 + b1 * (255 - a2)) / 255;
			if (a2 > a1)
				a1 = a2;
	        *line1 = qRgba(r1, g1, b1, a1);
		}
	}
	QPixmap res;
	res.convertFromImage(img1);
    return res;
}
コード例 #20
0
void PixServer::initPixmaps()
{

    QPixmap pm = QPixmap(locate("appdata", "pics/snake1.png"));
    QImage qi = pm.convertToImage();
    qi=qi.smoothScale(BRICKSIZE*18,BRICKSIZE);
    pm.convertFromImage(qi,QPixmap::AvoidDither);
    for (int x = 0 ; x < 18; x++){
		compuSnakePix[x].resize(BRICKSIZE, BRICKSIZE);
		bitBlt(&compuSnakePix[x] ,0,0, &pm,x*BRICKSIZE, 0, BRICKSIZE, BRICKSIZE, Qt::CopyROP, true);
		compuSnakePix[x].setMask(compuSnakePix[x].createHeuristicMask());
    }

    pm = QPixmap(locate("appdata", "pics/snake2.png"));
    qi = pm.convertToImage();
    qi=qi.smoothScale(BRICKSIZE*18,BRICKSIZE);
    pm.convertFromImage(qi,QPixmap::AvoidDither);
    for (int x = 0 ; x < 18; x++){
		samyPix[x].resize(BRICKSIZE, BRICKSIZE);
		bitBlt(&samyPix[x] ,0,0, &pm,x*BRICKSIZE, 0, BRICKSIZE, BRICKSIZE, Qt::CopyROP, true);
		samyPix[x].setMask(samyPix[x].createHeuristicMask());
    }

    pm = QPixmap(locate("appdata", "pics/ball.png"));
    qi = pm.convertToImage();
    qi=qi.smoothScale(BRICKSIZE*4,BRICKSIZE);
    pm.convertFromImage(qi,QPixmap::AvoidDither);
    for (int x = 0 ; x < 4; x++){
	ballPix[x].resize(BRICKSIZE, BRICKSIZE);
	bitBlt(&ballPix[x] ,0,0, &pm,x*BRICKSIZE, 0, BRICKSIZE, BRICKSIZE, Qt::CopyROP, true);
	ballPix[x].setMask(ballPix[x].createHeuristicMask());
    }

    pm = QPixmap(locate("appdata", "pics/apples.png"));
    qi = pm.convertToImage();
    qi=qi.smoothScale(BRICKSIZE*2,BRICKSIZE);
    pm.convertFromImage(qi,QPixmap::AvoidDither);
    for (int x = 0 ; x < 2; x++){
	applePix[x].resize(BRICKSIZE, BRICKSIZE);
	bitBlt(&applePix[x] ,0,0, &pm,x*BRICKSIZE, 0, BRICKSIZE, BRICKSIZE, Qt::CopyROP, true);
	applePix[x].setMask(applePix[x].createHeuristicMask());
    }
}
コード例 #21
0
ファイル: battery.cpp プロジェクト: serghei/kde3-kdeutils
void
BatteryConfig::ConvertIcon(int percent, QPixmap &pm, QPixmap &result)
{
	QImage image = pm.convertToImage();

	int w = image.width();
	int h = image.height();
	int count = 0;
	QRgb rgb;
	int x, y;
	for (x = 0; x < w; x++)
	for (y = 0; y < h; y++) {
		rgb = image.pixel(x, y);
		if (qRed(rgb) == 0xff &&
		    qGreen(rgb) == 0xff &&
		    qBlue(rgb) == 0xff)
			count++;
	}
	int c = (count*percent)/100;
	if (percent == 100) {
		c = count;
	} else
	if (percent != 100 && c == count)
		c = count-1;


	if (c) {
		uint ui;
		QRgb blue = qRgb(0x00,0x00,0xff);

		if (image.depth() <= 8) {
			ui = image.numColors();		// this fix thanks to Sven Krumpke
			image.setNumColors(ui+1);
			image.setColor(ui, blue);
		} else {
			ui = 0xff000000|blue;
		}

		for (y = h-1; y >= 0; y--)
		for (x = 0; x < w; x++) {
			rgb = image.pixel(x, y);
			if (qRed(rgb) == 0xff &&
		    	    qGreen(rgb) == 0xff &&
		    	    qBlue(rgb) == 0xff) {
				image.setPixel(x, y, ui);
				c--;
				if (c <= 0)
					goto quit;
			}
		}
	}
quit:

	result.convertFromImage(image);
}
コード例 #22
0
ファイル: reco.cpp プロジェクト: BackupTheBerlios/maestro-svn
void mat_Filtrer(QLabel *lblCadre)
{
    QPixmap *pix;
    QImage img;
    
    pix = lblCadre->pixmap();
    img = pix->convertToImage();
    Filtre(&img,200);
    pix->convertFromImage(img);
    lblCadre->setPixmap(*pix);
}
コード例 #23
0
ファイル: reco.cpp プロジェクト: BackupTheBerlios/maestro-svn
void mat_Eroder(QLabel *lblCadre)
{
    QPixmap *pix;
    QImage img;
    
    pix = lblCadre->pixmap();
    img = pix->convertToImage();
    Eroder(&img);
    pix->convertFromImage(img);
    lblCadre->setPixmap(*pix);
}
コード例 #24
0
ProfileOpenDlg::ProfileOpenDlg(const QString &def, const VarList &_langs, const QString &curLang, QWidget *parent)
:QDialog(parent)
{
	setupUi(this);
	setModal(true);
	setWindowTitle(CAP(caption()));

	langs = _langs;

	// insert the logo
	QPixmap logo = (QPixmap)IconsetFactory::icon("psi/psiLogo").pixmap();
	lb_logo->setPixmap(logo);
	lb_logo->setFixedSize(logo.width(), logo.height());
	lb_logo->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
	//setFixedWidth(logo->width());

	QImage logoImg = logo.convertToImage();

	QPixmap tmp;
	tmp.convertFromImage( logoImg.copy(0, 0, 1, logoImg.height()) );
	StretchLogoLabel *stretch = new StretchLogoLabel(tmp, lb_left);

	tmp.convertFromImage( logoImg.copy(logoImg.width()-1, 0, 1, logoImg.height()) );
	stretch = new StretchLogoLabel(tmp, lb_right);

	// setup signals
	connect(pb_open, SIGNAL(clicked()), SLOT(accept()));
	connect(pb_close, SIGNAL(clicked()), SLOT(reject()));
	connect(pb_profiles, SIGNAL(clicked()), SLOT(manageProfiles()));
	connect(cb_lang, SIGNAL(activated(int)), SLOT(langChange(int)));

	int x = 0;
	langSel = x;
	for(VarList::ConstIterator it = langs.begin(); it != langs.end(); ++it) {
		cb_lang->insertItem((*it).data());
		if((curLang.isEmpty() && x == 0) || (curLang == (*it).key())) {
			cb_lang->setCurrentItem(x);
			langSel = x;
		}
		++x;
	}

	// QWhatsThis helpers
	cb_profile->setWhatsThis(
		tr("Select a profile to open from this list."));
	cb_lang->setWhatsThis(
		tr("Select a language you would like Synapse-IM to use from this "
		"list.  You can download extra language packs from the Synapse-IM homepage."));
	ck_auto->setWhatsThis(
		tr("Automatically open this profile when Synapse-IM is started.  Useful if "
		"you only have one profile."));

	reload(def);
}
コード例 #25
0
void LayoutIcon::dimPixmap(QPixmap& pm)
{
	QImage image = pm.convertToImage();
	for (int y=0; y<image.height(); y++)
		for(int x=0; x<image.width(); x++)
	{
		QRgb rgb = image.pixel(x,y);
		QRgb dimRgb(qRgb(qRed(rgb)*3/4, qGreen(rgb)*3/4, qBlue(rgb)*3/4));
		image.setPixel(x, y, dimRgb);
	}
	pm.convertFromImage(image);
}
コード例 #26
0
static QPixmap appIcon(const QString &iconName)
{
     QString path;
     QPixmap normal = KGlobal::iconLoader()->loadIcon(iconName, KIcon::Small, 0, KIcon::DefaultState, &path, true);
     // make sure they are not larger than KIcon::SizeSmall
     if (normal.width() > KIcon::SizeSmall || normal.height() > KIcon::SizeSmall)
     {
         QImage tmp = normal.convertToImage();
         tmp = tmp.smoothScale(KIcon::SizeSmall, KIcon::SizeSmall);
         normal.convertFromImage(tmp);
     }
     return normal;
}
コード例 #27
0
ファイル: colorpopup.cpp プロジェクト: ozkanpakdil/f4l
void CColorPopup::mouseMoveEvent (QMouseEvent * e)
{
    QPoint p = e->globalPos ();
    QWidget * desktop = QApplication::desktop ();
    QPixmap pm = QPixmap::grabWindow (desktop->winId (), p.x (), p.y (), 1, 1);
    QImage i = pm.convertToImage ();
    QRgb px = i.pixel (0, 0);
    QColor color (qRed (px), qGreen (px), qBlue (px));
    colorShower->setPaletteBackgroundColor (color);
    QString tmp;
    tmp.sprintf ("#%02x%02x%02x",qRed (px), qGreen (px), qBlue (px));
    colorName->setText (tmp.upper ());
}
コード例 #28
0
static QPixmap scalePixmap( const QPixmap& pm, int w, int h )
{
#if QT_VERSION >= 0x030200
	QPixmap result( 20, 20, pm.depth() );
	result.setMask( QBitmap( 20, 20, true ) );
	QPixmap scaled( pm.convertToImage().smoothScale( w, h ) );
	copyBlt( &result, (20 - w) / 2, (20 - h) / 2, &scaled, 0, 0, w, h );
	return result;
#else
	Q_UNUSED(w);
	Q_UNUSED(h);
	return pm;
#endif
}
コード例 #29
0
extern "C" void gxpport_createimmutable_from_mutable
(gxpport_mutableimage_native_handle srcMutableImagePtr,
 gxpport_image_native_handle *newImmutableImagePtr,
 gxutl_native_image_error_codes* creationErrorPtr) {

    /* Convert from source QPixmap to destination QImage */
    QPixmap* srcPixmap = gxpportqt_get_mutableimage_pixmap(srcMutableImagePtr);

    int rscSize = ImgRscSize(srcPixmap); /* new img is the same size */

    /* Check resource limit before copying */
    if (midpCheckResourceLimit(RSC_TYPE_IMAGE_IMMUT, rscSize) == 0) {
        /* Exceeds resource limit */
        *creationErrorPtr  = GXUTL_NATIVE_IMAGE_RESOURCE_LIMIT;
        return;
    }

    _Platform_ImmutableImage* immutableImage =
        (_Platform_ImmutableImage*)midpMalloc(sizeof(_Platform_ImmutableImage));
    if (immutableImage == NULL) {
        *creationErrorPtr = GXUTL_NATIVE_IMAGE_OUT_OF_MEMORY_ERROR;
        return;
    }

    immutableImage->qimage = new QImage(srcPixmap->convertToImage());
    if (NULL == immutableImage->qimage) {
	midpFree(immutableImage);
        *creationErrorPtr = GXUTL_NATIVE_IMAGE_OUT_OF_MEMORY_ERROR;
        return;
    }

    if (immutableImage->qimage->isNull()) {
        delete immutableImage->qimage;
	midpFree(immutableImage);
        *creationErrorPtr = GXUTL_NATIVE_IMAGE_OUT_OF_MEMORY_ERROR;
        return;    
    }

    /* Copying succeeds */
    if (midpIncResourceCount(RSC_TYPE_IMAGE_IMMUT, rscSize) == 0) {
        REPORT_ERROR(LC_LOWUI, "Error in updating resource limit"
                     " for Immutable image");
    }

    immutableImage->marker = 1;
    immutableImage->qpixmap = NULL;

    *newImmutableImagePtr = immutableImage;
    *creationErrorPtr = GXUTL_NATIVE_IMAGE_NO_ERROR;
}
コード例 #30
0
QPixmap scalePixmap(const QPixmap &pixmap, int width, int height)
{
  if (pixmap.width()>100)
  {
    KPixmapIO io;
    QImage img(io.convertToImage(pixmap));
    return io.convertToPixmap(img.smoothScale(width,height));
  }

  QImage img(pixmap.convertToImage().smoothScale(width,height));
  QPixmap pix;
  pix.convertFromImage(img);

  return pix;
}