Пример #1
0
void GxsChannelDialog::channelListCustomPopupMenu( QPoint /*point*/ )
{
	if (mChannelId.empty()) 
	{
		return;
	}

	uint32_t subscribeFlags = ui.treeWidget->subscribeFlags(QString::fromStdString(mChannelId));

	QMenu contextMnu(this);

	bool isAdmin = IS_GROUP_ADMIN(subscribeFlags);
	bool isPublisher = IS_GROUP_PUBLISHER(subscribeFlags);
	bool isSubscribed = IS_GROUP_SUBSCRIBED(subscribeFlags);
	bool autoDownload = rsGxsChannels->getChannelAutoDownload(mChannelId);

	if (isPublisher)
	{
		QAction *postchannelAct = new QAction(QIcon(":/images/mail_reply.png"), tr( "Post to Channel" ), &contextMnu);
		connect( postchannelAct , SIGNAL( triggered() ), this, SLOT( createMsg() ) );
	  	contextMnu.addAction( postchannelAct );
		contextMnu.addSeparator();
	}

	if (isSubscribed)
	{
		QAction *setallasreadchannelAct = new QAction(QIcon(":/images/message-mail-read.png"), tr( "Set all as read" ), &contextMnu);
		connect( setallasreadchannelAct , SIGNAL( triggered() ), this, SLOT( setAllAsReadClicked() ) );
		contextMnu.addAction( setallasreadchannelAct );

		contextMnu.addSeparator();

		QAction *autoAct = new QAction(QIcon(":/images/redled.png"), tr( "Disable Auto-Download" ), &contextMnu);
		QAction *noautoAct = new QAction(QIcon(":/images/start.png"),tr( "Enable Auto-Download" ), &contextMnu);
		connect( autoAct , SIGNAL( triggered() ), this, SLOT( toggleAutoDownload() ) );
		connect( noautoAct , SIGNAL( triggered() ), this, SLOT( toggleAutoDownload() ) );

		contextMnu.addAction( autoAct );
		contextMnu.addAction( noautoAct );

		autoAct->setEnabled(autoDownload);
		noautoAct->setEnabled(!autoDownload);

		QAction *unsubscribechannelAct = new QAction(QIcon(":/images/cancel.png"), tr( "Unsubscribe to Channel" ), &contextMnu);
		connect( unsubscribechannelAct , SIGNAL( triggered() ), this, SLOT( unsubscribeChannel() ) );
		contextMnu.addAction( unsubscribechannelAct );
	}
	else
	{
		QAction *subscribechannelAct = new QAction(QIcon(":/images/edit_add24.png"), tr( "Subscribe to Channel" ), &contextMnu);
		connect( subscribechannelAct , SIGNAL( triggered() ), this, SLOT( subscribeChannel() ) );
		contextMnu.addAction( subscribechannelAct );
	}

	if (isAdmin)
	{
		QAction *editChannelDetailAct = new QAction(QIcon(":/images/edit_16.png"), tr("Edit Channel Details"), &contextMnu);
		connect( editChannelDetailAct, SIGNAL( triggered() ), this, SLOT( editChannelDetail() ) );
		contextMnu.addAction( editChannelDetailAct);
	}
	else
	{
		QAction *channeldetailsAct = new QAction(QIcon(":/images/info16.png"), tr( "Show Channel Details" ), &contextMnu);
		connect( channeldetailsAct , SIGNAL( triggered() ), this, SLOT( showChannelDetails() ) );
		contextMnu.addAction( channeldetailsAct );
	}

	if (isPublisher)
	{
		QAction *restoreKeysAct = new QAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights for Channel" ), &contextMnu);
		connect( restoreKeysAct , SIGNAL( triggered() ), this, SLOT( restoreChannelKeys() ) );
		contextMnu.addAction( restoreKeysAct );
	}
	else
	{
		QAction *shareKeyAct = new QAction(QIcon(":/images/gpgp_key_generate.png"), tr("Share Channel"), &contextMnu);
		connect( shareKeyAct, SIGNAL( triggered() ), this, SLOT( shareKey() ) );
		contextMnu.addAction( shareKeyAct );
	}

	contextMnu.addSeparator();
	QAction *action = contextMnu.addAction(QIcon(":/images/copyrslink.png"), tr("Copy RetroShare Link"), this, SLOT(copyChannelLink()));
	action->setEnabled(!mChannelId.empty());

	contextMnu.exec(QCursor::pos());

#if 0
	ChannelInfo ci;
	if (!rsChannels->getChannelInfo(mChannelId, ci)) {
		return;
	}

	QMenu contextMnu(this);

	QAction *postchannelAct = new QAction(QIcon(":/images/mail_reply.png"), tr( "Post to Channel" ), &contextMnu);
	connect( postchannelAct , SIGNAL( triggered() ), this, SLOT( createMsg() ) );

	QAction *subscribechannelAct = new QAction(QIcon(":/images/edit_add24.png"), tr( "Subscribe to Channel" ), &contextMnu);
	connect( subscribechannelAct , SIGNAL( triggered() ), this, SLOT( subscribeChannel() ) );

	QAction *unsubscribechannelAct = new QAction(QIcon(":/images/cancel.png"), tr( "Unsubscribe to Channel" ), &contextMnu);
	connect( unsubscribechannelAct , SIGNAL( triggered() ), this, SLOT( unsubscribeChannel() ) );

	QAction *setallasreadchannelAct = new QAction(QIcon(":/images/message-mail-read.png"), tr( "Set all as read" ), &contextMnu);
	connect( setallasreadchannelAct , SIGNAL( triggered() ), this, SLOT( setAllAsReadClicked() ) );

	bool autoDl = false;
	rsChannels->channelGetAutoDl(mChannelId, autoDl);

	QAction *autochannelAct = autoDl? (new QAction(QIcon(":/images/redled.png"), tr( "Disable Auto-Download" ), &contextMnu))
			 									: (new QAction(QIcon(":/images/start.png"),tr( "Enable Auto-Download" ), &contextMnu)) ;

	connect( autochannelAct , SIGNAL( triggered() ), this, SLOT( toggleAutoDownload() ) );

	QAction *channeldetailsAct = new QAction(QIcon(":/images/info16.png"), tr( "Show Channel Details" ), &contextMnu);
	connect( channeldetailsAct , SIGNAL( triggered() ), this, SLOT( showChannelDetails() ) );

	QAction *restoreKeysAct = new QAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights for Channel" ), &contextMnu);
	connect( restoreKeysAct , SIGNAL( triggered() ), this, SLOT( restoreChannelKeys() ) );

	QAction *editChannelDetailAct = new QAction(QIcon(":/images/edit_16.png"), tr("Edit Channel Details"), &contextMnu);
	connect( editChannelDetailAct, SIGNAL( triggered() ), this, SLOT( editChannelDetail() ) );

	QAction *shareKeyAct = new QAction(QIcon(":/images/gpgp_key_generate.png"), tr("Share Channel"), &contextMnu);
	connect( shareKeyAct, SIGNAL( triggered() ), this, SLOT( shareKey() ) );

	if((ci.channelFlags & RS_DISTRIB_ADMIN) && (ci.channelFlags & RS_DISTRIB_SUBSCRIBED))
		contextMnu.addAction( editChannelDetailAct);
	else
		contextMnu.addAction( channeldetailsAct );

	if((ci.channelFlags & RS_DISTRIB_PUBLISH) && (ci.channelFlags & RS_DISTRIB_SUBSCRIBED)) 
	{
		contextMnu.addAction( postchannelAct );
		contextMnu.addAction( shareKeyAct );
	}

	if(ci.channelFlags & RS_DISTRIB_SUBSCRIBED)
	{
		contextMnu.addAction( unsubscribechannelAct );
		contextMnu.addAction( restoreKeysAct );
		contextMnu.addSeparator();
		contextMnu.addAction( autochannelAct );
		contextMnu.addAction( setallasreadchannelAct );
	}
	else
		contextMnu.addAction( subscribechannelAct );

	contextMnu.addSeparator();
	QAction *action = contextMnu.addAction(QIcon(":/images/copyrslink.png"), tr("Copy RetroShare Link"), this, SLOT(copyChannelLink()));
	action->setEnabled(!mChannelId.empty());

	contextMnu.exec(QCursor::pos());

#endif
}
Пример #2
0
void ChannelFeed::channelListCustomPopupMenu( QPoint /*point*/ )
{
    ChannelInfo ci;
    if (!rsChannels->getChannelInfo(mChannelId, ci)) {
        return;
    }

    QMenu contextMnu(this);

    QAction *postchannelAct = new QAction(QIcon(":/images/mail_reply.png"), tr( "Post to Channel" ), &contextMnu);
    connect( postchannelAct , SIGNAL( triggered() ), this, SLOT( createMsg() ) );

    QAction *subscribechannelAct = new QAction(QIcon(":/images/edit_add24.png"), tr( "Subscribe to Channel" ), &contextMnu);
    connect( subscribechannelAct , SIGNAL( triggered() ), this, SLOT( subscribeChannel() ) );

    QAction *unsubscribechannelAct = new QAction(QIcon(":/images/cancel.png"), tr( "Unsubscribe to Channel" ), &contextMnu);
    connect( unsubscribechannelAct , SIGNAL( triggered() ), this, SLOT( unsubscribeChannel() ) );

    QAction *setallasreadchannelAct = new QAction(QIcon(":/images/message-mail-read.png"), tr( "Set all as read" ), &contextMnu);
    connect( setallasreadchannelAct , SIGNAL( triggered() ), this, SLOT( setAllAsReadClicked() ) );

    bool autoDl = false;
    rsChannels->channelGetAutoDl(mChannelId, autoDl);

    QAction *autochannelAct = autoDl? (new QAction(QIcon(":/images/redled.png"), tr( "Disable Auto-Download" ), &contextMnu))
			 									: (new QAction(QIcon(":/images/start.png"),tr( "Enable Auto-Download" ), &contextMnu)) ;
	 
    connect( autochannelAct , SIGNAL( triggered() ), this, SLOT( toggleAutoDownload() ) );

    QAction *channeldetailsAct = new QAction(QIcon(":/images/info16.png"), tr( "Show Channel Details" ), &contextMnu);
    connect( channeldetailsAct , SIGNAL( triggered() ), this, SLOT( showChannelDetails() ) );

    QAction *restoreKeysAct = new QAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights for Channel" ), &contextMnu);
    connect( restoreKeysAct , SIGNAL( triggered() ), this, SLOT( restoreChannelKeys() ) );

    QAction *editChannelDetailAct = new QAction(QIcon(":/images/edit_16.png"), tr("Edit Channel Details"), &contextMnu);
    connect( editChannelDetailAct, SIGNAL( triggered() ), this, SLOT( editChannelDetail() ) );

    QAction *shareKeyAct = new QAction(QIcon(":/images/gpgp_key_generate.png"), tr("Share Channel"), &contextMnu);
    connect( shareKeyAct, SIGNAL( triggered() ), this, SLOT( shareKey() ) );

	 if((ci.channelFlags & RS_DISTRIB_ADMIN) && (ci.channelFlags & RS_DISTRIB_SUBSCRIBED))
        contextMnu.addAction( editChannelDetailAct);
	 else
        contextMnu.addAction( channeldetailsAct );

    if((ci.channelFlags & RS_DISTRIB_PUBLISH) && (ci.channelFlags & RS_DISTRIB_SUBSCRIBED)) 
	 {
      contextMnu.addAction( postchannelAct );
      contextMnu.addAction( shareKeyAct );
	 }

	 if(ci.channelFlags & RS_DISTRIB_SUBSCRIBED)
	 {
		 contextMnu.addAction( unsubscribechannelAct );
		 contextMnu.addAction( restoreKeysAct );
		 contextMnu.addSeparator();
		 contextMnu.addAction( autochannelAct );
		 contextMnu.addAction( setallasreadchannelAct );
	 }
	 else
        contextMnu.addAction( subscribechannelAct );

	 contextMnu.addSeparator();
    QAction *action = contextMnu.addAction(QIcon(":/images/copyrslink.png"), tr("Copy RetroShare Link"), this, SLOT(copyChannelLink()));
    action->setEnabled(!mChannelId.empty());

#ifdef CHAN_DEBUG
    contextMnu.addSeparator();
    action = contextMnu.addAction("Generate mass data", this, SLOT(generateMassData()));
    action->setEnabled (!mChannelId.empty() && (ci.channelFlags & RS_DISTRIB_PUBLISH));
#endif

    contextMnu.exec(QCursor::pos());
}