QString ToolTipFiller::filterActionTipContents(const FilterAction& action) { if (action.isNull()) { return QString(); } QString str; DToolTipStyleSheet cnt(ApplicationSettings::instance()->getToolTipsFont()); QString tip = cnt.tipHeader; tip += cnt.headBeg + i18n("Filter") + cnt.headEnd; // Displayable name tip += cnt.cellBeg + i18n("Name:") + cnt.cellMid + DImgFilterManager::instance()->i18nDisplayableName(action) + cnt.cellEnd; // Category QString reproducible("---"); switch (action.category()) { case FilterAction::ReproducibleFilter: reproducible = i18nc("Image filter reproducible: Yes", "Yes"); break; case FilterAction::ComplexFilter: reproducible = i18nc("Image filter reproducible: Partially", "Partially"); break; case FilterAction::DocumentedHistory: reproducible = i18nc("Image filter reproducible: No", "No"); break; default: break; }; tip += cnt.cellBeg + i18n("Reproducible:") + cnt.cellMid + reproducible + cnt.cellEnd; // Description str = action.description(); if (str.isEmpty()) { str = QString("---"); } tip += cnt.cellSpecBeg + i18nc("Image filter description", "Description:") + cnt.cellSpecMid + cnt.breakString(str) + cnt.cellSpecEnd; // Identifier + version tip += cnt.cellBeg + i18n("Identifier:") + cnt.cellMid + action.identifier() + " (v" + QString::number(action.version()) + ") " + cnt.cellEnd; if (action.hasParameters()) { tip += cnt.headBeg + i18n("Technical Parameters") + cnt.headEnd; const QHash<QString, QVariant>& params = action.parameters(); QList<QString> keys = params.keys(); qSort(keys); foreach(const QString& key, keys) { QHash<QString, QVariant>::const_iterator it; for (it = params.find(key); it != params.end() && it.key() == key; ++it) { if (it.key().isEmpty() || !it.value().isValid()) { continue; } if (it.key().startsWith(QLatin1String("curveData"))) { str = i18n("<i>Binary Data</i>"); } else { str = it.value().toString(); } if (str.length() > cnt.maxStringLength) { str = cnt.elidedText(str, Qt::ElideRight); } QString key = it.key(); QChar first = key.at(0); if (first.isLower()) { key.replace(0, 1, first.toUpper()); } tip += cnt.cellBeg + key + cnt.cellMid + str + cnt.cellEnd; } }
void DImgBuiltinFilter::setAction(const FilterAction& action) { m_type = NoOperation; if (action.identifier() == "transform:rotate" && action.version() == 1) { int angle = action.parameter("angle").toInt(); if (angle == 90) { m_type = Rotate90; } else if (angle == 180) { m_type = Rotate180; } else { m_type = Rotate270; } } else if (action.identifier() == "transform:flip" && action.version() == 1) { QString direction = action.parameter("direction").toString(); if (direction == "vertical") { m_type = FlipVertically; } else { m_type = FlipHorizontally; } } else if (action.identifier() == "transform:crop" && action.version() == 1) { m_type = Crop; int x = action.parameter("x").toInt(); int y = action.parameter("y").toInt(); int width = action.parameter("width").toInt(); int height = action.parameter("height").toInt(); m_arg = QRect(x, y, width, height); } else if (action.identifier() == "transform:resize" && action.version() == 1) { m_type = Resize; int width = action.parameter("width").toInt(); int height = action.parameter("height").toInt(); m_arg = QSize(width, height); } else if (action.identifier() == "transform:convertDepth" && action.version() == 1) { int depth = action.parameter("depth").toInt(); if (depth == 16) { m_type = ConvertTo16Bit; } else { m_type = ConvertTo8Bit; } } }