// Read the command set from settings. bool QsciCommandSet::readSettings(QSettings &qs, const char *prefix) { bool rc = true; QString skey; for (int i = 0; i < cmds.count(); ++i) { QsciCommand *cmd = cmds.at(i); skey.sprintf("%s/keymap/c%d/", prefix, static_cast<int>(cmd->command())); int key; bool ok; // Read the key. key = qs.readNumEntry(skey + "key", 0, &ok); if (ok) cmd->setKey(key); else rc = false; // Read the alternate key. key = qs.readNumEntry(skey + "alt", 0, &ok); if (ok) cmd->setAlternateKey(key); else rc = false; } return rc; }
ScintillaEditor::ScintillaEditor(QWidget *parent) : EditorInterface(parent) { scintillaLayout = new QVBoxLayout(this); qsci = new QsciScintilla(this); // Force EOL mode to Unix, since QTextStream will manage local EOL modes. qsci->setEolMode(QsciScintilla::EolUnix); // // Remapping some scintilla key binding which conflict with OpenSCAD global // key bindings, as well as some minor scintilla bugs // QsciCommand *c; #ifdef Q_OS_MAC // Alt-Backspace should delete left word (Alt-Delete already deletes right word) c = qsci->standardCommands()->find(QsciCommand::DeleteWordLeft); c->setKey(Qt::Key_Backspace | Qt::ALT); #endif // Cmd/Ctrl-T is handled by the menu c = qsci->standardCommands()->boundTo(Qt::Key_T | Qt::CTRL); c->setKey(0); // Cmd/Ctrl-D is handled by the menu c = qsci->standardCommands()->boundTo(Qt::Key_D | Qt::CTRL); c->setKey(0); // Ctrl-Shift-Z should redo on all platforms c = qsci->standardCommands()->find(QsciCommand::Redo); c->setKey(Qt::Key_Z | Qt::CTRL | Qt::SHIFT); c->setAlternateKey(Qt::Key_Y | Qt::CTRL); scintillaLayout->setContentsMargins(0, 0, 0, 0); scintillaLayout->addWidget(qsci); qsci->indicatorDefine(QsciScintilla::RoundBoxIndicator, errorIndicatorNumber); qsci->indicatorDefine(QsciScintilla::RoundBoxIndicator , findIndicatorNumber); qsci->markerDefine(QsciScintilla::Circle, markerNumber); qsci->setUtf8(true); qsci->setFolding(QsciScintilla::BoxedTreeFoldStyle, 4); this->lexer = new ScadLexer(this); qsci->setLexer(this->lexer); initMargin(); connect(qsci, SIGNAL(textChanged()), this, SIGNAL(contentsChanged())); connect(qsci, SIGNAL(modificationChanged(bool)), this, SIGNAL(modificationChanged(bool))); qsci->installEventFilter(this); }