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 "util/qtthreadsutils.h"
#include "gui/gxs/GxsIdDetails.h" #include "gui/gxs/GxsIdDetails.h"
#include "PostedCreatePostDialog.h" #include "PostedCreatePostDialog.h"
#include "gui/settings/rsharesettings.h"
#include "PostedItem.h" #include "PostedItem.h"
#include "PostedCardView.h" #include "PostedCardView.h"
#include "gui/common/UIStateHelper.h" #include "gui/common/UIStateHelper.h"
@ -113,6 +114,7 @@ PostedListWidget::PostedListWidget(const RsGxsGroupId &postedId, QWidget *parent
/* Initialize GUI */ /* Initialize GUI */
setGroupId(postedId); setGroupId(postedId);
} }
PostedListWidget::~PostedListWidget() PostedListWidget::~PostedListWidget()
{ {
// save settings // save settings
@ -147,16 +149,37 @@ void PostedListWidget::processSettings(bool load)
{ {
Settings->beginGroup(QString("PostedListWidget")); Settings->beginGroup(QString("PostedListWidget"));
if (load) { if (load)
{
// load settings // load settings
/* View mode */
setViewMode(Settings->value("viewMode", VIEW_MODE_CLASSIC).toInt()); 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 // save settings
/* View mode */ /* View mode */
Settings->setValue("viewMode", viewMode()); 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(); 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 << "PostedListWidget::createPost() ERROR GETTING AuthorId!, Vote Failed";
std::cerr << std::endl; 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; return;
}//switch (ui.idChooser->getChosenId(authorId)) }
RsGxsVote vote; RsGxsVote vote;
@ -322,11 +345,10 @@ void PostedListWidget::submitVote(const RsGxsGrpMsgIdPair &msgId, bool up)
vote.mMeta.mParentId = msgId.second; vote.mMeta.mParentId = msgId.second;
vote.mMeta.mAuthorId = authorId; vote.mMeta.mAuthorId = authorId;
if (up) { if (up)
vote.mVoteType = GXS_VOTE_UP; vote.mVoteType = GXS_VOTE_UP;
} else { //if (up) else
vote.mVoteType = GXS_VOTE_DOWN; vote.mVoteType = GXS_VOTE_DOWN;
}//if (up)
#ifdef DEBUG_POSTED_LIST_WIDGET #ifdef DEBUG_POSTED_LIST_WIDGET
std::cerr << "PostedListWidget::submitVote()"; std::cerr << "PostedListWidget::submitVote()";

View file

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>616</width> <width>950</width>
<height>595</height> <height>771</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -250,7 +250,11 @@
</widget> </widget>
</item> </item>
<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> </item>
</layout> </layout>
</widget> </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; <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; &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; } 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> &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>
<property name="textInteractionFlags"> <property name="textInteractionFlags">
@ -557,7 +561,7 @@ p, li { white-space: pre-wrap; }
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>614</width> <width>98</width>
<height>16</height> <height>16</height>
</rect> </rect>
</property> </property>
@ -613,7 +617,7 @@ p, li { white-space: pre-wrap; }
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>614</width> <width>948</width>
<height>16</height> <height>16</height>
</rect> </rect>
</property> </property>
@ -667,9 +671,9 @@ p, li { white-space: pre-wrap; }
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="../images.qrc"/>
<include location="../icons.qrc"/> <include location="../icons.qrc"/>
<include location="Posted_images.qrc"/> <include location="Posted_images.qrc"/>
<include location="../images.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>