added selection boxes to add forum moderators

This commit is contained in:
csoler 2018-08-09 21:18:37 +02:00
parent b20bd0a454
commit ded9c21617
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
8 changed files with 146 additions and 156 deletions

View File

@ -43,7 +43,7 @@ class RsGxsForumGroup
public:
RsGroupMetaData mMeta;
std::string mDescription;
RsTlvGxsIdSet admin_list; // this is optional, and handled by the serialiser
RsTlvGxsIdSet mAdminList; // this is optional, and handled by the serialiser
};
class RsGxsForumMsg

View File

@ -58,7 +58,7 @@ void RsGxsForumGroupItem::serial_process(RsGenericSerializer::SerializeJob j,RsG
if(j == RsGenericSerializer::DESERIALIZE && ctx.mOffset == ctx.mSize)
return ;
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,mGroup.admin_list,"admin_list") ;
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,mGroup.mAdminList,"admin_list") ;
}
void RsGxsForumMsgItem::clear()

View File

@ -32,7 +32,7 @@ const uint32_t PostedCreateEnabledFlags = (
GXS_GROUP_FLAGS_DESCRIPTION |
GXS_GROUP_FLAGS_DISTRIBUTION |
// GXS_GROUP_FLAGS_PUBLISHSIGN |
GXS_GROUP_FLAGS_SHAREKEYS |
// GXS_GROUP_FLAGS_SHAREKEYS | // disabled because the UI doesn't handle it yet.
// GXS_GROUP_FLAGS_PERSONALSIGN |
// GXS_GROUP_FLAGS_COMMENTS |
0);
@ -84,7 +84,7 @@ void PostedGroupDialog::initUi()
break;
}
setUiText(UITYPE_KEY_SHARE_CHECKBOX, tr("Add Topic Admins"));
setUiText(UITYPE_ADD_ADMINS_CHECKBOX, tr("Add Topic Admins"));
setUiText(UITYPE_CONTACTS_DOCK, tr("Select Topic Admins"));
}

View File

