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">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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