| 867 | } |
| 868 | |
| 869 | void LabelWidget::charMenu() { |
| 870 | QMenu menu; |
| 871 | KCharSelect selection(this, nullptr, KCharSelect::SearchLine | KCharSelect::CharacterTable | KCharSelect::BlockCombos | KCharSelect::HistoryButtons); |
| 872 | QFont font = ui.teLabel->currentFont(); |
| 873 | // use the system default size, otherwise the symbols might be hard to read |
| 874 | // if the current label font size is too small |
| 875 | font.setPointSize(QFont().pointSize()); |
| 876 | selection.setCurrentFont(font); |
| 877 | connect(&selection, &KCharSelect::charSelected, this, &LabelWidget::insertChar); |
| 878 | connect(&selection, &KCharSelect::charSelected, &menu, &LabelWidget::close); |
| 879 | |
| 880 | auto* widgetAction = new QWidgetAction(this); |
| 881 | widgetAction->setDefaultWidget(&selection); |
| 882 | menu.addAction(widgetAction); |
| 883 | |
| 884 | QPoint pos(-menu.sizeHint().width() + ui.tbSymbols->width(), -menu.sizeHint().height()); |
| 885 | menu.exec(ui.tbSymbols->mapToGlobal(pos)); |
| 886 | } |
| 887 | |
| 888 | void LabelWidget::insertChar(QChar c) { |
| 889 | ui.teLabel->insertPlainText(QString(c)); |