From bfa2da61f530a943dc22d06324c2c288caab64ac Mon Sep 17 00:00:00 2001 From: chrisparker126 Date: Sun, 2 May 2010 12:20:30 +0000 Subject: [PATCH] new create channel ui - essentailly a copy of createforums explicitly for channels git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2828 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- .../src/gui/channels/CreateChannel.cpp | 147 +++++++ .../src/gui/channels/CreateChannel.h | 59 +++ .../src/gui/channels/CreateChannel.ui | 367 ++++++++++++++++++ 3 files changed, 573 insertions(+) create mode 100644 retroshare-gui/src/gui/channels/CreateChannel.cpp create mode 100644 retroshare-gui/src/gui/channels/CreateChannel.h create mode 100644 retroshare-gui/src/gui/channels/CreateChannel.ui diff --git a/retroshare-gui/src/gui/channels/CreateChannel.cpp b/retroshare-gui/src/gui/channels/CreateChannel.cpp new file mode 100644 index 000000000..91a27b500 --- /dev/null +++ b/retroshare-gui/src/gui/channels/CreateChannel.cpp @@ -0,0 +1,147 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2008 Robert Fernie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + +#include +#include + +#include "CreateChannel.h" + +#include "rsiface/rschannels.h" + +/** Constructor */ +CreateChannel::CreateChannel(QWidget *parent) +: QDialog(parent) +{ + /* Invoke the Qt Designer generated object setup routine */ + ui.setupUi(this); + + // connect up the buttons. + connect( ui.cancelButton, SIGNAL( clicked ( bool ) ), this, SLOT( cancelChannel( ) ) ); + connect( ui.createButton, SIGNAL( clicked ( bool ) ), this, SLOT( createChannel( ) ) ); + + connect( ui.LogoButton, SIGNAL(clicked() ), this , SLOT(addChannelLogo())); + connect( ui.ChannelLogoButton, SIGNAL(clicked() ), this , SLOT(addChannelLogo())); + + newChannel(); + +} + +void CreateChannel::show() +{ + //loadSettings(); + if(!this->isVisible()) { + QWidget::show(); + + } +} + + +void CreateChannel::newChannel() +{ + /* enforce Private for the moment */ + ui.typePrivate->setChecked(true); + + ui.typePublic->setEnabled(false); + ui.typeEncrypted->setEnabled(false); + + ui.msgAnon->setChecked(true); + ui.msgAuth->setEnabled(false); + ui.msgGroupBox->hide(); +} + +void CreateChannel::createChannel() +{ + QString name = ui.channelName->text(); + QString desc = ui.channelDesc->toPlainText(); + uint32_t flags = 0; + + if(name.isEmpty()) + { /* error message */ + int ret = QMessageBox::warning(this, tr("RetroShare"), + tr("Please add a Name"), + QMessageBox::Ok, QMessageBox::Ok); + + return; //Don't add a empty name!! + } + else + + if (ui.typePublic->isChecked()) + { + flags |= RS_DISTRIB_PUBLIC; + } + else if (ui.typePrivate->isChecked()) + { + flags |= RS_DISTRIB_PRIVATE; + } + else if (ui.typeEncrypted->isChecked()) + { + flags |= RS_DISTRIB_ENCRYPTED; + } + + if (ui.msgAuth->isChecked()) + { + flags |= RS_DISTRIB_AUTHEN_REQ; + } + else if (ui.msgAnon->isChecked()) + { + flags |= RS_DISTRIB_AUTHEN_ANON; + } + + if (rsChannels) + { + rsChannels->createChannel(name.toStdWString(), desc.toStdWString(), flags); + } + + close(); + return; +} + + +void CreateChannel::cancelChannel() +{ + close(); + return; +} + +void CreateChannel::addChannelLogo() +{ + 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.ChannelLogoButton->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 ; + + //rsMsgs->setOwnAvatarData((unsigned char *)(ba.data()),ba.size()) ; // last char 0 included. + + } +} diff --git a/retroshare-gui/src/gui/channels/CreateChannel.h b/retroshare-gui/src/gui/channels/CreateChannel.h new file mode 100644 index 000000000..b4e0177f9 --- /dev/null +++ b/retroshare-gui/src/gui/channels/CreateChannel.h @@ -0,0 +1,59 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2008 Robert Fernie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + + +#ifndef _CREATE_CHANNEL_DIALOG_H +#define _CREATE_CHANNEL_DIALOG_H + +#include + +#include "ui_CreateChannel.h" + +class CreateChannel : public QDialog +{ + Q_OBJECT + +public: + CreateChannel(QWidget *parent = 0); + +void newChannel(); /* cleanup */ + + /** Qt Designer generated object */ + Ui::CreateChannel ui; + + QPixmap picture; + +public slots: + /** Overloaded QWidget.show */ + void show(); + +private slots: + + /* actions to take.... */ +void createChannel(); +void cancelChannel(); + +void addChannelLogo(); + +}; + +#endif + diff --git a/retroshare-gui/src/gui/channels/CreateChannel.ui b/retroshare-gui/src/gui/channels/CreateChannel.ui new file mode 100644 index 000000000..461ef44a0 --- /dev/null +++ b/retroshare-gui/src/gui/channels/CreateChannel.ui @@ -0,0 +1,367 @@ + + + CreateChannel + + + + 0 + 0 + 534 + 535 + + + + Create a new Channel + + + + :/images/rstray3.png:/images/rstray3.png + + + + 0 + + + 0 + + + + + + 16777215 + 64 + + + + QFrame#frame_2{background-image: url(:/images/connect/connectFriendBanner.png);} + + + QFrame::NoFrame + + + QFrame::Raised + + + + 6 + + + 6 + + + + + + 48 + 48 + + + + + + + + + + :/images/konversation64.png + + + true + + + + + + + color: rgb(255, 255, 255); + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:24pt; font-weight:600; color:#ffffff;">New Channel</span></p></body></html> + + + + + + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + + + + + Name + + + + + + + + + + + + + + Description + + + + + + + + + + + + Type: + + + + 0 + + + 6 + + + + + Public - Anyone can read and publish (Shared Publish Key) + + + + + + + Restricted - Anyone can read, limited publishing (Private Publish Key) + + + + + + + Private - (Private Publish Key required to view Messages) + + + + + + + + + + Allowed Messages + + + + 0 + + + 6 + + + + + Authemticated Messages + + + + + + + Anonymous Messages + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + Qt::Horizontal + + + + 238 + 20 + + + + + + + + Cancel + + + + + + + Create + + + true + + + + + + + Channel Logo + + + + 6 + + + 6 + + + 6 + + + 2 + + + 6 + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + +border: 2px solid white; +border-radius: 10px; + + + + + + + + :/images/channels.png:/images/channels.png + + + + 64 + 64 + + + + + + + + Add Channel Logo + + + + :/images/add_image24.png:/images/add_image24.png + + + + + + + Qt::Horizontal + + + + 118 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + + + + + + + + + + + +