void MainWindow::createActions() { connect(ui->actionFind, SIGNAL(triggered()), this, SLOT(findDialog())); connect(ui->actionReplace, SIGNAL(triggered()), this, SLOT(findReplaceDialog())); connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about())); connect(ui->actionAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt())); connect(ui->actionFindNext, SIGNAL(triggered()), m_findDialog, SLOT(findNext())); connect(ui->actionFindPrevious, SIGNAL(triggered()), m_findDialog, SLOT(findPrev())); }
CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent){ lineNumberArea = new LineNumberArea(this); findDialog_ = new FindDialog(this); findDialog_->setModal(false); findDialog_->setTextEdit(this); findReplaceDialog_ = new FindReplaceDialog(this); findReplaceDialog_->setModal(false); findReplaceDialog_->setTextEdit(this); qtScriptReservedWords_<<"break"<<"case"<<"catch"<<"continue"<<"debugger"<<"default"<<"delete"<<"do"<<"else"<<"finally"<<\ "for"<<"function"<<"if"<<"in"<<"instanceof"<<"new"<<"return"<<"switch"<<"this"<<"throw"<<"try"<<\ "typeof"<<"var"<<"void"<<"while"<<"with"; syntaxHighlighter_ = new ScriptSyntaxHighlighter(this->document()); s = Global::guiSettings(this); s->beginGroup("CodeEditor"); QFont font = s->value("font",this->font()).value<QFont>(); this->setFont(font); s->endGroup(); findAction = new QAction("Find...",this); connect(findAction, SIGNAL(triggered()), this, SLOT(findDialog())); findAction->setShortcut(tr("Ctrl+F")); addAction(findAction); findReplaceAction = new QAction("Replace...",this); connect(findReplaceAction, SIGNAL(triggered()), this, SLOT(findReplaceDialog())); findReplaceAction->setShortcut(tr("Ctrl+R")); addAction(findReplaceAction); beautifyAction = new QAction("Beautify javascript code",this); connect(beautifyAction, SIGNAL(triggered()), this, SLOT(beautify())); beautifyAction->setShortcut(tr("Ctrl+B")); addAction(beautifyAction); connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int))); connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int))); connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine())); updateLineNumberAreaWidth(0); highlightCurrentLine(); completer_ = new QCompleter(this); completer_->setModel(modelFromStringList(qtScriptReservedWords_)); completer_->setModelSorting(QCompleter::CaseInsensitivelySortedModel); completer_->setCaseSensitivity(Qt::CaseInsensitive); completer_->setWrapAround(false); this->setCompleter(completer_); }