当前位置: 首页>>代码示例>>C++>>正文


C++ QPixmap::width方法代码示例

本文整理汇总了C++中QPixmap::width方法的典型用法代码示例。如果您正苦于以下问题:C++ QPixmap::width方法的具体用法?C++ QPixmap::width怎么用?C++ QPixmap::width使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QPixmap的用法示例。


在下文中一共展示了QPixmap::width方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: updateDiskBarPixmaps

void DiskInfoWidget::updateDiskBarPixmaps( void )
{
	if (mTabProp[usageCol]->mVisible != true)
		return;

	int size=0, w=0;

	// FIXME: Not the right width!!
/*	for(uint i=0; i<mTabProp.size()-1; i++ )
		size += mList->columnWidth(i);
	w=mList->width() - size - 4;
	if (w<0)
		w=0;
	mList->setColumnWidth(usageCol, w );*/

	int h = mList->fontMetrics().lineSpacing()-2;
	if( h <= 0 )
		return;

	int i=0;
	for(QListViewItem *it=mList->firstChild(); it!=0;it=it->nextSibling(),i++ )
	{
		// I can't get find() to work. The Disks::compareItems(..) is
		// never called.
		//
		//int pos=mDiskList->find(disk);

		DiskEntry dummy(it->text(deviceCol));
		dummy.setMountPoint(it->text(mntCol));
		int pos = -1;
		for( u_int i=0; i<mDiskList.count(); i++ )
		{
			DiskEntry *item = mDiskList.at(i);
			int res = dummy.deviceName().compare( item->deviceName() );
			if( res == 0 )
			{
				res = dummy.mountPoint().compare( item->mountPoint() );
			}
			if( res == 0 )
			{
				pos = i;
				break;
			}
		}

		DiskEntry *disk = mDiskList.at(pos);
		if( disk == 0 ) { continue; }

		if( disk->mounted() == true && disk->percentFull() != -1 )
		{
			int w = mList->columnWidth(usageCol)-2;
			if( w <= 0 ) { continue; }

			QPixmap *pix = new QPixmap( w, h );
			if( pix == 0 ) { continue; }

			pix->fill(white);
			QPainter p(pix);
			p.setPen(black);
			p.drawRect(0,0,w,h);
			QColor c;
			if ( (disk->iconName().find("cdrom") != -1)
					|| (disk->iconName().find("writer") != -1) )
				c = gray;
			else
				c = disk->percentFull() > FULL_PERCENT ? red : darkGreen;
			p.setBrush(c );
			p.setPen(white);
			p.drawRect(1,1,(int)(((float)pix->width()-2)*(disk->percentFull()/100)),
			pix->height()-2);
			it->setPixmap ( usageCol, *pix );
			p.end();
			delete pix;
		}
	}
}
开发者ID:BackupTheBerlios,项目名称:slicker-svn,代码行数:76,代码来源:diskinfo.cpp

示例2: pixPaint

SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f, bool isTestNet) :
    QSplashScreen(pixmap, f)
{
    setAutoFillBackground(true);

    // set reference point, paddings
    int paddingRight            = 50;
    int paddingTop              = 50;
    int titleVersionVSpace      = 17;
    int titleCopyrightVSpace    = 40;

    float fontFactor            = 1.0;

    // define text to place
    QString titleText       = tr("Pebblecoin Qt");
    QString versionText     = QString("Version %1").arg(QString::fromStdString(FormatFullVersion()));
    QString copyrightText   = QChar(0xA9)+QString(" 2013-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Pebblecoin developers"));
    QString testnetAddText  = QString(tr("[testnet]")); // define text to place as single text object

    QString font            = "Arial";

    // load the bitmap for writing some text over it
    QPixmap newPixmap;
    if(isTestNet) {
        newPixmap     = QPixmap(":/images/splash_testnet");
    }
    else {
        newPixmap     = QPixmap(":/images/splash");
    }

    QPainter pixPaint(&newPixmap);
    pixPaint.setPen(QColor(100,100,100));

    // check font size and drawing with
    pixPaint.setFont(QFont(font, 33*fontFactor));
    QFontMetrics fm = pixPaint.fontMetrics();
    int titleTextWidth  = fm.width(titleText);
    if(titleTextWidth > 160) {
        // strange font rendering, Arial probably not found
        fontFactor = 0.75;
    }

    pixPaint.setFont(QFont(font, 33*fontFactor));
    fm = pixPaint.fontMetrics();
    titleTextWidth  = fm.width(titleText);
    pixPaint.drawText(newPixmap.width()-titleTextWidth-paddingRight,paddingTop,titleText);

    pixPaint.setFont(QFont(font, 15*fontFactor));

    // if the version string is to long, reduce size
    fm = pixPaint.fontMetrics();
    int versionTextWidth  = fm.width(versionText);
    if(versionTextWidth > titleTextWidth+paddingRight-10) {
        pixPaint.setFont(QFont(font, 10*fontFactor));
        titleVersionVSpace -= 5;
    }
    pixPaint.drawText(newPixmap.width()-titleTextWidth-paddingRight+2,paddingTop+titleVersionVSpace,versionText);

    // draw copyright stuff
    pixPaint.setFont(QFont(font, 10*fontFactor));
    pixPaint.drawText(newPixmap.width()-titleTextWidth-paddingRight,paddingTop+titleCopyrightVSpace,copyrightText);

    // draw testnet string if testnet is on
    if(isTestNet) {
        QFont boldFont = QFont(font, 10*fontFactor);
        boldFont.setWeight(QFont::Bold);
        pixPaint.setFont(boldFont);
        fm = pixPaint.fontMetrics();
        int testnetAddTextWidth  = fm.width(testnetAddText);
        pixPaint.drawText(newPixmap.width()-testnetAddTextWidth-10,15,testnetAddText);
    }

    pixPaint.end();

    this->setPixmap(newPixmap);

    subscribeToCoreSignals();
}
开发者ID:blockchain-research-foundation,项目名称:pebblecoin,代码行数:78,代码来源:splashscreen.cpp

示例3: paintEvent

