bool TextEdit::qt_invoke( int _id, QUObject* _o ) { switch ( _id - staticMetaObject()->slotOffset() ) { case 0: fileNew(); break; case 1: fileOpen(); break; case 2: fileSave(); break; case 3: fileSaveAs(); break; case 4: filePrint(); break; case 5: fileClose(); break; case 6: fileExit(); break; case 7: editUndo(); break; case 8: editRedo(); break; case 9: editCut(); break; case 10: editCopy(); break; case 11: editPaste(); break; case 12: textBold(); break; case 13: textUnderline(); break; case 14: textItalic(); break; case 15: textFamily((const QString&)static_QUType_QString.get(_o+1)); break; case 16: textSize((const QString&)static_QUType_QString.get(_o+1)); break; case 17: textColor(); break; case 18: textAlign((QAction*)static_QUType_ptr.get(_o+1)); break; case 19: fontChanged((const QFont&)*((const QFont*)static_QUType_ptr.get(_o+1))); break; case 20: colorChanged((const QColor&)*((const QColor*)static_QUType_ptr.get(_o+1))); break; case 21: alignmentChanged((int)static_QUType_int.get(_o+1)); break; case 22: editorChanged((QWidget*)static_QUType_ptr.get(_o+1)); break; default: return QMainWindow::qt_invoke( _id, _o ); } return TRUE; }
void EditorWidget::on_edit_text_align(QAction *action) { if (m_initialPag == PlainTextIndex) { const QString str_select = editor_plain_text->textCursor().selectedText(); QString txt_align = ""; if (action == m_align_center_action) txt_align = " align=\"center\""; else if (action == m_align_right_action) txt_align = " align=\"right\""; else if (action == m_align_justify_action) txt_align = " align=\"justify\""; if (!str_select.isEmpty()) editor_plain_text->textCursor().insertText("<p"+ txt_align +">"+ str_select +"</p>"); } else { if (action == m_align_center_action) editor_rich_text->setAlignment(Qt::AlignHCenter); else if (action == m_align_right_action) editor_rich_text->setAlignment(Qt::AlignRight | Qt::AlignAbsolute); else if (action == m_align_justify_action) editor_rich_text->setAlignment(Qt::AlignJustify); else editor_rich_text->setAlignment(Qt::AlignLeft | Qt::AlignAbsolute); alignmentChanged(editor_rich_text->alignment()); } }
void GridLayoutAttached::setAlignment(Qt::Alignment a) { if (m_alignment != a) { m_alignment = a; emit alignmentChanged(reinterpret_cast<QGraphicsLayoutItem*>(parent()), m_alignment); } }
void RichTextEdit::cursorPositionChanged() { alignmentChanged(textedit->alignment()); int line = textedit->textCursor().block().blockNumber(); int col = textedit->textCursor().position() - textedit->textCursor().block().position(); Controller::create()->getStatusBar()->setCursorPosition(line, col); }
void TextObjectAlignmentDockWidget::emitAlignmentChanged() { const TextObject::HorizontalAlignment horz_array[] = {TextObject::AlignLeft, TextObject::AlignHCenter, TextObject::AlignRight}; const TextObject::VerticalAlignment vert_array[] = {TextObject::AlignTop, TextObject::AlignVCenter, TextObject::AlignBaseline, TextObject::AlignBottom}; emit(alignmentChanged((int)horz_array[horz_index], (int)vert_array[vert_index])); }
void Stack::addDocument(Document* document) { document->setSceneList(m_scenes); connect(document, SIGNAL(alert(Alert*)), m_alerts, SLOT(addAlert(Alert*))); connect(document, SIGNAL(alignmentChanged()), this, SIGNAL(updateFormatAlignmentActions())); connect(document, SIGNAL(changedName()), this, SIGNAL(updateFormatActions())); connect(document, SIGNAL(footerVisible(bool)), this, SLOT(setFooterVisible(bool))); connect(document, SIGNAL(headerVisible(bool)), this, SLOT(setHeaderVisible(bool))); connect(document, SIGNAL(scenesVisible(bool)), this, SLOT(setScenesVisible(bool))); connect(document->text(), SIGNAL(copyAvailable(bool)), this, SIGNAL(copyAvailable(bool))); connect(document->text(), SIGNAL(redoAvailable(bool)), this, SIGNAL(redoAvailable(bool))); connect(document->text(), SIGNAL(undoAvailable(bool)), this, SIGNAL(undoAvailable(bool))); connect(document->text(), SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SIGNAL(updateFormatActions())); m_documents.append(document); m_contents->addWidget(document); m_contents->setCurrentWidget(document); QAction* action = new QAction(this); action->setCheckable(true); action->setActionGroup(m_menu_group); m_document_actions.push_back(action); m_menu->addAction(action); updateMenuIndexes(); document->loadTheme(m_theme); document->text()->setFixedSize(m_foreground_size); emit documentAdded(document); emit updateFormatActions(); }
XYZTextEditor::XYZTextEditor(QWidget *parent) : QWidget(parent), m_ui(new Ui::XYZTextEditor) { m_ui->setupUi(this); setupTextActions(); fontChanged(m_ui->textEdit->font()); alignmentChanged(m_ui->textEdit->alignment()); m_ui->textEdit->setFocus(); textEdit = m_ui->textEdit; QButtonGroup *btnGroup = new QButtonGroup(this); btnGroup->addButton(m_ui->btnAlignCenter); btnGroup->addButton(m_ui->btnAlignJustify); btnGroup->addButton(m_ui->btnAlignLeft); btnGroup->addButton(m_ui->btnAlignRight); QObject::connect(m_ui->textEdit, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)), this, SLOT(currentCharFormatChanged(const QTextCharFormat &))); QObject::connect(m_ui->textEdit, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged())); QObject::connect(m_ui->btnCut, SIGNAL(clicked()), m_ui->textEdit, SLOT(cut())); QObject::connect(m_ui->btnCopy, SIGNAL(clicked()), m_ui->textEdit, SLOT(copy())); QObject::connect(m_ui->btnPaste, SIGNAL(clicked()), m_ui->textEdit, SLOT(paste())); QObject::connect(m_ui->btnTextDirection, SIGNAL(clicked()), this, SLOT(textDirection())); // m_ui->textEdit->document()->defaultTextOption().setTextDirection(QApplication::layoutDirection()); // QTextCursor cursor = m_ui->textEdit->textCursor(); // QTextBlockFormat blockFmt = cursor.blockFormat(); // if (QApplication::layoutDirection() == Qt::RightToLeft) { // blockFmt.setLayoutDirection(Qt::RightToLeft); // } else { // blockFmt.setLayoutDirection(Qt::LeftToRight); // } // cursor.setBlockFormat(blockFmt); // qDebug()<<m_ui->textEdit->document()->defaultTextOption().textDirection(); // qDebug()<<m_ui->textEdit->toHtml(); }
void EditorWidget::on_show_source(bool checked) { m_initialPag = checked ? PlainTextIndex : RichTextIndex; m_bold_action->setCheckable(!checked); m_italic_action->setCheckable(!checked); m_underline_action->setCheckable(!checked); m_align_left_action->setCheckable(!checked); m_align_center_action->setCheckable(!checked); m_align_right_action->setCheckable(!checked); m_align_justify_action->setCheckable(!checked); m_valign_sup_action->setCheckable(!checked); m_valign_sub_action->setCheckable(!checked); m_link_action->setCheckable(!checked); m_simplify_richtext_action->setVisible(!checked); if (m_initialPag == PlainTextIndex) editor_plain_text->setFocus(); else { editor_rich_text->setFocus(); if (m_align_checked == "center") m_align_center_action->setChecked(checked); else if (m_align_checked == "right") m_align_right_action->setChecked(checked); else if (m_align_checked == "justify") m_align_justify_action->setChecked(checked); else m_align_left_action->setChecked(checked); alignmentChanged(editor_rich_text->alignment()); } pag_stacked->setCurrentIndex(checked ? 1 : 0); }
void Document::cursorPositionChanged() { emit indentChanged(m_text->textCursor().blockFormat().indent()); emit alignmentChanged(); if (QApplication::mouseButtons() == Qt::NoButton) { centerCursor(); } }
void TextEdit::editorChanged( QWidget * ) { if ( !currentEditor() ) return; fontChanged( currentEditor()->font() ); colorChanged( currentEditor()->color() ); alignmentChanged( currentEditor()->alignment() ); }
void XYZTextEditor::cursorPositionChanged() { alignmentChanged(m_ui->textEdit->alignment()); QTextBlockFormat blockFmt = m_ui->textEdit->textCursor().blockFormat(); if (blockFmt.layoutDirection() == Qt::RightToLeft) m_ui->btnTextDirection->setChecked(true); else m_ui->btnTextDirection->setChecked(false); }
void MailEditorMainWindow::onCursorPositionChanged() { /** When cursor pos. changes update alignment & text formatting controls according to format of text under cursor. */ alignmentChanged(ui->messageEdit->alignment()); QTextCursor cursor = ui->messageEdit->textCursor(); fontChanged(cursor.charFormat().font()); }
void DocumentHandler::setAlignment(Qt::Alignment a) { QTextBlockFormat fmt; fmt.setAlignment((Qt::Alignment) a); QTextCursor cursor = QTextCursor(m_doc); cursor.setPosition(m_selectionStart, QTextCursor::MoveAnchor); cursor.setPosition(m_selectionEnd, QTextCursor::KeepAnchor); cursor.mergeBlockFormat(fmt); emit alignmentChanged(); }
void DocumentHandler::reset() { emit fontFamilyChanged(); emit alignmentChanged(); emit boldChanged(); emit italicChanged(); emit underlineChanged(); emit fontSizeChanged(); emit textColorChanged(); }
TextEdit::TextEdit(QWidget *parent) : QWidget(parent), layout(parent), toolBar1(parent), toolBar2(parent) { setupEditActions(); setupTextActions(); { setLayout(&layout); layout.addItem(&toolBar1); layout.addItem(&toolBar2); } textEdit = new QTextEdit(this); connect(textEdit, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)), this, SLOT(currentCharFormatChanged(const QTextCharFormat &))); connect(textEdit, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged())); layout.addWidget(textEdit); textEdit->setFocus(); fontChanged(textEdit->font()); colorChanged(textEdit->textColor()); alignmentChanged(textEdit->alignment()); connect(textEdit->document(), SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool))); connect(textEdit->document(), SIGNAL(undoAvailable(bool)), actionUndo, SLOT(setEnabled(bool))); connect(textEdit->document(), SIGNAL(redoAvailable(bool)), actionRedo, SLOT(setEnabled(bool))); setWindowModified(textEdit->document()->isModified()); actionUndo->setEnabled(textEdit->document()->isUndoAvailable()); actionRedo->setEnabled(textEdit->document()->isRedoAvailable()); connect(actionUndo, SIGNAL(triggered()), textEdit, SLOT(undo())); connect(actionRedo, SIGNAL(triggered()), textEdit, SLOT(redo())); actionCut->setEnabled(false); actionCopy->setEnabled(false); connect(actionCut, SIGNAL(triggered()), textEdit, SLOT(cut())); connect(actionCopy, SIGNAL(triggered()), textEdit, SLOT(copy())); connect(actionPaste, SIGNAL(triggered()), textEdit, SLOT(paste())); connect(textEdit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool))); connect(textEdit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool))); connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); QString initialFile = ":/example.html"; const QStringList args = QCoreApplication::arguments(); if (args.count() == 2) initialFile = args.at(1); }
QTM_BEGIN_NAMESPACE QGeoTiledMapTextObjectInfo::QGeoTiledMapTextObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject) : QGeoTiledMapObjectInfo(mapData, mapObject) { text = static_cast<QGeoMapTextObject*>(mapObject); connect(text, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString))); connect(text, SIGNAL(fontChanged(QFont)), this, SLOT(fontChanged(QFont))); connect(text, SIGNAL(penChanged(QPen)), this, SLOT(penChanged(QPen))); connect(text, SIGNAL(brushChanged(QBrush)), this, SLOT(brushChanged(QBrush))); connect(text, SIGNAL(offsetChanged(QPoint)), this, SLOT(offsetChanged(QPoint))); connect(text, SIGNAL(alignmentChanged(Qt::Alignment)), this, SLOT(alignmentChanged(Qt::Alignment))); textItem = new QGraphicsSimpleTextItem(); graphicsItem = textItem; penChanged(text->pen()); brushChanged(text->brush()); originChanged(text->origin()); fontChanged(text->font()); textChanged(text->text()); }
void MailEditorMainWindow::onTextAlignTriggerred(QAction *a) { QTextEdit* edit = ui->messageEdit; if (a == ui->actionLeft) edit->setAlignment(Qt::AlignLeft | Qt::AlignAbsolute); else if (a == ui->actionCenter) edit->setAlignment(Qt::AlignHCenter); else if (a == ui->actionRight) edit->setAlignment(Qt::AlignRight | Qt::AlignAbsolute); else if (a == ui->actionJustify) edit->setAlignment(Qt::AlignJustify); alignmentChanged(edit->alignment()); }
void DeclarativeBoxLayoutAttached::setAlignment(Qt::Alignment alignment) { if (alignment == d->alignment) return; d->alignment = alignment; emit alignmentChanged(alignment); if (d->parentLayout) { if (d->widget) d->parentLayout->setAlignment(d->widget, d->alignment); if (d->layout) d->parentLayout->setAlignment(d->layout, d->alignment); } }
void Stack::addDocument(Document* document) { document->setSceneList(m_scenes); connect(document, SIGNAL(alert(Alert*)), m_alerts, SLOT(addAlert(Alert*))); connect(document, SIGNAL(alignmentChanged()), this, SIGNAL(updateFormatAlignmentActions())); connect(document, SIGNAL(changedName()), this, SIGNAL(updateFormatActions())); connect(document, SIGNAL(changedName()), this, SLOT(updateMapping())); connect(document, SIGNAL(footerVisible(bool)), this, SLOT(setFooterVisible(bool))); connect(document, SIGNAL(headerVisible(bool)), this, SLOT(setHeaderVisible(bool))); connect(document, SIGNAL(scenesVisible(bool)), this, SLOT(setScenesVisible(bool))); connect(document->text(), SIGNAL(copyAvailable(bool)), this, SIGNAL(copyAvailable(bool))); connect(document->text(), SIGNAL(redoAvailable(bool)), this, SIGNAL(redoAvailable(bool))); connect(document->text(), SIGNAL(undoAvailable(bool)), this, SIGNAL(undoAvailable(bool))); connect(document->text(), SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SIGNAL(updateFormatActions())); m_documents.append(document); m_contents->addWidget(document); m_contents->setCurrentWidget(document); updateMapping(); emit documentAdded(document); emit updateFormatActions(); }
void RazorPanelPlugin::setAlignment(Alignment alignment) { Q_D(RazorPanelPlugin); d->setAlignment(alignment); emit alignmentChanged(); }
void EditorWidget::cursorPositionChanged() { if (m_initialPag == RichTextIndex) alignmentChanged(editor_rich_text->alignment()); }
TextEdit::TextEdit(QWidget *parent) : QMainWindow(parent) { setToolButtonStyle(Qt::ToolButtonFollowStyle); setupFileActions(); setupEditActions(); setupTextActions(); { QMenu *helpMenu = new QMenu(tr("Help"), this); menuBar()->addMenu(helpMenu); helpMenu->addAction(tr("About"), this, SLOT(about())); helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt())); } textEdit = new QTextEdit(this); connect(textEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(currentCharFormatChanged(QTextCharFormat))); connect(textEdit, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged())); setCentralWidget(textEdit); textEdit->setFocus(); setCurrentFileName(QString()); fontChanged(textEdit->font()); colorChanged(textEdit->textColor()); alignmentChanged(textEdit->alignment()); connect(textEdit->document(), SIGNAL(modificationChanged(bool)), actionSave, SLOT(setEnabled(bool))); connect(textEdit->document(), SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool))); connect(textEdit->document(), SIGNAL(undoAvailable(bool)), actionUndo, SLOT(setEnabled(bool))); connect(textEdit->document(), SIGNAL(redoAvailable(bool)), actionRedo, SLOT(setEnabled(bool))); setWindowModified(textEdit->document()->isModified()); actionSave->setEnabled(textEdit->document()->isModified()); actionUndo->setEnabled(textEdit->document()->isUndoAvailable()); actionRedo->setEnabled(textEdit->document()->isRedoAvailable()); connect(actionUndo, SIGNAL(triggered()), textEdit, SLOT(undo())); connect(actionRedo, SIGNAL(triggered()), textEdit, SLOT(redo())); actionCut->setEnabled(false); actionCopy->setEnabled(false); connect(actionCut, SIGNAL(triggered()), textEdit, SLOT(cut())); connect(actionCopy, SIGNAL(triggered()), textEdit, SLOT(copy())); connect(actionPaste, SIGNAL(triggered()), textEdit, SLOT(paste())); connect(textEdit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool))); connect(textEdit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool))); #ifndef QT_NO_CLIPBOARD connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); #endif QString initialFile = "/example.html"; const QStringList args = QCoreApplication::arguments(); if (args.count() == 2) initialFile = args.at(1); if (!load(initialFile)) fileNew(); }
void TextEdit::cursorPositionChanged() { alignmentChanged(textEdit->alignment()); }
void Document::cursorPositionChanged() { emit indentChanged(m_text->textCursor().blockFormat().indent()); emit alignmentChanged(); emit headingsChanged(); }
MailEditorMainWindow::MailEditorMainWindow(ATopLevelWindowsContainer* parent, AddressBookModel& abModel, IMailProcessor& mailProcessor, bool editMode) : ATopLevelWindow(parent), ui(new Ui::MailEditorWindow()), ABModel(abModel), MailProcessor(mailProcessor), FontCombo(nullptr), EditMode(editMode) { ui->setupUi(this); /** Disable these toolbars by default. They should be showed up on demand, when given action will be trigerred. */ ui->fileAttachementToolBar->hide(); ui->moneyAttachementToolBar->hide(); ui->editToolBar->hide(); ui->adjustToolbar->hide(); ui->formatToolBar->hide(); MoneyAttachement = new TMoneyAttachementWidget(ui->moneyAttachementToolBar); ui->moneyAttachementToolBar->addWidget(MoneyAttachement); FileAttachment = new TFileAttachmentWidget(ui->fileAttachementToolBar, editMode); ui->fileAttachementToolBar->addWidget(FileAttachment); MailFields = new MailFieldsWidget(*this, *ui->actionSend, abModel, editMode); /// Initially only basic mail fields (To: and Subject:) should be visible MailFields->showCcControls(false); MailFields->showBccControls(false); ui->mailFieldsToolBar->addWidget(MailFields); connect(MailFields, SIGNAL(subjectChanged(QString)), this, SLOT(onSubjectChanged(QString))); connect(MailFields, SIGNAL(recipientListChanged()), this, SLOT(onRecipientListChanged())); connect(FileAttachment, SIGNAL(attachmentListChanged()), this, SLOT(onAttachmentListChanged())); if(editMode) { /** Supplement definition of mailFieldSelectorToolbar since Qt Creator doesn't support putting into its context dedicated controls (like preconfigured toolbutton). Setup local menu for 'actionMailFields' toolButton (used to enable/disable additional mail field selection). */ QMenu* mailFieldsMenu = new QMenu(this); mailFieldsMenu->addAction(ui->actionFrom); mailFieldsMenu->addAction(ui->actionCC); mailFieldsMenu->addAction(ui->actionBCC); /// Update state of sub-menu commands. ui->actionBCC->setChecked(MailFields->isFieldVisible(MailFieldsWidget::BCC_FIELDS)); ui->actionCC->setChecked(MailFields->isFieldVisible(MailFieldsWidget::CC_FIELD)); ui->actionFrom->setChecked(MailFields->isFieldVisible(MailFieldsWidget::FROM_FIELD)); ui->actionMailFields->setMenu(mailFieldsMenu); ui->mainToolBar->insertAction(ui->actionShowFormatOptions, ui->actionMailFields); } setupEditorCommands(); ui->messageEdit->setFocus(); fontChanged(ui->messageEdit->font()); colorChanged(ui->messageEdit->textColor()); alignmentChanged(ui->messageEdit->alignment()); QString subject = MailFields->getSubject(); onSubjectChanged(subject); /// Clear modified flag ui->messageEdit->document()->setModified(false); setWindowModified(ui->messageEdit->document()->isModified()); ui->actionSave->setEnabled(ui->messageEdit->document()->isModified()); ui->actionUndo->setEnabled(ui->messageEdit->document()->isUndoAvailable()); ui->actionRedo->setEnabled(ui->messageEdit->document()->isRedoAvailable()); /// Setup command update ui related to 'save' option activity control and window modify marker. connect(ui->messageEdit->document(), SIGNAL(modificationChanged(bool)), ui->actionSave, SLOT(setEnabled(bool))); connect(ui->messageEdit->document(), SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool))); connect(ui->messageEdit, SIGNAL(addAttachments(QStringList)), this, SLOT(onAddAttachments(QStringList))); #ifndef QT_NO_CLIPBOARD connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(onClipboardDataChanged())); #endif toggleReadOnlyMode(); }
void GraphicTextDialog::cursorPositionChanged() { alignmentChanged(textEdit->alignment()); }
void CreateBlogMsg::cursorPositionChanged() { alignmentChanged(ui.msgEdit->alignment()); }
/** Constructor */ CreateBlogMsg::CreateBlogMsg(std::string cId ,QWidget* parent, Qt::WFlags flags) : mBlogId(cId), QMainWindow (parent, flags) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); setAttribute ( Qt::WA_DeleteOnClose, true ); setupFileActions(); setupEditActions(); setupViewActions(); setupInsertActions(); setupParagraphActions(); setAcceptDrops(true); setStartupText(); newBlogMsg(); ui.toolBar_2->addAction(ui.actionIncreasefontsize); ui.toolBar_2->addAction(ui.actionDecreasefontsize); ui.toolBar_2->addAction(ui.actionBlockquoute); ui.toolBar_2->addAction(ui.actionOrderedlist); ui.toolBar_2->addAction(ui.actionUnorderedlist); ui.toolBar_2->addAction(ui.actionBlockquoute); ui.toolBar_2->addAction(ui.actionCode); ui.toolBar_2->addAction(ui.actionsplitPost); setupTextActions(); connect(ui.actionPublish, SIGNAL(triggered()), this, SLOT(sendMsg())); connect(ui.actionNew, SIGNAL(triggered()), this, SLOT (fileNew())); connect(ui.actionIncreasefontsize, SIGNAL (triggered()), this, SLOT (fontSizeIncrease())); connect(ui.actionDecreasefontsize, SIGNAL (triggered()), this, SLOT (fontSizeDecrease())); connect(ui.actionBlockquoute, SIGNAL (triggered()), this, SLOT (blockQuote())); connect(ui.actionCode, SIGNAL (triggered()), this, SLOT (toggleCode())); connect(ui.actionsplitPost, SIGNAL (triggered()), this, SLOT (addPostSplitter())); connect(ui.actionOrderedlist, SIGNAL (triggered()), this, SLOT (addOrderedList())); connect(ui.actionUnorderedlist, SIGNAL (triggered()), this, SLOT (addUnorderedList())); //connect(webView, SIGNAL(loadFinished(bool)),this, SLOT(updateTextEdit())); connect( ui.msgEdit, SIGNAL( textChanged(const QString &)), this, SLOT(updateTextEdit())); connect( ui.msgEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(currentCharFormatChanged(QTextCharFormat))); connect( ui.msgEdit, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged())); QPalette palette = QApplication::palette(); codeBackground = palette.color( QPalette::Active, QPalette::Midlight ); fontChanged(ui.msgEdit->font()); colorChanged(ui.msgEdit->textColor()); alignmentChanged(ui.msgEdit->alignment()); connect( ui.msgEdit->document(), SIGNAL(modificationChanged(bool)), actionSave, SLOT(setEnabled(bool))); connect( ui.msgEdit->document(), SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool))); connect( ui.msgEdit->document(), SIGNAL(undoAvailable(bool)), actionUndo, SLOT(setEnabled(bool))); connect( ui.msgEdit->document(), SIGNAL(undoAvailable(bool)), ui.actionUndo, SLOT(setEnabled(bool))); connect( ui.msgEdit->document(), SIGNAL(redoAvailable(bool)), actionRedo, SLOT(setEnabled(bool))); setWindowModified( ui.msgEdit->document()->isModified()); actionSave->setEnabled( ui.msgEdit->document()->isModified()); actionUndo->setEnabled( ui.msgEdit->document()->isUndoAvailable()); ui.actionUndo->setEnabled( ui.msgEdit->document()->isUndoAvailable()); actionRedo->setEnabled( ui.msgEdit->document()->isRedoAvailable()); connect(actionUndo, SIGNAL(triggered()), ui.msgEdit, SLOT(undo())); connect(ui.actionUndo, SIGNAL(triggered()), ui.msgEdit, SLOT(undo())); connect(actionRedo, SIGNAL(triggered()), ui.msgEdit, SLOT(redo())); actionCut->setEnabled(false); actionCopy->setEnabled(false); connect(actionCut, SIGNAL(triggered()), ui.msgEdit, SLOT(cut())); connect(actionCopy, SIGNAL(triggered()), ui.msgEdit, SLOT(copy())); connect(actionPaste, SIGNAL(triggered()), ui.msgEdit, SLOT(paste())); connect(ui.msgEdit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool))); connect(ui.msgEdit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool))); #ifndef QT_NO_CLIPBOARD connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); #endif //defaultCharFormat defaultCharFormat = ui.msgEdit->currentCharFormat(); const QFont defaultFont = ui.msgEdit->document()->defaultFont(); defaultCharFormat.setFont( defaultFont ); defaultCharFormat.setForeground( ui.msgEdit->currentCharFormat().foreground() ); defaultCharFormat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( 0 ) ); defaultCharFormat.setBackground( palette.color( QPalette::Active, QPalette::Base ) ); defaultCharFormat.setProperty( TextFormat::HasCodeStyle, QVariant( false ) ); //defaultBlockFormat defaultBlockFormat = ui.msgEdit->textCursor().blockFormat(); }
GraphicTextDialog::GraphicTextDialog(GraphicText *text, Qucs::UndoOption opt, QWidget *parent) : QDialog(parent), textItem(text), undoOption(opt) { mainLayout = new QVBoxLayout(this); mainLayout->setSpacing(-1); toolBarLayout = new QHBoxLayout; mainLayout->addItem(toolBarLayout); toolBar = new QToolBar(this); toolBar->setIconSize(QSize(16, 16)); toolBarLayout->addWidget(toolBar); toolBarLayout->setSpacing(-1); toolBarLayout->setContentsMargins(0,0,0,0); setupEditActions(); setupTextActions(); textEdit = new QTextEdit; if(textItem) { QString latex = Qucs::unicodeToLatex(textItem->richText()); textEdit->setHtml(latex); } mainLayout->addWidget(textEdit); connect(textEdit, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)), SLOT(currentCharFormatChanged(const QTextCharFormat &))); connect(textEdit, SIGNAL(cursorPositionChanged()), SLOT(cursorPositionChanged())); textEdit->setFocus(); fontChanged(textEdit->font()); colorChanged(textEdit->textColor()); alignmentChanged(textEdit->alignment()); subSuperAlignmentChanged(textEdit->currentCharFormat().verticalAlignment()); connect(textEdit->document(), SIGNAL(undoAvailable(bool)), actionUndo, SLOT(setEnabled(bool))); connect(textEdit->document(), SIGNAL(redoAvailable(bool)), actionRedo, SLOT(setEnabled(bool))); actionUndo->setEnabled(textEdit->document()->isUndoAvailable()); actionRedo->setEnabled(textEdit->document()->isRedoAvailable()); connect(actionUndo, SIGNAL(triggered()), textEdit, SLOT(undo())); connect(actionRedo, SIGNAL(triggered()), textEdit, SLOT(redo())); actionCut->setEnabled(false); actionCopy->setEnabled(false); connect(actionCut, SIGNAL(triggered()), textEdit, SLOT(cut())); connect(actionCopy, SIGNAL(triggered()), textEdit, SLOT(copy())); connect(actionPaste, SIGNAL(triggered()), textEdit, SLOT(paste())); connect(textEdit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool))); connect(textEdit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool))); connect(QApplication::clipboard(), SIGNAL(dataChanged()), SLOT(clipboardDataChanged())); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); buttonBox->button(QDialogButtonBox::Ok)->setText(tr("&OK")); connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); mainLayout->addWidget(buttonBox); adjustSize(); }
EditorWidget::EditorWidget(QString theme, QWidget *parent) : QWidget(parent), editor_rich_text(new EditorRichText(this)), editor_plain_text(new CodeEditor(this, CodeEditor::Html)), pag_stacked(new QStackedWidget(this)), m_state(Clean), m_initialPag(RichTextIndex) { m_theme = theme; m_color = editor_rich_text->textColor(); connect(editor_plain_text, SIGNAL(textChanged()), this, SLOT(plainTextChanged())); connect(editor_rich_text, SIGNAL(textChanged()), this, SLOT(richTextChanged())); connect(editor_rich_text, SIGNAL(simplifyRichTextChanged(bool)), this, SLOT(richTextChanged())); connect(editor_rich_text, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(currentCharFormatChanged(QTextCharFormat))); connect(editor_rich_text, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged())); list_smile = new QListWidget(this); list_smile->setMaximumSize(QSize(155, 16777215)); list_smile->setMovement(QListView::Static); list_smile->setResizeMode(QListView::Adjust); list_smile->setViewMode(QListView::IconMode); connect(list_smile, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(list_smile_itemDoubleClicked(QListWidgetItem*))); toolbar_find_replace = new QWidget(this); toolbar_find_replace->setMinimumSize(QSize(0, 30)); QVBoxLayout *main_layout = new QVBoxLayout(this); main_layout->setContentsMargins(0, 0, 0, 0); main_layout->setSpacing(4); QHBoxLayout *toolbar_layout = new QHBoxLayout(); toolbar_layout->setContentsMargins(0, 0, 0, 0); toolbar_layout->setSpacing(10); QToolBar *toolbar_edit = new QToolBar(this); toolbar_edit->setMinimumSize(QSize(0, 30)); toolbar_edit->setIconSize(QSize(20, 20)); toolbar_edit->setStyleSheet("QToolBar{border:0px;}"); // Save Pdf /* m_pdf_action = createAction(QIcon(m_theme +"img16/pdf.png"), tr("Exportar a PDF") +"...", false, toolbar_edit); m_pdf_action->setPriority(QAction::LowPriority); m_pdf_action->setShortcut(Qt::CTRL + Qt::Key_D); connect(m_pdf_action, SIGNAL(triggered()), this, SLOT(on_edit_export_pdf())); toolbar_edit->addAction(m_pdf_action); toolbar_edit->addSeparator();*/ // combos font and size QWidget *toolbar_font_input = new QWidget(this); QHBoxLayout *combofont_layout = new QHBoxLayout(toolbar_font_input); combofont_layout->setContentsMargins(0, 0, 2, 0); m_font_input = new QFontComboBox(toolbar_edit); connect(m_font_input, SIGNAL(activated(QString)), this, SLOT(on_edit_font(QString))); combofont_layout->addWidget(m_font_input); m_font_size_input = new QComboBox(toolbar_edit); QFontDatabase font_db; foreach(int size, font_db.standardSizes()) m_font_size_input->addItem(QString::number(size)); connect(m_font_size_input, SIGNAL(activated(QString)), this, SLOT(on_edit_font_size(QString))); combofont_layout->addWidget(m_font_size_input); // combofont_layout->setStretch(0, 1); toolbar_edit->addWidget(toolbar_font_input); toolbar_edit->addSeparator(); // cut, copy, paste m_cut_action = createAction(QIcon(m_theme +"img16/edit_cut.png"), tr("Cortar"), false, toolbar_edit); m_cut_action->setPriority(QAction::LowPriority); m_cut_action->setShortcut(QKeySequence::Cut); connect(m_cut_action, SIGNAL(triggered()), this, SLOT(on_edit_cut())); toolbar_edit->addAction(m_cut_action); m_copy_action = createAction(QIcon(m_theme +"img16/edit_copy.png"), tr("Copiar"), false, toolbar_edit); m_copy_action->setPriority(QAction::LowPriority); m_copy_action->setShortcut(QKeySequence::Copy); connect(m_copy_action, SIGNAL(triggered()), this, SLOT(on_edit_copy())); toolbar_edit->addAction(m_copy_action); m_paste_action = createAction(QIcon(m_theme +"img16/edit_paste.png"), tr("Pegar"), false, toolbar_edit); m_paste_action->setPriority(QAction::LowPriority); m_paste_action->setShortcut(QKeySequence::Paste); connect(m_paste_action, SIGNAL(triggered()), this, SLOT(on_edit_paste())); toolbar_edit->addAction(m_paste_action); toolbar_edit->addSeparator(); // undo, redo m_undo_action = createAction(QIcon(m_theme +"img16/edit_deshacer.png"), tr("Deshacer"), false, toolbar_edit); m_undo_action->setShortcut(QKeySequence::Undo); connect(m_undo_action, SIGNAL(triggered()), this, SLOT(on_edit_undo())); toolbar_edit->addAction(m_undo_action); m_redo_action = createAction(QIcon(m_theme +"img16/edit_rehacer.png"), tr("Rehacer"), false, toolbar_edit); m_redo_action->setPriority(QAction::LowPriority); m_redo_action->setShortcut(QKeySequence::Redo); connect(m_redo_action, SIGNAL(triggered()), this, SLOT(on_edit_redo())); toolbar_edit->addAction(m_redo_action); toolbar_edit->addSeparator(); // bold, italic, underline, , m_bold_action = createAction(QIcon(m_theme +"img16/edit_negrita.png"), tr("Negrita"), true, toolbar_edit); m_bold_action->setPriority(QAction::LowPriority); m_bold_action->setShortcut(Qt::CTRL + Qt::Key_B); connect(m_bold_action, SIGNAL(triggered()), this, SLOT(on_edit_bold())); toolbar_edit->addAction(m_bold_action); m_italic_action = createAction(QIcon(m_theme +"img16/edit_cursiva.png"), tr("Cursiva"), true, toolbar_edit); m_italic_action->setPriority(QAction::LowPriority); m_italic_action->setShortcut(Qt::CTRL + Qt::Key_I); connect(m_italic_action, SIGNAL(triggered()), this, SLOT(on_edit_italic())); toolbar_edit->addAction(m_italic_action); m_underline_action = createAction(QIcon(m_theme +"img16/edit_subrayada.png"), tr("Subrayado"), true, toolbar_edit); m_underline_action->setPriority(QAction::LowPriority); m_underline_action->setShortcut(Qt::CTRL + Qt::Key_U); connect(m_underline_action, SIGNAL(triggered()), this, SLOT(on_edit_underline())); toolbar_edit->addAction(m_underline_action); toolbar_edit->addSeparator(); // align: left, center, right, justify QActionGroup *grp = new QActionGroup(toolbar_edit); connect(grp, SIGNAL(triggered(QAction*)), this, SLOT(on_edit_text_align(QAction*))); if (QApplication::isLeftToRight()) { m_align_left_action = createAction(QIcon(m_theme +"img16/edit_text_left.png"), tr("Izquierdo"), true, grp); m_align_center_action = createAction(QIcon(m_theme +"img16/edit_text_center.png"), tr("Centro"), true, grp); m_align_right_action = createAction(QIcon(m_theme +"img16/edit_text_right.png"), tr("Derecho"), true, grp); } else { m_align_right_action = createAction(QIcon(m_theme +"img16/edit_text_right.png"), tr("Derecho"), true, grp); m_align_center_action = createAction(QIcon(m_theme +"img16/edit_text_center.png"), tr("Centro"), true, grp); m_align_left_action = createAction(QIcon(m_theme +"img16/edit_text_left.png"), tr("Izquierdo"), true, grp); } m_align_justify_action = createAction(QIcon(m_theme +"img16/edit_text_justify.png"), tr("Justificado"), true, grp); m_align_left_action->setPriority(QAction::LowPriority); m_align_left_action->setShortcut(Qt::CTRL + Qt::Key_L); m_align_center_action->setPriority(QAction::LowPriority); m_align_center_action->setShortcut(Qt::CTRL + Qt::Key_E); m_align_right_action->setPriority(QAction::LowPriority); m_align_right_action->setShortcut(Qt::CTRL + Qt::Key_R); m_align_justify_action->setPriority(QAction::LowPriority); m_align_justify_action->setShortcut(Qt::CTRL + Qt::Key_J); toolbar_edit->addActions(grp->actions()); toolbar_edit->addSeparator(); // superscript, subscript m_valign_sup_action = createAction(QIcon(m_theme +"img16/edit_text_super.png"), tr("Superíndice"), true, toolbar_edit); connect(m_valign_sup_action, SIGNAL(triggered(bool)), this, SLOT(on_edit_valign_sup())); toolbar_edit->addAction(m_valign_sup_action); m_valign_sub_action = createAction(QIcon(m_theme +"img16/edit_text_subs.png"), tr("Subíndice"), true, toolbar_edit); connect(m_valign_sub_action, SIGNAL(triggered(bool)), this, SLOT(on_edit_valign_sub())); toolbar_edit->addAction(m_valign_sub_action); toolbar_edit->addSeparator(); // image, link, color, simplify m_image_action = createAction(QIcon(m_theme +"img16/edit_imagen.png"), tr("Imagen"), false, toolbar_edit); connect(m_image_action, SIGNAL(triggered()), this, SLOT(on_edit_image())); toolbar_edit->addAction(m_image_action); m_link_action = createAction(QIcon(m_theme +"img16/edit_enlace.png"), tr("Enlace"), true, toolbar_edit); connect(m_link_action, SIGNAL(triggered(bool)), this, SLOT(on_edit_link(bool))); toolbar_edit->addAction(m_link_action); QPixmap pix(16, 16); pix.fill(Qt::black); m_color_action = createAction(QIcon(pix), tr("Color") +"...", false, toolbar_edit); connect(m_color_action, SIGNAL(triggered()), this, SLOT(on_edit_color())); toolbar_edit->addAction(m_color_action); toolbar_edit->addSeparator(); m_simplify_richtext_action = createAction(QIcon(m_theme +"img16/edit_simplify_richtext.png"), tr("Simplificar") +" Html", true, toolbar_edit); m_simplify_richtext_action->setChecked(editor_rich_text->simplifyRichText()); connect(m_simplify_richtext_action, SIGNAL(triggered(bool)), editor_rich_text, SLOT(setSimplifyRichText(bool))); connect(editor_rich_text, SIGNAL(simplifyRichTextChanged(bool)), m_simplify_richtext_action, SLOT(setChecked(bool))); toolbar_edit->addAction(m_simplify_richtext_action); toolbar_layout->addWidget(toolbar_edit); QToolBar *toolbar_opts = new QToolBar(this); toolbar_opts->setIconSize(QSize(20, 20)); toolbar_opts->setMinimumSize(QSize(30, 30)); toolbar_opts->setStyleSheet("QToolBar{border:0px;}"); m_find_replace_text_action = createAction(QIcon(m_theme +"img16/edit_buscar.png"), tr("Buscar") +"/"+ tr("Reemplazar"), true, toolbar_opts); m_find_replace_text_action->setPriority(QAction::LowPriority); m_find_replace_text_action->setShortcut(QKeySequence::Find); connect(m_find_replace_text_action, SIGNAL(triggered(bool)), this, SLOT(on_show_find_replace(bool))); toolbar_opts->addAction(m_find_replace_text_action); m_rich_plain_action = createAction(QIcon(m_theme +"img16/script.png"), tr("Editor") +"/"+ tr("Código"), true, toolbar_opts); connect(m_rich_plain_action, SIGNAL(triggered(bool)), this, SLOT(on_show_source(bool))); toolbar_opts->addAction(m_rich_plain_action); m_smiles_action = createAction(QIcon(m_theme +"img16/smile.png"), tr("Smiles"), true, toolbar_opts); connect(m_smiles_action, SIGNAL(triggered(bool)), list_smile, SLOT(setVisible(bool))); toolbar_opts->addAction(m_smiles_action); toolbar_layout->addWidget(toolbar_opts); toolbar_layout->setStretch(0, 1); main_layout->addLayout(toolbar_layout); QHBoxLayout *edit_smiles_layout = new QHBoxLayout(); edit_smiles_layout->setContentsMargins(0, 0, 0, 0); edit_smiles_layout->setSpacing(4); QWidget *rich_edit = new QWidget(); QVBoxLayout *rich_edit_layout = new QVBoxLayout(rich_edit); rich_edit_layout->setContentsMargins(0, 0, 0, 0); rich_edit_layout->addWidget(editor_rich_text); pag_stacked->addWidget(rich_edit); QWidget *plain_edit = new QWidget(); QVBoxLayout *plain_edit_layout = new QVBoxLayout(plain_edit); plain_edit_layout->setContentsMargins(0, 0, 0, 0); plain_edit_layout->addWidget(editor_plain_text); pag_stacked->addWidget(plain_edit); connect(pag_stacked, SIGNAL(currentChanged(int)), this, SLOT(pagIndexChanged(int))); edit_smiles_layout->addWidget(pag_stacked); edit_smiles_layout->addWidget(list_smile); main_layout->addLayout(edit_smiles_layout); QGridLayout *gridLayout = new QGridLayout(toolbar_find_replace); gridLayout->setSpacing(4); gridLayout->setContentsMargins(0, 0, 0, 0); QLabel *lb_find = new QLabel(tr("Buscar")+":", toolbar_find_replace); gridLayout->addWidget(lb_find, 0, 0, 1, 1); txt_find = new QLineEdit(toolbar_find_replace); txt_find->setMinimumSize(QSize(0, 24)); connect(txt_find, SIGNAL(textChanged(QString)), this, SLOT(txtFindTextChanged(QString))); gridLayout->addWidget(txt_find, 0, 1, 1, 1); QToolButton *btnFindBack = createToolButton(QIcon(m_theme +"img16/edit_buscar_anterior.png"), tr("Buscar anterior"), toolbar_find_replace); btnFindBack->setShortcut(QKeySequence::FindPrevious); connect(btnFindBack, SIGNAL(clicked()), this, SLOT(btnFindBack_clicked())); gridLayout->addWidget(btnFindBack, 0, 2, 1, 1); QToolButton *btnFindNext = createToolButton(QIcon(m_theme +"img16/edit_buscar_siguiente.png"), tr("Buscar siguiente"), toolbar_find_replace); btnFindBack->setShortcut(QKeySequence::FindNext); connect(btnFindNext, SIGNAL(clicked()), this, SLOT(btnFindNext_clicked())); gridLayout->addWidget(btnFindNext, 0, 3, 1, 1); chkCaseSensitive = new QCheckBox(tr("Coincidir mayúsculas/minúsculas"), toolbar_find_replace); chkCaseSensitive->setChecked(false); connect(chkCaseSensitive, SIGNAL(toggled(bool)), this, SLOT(chkCaseSensitive_toggled(bool))); gridLayout->addWidget(chkCaseSensitive, 0, 5, 1, 1); QCheckBox *chkReplace = new QCheckBox(tr("Reemplazar por") +":", toolbar_find_replace); chkReplace->setChecked(false); connect(chkReplace, SIGNAL(toggled(bool)), this, SLOT(chkReplace_toggled(bool))); gridLayout->addWidget(chkReplace, 1, 0, 1, 1); txt_replace = new QLineEdit(toolbar_find_replace); txt_replace->setEnabled(false); txt_replace->setMinimumSize(QSize(0, 24)); gridLayout->addWidget(txt_replace, 1, 1, 1, 1); btnReplace = createToolButton(QIcon(m_theme +"img16/edit_reemplazar.png"), tr("Reemplazar"), toolbar_find_replace); btnReplace->setEnabled(false); connect(btnReplace, SIGNAL(clicked()), this, SLOT(btnReplace_clicked())); gridLayout->addWidget(btnReplace, 1, 2, 1, 1); btnReplaceAndNext = createToolButton(QIcon(m_theme +"img16/edit_reemplazar.png"), tr("Reemplazar siguiente"), toolbar_find_replace); btnReplaceAndNext->setEnabled(false); connect(btnReplaceAndNext, SIGNAL(clicked()), this, SLOT(btnReplaceAndNext_clicked())); gridLayout->addWidget(btnReplaceAndNext, 1, 3, 1, 1); btnReplaceAll = createToolButton(QIcon(m_theme +"img16/edit_reemplazar.png"), tr("Reemplazar todo"), toolbar_find_replace); btnReplaceAll->setEnabled(false); connect(btnReplaceAll, SIGNAL(clicked()), this, SLOT(btnReplaceAll_clicked())); gridLayout->addWidget(btnReplaceAll, 1, 4, 1, 1); chkWholeWords = new QCheckBox(tr("Solo palabras completas"), toolbar_find_replace); gridLayout->addWidget(chkWholeWords, 1, 5, 1, 1); main_layout->addWidget(toolbar_find_replace); #ifndef QT_NO_CLIPBOARD connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); #endif showSource(m_initialPag == RichTextIndex ? false : true); showFindReplace(false); showSmiles(false); setTabStopWidth(40); fontChanged(editor_rich_text->font()); colorChanged(editor_rich_text->textColor()); alignmentChanged(editor_rich_text->alignment()); }