void EditPanel::onImagePathButtonClicked(bool /*checked*/) { QList<QByteArray> formats = QImageReader::supportedImageFormats(); QString filter; for(QList<QByteArray>::const_iterator i=formats.begin(); i!=formats.end(); i++) { QString ext(*i); if( !ext.isEmpty() ) { if( !filter.isEmpty() ) filter.append(' '); filter.append( QString("*.%1").arg(ext) ); } } if( !filter.isEmpty() ) { filter.prepend( tr("Image Files (") ); filter.append(")"); } QString imagePath = QFileDialog::getOpenFileName(this, tr("Select Icon"), QDesktopServices::storageLocation(QDesktopServices::PicturesLocation), filter); SetImagePath(imagePath); emit edited(); }
//! Set the root path from which to look for images with the factory. bool ImageBlock::SetDefaultImagePath(const std::string& path) { // Find the image block factory from the default map and give it the path. RichText::BLOCK_FACTORY_MAP::const_iterator factory_it = RichText::DefaultBlockFactoryMap()->find(IMAGE_TAG); if (factory_it != RichText::DefaultBlockFactoryMap()->end()) { ImageBlockFactory* factory = dynamic_cast<ImageBlockFactory*>(factory_it->second); if (factory != 0) { return SetImagePath(factory, path); } } return false; }