added group icon support for blogs and channels

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2905 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2010-05-14 13:06:58 +00:00
parent 27895d1781
commit 26a808b3e7
6 changed files with 175 additions and 35 deletions

View File

@ -43,6 +43,8 @@
#include "GeneralMsgDialog.h" #include "GeneralMsgDialog.h"
#define CHAN_DEFAULT_IMAGE ":/images/channels.png"
/**** /****
* #define CHAN_DEBUG * #define CHAN_DEBUG
***/ ***/
@ -655,6 +657,15 @@ void ChannelFeed::updateChannelMsgs()
return; return;
} }
if(ci.pngImageLen != 0){
QPixmap chanImage;
chanImage.loadFromData(ci.pngChanImage, ci.pngImageLen, "PNG");
iconLabel->setPixmap(chanImage);
}else{
QPixmap defaulImage(CHAN_DEFAULT_IMAGE);
iconLabel->setPixmap(defaulImage);
}
iconLabel->setEnabled(true); iconLabel->setEnabled(true);
/* set textcolor for Channel name */ /* set textcolor for Channel name */

View File

@ -33,6 +33,8 @@ CreateChannel::CreateChannel(QWidget *parent)
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); ui.setupUi(this);
picture = NULL;
// connect up the buttons. // connect up the buttons.
connect( ui.cancelButton, SIGNAL( clicked ( bool ) ), this, SLOT( cancelChannel( ) ) ); connect( ui.cancelButton, SIGNAL( clicked ( bool ) ), this, SLOT( cancelChannel( ) ) );
connect( ui.createButton, SIGNAL( clicked ( bool ) ), this, SLOT( createChannel( ) ) ); connect( ui.createButton, SIGNAL( clicked ( bool ) ), this, SLOT( createChannel( ) ) );
@ -103,10 +105,19 @@ void CreateChannel::createChannel()
{ {
flags |= RS_DISTRIB_AUTHEN_ANON; flags |= RS_DISTRIB_AUTHEN_ANON;
} }
QByteArray ba;
QBuffer buffer(&ba);
if(!picture.isNull()){
// send chan image
buffer.open(QIODevice::WriteOnly);
picture.save(&buffer, "PNG"); // writes image into ba in PNG format
}
if (rsChannels) if (rsChannels)
{ {
rsChannels->createChannel(name.toStdWString(), desc.toStdWString(), flags); rsChannels->createChannel(name.toStdWString(), desc.toStdWString(), flags, (unsigned char*)ba.data(), ba.size());
} }
close(); close();
@ -140,7 +151,5 @@ void CreateChannel::addChannelLogo()
std::cerr << "Image size = " << ba.size() << std::endl ; std::cerr << "Image size = " << ba.size() << std::endl ;
//rsMsgs->setOwnAvatarData((unsigned char *)(ba.data()),ba.size()) ; // last char 0 included.
} }
} }

View File

