From 478c4e1c2914b52ca974e3b22b150f05851aadd6 Mon Sep 17 00:00:00 2001 From: chrisparker126 Date: Fri, 4 Jun 2010 22:52:54 +0000 Subject: [PATCH] edit channel info dialog git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3062 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- .../src/gui/channels/EditChanDetails.cpp | 119 ++++++++++++ .../src/gui/channels/EditChanDetails.h | 67 +++++++ .../src/gui/channels/EditChanDetails.ui | 176 ++++++++++++++++++ 3 files changed, 362 insertions(+) create mode 100644 retroshare-gui/src/gui/channels/EditChanDetails.cpp create mode 100644 retroshare-gui/src/gui/channels/EditChanDetails.h create mode 100644 retroshare-gui/src/gui/channels/EditChanDetails.ui diff --git a/retroshare-gui/src/gui/channels/EditChanDetails.cpp b/retroshare-gui/src/gui/channels/EditChanDetails.cpp new file mode 100644 index 000000000..8f441df17 --- /dev/null +++ b/retroshare-gui/src/gui/channels/EditChanDetails.cpp @@ -0,0 +1,119 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2010 Christopher Evi-Parker + * + * 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 "EditChanDetails.h" + +#include "rsiface/rschannels.h" + +#include +#include +#include + + +/** 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); + + connect(ui.applyButton, SIGNAL(clicked()), this, SLOT(applyDialog())); + connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(closeinfodlg())); + + ui.ChannelLogoButton->setDisabled(true); + ui.ChannelLogoButton->hide(); + ui.LogoButton->setDisabled(true); + ui.LogoButton->hide(); + + loadChannel(); + +} + + +/** + Overloads the default show() slot so we can set opacity*/ + +void EditChanDetails::show() +{ + + if(!this->isVisible()) { + QDialog::show(); + + } +} + +void EditChanDetails::closeEvent (QCloseEvent * event) +{ + QWidget::closeEvent(event); +} + +void EditChanDetails::closeinfodlg() +{ + close(); +} + + +void EditChanDetails::loadChannel() +{ + + if (!rsChannels) + { + return; + } + + ChannelInfo ci; + rsChannels->getChannelInfo(mChannelId, ci); + + // Set Channel Name + ui.nameline->setText(QString::fromStdWString(ci.channelName)); + + + // Set Channel Description + ui.DescriptiontextEdit->setText(QString::fromStdWString(ci.channelDesc)); + +} + +void EditChanDetails::applyDialog() +{ + + if(!rsChannels) + return; + + // if text boxes have not been edited leave alone + if(!ui.nameline->isModified() && !ui.DescriptiontextEdit->document()->isModified()) + return; + + ChannelInfo ci; + + ci.channelName = ui.nameline->text().toStdWString(); + ci.channelDesc = ui.DescriptiontextEdit->document()->toPlainText().toStdWString(); + + + /* reload now */ + rsChannels->channelEditInfo(mChannelId, ci); + + /* close the Dialog after the Changes applied */ + closeinfodlg(); + + return; +} + + + diff --git a/retroshare-gui/src/gui/channels/EditChanDetails.h b/retroshare-gui/src/gui/channels/EditChanDetails.h new file mode 100644 index 000000000..5898d30bf --- /dev/null +++ b/retroshare-gui/src/gui/channels/EditChanDetails.h @@ -0,0 +1,67 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2010 Christopher Evi-Parker + * + * 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 _EDITCHANDETAILS_H +#define _EDITCHANDETAILS_H + +#include + +#include "ui_EditChanDetails.h" + +class EditChanDetails : public QDialog +{ + Q_OBJECT + + public: + + /** Default constructor */ + EditChanDetails(QWidget *parent = 0, Qt::WFlags flags = 0, std::string cId = ""); + /** Default destructor */ + + +signals: + void configChanged() ; + +public slots: + /** Overloaded QWidget.show */ + void show(); + +protected: + void closeEvent (QCloseEvent * event); + +private slots: + + void closeinfodlg(); + void applyDialog(); + + +private: + + void loadChannel(); + + std::string mChannelId; + /** Qt Designer generated object */ + Ui::EditChanDetails ui; + +}; + +#endif + diff --git a/retroshare-gui/src/gui/channels/EditChanDetails.ui b/retroshare-gui/src/gui/channels/EditChanDetails.ui new file mode 100644 index 000000000..e95d4863f --- /dev/null +++ b/retroshare-gui/src/gui/channels/EditChanDetails.ui @@ -0,0 +1,176 @@ + + + EditChanDetails + + + + 0 + 0 + 436 + 355 + + + + Channel Details + + + + :/images/rstray3.png:/images/rstray3.png + + + + + + + + Qt::Horizontal + + + + 311 + 20 + + + + + + + + Cancel + + + + + + + OK + + + false + + + true + + + + + + + + + 0 + + + + + :/images/info16.png:/images/info16.png + + + Edit Channel Detail + + + + + + Channel Info + + + + + + Channel Name + + + + + + + + + + Channel Description + + + + + + + + + + + + + + + + + Qt::Horizontal + + + + 118 + 20 + + + + + + + + Add Channel Logo + + + + :/images/add_image24.png:/images/add_image24.png + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + +border: 2px solid white; +border-radius: 10px; + + + + + + + + :/images/channels.png:/images/channels.png + + + + 64 + 64 + + + + + + + + + + + + + + + + +