2013-03-11 20:53:15 +00:00
|
|
|
/****************************************************************
|
|
|
|
* 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 "GxsChannelDialog.h"
|
2014-05-04 22:59:06 +00:00
|
|
|
#include "GxsChannelGroupDialog.h"
|
|
|
|
#include "GxsChannelPostsWidget.h"
|
|
|
|
#include "gui/channels/ShareKey.h"
|
2014-05-08 00:00:21 +00:00
|
|
|
#include "gui/feeds/GxsChannelPostItem.h"
|
2014-05-08 17:17:48 +00:00
|
|
|
#include "gui/settings/rsharesettings.h"
|
|
|
|
#include "gui/notifyqt.h"
|
2013-03-11 20:53:15 +00:00
|
|
|
|
|
|
|
/****
|
2013-07-19 09:48:51 +00:00
|
|
|
* #define DEBUG_CHANNEL
|
2013-03-11 20:53:15 +00:00
|
|
|
***/
|
|
|
|
|
|
|
|
/** Constructor */
|
|
|
|
GxsChannelDialog::GxsChannelDialog(QWidget *parent)
|
2014-05-08 00:00:21 +00:00
|
|
|
: GxsGroupFrameDialog(rsGxsChannels, parent)
|
2013-03-11 20:53:15 +00:00
|
|
|
{
|
2014-05-08 17:17:48 +00:00
|
|
|
connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged()));
|
|
|
|
|
|
|
|
settingsChanged();
|
2013-03-11 20:53:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GxsChannelDialog::~GxsChannelDialog()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-05-08 17:17:48 +00:00
|
|
|
//UserNotify *GxsChannelDialog::getUserNotify(QObject *parent)
|
|
|
|
//{
|
|
|
|
// return new ChannelUserNotify(parent);
|
|
|
|
//}
|
|
|
|
|
2014-05-04 22:59:06 +00:00
|
|
|
QString GxsChannelDialog::text(TextType type)
|
2013-03-24 16:29:08 +00:00
|
|
|
{
|
2014-05-04 22:59:06 +00:00
|
|
|
switch (type) {
|
|
|
|
case TEXT_NAME:
|
|
|
|
return tr("Channels");
|
|
|
|
case TEXT_NEW:
|
|
|
|
return tr("Create Channel");
|
|
|
|
case TEXT_TODO:
|
|
|
|
return "<b>Open points:</b><ul>"
|
|
|
|
"<li>Threaded load of messages"
|
|
|
|
"<li>Share key"
|
|
|
|
"<li>Restore channel keys"
|
|
|
|
"<li>Copy/navigate channel link"
|
|
|
|
"<li>Display count of unread messages"
|
|
|
|
"<li>Set all as read"
|
|
|
|
"<li>Set read/unread status"
|
|
|
|
"</ul>";
|
2013-03-24 16:29:08 +00:00
|
|
|
|
2014-05-04 22:59:06 +00:00
|
|
|
case TEXT_YOUR_GROUP:
|
|
|
|
return tr("My Channels");
|
|
|
|
case TEXT_SUBSCRIBED_GROUP:
|
|
|
|
return tr("Subscribed Channels");
|
|
|
|
case TEXT_POPULAR_GROUP:
|
|
|
|
return tr("Popular Channels");
|
|
|
|
case TEXT_OTHER_GROUP:
|
|
|
|
return tr("Other Channels");
|
2013-07-19 09:48:51 +00:00
|
|
|
}
|
2013-03-24 16:29:08 +00:00
|
|
|
|
2014-05-04 22:59:06 +00:00
|
|
|
return "";
|
2013-03-24 16:29:08 +00:00
|
|
|
}
|
|
|
|
|
2014-05-04 22:59:06 +00:00
|
|
|
QString GxsChannelDialog::icon(IconType type)
|
2013-03-11 20:53:15 +00:00
|
|
|
{
|
2014-05-04 22:59:06 +00:00
|
|
|
switch (type) {
|
|
|
|
case ICON_NAME:
|
2014-05-06 23:43:14 +00:00
|
|
|
return ":/images/channels24.png";
|
2014-05-04 22:59:06 +00:00
|
|
|
case ICON_NEW:
|
2014-05-06 23:43:14 +00:00
|
|
|
return ":/images/add_channel24.png";
|
2014-05-04 22:59:06 +00:00
|
|
|
case ICON_YOUR_GROUP:
|
|
|
|
return ":/images/channelsblue.png";
|
|
|
|
case ICON_SUBSCRIBED_GROUP:
|
|
|
|
return ":/images/channelsred.png";
|
|
|
|
case ICON_POPULAR_GROUP:
|
|
|
|
return ":/images/channelsgreen.png";
|
|
|
|
case ICON_OTHER_GROUP:
|
|
|
|
return ":/images/channelsyellow.png";
|
|
|
|
case ICON_DEFAULT:
|
|
|
|
return ":/images/channels.png";
|
|
|
|
}
|
|
|
|
|
|
|
|
return "";
|
2013-03-11 20:53:15 +00:00
|
|
|
}
|
|
|
|
|
2014-05-08 17:17:48 +00:00
|
|
|
void GxsChannelDialog::settingsChanged()
|
|
|
|
{
|
|
|
|
setSingleTab(!Settings->getChannelOpenAllInNewTab());
|
|
|
|
}
|
2013-03-11 20:53:15 +00:00
|
|
|
|
2014-05-04 22:59:06 +00:00
|
|
|
GxsGroupDialog *GxsChannelDialog::createNewGroupDialog(TokenQueue *tokenQueue)
|
2013-03-11 20:53:15 +00:00
|
|
|
{
|
2014-05-04 22:59:06 +00:00
|
|
|
return new GxsChannelGroupDialog(tokenQueue, this);
|
2013-03-11 20:53:15 +00:00
|
|
|
}
|
|
|
|
|
2014-05-04 22:59:06 +00:00
|
|
|
GxsGroupDialog *GxsChannelDialog::createGroupDialog(TokenQueue *tokenQueue, RsTokenService *tokenService, GxsGroupDialog::Mode mode, RsGxsGroupId groupId)
|
2013-03-11 20:53:15 +00:00
|
|
|
{
|
2014-05-04 22:59:06 +00:00
|
|
|
return new GxsChannelGroupDialog(tokenQueue, tokenService, mode, groupId, this);
|
2013-03-11 20:53:15 +00:00
|
|
|
}
|
|
|
|
|
2014-05-04 22:59:06 +00:00
|
|
|
int GxsChannelDialog::shareKeyType()
|
2013-03-11 20:53:15 +00:00
|
|
|
{
|
2014-05-04 22:59:06 +00:00
|
|
|
return CHANNEL_KEY_SHARE;
|
2013-03-11 20:53:15 +00:00
|
|
|
}
|
|
|
|
|
2014-05-04 22:59:06 +00:00
|
|
|
GxsMessageFrameWidget *GxsChannelDialog::createMessageFrameWidget(const RsGxsGroupId &groupId)
|
2013-03-11 20:53:15 +00:00
|
|
|
{
|
2014-05-08 00:00:21 +00:00
|
|
|
return new GxsChannelPostsWidget(groupId);
|
2013-03-11 20:53:15 +00:00
|
|
|
}
|
|
|
|
|
2014-05-04 22:59:06 +00:00
|
|
|
void GxsChannelDialog::groupTreeCustomActions(RsGxsGroupId grpId, int subscribeFlags, QList<QAction*> &actions)
|
2013-03-11 20:53:15 +00:00
|
|
|
{
|
2014-05-04 22:59:06 +00:00
|
|
|
bool isSubscribed = IS_GROUP_SUBSCRIBED(subscribeFlags);
|
|
|
|
bool autoDownload = rsGxsChannels->getChannelAutoDownload(grpId);
|
2013-07-19 09:48:51 +00:00
|
|
|
|
2014-05-04 22:59:06 +00:00
|
|
|
if (isSubscribed)
|
2013-07-19 09:48:51 +00:00
|
|
|
{
|
2014-05-04 22:59:06 +00:00
|
|
|
QAction *action = autoDownload ? (new QAction(QIcon(":/images/redled.png"), tr("Disable Auto-Download"), this))
|
|
|
|
: (new QAction(QIcon(":/images/start.png"),tr("Enable Auto-Download"), this));
|
2013-07-19 09:48:51 +00:00
|
|
|
|
2014-05-04 22:59:06 +00:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(toggleAutoDownload()));
|
|
|
|
actions.append(action);
|
2013-07-19 09:48:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-08 00:00:21 +00:00
|
|
|
RsGxsCommentService *GxsChannelDialog::getCommentService()
|
|
|
|
{
|
|
|
|
return rsGxsChannels;
|
|
|
|
}
|
|
|
|
|
|
|
|
QWidget *GxsChannelDialog::createCommentHeaderWidget(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId)
|
|
|
|
{
|
|
|
|
return new GxsChannelPostItem(NULL, 0, grpId, msgId, true, true);
|
|
|
|
}
|
|
|
|
|
2013-03-11 20:53:15 +00:00
|
|
|
void GxsChannelDialog::toggleAutoDownload()
|
|
|
|
{
|
2014-05-04 22:59:06 +00:00
|
|
|
RsGxsGroupId grpId = groupId();
|
|
|
|
if (grpId.isNull()) {
|
2013-07-19 09:48:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-03-11 20:53:15 +00:00
|
|
|
|
2014-05-04 22:59:06 +00:00
|
|
|
bool autoDownload = rsGxsChannels->getChannelAutoDownload(grpId);
|
|
|
|
if (!rsGxsChannels->setChannelAutoDownload(grpId, !autoDownload))
|
2013-07-19 09:48:51 +00:00
|
|
|
{
|
2014-05-04 22:59:06 +00:00
|
|
|
std::cerr << "GxsChannelDialog::toggleAutoDownload() Auto Download failed to set";
|
2013-07-19 09:48:51 +00:00
|
|
|
std::cerr << std::endl;
|
2013-03-11 20:53:15 +00:00
|
|
|
}
|
|
|
|
}
|