@ -36,7 +36,8 @@ CreateBlog::CreateBlog(QWidget *parent, bool isForum)
// connect up the buttons. // connect up the buttons.
connect( ui.cancelButton, SIGNAL( clicked ( bool ) ), this, SLOT( cancelBlog( ) ) ); connect( ui.cancelButton, SIGNAL( clicked ( bool ) ), this, SLOT( cancelBlog( ) ) );
connect( ui.createButton, SIGNAL( clicked ( bool ) ), this, SLOT( createBlog( ) ) ); connect( ui.createButton, SIGNAL( clicked ( bool ) ), this, SLOT( createBlog( ) ) );
connect( ui.LogoButton, SIGNAL(clicked() ), this , SLOT(addBlogLogo()));
connect( ui.blogLogoButton, SIGNAL(clicked() ), this , SLOT(addBlogLogo()));
newBlog(); newBlog();
@ -118,9 +119,20 @@ void CreateBlog::createBlog()
flags |= RS_DISTRIB_AUTHEN_ANON; flags |= RS_DISTRIB_AUTHEN_ANON;
} }
QByteArray ba;
QBuffer buffer(&ba);
if(!picture.isNull()){
// send chan image
buffer.open(QIODevice::WriteOnly);
picture.save(&buffer, "PNG"); // writes image into ba in PNG format
}
if (rsBlogs) if (rsBlogs)
{ {
rsBlogs->createBlog(name.toStdWString(), desc.toStdWString(), flags); rsBlogs->createBlog(name.toStdWString(), desc.toStdWString(), flags,
(unsigned char*) ba.data(), ba.size());
} }
@ -128,6 +140,28 @@ void CreateBlog::createBlog()
return; return;
} }
void CreateBlog::addBlogLogo(){
QString fileName = QFileDialog::getOpenFileName(this, "Load File", QDir::homePath(), "Pictures (*.png *.xpm *.jpg)");
if(!fileName.isEmpty())
{
picture = QPixmap(fileName).scaled(64,64, Qt::IgnoreAspectRatio);
// to show the selected
ui.blogLogoButton->setIcon(picture);
std::cerr << "Sending avatar image down the pipe" << std::endl ;
// send avatar down the pipe for other peers to get it.
QByteArray ba;
QBuffer buffer(&ba);
buffer.open(QIODevice::WriteOnly);
picture.save(&buffer, "PNG"); // writes image into ba in PNG format
std::cerr << "Image size = " << ba.size() << std::endl ;
}
}
void CreateBlog::cancelBlog() void CreateBlog::cancelBlog()
{ {

View File

@ -49,6 +49,7 @@ private slots:
/* actions to take.... */ /* actions to take.... */
void createBlog(); void createBlog();
void cancelBlog(); void cancelBlog();
void addBlogLogo();
private: private:

View File

@ -7,14 +7,14 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>534</width> <width>534</width>
<height>481</height> <height>545</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Create new Blog</string> <string>Create new Blog</string>
</property> </property>
<property name="windowIcon"> <property name="windowIcon">
<iconset resource="../images.qrc"> <iconset resource="../../images.qrc">
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset> <normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property> </property>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
@ -63,7 +63,7 @@
<string/> <string/>
</property> </property>
<property name="pixmap"> <property name="pixmap">
<pixmap resource="../images.qrc">:/images/hi48-app-kblogger.png</pixmap> <pixmap resource="../../images.qrc">:/images/hi48-app-kblogger.png</pixmap>
</property> </property>
<property name="scaledContents"> <property name="scaledContents">
<bool>true</bool> <bool>true</bool>
@ -87,7 +87,7 @@ p, li { white-space: pre-wrap; }
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="2" column="0">
<widget class="QFrame" name="frame"> <widget class="QFrame" name="frame">
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::NoFrame</enum> <enum>QFrame::NoFrame</enum>
@ -95,8 +95,8 @@ p, li { white-space: pre-wrap; }
<property name="frameShadow"> <property name="frameShadow">
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<layout class="QGridLayout" name="gridLayout_5"> <layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0" colspan="3"> <item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
@ -110,21 +110,17 @@ p, li { white-space: pre-wrap; }
</item> </item>
</layout> </layout>
</item> </item>
<item row="1" column="0" colspan="3"> <item row="1" column="0">
<layout class="QVBoxLayout">
<item>
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="label_5">
<property name="text"> <property name="text">
<string>Description</string> <string>Description</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="2" column="0" colspan="3">
<widget class="QTextEdit" name="forumDesc"/> <widget class="QTextEdit" name="forumDesc"/>
</item> </item>
</layout> <item row="3" column="0" colspan="3">
</item>
<item row="2" column="0" colspan="3">
<widget class="QGroupBox" name="tyoeGroupBox"> <widget class="QGroupBox" name="tyoeGroupBox">
<property name="title"> <property name="title">
<string>Type:</string> <string>Type:</string>
@ -160,7 +156,7 @@ p, li { white-space: pre-wrap; }
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="3"> <item row="4" column="0" colspan="3">
<widget class="QGroupBox" name="msgGroupBox"> <widget class="QGroupBox" name="msgGroupBox">
<property name="title"> <property name="title">
<string>Allowed Messages</string> <string>Allowed Messages</string>
@ -186,15 +182,102 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </item>
<item> </layout>
<spacer name="verticalSpacer_2"> </widget>
</item>
<item row="5" column="0" colspan="3">
<widget class="QGroupBox" name="groupBoxLogo">
<property name="title">
<string>Blog Logo</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<property name="verticalSpacing">
<number>6</number>
</property>
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" rowspan="2">
<widget class="QToolButton" name="blogLogoButton">
<property name="minimumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">
border: 2px solid white;
border-radius: 10px;
</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../images.qrc">
<normaloff>:/images/hi64-app-kblogger.png</normaloff>:/images/hi64-app-kblogger.png</iconset>
</property>
<property name="iconSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="LogoButton">
<property name="text">
<string>Add Blog Logo</string>
</property>
<property name="icon">
<iconset resource="../../images.qrc">
<normaloff>:/images/add_image24.png</normaloff>:/images/add_image24.png</iconset>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>118</width>
<height>40</height> <height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size> </size>
</property> </property>
</spacer> </spacer>
@ -202,7 +285,7 @@ p, li { white-space: pre-wrap; }
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="6" column="0">
<spacer> <spacer>
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -215,14 +298,14 @@ p, li { white-space: pre-wrap; }
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="4" column="1"> <item row="6" column="1">
<widget class="QPushButton" name="cancelButton"> <widget class="QPushButton" name="cancelButton">
<property name="text"> <property name="text">
<string>Cancel</string> <string>Cancel</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="2"> <item row="6" column="2">
<widget class="QPushButton" name="createButton"> <widget class="QPushButton" name="createButton">
<property name="text"> <property name="text">
<string>Create</string> <string>Create</string>
@ -238,7 +321,8 @@ p, li { white-space: pre-wrap; }
</layout> </layout>
</widget> </widget>
<resources> <resources>
<include location="../images.qrc"/> <include location="../../images.qrc"/>
<include location="../../images.qrc"/>
<include location="../images.qrc"/> <include location="../images.qrc"/>
</resources> </resources>
<connections/> <connections/>

View File

@ -26,6 +26,7 @@
#include <QMap> #include <QMap>
#include <QPointer> #include <QPointer>
#include <QObject> #include <QObject>
#include <qsettings.h>
#include "ui_CreateBlogMsg.h" #include "ui_CreateBlogMsg.h"
#include <stdint.h> #include <stdint.h>