edit channel info dialog

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3062 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2010-06-04 22:52:54 +00:00
parent ef56b199b8
commit 478c4e1c29
3 changed files with 362 additions and 0 deletions

View File

@ -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 <list>
#include <iostream>
#include <string>
/** 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;
}

View File

@ -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 <QDialog>
#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

View File

@ -0,0 +1,176 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EditChanDetails</class>
<widget class="QDialog" name="EditChanDetails">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>436</width>
<height>355</height>
</rect>
</property>
<property name="windowTitle">
<string>Channel Details</string>
</property>
<property name="windowIcon">
<iconset resource="../images.qrc">
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0">
<layout class="QGridLayout" name="_2">
<item row="0" column="0">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>311</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="applyButton">
<property name="text">
<string>OK</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QTabWidget" name="stabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/info16.png</normaloff>:/images/info16.png</iconset>
</attribute>
<attribute name="title">
<string>Edit Channel Detail</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Channel Info</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Channel Name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="nameline"/>
</item>
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Channel Description</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTextEdit" name="DescriptiontextEdit"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_4">
<item row="1" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>118</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="LogoButton">
<property name="text">
<string>Add Channel 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="0" column="0" rowspan="2">
<widget class="QToolButton" name="ChannelLogoButton">
<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/channels.png</normaloff>:/images/channels.png</iconset>
</property>
<property name="iconSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>