void FWObjectDropArea::paintEvent(QPaintEvent *)
{
    int w=width();
    int h=height();

    QPainter p(this);

    QPixmap bufferpixmap;
    bufferpixmap = QPixmap( w , h );
    bufferpixmap.fill( Qt::white );
    QPainter tp( &bufferpixmap );

    tp.setBrush(Qt::black);
    tp.drawLine(0,0,w-1,0);
    tp.drawLine(w-1,0,w-1,h-1);
    tp.drawLine(w-1,h-1,0,h-1);
    tp.drawLine(0,h-1,0,0);
    tp.fillRect(1, 1, w-2, h-2, Qt::white);

    if (object!=nullptr)
    {

        QPixmap pm;
        QString icn_file = (":/Icons/"+object->getTypeName()+"/icon").c_str();

        if ( ! QPixmapCache::find( icn_file, pm) )
        {
            pm.load( icn_file );
            QPixmapCache::insert( icn_file, pm);
        }

        tp.drawPixmap( ((w-pm.width())/2), (h/2)-(2+pm.height()) , pm );

        QString t=QString::fromUtf8(object->getName().c_str());

        int t_x=2;
        int t_y=2+h/2;
        int t_w=w-4;
        int t_h=h/2-4;

        tp.drawText( t_x, t_y , t_w, t_h ,
                     Qt::AlignHCenter|Qt::AlignTop|Qt::TextWordWrap, t );
    }
    else
    {
        QString t = helperText ; 

        int t_x = 2;
        int t_y = 2;
        int t_w = w-4;
        int t_h = h-4;

        tp.drawText( t_x, t_y , t_w, t_h ,
                     Qt::AlignHCenter|Qt::AlignVCenter|Qt::TextWordWrap, t );


    }
    tp.end();
    p.drawPixmap( 0, 0, bufferpixmap );

}
开发者ID:cwittmer,项目名称:fwbuilder,代码行数:61,代码来源:FWObjectDropArea.cpp

示例4: QFrame

