Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new rich text editor & redesigned Posted Composer #1740

Merged
merged 4 commits into from
Dec 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
50 changes: 41 additions & 9 deletions retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,41 @@
* *
*******************************************************************************/

#include <QBuffer>
#include <QBuffer>
#include <QMessageBox>
#include "PostedCreatePostDialog.h"
#include "ui_PostedCreatePostDialog.h"

#include "util/misc.h"
#include "util/TokenQueue.h"
#include "util/RichTextEdit.h"
#include "gui/feeds/SubFileItem.h"
#include "util/rsdir.h"

#include "gui/settings/rsharesettings.h"
#include <QBuffer>

#include <iostream>

PostedCreatePostDialog::PostedCreatePostDialog(TokenQueue* tokenQ, RsPosted *posted, const RsGxsGroupId& grpId, QWidget *parent):
QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint),
QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint),
mTokenQueue(tokenQ), mPosted(posted), mGrpId(grpId),
ui(new Ui::PostedCreatePostDialog)
{
ui->setupUi(this);
Settings->loadWidgetInformation(this);

connect(ui->submitButton, SIGNAL(clicked()), this, SLOT(createPost()));
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(close()));
connect(ui->pushButton, SIGNAL(clicked() ), this , SLOT(addPicture()));

ui->headerFrame->setHeaderImage(QPixmap(":/images/posted_64.png"));
ui->headerFrame->setHeaderText(tr("Submit a new Post"));
ui->headerFrame->setHeaderImage(QPixmap(":/icons/png/postedlinks.png"));
ui->headerFrame->setHeaderText(tr("Create a new Post"));

setAttribute ( Qt::WA_DeleteOnClose, true );

ui->RichTextEditWidget->setPlaceHolderTextPosted();

/* fill in the available OwnIds for signing */
ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, RsGxsId());
}
Expand Down Expand Up @@ -78,10 +84,21 @@ void PostedCreatePostDialog::createPost()
RsPostedPost post;
post.mMeta.mGroupId = mGrpId;
post.mLink = std::string(ui->linkEdit->text().toUtf8());
post.mNotes = std::string(ui->notesTextEdit->toPlainText().toUtf8());
post.mMeta.mMsgName = std::string(ui->titleEdit->text().toUtf8());
post.mMeta.mAuthorId = authorId;

QString text;
text = ui->RichTextEditWidget->toHtml();
post.mNotes = std::string(text.toUtf8());

post.mMeta.mAuthorId = authorId;

if(!ui->titleEdit->text().isEmpty())
{
post.mMeta.mMsgName = std::string(ui->titleEdit->text().toUtf8());
}else
{
post.mMeta.mMsgName = std::string(ui->titleEditLink->text().toUtf8());
}

QByteArray ba;
QBuffer buffer(&ba);

Expand All @@ -94,7 +111,7 @@ void PostedCreatePostDialog::createPost()
post.mImage.copy((uint8_t *) ba.data(), ba.size());
}

if(ui->titleEdit->text().isEmpty()) {
if(ui->titleEdit->text().isEmpty()&& ui->titleEditLink->text().isEmpty()) {
/* error message */
QMessageBox::warning(this, "RetroShare", tr("Please add a Title"), QMessageBox::Ok, QMessageBox::Ok);
return; //Don't add a empty title!!
Expand All @@ -118,4 +135,19 @@ void PostedCreatePostDialog::addPicture()

// to show the selected
ui->imageLabel->setPixmap(picture);
}
}

void PostedCreatePostDialog::on_postButton_clicked()
{
ui->stackedWidget->setCurrentIndex(0);
}

void PostedCreatePostDialog::on_imageButton_clicked()
{
ui->stackedWidget->setCurrentIndex(1);
}

void PostedCreatePostDialog::on_linkButton_clicked()
{
ui->stackedWidget->setCurrentIndex(2);
}
7 changes: 5 additions & 2 deletions retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <QDialog>
#include "retroshare/rsposted.h"
#include "util/RichTextEdit.h"

class TokenQueue;

Expand All @@ -41,13 +42,15 @@ class PostedCreatePostDialog : public QDialog
*/
explicit PostedCreatePostDialog(TokenQueue* tokenQ, RsPosted* posted, const RsGxsGroupId& grpId, QWidget *parent = 0);
~PostedCreatePostDialog();

QPixmap picture;

private slots:
void createPost();
void addPicture();

void on_postButton_clicked();
void on_imageButton_clicked();
void on_linkButton_clicked();

private:
QString mLink;
Expand Down