// We could use QItemDelegate::paint instead, but it does so much more, it looks slow. void KDReports::SpreadsheetReportLayout::paintTextAndIcon( QPainter& painter, const QRectF& cellContentsRect, const QString& cellText, const QVariant& cellDecoration, const QVariant& decorationAlignment, Qt::Alignment alignment ) { QRectF textRect = cellContentsRect; const bool hasIcon = !cellDecoration.isNull(); int iconWidth = 0; const bool iconAfterText = decorationAlignment.isValid() && ( decorationAlignment.toInt() & Qt::AlignRight ); if ( hasIcon ) { iconWidth = m_tableLayout.decorationSize( cellDecoration ).width() * m_tableLayout.scalingFactor(); //qDebug() << "row" << row << "hasIcon=" << hasIcon << "iconAfterText=" << iconAfterText << "iconWidth=" << iconWidth; if ( !iconAfterText ) { paintIcon( painter, cellContentsRect, cellDecoration ); textRect.setLeft( textRect.left() + iconWidth + 2 ); } else { textRect.setWidth( textRect.width() - iconWidth - 2 ); } } //qDebug() << "Drawing text in" << textRect; painter.drawText( textRect, alignment, cellText ); if ( hasIcon && iconAfterText ) { QRectF iconRect = cellContentsRect; iconRect.setLeft( iconRect.right() - iconWidth ); //qDebug() << "iconRect=" << iconRect; paintIcon( painter, iconRect, cellDecoration ); } }
// display a play icon when downloading void Tray::setDownloading( bool downloading ) { if (downloading == m_downloading) return; m_downloading = downloading; kDebug(5001) << "Tray::setDownloading"; if (downloading) paintIcon( 50, true ); else paintIcon( -1, true ); }
/** class Tray * Reimplmentation of the system tray class adding drag/drop * capabilities and the quit action. */ Tray::Tray(MainWindow * parent) : KSystemTrayIcon(parent), grayedIcon( 0 ), alternateIcon( 0 ), playOverlay( 0 ), m_downloading( false ) { baseIcon = new QPixmap( KSystemTrayIcon::loadIcon("kget").pixmap(22) ); // 12x12 pixel overlay looks fine, amarok uses 10x10 playOverlay = new QPixmap( SmallIcon( "media-playback-start", 12 ) ); paintIcon(); // add preferences action to the context menu QMenu * cm = contextMenu(); cm->addAction( parent->actionCollection()->action("new_download") ); cm->addAction( parent->actionCollection()->action("import_links") ); cm->addSeparator(); cm->addAction( parent->actionCollection()->action("start_all_download") ); cm->addAction( parent->actionCollection()->action("stop_all_download") ); cm->addSeparator(); cm->addAction( parent->actionCollection()->action("konqueror_integration") ); cm->addAction( parent->actionCollection()->action("show_drop_target") ); cm->addAction( parent->actionCollection()->action("options_configure") ); // add tooltip telling "I'm kget" setToolTip(i18n("KGet - Download Manager")); // connecting the "Exit" menu item to the quit() of our app connect( this, SIGNAL( quitSelected() ), kapp, SLOT(quit())); connect( this, SIGNAL( activated( QSystemTrayIcon::ActivationReason ) ), SLOT( slotActivated( QSystemTrayIcon::ActivationReason ) ) ); }
void MapIcons::paintItemIcon(MapParameters& param, QPainter& p, const MapIcon& mapIcon, const Item* item, const QPoint& point) { paintIcon(param, p, mapIcon, *item, item->name(), point); }
void amaroK::TrayIcon::paletteChange( const QPalette & op ) { if ( palette().active().highlight() == op.active().highlight() || alternateIcon.isNull() ) return; alternateIcon.resize( 0, 0 ); paintIcon( mergeLevel, true ); }
void SkinListDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex &index) const { painter->save(); paintBackground(painter, option); paintIcon(painter, option, index); paintText(painter, option, index); painter->restore(); }
void TitleButton::paintEvent(QPaintEvent *e) { Painter p(this); p.fillRect(rect(), st::titleBg); p.setBrush(st::mediaPlayerTitleButtonInnerBg); p.setPen(Qt::NoPen); p.setRenderHint(QPainter::HighQualityAntialiasing, true); p.drawEllipse((width() - st::mediaPlayerTitleButtonInner.width()) / 2, (height() - st::mediaPlayerTitleButtonInner.height()) / 2, st::mediaPlayerTitleButtonInner.width(), st::mediaPlayerTitleButtonInner.height()); p.setRenderHint(QPainter::HighQualityAntialiasing, false); paintIcon(p); }
void amaroK::TrayIcon::engineStateChanged( Engine::State state, Engine::State /*oldState*/ ) { // stop timer if ( blinkTimerID ) { killTimer( blinkTimerID ); blinkTimerID = 0; } // draw overlay overlayVisible = true; // draw the right overlay for each state switch( state ) { case Engine::Paused: overlay = &pauseOverlay; paintIcon( mergeLevel, true ); break; case Engine::Playing: overlay = &playOverlay; if( AmarokConfig::animateTrayIcon() ) blinkTimerID = startTimer( 1500 ); // start 'blink' timer paintIcon( mergeLevel, true ); // repaint the icon break; case Engine::Empty: overlayVisible = false; paintIcon( -1, true ); // repaint the icon default: ; } }
void CSVWorld::DataDisplayDelegate::paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { painter->save(); //default to enum delegate's paint method for text-only conditions if (mDisplayMode == Mode_TextOnly) EnumDelegate::paint(painter, option, index); else { int valueIndex = getValueIndex(index); if (valueIndex != -1) { paintIcon(painter, option, valueIndex); } } painter->restore(); }
void TalkablePainter::paint(QPainter *painter) { ItemRect = Option.rect; ItemRect.adjust(HFrameMargin, VFrameMargin, -HFrameMargin, -VFrameMargin); computeLayout(); fixColors(); // some bit of broken logic if (drawSelected() || drawDisabled() || !Configuration->useConfigurationColors()) painter->setPen(textColor()); else { Buddy buddy = Index.data(BuddyRole).value<Buddy>(); Contact contact = Index.data(ContactRole).value<Contact>(); if (buddy.isBlocked() || contact.isBlocking()) painter->setPen(QColor(255, 0, 0)); else painter->setPen(Configuration->fontColor()); } paintCheckbox(painter); paintIcon(painter); paintAvatar(painter); paintIdentityName(painter); paintName(painter); paintDescription(painter); /* paintDebugRect(painter, ItemRect, QColor(255, 0, 0)); paintDebugRect(painter, CheckboxRect, QColor(255, 255, 0)); paintDebugRect(painter, IconRect, QColor(0, 255, 0)); paintDebugRect(painter, AvatarRect, QColor(0, 0, 255)); paintDebugRect(painter, IdentityNameRect, QColor(255, 0, 255)); paintDebugRect(painter, NameRect, QColor(0, 255, 255)); paintDebugRect(painter, DescriptionRect, QColor(0, 0, 0)); */ }
bool amaroK::TrayIcon::event( QEvent *e ) { switch( e->type() ) { case QEvent::Drop: case QEvent::Wheel: case QEvent::DragEnter: return amaroK::genericEventHandler( this, e ); case QEvent::Timer: if( static_cast<QTimerEvent*>(e)->timerId() != blinkTimerID ) return KSystemTray::event( e ); // if we're playing, blink icon if ( overlay == &playOverlay ) { overlayVisible = !overlayVisible; paintIcon( mergeLevel, true ); } return true; case QEvent::MouseButtonPress: if( static_cast<QMouseEvent*>(e)->button() == Qt::MidButton ) { EngineController::instance()->playPause(); return true; } //else FALL THROUGH default: return KSystemTray::event( e ); } }
void DockWidget::paintEvent (QPaintEvent *e) { (void) e; paintIcon(); }
static void ShowInfo(MENU *m, int knew ) { int icon_w=0, icon_h=0, xsize=0, ysize=0; int loop, dloop, ldy, stlen; double scrollbar_len, scrollbar_ofs, scrollbar_cor; int index=m->act_entry,tind=m->act_entry; int sbw=(m->num_entrys>MAX_FUNCS)?scale2res(15):0; // scrollbar width int sbo=OFFSET_MIN; // inner scrollbar offset char tstr[BUFSIZE]={0}, *tptr; char dstr[BUFSIZE]={0}, *lcptr,*lcstr; int dy, my, moffs, mh, toffs, soffs=OFFSET_SMALL/*4*/, oldx=startx, oldy=starty, sbar=0, nosel; PLISTENTRY pl; moffs=iyw/(MAX_FUNCS+1)+OFFSET_SMALL; mh=iyw-moffs; dy=mh/(MAX_FUNCS+1); toffs=dy/2; my=moffs+toffs+dy; startx = sx + (((ex-sx) - ixw)/2); starty = sy + (((ey-sy) - iyw)/2); tind=index; //frame layout RenderBox(OFFSET_SMALL/*6*/, OFFSET_SMALL, ixw+OFFSET_SMALL, iyw+OFFSET_SMALL, radius, COL_SHADOW_PLUS_0); RenderBox(0, 0, ixw, iyw, radius, CMC); // titlebar RenderBox(0, 0, ixw, moffs, radius, CMH); for(loop=MAX_FUNCS*(index/MAX_FUNCS); loop<MAX_FUNCS*(index/MAX_FUNCS+1) && loop<m->num_entrys && !sbar; loop++) { pl=m->list[loop]; sbar |= ((pl->type!=TYP_COMMENT) && (pl->type!=TYP_INACTIVE)); } --loop; if(loop>index) { m->act_entry=index=loop; } if(sbw) { //sliderframe RenderBox(ixw-sbw, moffs, ixw, iyw, radius, COL_MENUCONTENT_PLUS_1); //slider scrollbar_len = (double)mh / (double)((m->num_entrys/MAX_FUNCS+1)*MAX_FUNCS); scrollbar_ofs = scrollbar_len*(double)((index/MAX_FUNCS)*MAX_FUNCS); scrollbar_cor = scrollbar_len*(double)MAX_FUNCS; RenderBox(ixw-sbw + sbo, moffs + scrollbar_ofs + sbo, ixw - sbo, moffs + scrollbar_ofs + scrollbar_cor - sbo, radius, COL_MENUCONTENT_PLUS_3); } int iw,ih; int offset, hoffs = (m->headermed[m->act_header]==1)?0:scale2res(48); int ioffs = xoffs+8; // + half standard icon if(m->icon[m->act_header]) { png_getsize(m->icon[m->act_header], &icon_w, &icon_h); // limit icon size if(icon_w > 150 || icon_h > 36) { icon_w = xsize = 150; icon_h = ysize = 36; } if (icon_w > 32) { offset = ioffs-16; } else offset = ioffs-icon_w/2; paintIcon(m->icon[m->act_header], offset, (moffs-icon_h)/2+1, xsize, ysize, &iw, &ih); } // Title text if (icon_w > 32) { hoffs = offset+iw+8; } lcstr=strdup(m->headertxt[m->act_header]); clean_string(m->headertxt[m->act_header],lcstr); RenderString(lcstr, hoffs, moffs-(moffs-FSIZE_BIG)/2+2, ixw-sbw-hoffs, (m->headermed[m->act_header]==1)?CENTER:LEFT, FSIZE_BIG, CMHT); free(lcstr); index /= MAX_FUNCS; dloop=0; ldy=dy; //Show table of commands for(loop = index*MAX_FUNCS; (loop < (index+1)*MAX_FUNCS) && (loop < m->num_entrys); ++loop) { int clh=2; // comment line height dy=ldy; pl=m->list[loop]; strcpy(dstr,pl->entry); if((tptr=strxchr(dstr,','))!=NULL) { if(pl->type != TYP_COMMENT) { *tptr=0; } } lcptr=tptr=dstr; while(*tptr) { if(*tptr==0x27) { memmove(tptr,tptr+1,strlen(tptr)); } ++tptr; } if(m->num_active && sbar && (loop==m->act_entry)) { RenderBox(0, my+soffs-dy, ixw-sbw, my+soffs, radius, CMCS); } nosel=(pl->type==TYP_COMMENT) || (pl->type==TYP_INACTIVE); if(!(pl->type==TYP_COMMENT && pl->underline==2)) { int font_type = MED; int font_size = FSIZE_MED; int coffs=0; // comment offset if (pl->type==TYP_COMMENT) { font_type = SMALL; font_size = FSIZE_SMALL; if (pl->underline==1) { coffs=clh; } } RenderString(dstr, scale2res(48), my+soffs-(dy-font_size)/2-coffs+2, ixw-sbw-scale2res(65), LEFT, font_type, (((loop%MAX_FUNCS) == (tind%MAX_FUNCS)) && (sbar) && (!nosel))?CMCST:(nosel)?CMCIT:CMCT); } if(pl->type==TYP_MENU) { RenderString(">", scale2res(30), my+soffs-(dy-FSIZE_MED)/2+OFFSET_MIN, scale2res(65), LEFT, MED, (((loop%MAX_FUNCS) == (tind%MAX_FUNCS)) && (sbar) && (!nosel))?CMCST:CMCT); } if(pl->underline) { int cloffs=0,ccenter=0; if(pl->type==TYP_COMMENT) { if(strlen(dstr)==0) { cloffs=dy/2; if(pl->underline==2) { dy/=2; // FIXME: these substraction causes space at bottom of painted box cloffs+=dy/2; } } else { if(pl->underline==2) { cloffs=dy/2; ccenter=1; } } } else { if(pl->underline==2) { dy+=dy/2; // FIXME: these addition causes text outside painted box cloffs=-dy/4; } } RenderBox(xoffs, my+soffs-cloffs-clh, ixw-xoffs-sbw, my+soffs-cloffs, 0, COL_MENUCONTENT_PLUS_3); if(ccenter) { stlen=GetStringLen(xoffs, dstr, MED); RenderBox(xoffs+(ixw-xoffs-sbw)/2-stlen/2, my+soffs-ldy, xoffs+(ixw-xoffs-sbw)/2+stlen/2+3*OFFSET_SMALL, my+soffs, FILL, CMC); RenderString(dstr, xoffs, my+soffs-(dy-FSIZE_MED)/2, ixw-sbw, CENTER, MED, CMCIT); } } if((pl->type!=TYP_COMMENT) && ((pl->type!=TYP_INACTIVE) || (pl->showalways==2))) { icon_w = icon_h = 0; png_getsize(ICON_BUTTON_RED, &icon_w, &icon_h); direct[dloop++]=(pl->type!=TYP_INACTIVE)?loop:-1; switch(dloop) { case 1: paintIcon(ICON_BUTTON_RED, ioffs-icon_w/2, my+soffs-(dy+icon_h)/2, 0, 0, &iw, &ih); break; case 2: paintIcon(ICON_BUTTON_GREEN, ioffs-icon_w/2, my+soffs-(dy+icon_h)/2, 0, 0, &iw, &ih); break; case 3: paintIcon(ICON_BUTTON_YELLOW, ioffs-icon_w/2, my+soffs-(dy+icon_h)/2, 0, 0, &iw, &ih); break; case 4: paintIcon(ICON_BUTTON_BLUE, ioffs-icon_w/2, my+soffs-(dy+icon_h)/2, 0, 0, &iw, &ih); break; default: if(dloop<15) { sprintf(tstr,"%1d",(dloop-4)%10); RenderString(tstr, xoffs, my+soffs-(dy-FSIZE_SMALL)/2+2, 3*OFFSET_SMALL, CENTER, SMALL, ((loop%MAX_FUNCS) == (tind%MAX_FUNCS))?CMCST:((pl->type==TYP_INACTIVE)?CMCIT:CMCT)); } break; } } my += dy; } dy=ldy; for(; dloop<MAX_FUNCS; dloop++) { direct[dloop]=-1; } //copy backbuffer to framebuffer #ifdef MARTII blit(); #else memcpy(lfb, lbb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t)); #endif if(m->num_active && knew) { if(m->list[m->act_entry]->entry) { sprintf(trstr,"%s%s",(m->list[m->act_entry]->type<=TYP_MENUSOFF)?"> ":"",m->list[m->act_entry]->entry); if((lcptr=strxchr(trstr,','))!=NULL) { *lcptr=0; } } else { sprintf(trstr,"Kein Eintrag"); } if(vfd) { lcstr=strdup(trstr); clean_string(trstr,lcstr); sprintf(tstr,"%s -t\"%s\"",VFD,lcstr); system(tstr); free(lcstr); } } startx=oldx; starty=oldy; }
int show_txt(int buttonly) { FILE *tfh; char const *fname=NULL; int yo=scale2res(80), buttx=scale2res(80), butty=scale2res(30), buttdx=scale2res(20), buttdy=scale2res(10); int icon_w=0, icon_h=0, xsize=0, ysize=0; int i,bx,by,x1,y1,rv=-1,run=1,line=0,action=1,cut,itmp,btns=buttons,lbtns=(buttons>bpline)?bpline:buttons,blines=1+((btns-1)/lbtns); if(hide) { #if HAVE_SPARK_HARDWARE || HAVE_DUCKBOX_HARDWARE memcpy(lbb, hbb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t)); blit(); #else memcpy(lfb, hbb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t)); #endif return 0; } if (strcmp(icon, "none")==0 || strcmp(icon, "0")==0) fname = ""; else if (strcmp(icon, "error")==0 || strcmp(icon, "1")==0) fname = ICON_ERROR; else if (strcmp(icon, "info")==0 || strcmp(icon, "2")==0) fname = ICON_INFO; else fname = icon; png_getsize(fname, &icon_w, &icon_h); // limit icon size if(icon_w > 100 || icon_h > 60) { icon_w = xsize = 100; icon_h = ysize = 60; } int h_head = max(FSIZE_MED+(size/2), icon_h); yo=((header)?h_head:0); int moffs=yo-h_head/3-(size/2); if(!buttonly) { memcpy(lbb, ibb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t)); } if((tfh=fopen(TMP_FILE,"r"))!=NULL) { fclose(tfh); int fsizebut = scale2res(26); if(!buttonly) { if(type!=1) { btns=0; myo=0; } pxw=GetStringLen(sx,title,FSIZE_BIG)+OFFSET_MED; if(type==1) { myo=blines*(butty+buttdy); for(i=0; i<btns; i++) { itmp=GetStringLen(sx,butmsg[i],fsizebut)+OFFSET_MED; if(itmp>buttx) { buttx=itmp; } } } buttsize=buttx; if(fh_txt_getsize(TMP_FILE, &x1, &y1, size, &cut)) { printf(__plugin__ " <invalid Text-Format>\n"); return -1; } x1+=OFFSET_MED; dy=size; if(pxw<x1) { pxw=x1; } if(pxw<(lbtns*buttx+lbtns*buttdx)) { pxw=(lbtns*buttx+lbtns*buttdx); } if(pxw>((ex-sx)-2*buttdx)) { pxw=ex-sx-2*buttdx; } psx=((ex-sx)/2-pxw/2); pyw=y1*dy/*-myo*/; if(pyw>((ey-sy)-yo-myo)) { pyw=((ey-sy)-yo-myo); } psy=((ey-sy)/2-(pyw+myo-yo)/2); if(btns) { buttxstart=psx+pxw/2-(((double)lbtns*(double)buttsize+(((lbtns>2)&&(lbtns&1))?((double)buttdx):0.0))/2.0); buttystart=psy+y1*dy+2*OFFSET_MED; } } while(run) { //frame layout if(action) { if(!buttonly) { int iw, ih, pxoffs = 0; int slen = GetStringLen(sx, title, FSIZE_BIG)+2*OFFSET_MED; if (icon_w > 0 && (psx+pxw-2*OFFSET_MED-slen <= psx-OFFSET_MED+icon_w+OFFSET_MED)) pxoffs = (icon_w)/2; RenderBox(psx-2*OFFSET_MED-pxoffs+OFFSET_SMALL, psy-yo-h_head/3-OFFSET_SMALL, psx+pxw+pxoffs+2*OFFSET_MED+OFFSET_SMALL, psy+pyw+myo+(h_head/3)+OFFSET_MED+OFFSET_SMALL, radius, COL_SHADOW_PLUS_0); RenderBox(psx-2*OFFSET_MED-pxoffs, psy-yo-h_head/3-OFFSET_MED, psx+pxw+pxoffs+2*OFFSET_MED, psy+pyw+myo+(h_head/3)+OFFSET_MED, radius, CMC); if(header) { int pyoffs=(icon_h < h_head)?1:0; RenderBox(psx-2*OFFSET_MED-pxoffs, psy-yo-h_head/3-OFFSET_MED, psx+pxw+pxoffs+2*OFFSET_MED, psy-yo+(h_head*2)/3-OFFSET_MED, radius, CMH); paintIcon(fname, psx-OFFSET_MED-pxoffs, psy-yo-h_head/3+h_head/2-icon_h/2+pyoffs-OFFSET_MED, xsize, ysize, &iw, &ih); RenderString(title, psx+pxoffs, psy-moffs-OFFSET_MED, pxw, CENTER, FSIZE_BIG, CMHT); } } if(buttonly || !(rv=fh_txt_load(TMP_FILE, psx, pxw, psy+size, dy, size, line, &cut))) { if(type==1) { for(i=0; i<btns; i++) { bx=i%lbtns; by=i/lbtns; RenderBox(buttxstart+bx*(buttsize+buttdx/2)+OFFSET_SMALL/2, buttystart+by*(butty+buttdy/2)+OFFSET_SMALL/2, buttxstart+(bx+1)*buttsize+bx*(buttdx/2)+OFFSET_SMALL/2, buttystart+by*(butty+buttdy/2)+butty+OFFSET_SMALL/2, radius_small, COL_SHADOW_PLUS_0); RenderBox(buttxstart+bx*(buttsize+buttdx/2), buttystart+by*(butty+buttdy/2), buttxstart+(bx+1)*buttsize+bx*(buttdx/2), buttystart+by*(butty+buttdy/2)+butty, radius_small, CMCS/*YELLOW*/); RenderBox(buttxstart+bx*(buttsize+buttdx/2)+1, buttystart+by*(butty+buttdy/2)+1, buttxstart+(bx+1)*buttsize+bx*(buttdx/2)-1, buttystart+by*(butty+buttdy/2)+butty-1, radius_small, ((by*bpline+bx)==(selection-1))?CMCS:CMC); RenderString(butmsg[i], buttxstart+bx*(buttsize+buttdx/2), buttystart+by*(butty+buttdy/2)+butty, buttsize, CENTER, fsizebut, (i==(selection-1))?CMCST:CMCIT); } } #if HAVE_SPARK_HARDWARE || HAVE_DUCKBOX_HARDWARE blit(); #else memcpy(lfb, lbb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t)); #endif } } run=0; } } return (rv)?-1:0; }
void amaroK::TrayIcon::engineTrackPositionChanged( long position, bool /*userSeek*/ ) { mergeLevel = trackLength ? ((baseIcon.height() + 1) * position) / trackLength : -1; paintIcon( mergeLevel ); }