@ -101,6 +101,7 @@ void GxsGroupDialog::init()
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(submitGroup()));
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(cancelDialog()));
connect(ui.pubKeyShare_cb, SIGNAL(clicked()), this, SLOT(setShareList()));
connect(ui.addAdmins_cb, SIGNAL(clicked()), this, SLOT(setAdminsList()));
connect(ui.groupLogo, SIGNAL(clicked() ), this , SLOT(addGroupLogo()));
connect(ui.addLogoButton, SIGNAL(clicked() ), this , SLOT(addGroupLogo()));
@ -115,14 +116,25 @@ void GxsGroupDialog::init()
if (!ui.pubKeyShare_cb->isChecked())
{
ui.contactsdockWidget->hide();
this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height());
ui.shareKeyList->hide();
//this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height());
}
if (!ui.addAdmins_cb->isChecked())
{
ui.adminsList->hide();
//this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height());
}
/* initialize key share list */
ui.keyShareList->setHeaderText(tr("Contacts:"));
ui.keyShareList->setModus(FriendSelectionWidget::MODUS_CHECK);
ui.keyShareList->start();
ui.shareKeyList->setHeaderText(tr("Contacts:"));
ui.shareKeyList->setModus(FriendSelectionWidget::MODUS_CHECK);
ui.shareKeyList->start();
/* initialize key share list */
ui.adminsList->setHeaderText(tr("Moderators:"));
ui.adminsList->setModus(FriendSelectionWidget::MODUS_CHECK);
ui.adminsList->setShowType(FriendSelectionWidget::SHOW_GXS);
ui.adminsList->start();
/* Setup Reasonable Defaults */
@ -165,7 +177,8 @@ void GxsGroupDialog::setUiText(UiType uiType, const QString &text)
ui.pubKeyShare_cb->setText(text);
break;
case UITYPE_CONTACTS_DOCK:
ui.contactsdockWidget->setWindowTitle(text);
case UITYPE_ADD_ADMINS_CHECKBOX:
//ui.contactsdockWidget->setWindowTitle(text);
break;
case UITYPE_BUTTONBOX_OK:
ui.buttonBox->button(QDialogButtonBox::Ok)->setText(text);
@ -173,6 +186,23 @@ void GxsGroupDialog::setUiText(UiType uiType, const QString &text)
}
}
void GxsGroupDialog::setUiToolTip(UiType uiType, const QString &text)
{
switch (uiType)
{
case UITYPE_KEY_SHARE_CHECKBOX:
ui.pubKeyShare_cb->setToolTip(text);
break;
case UITYPE_ADD_ADMINS_CHECKBOX:
ui.addAdmins_cb->setToolTip(text);
break;
case UITYPE_BUTTONBOX_OK:
ui.buttonBox->button(QDialogButtonBox::Ok)->setToolTip(text);
default:
break;
}
}
void GxsGroupDialog::initMode()
{
setAllReadonly();
@ -345,6 +375,7 @@ void GxsGroupDialog::setupVisibility()
ui.publishGroupBox->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_PUBLISHSIGN);
ui.pubKeyShare_cb->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_SHAREKEYS);
ui.addAdmins_cb->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_ADDADMINS);
ui.personalGroupBox->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_PERSONALSIGN);
@ -828,6 +859,11 @@ QString GxsGroupDialog::getDescription()
return ui.groupDesc->toPlainText();
}
void GxsGroupDialog::getSelectedModerators(std::set<RsGxsId>& ids)
{
ui.adminsList->selectedIds<RsGxsId,FriendSelectionWidget::IDTYPE_GXS>(ids, true);
}
/***********************************************************************************
Share Lists.
***********************************************************************************/
@ -837,6 +873,20 @@ void GxsGroupDialog::sendShareList(std::string /*groupId*/)
close();
}
void GxsGroupDialog::setAdminsList()
{
if (ui.addAdmins_cb->isChecked())
{
//this->resize(this->size().width() + ui.contactsdockWidget->size().width(), this->size().height());
ui.adminsList->show();
}
else
{ // hide share widget
ui.adminsList->hide();
//this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height());
}
}
void GxsGroupDialog::setShareList()
{
if (ui.pubKeyShare_cb->isChecked()) {

View File

@ -55,44 +55,45 @@ public:
/*** Group flags affect what is visually enabled that gets input into the grpMeta ***/
#define GXS_GROUP_FLAGS_NAME 0x00000001
#define GXS_GROUP_FLAGS_ICON 0x00000002
#define GXS_GROUP_FLAGS_DESCRIPTION 0x00000004
#define GXS_GROUP_FLAGS_DISTRIBUTION 0x00000008
#define GXS_GROUP_FLAGS_PUBLISHSIGN 0x00000010
#define GXS_GROUP_FLAGS_SHAREKEYS 0x00000020
#define GXS_GROUP_FLAGS_PERSONALSIGN 0x00000040
#define GXS_GROUP_FLAGS_COMMENTS 0x00000080
#define GXS_GROUP_FLAGS_EXTRA 0x00000100
#define GXS_GROUP_FLAGS_ANTI_SPAM 0x00000200
#define GXS_GROUP_FLAGS_NAME 0x00000001
#define GXS_GROUP_FLAGS_ICON 0x00000002
#define GXS_GROUP_FLAGS_DESCRIPTION 0x00000004
#define GXS_GROUP_FLAGS_DISTRIBUTION 0x00000008
#define GXS_GROUP_FLAGS_PUBLISHSIGN 0x00000010
#define GXS_GROUP_FLAGS_SHAREKEYS 0x00000020
#define GXS_GROUP_FLAGS_PERSONALSIGN 0x00000040
#define GXS_GROUP_FLAGS_COMMENTS 0x00000080
#define GXS_GROUP_FLAGS_EXTRA 0x00000100
#define GXS_GROUP_FLAGS_ANTI_SPAM 0x00000200
#define GXS_GROUP_FLAGS_ADDADMINS 0x00000400
/*** Default flags are used to determine privacy of group, signatures required ***
*** whether publish or id and whether comments are allowed or not ***/
#define GXS_GROUP_DEFAULTS_DISTRIB_MASK 0x0000000f
#define GXS_GROUP_DEFAULTS_PUBLISH_MASK 0x000000f0
#define GXS_GROUP_DEFAULTS_PERSONAL_MASK 0x00000f00
#define GXS_GROUP_DEFAULTS_COMMENTS_MASK 0x0000f000
#define GXS_GROUP_DEFAULTS_DISTRIB_MASK 0x0000000f
#define GXS_GROUP_DEFAULTS_PUBLISH_MASK 0x000000f0
#define GXS_GROUP_DEFAULTS_PERSONAL_MASK 0x00000f00
#define GXS_GROUP_DEFAULTS_COMMENTS_MASK 0x0000f000
#define GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC 0x00000001
#define GXS_GROUP_DEFAULTS_DISTRIB_GROUP 0x00000002
#define GXS_GROUP_DEFAULTS_DISTRIB_LOCAL 0x00000004
#define GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC 0x00000001
#define GXS_GROUP_DEFAULTS_DISTRIB_GROUP 0x00000002
#define GXS_GROUP_DEFAULTS_DISTRIB_LOCAL 0x00000004
#define GXS_GROUP_DEFAULTS_PUBLISH_OPEN 0x00000010
#define GXS_GROUP_DEFAULTS_PUBLISH_THREADS 0x00000020
#define GXS_GROUP_DEFAULTS_PUBLISH_REQUIRED 0x00000040
#define GXS_GROUP_DEFAULTS_PUBLISH_ENCRYPTED 0x00000080
#define GXS_GROUP_DEFAULTS_PUBLISH_OPEN 0x00000010
#define GXS_GROUP_DEFAULTS_PUBLISH_THREADS 0x00000020
#define GXS_GROUP_DEFAULTS_PUBLISH_REQUIRED 0x00000040
#define GXS_GROUP_DEFAULTS_PUBLISH_ENCRYPTED 0x00000080
#define GXS_GROUP_DEFAULTS_PERSONAL_PGP 0x00000100
#define GXS_GROUP_DEFAULTS_PERSONAL_REQUIRED 0x00000200
#define GXS_GROUP_DEFAULTS_PERSONAL_IFNOPUB 0x00000400
#define GXS_GROUP_DEFAULTS_PERSONAL_PGP 0x00000100
#define GXS_GROUP_DEFAULTS_PERSONAL_REQUIRED 0x00000200
#define GXS_GROUP_DEFAULTS_PERSONAL_IFNOPUB 0x00000400
#define GXS_GROUP_DEFAULTS_COMMENTS_YES 0x00001000
#define GXS_GROUP_DEFAULTS_COMMENTS_NO 0x00002000
#define GXS_GROUP_DEFAULTS_COMMENTS_YES 0x00001000
#define GXS_GROUP_DEFAULTS_COMMENTS_NO 0x00002000
#define GXS_GROUP_DEFAULTS_ANTISPAM_FAVOR_PGP 0x00100000
#define GXS_GROUP_DEFAULTS_ANTISPAM_TRACK 0x00200000
#define GXS_GROUP_DEFAULTS_ANTISPAM_FAVOR_PGP_KNOWN 0x00400000
#define GXS_GROUP_DEFAULTS_ANTISPAM_FAVOR_PGP 0x00100000
#define GXS_GROUP_DEFAULTS_ANTISPAM_TRACK 0x00200000
#define GXS_GROUP_DEFAULTS_ANTISPAM_FAVOR_PGP_KNOWN 0x00400000
/*!
* The aim of this dialog is to be convenient to encapsulate group
@ -121,6 +122,7 @@ public:
enum UiType {
UITYPE_SERVICE_HEADER,
UITYPE_KEY_SHARE_CHECKBOX,
UITYPE_ADD_ADMINS_CHECKBOX,
UITYPE_CONTACTS_DOCK,
UITYPE_BUTTONBOX_OK
};
@ -172,7 +174,14 @@ protected:
virtual QPixmap serviceImage() = 0;
virtual QIcon serviceWindowIcon();
void setUiText(UiType uiType, const QString &text);
/*!
* \brief setUiToolTip/setUiText
* Sets the text and tooltip of some parts of the UI
* \param uiType widget to set
* \param text text to set
*/
void setUiToolTip(UiType uiType, const QString &text);
void setUiText (UiType uiType, const QString &text);
/*!
* It is up to the service to do the actual group creation
@ -219,12 +228,19 @@ protected:
*/
QString getDescription();
/*!
* \brief getSelectedModerators
* Returns the set of ids that hve been selected as moderators.
*/
void getSelectedModerators(std::set<RsGxsId>& ids);
private slots:
/* actions to take.... */
void cancelDialog();
// set private forum key share list
void setShareList();
void setAdminsList();
void updateCircleOptions();

View File

@ -172,13 +172,23 @@
<string>Will be used to send feedback</string>
</property>
<property name="text">
<string>Owner:</string>
<string>Contact:</string>
</property>
</widget>
</item>
<item>
<widget class="GxsIdChooser" name="idChooser"/>
</item>
<item>
<widget class="QCheckBox" name="addAdmins_cb">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Add moderators</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="pubKeyShare_cb">
<property name="toolTip">
@ -196,102 +206,6 @@
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QDockWidget" name="contactsdockWidget">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>524287</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>220</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>check peers you would like to share private publish key with</string>
</property>
<property name="floating">
<bool>false</bool>
</property>
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>Share Key With</string>
</property>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QGridLayout" name="_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="FriendSelectionWidget" name="keyShareList" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>4</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>16777215</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>220</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="distribGroupBox">
<property name="sizePolicy">
@ -435,7 +349,7 @@
</layout>
</widget>
</item>
<item row="2" column="0">
<item row="4" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Description</string>
@ -447,7 +361,7 @@
</layout>
</widget>
</item>
<item row="3" column="0">
<item row="5" column="0">
<widget class="QGroupBox" name="publishGroupBox">
<property name="title">
<string>Publish Signatures</string>
@ -512,7 +426,7 @@
</layout>
</widget>
</item>
<item row="4" column="0">
<item row="6" column="0">
<widget class="QGroupBox" name="personalGroupBox">
<property name="title">
<string>Personal Signatures</string>
@ -555,7 +469,7 @@
</layout>
</widget>
</item>
<item row="5" column="0">
<item row="7" column="0">
<widget class="QGroupBox" name="commentGroupBox">
<property name="title">
<string>Comments</string>
@ -606,7 +520,7 @@
</layout>
</widget>
</item>
<item row="6" column="0">
<item row="8" column="0">
<widget class="QGroupBox" name="spamProtection_GB">
<property name="title">
<string>Spam-protection</string>
@ -657,7 +571,7 @@
</layout>
</widget>
</item>
<item row="7" column="0" colspan="2">
<item row="9" column="0" colspan="2">
<widget class="QFrame" name="extraFrame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
@ -667,6 +581,12 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="FriendSelectionWidget" name="adminsList" native="true"/>
</item>
<item row="3" column="0">
<widget class="FriendSelectionWidget" name="shareKeyList" native="true"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="showmode">

View File

@ -34,7 +34,7 @@ const uint32_t ChannelCreateEnabledFlags = (
GXS_GROUP_FLAGS_DESCRIPTION |
GXS_GROUP_FLAGS_DISTRIBUTION |
// GXS_GROUP_FLAGS_PUBLISHSIGN |
GXS_GROUP_FLAGS_SHAREKEYS |
// GXS_GROUP_FLAGS_SHAREKEYS | // disabled because the UI doesn't handle it, so no need to show the disabled button. The user can do it in a second step from the channel menu.
// GXS_GROUP_FLAGS_PERSONALSIGN |
GXS_GROUP_FLAGS_COMMENTS |
0);
@ -75,19 +75,19 @@ void GxsChannelGroupDialog::initUi()
{
case MODE_CREATE:
setUiText(UITYPE_SERVICE_HEADER, tr("Create New Channel"));
setUiText(UITYPE_BUTTONBOX_OK, tr("Create"));
setUiText(UITYPE_BUTTONBOX_OK, tr("Create"));
break;
case MODE_SHOW:
setUiText(UITYPE_SERVICE_HEADER, tr("Channel"));
break;
case MODE_EDIT:
setUiText(UITYPE_SERVICE_HEADER, tr("Edit Channel"));
setUiText(UITYPE_BUTTONBOX_OK, tr("Update Channel"));
setUiText(UITYPE_BUTTONBOX_OK, tr("Update Channel"));
break;
}
setUiText(UITYPE_KEY_SHARE_CHECKBOX, tr("Add Channel Admins"));
setUiText(UITYPE_CONTACTS_DOCK, tr("Select Channel Admins"));
setUiText(UITYPE_CONTACTS_DOCK, tr("Select Channel Admins"));
}
QPixmap GxsChannelGroupDialog::serviceImage()

View File

@ -27,12 +27,13 @@
// To start with we only have open forums - with distribution controls.
const uint32_t ForumCreateEnabledFlags = (
GXS_GROUP_FLAGS_NAME |
// GXS_GROUP_FLAGS_ICON |
GXS_GROUP_FLAGS_NAME |
// GXS_GROUP_FLAGS_ICON |
GXS_GROUP_FLAGS_DESCRIPTION |
GXS_GROUP_FLAGS_DISTRIBUTION |
// GXS_GROUP_FLAGS_PUBLISHSIGN |
GXS_GROUP_FLAGS_SHAREKEYS |
// GXS_GROUP_FLAGS_PUBLISHSIGN|
// GXS_GROUP_FLAGS_SHAREKEYS |
GXS_GROUP_FLAGS_ADDADMINS |
GXS_GROUP_FLAGS_ANTI_SPAM |
// GXS_GROUP_FLAGS_PERSONALSIGN |
// GXS_GROUP_FLAGS_COMMENTS |
@ -42,17 +43,17 @@ const uint32_t ForumCreateDefaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC
//GXS_GROUP_DEFAULTS_DISTRIB_GROUP |
//GXS_GROUP_DEFAULTS_DISTRIB_LOCAL |
GXS_GROUP_DEFAULTS_PUBLISH_OPEN |
GXS_GROUP_DEFAULTS_PUBLISH_OPEN |
//GXS_GROUP_DEFAULTS_PUBLISH_THREADS |
//GXS_GROUP_DEFAULTS_PUBLISH_REQUIRED |
//GXS_GROUP_DEFAULTS_PUBLISH_ENCRYPTED |
//GXS_GROUP_DEFAULTS_PERSONAL_PGP |
GXS_GROUP_DEFAULTS_PERSONAL_REQUIRED |
GXS_GROUP_DEFAULTS_PERSONAL_REQUIRED |
//GXS_GROUP_DEFAULTS_PERSONAL_IFNOPUB |
//GXS_GROUP_DEFAULTS_COMMENTS_YES |
GXS_GROUP_DEFAULTS_COMMENTS_NO |
GXS_GROUP_DEFAULTS_COMMENTS_NO |
0);
const uint32_t ForumEditEnabledFlags = ForumCreateEnabledFlags;
@ -87,8 +88,10 @@ void GxsForumGroupDialog::initUi()
break;
}
setUiText(UITYPE_KEY_SHARE_CHECKBOX, tr("Add Forum Admins"));
setUiText(UITYPE_CONTACTS_DOCK, tr("Select Forum Admins"));
setUiToolTip(UITYPE_ADD_ADMINS_CHECKBOX,tr("Forum moderators can edit/delete/pinup others posts"));
//setUiText(UITYPE_KEY_SHARE_CHECKBOX, tr("Add Forum Admins"));
//setUiText(UITYPE_CONTACTS_DOCK, tr("Select Forum Admins"));
}
QPixmap GxsForumGroupDialog::serviceImage()
@ -102,6 +105,7 @@ bool GxsForumGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMeta
RsGxsForumGroup grp;
grp.mMeta = meta;
grp.mDescription = getDescription().toUtf8().constData();
getSelectedModerators(grp.mAdminList.ids);
rsGxsForums->createGroup(token, grp);
return true;