From 5e2f46a5fc1c83544bb815aa0ce65fc587d0a2a8 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 1 Oct 2020 21:06:33 +0200 Subject: [PATCH] use the comments ID to create new comment --- .../src/gui/Posted/PostedCreatePostDialog.cpp | 15 ++++++++++++--- .../src/gui/Posted/PostedCreatePostDialog.h | 2 +- .../src/gui/Posted/PostedListWidgetWithModel.cpp | 6 ++++-- retroshare-gui/src/gui/gxs/GxsIdChooser.cpp | 2 +- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp index fada00020..7eb9cfc3a 100644 --- a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp +++ b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp @@ -44,7 +44,7 @@ #define VIEW_IMAGE 2 #define VIEW_LINK 3 -PostedCreatePostDialog::PostedCreatePostDialog(RsPosted *posted, const RsGxsGroupId& grpId, QWidget *parent): +PostedCreatePostDialog::PostedCreatePostDialog(RsPosted *posted, const RsGxsGroupId& grpId, const RsGxsId& default_author, QWidget *parent): QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint), mPosted(posted), mGrpId(grpId), ui(new Ui::PostedCreatePostDialog) @@ -69,8 +69,8 @@ PostedCreatePostDialog::PostedCreatePostDialog(RsPosted *posted, const RsGxsGrou ui->sizeWarningLabel->setText(QString("Post size is limited to %1 KB, pictures will be downscaled.").arg(MAXMESSAGESIZE / 1024)); /* fill in the available OwnIds for signing */ - ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, RsGxsId()); - + ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, default_author); + QSignalMapper *signalMapper = new QSignalMapper(this); connect(ui->postButton, SIGNAL(clicked()), signalMapper, SLOT(map())); connect(ui->imageButton, SIGNAL(clicked()), signalMapper, SLOT(map())); @@ -85,6 +85,15 @@ PostedCreatePostDialog::PostedCreatePostDialog(RsPosted *posted, const RsGxsGrou /* load settings */ processSettings(true); + + // Override the default ID, if supplied, since it is changed by processSettings + + if(!default_author.isNull()) + { + ui->idChooser->setChosenId(default_author); + + // should we save the ID in the settings here? I'm not sure we want this. + } } PostedCreatePostDialog::~PostedCreatePostDialog() diff --git a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h index 64ab35566..ba3defd06 100644 --- a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h +++ b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h @@ -39,7 +39,7 @@ public: * @param tokenQ parent callee token * @param posted */ - explicit PostedCreatePostDialog(RsPosted* posted, const RsGxsGroupId& grpId, QWidget *parent = 0); + explicit PostedCreatePostDialog(RsPosted* posted, const RsGxsGroupId& grpId, const RsGxsId& default_author=RsGxsId(),QWidget *parent = 0); ~PostedCreatePostDialog(); private: diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index d4bec080a..6b2f16a30 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -741,8 +741,10 @@ void PostedListWidgetWithModel::createMsg() if (!IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags)) { return; } - - PostedCreatePostDialog *msgDialog = new PostedCreatePostDialog(rsPosted,groupId()); + RsGxsId author_id; + ui->idChooser->getChosenId(author_id); +std::cerr << "Chosing default ID " << author_id<< std::endl; + PostedCreatePostDialog *msgDialog = new PostedCreatePostDialog(rsPosted,groupId(),author_id); msgDialog->show(); /* window will destroy itself! */ diff --git a/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp b/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp index 6235c025f..9321c4de4 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp @@ -313,7 +313,7 @@ void GxsIdChooser::setDefaultItem() } if (def >= 0) { - setCurrentIndex(def); + whileBlocking(this)->setCurrentIndex(def); #ifdef IDCHOOSER_DEBUG std::cerr << "GxsIdChooser-002" << (void*)this << " setting current index to " << def << std::endl; #endif