TQColor KColorDialog::grabColor(const TQPoint &p) { TQWidget *desktop = TQT_TQWIDGET(TQApplication::desktop()); TQPixmap pm = TQPixmap::grabWindow( desktop->winId(), p.x(), p.y(), 1, 1); TQImage i = pm.convertToImage(); return i.pixel(0,0); }
void TDEIconEffectSetupDialog::preview() { TQPixmap pm; TQImage img = mExample.copy(); img = mpEffect->apply(img, mEffect.type, mEffect.value, mEffect.color, mEffect.color2, mEffect.transparant); pm.convertFromImage(img); mpPreview->setPixmap(pm); }
void LayoutIcon::dimPixmap(TQPixmap& pm) { TQImage 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(tqRgb(tqRed(rgb)*3/4, tqGreen(rgb)*3/4, tqBlue(rgb)*3/4)); image.setPixel(x, y, dimRgb); } pm.convertFromImage(image); }
void TDEIconConfig::EffectSetup(int state) { int viewedGroup = (mUsage == TDEIcon::LastGroup) ? TDEIcon::FirstGroup : mUsage; if (mpUsageList->currentText() == i18n("Panel Buttons")) { return; } if (mpUsageList->currentText() == i18n("System Tray Icons")) { return; } TQPixmap pm = mpLoader->loadIcon(mExample, TDEIcon::NoGroup, mSizes[viewedGroup]); TQImage img = pm.convertToImage(); if (mbDP[viewedGroup]) { int w = img.width() * 2; img = img.smoothScale(w, w); } TQString caption; switch (state) { case 0 : caption = i18n("Setup Default Icon Effect"); break; case 1 : caption = i18n("Setup Active Icon Effect"); break; case 2 : caption = i18n("Setup Disabled Icon Effect"); break; } TDEIconEffectSetupDialog dlg(mEffects[viewedGroup][state], mDefaultEffect[state], caption, img); if (dlg.exec() == TQDialog::Accepted) { if (mUsage == TDEIcon::LastGroup) { for (int i=0; i<TDEIcon::LastGroup; i++) mEffects[i][state] = dlg.effect(); } else { mEffects[mUsage][state] = dlg.effect(); } // AK - can this call be moved therefore removing // code duplication? emit changed(true); if (mUsage == TDEIcon::LastGroup) { for (int i=0; i<TDEIcon::LastGroup; i++) mbChanged[i] = true; } else { mbChanged[mUsage] = true; } } preview(state); }
void EvaQunMemberPicker::updateBuddyListView() { //if(!mQun) return; lvBuddyList->clear(); TQTextCodec *codec = TQTextCodec::codecForName("GB18030"); std::list<std::string> names = EvaMain::user->getGroupNames(); std::list<std::string>::iterator groupIter; int i=0; for(groupIter = names.begin(); groupIter!= names.end(); ++groupIter){ TQString g = codec->toUnicode(groupIter->c_str()); TQCheckListItem *item = new TQCheckListItem(lvBuddyList, g, TQCheckListItem::CheckBox); item->setState(TQCheckListItem::Off); groups[i++] = item; } //QunInfo info = mQun->getDetails(); std::map<unsigned int, TQQFriend>::iterator iter; std::map<unsigned int, TQQFriend> list = (EvaMain::user->getFriendList()).getAllFriendsMap(); for(iter = list.begin(); iter != list.end(); ++iter){ int id = iter->second.getQQ(); TQString nick = EvaTextFilter::filter(codec->toUnicode(iter->second.getNick().c_str())); int groupIndex = iter->second.getGroupIndex(); TQCheckListItem *group = groups[groupIndex]; if(!group) continue; short faceID = (iter->second.getFace())/3 + 1; if(faceID<1) faceID = 1; TQCheckListItem *item = new TQCheckListItem(group, nick + "(" + TQString::number(id) + ")", TQCheckListItem::CheckBox); TQPixmap *pic = EvaMain::images->getFace(faceID, true); if(pic) { TQImage img(pic->convertToImage().smoothScale(16, 16)); item->setPixmap(0, TQPixmap(img)); }else{ fprintf(stderr, "EvaQunMemberPicker::updateBuddyListView (id:%d, faceID:%d, %s) -- NULL TQPixmap pointer, ignored!\n", id, faceID, nick.ascii()); } if(mQun && mQun->hasMember(id)) item->setState(TQCheckListItem::On); else item->setState(TQCheckListItem::Off); buddyList[id] = item; } }
void KMdiDockContainer::setPixmap( KDockWidget* widget , const TQPixmap& pixmap ) { int id = m_ws->id( widget ); if ( id == -1 ) return ; KMultiTabBarTab *tab = m_tb->tab( id ); tab->setIcon( pixmap.isNull() ? SmallIcon( "misc" ) : pixmap ); }
void TDEAboutContainerBase::setProgramLogo( const TQPixmap &pixmap ) { if( !mIconLabel ) { kdDebug(291) << "setProgramLogo: " << "Invalid layout" << endl; return; } if( !pixmap.isNull() ) { mIconLabel->setPixmap( pixmap ); } }
TQDragObject *KFileDetailView::dragObject() { // create a list of the URL:s that we want to drag KURL::List urls; KFileItemListIterator it( * KFileView::selectedItems() ); for ( ; it.current(); ++it ){ urls.append( (*it)->url() ); } TQPixmap pixmap; if( urls.count() > 1 ) pixmap = DesktopIcon( "tdemultiple", TDEIcon::SizeSmall ); if( pixmap.isNull() ) pixmap = currentFileItem()->pixmap( TDEIcon::SizeSmall ); TQPoint hotspot; hotspot.setX( pixmap.width() / 2 ); hotspot.setY( pixmap.height() / 2 ); TQDragObject* myDragObject = new KURLDrag( urls, widget() ); myDragObject->setPixmap( pixmap, hotspot ); return myDragObject; }
void TDEIconConfig::preview(int i) { // Apply effects ourselves because we don't want to sync // the configuration every preview. int viewedGroup; if (mpUsageList->text(mUsage) == i18n("Panel Buttons")) { viewedGroup = TDEIcon::FirstGroup; } else if (mpUsageList->text(mUsage) == i18n("System Tray Icons")) { viewedGroup = TDEIcon::FirstGroup; } else { viewedGroup = (mUsage == TDEIcon::LastGroup) ? TDEIcon::FirstGroup : mUsage; } TQPixmap pm; if (mpUsageList->text(mUsage) == i18n("Panel Buttons")) { pm = mpLoader->loadIcon(mExample, TDEIcon::NoGroup, mQuickLaunchSize); } else if (mpUsageList->text(mUsage) == i18n("System Tray Icons")) { pm = mpLoader->loadIcon(mExample, TDEIcon::NoGroup, mSysTraySize); } else { pm = mpLoader->loadIcon(mExample, TDEIcon::NoGroup, mSizes[viewedGroup]); } TQImage img = pm.convertToImage(); if (mbDP[viewedGroup]) { int w = img.width() * 2; img = img.smoothScale(w, w); } Effect &effect = mEffects[viewedGroup][i]; img = mpEffect->apply(img, effect.type, effect.value, effect.color, effect.color2, effect.transparant); pm.convertFromImage(img); mpPreview[i]->setPixmap(pm); }
void CustomSmileyManager::loadSmileys( int groupIndex ) { // clear the table first for(int row = 0; row < tblFaceList->numRows(); row++){ tblFaceList->removeRow(row); } tblFaceList->setNumRows(0); TQString dir = EvaMain::user->getSetting()->getCustomSmileyDir() + "/"; if(groupIndex>0) dir += (m_Config->groupName( groupIndex) + "/"); FaceList list = m_Config->groupMembers( groupIndex ); int row = 0; if(list.size()){ tblFaceList->setNumRows(list.size()); tblFaceList->horizontalHeader()->setLabel( 0, i18n("No." ) ); tblFaceList->horizontalHeader()->setLabel( 1, i18n("Smiley" ) ); tblFaceList->horizontalHeader()->setLabel( 2, i18n("Shortcut" ) ); for( FaceList::Iterator it = list.begin(); it != list.end(); ++it){ //tblFaceList->setText(row, 0, TQString::number( row + 1)); tblFaceList->setItem(row, 0, new TQTableItem(tblFaceList, TQTableItem::Never, TQString::number(row + 1))); TQPixmap *pixmap = new TQPixmap(dir + (*it).fixed()); CustomItem *item = new CustomItem(tblFaceList, (*it).tip(), *pixmap); tblFaceList->setItem(row, 1, item); CustomItem *itemSC = new CustomItem(tblFaceList, (*it).shortcut() ); tblFaceList->setItem(row, 2, itemSC); tblFaceList->setRowHeight(row, pixmap->width() + 2); delete pixmap; row++; } tblFaceList->setColumnWidth(0, 20); tblFaceList->setColumnWidth(1, tblFaceList->visibleWidth() - 20 - 50 ); } }
//private TQPixmap* LayoutIcon::createErrorPixmap() { TQPixmap* pm = new TQPixmap(21, 14); pm->fill(Qt::white); TQPainter p(pm); p.setFont(m_labelFont); p.setPen(Qt::red); p.drawText(1, 1, pm->width(), pm->height()-2, Qt::AlignCenter, ERROR_LABEL); p.setPen(Qt::blue); p.drawText(0, 0, pm->width(), pm->height()-2, Qt::AlignCenter, ERROR_LABEL); m_pixmapCache.insert(ERROR_CODE, pm); return pm; }
void KMdiDockContainer::insertWidget ( KDockWidget *dwdg, TQPixmap pixmap, const TQString &text, int & ) { kdDebug( 760 ) << k_funcinfo << "Adding a dockwidget to the dock container" << endl; KDockWidget* w = dwdg; int tab; bool alreadyThere = m_map.contains( w ); if ( alreadyThere ) { tab = m_map[ w ]; if ( m_ws->addWidget( w, tab ) != tab ) kdDebug( 760 ) << "ERROR COULDN'T READD WIDGET" << endl; kdDebug( 760 ) << k_funcinfo << "Readded widget " << dwdg << endl; } else { tab = m_ws->addWidget( w ); m_map.insert( w, tab ); m_revMap.insert( tab, w ); if ( ( ( KDockWidget* ) parentWidget() ) ->mayBeShow() ) ( ( KDockWidget* ) parentWidget() ) ->dockBack(); if ( ::tqqt_cast<KDockWidgetHeader*>(w->getHeader()) ) { kdDebug( 760 ) << k_funcinfo << "The dockwidget we're adding has a header" << endl; kdDebug( 760 ) << k_funcinfo << "Adding our overlap mode button to it" << endl; KDockWidgetHeader *hdr = ::tqqt_cast<KDockWidgetHeader*>( w->getHeader() ); KDockButton_Private *btn = new KDockButton_Private( hdr, "OverlapButton" ); TQToolTip::add( btn, i18n( "Switch between overlap and side by side mode", "Overlap" ) ); btn->setToggleButton( true ); btn->setPixmap( const_cast< const char** >( tdemdi_not_close_xpm ) ); hdr->addButton( btn ); m_overlapButtons.insert( w, btn ); btn->setOn( !isOverlapMode() ); connect( btn, TQT_SIGNAL( clicked() ), this, TQT_SLOT( changeOverlapMode() ) ); } m_tb->appendTab( pixmap.isNull() ? SmallIcon( "misc" ) : pixmap, tab, w->tabPageLabel() ); m_tb->tab( tab )->installEventFilter( this ); kdDebug( 760 ) << k_funcinfo << "Added tab with label " << w->tabPageLabel() << " to the tabbar" << endl; connect( m_tb->tab( tab ), TQT_SIGNAL( clicked( int ) ), this, TQT_SLOT( tabClicked( int ) ) ); mTabCnt++; m_inserted = tab; int dummy = 0; KDockContainer::insertWidget( w, pixmap, text, dummy ); itemNames.append( w->name() ); tabCaptions.insert( w->name(), w->tabPageLabel() ); tabTooltips.insert( w->name(), w->toolTipString() ); } //FB m_ws->raiseWidget(tab); }
void KwikDisk::updateDFDone() { kdDebug() << k_funcinfo << endl; m_readingDF = FALSE; m_dirty = FALSE; contextMenu()->clear(); contextMenu()->insertTitle(KSystemTray::loadIcon("kdf"), i18n("KwikDisk")); int itemNo = 0; for( DiskEntry *disk = m_diskList.first(); disk != 0; disk = m_diskList.next() ) { // FIXME: tool tips are unused atm TQString toolTipText = i18n("%1 (%2) %3 on %4") .arg( disk->mounted() ? i18n("Unmount") : i18n("Mount")) .arg(disk->fsType()).arg(disk->deviceName()).arg(disk->mountPoint()); TQString entryName = disk->mountPoint(); if( disk->mounted() ) { entryName += TQString("\t\t\t[%1]").arg(disk->prettyKBAvail()); } int id = contextMenu()->insertItem("", this, TQT_SLOT(toggleMount(int)) ); contextMenu()->setItemParameter(id, itemNo); itemNo++; TQPixmap *pix = new TQPixmap(KSystemTray::loadIcon(disk->iconName())); if( getuid() !=0 && disk->mountOptions().find("user",0, false) == -1 ) { // // Special root icon, normal user cant mount. // // 2000-01-23 Espen Sand // Careful here: If the mask has not been defined we can // not use TQPixmap::mask() because it returns 0 => segfault // if( pix->mask() != 0 ) { TQBitmap *bm = new TQBitmap(*(pix->mask())); if( bm != 0 ) { TQPainter qp( bm ); qp.setPen(TQPen(white,1)); qp.drawRect(0,0,bm->width(),bm->height()); qp.end(); pix->setMask(*bm); } TQPainter qp( pix ); qp.setPen(TQPen(red,1)); qp.drawRect(0,0,pix->width(),pix->height()); qp.end(); } contextMenu()->disconnectItem(id,disk,TQT_SLOT(toggleMount())); toolTipText = i18n("You must login as root to mount this disk"); } contextMenu()->changeItem(*pix,entryName,id); } contextMenu()->insertSeparator(); contextMenu()->insertItem( KSystemTray::loadIcon("kdf"), i18n("&Start KDiskFree"), this, TQT_SLOT(startKDF()),0); contextMenu()->insertItem( KSystemTray::loadIcon("configure"), i18n("&Configure KwikDisk..."), this, TQT_SLOT(changeSettings()),0); contextMenu()->insertItem( KSystemTray::loadIcon("help"), KStdGuiItem::help().text(), this, TQT_SLOT(invokeHelp()),0); contextMenu()->insertSeparator(); contextMenu()->insertItem( KSystemTray::loadIcon("exit"), KStdGuiItem::quit().text(), this, TQT_SIGNAL(quitSelected()) ); }
void ThumbnailProtocol::get(const KURL &url) { m_mimeType = metaData("mimeType"); kdDebug(7115) << "Wanting MIME Type:" << m_mimeType << endl; #ifdef THUMBNAIL_HACK // ### HACK bool direct=false; if (m_mimeType.isEmpty()) { kdDebug(7115) << "PATH: " << url.path() << endl; TQFileInfo info(url.path()); if (info.isDir()) { // We cannot process a directory error(TDEIO::ERR_IS_DIRECTORY,url.path()); return; } else if (!info.exists()) { // The file does not exist error(TDEIO::ERR_DOES_NOT_EXIST,url.path()); return; } else if (!info.isReadable()) { // The file is not readable! error(TDEIO::ERR_COULD_NOT_READ,url.path()); return; } m_mimeType = KMimeType::findByURL(url)->name(); kdDebug(7115) << "Guessing MIME Type:" << m_mimeType << endl; direct=true; // thumbnail: was probably called from Konqueror } #endif if (m_mimeType.isEmpty()) { error(TDEIO::ERR_INTERNAL, i18n("No MIME Type specified.")); return; } m_width = metaData("width").toInt(); m_height = metaData("height").toInt(); int iconSize = metaData("iconSize").toInt(); if (m_width < 0 || m_height < 0) { error(TDEIO::ERR_INTERNAL, i18n("No or invalid size specified.")); return; } #ifdef THUMBNAIL_HACK else if (!m_width || !m_height) { kdDebug(7115) << "Guessing height, width, icon size!" << endl; m_width=128; m_height=128; iconSize=128; } #endif if (!iconSize) iconSize = TDEGlobal::iconLoader()->currentSize(TDEIcon::Desktop); if (iconSize != m_iconSize) m_iconDict.clear(); m_iconSize = iconSize; m_iconAlpha = metaData("iconAlpha").toInt(); if (m_iconAlpha) m_iconAlpha = (m_iconAlpha << 24) | 0xffffff; TQImage img; TDEConfigGroup group( TDEGlobal::config(), "PreviewSettings" ); // ### KFMI bool kfmiThumb = false; if (group.readBoolEntry( "UseFileThumbnails", true )) { KService::Ptr service = KServiceTypeProfile::preferredService( m_mimeType, "KFilePlugin"); if ( service && service->isValid() && /*url.isLocalFile() && */ service->property("SupportsThumbnail").toBool()) { KFileMetaInfo info(url.path(), m_mimeType, KFileMetaInfo::Thumbnail); if (info.isValid()) { KFileMetaInfoItem item = info.item(KFileMimeTypeInfo::Thumbnail); if (item.isValid() && item.value().type() == TQVariant::Image) { img = item.value().toImage(); kdDebug(7115) << "using KFMI for the thumbnail\n"; kfmiThumb = true; } } } } ThumbCreator::Flags flags = ThumbCreator::None; if (!kfmiThumb) { kdDebug(7115) << "using thumb creator for the thumbnail\n"; TQString plugin = metaData("plugin"); #ifdef THUMBNAIL_HACK if (plugin.isEmpty()) { TDETrader::OfferList plugins = TDETrader::self()->query("ThumbCreator"); TQMap<TQString, KService::Ptr> mimeMap; for (TDETrader::OfferList::ConstIterator it = plugins.begin(); it != plugins.end(); ++it) { TQStringList mimeTypes = (*it)->property("MimeTypes").toStringList(); for (TQStringList::ConstIterator mt = mimeTypes.begin(); mt != mimeTypes.end(); ++mt) { if ((*mt)==m_mimeType) { plugin=(*it)->library(); break; } } if (!plugin.isEmpty()) break; } } kdDebug(7115) << "Guess plugin: " << plugin << endl; #endif if (plugin.isEmpty()) { error(TDEIO::ERR_INTERNAL, i18n("No plugin specified.")); return; } ThumbCreator *creator = m_creators[plugin]; if (!creator) { // Don't use KLibFactory here, this is not a TQObject and // neither is ThumbCreator KLibrary *library = KLibLoader::self()->library(TQFile::encodeName(plugin)); if (library) { newCreator create = (newCreator)library->symbol("new_creator"); if (create) creator = create(); } if (!creator) { error(TDEIO::ERR_INTERNAL, i18n("Cannot load ThumbCreator %1").arg(plugin)); return; } m_creators.insert(plugin, creator); } if (!creator->create(url.path(), m_width, m_height, img)) { error(TDEIO::ERR_INTERNAL, i18n("Cannot create thumbnail for %1").arg(url.path())); return; } flags = creator->flags(); } if (img.width() > m_width || img.height() > m_height) { double imgRatio = (double)img.height() / (double)img.width(); if (imgRatio > (double)m_height / (double)m_width) img = img.smoothScale( int(TQMAX((double)m_height / imgRatio, 1)), m_height); else img = img.smoothScale(m_width, int(TQMAX((double)m_width * imgRatio, 1))); } // ### FIXME #ifndef USE_KINSTANCE if (flags & ThumbCreator::DrawFrame) { TQPixmap pix; pix.convertFromImage(img); int x2 = pix.width() - 1; int y2 = pix.height() - 1; // paint a black rectangle around the "page" TQPainter p; p.begin( &pix ); p.setPen( TQColor( 48, 48, 48 )); p.drawLine( x2, 0, x2, y2 ); p.drawLine( 0, y2, x2, y2 ); p.setPen( TQColor( 215, 215, 215 )); p.drawLine( 0, 0, x2, 0 ); p.drawLine( 0, 0, 0, y2 ); p.end(); const TQBitmap *mask = pix.mask(); if ( mask ) // need to update it so we can see the frame { TQBitmap bitmap( *mask ); TQPainter painter; painter.begin( &bitmap ); painter.drawLine( x2, 0, x2, y2 ); painter.drawLine( 0, y2, x2, y2 ); painter.drawLine( 0, 0, x2, 0 ); painter.drawLine( 0, 0, 0, y2 ); painter.end(); pix.setMask( bitmap ); } img = pix.convertToImage(); } #endif if ((flags & ThumbCreator::BlendIcon) && TDEGlobal::iconLoader()->alphaBlending(TDEIcon::Desktop)) { // blending the mimetype icon in TQImage icon = getIcon(); int x = img.width() - icon.width() - 4; x = TQMAX( x, 0 ); int y = img.height() - icon.height() - 6; y = TQMAX( y, 0 ); KImageEffect::blendOnLower( x, y, icon, img ); } if (img.isNull()) { error(TDEIO::ERR_INTERNAL, i18n("Failed to create a thumbnail.")); return; } const TQString shmid = metaData("shmid"); if (shmid.isEmpty()) { #ifdef THUMBNAIL_HACK if (direct) { // If thumbnail was called directly from Konqueror, then the image needs to be raw //kdDebug(7115) << "RAW IMAGE TO STREAM" << endl; TQBuffer buf; if (!buf.open(IO_WriteOnly)) { error(TDEIO::ERR_INTERNAL, i18n("Could not write image.")); return; } img.save(&buf,"PNG"); buf.close(); data(buf.buffer()); } else #endif { TQByteArray imgData; TQDataStream stream( imgData, IO_WriteOnly ); //kdDebug(7115) << "IMAGE TO STREAM" << endl; stream << img; data(imgData); } } else { TQByteArray imgData; TQDataStream stream( imgData, IO_WriteOnly ); //kdDebug(7115) << "IMAGE TO SHMID" << endl; void *shmaddr = shmat(shmid.toInt(), 0, 0); if (shmaddr == (void *)-1) { error(TDEIO::ERR_INTERNAL, i18n("Failed to attach to shared memory segment %1").arg(shmid)); return; } if (img.width() * img.height() > m_width * m_height) { error(TDEIO::ERR_INTERNAL, i18n("Image is too big for the shared memory segment")); shmdt((char*)shmaddr); return; } if( img.depth() != 32 ) // TDEIO::PreviewJob and this code below completely img = img.convertDepth( 32 ); // ignores colortable :-/, so make sure there is none stream << img.width() << img.height() << img.depth() << img.hasAlphaBuffer(); memcpy(shmaddr, img.bits(), img.numBytes()); shmdt((char*)shmaddr); data(imgData); } finished(); }
const TQPixmap& LayoutIcon::findPixmap(const TQString& code_, bool showFlag, const TQString& displayName_) { TQPixmap* pm = NULL; if( code_ == ERROR_CODE ) { pm = m_pixmapCache[ERROR_CODE]; if( pm == NULL ) { pm = createErrorPixmap(); m_pixmapCache.insert(ERROR_CODE, pm); } return *pm; } TQString displayName(displayName_); if( displayName.isEmpty() ) { displayName = KxkbConfig::getDefaultDisplayName(code_); } if( displayName.length() > 3 ) displayName = displayName.left(3); const TQString pixmapKey( showFlag ? code_ + "." + displayName : displayName ); pm = m_pixmapCache[pixmapKey]; if( pm ) return *pm; TQString flag; if( showFlag ) { TQString countryCode = getCountryFromLayoutName( code_ ); flag = locate("locale", flagTemplate.arg(countryCode)); } if( flag.isEmpty() ) { pm = new TQPixmap(FLAG_MAX_WIDTH, FLAG_MAX_HEIGHT); pm->fill(Qt::gray); } else { pm = new TQPixmap(flag); dimPixmap( *pm ); #if 0 if( pm->height() < FLAG_MAX_HEIGHT ) { TQPixmap* pix = new TQPixmap(FLAG_MAX_WIDTH, FLAG_MAX_HEIGHT); pix->fill( Qt::lightGray ); // pix->fill( TQColor(tqRgba(127,127,127,255)) ); // TQBitmap mask; // mask.fill(1); // pix->setMask(mask); int dy = (pix->height() - pm->height()) / 2; copyBlt( pix, 0, dy, pm, 0, 0, -1, -1 ); // TQPixmap* px = new TQPixmap(21, 14); // px->convertFromImage(img);*/ delete pm; pm = pix; } #endif } TQPainter p(pm); p.setFont(m_labelFont); p.setPen(Qt::black); p.drawText(1, 1, pm->width(), pm->height()-2, Qt::AlignCenter, displayName); p.setPen(Qt::white); p.drawText(0, 0, pm->width(), pm->height()-2, Qt::AlignCenter, displayName); m_pixmapCache.insert(pixmapKey, pm); return *pm; }
/************************************************************************** * recalculates and repaints the pixBars **/ void KDFWidget::updateDiskBarPixmaps( void ) { if (mTabProp[usageCol]->mVisible != true) return; int size=0, w=0; 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(TQListViewItem *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; } TQPixmap *pix = new TQPixmap( w, h ); if( pix == 0 ) { continue; } pix->fill(white); TQPainter p(pix); p.setPen(black); p.drawRect(0,0,w,h); TQColor 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; } } }