load/save prefered identity for voting in posted

This commit is contained in:
csoler 2020-02-12 21:10:35 +01:00
parent a498d4e370
commit 01c4534a20
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
2 changed files with 41 additions and 15 deletions

View File

@ -27,6 +27,7 @@
#include "util/qtthreadsutils.h"
#include "gui/gxs/GxsIdDetails.h"
#include "PostedCreatePostDialog.h"
#include "gui/settings/rsharesettings.h"
#include "PostedItem.h"
#include "PostedCardView.h"
#include "gui/common/UIStateHelper.h"
@ -113,6 +114,7 @@ PostedListWidget::PostedListWidget(const RsGxsGroupId &postedId, QWidget *parent
/* Initialize GUI */
setGroupId(postedId);
}
PostedListWidget::~PostedListWidget()
{
// save settings
@ -147,16 +149,37 @@ void PostedListWidget::processSettings(bool load)
{
Settings->beginGroup(QString("PostedListWidget"));
if (load) {
if (load)
{
// load settings
/* View mode */
setViewMode(Settings->value("viewMode", VIEW_MODE_CLASSIC).toInt());
} else {
RsGxsId voteId(Settings->value("defaultIdentity",QString()).toString().toStdString());
if(!voteId.isNull())
ui->idChooser->setChosenId(voteId);
}
else
{
// save settings
/* View mode */
Settings->setValue("viewMode", viewMode());
RsGxsId voteId;
switch (ui->idChooser->getChosenId(voteId))
{
case GxsIdChooser::KnowId:
case GxsIdChooser::UnKnowId: Settings->setValue("defaultIdentity",QString::fromStdString(voteId.toStdString()));
break;
default:
case GxsIdChooser::NoId:
case GxsIdChooser::None:
break;
}
}
Settings->endGroup();
@ -310,10 +333,10 @@ void PostedListWidget::submitVote(const RsGxsGrpMsgIdPair &msgId, bool up)
std::cerr << "PostedListWidget::createPost() ERROR GETTING AuthorId!, Vote Failed";
std::cerr << std::endl;
QMessageBox::warning(this, tr("RetroShare"),tr("Please create or choose a Signing Id before Voting"), QMessageBox::Ok, QMessageBox::Ok);
QMessageBox::warning(this, tr("RetroShare"),tr("Please create or choose a default identity to use for voting"), QMessageBox::Ok, QMessageBox::Ok);
return;
}//switch (ui.idChooser->getChosenId(authorId))
}
RsGxsVote vote;
@ -322,11 +345,10 @@ void PostedListWidget::submitVote(const RsGxsGrpMsgIdPair &msgId, bool up)
vote.mMeta.mParentId = msgId.second;
vote.mMeta.mAuthorId = authorId;
if (up) {
if (up)
vote.mVoteType = GXS_VOTE_UP;
} else { //if (up)
else
vote.mVoteType = GXS_VOTE_DOWN;
}//if (up)
#ifdef DEBUG_POSTED_LIST_WIDGET
std::cerr << "PostedListWidget::submitVote()";

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>616</width>
<height>595</height>
<width>950</width>
<height>771</height>
</rect>
</property>
<property name="windowTitle">
@ -250,7 +250,11 @@
</widget>
</item>
<item>
<widget class="GxsIdChooser" name="idChooser"/>
<widget class="GxsIdChooser" name="idChooser">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Default identity used when voting&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
@ -508,7 +512,7 @@
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;Description&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textInteractionFlags">
@ -557,7 +561,7 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>614</width>
<width>98</width>
<height>16</height>
</rect>
</property>
@ -613,7 +617,7 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>614</width>
<width>948</width>
<height>16</height>
</rect>
</property>
@ -667,9 +671,9 @@ p, li { white-space: pre-wrap; }
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>
<include location="../icons.qrc"/>
<include location="Posted_images.qrc"/>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>