Merge pull request #2746 from PYRET1C/edit_account

This commit gives the edit account feature in the wire.
This commit is contained in:
csoler 2023-07-17 09:40:30 +02:00 committed by GitHub
commit 7a3c9f7efe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 220 additions and 72 deletions

View File

@ -0,0 +1,41 @@
/*******************************************************************************
* gui/TheWire/CustomFrame.cpp *
* *
* Copyright (c) 2012-2020 Robert Fernie <retroshare.project@gmail.com> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
* *
*******************************************************************************/
#include "CustomFrame.h"
#include <QPainter>
// Constructor
CustomFrame::CustomFrame(QWidget *parent) : QFrame(parent)
{
// Any initializations for this frame.
}
// Overriding the inbuilt paint function
void CustomFrame::paintEvent(QPaintEvent *event)
{
QFrame::paintEvent(event);
QPainter painter(this);
painter.drawPixmap(rect(), backgroundImage);
}
// Function to set the member variable 'backgroundImage'
void CustomFrame::setPixmap(QPixmap pixmap){
backgroundImage = pixmap;
}

View File

@ -0,0 +1,44 @@
/*******************************************************************************
* gui/TheWire/CustomFrame.h *
* *
* Copyright (c) 2012-2020 Robert Fernie <retroshare.project@gmail.com> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
* *
*******************************************************************************/
#ifndef CUSTOMFRAMEH_H
#define CUSTOMFRAMEH_H
#include <QFrame>
#include <QPixmap>
// This class is made to implement the background image in a Qframe or any widget
class CustomFrame : public QFrame
{
Q_OBJECT
public:
explicit CustomFrame(QWidget *parent = nullptr);
void setPixmap(QPixmap pixmap);
protected:
void paintEvent(QPaintEvent *event) override;
private:
QPixmap backgroundImage;
};
#endif //CUSTOMFRAMEH_H

View File

@ -767,7 +767,6 @@
<property name="font"> <property name="font">
<font> <font>
<pointsize>12</pointsize> <pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
</font> </font>
</property> </property>

View File

