| 934 | } |
| 935 | |
| 936 | void MainWindow::applyCustomShortcuts() |
| 937 | { |
| 938 | ApplicationSettings *settings = app->getSettings(); |
| 939 | settings->beginGroup("Shortcuts"); |
| 940 | |
| 941 | for (const QString &actionName : settings->childKeys()) { |
| 942 | QAction *action = findChild<QAction *>(QStringLiteral("action") + actionName, Qt::FindDirectChildrenOnly); |
| 943 | |
| 944 | if (!action) { |
| 945 | qWarning() << "CustomShortcut: Cannot find action" << actionName; |
| 946 | continue; |
| 947 | } |
| 948 | |
| 949 | const QVariant value = settings->value(actionName); |
| 950 | if (!value.canConvert<QStringList>()) { |
| 951 | qWarning() << "CustomShortcut: Invalid shortcut format for" << actionName; |
| 952 | continue; |
| 953 | } |
| 954 | |
| 955 | QList<QKeySequence> shortcuts; |
| 956 | for (const QString &shortcutString : value.toStringList()) { |
| 957 | auto sequence = QKeySequence(shortcutString); |
| 958 | |
| 959 | #if QT_VERSION >= QT_VERSION_CHECK(6,0,0) |
| 960 | if (sequence.count() > 0 && sequence[0].key() != Qt::Key_unknown) { |
| 961 | #else |
| 962 | if (sequence.count() > 0 && (sequence[0] & ~Qt::KeyboardModifierMask) != Qt::Key_unknown) { |
| 963 | #endif |
| 964 | shortcuts.append(sequence); |
| 965 | } |
| 966 | else { |
| 967 | qWarning() << "CustomShortcut: Cannot create QKeySequence(" << shortcutString << ") for " << actionName; |
| 968 | } |
| 969 | } |
| 970 | |
| 971 | if (!shortcuts.empty()) { |
| 972 | action->setShortcuts(shortcuts); |
| 973 | } |
| 974 | } |
| 975 | |
| 976 | settings->endGroup(); |
| 977 | } |
| 978 | |
| 979 | void MainWindow::setupLanguageMenu() |
| 980 | { |
| 981 | qInfo(Q_FUNC_INFO); |
| 982 | |
| 983 | QStringList language_names = app->getLanguages(); |
| 984 | |
| 985 | int i = 0; |
| 986 | while (i < language_names.size()) { |
| 987 | QList<QAction *> actions; |
| 988 | int j = i; |
| 989 | |
| 990 | // Get all consecutive names that start with the same letter |
| 991 | // NOTE: this loop always runs once since i == j the first time |
| 992 | while (j < language_names.size() && language_names[i][0].toUpper() == language_names[j][0].toUpper()) { |
| 993 | const QString key = language_names[j]; |
nothing calls this directly
no test coverage detected