void MainWindow::initMenuEdit() { //connect menu "Edit" Action connect(actionCut, SIGNAL(triggered()), _documentManager, SLOT(cut())); connect(actionCopy, SIGNAL(triggered()), _documentManager, SLOT(copy())); connect(actionPaste, SIGNAL(triggered()), _documentManager, SLOT(paste())); connect(actionUndo, SIGNAL(triggered()), _documentManager, SLOT(undo())); connect(actionRedo, SIGNAL(triggered()), _documentManager, SLOT(redo())); connect(actionSelectAll, SIGNAL(triggered()), _documentManager, SLOT(selectAll())); connect(actionIndent, SIGNAL(triggered()), this, SLOT(increaseIndentation())); connect(actionUnindent, SIGNAL(triggered()), this, SLOT(decreaseIndentation())); connect(actionAutoIndentation, SIGNAL(toggled(bool)), _documentManager, SLOT(setAutoIndentation(bool))); connect(actionIndentationGuides, SIGNAL(toggled(bool)), _documentManager, SLOT(showIndentationGuides(bool))); connect(actionTabsToSpaces, SIGNAL(triggered()), _documentManager, SLOT(tabsToSpaces())); connect(actionSpacesToTabs, SIGNAL(triggered()), _documentManager, SLOT(spacesToTabs())); connect(actionTrimTrailingSpaces, SIGNAL(triggered()), _documentManager, SLOT(trimTrailingSpaces())); connect(actionCompressSpaces, SIGNAL(triggered()), _documentManager, SLOT(compressSpaces())); connect(actionUpperCase, SIGNAL(triggered()), _documentManager, SLOT(convertSelectedTextToUpperCase())); connect(actionLowerCase, SIGNAL(triggered()), _documentManager, SLOT(convertSelectedTextToLowerCase())); connect(actionDuplicateLine, SIGNAL(triggered()), _documentManager, SLOT(duplicateCurrentLine())); connect(actionCopyLine, SIGNAL(triggered()), _documentManager, SLOT(copyCurrentLine())); connect(actionCutLine, SIGNAL(triggered()), _documentManager, SLOT(cutCurrentLine())); connect(actionDeleteLine, SIGNAL(triggered()), _documentManager, SLOT(deleteCurrentLine())); connect(actionMoveLineUp, SIGNAL(triggered()), _documentManager, SLOT(moveCurrentLineUp())); connect(actionMoveLineDown, SIGNAL(triggered()), _documentManager, SLOT(moveCurrentLineDown())); connect(actionDeleteWord, SIGNAL(triggered()), _documentManager, SLOT(deleteCurrentWord())); connect(actionGotoLine, SIGNAL(triggered()), this, SLOT(gotoLine())); connect(actionReadOnly, SIGNAL(triggered(bool)), _documentManager, SLOT(setReadOnly(bool))); connect(actionReindentFile, SIGNAL(triggered()), _documentManager, SLOT(reindentDocument())); connect(actionReindentOpenFiles, SIGNAL(triggered()), _documentManager, SLOT(reindentOpenDocuments())); connect(actionToggleComment, SIGNAL(triggered()), _documentManager, SLOT(toggleComment())); connect(actionToggleBlockComment, SIGNAL(triggered()), _documentManager, SLOT(toggleBlockComment())); connect(actionSwitchSrc, SIGNAL(triggered()), _documentManager, SLOT(switchDocumentSrc())); connect(actionSwitchFile, SIGNAL(triggered()), _documentManager, SLOT(switchFile())); connect(actionSwitchSymbol, SIGNAL(triggered()), this, SLOT(switchSymbol())); connect(menuEdit, SIGNAL(aboutToShow()), this, SLOT(aboutToShowEditMenu())); connect(menuIndentation, SIGNAL(aboutToShow()), this, SLOT(aboutToShowEditIndentationMenu())); }
MRichTextEdit::MRichTextEdit(QWidget *parent) : QWidget(parent) { setupUi(this); m_lastBlockList = 0; f_textedit->setTabStopWidth(40); connect(f_textedit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(slotCurrentCharFormatChanged(QTextCharFormat))); connect(f_textedit, SIGNAL(cursorPositionChanged()), this, SLOT(slotCursorPositionChanged())); m_fontsize_h1 = 18; m_fontsize_h2 = 16; m_fontsize_h3 = 14; m_fontsize_h4 = 12; fontChanged(f_textedit->font()); bgColorChanged(f_textedit->textColor()); // paragraph formatting m_paragraphItems << tr("Standard") << tr("Heading 1") << tr("Heading 2") << tr("Heading 3") << tr("Heading 4") << tr("Monospace"); f_paragraph->addItems(m_paragraphItems); connect(f_paragraph, SIGNAL(activated(int)), this, SLOT(textStyle(int))); // undo & redo f_undo->setShortcut(QKeySequence::Undo); f_redo->setShortcut(QKeySequence::Redo); connect(f_textedit->document(), SIGNAL(undoAvailable(bool)), f_undo, SLOT(setEnabled(bool))); connect(f_textedit->document(), SIGNAL(redoAvailable(bool)), f_redo, SLOT(setEnabled(bool))); f_undo->setEnabled(f_textedit->document()->isUndoAvailable()); f_redo->setEnabled(f_textedit->document()->isRedoAvailable()); connect(f_undo, SIGNAL(clicked()), f_textedit, SLOT(undo())); connect(f_redo, SIGNAL(clicked()), f_textedit, SLOT(redo())); // cut, copy & paste f_cut->setShortcut(QKeySequence::Cut); f_copy->setShortcut(QKeySequence::Copy); f_paste->setShortcut(QKeySequence::Paste); f_cut->setEnabled(false); f_copy->setEnabled(false); connect(f_cut, SIGNAL(clicked()), f_textedit, SLOT(cut())); connect(f_copy, SIGNAL(clicked()), f_textedit, SLOT(copy())); connect(f_paste, SIGNAL(clicked()), f_textedit, SLOT(paste())); connect(f_textedit, SIGNAL(copyAvailable(bool)), f_cut, SLOT(setEnabled(bool))); connect(f_textedit, SIGNAL(copyAvailable(bool)), f_copy, SLOT(setEnabled(bool))); #ifndef QT_NO_CLIPBOARD connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(slotClipboardDataChanged())); #endif // link f_link->setShortcut(Qt::CTRL + Qt::Key_L); connect(f_link, SIGNAL(clicked(bool)), this, SLOT(textLink(bool))); // bold, italic & underline f_bold->setShortcut(Qt::CTRL + Qt::Key_B); f_italic->setShortcut(Qt::CTRL + Qt::Key_I); f_underline->setShortcut(Qt::CTRL + Qt::Key_U); connect(f_bold, SIGNAL(clicked()), this, SLOT(textBold())); connect(f_italic, SIGNAL(clicked()), this, SLOT(textItalic())); connect(f_underline, SIGNAL(clicked()), this, SLOT(textUnderline())); connect(f_strikeout, SIGNAL(clicked()), this, SLOT(textStrikeout())); // lists f_list_bullet->setShortcut(Qt::CTRL + Qt::Key_Minus); f_list_ordered->setShortcut(Qt::CTRL + Qt::Key_Equal); connect(f_list_bullet, SIGNAL(clicked(bool)), this, SLOT(listBullet(bool))); connect(f_list_ordered, SIGNAL(clicked(bool)), this, SLOT(listOrdered(bool))); // indentation f_indent_dec->setShortcut(Qt::CTRL + Qt::Key_Comma); f_indent_inc->setShortcut(Qt::CTRL + Qt::Key_Period); connect(f_indent_inc, SIGNAL(clicked()), this, SLOT(increaseIndentation())); connect(f_indent_dec, SIGNAL(clicked()), this, SLOT(decreaseIndentation())); // font size QFontDatabase db; foreach(int size, db.standardSizes()) { f_fontsize->addItem(QString::number(size)); } connect(f_fontsize, SIGNAL(activated(QString)), this, SLOT(textSize(QString))); f_fontsize->setCurrentIndex(f_fontsize->findText(QString::number(QApplication::font().pointSize()))); // text background color QPixmap pix(16, 16); pix.fill(QApplication::palette().background().color()); f_bgcolor->setIcon(pix); connect(f_bgcolor, SIGNAL(clicked()), this, SLOT(textBgColor())); // images connect(f_image, SIGNAL(clicked()), this, SLOT(insertImage())); }