diff --git a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp index 2dea36101..c822bb492 100644 --- a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp +++ b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp @@ -25,7 +25,7 @@ #include "util/misc.h" #include "util/TokenQueue.h" -#include "util/MRichTextEdit.h" +#include "util/RichTextEdit.h" #include "gui/feeds/SubFileItem.h" #include "util/rsdir.h" @@ -51,7 +51,7 @@ PostedCreatePostDialog::PostedCreatePostDialog(TokenQueue* tokenQ, RsPosted *pos setAttribute ( Qt::WA_DeleteOnClose, true ); - ui->MRichTextEditWidget->setPlaceHolderTextPosted(); + ui->RichTextEditWidget->setPlaceHolderTextPosted(); /* fill in the available OwnIds for signing */ ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, RsGxsId()); @@ -86,7 +86,7 @@ void PostedCreatePostDialog::createPost() post.mLink = std::string(ui->linkEdit->text().toUtf8()); QString text; - text = ui->MRichTextEditWidget->toHtml(); + text = ui->RichTextEditWidget->toHtml(); post.mNotes = std::string(text.toUtf8()); post.mMeta.mAuthorId = authorId; diff --git a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h index 212faa159..de13358fb 100644 --- a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h +++ b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h @@ -23,7 +23,7 @@ #include #include "retroshare/rsposted.h" -#include "util/MRichTextEdit.h" +#include "util/RichTextEdit.h" class TokenQueue; diff --git a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.ui b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.ui index 97ad94741..d64c3ad01 100644 --- a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.ui +++ b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.ui @@ -278,7 +278,7 @@ 0 - + @@ -467,9 +467,9 @@
gui/gxs/GxsIdChooser.h
- MRichTextEdit + RichTextEdit QWidget -
util/MRichTextEdit.h
+
util/RichTextEdit.h
1
diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp index fa038f7fc..85f89f3dc 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp @@ -33,6 +33,7 @@ #include "util/HandleRichText.h" #include "util/misc.h" #include "util/rsdir.h" +#include "util/RichTextEdit.h" #include @@ -55,7 +56,7 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId Settings->loadWidgetInformation(this); mChannelQueue = new TokenQueue(rsGxsChannels->getTokenService(), this); - headerFrame->setHeaderImage(QPixmap(":/images/channels.png")); + headerFrame->setHeaderImage(QPixmap(":/icons/png/channel.png")); if(!existing_post.isNull()) headerFrame->setHeaderText(tr("Edit Channel Post")); @@ -64,17 +65,19 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId setAttribute ( Qt::WA_DeleteOnClose, true ); + buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Post")); + connect(buttonBox, SIGNAL(accepted()), this, SLOT(sendMsg())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(cancelMsg())); connect(addFileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile())); - connect(addfilepushButton, SIGNAL(clicked() ), this , SLOT(addExtraFile())); + connect(addfilepushButton, SIGNAL(clicked() ), this , SLOT(addExtraFile())); + connect(addThumbnailButton, SIGNAL(clicked() ), this , SLOT(addThumbnail())); connect(thumbNailCb, SIGNAL(toggled(bool)), this, SLOT(allowAutoMediaThumbNail(bool))); - connect(tabWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenu(QPoint))); + connect(stackedWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenu(QPoint))); connect(generateCheckBox, SIGNAL(toggled(bool)), generateSpinBox, SLOT(setEnabled(bool))); - connect(addPictureButton, SIGNAL(clicked()), this, SLOT(addPicture())); - connect(msgEdit, SIGNAL(textChanged()), this, SLOT(checkLength())); + generateSpinBox->setEnabled(false); thumbNailCb->setVisible(false); @@ -84,7 +87,6 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId thumbNailCb->setVisible(true); thumbNailCb->setEnabled(true); #endif - //buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); setAcceptDrops(true); @@ -95,27 +97,7 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId generateSpinBox->hide(); #endif } - -static const uint32_t MAX_ALLOWED_GXS_MESSAGE_SIZE = 199000; - -void CreateGxsChannelMsg::checkLength() -{ - QString text; - RsHtml::optimizeHtml(msgEdit, text); - std::wstring msg = text.toStdWString(); - int charRemains = MAX_ALLOWED_GXS_MESSAGE_SIZE - msg.length(); - if(charRemains >= 0) { - text = tr("It remains %1 characters after HTML conversion.").arg(charRemains); - infoLabel->setStyleSheet("QLabel#infoLabel { }"); - }else{ - text = tr("Warning: This message is too big of %1 characters after HTML conversion.").arg((0-charRemains)); - infoLabel->setStyleSheet("QLabel#infoLabel {color: red; font: bold; }"); - } - buttonBox->button(QDialogButtonBox::Ok)->setToolTip(text); - buttonBox->button(QDialogButtonBox::Ok)->setEnabled(charRemains>=0); - infoLabel->setText(text); -} - + CreateGxsChannelMsg::~CreateGxsChannelMsg() { Settings->saveWidgetInformation(this); @@ -442,7 +424,7 @@ void CreateGxsChannelMsg::addSubject(const QString& text) void CreateGxsChannelMsg::addHtmlText(const QString& text) { - msgEdit->setHtml(text) ; + RichTextEditWidget->setText(text) ; } void CreateGxsChannelMsg::addAttachment(const std::string &path) @@ -650,8 +632,9 @@ void CreateGxsChannelMsg::sendMsg() /* construct message bits */ std::string subject = std::string(misc::removeNewLine(subjectEdit->text()).toUtf8()); + QString text; - RsHtml::optimizeHtml(msgEdit, text); + text = RichTextEditWidget->toHtml(); std::string msg = std::string(text.toUtf8()); std::list files; @@ -763,18 +746,6 @@ void CreateGxsChannelMsg::addThumbnail() thumbnail_label->setPixmap(picture); } -void CreateGxsChannelMsg::addPicture() -{ - QString file; - if (misc::getOpenFileName(window(), RshareSettings::LASTDIR_IMAGES, tr("Load Picture File"), "Pictures (*.png *.xpm *.jpg *.jpeg)", file)) { - QString encodedImage; - if (RsHtml::makeEmbeddedImage(file, encodedImage, 640*480, MAX_ALLOWED_GXS_MESSAGE_SIZE - 200)) { - QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(encodedImage); - msgEdit->textCursor().insertFragment(fragment); - } - } -} - void CreateGxsChannelMsg::loadChannelPostInfo(const uint32_t &token) { #ifdef DEBUG_CREATE_GXS_MSG @@ -801,13 +772,16 @@ void CreateGxsChannelMsg::loadChannelPostInfo(const uint32_t &token) } subjectEdit->setText(QString::fromUtf8(post.mMeta.mMsgName.c_str())) ; - msgEdit->setText(QString::fromUtf8(post.mMsg.c_str())) ; + RichTextEditWidget->setText(QString::fromUtf8(post.mMsg.c_str())); for(std::list::const_iterator it(post.mFiles.begin());it!=post.mFiles.end();++it) addAttachment(it->mHash,it->mName,it->mSize,true,RsPeerId(),true); - GxsIdDetails::loadPixmapFromData(post.mThumbnail.mData,post.mThumbnail.mSize,picture,GxsIdDetails::ORIGINAL); - thumbnail_label->setPixmap(picture); + if(post.mThumbnail.mData != NULL) + { + GxsIdDetails::loadPixmapFromData(post.mThumbnail.mData,post.mThumbnail.mSize,picture,GxsIdDetails::ORIGINAL); + thumbnail_label->setPixmap(picture); + } } void CreateGxsChannelMsg::loadChannelInfo(const uint32_t &token) @@ -856,3 +830,13 @@ void CreateGxsChannelMsg::loadRequest(const TokenQueue *queue, const TokenReques } } } + +void CreateGxsChannelMsg::on_channelpostButton_clicked() +{ + stackedWidget->setCurrentIndex(0); +} + +void CreateGxsChannelMsg::on_attachmentsButton_clicked() +{ + stackedWidget->setCurrentIndex(1); +} diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h index 96b9dd6d3..1347a96c2 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h @@ -69,10 +69,10 @@ private slots: void contextMenu(QPoint) ; void addThumbnail(); - void addPicture(); - void checkLength(); void allowAutoMediaThumbNail(bool); + void on_channelpostButton_clicked(); + void on_attachmentsButton_clicked(); private: void loadChannelInfo(const uint32_t &token); void loadChannelPostInfo(const uint32_t &token); diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui index 8b53c93d6..5086f4acb 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui @@ -37,7 +37,11 @@ 0 - + + + QFrame::Plain + + @@ -47,9 +51,56 @@ QFrame::Raised - + - + + + Channel Post + + + + :/icons/png/comment.png:/icons/png/comment.png + + + + 24 + 24 + + + + + + + + Attachments + + + + :/icons/png/attachements.png:/icons/png/attachements.png + + + + 24 + 24 + + + + + + + + Qt::Horizontal + + + + 486 + 20 + + + + + + true @@ -62,15 +113,138 @@ 0 - - - Channel Post - - - + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + 156 + 107 + + + + + 0 + 0 + + + + :/images/thumb-default-video.png + + + + + + + <!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:'Ubuntu'; font-size:11pt; 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-family:'MS Shell Dlg 2'; font-size:10pt; font-weight:600;">Attachments:</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/images/feedback_arrow.png" /><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;"> Use Drag and Drop / Add Files button, to Hash new files.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/images/feedback_arrow.png" /><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;"> Copy/Paste RetroShare links from your shares</span></p></body></html> + + + + + + + Add Channel Thumbnail + + + + :/icons/png/add-image.png:/icons/png/add-image.png + + + + 24 + 24 + + + + + + + + Add File to Attach + + + + :/icons/png/add-file.png:/icons/png/add-file.png + + + + 24 + 24 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 40 + 20 + + + + + + + + + + Message + + + + 0 + + + + + Title + + + + + + + + + + + + + 0 + 0 + + 75 @@ -94,138 +268,22 @@ - - - - - - Add File to Attach - - - - :/images/add-share24.png:/images/add-share24.png - - - - - - - Add Channel Thumbnail - - - - :/images/add_image24.png:/images/add_image24.png - - - - - - - Add Picture - - - - :/images/add_image24.png:/images/add_image24.png - - - - - - - <!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:'Ubuntu'; font-size:11pt; 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-family:'MS Shell Dlg 2'; font-size:10pt; font-weight:600;">Attachments:</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/images/feedback_arrow.png" /><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;"> Use Drag and Drop / Add Files button, to Hash new files.</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/images/feedback_arrow.png" /><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;"> Copy/Paste RetroShare links from your shares</span></p></body></html> - - - - - - - - - - 156 - 107 - - - - - 0 - 0 - - - - :/images/thumb-default-video.png - - - - - - - Qt::Horizontal - - - - 12 - 98 - - - - - - - - Message - - - - - - - - - 75 - true - - - - Subject : - - - - - - - - - - - - - - - - - - - - - - - - - :/images/attachment.png:/images/attachment.png - - - Attachments - + + + 0 + + + 0 + + + 0 + + + 0 + @@ -286,8 +344,8 @@ p, li { white-space: pre-wrap; } - - :/images/add-share24.png:/images/add-share24.png + + :/icons/png/add-file.png:/icons/png/add-file.png @@ -320,7 +378,7 @@ p, li { white-space: pre-wrap; } 0 0 - 812 + 81 24 @@ -371,7 +429,7 @@ p, li { white-space: pre-wrap; } - + @@ -392,6 +450,9 @@ p, li { white-space: pre-wrap; } + + + Qt::Horizontal @@ -408,19 +469,21 @@ p, li { white-space: pre-wrap; } - - MimeTextEdit - QTextEdit -
gui/common/MimeTextEdit.h
-
HeaderFrame QFrame
gui/common/HeaderFrame.h
1
+ + RichTextEdit + QWidget +
util/RichTextEdit.h
+ 1 +
+ diff --git a/retroshare-gui/src/gui/icons.qrc b/retroshare-gui/src/gui/icons.qrc index b513696b2..04a6702b1 100644 --- a/retroshare-gui/src/gui/icons.qrc +++ b/retroshare-gui/src/gui/icons.qrc @@ -116,7 +116,7 @@ icons/png/newsfeed-notify.png icons/png/newsfeed.png icons/png/options.png - icons/png/pencil-edit-button.png + icons/png/pencil-edit-button.png icons/png/people-notify.png icons/png/people.png icons/png/person.png @@ -134,7 +134,7 @@ icons/png/thumbs-down.png icons/png/thumbs-neutral.png icons/png/thumbs-up.png - icons/png/typing.png + icons/png/typing.png icons/png/video.png icons/posted_128.png icons/posted_red_128.png @@ -306,5 +306,8 @@ icons/textedit/redo.png icons/textedit/undo.png icons/textedit/settings.png + icons/png/add-file.png + icons/png/add-image.png + icons/png/attachements.png diff --git a/retroshare-gui/src/gui/icons/png/add-file.png b/retroshare-gui/src/gui/icons/png/add-file.png new file mode 100644 index 000000000..e9574feaf Binary files /dev/null and b/retroshare-gui/src/gui/icons/png/add-file.png differ diff --git a/retroshare-gui/src/gui/icons/png/add-image.png b/retroshare-gui/src/gui/icons/png/add-image.png new file mode 100644 index 000000000..68c176be4 Binary files /dev/null and b/retroshare-gui/src/gui/icons/png/add-image.png differ diff --git a/retroshare-gui/src/gui/icons/png/attachements.png b/retroshare-gui/src/gui/icons/png/attachements.png new file mode 100644 index 000000000..1d0941a5d Binary files /dev/null and b/retroshare-gui/src/gui/icons/png/attachements.png differ diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index 7f79672ff..188bd9546 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -626,7 +626,7 @@ HEADERS += rshare.h \ gui/statistics/BWGraph.h \ util/RsSyntaxHighlighter.h \ util/imageutil.h \ - util/MRichTextEdit.h \ + util/RichTextEdit.h \ gui/NetworkDialog/pgpid_item_model.h \ gui/NetworkDialog/pgpid_item_proxy.h \ gui/common/RsCollection.h \ @@ -749,7 +749,7 @@ FORMS += gui/StartDialog.ui \ gui/statistics/BwCtrlWindow.ui \ gui/statistics/RttStatistics.ui \ gui/GetStartedDialog.ui \ - util/MRichTextEdit.ui + util/RichTextEdit.ui # gui/ForumsDialog.ui \ @@ -827,7 +827,7 @@ SOURCES += main.cpp \ util/HandleRichText.cpp \ util/ObjectPainter.cpp \ util/RsFile.cpp \ - util/MRichTextEdit.cpp \ + util/RichTextEdit.cpp \ gui/profile/ProfileWidget.cpp \ gui/profile/StatusMessage.cpp \ gui/profile/ProfileManager.cpp \ diff --git a/retroshare-gui/src/util/MRichTextEdit.cpp b/retroshare-gui/src/util/RichTextEdit.cpp similarity index 85% rename from retroshare-gui/src/util/MRichTextEdit.cpp rename to retroshare-gui/src/util/RichTextEdit.cpp index d2717fec1..541e6c3eb 100644 --- a/retroshare-gui/src/util/MRichTextEdit.cpp +++ b/retroshare-gui/src/util/RichTextEdit.cpp @@ -1,29 +1,24 @@ -/* -** Copyright (C) 2019 by defnax -** -** Copyright (C) 2013 Jiří Procházka (Hobrasoft) -** Contact: http://www.hobrasoft.cz/ -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file is under the terms of the GNU Lesser General Public License -** version 2.1 as published by the Free Software Foundation and appearing -** in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the -** GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -*/ +/******************************************************************************* + * util/RichTextEdit.cpp * + * * + * Copyright (c) 2019 Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ -#include "MRichTextEdit.h" +#include "RichTextEdit.h" #include #include #include @@ -47,7 +42,7 @@ static const uint32_t MAX_ALLOWED_GXS_MESSAGE_SIZE = 199000; -MRichTextEdit::MRichTextEdit(QWidget *parent) : QWidget(parent) { +RichTextEdit::RichTextEdit(QWidget *parent) : QWidget(parent) { setupUi(this); m_lastBlockList = 0; f_textedit->setTabStopWidth(40); @@ -196,14 +191,14 @@ MRichTextEdit::MRichTextEdit(QWidget *parent) : QWidget(parent) { // images connect(f_image, SIGNAL(clicked()), this, SLOT(insertImage())); - + // check message length connect(f_textedit, SIGNAL(textChanged()), this, SLOT(checkLength())); } -void MRichTextEdit::textSource() { +void RichTextEdit::textSource() { QDialog *dialog = new QDialog(this); QPlainTextEdit *pte = new QPlainTextEdit(dialog); pte->setPlainText( f_textedit->toHtml() ); @@ -220,7 +215,7 @@ void MRichTextEdit::textSource() { } -void MRichTextEdit::textRemoveFormat() { +void RichTextEdit::textRemoveFormat() { QTextCharFormat fmt; fmt.setFontWeight(QFont::Normal); fmt.setFontUnderline (false); @@ -246,7 +241,7 @@ void MRichTextEdit::textRemoveFormat() { } -void MRichTextEdit::textRemoveAllFormat() { +void RichTextEdit::textRemoveAllFormat() { f_bold ->setChecked(false); f_underline ->setChecked(false); f_italic ->setChecked(false); @@ -257,37 +252,37 @@ void MRichTextEdit::textRemoveAllFormat() { } -void MRichTextEdit::textBold() { +void RichTextEdit::textBold() { QTextCharFormat fmt; fmt.setFontWeight(f_bold->isChecked() ? QFont::Bold : QFont::Normal); mergeFormatOnWordOrSelection(fmt); } -void MRichTextEdit::focusInEvent(QFocusEvent *) { +void RichTextEdit::focusInEvent(QFocusEvent *) { f_textedit->setFocus(Qt::TabFocusReason); } -void MRichTextEdit::textUnderline() { +void RichTextEdit::textUnderline() { QTextCharFormat fmt; fmt.setFontUnderline(f_underline->isChecked()); mergeFormatOnWordOrSelection(fmt); } -void MRichTextEdit::textItalic() { +void RichTextEdit::textItalic() { QTextCharFormat fmt; fmt.setFontItalic(f_italic->isChecked()); mergeFormatOnWordOrSelection(fmt); } -void MRichTextEdit::textStrikeout() { +void RichTextEdit::textStrikeout() { QTextCharFormat fmt; fmt.setFontStrikeOut(f_strikeout->isChecked()); mergeFormatOnWordOrSelection(fmt); } -void MRichTextEdit::textSize(const QString &p) { +void RichTextEdit::textSize(const QString &p) { qreal pointSize = p.toFloat(); if (p.toFloat() > 0) { QTextCharFormat fmt; @@ -296,7 +291,7 @@ void MRichTextEdit::textSize(const QString &p) { } } -void MRichTextEdit::textLink(bool checked) { +void RichTextEdit::textLink(bool checked) { bool unlink = false; QTextCharFormat fmt; if (checked) { @@ -325,7 +320,7 @@ void MRichTextEdit::textLink(bool checked) { mergeFormatOnWordOrSelection(fmt); } -void MRichTextEdit::textStyle(int index) { +void RichTextEdit::textStyle(int index) { QTextCursor cursor = f_textedit->textCursor(); cursor.beginEditBlock(); @@ -371,7 +366,7 @@ void MRichTextEdit::textStyle(int index) { cursor.endEditBlock(); } -void MRichTextEdit::textFgColor() { +void RichTextEdit::textFgColor() { QColor col = QColorDialog::getColor(f_textedit->textColor(), this); QTextCursor cursor = f_textedit->textCursor(); if (!cursor.hasSelection()) { @@ -388,7 +383,7 @@ void MRichTextEdit::textFgColor() { fgColorChanged(col); } -void MRichTextEdit::textBgColor() { +void RichTextEdit::textBgColor() { QColor col = QColorDialog::getColor(f_textedit->textBackgroundColor(), this); QTextCursor cursor = f_textedit->textCursor(); if (!cursor.hasSelection()) { @@ -405,21 +400,21 @@ void MRichTextEdit::textBgColor() { bgColorChanged(col); } -void MRichTextEdit::listBullet(bool checked) { +void RichTextEdit::listBullet(bool checked) { if (checked) { f_list_ordered->setChecked(false); } list(checked, QTextListFormat::ListDisc); } -void MRichTextEdit::listOrdered(bool checked) { +void RichTextEdit::listOrdered(bool checked) { if (checked) { f_list_bullet->setChecked(false); } list(checked, QTextListFormat::ListDecimal); } -void MRichTextEdit::list(bool checked, QTextListFormat::Style style) { +void RichTextEdit::list(bool checked, QTextListFormat::Style style) { QTextCursor cursor = f_textedit->textCursor(); cursor.beginEditBlock(); if (!checked) { @@ -438,7 +433,7 @@ void MRichTextEdit::list(bool checked, QTextListFormat::Style style) { cursor.endEditBlock(); } -void MRichTextEdit::mergeFormatOnWordOrSelection(const QTextCharFormat &format) { +void RichTextEdit::mergeFormatOnWordOrSelection(const QTextCharFormat &format) { QTextCursor cursor = f_textedit->textCursor(); if (!cursor.hasSelection()) { cursor.select(QTextCursor::WordUnderCursor); @@ -448,7 +443,7 @@ void MRichTextEdit::mergeFormatOnWordOrSelection(const QTextCharFormat &format) f_textedit->setFocus(Qt::TabFocusReason); } -void MRichTextEdit::slotCursorPositionChanged() { +void RichTextEdit::slotCursorPositionChanged() { QTextList *l = f_textedit->textCursor().currentList(); if (m_lastBlockList && (l == m_lastBlockList || (l != 0 && m_lastBlockList != 0 && l->format().style() == m_lastBlockList->format().style()))) { @@ -473,7 +468,7 @@ void MRichTextEdit::slotCursorPositionChanged() { } } -void MRichTextEdit::fontChanged(const QFont &f) { +void RichTextEdit::fontChanged(const QFont &f) { f_fontsize->setCurrentIndex(f_fontsize->findText(QString::number(f.pointSize()))); f_bold->setChecked(f.bold()); f_italic->setChecked(f.italic()); @@ -512,7 +507,7 @@ void MRichTextEdit::fontChanged(const QFont &f) { } } -void MRichTextEdit::fgColorChanged(const QColor &c) { +void RichTextEdit::fgColorChanged(const QColor &c) { QPixmap pix(16, 16); if (c.isValid()) { pix.fill(c); @@ -522,7 +517,7 @@ void MRichTextEdit::fgColorChanged(const QColor &c) { f_fgcolor->setIcon(pix); } -void MRichTextEdit::bgColorChanged(const QColor &c) { +void RichTextEdit::bgColorChanged(const QColor &c) { QPixmap pix(16, 16); if (c.isValid()) { pix.fill(c); @@ -532,21 +527,21 @@ void MRichTextEdit::bgColorChanged(const QColor &c) { f_bgcolor->setIcon(pix); } -void MRichTextEdit::slotCurrentCharFormatChanged(const QTextCharFormat &format) { +void RichTextEdit::slotCurrentCharFormatChanged(const QTextCharFormat &format) { fontChanged(format.font()); bgColorChanged((format.background().isOpaque()) ? format.background().color() : QColor()); fgColorChanged((format.foreground().isOpaque()) ? format.foreground().color() : QColor()); f_link->setChecked(format.isAnchor()); } -void MRichTextEdit::slotClipboardDataChanged() { +void RichTextEdit::slotClipboardDataChanged() { #ifndef QT_NO_CLIPBOARD if (const QMimeData *md = QApplication::clipboard()->mimeData()) f_paste->setEnabled(md->hasText()); #endif } -QString MRichTextEdit::toHtml() const { +QString RichTextEdit::toHtml() const { QString s = f_textedit->toHtml(); // convert emails to links s = s.replace(QRegExp("(<[^a][^>]+>(?:]+>)?|\\s)([a-zA-Z\\d]+@[a-zA-Z\\d]+\\.[a-zA-Z]+)"), "\\1\\2"); @@ -556,15 +551,15 @@ QString MRichTextEdit::toHtml() const { return s; } -void MRichTextEdit::increaseIndentation() { +void RichTextEdit::increaseIndentation() { indent(+1); } -void MRichTextEdit::decreaseIndentation() { +void RichTextEdit::decreaseIndentation() { indent(-1); } -void MRichTextEdit::indent(int delta) { +void RichTextEdit::indent(int delta) { QTextCursor cursor = f_textedit->textCursor(); cursor.beginEditBlock(); QTextBlockFormat bfmt = cursor.blockFormat(); @@ -576,7 +571,7 @@ void MRichTextEdit::indent(int delta) { cursor.endEditBlock(); } -void MRichTextEdit::setText(const QString& text) { +void RichTextEdit::setText(const QString& text) { if (text.isEmpty()) { setPlainText(text); return; @@ -588,7 +583,7 @@ void MRichTextEdit::setText(const QString& text) { } } -void MRichTextEdit::insertImage() { +void RichTextEdit::insertImage() { QString file; if (misc::getOpenFileName(window(), RshareSettings::LASTDIR_IMAGES, tr("Load Picture File"), "Pictures (*.png *.xpm *.jpg *.jpeg)", file)) { QString encodedImage; @@ -599,7 +594,7 @@ void MRichTextEdit::insertImage() { } } -void MRichTextEdit::checkLength(){ +void RichTextEdit::checkLength(){ QString text; RsHtml::optimizeHtml(f_textedit, text); std::wstring msg = text.toStdWString(); @@ -615,6 +610,7 @@ void MRichTextEdit::checkLength(){ f_info->setText(text); } -void MRichTextEdit::setPlaceHolderTextPosted() { + +void RichTextEdit::setPlaceHolderTextPosted() { f_textedit->setPlaceholderText(tr("Text (optional)")); } diff --git a/retroshare-gui/src/util/MRichTextEdit.h b/retroshare-gui/src/util/RichTextEdit.h similarity index 55% rename from retroshare-gui/src/util/MRichTextEdit.h rename to retroshare-gui/src/util/RichTextEdit.h index 68ca1dd40..8a4c95eba 100644 --- a/retroshare-gui/src/util/MRichTextEdit.h +++ b/retroshare-gui/src/util/RichTextEdit.h @@ -1,41 +1,36 @@ -/* -** Copyright (C) 2019 by defnax -** -** Copyright (C) 2013 Jiří Procházka (Hobrasoft) -** Contact: http://www.hobrasoft.cz/ -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file is under the terms of the GNU Lesser General Public License -** version 2.1 as published by the Free Software Foundation and appearing -** in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the -** GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -*/ +/******************************************************************************* + * util/RichTextEdit.h * + * * + * Copyright (c) 2019 Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ -#ifndef _MRICHTEXTEDIT_H_ -#define _MRICHTEXTEDIT_H_ +#ifndef _RICHTEXTEDIT_H_ +#define _RICHTEXTEDIT_H_ #include -#include "ui_MRichTextEdit.h" +#include "ui_RichTextEdit.h" /** * @Brief A simple rich-text editor */ -class MRichTextEdit : public QWidget, protected Ui::MRichTextEdit { +class RichTextEdit : public QWidget, protected Ui::RichTextEdit { Q_OBJECT public: - MRichTextEdit(QWidget *parent = 0); + RichTextEdit(QWidget *parent = 0); QString toPlainText() const { return f_textedit->toPlainText(); } QString toHtml() const; @@ -47,7 +42,7 @@ class MRichTextEdit : public QWidget, protected Ui::MRichTextEdit { void setText(const QString &text); void setPlaceHolderTextPosted(); - + protected slots: void setPlainText(const QString &text) { f_textedit->setPlainText(text); } void setHtml(const QString &text) { f_textedit->setHtml(text); } diff --git a/retroshare-gui/src/util/MRichTextEdit.ui b/retroshare-gui/src/util/RichTextEdit.ui similarity index 97% rename from retroshare-gui/src/util/MRichTextEdit.ui rename to retroshare-gui/src/util/RichTextEdit.ui index 27c63689f..7b5ffc6ae 100644 --- a/retroshare-gui/src/util/MRichTextEdit.ui +++ b/retroshare-gui/src/util/RichTextEdit.ui @@ -1,12 +1,12 @@ - MRichTextEdit - + RichTextEdit + 0 0 - 699 + 703 312 @@ -62,6 +62,12 @@
+ + + MS Sans Serif + 10 + + Qt::ClickFocus @@ -557,6 +563,12 @@ + + + MS Sans Serif + 9 + + QTextEdit::AutoNone