/** 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(); }
/* TextEdit */ TextEdit::TextEdit(QWidget *parent) : QMainWindow(parent) { setIconSize(QSize(16, 16)); setToolButtonStyle(Qt::ToolButtonFollowStyle); setupFileActions(); setupEditActions(); setupViewActions(); setupTextActions(); QStatusBar *pStatusBar = statusBar(); pStatusBar->showMessage(tr("Ready")); { QMenu *helpMenu = new QMenu(tr("Help"), this); menuBar()->addMenu(helpMenu); helpMenu->addAction(tr("About"), this, SLOT(about())); } 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(); QRect geom = QApplication::desktop()->availableGeometry(); resize( 2 * geom.width() / 3, 2 * geom.height() / 3 ); }