@ -24,86 +24,114 @@
#include <QBuffer> #include <QBuffer>
#include "PulseViewGroup.h" #include "PulseViewGroup.h"
#include "CustomFrame.h"
#include "gui/gxs/GxsIdDetails.h" #include "gui/gxs/GxsIdDetails.h"
#include "gui/common/FilesDefs.h" #include "gui/common/FilesDefs.h"
#include "util/DateTime.h" #include "util/DateTime.h"
Q_DECLARE_METATYPE(RsWireGroup)
/** Constructor */ /** Constructor */
PulseViewGroup::PulseViewGroup(PulseViewHolder *holder, RsWireGroupSPtr group) PulseViewGroup::PulseViewGroup(PulseViewHolder *holder, RsWireGroupSPtr group)
:PulseViewItem(holder), mGroup(group) :PulseViewItem(holder), mGroup(group)
{ {
setupUi(this); setupUi(this);
setAttribute ( Qt::WA_DeleteOnClose, true ); setAttribute ( Qt::WA_DeleteOnClose, true );
setup(); setup();
} }
void PulseViewGroup::setup() void PulseViewGroup::setup()
{ {
if (mGroup) { if (mGroup) {
connect(followButton, SIGNAL(clicked()), this, SLOT(actionFollow())); connect(followButton, SIGNAL(clicked()), this, SLOT(actionFollow()));
label_groupName->setText("@" + QString::fromStdString(mGroup->mMeta.mGroupName)); label_groupName->setText("@" + QString::fromStdString(mGroup->mMeta.mGroupName));
label_authorName->setText(BoldString(QString::fromStdString(mGroup->mMeta.mAuthorId.toStdString()))); label_authorName->setText(BoldString(QString::fromStdString(mGroup->mMeta.mAuthorId.toStdString())));
label_date->setText(DateTime::formatDateTime(mGroup->mMeta.mPublishTs)); label_date->setText(DateTime::formatDateTime(mGroup->mMeta.mPublishTs));
label_tagline->setText(QString::fromStdString(mGroup->mTagline)); label_tagline->setText(QString::fromStdString(mGroup->mTagline));
label_location->setText(QString::fromStdString(mGroup->mLocation)); label_location->setText(QString::fromStdString(mGroup->mLocation));
// need to draw mGroup->mMasthead, as background to headshot.
// TODO frame_headerBackground->setBackground()
if (mGroup->mHeadshot.mData) if (mGroup->mMasthead.mData)
{ {
QPixmap pixmap; QPixmap pixmap;
if (GxsIdDetails::loadPixmapFromData( if (GxsIdDetails::loadPixmapFromData(
mGroup->mHeadshot.mData, mGroup->mMasthead.mData,
mGroup->mHeadshot.mSize, mGroup->mMasthead.mSize,
pixmap,GxsIdDetails::ORIGINAL)) pixmap, GxsIdDetails::ORIGINAL))
{ {
pixmap = pixmap.scaled(50,50); QSize frameSize = frame_masthead->size();
label_headshot->setPixmap(pixmap);
} // Scale the pixmap based on the frame size
} pixmap = pixmap.scaledToWidth(frameSize.width(), Qt::SmoothTransformation);
else frame_masthead->setPixmap(pixmap);
{ }
}
// Uncomment the below code for default background
// else
// {
// // Default pixmap
// QPixmap pixmap = FilesDefs::getPixmapFromQtResourcePath(":/icons/png/posted.png");
// QSize frameSize = frame_masthead->size();
// // Scale the pixmap based on the frame size
// pixmap = pixmap.scaled(frameSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
// frame_masthead->setPixmap(pixmap);
// }
if (mGroup->mHeadshot.mData)
{
QPixmap pixmap;
if (GxsIdDetails::loadPixmapFromData(
mGroup->mHeadshot.mData,
mGroup->mHeadshot.mSize,
pixmap,GxsIdDetails::ORIGINAL))
{
pixmap = pixmap.scaled(100,100);
label_headshot->setPixmap(pixmap);
}
}
else
{
// default. // default.
QPixmap pixmap = FilesDefs::getPixmapFromQtResourcePath(":/icons/png/posted.png").scaled(50,50); QPixmap pixmap = FilesDefs::getPixmapFromQtResourcePath(":/icons/png/posted.png").scaled(100,100);
label_headshot->setPixmap(pixmap); label_headshot->setPixmap(pixmap);
} }
if (mGroup->mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED) if (mGroup->mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED)
{ {
uint32_t pulses = mGroup->mGroupPulses + mGroup->mGroupReplies; uint32_t pulses = mGroup->mGroupPulses + mGroup->mGroupReplies;
uint32_t replies = mGroup->mRefReplies; uint32_t replies = mGroup->mRefReplies;
uint32_t republishes = mGroup->mRefRepublishes; uint32_t republishes = mGroup->mRefRepublishes;
uint32_t likes = mGroup->mRefLikes; uint32_t likes = mGroup->mRefLikes;
label_extra_pulses->setText(BoldString(ToNumberUnits(pulses))); label_extra_pulses->setText(BoldString(ToNumberUnits(pulses)));
label_extra_replies->setText(BoldString(ToNumberUnits(replies))); label_extra_replies->setText(BoldString(ToNumberUnits(replies)));
label_extra_republishes->setText(BoldString(ToNumberUnits(republishes))); label_extra_republishes->setText(BoldString(ToNumberUnits(republishes)));
label_extra_likes->setText(BoldString(ToNumberUnits(likes))); label_extra_likes->setText(BoldString(ToNumberUnits(likes)));
// hide follow. // hide follow.
widget_actions->setVisible(false); widget_actions->setVisible(false);
} }
else else
{ {
// hide stats. // hide stats.
widget_replies->setVisible(false); widget_replies->setVisible(false);
} }
} }
} }
void PulseViewGroup::actionFollow() void PulseViewGroup::actionFollow()
{ {
RsGxsGroupId groupId = mGroup->mMeta.mGroupId; RsGxsGroupId groupId = mGroup->mMeta.mGroupId;
std::cerr << "PulseViewGroup::actionFollow() following "; std::cerr << "PulseViewGroup::actionFollow() following ";
std::cerr << groupId; std::cerr << groupId;
std::cerr << std::endl; std::cerr << std::endl;
if (mHolder) { if (mHolder) {
mHolder->PVHfollow(groupId); mHolder->PVHfollow(groupId);
} }
} }