ParameterGroupWidget::ParameterGroupWidget( ParameterWindow* pWindow, BRDFBase* brdfIn )
    : QFrame(), paramWindow(pWindow), brdf(brdfIn), visibleCheckBox(NULL), dirty(true)
{
    // start by setting the draw color of the BRDF
    brdfDrawColor[0] = drawColors[colorIndex][0];
    brdfDrawColor[1] = drawColors[colorIndex][1];
    brdfDrawColor[2] = drawColors[colorIndex][2];

    colorIndex = (colorIndex + 1) % NUM_DRAW_COLORS;



    // now let's get to the layout
    QVBoxLayout *layout = new QVBoxLayout;
    layout->setMargin( 0 );
    layout->setContentsMargins( 0, 0, 0, 0 );

    // the parameter window needs to know to emit changes whenever this BRDF is reloaded
    connect( this, SIGNAL(brdfChanged(ParameterGroupWidget*)), paramWindow, SLOT(emitBRDFListChanged()) );


    // add and connect the show/hide button
    titleButton = new QPushButton( QString("  ") + QString(extractFilename(brdf->getName()).c_str()) );
    titleButton->setFixedHeight( 22 ); 
    connect( titleButton, SIGNAL(clicked()), this, SLOT(titleButtonPushed()) );


    // set the button color to the BRDF's draw color
    changeTitleButtonColor( false );



    // make the command QFrame - contains the visible checkbox and reload/close buttons
    QFrame* cmdFrame = new QFrame;

    QHBoxLayout* cmdLayout = new QHBoxLayout;
    cmdLayout->setMargin( 0 );
    cmdLayout->setContentsMargins( 0, 0, 0, 0 );
    cmdLayout->setSpacing( 11 );
    cmdFrame->setLayout( cmdLayout );


    visibleCheckBox = new QCheckBox( "Visible" );
    visibleCheckBox->setChecked( true );
    cmdLayout->addWidget( visibleCheckBox );
    connect( visibleCheckBox, SIGNAL(stateChanged(int)), this, SLOT(paramChanged()) );


    // add the solo button
    soloButton = new QPushButton();
    QPixmap* soloPixmap = new QPixmap((getImagesPath() + "soloSmall.png").c_str());
    soloButton->setIconSize( QSize(soloPixmap->width(), soloPixmap->height()) );
    soloButton->setIcon( QIcon(*soloPixmap) );
    soloButton->setFixedWidth( 24 );
    soloButton->setFixedHeight( 20 );
    soloButton->setCheckable( true );
    soloButton->setChecked( false );
    soloButton->setToolTip( "Solo this BRDF" );
    connect( soloButton, SIGNAL(clicked()), this, SLOT(soloButtonPushed()) );
    cmdLayout->addWidget( soloButton );


    // add the solo colors button
    soloColorsButton = new QPushButton();
    QPixmap* soloColorsPixmap = new QPixmap((getImagesPath() + "soloColorsSmall.png").c_str());
    soloColorsButton->setIconSize( QSize(soloColorsPixmap->width(), soloColorsPixmap->height()) );
    soloColorsButton->setIcon( QIcon(*soloColorsPixmap) );
    soloColorsButton->setFixedWidth( 24 );
    soloColorsButton->setFixedHeight( 20 );
    soloColorsButton->setCheckable( true );
    soloColorsButton->setChecked( false );
    soloColorsButton->setToolTip( "Solo this BRDF's color channels" );
    connect( soloColorsButton, SIGNAL(clicked()), this, SLOT(soloColorsButtonPushed()) );
    cmdLayout->addWidget( soloColorsButton );
   
    
    QMenu* optionsMenu = new QMenu;
    QAction* reloadAction = optionsMenu->addAction( "Reload BRDF" );
    QPixmap* reloadPixmap = new QPixmap((getImagesPath() + "reloadSmall.png").c_str());
    reloadAction->setIcon( QIcon(*reloadPixmap) );    
    connect( reloadAction, SIGNAL(triggered()), this, SLOT(reloadButtonPushed()) );
    
    QAction* resetAction = optionsMenu->addAction( "Reload BRDF and reset to default" );
    QPixmap* resetPixmap = new QPixmap((getImagesPath() + "resetSmall.png").c_str());
    resetAction->setIcon( QIcon(*resetPixmap) );
    connect( resetAction, SIGNAL(triggered()), this, SLOT(resetButtonPushed()) );
    
    QAction* saveAction = optionsMenu->addAction( "Save Parameters File..." );
    QPixmap* folderPixmap = new QPixmap((getImagesPath() + "folderSmall.png").c_str());
    saveAction->setIcon( QIcon(*folderPixmap) );
    connect( saveAction, SIGNAL(triggered()), this, SLOT(saveParamsFileButtonPushed()) );
    
    optionsMenu->addSeparator();
    
    QAction* closeAction = optionsMenu->addAction( "Close BRDF" );
    QPixmap* closePixmap = new QPixmap((getImagesPath() + "closeSmall.png").c_str());
    closeAction->setIcon( QIcon(*closePixmap) );
    connect( closeAction, SIGNAL(triggered()), this, SLOT(removeButtonPushed()) );
    

//.........这里部分代码省略.........
开发者ID:wdas,项目名称:brdf,代码行数:101,代码来源:ParameterGroupWidget.cpp

示例5: CScreenShotScene

CScreenShotView::CScreenShotView(const QList<QRect> &rectList,
                                 QScreen *screen, bool onlySelect,
                                 QWidget *parent)
    :QGraphicsView(parent)
    ,m_windowRectList(rectList)
    ,m_desktopScreen(screen)
    ,m_screen(NULL)
    ,m_backgroundItem(NULL)
    ,m_selectRectItem(NULL)
    ,m_toolbarItem(NULL)
    ,m_currentRectItem(NULL)
    ,m_tooltipSizeItem(NULL)
    ,m_previewItem(NULL)
    ,m_positionType(CSCREEN_POSITION_TYPE_NOT_CONTAIN)
    ,m_shotStatus(CSCREEN_SHOT_STATE_INITIALIZED)
    ,m_screenButtonType(CSCREEN_BUTTON_TYPE_UNDEFINED)
    ,m_isPressed(false)
    ,m_isLocked(false)
    ,m_isValid(false)
    ,m_onlySelect(onlySelect)
{
    C_SCREENSHOT_LOG_FUNCTION;
    this->setMouseTracking(true);
    m_screen = new CScreenShotScene(this);
    this->setScene(m_screen);
    QRect geometry= screen->geometry();
    C_SCREENSHOT_LOG_INFO(QString("screen->geometry() (%1,%2,%3,%4)")
                           .arg(geometry.x())
                           .arg(geometry.y())
                           .arg(geometry.width())
                           .arg(geometry.height()));
    C_SCREENSHOT_LOG_TEST;
    QPixmap pixmap = createDesktopPixmap();
    C_SCREENSHOT_LOG_TEST;
    drawPixmap(pixmap);
    m_backgroundItem = new QGraphicsPixmapItem(m_backgroundPixmap);
    m_screen->addItem(m_backgroundItem);
    C_SCREENSHOT_LOG_TEST;
    this->setGeometry(geometry);
    m_screen->setSceneRect(QRect(0,0,geometry.width(),geometry.height()));
    m_sx = 1.0 * geometry.width() / pixmap.width();
    m_sy = 1.0 * geometry.height() / pixmap.height();

    m_backgroundItem->setScale(m_sx);
    m_selectRectItem = new CScreenSelectRectItem(m_desktopPixmap);
    m_selectRectItem->setScale(m_sx);
    m_selectRectItem->setVisible(false);
    m_screen->addItem(m_selectRectItem);
    C_SCREENSHOT_LOG_TEST;
    //====================
    m_toolbarItem = new CScreenEditorToolbarItem;
    connect(m_toolbarItem,SIGNAL(sigButtonClicked(CScreenButtonType)),
            this,SLOT(onButtonClicked(CScreenButtonType)));
    m_toolbarItem->setVisible(false);
    m_toolbarItem->setZValue(m_selectRectItem->zValue() + 1);
    m_screen->addItem(m_toolbarItem);
    m_tooltipSizeItem = new CScreenTooltipItem;
    C_SCREENSHOT_LOG_TEST;
    m_tooltipSizeItem->setVisible(false);
    m_screen->addItem(m_tooltipSizeItem);
    m_previewItem = new QGraphicsPixmapItem;
    m_previewItem->setVisible(false);
    m_previewItem->setZValue(m_toolbarItem->zValue() + 1);
    C_SCREENSHOT_LOG_TEST;
    m_screen->addItem(m_previewItem);
    this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    this->setStyleSheet("QWidget{border: 0px solid #1880ed;}");
#ifdef Q_OS_MAC
    qApp->installEventFilter(this);
#endif
    QPoint pos = QCursor::pos();
    if(geometry.contains(pos))
    {
        //TODO 暂时屏蔽 为了快速启动,耗时400ms
//        updatePreviewItem(this->mapFromGlobal(pos));
    }
    C_SCREENSHOT_LOG_TEST;
}
开发者ID:weinkym,项目名称:src_miao,代码行数:79,代码来源:cscreenshotview.cpp

示例6: boundingRect

QRectF ScenePixmapItem::boundingRect (){
	QPixmap p = pixmap();
//  	qDebug() << "ScenePixmapItem::pixmap width" << (qreal)p.width(); // obrigado por testares :)
	return QRectF(0.0,0.0,(qreal)p.width(),(qreal)p.height());
}
开发者ID:LC43,项目名称:floorplan,代码行数:5,代码来源:scenepixmapitem.cpp

示例7: drawLabel

void Flags::drawLabel(QPainter& painter, const QString& layoutText, bool flagShown)
{
    QFont font = painter.font();

    QRect rect = painter.window();
//	int fontSize = layoutText.length() == 2
//			? height * 7 / 10
//			: height * 5 / 10;

    int fontSize = rect.height();// * 7 /10;

    font.setPixelSize(fontSize);
    font.setWeight(QFont::DemiBold);

    QFontMetrics fm = painter.fontMetrics();
    int width = fm.width(layoutText);

    if( width > rect.width() * 2 / 3 ) {
        fontSize = round( (double)fontSize * ((double)rect.width()*2/3) / width );
    }

    int smallestReadableSize = KGlobalSettings::smallestReadableFont().pixelSize();
    if( fontSize < smallestReadableSize ) {
        fontSize = smallestReadableSize;
    }
    font.setPixelSize(fontSize);

#ifdef DONT_USE_PLASMA
    painter.setFont(font);
    painter.setPen(Qt::white);
    painter.drawText(QRect(rect).adust(1,1,0,0), Qt::AlignCenter | Qt::AlignHCenter, layoutText);
    painter.setPen(Qt::black);
    painter.drawText(rect, Qt::AlignCenter | Qt::AlignHCenter, layoutText);
#else
    // we init svg so that we get notification about theme change
    getSvg();

    Plasma::Theme theme;
    QColor textColor = flagShown ? Qt::black : theme.color(Plasma::Theme::TextColor);
    QPoint offset = QPoint(0, 0);

    auto shadowText = [&font, &textColor, &offset](QString text) {
        //don't try to paint stuff on a future null pixmap because the text is empty
        if (text.isEmpty()) {
            return QPixmap();
        }

        // Draw text
        QFontMetrics fm(font);
        QRect textRect = fm.boundingRect(text);
        QPixmap textPixmap(textRect.width(), fm.height());
        textPixmap.fill(Qt::transparent);
        QPainter p(&textPixmap);
        p.setPen(textColor);
        p.setFont(font);
        // FIXME: the center alignment here is odd: the rect should be the size needed by
        //        the text, but for some fonts and configurations this is off by a pixel or so
        //        and "centering" the text painting 'fixes' that. Need to research why
        //        this is the case and determine if we should be painting it differently here,
        //        doing soething different with the boundingRect call or if it's a problem
        //        in Qt itself
        p.drawText(textPixmap.rect(), Qt::AlignCenter, text);
        p.end();

        return textPixmap;
    };

    //    QPixmap pixmap = Plasma::PaintUtils::texturedText(layoutText, font, svg);
    QPixmap labelPixmap = shadowText(layoutText);

    int y = round((rect.height() - labelPixmap.height()) / 2.0);
    int x = round((rect.width() - labelPixmap.width()) / 2.0);
    painter.drawPixmap(QPoint(x, y), labelPixmap);
#endif
}
开发者ID:KDE,项目名称:kde-workspace,代码行数:75,代码来源:flags.cpp

示例8: paint

void rosterItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
    painter->save();
    painter->setRenderHint(QPainter::TextAntialiasing);
    QVariant value = index.data(Qt::DecorationRole);

    QColor selectedBg(60, 140, 222);
    QColor alternateBg(239, 245, 254);
    QColor selectedText(Qt::white);

    QColor nameTextColor(Qt::black);
    QColor statusTextColor(Qt::darkGray);

    QPixmap pixmap;
    if(value.type() == QVariant::Icon)
    {
        QIcon icon = qvariant_cast<QIcon>(value);
        pixmap = icon.pixmap(QSize(16, 16), QIcon::Normal, QIcon::On);
    }

    QPen penDivision;
//        if(index.row() % 2)
//            painter->fillRect(option.rect, alternateBg);

    if (option.state & QStyle::State_Selected)
    {
        painter->fillRect(option.rect, selectedBg);
//            painter->fillRect(option.rect, option.palette.highlight());
//            penDivision.setColor(option.palette.highlight().color());
        penDivision.setColor(selectedBg);
        nameTextColor = selectedText;
        statusTextColor = selectedText;
    }
    else
    {
        penDivision.setColor(QColor(244, 244, 244));
    }

    QRect rect = option.rect;
    rect.setWidth(pixmap.width());
    rect.setHeight(pixmap.height());
    rect.moveTop(rect.y() + (option.rect.height() - pixmap.height())/2);
    rect.moveLeft(rect.left() + 2);
    painter->drawPixmap(rect, pixmap);

    rect = option.rect;
    rect.setLeft(rect.x() + pixmap.width() + 8);
    rect.moveTop(rect.y() + 3);
    QFont font;
    painter->setFont(font);
    painter->setPen(nameTextColor);
    if(!index.data(Qt::DisplayRole).toString().isEmpty())
        painter->drawText(rect, index.data(Qt::DisplayRole).toString());
    else
        painter->drawText(rect, index.data(rosterItem::BareJid).toString());

    painter->setPen(statusTextColor);
    rect.setTop(rect.y() + rect.height()/2);
    rect.moveTop(rect.y() - 3);
    QString statusText = index.data(rosterItem::StatusText).toString();
    QFontMetrics fontMetrics(font);
    statusText = fontMetrics.elidedText(statusText, Qt::ElideRight, rect.width() - 34);
    painter->drawText(rect, statusText);

    penDivision.setWidth(0);
    painter->setPen(penDivision);

    rect = option.rect;
    QPoint left = rect.bottomLeft();
    left.setX(left.x() + 4);
    QPoint right = rect.bottomRight();
    right.setX(right.x() - 4);
    painter->drawLine(left, right);

    QImage image;
    value = index.data(rosterItem::Avatar);
    if(value.type() == QVariant::Image)
    {
        image = qvariant_cast<QImage>(value);
    }

    pixmap = QPixmap(":/icons/resource/avatar.png");
    rect = option.rect;
    rect.setWidth(pixmap.width());
    rect.setHeight(pixmap.height());
    rect.moveTop(rect.y() + (option.rect.height() - pixmap.height())/2);
    rect.moveLeft(option.rect.x() + option.rect.width() - pixmap.width() - 2);

//    if(image.isNull())
//        painter->drawPixmap(rect, pixmap);
//    else
        painter->drawImage(rect, image);

    painter->restore();
}
开发者ID:Aseman-Land,项目名称:qxmpp,代码行数:95,代码来源:rosterItem.cpp

