mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-08 22:32:34 -04:00
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:
parent
f7635044ae
commit
fc6c5ea22f
2 changed files with 58 additions and 25 deletions
|
@ -20,29 +20,34 @@
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
#include "EditChanDetails.h"
|
#include "EditChanDetails.h"
|
||||||
|
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
#include <retroshare/rschannels.h>
|
#include <retroshare/rschannels.h>
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#define CHAN_DEFAULT_IMAGE ":/images/channels.png"
|
||||||
|
|
||||||
|
|
||||||
/** Default constructor */
|
/** Default constructor */
|
||||||
EditChanDetails::EditChanDetails(QWidget *parent, Qt::WFlags flags, std::string cId)
|
EditChanDetails::EditChanDetails(QWidget *parent, Qt::WFlags flags, std::string cId)
|
||||||
: QDialog(parent, flags), mChannelId(cId)
|
: QDialog(parent, flags), mChannelId(cId)
|
||||||
{
|
{
|
||||||
/* Invoke Qt Designer generated QObject setup routine */
|
/* Invoke Qt Designer generated QObject setup routine */
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
connect(ui.applyButton, SIGNAL(clicked()), this, SLOT(applyDialog()));
|
connect(ui.applyButton, SIGNAL(clicked()), this, SLOT(applyDialog()));
|
||||||
connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(closeinfodlg()));
|
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);
|
loadChannel();
|
||||||
ui.ChannelLogoButton->hide();
|
|
||||||
ui.LogoButton->setDisabled(true);
|
|
||||||
ui.LogoButton->hide();
|
|
||||||
|
|
||||||
loadChannel();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +66,7 @@ void EditChanDetails::show()
|
||||||
|
|
||||||
void EditChanDetails::closeEvent (QCloseEvent * event)
|
void EditChanDetails::closeEvent (QCloseEvent * event)
|
||||||
{
|
{
|
||||||
QWidget::closeEvent(event);
|
QWidget::closeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditChanDetails::closeinfodlg()
|
void EditChanDetails::closeinfodlg()
|
||||||
|
@ -87,6 +92,19 @@ void EditChanDetails::loadChannel()
|
||||||
|
|
||||||
// Set Channel Description
|
// Set Channel Description
|
||||||
ui.DescriptiontextEdit->setText(QString::fromStdWString(ci.channelDesc));
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,36 +30,40 @@ class EditChanDetails : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** Default constructor */
|
/** Default constructor */
|
||||||
EditChanDetails(QWidget *parent = 0, Qt::WFlags flags = 0, std::string cId = "");
|
EditChanDetails(QWidget *parent = 0, Qt::WFlags flags = 0, std::string cId = "");
|
||||||
/** Default destructor */
|
/** Default destructor */
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void configChanged() ;
|
void configChanged() ;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/** Overloaded QWidget.show */
|
/** Overloaded QWidget.show */
|
||||||
void show();
|
void show();
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent (QCloseEvent * event);
|
void closeEvent (QCloseEvent * event);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void closeinfodlg();
|
void closeinfodlg();
|
||||||
void applyDialog();
|
void applyDialog();
|
||||||
|
void addChannelLogo();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void loadChannel();
|
void loadChannel();
|
||||||
|
|
||||||
std::string mChannelId;
|
std::string mChannelId;
|
||||||
/** Qt Designer generated object */
|
|
||||||
Ui::EditChanDetails ui;
|
QPixmap picture;
|
||||||
|
|
||||||
|
/** Qt Designer generated object */
|
||||||
|
Ui::EditChanDetails ui;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue