MCPcopy Create free account
hub / github.com/dail8859/NotepadNext / setupLanguageMenu

Method setupLanguageMenu

src/dialogs/MainWindow.cpp:979–1015  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

977}
978
979void 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];
994 QAction *action = new QAction(key);
995 action->setCheckable(true);
996 action->setData(key);
997 connect(action, &QAction::triggered, this, &MainWindow::languageMenuTriggered);
998 languageActionGroup->addAction(action);
999 actions.append(action);
1000
1001 ++j;
1002 }
1003
1004 if (actions.size() == 1) {
1005 ui->menuLanguage->addActions(actions);
1006 }
1007 else {
1008 // Create a sub menu with the actions
1009 QMenu *compactMenu = new QMenu(actions[0]->text().at(0).toUpper());
1010 compactMenu->addActions(actions);
1011 ui->menuLanguage->addMenu(compactMenu);
1012 }
1013 i = j;
1014 }
1015}
1016
1017ScintillaNext *MainWindow::currentEditor() const
1018{

Callers

nothing calls this directly

Calls 3

getLanguagesMethod · 0.80
sizeMethod · 0.45
setDataMethod · 0.45

Tested by

no test coverage detected