| 2182 | } |
| 2183 | |
| 2184 | void EncodingLabel::insertCodec(const QString& visibleCodecName, const QByteArray& nameArray, QList<QByteArray>& codecList, QMenu* pMenu, const QByteArray& currentTextCodecName) const |
| 2185 | { |
| 2186 | if(!codecList.contains(nameArray)) |
| 2187 | { |
| 2188 | QAction* pAction = new QAction(pMenu); // menu takes ownership, so deleting the menu deletes the action too. |
| 2189 | const QLatin1String codecName = QLatin1String(nameArray); |
| 2190 | |
| 2191 | pAction->setText(visibleCodecName.isEmpty() ? codecName : visibleCodecName + u8" (" + codecName + u8")"); |
| 2192 | pAction->setData(nameArray); |
| 2193 | pAction->setCheckable(true); |
| 2194 | if(currentTextCodecName == nameArray) |
| 2195 | pAction->setChecked(true); |
| 2196 | pMenu->addAction(pAction); |
| 2197 | chk_connect_a(pAction, &QAction::triggered, this, &EncodingLabel::slotSelectEncoding); |
| 2198 | codecList.append(nameArray); |
| 2199 | } |
| 2200 | } |
| 2201 | |
| 2202 | void EncodingLabel::slotSelectEncoding() |
| 2203 | { |