/** Constructor */
GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWidget *parent) :
    GxsMessageFramePostWidget(rsGxsChannels, parent),
    ui(new Ui::GxsChannelPostsWidget)
{
    /* Invoke the Qt Designer generated object setup routine */
    ui->setupUi(this);


    /* Setup UI helper */

    mStateHelper->addWidget(mTokenTypeAllPosts, ui->progressBar, UISTATE_LOADING_VISIBLE);
    mStateHelper->addWidget(mTokenTypeAllPosts, ui->loadingLabel, UISTATE_LOADING_VISIBLE);
    mStateHelper->addWidget(mTokenTypeAllPosts, ui->filterLineEdit);

    mStateHelper->addWidget(mTokenTypePosts, ui->loadingLabel, UISTATE_LOADING_VISIBLE);

    mStateHelper->addLoadPlaceholder(mTokenTypeGroupData, ui->nameLabel);

    mStateHelper->addWidget(mTokenTypeGroupData, ui->postButton);
    mStateHelper->addWidget(mTokenTypeGroupData, ui->logoLabel);
    mStateHelper->addWidget(mTokenTypeGroupData, ui->subscribeToolButton);

    /* Connect signals */
    connect(ui->postButton, SIGNAL(clicked()), this, SLOT(createMsg()));
    connect(ui->subscribeToolButton, SIGNAL(subscribe(bool)), this, SLOT(subscribeGroup(bool)));
    connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged()));

    /* add filter actions */
    ui->filterLineEdit->addFilter(QIcon(), tr("Title"), FILTER_TITLE, tr("Search Title"));
    ui->filterLineEdit->addFilter(QIcon(), tr("Message"), FILTER_MSG, tr("Search Message"));
    ui->filterLineEdit->addFilter(QIcon(), tr("Filename"), FILTER_FILE_NAME, tr("Search Filename"));
    connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), ui->feedWidget, SLOT(setFilterText(QString)));
    connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), ui->fileWidget, SLOT(setFilterText(QString)));
    connect(ui->filterLineEdit, SIGNAL(filterChanged(int)), this, SLOT(filterChanged(int)));

    /* Initialize view button */
    //setViewMode(VIEW_MODE_FEEDS); see processSettings
    ui->infoWidget->hide();

    QSignalMapper *signalMapper = new QSignalMapper(this);
    connect(ui->feedToolButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
    connect(ui->fileToolButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
    signalMapper->setMapping(ui->feedToolButton, VIEW_MODE_FEEDS);
    signalMapper->setMapping(ui->fileToolButton, VIEW_MODE_FILES);
    connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(setViewMode(int)));

    /*************** Setup Left Hand Side (List of Channels) ****************/

    ui->loadingLabel->hide();
    ui->progressBar->hide();

    ui->nameLabel->setMinimumWidth(20);

    /* Initialize feed widget */
    ui->feedWidget->setSortRole(ROLE_PUBLISH, Qt::DescendingOrder);
    ui->feedWidget->setFilterCallback(filterItem);

    /* load settings */
    processSettings(true);

    /* Initialize subscribe button */
    QIcon icon;
    icon.addPixmap(QPixmap(":/images/redled.png"), QIcon::Normal, QIcon::On);
    icon.addPixmap(QPixmap(":/images/start.png"), QIcon::Normal, QIcon::Off);
    mAutoDownloadAction = new QAction(icon, "", this);
    mAutoDownloadAction->setCheckable(true);
    connect(mAutoDownloadAction, SIGNAL(triggered()), this, SLOT(toggleAutoDownload()));

    ui->subscribeToolButton->addSubscribedAction(mAutoDownloadAction);

    /* Initialize GUI */
    setAutoDownload(false);
    settingsChanged();
    setGroupId(channelId);
}
Esempio n. 2
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
}
Esempio n. 3
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());
}