From 9e584e6723356925c9224db8e6e17fddf076d358 Mon Sep 17 00:00:00 2001 From: defnax Date: Mon, 22 Feb 2010 14:20:40 +0000 Subject: [PATCH] redesign Create Blog Msg Publisher with html Formating features and fixed textSize formating for Message Composer git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2388 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/blogs/BlogsMsgItem.cpp | 13 +- retroshare-gui/src/gui/blogs/BlogsMsgItem.ui | 310 +++--- .../src/gui/blogs/CreateBlogMsg.cpp | 917 +++++++++++++++++- retroshare-gui/src/gui/blogs/CreateBlogMsg.h | 105 +- retroshare-gui/src/gui/blogs/CreateBlogMsg.ui | 868 ++++++++++------- retroshare-gui/src/gui/images.qrc | 3 + .../images/textedit/format-list-ordered.png | Bin 0 -> 619 bytes .../images/textedit/format-list-unordered.png | Bin 0 -> 314 bytes .../gui/images/textedit/format-text-color.png | Bin 0 -> 825 bytes .../textedit/format-text-strikethrough.png | Bin 0 -> 579 bytes retroshare-gui/src/gui/msgs/ChanMsgDialog.cpp | 9 +- 11 files changed, 1668 insertions(+), 557 deletions(-) create mode 100644 retroshare-gui/src/gui/images/textedit/format-list-ordered.png create mode 100644 retroshare-gui/src/gui/images/textedit/format-list-unordered.png create mode 100644 retroshare-gui/src/gui/images/textedit/format-text-color.png create mode 100644 retroshare-gui/src/gui/images/textedit/format-text-strikethrough.png diff --git a/retroshare-gui/src/gui/blogs/BlogsMsgItem.cpp b/retroshare-gui/src/gui/blogs/BlogsMsgItem.cpp index 989a5fd4e..ac1fc7152 100644 --- a/retroshare-gui/src/gui/blogs/BlogsMsgItem.cpp +++ b/retroshare-gui/src/gui/blogs/BlogsMsgItem.cpp @@ -85,27 +85,24 @@ void BlogsMsgItem::updateItemStatic() title = "Channel Feed: "; title += QString::fromStdWString(ci.blogName); titleLabel->setText(title); - subjectLabel->setText(QString::fromStdWString(cmi.subject)); + //subjectLabel->setText(QString::fromStdWString(cmi.subject)); } else { /* subject */ titleLabel->setText(QString::fromStdWString(cmi.subject)); - subjectLabel->setText(QString::fromStdWString(cmi.msg)); + /* Blog Message */ + textBrowser->setHtml( QString::fromStdWString(cmi.msg)); } - msgLabel->setText(QString::fromStdWString(cmi.msg)); + //msgLabel->setText(QString::fromStdWString(cmi.msg)); + //msgcommentstextEdit->setHtml(QString::fromStdWString(cmi.msg)); QDateTime qtime; qtime.setTime_t(cmi.ts); QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm:ss"); datetimelabel->setText(timestamp); - { - std::ostringstream out; - out << "(" << cmi.count << " Files)"; - filelabel->setText(QString::fromStdString(out.str())); - } std::list::iterator it; diff --git a/retroshare-gui/src/gui/blogs/BlogsMsgItem.ui b/retroshare-gui/src/gui/blogs/BlogsMsgItem.ui index 5027c0df8..7c8fcb40d 100644 --- a/retroshare-gui/src/gui/blogs/BlogsMsgItem.ui +++ b/retroshare-gui/src/gui/blogs/BlogsMsgItem.ui @@ -6,8 +6,8 @@ 0 0 - 538 - 272 + 516 + 327 @@ -60,157 +60,8 @@ border-radius: 10px;} QFrame::Raised - - - - - - - - 0 - 0 - - - - - 11 - 75 - true - true - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:11pt; font-weight:600; font-style:italic;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#656565;">Blog Subject</span></p></body></html> - - - - - - - - 75 - true - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:600; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt; color:#666666;">DateTime</span></p></body></html> - - - - - - - - 0 - 0 - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Blog Message</span></p></body></html> - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 67 - 21 - - - - - - - - - 0 - 0 - - - - Unsubscribe From Channel - - - - - - - :/images/mail_delete.png:/images/mail_delete.png - - - - - - - - 0 - 0 - - - - Remove Item - - - - - - - :/images/close_normal.png:/images/close_normal.png - - - - - - - - 0 - 0 - - - - Expand - - - - - - - - - - :/images/edit_add24.png:/images/edit_add24.png - - - - - - - TextLabel - - - - - - + + QFrame#expandFrame{border: 2px solid #D3D3D3; @@ -241,22 +92,149 @@ border-radius: 10px;} + + + + + + + 0 + 0 + + + + + 11 + 75 + true + true + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:11pt; font-weight:600; font-style:italic;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#656565;">Blog Subject</span></p></body></html> + + + + + + + + 75 + true + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:600; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt; color:#666666;">DateTime</span></p></body></html> + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 288 + 21 + + + + + + + + + 0 + 0 + + + + Expand + + + + + + + + + + :/images/edit_add24.png:/images/edit_add24.png + + + + + + + + 0 + 0 + + + + Remove Item + + + + + + + :/images/close_normal.png:/images/close_normal.png + + + + + + + + 0 + 0 + + + + Unsubscribe From Channel + + + + + + + :/images/mail_delete.png:/images/mail_delete.png + + + + + + + + 0 + 0 + + + + QTextBrowser#textBrowser{border: 2px solid #D3D3D3; +background-color: transparent; +border-radius: 10px;} + + + + + - - - - Qt::Vertical - - - - 200 - 200 - - - - diff --git a/retroshare-gui/src/gui/blogs/CreateBlogMsg.cpp b/retroshare-gui/src/gui/blogs/CreateBlogMsg.cpp index ae9fecbbc..f063ecd39 100644 --- a/retroshare-gui/src/gui/blogs/CreateBlogMsg.cpp +++ b/retroshare-gui/src/gui/blogs/CreateBlogMsg.cpp @@ -19,10 +19,36 @@ * Boston, MA 02110-1301, USA. ****************************************************************/ #include +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "CreateBlogMsg.h" #include "gui/feeds/SubFileItem.h" +#include "gui/msgs/textformat.h" #include "rsiface/rstypes.h" #include "rsiface/rspeers.h" @@ -34,20 +60,111 @@ #include /** Constructor */ -CreateBlogMsg::CreateBlogMsg(std::string cId) -: QDialog (NULL), mBlogId(cId) ,mCheckAttachment(true) +CreateBlogMsg::CreateBlogMsg(std::string cId ,QWidget* parent, Qt::WFlags flags) +: mBlogId(cId), QMainWindow (parent, flags) ,mCheckAttachment(true) { /* Invoke the Qt Designer generated object setup routine */ - setupUi(this); - - connect(buttonBox, SIGNAL(accepted()), this, SLOT(sendMsg())); - connect(buttonBox, SIGNAL(rejected()), this, SLOT(cancelMsg())); - - connect(addFileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile())); - - setAcceptDrops(true); + ui.setupUi(this); + + 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.addFileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile())); + + 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(); + } /* Dropping */ @@ -261,7 +378,7 @@ void CreateBlogMsg::addAttachment(std::string hash, std::string fname, uint64_t SubFileItem *file = new SubFileItem(hash, fname, size, flags, srcId); mAttachments.push_back(file); - QLayout *layout = fileFrame->layout(); + QLayout *layout = ui.fileFrame->layout(); layout->addWidget(file); if (mCheckAttachment) @@ -307,7 +424,7 @@ void CreateBlogMsg::addAttachment(std::string path) SubFileItem *file = new SubFileItem(path); mAttachments.push_back(file); - QLayout *layout = fileFrame->layout(); + QLayout *layout = ui.fileFrame->layout(); layout->addWidget(file); if (mCheckAttachment) @@ -333,7 +450,7 @@ void CreateBlogMsg::checkAttachmentReady() { /* */ - buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); + ui.actionPublish->setEnabled(false); break; @@ -344,7 +461,7 @@ void CreateBlogMsg::checkAttachmentReady() if (fit == mAttachments.end()) { - buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); + ui.actionPublish->setEnabled(true); } /* repeat... */ @@ -374,7 +491,7 @@ void CreateBlogMsg::newBlogMsg() return; } - channelName->setText(QString::fromStdWString(ci.blogName)); + ui.channelName->setText(QString::fromStdWString(ci.blogName)); @@ -387,8 +504,8 @@ void CreateBlogMsg::sendMsg() std::cerr << std::endl; /* construct message bits */ - std::wstring subject = subjectEdit->text().toStdWString(); - std::wstring msg = msgEdit->toPlainText().toStdWString(); + std::wstring subject = ui.subjectEdit->text().toStdWString(); + std::wstring msg = ui.msgEdit->toHtml().toStdWString(); std::list files; @@ -425,7 +542,7 @@ void CreateBlogMsg::sendMessage(std::wstring subject, std::wstring msg, std::lis { std::cerr << "CreateBlogMsg::sendMessage()" << std::endl; - QString name = subjectEdit->text(); + QString name = ui.subjectEdit->text(); if(name.isEmpty()) { /* error message */ @@ -457,9 +574,773 @@ void CreateBlogMsg::sendMessage(std::wstring subject, std::wstring msg, std::lis } +void CreateBlogMsg::fontSizeIncrease() +{ + if ( !( ui.msgEdit->textCursor().blockFormat().hasProperty( TextFormat::HtmlHeading ) && + ui.msgEdit->textCursor().blockFormat().intProperty( TextFormat::HtmlHeading ) ) ) { + QTextCharFormat format; + int idx = ui.msgEdit->currentCharFormat().intProperty( QTextFormat::FontSizeAdjustment ); + if ( idx < 3 ) { + format.setProperty( QTextFormat::FontSizeAdjustment, QVariant( ++idx ) ); + ui.msgEdit->textCursor().mergeCharFormat( format ); + } + } + ui.msgEdit->setFocus( Qt::OtherFocusReason ); +} +void CreateBlogMsg::fontSizeDecrease() +{ + if ( !( ui.msgEdit->textCursor().blockFormat().hasProperty( TextFormat::HtmlHeading ) && + ui.msgEdit->textCursor().blockFormat().intProperty( TextFormat::HtmlHeading ) ) ) { + QTextCharFormat format; + int idx = ui.msgEdit->currentCharFormat().intProperty( QTextFormat::FontSizeAdjustment ); + if ( idx > -1 ) { + format.setProperty( QTextFormat::FontSizeAdjustment, QVariant( --idx ) ); + ui.msgEdit->textCursor().mergeCharFormat( format ); + } + } + ui.msgEdit->setFocus( Qt::OtherFocusReason ); +} + +void CreateBlogMsg::blockQuote() +{ + QTextBlockFormat blockFormat = ui.msgEdit->textCursor().blockFormat(); + QTextBlockFormat f; + + if ( blockFormat.hasProperty( TextFormat::IsBlockQuote ) && + blockFormat.boolProperty( TextFormat::IsBlockQuote ) ) { + f.setProperty( TextFormat::IsBlockQuote, QVariant( false ) ); + f.setLeftMargin( 0 ); + f.setRightMargin( 0 ); + } else { + f.setProperty( TextFormat::IsBlockQuote, QVariant( true ) ); + f.setLeftMargin( 40 ); + f.setRightMargin( 40 ); + } + ui.msgEdit->textCursor().mergeBlockFormat( f ); +} + +void CreateBlogMsg::toggleCode() +{ + static QString preFontFamily; + + QTextCharFormat charFormat = ui.msgEdit->currentCharFormat(); + QTextCharFormat f; + + if ( charFormat.hasProperty( TextFormat::HasCodeStyle ) && + charFormat.boolProperty( TextFormat::HasCodeStyle ) ) { + f.setProperty( TextFormat::HasCodeStyle, QVariant( false ) ); + f.setBackground( defaultCharFormat.background() ); + f.setFontFamily( preFontFamily ); + ui.msgEdit->textCursor().mergeCharFormat( f ); + + } else { + preFontFamily = ui.msgEdit->fontFamily(); + f.setProperty( TextFormat::HasCodeStyle, QVariant( true ) ); + f.setBackground( codeBackground ); + f.setFontFamily( "Dejavu Sans Mono" ); + ui.msgEdit->textCursor().mergeCharFormat( f ); + } + ui.msgEdit->setFocus( Qt::OtherFocusReason ); +} + +void CreateBlogMsg::addPostSplitter() +{ + QTextBlockFormat f = ui.msgEdit->textCursor().blockFormat(); + QTextBlockFormat f1 = f; + + f.setProperty( TextFormat::IsHtmlTagSign, true ); + f.setProperty( QTextFormat::BlockTrailingHorizontalRulerWidth, + QTextLength( QTextLength::PercentageLength, 80 ) ); + if ( ui.msgEdit->textCursor().block().text().isEmpty() ) { + ui.msgEdit->textCursor().mergeBlockFormat( f ); + } else { + ui.msgEdit->textCursor().insertBlock( f ); + } + ui.msgEdit->textCursor().insertBlock( f1 ); +} + +void CreateBlogMsg::setStartupText() +{ + QString string = "

