Enabled to display the Channel logo on Channel Edit

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3485 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2010-09-14 13:00:32 +00:00
parent f7635044ae
commit fc6c5ea22f
2 changed files with 58 additions and 25 deletions

View File

@ -20,29 +20,34 @@
****************************************************************/
#include "EditChanDetails.h"
#include <QFileDialog>
#include <retroshare/rschannels.h>
#include <list>
#include <iostream>
#include <string>
#define CHAN_DEFAULT_IMAGE ":/images/channels.png"
/** Default constructor */
EditChanDetails::EditChanDetails(QWidget *parent, Qt::WFlags flags, std::string cId)
: QDialog(parent, flags), mChannelId(cId)
{
/* Invoke Qt Designer generated QObject setup routine */
ui.setupUi(this);
/* Invoke Qt Designer generated QObject setup routine */
ui.setupUi(this);
connect(ui.applyButton, SIGNAL(clicked()), this, SLOT(applyDialog()));
connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(closeinfodlg()));
connect(ui.applyButton, SIGNAL(clicked()), this, SLOT(applyDialog()));
connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(closeinfodlg()));
connect( ui.LogoButton, SIGNAL(clicked() ), this , SLOT(addChannelLogo()));
connect( ui.ChannelLogoButton, SIGNAL(clicked() ), this , SLOT(addChannelLogo()));
ui.ChannelLogoButton->setDisabled(true);
ui.LogoButton->setDisabled(true);
ui.ChannelLogoButton->setDisabled(true);
ui.ChannelLogoButton->hide();
ui.LogoButton->setDisabled(true);
ui.LogoButton->hide();
loadChannel();
loadChannel();
}
@ -61,7 +66,7 @@ void EditChanDetails::show()
void EditChanDetails::closeEvent (QCloseEvent * event)
{
QWidget::closeEvent(event);
QWidget::closeEvent(event);
}
void EditChanDetails::closeinfodlg()
@ -87,6 +92,19 @@ void EditChanDetails::loadChannel()
// Set Channel Description
ui.DescriptiontextEdit->setText(QString::fromStdWString(ci.channelDesc));
// Set Channel Logo
if(ci.pngImageLen != 0)
{
QPixmap chanImage;
chanImage.loadFromData(ci.pngChanImage, ci.pngImageLen, "PNG");
ui.ChannelLogoButton->setIcon(QIcon(chanImage));
}
else
{
QPixmap defaulImage(CHAN_DEFAULT_IMAGE);
ui.ChannelLogoButton->setIcon(QIcon(defaulImage));
}
}
@ -116,4 +134,15 @@ void EditChanDetails::applyDialog()
}
void EditChanDetails::addChannelLogo()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Load File"), QDir::homePath(), tr("Pictures (*.png *.xpm *.jpg)"));
if(!fileName.isEmpty())
{
picture = QPixmap(fileName).scaled(64,64, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
// to show the selected
ui.ChannelLogoButton->setIcon(picture);
}
}

View File

@ -30,36 +30,40 @@ class EditChanDetails : public QDialog
{
Q_OBJECT
public:
public:
/** Default constructor */
EditChanDetails(QWidget *parent = 0, Qt::WFlags flags = 0, std::string cId = "");
/** Default destructor */
/** Default constructor */
EditChanDetails(QWidget *parent = 0, Qt::WFlags flags = 0, std::string cId = "");
/** Default destructor */
signals:
void configChanged() ;
void configChanged() ;
public slots:
/** Overloaded QWidget.show */
void show();
/** Overloaded QWidget.show */
void show();
protected:
void closeEvent (QCloseEvent * event);
void closeEvent (QCloseEvent * event);
private slots:
void closeinfodlg();
void applyDialog();
void addChannelLogo();
private:
void loadChannel();
void loadChannel();
std::string mChannelId;
/** Qt Designer generated object */
Ui::EditChanDetails ui;
std::string mChannelId;
QPixmap picture;
/** Qt Designer generated object */
Ui::EditChanDetails ui;
};