Added ServicePermissions Settings page.

This just presents dummy data at the moment.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7172 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2014-03-07 13:48:33 +00:00
parent a621dcc4d1
commit 740de02489
5 changed files with 364 additions and 0 deletions

View File

@ -0,0 +1,187 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006 - 2010 RetroShare Team
*
* 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 "ServicePermissionsPage.h"
#include "rshare.h"
#include <retroshare/rsservicecontrol.h>
#include <iostream>
#include <QTimer>
ServicePermissionsPage::ServicePermissionsPage(QWidget * parent, Qt::WindowFlags flags)
: ConfigPage(parent, flags)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
QObject::connect(ui.tableWidget,SIGNAL(itemChanged(QTableWidgetItem *)),
this, SLOT(tableItemChanged(QTableWidgetItem *)));
/* Hide platform specific features */
#ifdef Q_WS_WIN
#endif
}
QString ServicePermissionsPage::helpText() const
{
return tr("<h1><img width=\"24\" src=\":/images/64px_help.png\">&nbsp;&nbsp;Permissions</h1> \
<p>Permissions allow you to control which services are available to which friends </p>");
}
/** Saves the changes on this page */
bool ServicePermissionsPage::save(QString &/*errmsg*/)
{
return true;
}
QBrush getColor(bool defaultOn, Qt::CheckState checkState)
{
switch(checkState)
{
case Qt::Unchecked:
return QBrush(Qt::red);
break;
case Qt::Checked:
return QBrush(Qt::green);
break;
case Qt::PartiallyChecked:
default:
if (defaultOn)
{
return QBrush(Qt::darkGreen);
}
else
{
return QBrush(Qt::darkRed);
}
break;
}
return QBrush(Qt::gray);
}
/** Loads the settings for this page */
void ServicePermissionsPage::load()
{
/* get all the peers */
/* get all the services */
std::list<std::string> peerList;
std::list<std::string>::const_iterator pit;
peerList.push_back("peer1");
peerList.push_back("peer2");
peerList.push_back("peer3");
peerList.push_back("peer4");
std::list<std::string> serviceList;
std::list<std::string>::const_iterator sit;
serviceList.push_back("service1");
serviceList.push_back("service2");
serviceList.push_back("service3");
serviceList.push_back("service4");
ui.tableWidget->setRowCount(serviceList.size());
ui.tableWidget->setColumnCount(peerList.size() + 1);
QStringList columnHeaders;
QStringList rowHeaders;
columnHeaders.push_back(tr("Default"));
for(pit = peerList.begin(); pit != peerList.end(); pit++)
{
columnHeaders.push_back(QString::fromStdString(*pit));
}
int row;
int column;
for(row = 0, sit = serviceList.begin(); sit != serviceList.end(); sit++, row++)
{
rowHeaders.push_back(QString::fromStdString(*sit));
{
QTableWidgetItem *item = new QTableWidgetItem(tr("Default"));
Qt::ItemFlags flags(Qt::ItemIsUserCheckable);
flags |= Qt::ItemIsEnabled;
item->setFlags(flags);
item->setCheckState(Qt::Checked);
ui.tableWidget->setItem(row, 0, item);
}
for(column = 1, pit = peerList.begin();
pit != peerList.end(); pit++, column++)
{
QTableWidgetItem *item = new QTableWidgetItem();
Qt::ItemFlags flags(Qt::ItemIsUserCheckable);
flags |= Qt::ItemIsEnabled;
flags |= Qt::ItemIsTristate;
item->setFlags(flags);
item->setCheckState(Qt::PartiallyChecked);
ui.tableWidget->setItem(row, column, item);
}
}
ui.tableWidget->setHorizontalHeaderLabels(columnHeaders);
ui.tableWidget->setVerticalHeaderLabels(rowHeaders);
}
void ServicePermissionsPage::tableItemChanged ( QTableWidgetItem * item )
{
std::cerr << "ServicePermissionsPage::tableItemChanged()";
std::cerr << std::endl;
std::cerr << "\t Location: Row: " << item->row() << " Column: " << item->column();
std::cerr << std::endl;
std::cerr << "\t IsChecked: " << (Qt::Checked == item->checkState());
std::cerr << std::endl;
if (item->column() == 0)
{
/* update the row */
bool defaultOn = (Qt::Checked == item->checkState());
item->setBackground(getColor(defaultOn, Qt::PartiallyChecked));
for(int column = 1; column < ui.tableWidget->columnCount(); column++)
{
QTableWidgetItem *rowitem = ui.tableWidget->item (item->row(), column);
if (rowitem)
{
rowitem->setBackground(getColor(defaultOn, rowitem->checkState()));
}
}
}
else
{
QTableWidgetItem *defitem = ui.tableWidget->item (item->row(), 0);
if (defitem)
{
bool defaultOn = (Qt::Checked == defitem->checkState());
item->setBackground(getColor(defaultOn, item->checkState()));
}
}
}

View File

@ -0,0 +1,55 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006 - 2014 RetroShare Team
*
* 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 SERVICEPERMISSIONSPAGE_H
#define SERVICEPERMISSIONSPAGE_H
# include <QWidget>
#include <retroshare-gui/configpage.h>
#include "ui_ServicePermissionsPage.h"
class ServicePermissionsPage: public ConfigPage
{
Q_OBJECT
public:
ServicePermissionsPage(QWidget * parent = 0, Qt::WindowFlags flags = 0);
~ServicePermissionsPage() {}
/** Saves the changes on this page */
virtual bool save(QString &/*errmsg*/);
/** Loads the settings for this page */
virtual void load();
virtual QPixmap iconPixmap() const { return QPixmap(":/images/server_24x24.png") ; }
virtual QString pageName() const { return tr("Permissions") ; }
virtual QString helpText() const ;
public slots:
void tableItemChanged ( QTableWidgetItem * item );
private:
Ui::ServicePermissionsPage ui;
};
#endif //SERVICEPERMISSIONSPAGE_H

View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ServicePermissionsPage</class>
<widget class="QWidget" name="ServicePermissionsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>639</width>
<height>331</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>ServicePermissions</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>619</width>
<height>276</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTableWidget" name="tableWidget">
<row>
<property name="text">
<string>Chat</string>
</property>
</row>
<row>
<property name="text">
<string>Row2</string>
</property>
</row>
<row>
<property name="text">
<string>Shares</string>
</property>
</row>
<row>
<property name="text">
<string>Channels</string>
</property>
</row>
<column>
<property name="text">
<string>Default</string>
</property>
</column>
<column>
<property name="text">
<string>Joe</string>
</property>
</column>
<column>
<property name="text">
<string>Sally</string>
</property>
</column>
<column>
<property name="text">
<string>Anne</string>
</property>
</column>
<column>
<property name="text">
<string>Jacki</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -38,6 +38,7 @@
#include "MessagePage.h"
//#include "ForumPage.h"
#include "PluginsPage.h"
#include "ServicePermissionsPage.h"
#include "rsharesettings.h"
#include "gui/notifyqt.h"
#include "gui/common/FloatingHelpBrowser.h"
@ -135,6 +136,7 @@ RSettingsWin::initStackedWidget()
addPage(new ChatPage());
addPage(new AppearancePage());
addPage(new SoundPage() );
addPage(new ServicePermissionsPage() );
// add widgets from plugins

View File

@ -408,6 +408,7 @@ HEADERS += rshare.h \
gui/settings/TransferPage.h \
gui/settings/ChatPage.h \
gui/settings/RelayPage.h \
gui/settings/ServicePermissionsPage.h \
gui/settings/AddFileAssociationDialog.h \
gui/toaster/MessageToaster.h \
gui/toaster/OnlineToaster.h \
@ -567,6 +568,7 @@ FORMS += gui/StartDialog.ui \
gui/settings/SoundPage.ui \
gui/settings/ChatPage.ui \
gui/settings/RelayPage.ui \
gui/settings/ServicePermissionsPage.ui \
gui/settings/PluginItem.ui \
gui/toaster/MessageToaster.ui \
gui/toaster/OnlineToaster.ui \
@ -765,6 +767,7 @@ SOURCES += main.cpp \
gui/settings/TransferPage.cpp \
gui/settings/ChatPage.cpp \
gui/settings/RelayPage.cpp \
gui/settings/ServicePermissionsPage.cpp \
gui/settings/AddFileAssociationDialog.cpp \
gui/statusbar/peerstatus.cpp \
gui/statusbar/natstatus.cpp \