示例9: DisplayHu

void GBMJDesktopController::DisplayHu(unsigned char chSite,const unsigned char *data,unsigned char chLen)
{
    djDebug()<<"GBMJDesktopController::DisplayHu"<<"seat"<<chSite<<"len"<<chLen;
    DebugBuffer( (const char*)data, chLen );
    unsigned char ch;
    QString strName;
    DJGraphicsPixmapItem *item;
    DJGraphicsTextItem	*itemText;
    QPixmap			pix;
    QFont			font;
    int x,y,i;

    for ( int i = 0; i <= panelController()->numberOfSeats(); ++i ) {
        clearSeatTypeItems(i,0);
    }

    DJGameUser *user	= panelController()->player( chSite );
    if ( user )
        strName	= user->userName();
    else
        strName	= tr("no name");
    if(data[0] == chSite || data[0] == 0 || data[0]>4)
    {
        strName+= tr("zi mo");
        strName += tr("hu");
    } else
    {
        strName += tr("hu");
        strName += QString(" , ");
        DJGameUser *dianpao	= panelController()->player( data[0] );
        if ( dianpao )
            strName	+= dianpao->userName();
        else
            strName	+= tr("no name");
        strName += tr("dian pao");
    }
    //itemText = new DJGameTextItem(strName,canvas(),m,0x01,0x01,DJGAME_DESKTOP_TYPE_HU_TEXT,false);
    itemText	= new DJGraphicsTextItem(strName, 0, desktop()->scene());
    appendSeatTypeItem(chSite,DJGAME_DESKTOP_TYPE_HU_TEXT,itemText);
    font = itemText->font();
    font.setPointSize(28);
    font.setBold(true);
    itemText->setFont(font);
    int h;
    pix = GetView1Card(1,false,false,&h);
    GetDesktopCenterPoint(&x,&y,NULL);
    x -= (7*pix.width());
    y = DJGAME_MAHJONG_DESKTOP_AVATAR_MAXHEIGHT+20;
    itemText->setZValue(3000);
    itemText->setVirtualPos( QPointF(x,y) );
    itemText->setMatrix( desktop()->scaleMatrix() );
    itemText->adjustPos( desktop()->totalMatrix() );
    itemText->show();
    y += 50;

    DJGraphicsPixmapItem *huit = NULL;
    if(data[2]>0)
    {
        djDebug()<<"data[2]="<<hex<<data[2];
        for(i=0; i<data[2]; i++)
        {
            djDebug()<<"card="<<hex<<(data[3+i]&0x3F);
            pix = GetView1Card((data[3+i]&0x3F),false,false,&h);
            item = new DJGraphicsPixmapItem(pix, 0, desktop()->scene());
            appendSeatTypeItem(chSite,DJGAME_DESKTOP_TYPE_HU_CARD,item);
            if((data[3+i]&0x3F) == (data[1] & 0x3F))
                huit = item;
            item->setZValue(3000);
            item->setVirtualPos( QPointF(x,y) );
            item->setMatrix( desktop()->scaleMatrix() );
            item->adjustPos( desktop()->totalMatrix() );
            item->show();
            x += pix.width();
        }
        if(huit != NULL)
            huit->setDJSelected(true);
        ch = data[2]+3;
        GetDesktopCenterPoint(&x,NULL,NULL);
        y += pix.height()+20;
        i=0;
        QString str;
        font.setPointSize(24);
        while(data[ch] != 0 && ch<chLen)
        {
            str = tr(fanNames[data[ch]]);
            //itemText = new DJGameTextItem(str,canvas(),m,0x01,0x01,DJGAME_DESKTOP_TYPE_HU_TEXT,false);
            itemText	= new DJGraphicsTextItem(str, 0, desktop()->scene());
            appendSeatTypeItem(chSite,DJGAME_DESKTOP_TYPE_HU_TEXT,itemText);
            itemText->setFont(font);
            itemText->setAlignment(Qt::AlignRight);
            itemText->setZValue(3000);
            itemText->setVirtualPos( QPointF(x,y) );
            itemText->setMatrix( desktop()->scaleMatrix() );
            itemText->adjustPos( desktop()->totalMatrix() );
            itemText->show();

            str = QString(" : %1 ").arg(data[ch+1])+ tr("fan");
            //itemText = new DJGameTextItem(str,canvas(),m,0x01,0x01,DJGAME_DESKTOP_TYPE_HU_TEXT,false);
            itemText	= new DJGraphicsTextItem(str, 0, desktop()->scene());
            appendSeatTypeItem(chSite,DJGAME_DESKTOP_TYPE_HU_TEXT,itemText);
//.........这里部分代码省略.........
开发者ID:CecilHarvey,项目名称:BlueDJGames,代码行数:101,代码来源:复件+GBMJDesktopController.cpp

示例10: makeDragPixmap

QPixmap DItemDelegate::makeDragPixmap(const QStyleOptionViewItem& option,
                                      const QList<QModelIndex>& indexes,
                                      const QPixmap& suggestedPixmap)
{
    QPixmap icon = suggestedPixmap;

    if (icon.isNull())
    {
        icon = QPixmap(DesktopIcon("image-jp2", KIconLoader::SizeMedium));
    }

    if (qMax(icon.width(), icon.height()) > KIconLoader::SizeHuge)
    {
        icon = icon.scaled(KIconLoader::SizeHuge, KIconLoader::SizeHuge,
                           Qt::KeepAspectRatio, Qt::SmoothTransformation);
    }

    int w                 = icon.width();
    int h                 = icon.height();
    const int borderWidth = 6;

    QRect   rect(0, 0, w + borderWidth*2, h + borderWidth*2);
    QRect   pixmapRect(borderWidth, borderWidth, w, h);

    QPixmap pix(rect.size());
    QPainter p(&pix);

/* 
    // border
    p.fillRect(0, 0, pix.width()-1, pix.height()-1, QColor(Qt::white));
    p.setPen(QPen(Qt::black, 1));
    p.drawRect(0, 0, pix.width()-1, pix.height()-1);
*/

    QStyleOption opt(option);
    opt.rect = rect;
    qApp->style()->drawPrimitive(QStyle::PE_PanelTipLabel, &opt, &p);

    p.drawPixmap(pixmapRect.topLeft(), icon);

    QFont f(option.font);
    f.setBold(true);
    p.setFont(f);

    if (indexes.size() > 1)
    {
        QRect   textRect;
        QString text;

        QString text2(i18np("1 Image", "%1 Images", indexes.count()));
        QString text1 = QString::number(indexes.count());
        QRect r1      = p.boundingRect(pixmapRect, Qt::AlignLeft|Qt::AlignTop, text1).adjusted(0,0,1,1);
        QRect r2      = p.boundingRect(pixmapRect, Qt::AlignLeft|Qt::AlignTop, text2).adjusted(0,0,1,1);

        if (r2.width() > pixmapRect.width() || r2.height() > pixmapRect.height())
        {
//            textRect     = r1;
            text         = text1;
            int rectSize = qMax(r1.width(), r1.height());
            textRect     = QRect(0, 0, rectSize, rectSize);
        }
        else
        {
            textRect = QRect(0, 0, r2.width(), r2.height());
            text     = text2;
        }

        textRect.moveLeft((pixmapRect.width() - textRect.width()) / 2 + pixmapRect.x());
        textRect.moveTop((pixmapRect.height() - textRect.height()) * 4 / 5);
        p.fillRect(textRect, QColor(0, 0, 0, 128));
        p.setPen(Qt::white);
        p.drawText(textRect, Qt::AlignCenter, text);
    }

    return pix;
}
开发者ID:rickysarraf,项目名称:digikam,代码行数:76,代码来源:ditemdelegate.cpp

示例11: prepareImages


//.........这里部分代码省略.........
				filename = patterns.front().replace('*', filename);
			}
			filesize = data.size();
		}
	} else {
		if (type == ToPrepareDocument) {
			filename = filedialogDefaultName(qsl("image"), qsl(".png"), QString(), true);
			QMimeType mimeType = QMimeDatabase().mimeTypeForName("image/png");
			data = QByteArray();
			{
				QBuffer b(&data);
				img.save(&b, "PNG");
			}
			filesize = data.size();
		} else {
			type = ToPreparePhoto; // only photo from QImage
			filename = qsl("Untitled.jpg");
			filesize = 0;
		}
	}

	if ((img.isNull() && (type != ToPrepareDocument || !filesize)) || type == ToPrepareAuto || (img.isNull() && file.isEmpty() && data.isEmpty())) { // if could not decide what type
		{
			QMutexLocker lock(loader->toPrepareMutex());
			ToPrepareMedias &list(loader->toPrepareMedias());
			list.pop_front();
		}

		QTimer::singleShot(1, this, SLOT(prepareImages()));

		emit imageFailed(id);
	} else {
		PreparedPhotoThumbs photoThumbs;
		QVector<MTPPhotoSize> photoSizes;

		MTPPhotoSize thumb(MTP_photoSizeEmpty(MTP_string("")));
		MTPPhoto photo(MTP_photoEmpty(MTP_long(0)));
		MTPDocument document(MTP_documentEmpty(MTP_long(0)));

		QByteArray jpeg;
		if (type == ToPreparePhoto) {
			int32 w = img.width(), h = img.height();

			QPixmap thumb = (w > 100 || h > 100) ? QPixmap::fromImage(img.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation)) : QPixmap::fromImage(img);
			photoThumbs.insert('s', thumb);
			photoSizes.push_back(MTP_photoSize(MTP_string("s"), MTP_fileLocationUnavailable(MTP_long(0), MTP_int(0), MTP_long(0)), MTP_int(thumb.width()), MTP_int(thumb.height()), MTP_int(0)));

			QPixmap medium = (w > 320 || h > 320) ? QPixmap::fromImage(img.scaled(320, 320, Qt::KeepAspectRatio, Qt::SmoothTransformation)) : QPixmap::fromImage(img);
			photoThumbs.insert('m', medium);
			photoSizes.push_back(MTP_photoSize(MTP_string("m"), MTP_fileLocationUnavailable(MTP_long(0), MTP_int(0), MTP_long(0)), MTP_int(medium.width()), MTP_int(medium.height()), MTP_int(0)));

			QPixmap full = (w > 800 || h > 800) ? QPixmap::fromImage(img.scaled(800, 800, Qt::KeepAspectRatio, Qt::SmoothTransformation)) : QPixmap::fromImage(img);
			photoThumbs.insert('x', full);
			photoSizes.push_back(MTP_photoSize(MTP_string("x"), MTP_fileLocationUnavailable(MTP_long(0), MTP_int(0), MTP_long(0)), MTP_int(full.width()), MTP_int(full.height()), MTP_int(0)));

			{
				QBuffer jpegBuffer(&jpeg);
				full.save(&jpegBuffer, "JPG", 87);
			}
			if (!filesize) filesize = jpeg.size();
		
			photo = MTP_photo(MTP_long(id), MTP_long(0), MTP_int(user), MTP_int(unixtime()), MTP_string(""), MTP_geoPointEmpty(), MTP_vector<MTPPhotoSize>(photoSizes));

			jpeg_id = id;
		} else if ((type == ToPrepareVideo || type == ToPrepareDocument) && !img.isNull()) {
			int32 w = img.width(), h = img.height();

			QPixmap full = (w > 90 || h > 90) ? QPixmap::fromImage(img.scaled(90, 90, Qt::KeepAspectRatio, Qt::SmoothTransformation)) : QPixmap::fromImage(img);

			{
				QBuffer jpegBuffer(&jpeg);
				full.save(&jpegBuffer, "JPG", 87);
			}

			photoThumbs.insert('0', full);
			thumb = MTP_photoSize(MTP_string(""), MTP_fileLocationUnavailable(MTP_long(0), MTP_int(0), MTP_long(0)), MTP_int(full.width()), MTP_int(full.height()), MTP_int(0));

			jpeg_id = MTP::nonce<uint64>();
		}

		if (type == ToPrepareDocument) {
			document = MTP_document(MTP_long(id), MTP_long(0), MTP_int(MTP::authedId()), MTP_int(unixtime()), MTP_string(filename), MTP_string(mime), MTP_int(filesize), thumb, MTP_int(MTP::maindc()));
		}

		{
			QMutexLocker lock(loader->readyMutex());
			loader->readyList().push_back(ReadyLocalMedia(type, file, filename, filesize, data, id, jpeg_id, peer, photo, photoThumbs, document, jpeg));
		}

		{
			QMutexLocker lock(loader->toPrepareMutex());
			ToPrepareMedias &list(loader->toPrepareMedias());
			list.pop_front();
		}

		QTimer::singleShot(1, this, SLOT(prepareImages()));

		emit imageReady();
	}
}
开发者ID:2k13yr,项目名称:tdesktop,代码行数:101,代码来源:localimageloader.cpp

