mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
abc33296a7
Added Default blue forum icons for own Forums. Changed default text color for own group & online status text color Switch icon when Contacts View is hided. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7816 b45a01b8-16f6-495d-af2f-9b41ad6348cc
93 lines
1.9 KiB
C++
93 lines
1.9 KiB
C++
#include <QMenu>
|
|
|
|
#include "SubscribeToolButton.h"
|
|
|
|
/* Use MenuButtonPopup, because the arrow of InstantPopup is too small */
|
|
#define USE_MENUBUTTONPOPUP
|
|
|
|
SubscribeToolButton::SubscribeToolButton(QWidget *parent) :
|
|
QToolButton(parent)
|
|
{
|
|
mSubscribed = false;
|
|
|
|
setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
|
|
|
#ifdef USE_MENUBUTTONPOPUP
|
|
connect(this, SIGNAL(clicked()), this, SLOT(subscribePrivate()));
|
|
#endif
|
|
|
|
updateUi();
|
|
}
|
|
|
|
void SubscribeToolButton::setSubscribed(bool subscribed)
|
|
{
|
|
if (mSubscribed == subscribed) {
|
|
return;
|
|
}
|
|
|
|
mSubscribed = subscribed;
|
|
|
|
updateUi();
|
|
}
|
|
|
|
void SubscribeToolButton::addSubscribedAction(QAction *action)
|
|
{
|
|
mSubscribedActions.push_back(action);
|
|
}
|
|
|
|
void SubscribeToolButton::updateUi()
|
|
{
|
|
if (mSubscribed) {
|
|
#ifdef USE_MENUBUTTONPOPUP
|
|
setPopupMode(QToolButton::MenuButtonPopup);
|
|
#else
|
|
setPopupMode(QToolButton::InstantPopup);
|
|
#endif
|
|
setIcon(QIcon(":/images/accepted16.png"));
|
|
setText(tr("Subscribed"));
|
|
|
|
QMenu *menu = new QMenu;
|
|
menu->addAction(QIcon(":/images/cancel.png"), tr("Unsubscribe"), this, SLOT(unsubscribePrivate()));
|
|
|
|
if (!mSubscribedActions.empty()) {
|
|
menu->addSeparator();
|
|
menu->addActions(mSubscribedActions);
|
|
}
|
|
setMenu(menu);
|
|
|
|
#ifndef USE_MENUBUTTONPOPUP
|
|
disconnect(this, SIGNAL(clicked()), this, SLOT(subscribePrivate()));
|
|
#endif
|
|
} else {
|
|
setPopupMode(QToolButton::DelayedPopup);
|
|
setMenu(NULL);
|
|
setIcon(QIcon(":/images/RSS_004_32.png"));
|
|
setText(tr("Subscribe"));
|
|
|
|
#ifndef USE_MENUBUTTONPOPUP
|
|
connect(this, SIGNAL(clicked()), this, SLOT(subscribePrivate()));
|
|
#endif
|
|
}
|
|
}
|
|
|
|
void SubscribeToolButton::subscribePrivate()
|
|
{
|
|
if (menu()) {
|
|
#ifdef USE_MENUBUTTONPOPUP
|
|
showMenu();
|
|
#endif
|
|
return;
|
|
}
|
|
|
|
emit subscribe(true);
|
|
|
|
setSubscribed(true);
|
|
}
|
|
|
|
void SubscribeToolButton::unsubscribePrivate()
|
|
{
|
|
emit subscribe(false);
|
|
|
|
setSubscribed(false);
|
|
}
|