HTML Previewer

" + "

This example shows you how to use QWebView to" + " preview HTML data written in a QPlainTextEdit.

" + " "; + //webView->setHtml(string); +} + +void CreateBlogMsg::updateTextEdit() +{ + //QWebFrame *mainFrame = webView->page()->mainFrame(); + QString frameText = ui.msgEdit->toHtml(); + ui.plainTextEdit->setPlainText(frameText); + //QString text = plainTextEdit->toPlainText(); +} +void CreateBlogMsg::textBold() +{ + QTextCharFormat fmt; + fmt.setFontWeight(actionTextBold->isChecked() ? QFont::Bold : QFont::Normal); + mergeFormatOnWordOrSelection(fmt); +} + +void CreateBlogMsg::textUnderline() +{ + QTextCharFormat fmt; + fmt.setFontUnderline(actionTextUnderline->isChecked()); + mergeFormatOnWordOrSelection(fmt); +} + +void CreateBlogMsg::textItalic() +{ + QTextCharFormat fmt; + fmt.setFontItalic(actionTextItalic->isChecked()); + mergeFormatOnWordOrSelection(fmt); +} +void CreateBlogMsg::textAlign(QAction *a) +{ + if (a == actionAlignLeft) + ui.msgEdit->setAlignment(Qt::AlignLeft | Qt::AlignAbsolute); + else if (a == actionAlignCenter) + ui.msgEdit->setAlignment(Qt::AlignHCenter | Qt::AlignAbsolute); + else if (a == actionAlignRight) + ui.msgEdit->setAlignment(Qt::AlignRight | Qt::AlignAbsolute); + else if (a == actionAlignJustify) + ui.msgEdit->setAlignment(Qt::AlignJustify | Qt::AlignAbsolute); + +} + +void CreateBlogMsg::alignmentChanged(Qt::Alignment a) +{ + if (a & Qt::AlignLeft) { + actionAlignLeft->setChecked(true); + } else if (a & Qt::AlignHCenter) { + actionAlignCenter->setChecked(true); + } else if (a & Qt::AlignRight) { + actionAlignRight->setChecked(true); + } else if (a & Qt::AlignJustify) { + actionAlignJustify->setChecked(true); + } +} + +void CreateBlogMsg::textFamily(const QString &f) +{ + QTextCharFormat fmt; + fmt.setFontFamily(f); + mergeFormatOnWordOrSelection(fmt); +} + +void CreateBlogMsg::textSize(const QString &p) +{ + qreal pointSize = p.toFloat(); + if (p.toFloat() > 0) { + QTextCharFormat fmt; + fmt.setFontPointSize(pointSize); + mergeFormatOnWordOrSelection(fmt); + } +} + +void CreateBlogMsg::textStyle(int styleIndex) +{ + QTextCursor cursor = ui.msgEdit->textCursor(); + + if (styleIndex != 0) { + QTextListFormat::Style style = QTextListFormat::ListDisc; + + switch (styleIndex) { + default: + case 1: + style = QTextListFormat::ListDisc; + break; + case 2: + style = QTextListFormat::ListCircle; + break; + case 3: + style = QTextListFormat::ListSquare; + break; + case 4: + style = QTextListFormat::ListDecimal; + break; + case 5: + style = QTextListFormat::ListLowerAlpha; + break; + case 6: + style = QTextListFormat::ListUpperAlpha; + break; + case 7: + style = QTextListFormat::ListLowerRoman; + break; + case 8: + style = QTextListFormat::ListUpperRoman; + break; + } + + cursor.beginEditBlock(); + + QTextBlockFormat blockFmt = cursor.blockFormat(); + + QTextListFormat listFmt; + + if (cursor.currentList()) { + listFmt = cursor.currentList()->format(); + } else { + listFmt.setIndent(blockFmt.indent() + 1); + blockFmt.setIndent(0); + cursor.setBlockFormat(blockFmt); + } + + listFmt.setStyle(style); + + cursor.createList(listFmt); + + cursor.endEditBlock(); + } else { + // #### + QTextBlockFormat bfmt; + bfmt.setObjectIndex(-1); + cursor.mergeBlockFormat(bfmt); + } +} + +void CreateBlogMsg::changeFormatType(int styleIndex ) +{ + ui.msgEdit->setFocus( Qt::OtherFocusReason ); + + QTextCursor cursor = ui.msgEdit->textCursor(); + //QTextBlockFormat bformat = cursor.blockFormat(); + QTextBlockFormat bformat; + QTextCharFormat cformat; + + switch (styleIndex) { + default: + case 0: + bformat.setProperty( TextFormat::HtmlHeading, QVariant( 0 ) ); + cformat.setFontWeight( QFont::Normal ); + cformat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( 0 ) ); + break; + case 1: + bformat.setProperty( TextFormat::HtmlHeading, QVariant( 1 ) ); + cformat.setFontWeight( QFont::Bold ); + cformat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( 3 ) ); + break; + case 2: + bformat.setProperty( TextFormat::HtmlHeading, QVariant( 2 ) ); + cformat.setFontWeight( QFont::Bold ); + cformat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( 2 ) ); + break; + case 3: + bformat.setProperty( TextFormat::HtmlHeading, QVariant( 3 ) ); + cformat.setFontWeight( QFont::Bold ); + cformat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( 1 ) ); + break; + case 4: + bformat.setProperty( TextFormat::HtmlHeading, QVariant( 4 ) ); + cformat.setFontWeight( QFont::Bold ); + cformat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( 0 ) ); + break; + case 5: + bformat.setProperty( TextFormat::HtmlHeading, QVariant( 5 ) ); + cformat.setFontWeight( QFont::Bold ); + cformat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( -1 ) ); + break; + case 6: + bformat.setProperty( TextFormat::HtmlHeading, QVariant( 6 ) ); + cformat.setFontWeight( QFont::Bold ); + cformat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( -2 ) ); + break; + } + //cformat.clearProperty( TextFormat::HasCodeStyle ); + + cursor.beginEditBlock(); + cursor.mergeBlockFormat( bformat ); + cursor.select( QTextCursor::BlockUnderCursor ); + cursor.mergeCharFormat( cformat ); + cursor.endEditBlock(); +} +void CreateBlogMsg::textColor() +{ + QColor col = QColorDialog::getColor(ui.msgEdit->textColor(), this); + if (!col.isValid()) + return; + QTextCharFormat fmt; + fmt.setForeground(col); + mergeFormatOnWordOrSelection(fmt); + colorChanged(col); +} + +void CreateBlogMsg::fontChanged(const QFont &f) +{ + comboFont->setCurrentIndex(comboFont->findText(QFontInfo(f).family())); + comboSize->setCurrentIndex(comboSize->findText(QString::number(f.pointSize()))); + actionTextBold->setChecked(f.bold()); + actionTextItalic->setChecked(f.italic()); + actionTextUnderline->setChecked(f.underline()); +} + +void CreateBlogMsg::colorChanged(const QColor &c) +{ + QPixmap pix(16, 16); + pix.fill(c); + //ui.colorbtn->setIcon(pix); + actionTextColor->setIcon(pix); +} + +void CreateBlogMsg::mergeFormatOnWordOrSelection(const QTextCharFormat &format) +{ + QTextCursor cursor = ui.msgEdit->textCursor(); + if (!cursor.hasSelection()) + cursor.select(QTextCursor::WordUnderCursor); + cursor.mergeCharFormat(format); + ui.msgEdit->mergeCurrentCharFormat(format); +} + +void CreateBlogMsg::currentCharFormatChanged(const QTextCharFormat &format) +{ + fontChanged(format.font()); + colorChanged(format.foreground().color()); +} + +void CreateBlogMsg::cursorPositionChanged() +{ + alignmentChanged(ui.msgEdit->alignment()); +} + +void CreateBlogMsg::clipboardDataChanged() +{ +#ifndef QT_NO_CLIPBOARD + actionPaste->setEnabled(!QApplication::clipboard()->text().isEmpty()); +#endif +} + + +void CreateBlogMsg::addOrderedList() +{ + ui.msgEdit->textCursor().createList( QTextListFormat::ListDecimal ); + +} + +void CreateBlogMsg::addUnorderedList() +{ + ui.msgEdit->textCursor().createList( QTextListFormat::ListDisc ); +} + +void CreateBlogMsg::setupFileActions() +{ + QMenu *menu = new QMenu(tr("&File"), this); + menuBar()->addMenu(menu); + + QAction *a; + + a = new QAction(QIcon(":/images/textedit/filenew.png"), tr("&New"), this); + a->setShortcut(QKeySequence::New); + connect(a, SIGNAL(triggered()), this, SLOT(fileNew())); + menu->addAction(a); + + a = new QAction(QIcon(":/images/textedit/fileopen.png"), tr("&Open..."), this); + a->setShortcut(QKeySequence::Open); + connect(a, SIGNAL(triggered()), this, SLOT(fileOpen())); + menu->addAction(a); + + menu->addSeparator(); + + actionSave = a = new QAction(QIcon(":/images/textedit/filesave.png"), tr("&Save"), this); + a->setShortcut(QKeySequence::Save); + connect(a, SIGNAL(triggered()), this, SLOT(fileSave())); + a->setEnabled(false); + menu->addAction(a); + + a = new QAction(tr("Save &As..."), this); + connect(a, SIGNAL(triggered()), this, SLOT(fileSaveAs())); + menu->addAction(a); + menu->addSeparator(); + + a = new QAction(QIcon(":/images/textedit/fileprint.png"), tr("&Print..."), this); + a->setShortcut(QKeySequence::Print); + connect(a, SIGNAL(triggered()), this, SLOT(filePrint())); + menu->addAction(a); + + a = new QAction(QIcon(":/images/textedit/fileprint.png"), tr("Print Preview..."), this); + connect(a, SIGNAL(triggered()), this, SLOT(filePrintPreview())); + menu->addAction(a); + + a = new QAction(QIcon(":/images/textedit/exportpdf.png"), tr("&Export PDF..."), this); + a->setShortcut(Qt::CTRL + Qt::Key_D); + connect(a, SIGNAL(triggered()), this, SLOT(filePrintPdf())); + menu->addAction(a); + + menu->addSeparator(); + + a = new QAction(tr("&Quit"), this); + a->setShortcut(Qt::CTRL + Qt::Key_Q); + connect(a, SIGNAL(triggered()), this, SLOT(cancelMsg())); + menu->addAction(a); +} + +void CreateBlogMsg::setupEditActions() +{ + QMenu *menu = new QMenu(tr("&Edit"), this); + menuBar()->addMenu(menu); + + QAction *a; + a = actionUndo = new QAction(QIcon(":/images/textedit/editundo.png"), tr("&Undo"), this); + a->setShortcut(QKeySequence::Undo); + menu->addAction(a); + a = actionRedo = new QAction(QIcon(":/images/textedit/editredo.png"), tr("&Redo"), this); + a->setShortcut(QKeySequence::Redo); + menu->addAction(a); + menu->addSeparator(); + a = actionCut = new QAction(QIcon(":/images/textedit/editcut.png"), tr("Cu&t"), this); + a->setShortcut(QKeySequence::Cut); + menu->addAction(a); + a = actionCopy = new QAction(QIcon(":/images/textedit/editcopy.png"), tr("&Copy"), this); + a->setShortcut(QKeySequence::Copy); + menu->addAction(a); + a = actionPaste = new QAction(QIcon(":/images/textedit/editpaste.png"), tr("&Paste"), this); + a->setShortcut(QKeySequence::Paste); + menu->addAction(a); + actionPaste->setEnabled(!QApplication::clipboard()->text().isEmpty()); +} + +void CreateBlogMsg::setupViewActions() +{ + QMenu *menu = new QMenu(tr("&View"), this); + menuBar()->addMenu(menu); + + QAction *a; + + +} + +void CreateBlogMsg::setupInsertActions() +{ + QMenu *menu = new QMenu(tr("&Insert"), this); + menuBar()->addMenu(menu); + + QAction *a; + + a = new QAction(QIcon(""), tr("&Image"), this); + connect(a, SIGNAL(triggered()), this, SLOT(addImage())); + menu->addAction(a); + +} + +void CreateBlogMsg::setupParagraphActions() +{ + comboStyle = new QComboBox(ui.toolBar_2); + ui.toolBar_2->addWidget(comboStyle); + comboStyle->addItem("Paragraph"); + comboStyle->addItem("Heading 1"); + comboStyle->addItem("Heading 2"); + comboStyle->addItem("Heading 3"); + comboStyle->addItem("Heading 4"); + comboStyle->addItem("Heading 5"); + comboStyle->addItem("Heading 6"); + + connect(comboStyle, SIGNAL(activated(int)), + this, SLOT(changeFormatType(int))); +} + +void CreateBlogMsg::setupTextActions() +{ + + QMenu *menu = new QMenu(tr("F&ormat"), this); + menuBar()->addMenu(menu); + + actionTextBold = new QAction(QIcon(":/images/textedit/textbold.png"),tr("&Bold"), this); + actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B); + actionTextBold->setPriority(QAction::LowPriority); + QFont bold; + bold.setBold(true); + actionTextBold->setFont(bold); + connect(actionTextBold, SIGNAL(triggered()), this, SLOT(textBold())); + + ui.toolBar_2->addAction(actionTextBold); + menu->addAction(actionTextBold); + actionTextBold->setCheckable(true); + + actionTextItalic = new QAction(QIcon(":/images/textedit/textitalic.png"),tr("&Italic"), this); + actionTextItalic->setPriority(QAction::LowPriority); + actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I); + QFont italic; + italic.setItalic(true); + actionTextItalic->setFont(italic); + connect(actionTextItalic, SIGNAL(triggered()), this, SLOT(textItalic())); + + ui.toolBar_2->addAction(actionTextItalic); + menu->addAction(actionTextItalic); + actionTextItalic->setCheckable(true); + + actionTextUnderline = new QAction(QIcon(":/images/textedit/textunder.png"),tr("&Underline"), this); + actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U); + actionTextUnderline->setPriority(QAction::LowPriority); + QFont underline; + underline.setUnderline(true); + actionTextUnderline->setFont(underline); + connect(actionTextUnderline, SIGNAL(triggered()), this, SLOT(textUnderline())); + + ui.toolBar_2->addAction(actionTextUnderline); + menu->addAction(actionTextUnderline); + actionTextUnderline->setCheckable(true); + + menu->addSeparator(); + + QActionGroup *grp = new QActionGroup(this); + connect(grp, SIGNAL(triggered(QAction*)), this, SLOT(textAlign(QAction*))); + + // Make sure the alignLeft is always left of the alignRight + if (QApplication::isLeftToRight()) { + actionAlignLeft = new QAction(QIcon(":/images/textedit/textleft.png"),tr("&Left"), grp); + actionAlignCenter = new QAction(QIcon(":/images/textedit/textcenter.png"), tr("C&enter"), grp); + actionAlignRight = new QAction(QIcon(":/images/textedit/textright.png"), tr("&Right"), grp); + } else { + actionAlignRight = new QAction(QIcon(":/images/textedit/textright.png"), tr("&Right"), grp); + actionAlignCenter = new QAction(QIcon(":/images/textedit/textcenter.png"), tr("C&enter"), grp); + actionAlignLeft = new QAction(QIcon(":/images/textedit/textleft.png"), tr("&Left"), grp); + } + actionAlignJustify = new QAction(QIcon(":/images/textedit/textjustify.png"), tr("&Justify"), grp); + + actionAlignLeft->setShortcut(Qt::CTRL + Qt::Key_L); + actionAlignLeft->setCheckable(true); + actionAlignLeft->setPriority(QAction::LowPriority); + actionAlignCenter->setShortcut(Qt::CTRL + Qt::Key_E); + actionAlignCenter->setCheckable(true); + actionAlignCenter->setPriority(QAction::LowPriority); + actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R); + actionAlignRight->setCheckable(true); + actionAlignRight->setPriority(QAction::LowPriority); + actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J); + actionAlignJustify->setCheckable(true); + actionAlignJustify->setPriority(QAction::LowPriority); + + ui.toolBar_2->addActions(grp->actions()); + menu->addActions(grp->actions()); + + menu->addSeparator(); + + QPixmap pix(16, 16); + pix.fill(Qt::black); + actionTextColor = new QAction(pix, tr("&Text Color..."), this); + connect(actionTextColor, SIGNAL(triggered()), this, SLOT(textColor())); + + ui.toolBar_2->addAction(actionTextColor); + menu->addAction(actionTextColor); + + menu->addAction(ui.actionOrderedlist); + menu->addAction(ui.actionUnorderedlist); + menu->addAction(ui.actionBlockquoute); + + + /*comboStyle = new QComboBox(ui.toolBar_2); + ui.toolBar_2->addWidget(comboStyle); + comboStyle->addItem("Paragraph"); + comboStyle->addItem("Heading 1"); + comboStyle->addItem("Heading 2"); + comboStyle->addItem("Heading 3"); + comboStyle->addItem("Heading 4"); + comboStyle->addItem("Heading 5"); + comboStyle->addItem("Heading 6"); + + connect(comboStyle, SIGNAL(activated(int)), + this, SLOT(changeFormatType(int)));*/ + + comboFont = new QFontComboBox(ui.toolBar_2); + ui.toolBar_2->addWidget(comboFont); + connect(comboFont, SIGNAL(activated(QString)), + this, SLOT(textFamily(QString))); + + comboSize = new QComboBox(ui.toolBar_2); + comboSize->setObjectName("comboSize"); + ui.toolBar_2->addWidget(comboSize); + comboSize->setEditable(true); + + QFontDatabase db; + foreach(int size, db.standardSizes()) + comboSize->addItem(QString::number(size)); + + connect(comboSize, SIGNAL(activated(QString)), + this, SLOT(textSize(QString))); + comboSize->setCurrentIndex(comboSize->findText(QString::number(QApplication::font() + .pointSize()))); +} + +bool CreateBlogMsg::load(const QString &f) +{ + if (!QFile::exists(f)) + return false; + QFile file(f); + if (!file.open(QFile::ReadOnly)) + return false; + + QByteArray data = file.readAll(); + QTextCodec *codec = Qt::codecForHtml(data); + QString str = codec->toUnicode(data); + if (Qt::mightBeRichText(str)) { + ui.msgEdit->setHtml(str); + } else { + str = QString::fromLocal8Bit(data); + ui.msgEdit->setPlainText(str); + } + + setCurrentFileName(f); + return true; +} + +bool CreateBlogMsg::maybeSave() +{ + if (!ui.msgEdit->document()->isModified()) + return true; + if (fileName.startsWith(QLatin1String(":/"))) + return true; + QMessageBox::StandardButton ret; + ret = QMessageBox::warning(this, tr("Application"), + tr("The document has been modified.\n" + "Do you want to save your changes?"), + QMessageBox::Save | QMessageBox::Discard + | QMessageBox::Cancel); + if (ret == QMessageBox::Save) + return fileSave(); + else if (ret == QMessageBox::Cancel) + return false; + return true; +} + +void CreateBlogMsg::fileNew() +{ + if (maybeSave()) { + ui.msgEdit->clear(); + setCurrentFileName(QString()); + } +} + +void CreateBlogMsg::fileOpen() +{ + QString fn = QFileDialog::getOpenFileName(this, tr("Open File..."), + QString(), tr("HTML-Files (*.htm *.html);;All Files (*)")); + if (!fn.isEmpty()) + load(fn); +} + +bool CreateBlogMsg::fileSave() +{ + if (fileName.isEmpty()) + return fileSaveAs(); + + QTextDocumentWriter writer(fileName); + bool success = writer.write(ui.msgEdit->document()); + if (success) + ui.msgEdit->document()->setModified(false); + return success; +} + +bool CreateBlogMsg::fileSaveAs() +{ + QString fn = QFileDialog::getSaveFileName(this, tr("Save as..."), + QString(), tr("ODF files (*.odt);;HTML-Files (*.htm *.html);;All Files (*)")); + if (fn.isEmpty()) + return false; + if (! (fn.endsWith(".odt", Qt::CaseInsensitive) || fn.endsWith(".htm", Qt::CaseInsensitive) || fn.endsWith(".html", Qt::CaseInsensitive)) ) + fn += ".odt"; // default + setCurrentFileName(fn); + return fileSave(); +} + +void CreateBlogMsg::filePrint() +{ +#ifndef QT_NO_PRINTER + QPrinter printer(QPrinter::HighResolution); + QPrintDialog *dlg = new QPrintDialog(&printer, this); + if (ui.msgEdit->textCursor().hasSelection()) + dlg->addEnabledOption(QAbstractPrintDialog::PrintSelection); + dlg->setWindowTitle(tr("Print Document")); + if (dlg->exec() == QDialog::Accepted) { + ui.msgEdit->print(&printer); + } + delete dlg; +#endif +} + +void CreateBlogMsg::filePrintPreview() +{ +#ifndef QT_NO_PRINTER + QPrinter printer(QPrinter::HighResolution); + QPrintPreviewDialog preview(&printer, this); + connect(&preview, SIGNAL(paintRequested(QPrinter*)), SLOT(printPreview(QPrinter*))); + preview.exec(); +#endif +} + +void CreateBlogMsg::printPreview(QPrinter *printer) +{ +#ifdef QT_NO_PRINTER + Q_UNUSED(printer); +#else + ui.msgEdit->print(printer); +#endif +} + + +void CreateBlogMsg::filePrintPdf() +{ +#ifndef QT_NO_PRINTER +//! [0] + QString fileName = QFileDialog::getSaveFileName(this, "Export PDF", + QString(), "*.pdf"); + if (!fileName.isEmpty()) { + if (QFileInfo(fileName).suffix().isEmpty()) + fileName.append(".pdf"); + QPrinter printer(QPrinter::HighResolution); + printer.setOutputFormat(QPrinter::PdfFormat); + printer.setOutputFileName(fileName); + ui.msgEdit->document()->print(&printer); + } +//! [0] +#endif +} + +void CreateBlogMsg::setCurrentFileName(const QString &fileName) +{ + this->fileName = fileName; + ui.msgEdit->document()->setModified(false); + + QString shownName; + if (fileName.isEmpty()) + shownName = "untitled.txt"; + else + shownName = QFileInfo(fileName).fileName(); + + //setWindowTitle(tr("%1[*] - %2").arg(shownName).arg(tr("Rich Text"))); + setWindowModified(false); +} + +void CreateBlogMsg::addImage() +{ + + QString fileimg = QFileDialog::getOpenFileName( this, tr( "Choose Image" ), + QString(setter.value("LastDir").toString()) ,tr("Image Files supported (*.png *.jpeg *.jpg *.gif)")); + + if ( fileimg.isEmpty() ) { + return; + } + + QImage base(fileimg); + + QString pathimage = fileimg.left(fileimg.lastIndexOf("/"))+"/"; + setter.setValue("LastDir",pathimage); + + Create_New_Image_Tag(fileimg); +} + +void CreateBlogMsg::Create_New_Image_Tag( const QString urlremoteorlocal ) +{ + /*if (image_extension(urlremoteorlocal)) {*/ + QString subtext = QString("