示例12: wakeUpLibrary

void TupCanvas::wakeUpLibrary()
{
    QString graphicPath = QFileDialog::getOpenFileName (this, tr("Import a SVG file..."), QDir::homePath(),
                                                    tr("Vectorial") + " (*.svg *.png *.jpg *.jpeg *.gif)");
    if (graphicPath.isEmpty())
        return;

    QFile f(graphicPath);
    QFileInfo fileInfo(f);

    if (graphicPath.toLower().endsWith(".svg")) {
        QString tag = fileInfo.fileName();

        if (f.open(QIODevice::ReadOnly)) {
            QByteArray data = f.readAll();
            f.close();
            // int projectWidth = k->size.width();
            // int projectHeight = k->size.height();

            TupProjectRequest request = TupRequestBuilder::createLibraryRequest(TupProjectRequest::Add, tag,
                                        TupLibraryObject::Svg, TupProject::FRAMES_EDITION, data, QString(),
                                        k->scene->currentSceneIndex(), k->scene->currentLayerIndex(), k->scene->currentFrameIndex());
            emit requestTriggered(&request);
        }
    } else {
        QString symName = fileInfo.fileName();

        if (f.open(QIODevice::ReadOnly)) {
            QByteArray data = f.readAll();
            f.close();

            QPixmap *pixmap = new QPixmap(graphicPath);
            int picWidth = pixmap->width();
            int picHeight = pixmap->height();
            int projectWidth = k->size.width(); 
            int projectHeight = k->size.height();

            if (picWidth > projectWidth || picHeight > projectHeight) {
                QDesktopWidget desktop;
                QMessageBox msgBox;
                msgBox.setWindowTitle(tr("Information"));
                msgBox.setIcon(QMessageBox::Question);
                msgBox.setText(tr("Image is bigger than workspace."));
                msgBox.setInformativeText(tr("Do you want to resize it?"));
                msgBox.setStandardButtons(QMessageBox::No | QMessageBox::Yes);
                msgBox.setDefaultButton(QMessageBox::Ok);
                msgBox.show();
                msgBox.move((int) (desktop.screenGeometry().width() - msgBox.width())/2,
                            (int) (desktop.screenGeometry().height() - msgBox.height())/2);

                int answer = msgBox.exec();

                if (answer == QMessageBox::Yes) {
                    pixmap = new QPixmap();
                    QString extension = fileInfo.suffix().toUpper();
                    QByteArray ba = extension.toAscii();
                    const char* ext = ba.data();
                    if (pixmap->loadFromData(data, ext)) {
                        QPixmap newpix;
                        if (picWidth > projectWidth)
                            newpix = QPixmap(pixmap->scaledToWidth(projectWidth, Qt::SmoothTransformation));
                        else
                            newpix = QPixmap(pixmap->scaledToHeight(projectHeight, Qt::SmoothTransformation));
                        QBuffer buffer(&data);
                        buffer.open(QIODevice::WriteOnly);
                        newpix.save(&buffer, ext);
                    }
                }
           }

           QString tag = symName;

           TupProjectRequest request = TupRequestBuilder::createLibraryRequest(TupProjectRequest::Add, tag,
                                                                               TupLibraryObject::Image, TupProject::FRAMES_EDITION, data, QString(),
                                                                               k->scene->currentSceneIndex(), k->scene->currentLayerIndex(), k->scene->currentFrameIndex());
           emit requestTriggered(&request);

           data.clear();
        }
    }
}
开发者ID:hpsaturn,项目名称:tupi,代码行数:81,代码来源:tupcanvas.pc.cpp

