本文整理汇总了C++中QPixmap::height方法的典型用法代码示例。如果您正苦于以下问题:C++ QPixmap::height方法的具体用法?C++ QPixmap::height怎么用?C++ QPixmap::height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPixmap
的用法示例。
在下文中一共展示了QPixmap::height方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paint
void FSTaskDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QString title = index.data(FSAbstractTaskModel::TitleRole).toString();
QString subTitle = index.data(FSAbstractTaskModel::SubTitleRole).toString();
int progress = index.data(FSAbstractTaskModel::ProgressRole).toInt();
QString mimeIconPath = index.data(FSAbstractTaskModel::MimeIconRole).toString();
// QString actionIconPath= index.data(FSAbstractTaskModel::TitleRole).toString();
if (option.state & QStyle::State_Selected)
{
painter->setPen(Qt::NoPen);
painter->setBrush(QBrush(QColor("#316AC5")));
painter->drawRect(option.rect);
}
painter->setPen(QPen(Qt::black));
QPixmap icon (mimeIconPath);
painter->drawPixmap(5, option.rect.center().y()-icon.height()/2, icon);
QRect progressRect = option.rect;
progressRect.setX(40);
progressRect.setY(option.rect.center().y() - 7);
progressRect.setRight(option.rect.right() - 30);
progressRect.setHeight(progress < 100 ? 14 : 1);
if (progress <100) {
QStyleOptionProgressBar progressBarOption;
progressBarOption.rect = progressRect;
progressBarOption.minimum = 0;
progressBarOption.maximum = 100;
progressBarOption.progress = progress;
progressBarOption.text = QString::number(progress) + "%";
progressBarOption.textVisible = true;
progressBarOption.textAlignment = Qt::AlignCenter;
qApp->style()->drawControl(QStyle::CE_ProgressBar,
&progressBarOption, painter);
QFontMetrics metrics(painter->font());
if ((option.state & QStyle::State_Selected))
painter->setPen(QPen(Qt::white));
else
painter->setPen(QPen(Qt::black));
painter->setFont(QFont(painter->font().family(),10));
painter->drawText(progressRect.topLeft()-QPoint(-5,5),title);
painter->setFont(QFont(painter->font().family(),8));
painter->drawText(progressRect.bottomLeft()+QPoint(5,5+metrics.height()),
subTitle);
}
else
{
QFontMetrics metrics(painter->font());
painter->setFont(QFont(painter->font().family(),10));
painter->drawText(progressRect.topLeft(),title);
painter->setFont(QFont(painter->font().family(),8));
painter->drawText(progressRect.topLeft()+QPoint(0,metrics.height()),subTitle);
}
// QPixmap rightPixmap(actionIconPath);
// if (mClicked.contains(index))
// painter->setOpacity(0.4);
// else
// painter->setOpacity(1);
// painter->drawPixmap(option.rect.right() -20, option.rect.center().y()-8,
// rightPixmap);
}
示例2: paintForeground
//VOXOX CHANGE - Add support for ItemList style and change paint structure.
void QtUMGroup::paintForeground(QPainter * painter, const QStyleOptionViewItem & option) {
QMutexLocker locker(&_mutex);
bool isGroupSelected = false;//VOXOX CHANGE by Rolando - 2009.09.03
bool isGroupBlinking = false;//VOXOX CHANGE by Rolando - 2009.09.08
QtUMItemListStyle * itemListStyle = QtUMItemListStyle::getInstance();//VOXOX CHANGE by Rolando - 2009.09.07
isGroupBlinking = isBlinking();//VOXOX CHANGE by Rolando - 2009.09.03
isGroupSelected = _isSelected;//VOXOX CHANGE by Rolando - 2009.10.01
if(isGroupSelected)//VOXOX CHANGE by Rolando - 2009.09.04
{
painter->setPen(itemListStyle->getSelectedGroupFontColor());//VOXOX CHANGE by Rolando - 2009.09.04
}
else
{
if(isGroupBlinking){
if(_blinkNow){//VOXOX CHANGE by Rolando - 2009.10.01
painter->setPen(itemListStyle->getGroupBlinkingFontColor());//VOXOX CHANGE by Rolando - 2009.10.01
}
else{
painter->setPen(itemListStyle->getNonSelectedGroupFontColor());//VOXOX CHANGE by Rolando - 2009.10.01
}
}
else{
painter->setPen(itemListStyle->getNonSelectedGroupFontColor());//VOXOX CHANGE by Rolando - 2009.09.04
}
}
painter->drawPixmap(option.rect.left(),option.rect.top(),getGroupBackGround(option.rect,option, isGroupSelected, isGroupBlinking));
QFont font = option.font;
painter->setFont(font);
QPixmap px;
if (option.state & QStyle::State_Open) {
px = itemListStyle->getGroupPixmapOpen();
} else {
px = itemListStyle->getGroupPixmapClose();
}
int x = option.rect.left();
QRect r = option.rect;
painter->drawPixmap(x, r.top() + 3, px);
_posXArrowButton = x;//VOXOX CHANGE by Rolando - 2009.09.29
_posYArrowButton = r.top() + 3;//VOXOX CHANGE by Rolando - 2009.09.29
_widthArrowButton = px.width();//VOXOX CHANGE by Rolando - 2009.09.29
_heightArrowButton = px.height();//VOXOX CHANGE by Rolando - 2009.09.29
x += px.width() + 3;
r.setLeft(x);
int y = ((r.bottom()-r.top())-QFontMetrics(font).height())/2;
r.setTop(y + r.top());
painter->drawText(r, Qt::AlignLeft, getGroupName(), 0);
//VOXOX CHANGE by Rolando - 2009.08.25 - getting corresponding close button
QPixmap closeButtonPixmap;
if ((option.state & QStyle::State_Selected) == QStyle::State_Selected) {
closeButtonPixmap = QPixmap(":/pics/chat/umtreewidget/btn_close_selected.png");//VOXOX CHANGE by Rolando - 2009.08.25
painter->setPen(_fontColor);//VOXOX CHANGE by Rolando - 2009.09.07
} else {
closeButtonPixmap = QPixmap(":/pics/chat/umtreewidget/btn_close_nonselected.png");//VOXOX CHANGE by Rolando - 2009.08.25
painter->setPen(_fontColor);//VOXOX CHANGE by Rolando - 2009.09.07
}
//VOXOX CHANGE by Rolando - 2009.08.25 - painting the close button
_posXCloseButton = r.right() - closeButtonPixmap.width() - 5;//VOXOX CHANGE by Rolando - 2009.09.16
int centeredCloseButton_y = ((r.bottom() - r.top()) - closeButtonPixmap.size().height()) / 2;
painter->drawPixmap(_posXCloseButton, r.top() + centeredCloseButton_y, closeButtonPixmap);
_posYCloseButton = r.top() + centeredCloseButton_y;
_widthCloseButton = closeButtonPixmap.width();//VOXOX CHANGE by Rolando - 2009.08.27
_heightCloseButton = closeButtonPixmap.height();//VOXOX CHANGE by Rolando - 2009.08.27
}
示例3: processBlock
//.........这里部分代码省略.........
exit();
return;
}
static QString boundaryMarker = "boundary=";
int boundaryStartIdx = m_dataBlock.indexOf(boundaryMarker,ctypeIdx);
if(boundaryStartIdx < 0)
{
qDebug() << "Error: Can't find boundary index after the first content-type index in data block, exiting.";
exit();
return;
}
int eolIdx = m_dataBlock.indexOf("\n",boundaryStartIdx);
int pos = boundaryStartIdx + boundaryMarker.length();
m_boundary = m_dataBlock.mid(pos, eolIdx - pos);
m_boundary.replace("\r","");
// qDebug() << "processBlock(): m_boundary:"<<m_boundary<<", pos:"<<pos<<", eolIdx:"<<eolIdx;
}
}
else
{
// we have the boundary string defenition, check for the boundary string in the data block.
// If found, grab the data from the start of the block up to and including the boundary, leaving any data after the boundary in the block.
// What we then have to process could look:
// Content-Type.....\r\n(data)--(boundary)
// If its the first block, we wait for the boundary, but discard it since the first block is the one that contains the server headers
// like the boundary definition, Server:, Connection:, etc.
int idx = m_dataBlock.indexOf(m_boundary);
while(idx > 0)
{
QByteArray block = m_dataBlock.left(idx);
int blockAndBoundaryLength = idx + m_boundary.length();
m_dataBlock.remove(0,blockAndBoundaryLength);
//qDebug() << "processBlock(): block length:"<<block.length()<<", blockAndBoundaryLength:"<<blockAndBoundaryLength;
if(m_firstBlock)
{
//QString string = block;
//qDebug() << "processBlock(): Discarding block since first block flag is true. Dump of block:\n"<<string;
m_firstBlock = false;
}
else
{
static const char * eol1 = "\n\n";
static const char * eol2 = "\r\n\r\n";
int headerLength = 0;
if(block.contains(eol2))
headerLength = block.indexOf(eol2,0) + 4;
else if(block.contains(eol1))
headerLength = block.indexOf(eol1,0) + 2;
if(headerLength)
{
//QString header = block.left(headerLength);
block.remove(0,headerLength);
// Block should now be just data
//qDebug() << "processBlock(): block length:"<<block.length()<<", headerLength:"<<headerLength<<", header:"<<header;
if(block.length() > 0)
{
QImage frame = QImage::fromData(block);
if(!frame.isNull())
{
// qDebug() << "processBlock(): New image received, original size:"<<frame.size()<<", bytes:"<<block.length();
if(m_autoResize.width()>0 && m_autoResize.height()>0 &&
m_autoResize != frame.size())
frame = frame.scaled(m_autoResize);
// qDebug() << "processBlock(): Emitting new image, size:"<<frame.size();
emit newImage(frame);
}
#ifdef MJPEG_TEST
QPixmap pix = QPixmap::fromImage(frame);
m_label->setPixmap(pix);
m_label->resize(pix.width(),pix.height());
#endif
}
}
}
// // check for another boundary string in the data before exiting from processBlock()
idx = m_dataBlock.indexOf(m_boundary);
}
}
// qDebug() << "processBlock(): End of processing, m_dataBlock.size() remaining:"<<m_dataBlock.size();
}
示例4: doShape
void KWMThemeClient::doShape()
{
QBitmap shapemask(width(), height());
shapemask.fill(color0);
QPainter p;
p.begin(&shapemask);
p.setBrush(color1);
p.setPen(color1);
int x,y;
// first the corners
int w1 = framePixmaps[FrameTopLeft]->width();
int h1 = framePixmaps[FrameTopLeft]->height();
if (w1 > width()/2) w1 = width()/2;
if (h1 > height()/2) h1 = height()/2;
if (framePixmaps[FrameTopLeft]->mask())
p.drawPixmap(0,0,*framePixmaps[FrameTopLeft]->mask(),
0,0,w1, h1);
else
p.fillRect(0,0,w1,h1,color1);
int w2 = framePixmaps[FrameTopRight]->width();
int h2 = framePixmaps[FrameTopRight]->height();
if (w2 > width()/2) w2 = width()/2;
if (h2 > height()/2) h2 = height()/2;
if (framePixmaps[FrameTopRight]->mask())
p.drawPixmap(width()-w2,0,*framePixmaps[FrameTopRight]->mask(),
framePixmaps[FrameTopRight]->width()-w2,0,w2, h2);
else
p.fillRect(width()-w2,0,w2, h2,color1);
int w3 = framePixmaps[FrameBottomLeft]->width();
int h3 = framePixmaps[FrameBottomLeft]->height();
if (w3 > width()/2) w3 = width()/2;
if (h3 > height()/2) h3 = height()/2;
if (framePixmaps[FrameBottomLeft]->mask())
p.drawPixmap(0,height()-h3,*framePixmaps[FrameBottomLeft]->mask(),
0,framePixmaps[FrameBottomLeft]->height()-h3,w3, h3);
else
p.fillRect(0,height()-h3,w3,h3,color1);
int w4 = framePixmaps[FrameBottomRight]->width();
int h4 = framePixmaps[FrameBottomRight]->height();
if (w4 > width()/2) w4 = width()/2;
if (h4 > height()/2) h4 = height()/2;
if (framePixmaps[FrameBottomRight]->mask())
p.drawPixmap(width()-w4,height()-h4,*framePixmaps[FrameBottomRight]->mask(),
framePixmaps[FrameBottomRight]->width()-w4,
framePixmaps[FrameBottomRight]->height()-h4,
w4, h4);
else
p.fillRect(width()-w4,height()-h4,w4,h4,color1);
QPixmap pm;
QWMatrix m;
int n,s,w;
//top
if (framePixmaps[FrameTop]->mask())
{
pm = *framePixmaps[FrameTop]->mask();
s = width()-w2-w1;
n = s/pm.width();
w = n>0?s/n:s;
m.reset();
m.scale(w/(float)pm.width(), 1);
pm = pm.xForm(m);
x = w1;
while (1){
if (pm.width() < width()-w2-x){
p.drawPixmap(x,maxExtent-pm.height()-1,
pm);
x += pm.width();
}
else {
p.drawPixmap(x,maxExtent-pm.height()-1,
pm,
0,0,width()-w2-x,pm.height());
break;
}
}
}
//bottom
if (framePixmaps[FrameBottom]->mask())
{
pm = *framePixmaps[FrameBottom]->mask();
s = width()-w4-w3;
n = s/pm.width();
w = n>0?s/n:s;
m.reset();
m.scale(w/(float)pm.width(), 1);
pm = pm.xForm(m);
x = w3;
while (1){
if (pm.width() < width()-w4-x){
p.drawPixmap(x,height()-maxExtent+1,pm);
x += pm.width();
//.........这里部分代码省略.........
示例5: setPixmap
void setPixmap(const QPixmap &pixmap)
{
setRect(0.0, 0.0, pixmap.width() + 2 * InnerBorder, pixmap.height() + 2 * InnerBorder);
m_pixmapItem->setPos(InnerBorder, InnerBorder);
m_pixmapItem->setPixmap(pixmap);
}
示例6: contactPhoto
QVariant KDEPixmapManipulation::contactPhoto(Contact* c, const QSize& size, bool displayPresence) {
const QString hash = QString("photo2%1%2%3").arg(size.width()).arg(size.height()).arg(c->isPresent());
QVariant preRendered = c->property(hash.toAscii());
if (preRendered.isValid())
return preRendered;
else
connect(c,SIGNAL(rebased(Contact*)),this,SLOT(clearCache()));
const int radius = (size.height() > 35) ? 7 : 5;
const QPixmap* pxmPtr = c->photo();
bool isTracked = displayPresence && c->isTracked();
bool isPresent = displayPresence && c->isPresent();
static QColor presentBrush = KStatefulBrush( KColorScheme::Window, KColorScheme::PositiveText ).brush(QPalette::Normal).color();
static QColor awayBrush = KStatefulBrush( KColorScheme::Window, KColorScheme::NegativeText ).brush(QPalette::Normal).color();
QPixmap pxm;
if (pxmPtr) {
QPixmap contactPhoto(pxmPtr->scaledToWidth(size.height()-6));
pxm = QPixmap(size);
pxm.fill(Qt::transparent);
QPainter painter(&pxm);
//Clear the pixmap
painter.setCompositionMode(QPainter::CompositionMode_Clear);
painter.fillRect(0,0,size.width(),size.height(),QBrush(Qt::white));
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
//Add corner radius to the Pixmap
QRect pxRect = contactPhoto.rect();
QBitmap mask(pxRect.size());
QPainter customPainter(&mask);
customPainter.setRenderHint (QPainter::Antialiasing, true );
customPainter.fillRect (pxRect , Qt::white );
customPainter.setBackground (Qt::black );
customPainter.setBrush (Qt::black );
customPainter.drawRoundedRect(pxRect,radius,radius);
contactPhoto.setMask(mask);
painter.drawPixmap(3,3,contactPhoto);
painter.setBrush(Qt::NoBrush);
QPen pen(QApplication::palette().color(QPalette::Disabled,QPalette::Text));
pen.setWidth(isTracked?1:2);
painter.setPen(pen);
painter.setRenderHint (QPainter::Antialiasing, true );
painter.drawRoundedRect(3,3,pxm.height()-6,pxm.height()-6,radius,radius);
//Draw the glow around pixmaps
if (isTracked) {
if (isPresent)
pen.setColor(presentBrush);
else
pen.setColor(awayBrush);
for (int i=2;i<=7;i+=2) {
pen.setWidth(i);
painter.setPen(pen);
painter.setOpacity(0.3f-(((i-2)*0.8f)/10.0f));
painter.drawRoundedRect(3,3,pxm.height()-6,pxm.height()-6,radius,radius);
}
}
}
else {
pxm = drawDefaultUserPixmap(size,isTracked,isPresent);
}
c->setProperty(hash.toAscii(),pxm);
return pxm;
}
示例7: pixPaint
SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f, bool isTestNet) :
QSplashScreen(pixmap, f)
{
setAutoFillBackground(true);
// set reference point, paddings
int paddingLeft = 14;
int paddingTop = 470;
int titleVersionVSpace = 17;
int titleCopyrightVSpace = 32;
float fontFactor = 1.0;
// define text to place
QString titleText = tr("Mobicoin Core");
QString versionText = QString(tr("Version %1")).arg(QString::fromStdString(FormatFullVersion()));
QString copyrightTextBtc = QChar(0xA9)+QString(" 2009-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Bitcoin Core developers"));
QString copyrightTextDrk = QChar(0xA9)+QString(" 2014-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Mobicoin Core 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, 28*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, 28*fontFactor));
fm = pixPaint.fontMetrics();
titleTextWidth = fm.width(titleText);
pixPaint.drawText(paddingLeft,paddingTop,titleText);
pixPaint.setFont(QFont(font, 15*fontFactor));
pixPaint.drawText(paddingLeft,paddingTop+titleVersionVSpace,versionText);
// draw copyright stuff
pixPaint.setFont(QFont(font, 10*fontFactor));
pixPaint.drawText(paddingLeft,paddingTop+titleCopyrightVSpace,copyrightTextBtc);
pixPaint.drawText(paddingLeft,paddingTop+titleCopyrightVSpace+12,copyrightTextDrk);
// 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,newPixmap.height()-25,testnetAddText);
}
pixPaint.end();
this->setPixmap(newPixmap);
subscribeToCoreSignals();
}
示例8: 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 );
}
示例9: prepareImages
//.........这里部分代码省略.........
}
}
MimeType mimeType = mimeTypeForData(data);
if (type == ToPrepareDocument || type == ToPrepareAudio) {
mime = mimeType.name();
}
if (mime == "image/jpeg") {
filename = filedialogDefaultName(qsl("image"), qsl(".jpg"), QString(), true);
} else if (type == ToPrepareAudio) {
filename = filedialogDefaultName(qsl("audio"), qsl(".ogg"), QString(), true);
mime = "audio/ogg";
} else {
QString ext;
QStringList patterns = mimeType.globPatterns();
if (!patterns.isEmpty()) {
ext = patterns.front().replace('*', QString());
}
filename = filedialogDefaultName((type == ToPrepareAudio) ? qsl("audio") : qsl("doc"), ext, QString(), true);
}
filesize = data.size();
}
} else {
if (type == ToPrepareDocument) {
filename = filedialogDefaultName(qsl("image"), qsl(".png"), QString(), true);
mime = mimeTypeForName("image/png").name();
data = QByteArray();
{
QBuffer b(&data);
img.save(&b, "PNG");
}
filesize = data.size();
} else {
if (img.hasAlphaChannel()) {
QImage solid(img.width(), img.height(), QImage::Format_ARGB32_Premultiplied);
solid.fill(st::white->c);
{
QPainter(&solid).drawImage(0, 0, img);
}
img = solid;
}
type = ToPreparePhoto;
filename = qsl("Untitled.jpg");
filesize = 0;
}
}
if ((img.isNull() && ((type != ToPrepareDocument && type != ToPrepareAudio) || !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;
QVector<MTPDocumentAttribute> attributes(1, MTP_documentAttributeFilename(MTP_string(filename)));
MTPPhotoSize thumb(MTP_photoSizeEmpty(MTP_string("")));
MTPPhoto photo(MTP_photoEmpty(MTP_long(0)));
MTPDocument document(MTP_documentEmpty(MTP_long(0)));
MTPAudio audio(MTP_audioEmpty(MTP_long(0)));
示例10: paint
///Delegate painter
void ImDelegates::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
Q_ASSERT(index.isValid());
QPixmap icon = index.data(Qt::DecorationRole).value<QPixmap>();
int icnWidth = 50;
if (!icon.isNull()) {
painter->drawPixmap(option.rect.x()+5,option.rect.y()+(option.rect.height()/2)-(icon.height()/2),icon);
icnWidth = icon.width();
}
QFontMetrics metric(painter->font());
QString text = index.data(Qt::DisplayRole).toString();
QRect requiredRect = metric.boundingRect(option.rect.x()+icnWidth+10,option.rect.y()+metric.height()+5,option.rect.width() - icnWidth - 10 /*margin*/,500,Qt::TextWordWrap|Qt::AlignLeft,text);
painter->drawText(requiredRect,Qt::AlignLeft|Qt::TextWordWrap,text);
QFont font = painter->font();
font.setBold(true);
painter->setFont(font);
const QString peerName = index.data((int)Media::TextRecording::Role::AuthorDisplayname).toString();
painter->drawText(option.rect.x()+icnWidth+10,option.rect.y()+metric.height(), peerName);
font.setBold(false);
painter->setFont(font);
}
示例11: paintContact
void paintContact(QPainter* mp, const QStyleOptionViewItem& option, const QModelIndex& index, GCUserViewItem* item) const
{
mp->save();
QStyleOptionViewItem o = option;
QPalette palette = o.palette;
MUCItem::Role r = item->s.mucItem().role();
QRect rect = o.rect;
if(nickColoring_) {
if(r == MUCItem::Moderator)
palette.setColor(QPalette::Text, colorModerator_);
else if(r == MUCItem::Participant)
palette.setColor(QPalette::Text, colorParticipant_);
else if(r == MUCItem::Visitor)
palette.setColor(QPalette::Text, colorVisitor_);
else
palette.setColor(QPalette::Text, colorNoRole_);
}
mp->fillRect(rect, (o.state & QStyle::State_Selected) ? palette.color(QPalette::Highlight) : palette.color(QPalette::Base));
if(showAvatar_) {
QPixmap ava = item->avatar();
if(ava.isNull()) {
ava = IconsetFactory::iconPixmap("psi/default_avatar");
}
ava = AvatarFactory::roundedAvatar(ava, avatarRadius_, avatarSize_);
QRect avaRect(rect);
avaRect.setWidth(ava.width());
avaRect.setHeight(ava.height());
if(!avatarAtLeft_) {
avaRect.moveTopRight(rect.topRight());
avaRect.translate(-1, 1);
rect.setRight(avaRect.left() - 1);
}
else {
avaRect.translate(1, 1);
rect.setLeft(avaRect.right() + 1);
}
mp->drawPixmap(avaRect, ava);
}
QPixmap status = showStatusIcons_ ? item->icon() : QPixmap();
int h = rect.height();
int sh = status.isNull() ? 0 : status.height();
rect.setHeight(qMax(sh, fontHeight_));
rect.moveTop(rect.top() + (h - rect.height())/2);
if(!status.isNull()) {
QRect statusRect(rect);
statusRect.setWidth(status.width());
statusRect.setHeight(status.height());
statusRect.translate(1, 1);
mp->drawPixmap(statusRect, status);
rect.setLeft(statusRect.right() + 2);
}
else
rect.setLeft(rect.left() + 2);
mp->setPen(QPen((o.state & QStyle::State_Selected) ? palette.color(QPalette::HighlightedText) : palette.color(QPalette::Text)));
mp->setFont(o.font);
mp->setClipRect(rect);
QTextOption to;
to.setWrapMode(QTextOption::NoWrap);
mp->drawText(rect, index.data(Qt::DisplayRole).toString(), to);
QList<QPixmap> rightPixs;
if(showAffiliations_) {
MUCItem::Affiliation a = item->s.mucItem().affiliation();
QPixmap pix;
if(a == MUCItem::Owner)
pix = IconsetFactory::iconPixmap("affiliation/owner");
else if(a == MUCItem::Admin)
pix = IconsetFactory::iconPixmap("affiliation/admin");
else if(a == MUCItem::Member)
pix = IconsetFactory::iconPixmap("affiliation/member");
else if(a == MUCItem::Outcast)
pix = IconsetFactory::iconPixmap("affiliation/outcast");
else
pix = IconsetFactory::iconPixmap("affiliation/noaffiliation");
if(!pix.isNull())
rightPixs.push_back(pix);
}
if(showClients_) {
GCUserView *gcuv = (GCUserView*)item->treeWidget();
GCMainDlg* dlg = gcuv->mainDlg();
QPixmap clientPix;
if(dlg) {
UserListItem u;
const QString &nick = item->text(0);
Jid caps_jid(/*s.mucItem().jid().isEmpty() ? */ dlg->jid().withResource(nick) /* : s.mucItem().jid()*/);
CapsManager *cm = dlg->account()->client()->capsManager();
QString client_name = cm->clientName(caps_jid);
QString client_version = (client_name.isEmpty() ? QString() : cm->clientVersion(caps_jid));
UserResource ur;
ur.setStatus(item->s);
ur.setClient(client_name,client_version,"");
u.userResourceList().append(ur);
QStringList clients = u.clients();
//.........这里部分代码省略.........
示例12: pixmap
{
fprintf(stderr, "%s\n", HWApplication::tr("Unknown option argument: %1", "command-line").arg(QString("--") + key).toUtf8().constData());
}
fprintf(stderr, "\n%s", getUsage().toUtf8().constData());
return 1;
}
// end of parameter parsing
#if defined Q_OS_WIN
QPixmap pixmap(":res/splash.png");
splash = new QLabel(0, Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint);
splash->setAttribute(Qt::WA_TranslucentBackground);
const QRect deskSize = HWApplication::desktop()->screenGeometry(-1);
QPoint splashCenter = QPoint( (deskSize.width() - pixmap.width())/2,
(deskSize.height() - pixmap.height())/2 );
splash->move(splashCenter);
splash->setPixmap(pixmap);
splash->show();
#endif
app.setStyle(new QPlastiqueStyle());
QDateTime now = QDateTime::currentDateTime();
srand(now.toTime_t());
rand();
Q_INIT_RESOURCE(hedgewars);
qRegisterMetaType<HWTeam>("HWTeam");
bindir->cd(QCoreApplication::applicationDirPath());
示例13: 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;
}
示例14: p
void Shadows::Private::initPixmap(const QString &element)
{
#ifdef Q_WS_X11
QPixmap pix = q->pixmap(element);
if (!pix.isNull() && pix.handle() == 0) {
Pixmap xPix = XCreatePixmap(QX11Info::display(), QX11Info::appRootWindow(), pix.width(), pix.height(), 32);
QPixmap tempPix = QPixmap::fromX11Pixmap(xPix, QPixmap::ExplicitlyShared);
tempPix.fill(Qt::transparent);
QPainter p(&tempPix);
p.drawPixmap(QPoint(0, 0), pix);
m_shadowPixmaps << tempPix;
m_managePixmaps = true;
} else {
m_shadowPixmaps << pix;
}
#endif
}
示例15: create
bool FskinCreator::create(const QString& path, int width, int height, QImage& img)
{
if (!QFile::exists(path))
return false;
KTar tar(path);
if (!tar.open(QIODevice::ReadOnly))
return false;
QStringList entries = tar.directory()->entries();
if (entries.count() != 1)
return false;
const KArchiveEntry* entry = tar.directory()->entry(entries.first());
if (!entry->isDirectory())
return false;
const KArchiveDirectory* subdir = static_cast<const KArchiveDirectory*>(entry);
const KArchiveEntry* skinconf_entry = subdir->entry("fcitx_skin.conf");
const KArchiveFile* skinconf = static_cast<const KArchiveFile*>(skinconf_entry);
if (!skinconf)
return false;
QByteArray data = skinconf->data();
/// parse ini file content
bool skinfont = false;
bool skininputbar = false;
QPixmap skin;
QString resizemode;
/// margins
int ml = 0, mr = 0, mt = 0, mb = 0;
/// font size
QFont font;
QColor color_en;
QColor color_label;
QColor color_ch_1st;
/// text y position
int yen = 0, ych = 0;
/// cursor color
QColor color_cursor;
/// back arrow
QPixmap barrow;
int xba = 0, yba = 0;
/// forward arrow
QPixmap farrow;
int xfa = 0, yfa = 0;
QTextStream ss(data);
QString line;
QString key, value;
do {
line = ss.readLine();
if (line.isEmpty() || line.at(0) == '#')
continue;
if (line.at(0) == '[') {
skinfont = (line == "[SkinFont]");
skininputbar = (line == "[SkinInputBar]");
continue;
}
if (!line.contains('='))
continue;
key = line.split('=').at(0);
value = line.split('=').at(1);
if (value.isEmpty())
continue;
if (skinfont) {
if (key == "FontSize") {
font.setPixelSize(value.toInt());
}
else if (key == "InputColor") {
color_en = value2color(value);
}
else if (key == "IndexColor") {
color_label = value2color(value);
}
else if (key == "FirstCandColor") {
color_ch_1st = value2color(value);
}
else if (key == "UserPhraseColor") {
QColor color_ch_user = value2color(value);
}
else if (key == "OtherColor") {
QColor color_ch_other = value2color(value);
}
}
else if (skininputbar) {
if (key == "BackImg") {
const KArchiveEntry* e = subdir->entry(value);
const KArchiveFile* pix = static_cast<const KArchiveFile*>(e);
if (pix)
skin.loadFromData(pix->data());
}
else if (key == "Resize") {
//.........这里部分代码省略.........