").arg(urlremoteorlocal); + ///////////subtext.append("

Description on image.

"); + QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(subtext); + ui.msgEdit->textCursor().insertFragment(fragment); + //emit statusMessage(QString("Image new :").arg(urlremoteorlocal)); + //} +} \ No newline at end of file diff --git a/retroshare-gui/src/gui/blogs/CreateBlogMsg.h b/retroshare-gui/src/gui/blogs/CreateBlogMsg.h index 24b2e5889..6dd906f9b 100644 --- a/retroshare-gui/src/gui/blogs/CreateBlogMsg.h +++ b/retroshare-gui/src/gui/blogs/CreateBlogMsg.h @@ -22,19 +22,32 @@ #ifndef _CREATEBLOGMSG_H #define _CREATEBLOGMSG_H +#include +#include +#include +#include +#include + #include "ui_CreateBlogMsg.h" #include class SubFileItem; class FileInfo; -class CreateBlogMsg : public QDialog, private Ui::CreateBlogMsg +QT_FORWARD_DECLARE_CLASS(QAction) +QT_FORWARD_DECLARE_CLASS(QComboBox) +QT_FORWARD_DECLARE_CLASS(QFontComboBox) +QT_FORWARD_DECLARE_CLASS(QTextEdit) +QT_FORWARD_DECLARE_CLASS(QTextCharFormat) +QT_FORWARD_DECLARE_CLASS(QMenu) + +class CreateBlogMsg : public QMainWindow { Q_OBJECT public: /** Default Constructor */ - CreateBlogMsg(std::string cId); + CreateBlogMsg(std::string cId, QWidget *parent = 0, Qt::WFlags flags = 0); /** Default Destructor */ void addAttachment(std::string path); @@ -44,6 +57,9 @@ public: void newBlogMsg(); QPixmap picture; + QSettings setter; + + void Create_New_Image_Tag( const QString urlremoteorlocal ); protected: virtual void dragEnterEvent(QDragEnterEvent *event); @@ -55,9 +71,64 @@ private slots: void cancelMsg(); void sendMsg(); + void addImage(); + void fontSizeIncrease(); + void fontSizeDecrease(); + void blockQuote(); + void toggleCode(); + void addPostSplitter(); + + void setStartupText(); + void updateTextEdit(); + + void fileNew(); + void fileOpen(); + bool fileSave(); + bool fileSaveAs(); + void filePrint(); + void filePrintPreview(); + void filePrintPdf(); + void printPreview(QPrinter *); + + void textBold(); + void textUnderline(); + void textItalic(); + void textFamily(const QString &f); + void textSize(const QString &p); + void textStyle(int styleIndex); + void changeFormatType(int styleIndex ); + + + void textColor(); + void textAlign(QAction *a); + + void addOrderedList(); + void addUnorderedList(); + + void currentCharFormatChanged(const QTextCharFormat &format); + void cursorPositionChanged(); + + void clipboardDataChanged(); + private: + void setupFileActions(); + void setupEditActions(); + void setupViewActions(); + void setupInsertActions(); + void setupParagraphActions(); + void setupTextActions(); + + void setCurrentFileName(const QString &fileName); + bool load(const QString &f); + bool maybeSave(); + + void mergeFormatOnWordOrSelection(const QTextCharFormat &format); + + void fontChanged(const QFont &f); + void colorChanged(const QColor &c); + void alignmentChanged(Qt::Alignment a); void parseRsFileListAttachments(std::string attachList); @@ -68,6 +139,36 @@ private: std::list mAttachments; bool mCheckAttachment; + + QAction *actionSave, + *actionTextBold, + *actionTextUnderline, + *actionTextItalic, + *actionTextColor, + *actionAlignLeft, + *actionAlignCenter, + *actionAlignRight, + *actionAlignJustify, + *actionUndo, + *actionRedo, + *actionCut, + *actionCopy, + *actionPaste; + + QComboBox *comboStyle; + QFontComboBox *comboFont; + QComboBox *comboSize; + + QString fileName; + + QColor codeBackground; + QTextCharFormat defaultCharFormat; + QTextBlockFormat defaultBlockFormat; + QTextCharFormat lastCharFormat; + QTextBlockFormat lastBlockFormat; + + /** Qt Designer generated object */ + Ui::CreateBlogMsg ui; }; diff --git a/retroshare-gui/src/gui/blogs/CreateBlogMsg.ui b/retroshare-gui/src/gui/blogs/CreateBlogMsg.ui index 3813f0cf6..0da9d5093 100644 --- a/retroshare-gui/src/gui/blogs/CreateBlogMsg.ui +++ b/retroshare-gui/src/gui/blogs/CreateBlogMsg.ui @@ -1,360 +1,508 @@ - - - CreateBlogMsg - - - - 0 - 0 - 627 - 464 - - - - true - - - New Blog Post - - - - :/images/rstray3.png:/images/rstray3.png - - - - 0 - - - 0 - - - - - - 16777215 - 64 - - - - QFrame#frame{background-image: url(:/images/connect/connectFriendBanner.png);} - - - - QFrame::NoFrame - - - QFrame::Raised - - - - - - - 48 - 48 - - - - - 48 - 48 - - - - - - - :/images/hi48-app-kblogger.png - - - true - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:26pt; color:#ffffff;">New Blog Post</span></p></body></html> - - - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - 0 - - - - Blog Post - - - - - - - - - 75 - true - - - - Blog Post to: - - - - - - - true - - - true - - - - - - - - - Blog Message - - - - - - - - - 75 - true - - - - Subject : - - - - - - - - - - - - - - - - - - - - :/images/attachment.png:/images/attachment.png - - - Attachments - - - - 0 - - - 0 - - - - - 0 - - - 6 - - - 6 - - - - - - - - :/images/attachment.png - - - - - - - - 16777215 - 26 - - - - - 75 - true - - - - Attachments - - - - - - - Qt::Horizontal - - - - 334 - 26 - - - - - - - - - 0 - 0 - - - - - 34 - 34 - - - - - - - - :/images/add-share24.png:/images/add-share24.png - - - - 24 - 24 - - - - - - - - - - Qt::ScrollBarAlwaysOn - - - true - - - - - 0 - 0 - 582 - 282 - - - - - - - - 0 - 0 - - - - true - - - Drag and Drop Files from Search Results - - - QFrame#fileFrame{border: 2px solid black; -background: white;} - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - - - - - - Qt::Vertical - - - - 438 - 137 - - - - - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - - - - - - - - - + + + CreateBlogMsg + + + + 0 + 0 + 666 + 515 + + + + New Blog Post + + + + :/images/rstray3.png:/images/rstray3.png + + + QToolBar#toolBar{background-image: url(:/images/connect/connectFriendBanner.png); +} + +QToolButton { + color: white; +} + +QToolBar#toolBar_2{ +background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, +stop:0 #FEFEFE, stop:1 #E8E8E8); + +border: 1px solid #CCCCCC;} + + + + + 0 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + + + QTabWidget::South + + + 0 + + + + Blog Post + + + + + + + + + 75 + true + + + + Blog Post to: + + + + + + + true + + + true + + + + + + + + + 0 + + + + Visual Editor + + + + + + Blog Message + + + + + + + + + 75 + true + + + + Subject : + + + + + + + + + + + + + + + + + + + Html Editor + + + + + + + + + + + + + + + :/images/attachment.png:/images/attachment.png + + + Attachments + + + + 0 + + + 0 + + + + + 0 + + + 6 + + + 6 + + + + + + + + :/images/attachment.png + + + + + + + + 16777215 + 26 + + + + + 75 + true + + + + Attachments + + + + + + + Qt::Horizontal + + + + 334 + 26 + + + + + + + + + 0 + 0 + + + + + 34 + 34 + + + + + + + + :/images/add-share24.png:/images/add-share24.png + + + + 24 + 24 + + + + + + + + + + Qt::ScrollBarAlwaysOn + + + true + + + + + 0 + 0 + 639 + 341 + + + + + + + + 0 + 0 + + + + true + + + Drag and Drop Files from Search Results + + + QFrame#fileFrame{border: 2px solid black; +background: white;} + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + + Qt::Vertical + + + + 438 + 137 + + + + + + + + + + + + + + + + + + + + + 0 + 0 + 666 + 21 + + + + + + + + 0 + 32 + + + + + 9 + + + + toolBar + + + TopToolBarArea + + + false + + + + + + + + toolBar_2 + + + TopToolBarArea + + + true + + + + + + true + + + + :/images/textedit/hi22-action-format-text-blockquote.png:/images/textedit/hi22-action-format-text-blockquote.png + + + blockquoute + + + + + + :/images/textedit/format_font_size_more.png:/images/textedit/format_font_size_more.png + + + Increase font Size + + + + + + :/images/textedit/format_font_size_less.png:/images/textedit/format_font_size_less.png + + + Decrease font size + + + + + + :/images/textedit/textbold.png:/images/textedit/textbold.png + + + Bold + + + + + + :/images/textedit/textunder.png:/images/textedit/textunder.png + + + Underline + + + + + + :/images/textedit/textitalic.png:/images/textedit/textitalic.png + + + Italic + + + + + Publish + + + + + New + + + + + + :/images/textedit/hi22-action-format-text-code.png:/images/textedit/hi22-action-format-text-code.png + + + Code + + + + + + :/images/textedit/hi22-action-insert-more-mark.png:/images/textedit/hi22-action-insert-more-mark.png + + + splitPost + + + + + + :/images/textedit/format-list-ordered.png:/images/textedit/format-list-ordered.png + + + Ordered List + + + + + + :/images/textedit/format-list-unordered.png:/images/textedit/format-list-unordered.png + + + Unordered List + + + + + true + + + + :/images/textedit/editcut.png:/images/textedit/editcut.png + + + Clipboard + + + + + + :/images/textedit/editundo.png:/images/textedit/editundo.png + + + Undo + + + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/images.qrc b/retroshare-gui/src/gui/images.qrc index e99d705cd..365117396 100644 --- a/retroshare-gui/src/gui/images.qrc +++ b/retroshare-gui/src/gui/images.qrc @@ -351,6 +351,9 @@ images/textedit/fileopen.png images/textedit/fileprint.png images/textedit/filesave.png + images/textedit/format-text-color.png + images/textedit/format-list-ordered.png + images/textedit/format-list-unordered.png images/textedit/zoomin.png images/textedit/zoomout.png images/textedit/format_font_size_more.png diff --git a/retroshare-gui/src/gui/images/textedit/format-list-ordered.png b/retroshare-gui/src/gui/images/textedit/format-list-ordered.png new file mode 100644 index 0000000000000000000000000000000000000000..043caa363e14840f008d8cb0a991aada75dc20db GIT binary patch literal 619 zcmV-x0+juUP)@z0u-CQ<~kq!mU{(u+cw1wo1jBUC&{ zARU7YL5j+Q)}ezJgFuij=Eb7IpvWK(5g9~=UPL^Ehe9HvptTH4^JUroEG&7I@dpp{ z%rJa;nEA$1sg#;K@^KyIxHi~gTwt1(E7jv_@EfBZCjiS4 z^qr7oCT{E%$4%_PFmClwFH{!uV8m(M4$@6iY8{4fYUPEl+P#+AQnX~uDEZwiURK?(g zgKMJO%)HA(llt4wFfx_ie+||x-f9E-%8R)1jP6Drjw*u?-LhxqEMfY{E`@ca={FXg zeS(33f!a{rD$tj^UeWxL&o~$9_FhOLuuN%60X`wF z|NsAINc$f-=RZUG|ESqec0fQtMMVWrM7ipJ)ZG6{KyuE1e}Dhvui5{ebH)s6Sco;Y&WM8ZjcL1Qz=6`$kpW&urQ@O1TaS?83{1OPzxcLe|d literal 0 HcmV?d00001 diff --git a/retroshare-gui/src/gui/images/textedit/format-text-color.png b/retroshare-gui/src/gui/images/textedit/format-text-color.png new file mode 100644 index 0000000000000000000000000000000000000000..98f61731166d44e43eafb99f8aea2f8f0391dd6a GIT binary patch literal 825 zcmV-91IGM`P)fLOc;aU$(C8;6kk|xpPND_h` zB9vADs33f)$e=grHL$`583sM2gNpuXBrTm43Uj-9r*pff@8tLw?;Y9) zKKJ)KJM6pPJ(tUv5Q6Mr&G7>S#CSv}(98xHiVy1JqBBnx*ajoC4dp7-;hji4{tfju zJPC{aO@wD{gQL-?f>MARd|zp&72%~KRs16b%ulp3d5YFikG?0xm8LCJjE;^j5#S_o zxm?b)&quStpt0(7zO0*==v(*|YFReDtwh4C_r%V*9S+K7{DY#vt4J}^s;InQIal50 zTrTg*c@`=%{zMs~wg>Y-K%K3rp*f##VoB3n$=cdOqT}oX9LF%WGXal2O;kln}p?Sh3xum*t)#&lmXV<+Kg7Nge$B-@$&rpRJwNCLOScBzyjA z!Yk}Xc??@&fVMLQ-@qQjFw%PpW&p)Y_GIvVlXl@B$BG;wl;?Vs00000NkvXXu0mjf DOE_|F literal 0 HcmV?d00001 diff --git a/retroshare-gui/src/gui/images/textedit/format-text-strikethrough.png b/retroshare-gui/src/gui/images/textedit/format-text-strikethrough.png new file mode 100644 index 0000000000000000000000000000000000000000..3e25ced5c2b7e719fc3b7f37f8f166607e426ab5 GIT binary patch literal 579 zcmV-J0=)f+P)MzCV_|S* zE^l&Yo9;Xs0005PNklXH>gXq!Po`ys|0ZR|%gyIz>?q&eDP&D$*MfZc;3 z@9H}|e2a5V8Ea_exUTa+{I2u5-%l?0drmsu*LkUZn-)j5wx{m!hACV;T&Bq|g#D?m zJb+JBMc%(4%NR)pOK6x8JhIqW8v^+7l|FJMbS;&r?cM%hi?cs*>mfPXI1Kjk7 zip_(~jZK@hIBK=9dQnT^Fh5aIAkQ3MndLK+e+r{;jdhUKt5KU*bg0T`Ihwsnl5x_E z(uL8b`x~mdjmF84f1h_`c!CTCutcRO9jH09w}B}>FpA6vu=yj!v7%I}?d7sO&NR=F z2@M|O9L7F1?>UZ#%Oea&gEKs)-Zw4T720Wp#qGt%C4yP2!4tT=jMcbn%8M@D2;7UZKbV0MRg{QEc7&~LjOMic(S R%ZUI0002ovPDHLkV1hht2TA|{ literal 0 HcmV?d00001 diff --git a/retroshare-gui/src/gui/msgs/ChanMsgDialog.cpp b/retroshare-gui/src/gui/msgs/ChanMsgDialog.cpp index e410a7790..b931853d3 100644 --- a/retroshare-gui/src/gui/msgs/ChanMsgDialog.cpp +++ b/retroshare-gui/src/gui/msgs/ChanMsgDialog.cpp @@ -783,9 +783,12 @@ void ChanMsgDialog::textFamily(const QString &f) void ChanMsgDialog::textSize(const QString &p) { - QTextCharFormat fmt; - fmt.setFontPointSize(p.toFloat()); - mergeFormatOnWordOrSelection(fmt); + qreal pointSize = p.toFloat(); + if (p.toFloat() > 0) { + QTextCharFormat fmt; + fmt.setFontPointSize(pointSize); + mergeFormatOnWordOrSelection(fmt); + } } void ChanMsgDialog::textStyle(int styleIndex)