示例13: drawSegmentControlSegmentLabel

static void drawSegmentControlSegmentLabel(const QStyleOption *option, QPainter *painter, QWidget *widget)
{
    if (const QtStyleOptionSegmentControlSegment *segment
            = static_cast<const QtStyleOptionSegmentControlSegment *>(option)) {
#ifdef Q_WS_MAC
        if (qobject_cast<QMacStyle *>(widget->style())) {
            QRect retRect = option->rect;
            retRect.adjust(+11, +4, -11, -6);
            switch (segment->position) {
            default:
            case QtStyleOptionSegmentControlSegment::Middle:
                break;
            case QtStyleOptionSegmentControlSegment::Beginning:
            case QtStyleOptionSegmentControlSegment::End:
                retRect.adjust(+1, 0, -1, 0);
                break;
            case QtStyleOptionSegmentControlSegment::OnlyOneSegment:
                retRect.adjust(+2, 0, -2, 0);
                break;
            }
        }
#endif
        QStyleOptionButton btn;
        btn.QStyleOption::operator=(*option);
        btn.text = segment->text;
        btn.icon = segment->icon;
        btn.iconSize = segment->iconSize;

        QStyleOptionButton *button = &btn;

        uint tf = Qt::AlignVCenter | Qt::TextShowMnemonic;
        QRect textRect = button->rect;
        if (!button->icon.isNull()) {
            //Center both icon and text
            QRect iconRect;
            QIcon::Mode mode = button->state & QStyle::State_Enabled ? QIcon::Normal : QIcon::Disabled;
            if (mode == QIcon::Normal && button->state & QStyle::State_HasFocus)
                mode = QIcon::Active;
            QIcon::State state = QIcon::Off;
            if (button->state & QStyle::State_On)
                state = QIcon::On;

            QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state);
            int labelWidth = pixmap.width();
            int labelHeight = pixmap.height();
            int iconSpacing = 0; //### 4 is currently hardcoded in QPushButton::sizeHint()
            int textWidth = button->fontMetrics.boundingRect(button->rect, tf, button->text).width();
            if (!button->text.isEmpty())
                labelWidth += (textWidth + iconSpacing);

//            iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2,
//                             textRect.y() + (textRect.height() - labelHeight) / 2,
//                             pixmap.width(), pixmap.height());

            iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2,
                             textRect.y() + (textRect.height() - labelHeight) / 2 - 3,
                             pixmap.width(), pixmap.height());

            iconRect = QStyle::visualRect(button->direction, textRect, iconRect);

            tf |= Qt::AlignLeft; //left align, we adjust the text-rect instead

            if (button->direction == Qt::RightToLeft)
                textRect.setRight(iconRect.left() - iconSpacing);
            else
                textRect.setLeft(iconRect.left() + iconRect.width() + iconSpacing);

            if (button->state & (QStyle::State_On | QStyle::State_Sunken))
                iconRect.translate(widget->style()->pixelMetric(QStyle::PM_ButtonShiftHorizontal, button, widget),
                                   widget->style()->pixelMetric(QStyle::PM_ButtonShiftVertical, button, widget));
            painter->drawPixmap(iconRect, pixmap);
        } else {
            tf |= Qt::AlignHCenter;
        }

        if (button->state & (QStyle::State_On | QStyle::State_Sunken))
            textRect.translate(widget->style()->pixelMetric(QStyle::PM_ButtonShiftHorizontal, button, widget),
                         widget->style()->pixelMetric(QStyle::PM_ButtonShiftVertical, button, widget));

        if (button->features & QStyleOptionButton::HasMenu) {
            int indicatorSize = widget->style()->pixelMetric(QStyle::PM_MenuButtonIndicator, button, widget);
            if (button->direction == Qt::LeftToRight)
                textRect = textRect.adjusted(0, 0, -indicatorSize, 0);
            else
                textRect = textRect.adjusted(indicatorSize, 0, 0, 0);
        }
        widget->style()->drawItemText(painter, textRect, tf, button->palette, (button->state & QStyle::State_Enabled),
                                      button->text, QPalette::ButtonText);

        //widget->style()->drawControl(QStyle::CE_PushButtonLabel, &button, painter, widget);
    }

}
开发者ID:liuyd07,项目名称:WizQTClient,代码行数:93,代码来源:qsegmentcontrol.cpp

