void IconPreview::showPreview(const char *file) { if (file == NULL){ if (icons){ delete icons; icons = NULL; setIcons(); } return; } icons = new IconDLL; if (!icons->load(QFile::decodeName(file))){ delete icons; icons = NULL; } setIcons(); }
void IconsPlugin::setIcons() { for (ICONS_MAP::iterator it = dlls.begin(); it != dlls.end(); ++it) delete (*it).second; dlls.clear(); for (unsigned n = 1; ; n++){ const char *cfg = getIconDLLs(n); if ((cfg == NULL) || (*cfg == 0)) break; string v = cfg; string name = getToken(v, ','); if (v.length() == 0) continue; IconDLL *dll = new IconDLL; if (!dll->load(QString::fromUtf8(v.c_str()))) continue; dlls.insert(ICONS_MAP::value_type(name.c_str(), dll)); } if (smiles){ string s; for (unsigned i = 0; i < smiles->count(); i++){ const QIconSet *is = smiles->get(i); if (is == NULL){ log(L_DEBUG, "Skip %u", i); s += '-'; s += '\x00'; s += '\x00'; s += '\x00'; continue; } QString pat = smiles->pattern(i); while (!pat.isEmpty()){ QString p = getToken(pat, ' ', false); if (p.isEmpty()) continue; s += p.latin1(); s += '\x00'; log(L_DEBUG, "%u > %s", i, (const char*)(p.latin1())); } s += '\x00'; QString tip = smiles->tip(i); if (!tip.isEmpty()){ s += tip.local8Bit(); log(L_DEBUG, "%u Tip %s", i, (const char*)(tip.local8Bit())); } s += '\x00'; QString url = "smile"; url += QString::number(i).upper(); url = QString("icon:") + url; QMimeSourceFactory::defaultFactory()->setPixmap(url, is->pixmap(QIconSet::Small, QIconSet::Normal)); } s += '\x00'; s += '\x00'; s += '\x00'; SIM::setSmiles(s.c_str()); }else{ for (unsigned i = 0; i < 16; i++){ QString url = "icon:smile"; url += QString::number(i).upper(); const QIconSet *is = Icon((const char*)(url.latin1())); if (is == NULL) continue; QMimeSourceFactory::defaultFactory()->setPixmap(url, is->pixmap(QIconSet::Small, QIconSet::Normal)); } SIM::setSmiles(NULL); } Event eIcon(EventIconChanged); eIcon.process(); Event eHistory(EventHistoryConfig); eHistory.process(); }