View File

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>745</width> <width>746</width>
<height>483</height> <height>483</height>
</rect> </rect>
</property> </property>
@ -48,19 +48,37 @@
<property name="frameShadow"> <property name="frameShadow">
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<layout class="QVBoxLayout" name="plainFrame_VL"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QFrame" name="frame_headerBackground"> <widget class="CustomFrame" name="frame_masthead">
<layout class="QHBoxLayout" name="frame_headerBackground_HL"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>700</width>
<height>135</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<spacer name="frame_headerBackground_LHSpacer"> <spacer name="widget_actions_RHSpacer_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>283</width> <width>277</width>
<height>20</height> <height>17</height>
</size> </size>
</property> </property>
</spacer> </spacer>
@ -79,19 +97,22 @@
<height>100</height> <height>100</height>
</size> </size>
</property> </property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text"> <property name="text">
<string>headshot</string> <string>headshot</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="frame_headerBackground_RHSpacer"> <spacer name="widget_actions_LHSpacer_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>23</width> <width>281</width>
<height>20</height> <height>20</height>
</size> </size>
</property> </property>
@ -509,7 +530,6 @@
<property name="font"> <property name="font">
<font> <font>
<pointsize>12</pointsize> <pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
</font> </font>
</property> </property>
@ -538,10 +558,25 @@
</widget> </widget>
</item> </item>
</layout> </layout>
<zorder>widget_header</zorder>
<zorder>widget_publish</zorder>
<zorder>line_1</zorder>
<zorder>widget_replies</zorder>
<zorder>line_2</zorder>
<zorder>widget_actions</zorder>
<zorder>frame_masthead</zorder>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>CustomFrame</class>
<extends>QFrame</extends>
<header>gui\TheWire\CustomFrame.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

View File

@ -434,8 +434,8 @@
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="TheWire_images.qrc"/>
<include location="../icons.qrc"/> <include location="../icons.qrc"/>
<include location="TheWire_images.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>

View File

@ -152,7 +152,7 @@ bool WireGroupDialog::service_updateGroup(const RsGroupMetaData &editedMeta)
std::cerr << "WireGroupDialog::service_updateGroup() submitting changes"; std::cerr << "WireGroupDialog::service_updateGroup() submitting changes";
std::cerr << std::endl; std::cerr << std::endl;
bool success = rsWire->updateGroup(grp); bool success = rsWire->editWire(grp);
// TODO updateGroup should refresh groupId or Data // TODO updateGroup should refresh groupId or Data
return success; return success;
} }

View File

@ -65,8 +65,7 @@ WireGroupItem::WireGroupItem(WireGroupHolder *holder, const RsWireGroup &grp)
setAttribute ( Qt::WA_DeleteOnClose, true ); setAttribute ( Qt::WA_DeleteOnClose, true );
setup(); setup();
// disabled, still not yet functional Edit/Update editButton->setEnabled(true);
editButton->setEnabled(false);
} }
RsGxsGroupId &WireGroupItem::groupId() RsGxsGroupId &WireGroupItem::groupId()

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>276</width> <width>292</width>
<height>114</height> <height>115</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">

View File

@ -1220,6 +1220,7 @@ gxsthewire {
gui/TheWire/PulseReply.h \ gui/TheWire/PulseReply.h \
gui/TheWire/PulseReplySeperator.h \ gui/TheWire/PulseReplySeperator.h \
gui/TheWire/PulseMessage.h \ gui/TheWire/PulseMessage.h \
gui/TheWire/CustomFrame.h \
FORMS += gui/TheWire/WireDialog.ui \ FORMS += gui/TheWire/WireDialog.ui \
gui/TheWire/WireGroupItem.ui \ gui/TheWire/WireGroupItem.ui \
@ -1242,6 +1243,7 @@ gxsthewire {
gui/TheWire/PulseReply.cpp \ gui/TheWire/PulseReply.cpp \
gui/TheWire/PulseReplySeperator.cpp \ gui/TheWire/PulseReplySeperator.cpp \
gui/TheWire/PulseMessage.cpp \ gui/TheWire/PulseMessage.cpp \
gui/TheWire/CustomFrame.cpp \
RESOURCES += gui/TheWire/TheWire_images.qrc RESOURCES += gui/TheWire/TheWire_images.qrc
} }