示例14: generateWallpaperImages

void WindowServerLuna::generateWallpaperImages()
{
	qreal hScale, vScale, wallpaperScale, wallpaperScaleRot = 0.0;

	int screenWidth = SystemUiController::instance()->currentUiWidth();
	int screenHeight = SystemUiController::instance()->currentUiHeight();

	QPixmap image = QPixmap(m_wallpaperFileName);
	if (image.isNull())
		return;

	bool desktop(false);
#ifdef TARGET_DESKTOP
	desktop = true;
#endif

	if(((image.width() < screenWidth) || (image.height() < screenHeight)) && ((image.height() < screenWidth) || (image.width() < screenHeight)) && !desktop) {
		// image is not large enough to fill the screen in any orientation, so do not scale it and
		// draw it centered on the screen
		m_normalWallpaperImage = QPixmap(image.width(), image.height());
		m_rotatedWallpaperImage = QPixmap();

		wallpaperScale = 1;
		m_wallpaperFullScreen = false;
		if (m_normalWallpaperImage.isNull())
			return;
	} else {
		// image can fill the screen in some orientations, so scale it to always fill the entire screen
		m_normalWallpaperImage = QPixmap(m_screenWidth, m_screenHeight);
		m_rotatedWallpaperImage = QPixmap(m_screenWidth, m_screenHeight);

		hScale = (qreal)m_screenWidth / image.width();
		vScale = (qreal)m_screenHeight / image.height();

		if(hScale >= vScale)
			wallpaperScale = hScale;
		else
			wallpaperScale = vScale;

		vScale = (qreal)m_screenHeight / image.width();
		hScale = (qreal)m_screenWidth / image.height();

		if(hScale >= vScale)
			wallpaperScaleRot = hScale;
		else
			wallpaperScaleRot = vScale;

		m_wallpaperFullScreen = true;

		if (m_normalWallpaperImage.isNull())
			return;
		if (m_rotatedWallpaperImage.isNull())
			return;
	}

	QRect target;
	QPainter painter;
	painter.begin(&m_normalWallpaperImage);

	target = QRect((-image.rect().width()/2), (-image.rect().height()/2), image.rect().width(), image.rect().height());

	painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
	painter.translate(m_normalWallpaperImage.width()/2, m_normalWallpaperImage.height()/2);
	painter.scale(wallpaperScale,wallpaperScale);

	painter.drawPixmap(target, image);

	painter.end();

	if(m_wallpaperFullScreen) {// also generate the cropped and rotated version
		painter.begin(&m_rotatedWallpaperImage);

		target = QRect((-image.rect().width()/2), (-image.rect().height()/2), image.rect().width(), image.rect().height());

		painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
		painter.translate(m_rotatedWallpaperImage.width()/2, m_rotatedWallpaperImage.height()/2);
		painter.rotate(90);
		painter.scale(wallpaperScaleRot,wallpaperScaleRot);

		painter.drawPixmap(target, image);

		painter.end();
	}

	if(Settings::LunaSettings()->displayUiRotates) {
		updateWallpaperForRotation(m_currentUiOrientation);
	} else {
		m_currWallpaperImg = &m_normalWallpaperImage;
		Q_EMIT signalWallpaperImageChanged(m_currWallpaperImg, m_wallpaperFullScreen, 0);
	}
}
开发者ID:KyleMaas,项目名称:luna-sysmgr,代码行数:91,代码来源:WindowServerLuna.cpp

示例15: insert

bool QPixmapCache::insert(const QString &key, const QPixmap &pixmap)
{
    return pm_cache()->insert(key, pixmap, pixmap.width() * pixmap.height() * pixmap.depth() / 8);
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:4,代码来源:qpixmapcache.cpp


注:本文中的QPixmap::width方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。