From bcd8f4b0de35aae26be614355b5bb85e51869e37 Mon Sep 17 00:00:00 2001 From: drbob Date: Tue, 26 May 2020 18:09:50 +1000 Subject: [PATCH] use Extra Widget for Group creation --- .../src/gui/TheWire/WireGroupDialog.cpp | 30 +++++-- .../src/gui/TheWire/WireGroupDialog.h | 5 ++ .../src/gui/TheWire/WireGroupExtra.cpp | 83 +++++++++++++++++++ .../src/gui/TheWire/WireGroupExtra.h | 54 ++++++++++++ .../src/gui/TheWire/WireGroupExtra.ui | 68 +++++++++++++++ retroshare-gui/src/retroshare-gui.pro | 3 + 6 files changed, 235 insertions(+), 8 deletions(-) create mode 100644 retroshare-gui/src/gui/TheWire/WireGroupExtra.cpp create mode 100644 retroshare-gui/src/gui/TheWire/WireGroupExtra.h create mode 100644 retroshare-gui/src/gui/TheWire/WireGroupExtra.ui diff --git a/retroshare-gui/src/gui/TheWire/WireGroupDialog.cpp b/retroshare-gui/src/gui/TheWire/WireGroupDialog.cpp index e8d388734..210a05b92 100644 --- a/retroshare-gui/src/gui/TheWire/WireGroupDialog.cpp +++ b/retroshare-gui/src/gui/TheWire/WireGroupDialog.cpp @@ -19,6 +19,8 @@ *******************************************************************************/ #include +#include "WireGroupExtra.h" + #include "WireGroupDialog.h" #include "gui/gxs/GxsIdDetails.h" @@ -27,7 +29,7 @@ const uint32_t WireCreateEnabledFlags = ( GXS_GROUP_FLAGS_NAME | GXS_GROUP_FLAGS_ICON | - GXS_GROUP_FLAGS_DESCRIPTION | + // GXS_GROUP_FLAGS_DESCRIPTION | GXS_GROUP_FLAGS_DISTRIBUTION | // GXS_GROUP_FLAGS_PUBLISHSIGN | // GXS_GROUP_FLAGS_SHAREKEYS | // disabled because the UI doesn't handle it yet. @@ -85,6 +87,9 @@ void WireGroupDialog::initUi() setUiText(UITYPE_ADD_ADMINS_CHECKBOX, tr("Add Wire Admins")); setUiText(UITYPE_CONTACTS_DOCK, tr("Select Wire Admins")); + + mExtra = new WireGroupExtra(this); + injectExtraWidget(mExtra); } QPixmap WireGroupDialog::serviceImage() @@ -95,11 +100,6 @@ QPixmap WireGroupDialog::serviceImage() void WireGroupDialog::prepareWireGroup(RsWireGroup &group, const RsGroupMetaData &meta) { group.mMeta = meta; - - // To Add. - group.mTagline = "a Tagline"; - group.mLocation = "here"; - QPixmap pixmap = getLogo(); if (!pixmap.isNull()) { @@ -110,12 +110,26 @@ void WireGroupDialog::prepareWireGroup(RsWireGroup &group, const RsGroupMetaData pixmap.save(&buffer, "PNG"); // writes image into ba in PNG format group.mHeadshot.copy((uint8_t *) ba.data(), ba.size()); - group.mMasthead.copy((uint8_t *) ba.data(), ba.size()); } else { group.mHeadshot.clear(); - group.mMasthead.clear(); } + // from Extra Widget. + group.mTagline = mExtra->getTagline(); + group.mLocation = mExtra->getLocation(); + pixmap = mExtra->getMasthead(); + + if (!pixmap.isNull()) { + QByteArray ba; + QBuffer buffer(&ba); + + buffer.open(QIODevice::WriteOnly); + pixmap.save(&buffer, "JPG"); + + group.mMasthead.copy((uint8_t *) ba.data(), ba.size()); + } else { + group.mMasthead.clear(); + } } bool WireGroupDialog::service_createGroup(RsGroupMetaData &meta) diff --git a/retroshare-gui/src/gui/TheWire/WireGroupDialog.h b/retroshare-gui/src/gui/TheWire/WireGroupDialog.h index b34d2d0dc..ca3f59e73 100644 --- a/retroshare-gui/src/gui/TheWire/WireGroupDialog.h +++ b/retroshare-gui/src/gui/TheWire/WireGroupDialog.h @@ -22,8 +22,11 @@ #define _WIRE_GROUP_DIALOG_H #include "gui/gxs/GxsGroupDialog.h" + #include +class WireGroupExtra; + class WireGroupDialog : public GxsGroupDialog { Q_OBJECT @@ -42,6 +45,8 @@ protected: private: void prepareWireGroup(RsWireGroup &group, const RsGroupMetaData &meta); + + WireGroupExtra *mExtra; }; #endif diff --git a/retroshare-gui/src/gui/TheWire/WireGroupExtra.cpp b/retroshare-gui/src/gui/TheWire/WireGroupExtra.cpp new file mode 100644 index 000000000..b6a1c5440 --- /dev/null +++ b/retroshare-gui/src/gui/TheWire/WireGroupExtra.cpp @@ -0,0 +1,83 @@ +/******************************************************************************* + * retroshare-gui/src/gui/TheWire/WireGroupExtra.cpp * + * * + * Copyright (C) 2020 by Robert Fernie * + * * + * 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 . * + * * + *******************************************************************************/ + +#include "WireGroupExtra.h" +#include "util/misc.h" + +WireGroupExtra::WireGroupExtra(QWidget *parent) : + QWidget(NULL) +{ + ui.setupUi(this); + setUp(); +} + +WireGroupExtra::~WireGroupExtra() +{ +} + +void WireGroupExtra::setUp() +{ + connect(ui.pushButton_masthead, SIGNAL(clicked() ), this , SLOT(addMasthead())); +} + + +void WireGroupExtra::addMasthead() +{ + QPixmap img = misc::getOpenThumbnailedPicture(this, tr("Load Masthead"), 400, 100); + + if (img.isNull()) + return; + + setMasthead(img); +} + + +void WireGroupExtra::setTagline(const std::string &str) +{ + ui.lineEdit_Tagline->setText(QString::fromStdString(str)); +} + +void WireGroupExtra::setLocation(const std::string &str) +{ + ui.lineEdit_Location->setText(QString::fromStdString(str)); +} + +void WireGroupExtra::setMasthead(const QPixmap &pixmap) +{ + mMasthead = pixmap; + ui.label_masthead->setPixmap(mMasthead); +} + +std::string WireGroupExtra::getTagline() +{ + return ui.lineEdit_Tagline->text().toStdString(); +} + +std::string WireGroupExtra::getLocation() +{ + return ui.lineEdit_Location->text().toStdString(); +} + +QPixmap WireGroupExtra::getMasthead() +{ + return mMasthead; +} + + diff --git a/retroshare-gui/src/gui/TheWire/WireGroupExtra.h b/retroshare-gui/src/gui/TheWire/WireGroupExtra.h new file mode 100644 index 000000000..ce606feb3 --- /dev/null +++ b/retroshare-gui/src/gui/TheWire/WireGroupExtra.h @@ -0,0 +1,54 @@ +/******************************************************************************* + * retroshare-gui/src/gui/TheWire/WireGroupExtra.h * + * * + * Copyright (C) 2020 by Robert Fernie * + * * + * 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 . * + * * + *******************************************************************************/ + +#ifndef WIRE_GROUP_EXTRA_H +#define WIRE_GROUP_EXTRA_H + +#include +#include "ui_WireGroupExtra.h" + +class WireGroupExtra : public QWidget +{ + Q_OBJECT + +public: + explicit WireGroupExtra(QWidget *parent = 0); + virtual ~WireGroupExtra(); + + void setMasthead(const QPixmap &pixmap); + QPixmap getMasthead(); + + void setTagline(const std::string &str); + void setLocation(const std::string &str); + + std::string getTagline(); + std::string getLocation(); + +private slots: + void addMasthead(); + +private: + void setUp(); +private: + QPixmap mMasthead; + Ui::WireGroupExtra ui; +}; + +#endif // WIRE_GROUP_EXTRA_H diff --git a/retroshare-gui/src/gui/TheWire/WireGroupExtra.ui b/retroshare-gui/src/gui/TheWire/WireGroupExtra.ui new file mode 100644 index 000000000..fb1da5e73 --- /dev/null +++ b/retroshare-gui/src/gui/TheWire/WireGroupExtra.ui @@ -0,0 +1,68 @@ + + + WireGroupExtra + + + + 0 + 0 + 516 + 199 + + + + + 0 + 0 + + + + Form + + + + + + Masthead + + + + + + + MastHead background Image + + + + + + + Select Image + + + + + + + Tagline: + + + + + + + + + + Location: + + + + + + + + + + + diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index 53ba27470..42f737005 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -1226,6 +1226,7 @@ gxsthewire { gui/TheWire/WireDialog.h \ gui/TheWire/WireGroupItem.h \ gui/TheWire/WireGroupDialog.h \ + gui/TheWire/WireGroupExtra.h \ gui/TheWire/PulseAddDialog.h \ gui/TheWire/PulseViewItem.h \ gui/TheWire/PulseTopLevel.h \ @@ -1237,6 +1238,7 @@ gxsthewire { FORMS += gui/TheWire/PulseItem.ui \ gui/TheWire/PulseDetails.ui \ gui/TheWire/WireGroupItem.ui \ + gui/TheWire/WireGroupExtra.ui \ gui/TheWire/WireDialog.ui \ gui/TheWire/PulseAddDialog.ui \ gui/TheWire/PulseTopLevel.ui \ @@ -1250,6 +1252,7 @@ gxsthewire { gui/TheWire/WireDialog.cpp \ gui/TheWire/WireGroupItem.cpp \ gui/TheWire/WireGroupDialog.cpp \ + gui/TheWire/WireGroupExtra.cpp \ gui/TheWire/PulseAddDialog.cpp \ gui/TheWire/PulseViewItem.cpp \ gui/TheWire/PulseTopLevel.cpp \