Add a notification when GxsId come back in lobby.

This can be setted even if GxsId is offline by using its name in
TextBrowser.
This commit is contained in:
Phenom 2022-01-15 13:08:49 +01:00
parent 91dd22d8d3
commit dac82bf672
6 changed files with 176 additions and 62 deletions

View file

@ -81,10 +81,11 @@ void SoundManager::soundEvents(SoundEvents &events)
/* add standard events */ /* add standard events */
events.addEvent(tr("Friend"), tr("Go Online"), SOUND_USER_ONLINE, QFileInfo(baseDir, "online1.wav").absoluteFilePath()); events.addEvent(tr("Friend"), tr("Go Online"), SOUND_USER_ONLINE, QFileInfo(baseDir, "online1.wav").absoluteFilePath());
events.addEvent(tr("Chatmessage"), tr("New Msg"), SOUND_NEW_CHAT_MESSAGE, QFileInfo(baseDir, "incomingchat.wav").absoluteFilePath()); events.addEvent(tr("Chat Message"), tr("New Msg"), SOUND_NEW_CHAT_MESSAGE, QFileInfo(baseDir, "incomingchat.wav").absoluteFilePath());
events.addEvent(tr("Message"), tr("Message arrived"), SOUND_MESSAGE_ARRIVED, QFileInfo(baseDir, "receive.wav").absoluteFilePath()); events.addEvent(tr("Message"), tr("Message arrived"), SOUND_MESSAGE_ARRIVED, QFileInfo(baseDir, "receive.wav").absoluteFilePath());
events.addEvent(tr("Download"), tr("Download complete"), SOUND_DOWNLOAD_COMPLETE, QFileInfo(baseDir, "ft_complete.wav").absoluteFilePath()); events.addEvent(tr("Download"), tr("Download complete"), SOUND_DOWNLOAD_COMPLETE, QFileInfo(baseDir, "ft_complete.wav").absoluteFilePath());
events.addEvent(tr("Lobby"), tr("Message arrived"), SOUND_NEW_LOBBY_MESSAGE, QFileInfo(baseDir, "incomingchat.wav").absoluteFilePath()); events.addEvent(tr("Chat Room"), tr("Message arrived"), SOUND_NEW_LOBBY_MESSAGE, QFileInfo(baseDir, "incomingchat.wav").absoluteFilePath());
events.addEvent(tr("Chat Room"), tr("Specific User incoming in Chat Room"), SOUND_LOBBY_INCOMING, QFileInfo(baseDir, "incomingchat.wav").absoluteFilePath());
/* add plugin events */ /* add plugin events */
int pluginCount = rsPlugins->nbPlugins(); int pluginCount = rsPlugins->nbPlugins();
@ -116,7 +117,7 @@ QString SoundManager::defaultFilename(const QString &event, bool check)
return convertFilename(filename); return convertFilename(filename);
} }
if (QFileInfo(filename).exists()) { if (QFileInfo::exists(filename)) {
return convertFilename(filename); return convertFilename(filename);
} }
@ -132,7 +133,7 @@ void SoundManager::initDefault()
foreach (event, events.mEventInfos.keys()) { foreach (event, events.mEventInfos.keys()) {
SoundEvents::SoundEventInfo &eventInfo = events.mEventInfos[event]; SoundEvents::SoundEventInfo &eventInfo = events.mEventInfos[event];
if (QFileInfo(eventInfo.mDefaultFilename).exists()) { if (QFileInfo::exists(eventInfo.mDefaultFilename)) {
setEventFilename(event, convertFilename(eventInfo.mDefaultFilename)); setEventFilename(event, convertFilename(eventInfo.mDefaultFilename));
setEventEnabled(event, true); setEventEnabled(event, true);
} }

View file

@ -24,11 +24,12 @@
#include <QObject> #include <QObject>
#include <QMap> #include <QMap>
#define SOUND_NEW_CHAT_MESSAGE "NewChatMessage"
#define SOUND_USER_ONLINE "User_go_Online" #define SOUND_USER_ONLINE "User_go_Online"
#define SOUND_NEW_CHAT_MESSAGE "NewChatMessage"
#define SOUND_MESSAGE_ARRIVED "MessageArrived" #define SOUND_MESSAGE_ARRIVED "MessageArrived"
#define SOUND_DOWNLOAD_COMPLETE "DownloadComplete" #define SOUND_DOWNLOAD_COMPLETE "DownloadComplete"
#define SOUND_NEW_LOBBY_MESSAGE "NewLobbyMessage" #define SOUND_NEW_LOBBY_MESSAGE "NewLobbyMessage"
#define SOUND_LOBBY_INCOMING "LobbyIncoming"
class SoundEvents class SoundEvents
{ {

View file

@ -41,7 +41,9 @@
#include "gui/msgs/MessageComposer.h" #include "gui/msgs/MessageComposer.h"
#include "gui/settings/RsharePeerSettings.h" #include "gui/settings/RsharePeerSettings.h"
#include "gui/settings/rsharesettings.h" #include "gui/settings/rsharesettings.h"
#include "gui/SoundManager.h"
#include "util/HandleRichText.h" #include "util/HandleRichText.h"
#include "util/misc.h"
#include "util/QtVersion.h" #include "util/QtVersion.h"
#include "retroshare/rsnotify.h" #include "retroshare/rsnotify.h"
@ -63,10 +65,14 @@ const static uint32_t timeToInactivity2 = 60 * 5; // in seconds
/** Default constructor */ /** Default constructor */
ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::WindowFlags flags) ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::WindowFlags flags)
: ChatDialog(parent, flags), lobbyId(lid), mWindowedSetted(false), mPCWindow(nullptr), : ChatDialog(parent, flags), lobbyId(lid), mWindowedSetted(false), mPCWindow(nullptr)
bullet_red_128(":/icons/bullet_red_128.png"), bullet_grey_128(":/icons/bullet_grey_128.png"), , bullet_red_128(":/icons/bullet_red_128.png"), bullet_grey_128(":/icons/bullet_grey_128.png")
bullet_green_128(":/icons/bullet_green_128.png"), bullet_yellow_128(":/icons/bullet_yellow_128.png"), , bullet_yellow_128(":/icons/bullet_yellow_128.png"), bullet_green_128(":/icons/bullet_green_128.png")
bullet_blue_128(":/icons/bullet_blue_128.png") , bullet_blue_128(":/icons/bullet_blue_128.png")
, bullet_red_128_star( misc::mergeIcon(":/icons/bullet_red_128.png" ,":/icons/star_overlay_128.png"))
, bullet_grey_128_star( misc::mergeIcon(":/icons/bullet_grey_128.png" ,":/icons/star_overlay_128.png"))
, bullet_yellow_128_star(misc::mergeIcon(":/icons/bullet_yellow_128.png",":/icons/star_overlay_128.png"))
, bullet_green_128_star( misc::mergeIcon(":/icons/bullet_green_128.png" ,":/icons/star_overlay_128.png"))
{ {
/* Invoke Qt Designer generated QObject setup routine */ /* Invoke Qt Designer generated QObject setup routine */
ui.setupUi(this); ui.setupUi(this);
@ -91,6 +97,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
QHeaderView * header = ui.participantsList->header(); QHeaderView * header = ui.participantsList->header();
QHeaderView_setSectionResizeModeColumn(header, COLUMN_NAME, QHeaderView::Stretch); QHeaderView_setSectionResizeModeColumn(header, COLUMN_NAME, QHeaderView::Stretch);
notifyNewArrivalAct = new QAction(QIcon(), tr("Notify (sound) when come back"), this);
muteAct = new QAction(QIcon(), tr("Mute participant"), this); muteAct = new QAction(QIcon(), tr("Mute participant"), this);
voteNegativeAct = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-down.png"), tr("Ban this person (Sets negative opinion)"), this); voteNegativeAct = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-down.png"), tr("Ban this person (Sets negative opinion)"), this);
voteNeutralAct = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-neutral.png"), tr("Give neutral opinion"), this); voteNeutralAct = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-neutral.png"), tr("Give neutral opinion"), this);
@ -110,7 +117,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
actionSortByActivity->setChecked(false); actionSortByActivity->setChecked(false);
actionSortByActivity->setActionGroup(sortgrp); actionSortByActivity->setActionGroup(sortgrp);
connect(notifyNewArrivalAct, SIGNAL(triggered()), this, SLOT(changeNotifyForParticipant()));
connect(muteAct, SIGNAL(triggered()), this, SLOT(changeParticipationState())); connect(muteAct, SIGNAL(triggered()), this, SLOT(changeParticipationState()));
connect(distantChatAct, SIGNAL(triggered()), this, SLOT(distantChatParticipant())); connect(distantChatAct, SIGNAL(triggered()), this, SLOT(distantChatParticipant()));
connect(sendMessageAct, SIGNAL(triggered()), this, SLOT(sendMessage())); connect(sendMessageAct, SIGNAL(triggered()), this, SLOT(sendMessage()));
@ -138,7 +145,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
undockButton->setAutoRaise(true); undockButton->setAutoRaise(true);
connect(undockButton, SIGNAL(clicked()), this , SLOT(toggleWindowed())); connect(undockButton, SIGNAL(clicked()), this , SLOT(toggleWindowed()));
getChatWidget()->addTitleBarWidget(undockButton) ; ChatLobbyDialog::getChatWidget()->addTitleBarWidget(undockButton) ;
// Add a button to invite friends. // Add a button to invite friends.
// //
@ -161,7 +168,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
connect(inviteFriendsButton, SIGNAL(clicked()), this , SLOT(inviteFriends())); connect(inviteFriendsButton, SIGNAL(clicked()), this , SLOT(inviteFriends()));
getChatWidget()->addTitleBarWidget(inviteFriendsButton) ; ChatLobbyDialog::getChatWidget()->addTitleBarWidget(inviteFriendsButton) ;
RsGxsId current_id; RsGxsId current_id;
rsMsgs->getIdentityForChatLobby(lobbyId, current_id); rsMsgs->getIdentityForChatLobby(lobbyId, current_id);
@ -207,7 +214,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
connect(unsubscribeButton, SIGNAL(clicked()), this , SLOT(leaveLobby())); connect(unsubscribeButton, SIGNAL(clicked()), this , SLOT(leaveLobby()));
getChatWidget()->addTitleBarWidget(unsubscribeButton) ; ChatLobbyDialog::getChatWidget()->addTitleBarWidget(unsubscribeButton) ;
} }
void ChatLobbyDialog::leaveLobby() void ChatLobbyDialog::leaveLobby()
@ -282,9 +289,12 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QList<RsGxs
if (idList.isEmpty()) if (idList.isEmpty())
return; return;
contextMnu->setToolTipsVisible(true);
contextMnu->addAction(distantChatAct); contextMnu->addAction(distantChatAct);
contextMnu->addAction(sendMessageAct); contextMnu->addAction(sendMessageAct);
contextMnu->addSeparator(); contextMnu->addSeparator();
contextMnu->addAction(notifyNewArrivalAct);
contextMnu->addAction(muteAct); contextMnu->addAction(muteAct);
contextMnu->addAction(votePositiveAct); contextMnu->addAction(votePositiveAct);
contextMnu->addAction(voteNeutralAct); contextMnu->addAction(voteNeutralAct);
@ -293,6 +303,10 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QList<RsGxs
distantChatAct->setEnabled(false); distantChatAct->setEnabled(false);
sendMessageAct->setEnabled(false); sendMessageAct->setEnabled(false);
notifyNewArrivalAct->setEnabled(false);
notifyNewArrivalAct->setCheckable(true);
notifyNewArrivalAct->setChecked(false);
notifyNewArrivalAct->setToolTip("");
muteAct->setEnabled(false); muteAct->setEnabled(false);
muteAct->setCheckable(true); muteAct->setCheckable(true);
muteAct->setChecked(false); muteAct->setChecked(false);
@ -303,6 +317,7 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QList<RsGxs
distantChatAct->setData(QVariant::fromValue(idList)); distantChatAct->setData(QVariant::fromValue(idList));
sendMessageAct->setData(QVariant::fromValue(idList)); sendMessageAct->setData(QVariant::fromValue(idList));
notifyNewArrivalAct->setData(QVariant::fromValue(idList));
muteAct->setData(QVariant::fromValue(idList)); muteAct->setData(QVariant::fromValue(idList));
votePositiveAct->setData(QVariant::fromValue(idList)); votePositiveAct->setData(QVariant::fromValue(idList));
voteNeutralAct->setData(QVariant::fromValue(idList)); voteNeutralAct->setData(QVariant::fromValue(idList));
@ -315,6 +330,17 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QList<RsGxs
{ {
distantChatAct->setEnabled(true); distantChatAct->setEnabled(true);
sendMessageAct->setEnabled(true); sendMessageAct->setEnabled(true);
if (SoundManager::eventEnabled(SOUND_LOBBY_INCOMING))
{
notifyNewArrivalAct->setEnabled(true);
notifyNewArrivalAct->setToolTip(tr("Play a sound when this user come back."));
} else {
notifyNewArrivalAct->setEnabled(false);
notifyNewArrivalAct->setToolTip(tr("'Specific User incoming in Chat Room' is unchecked in Sound Preferences page."));
}
notifyNewArrivalAct->setChecked(isParticipantWaitingArrival(gxsid));
muteAct->setEnabled(true);
muteAct->setChecked(isParticipantMuted(gxsid));
votePositiveAct->setEnabled( votePositiveAct->setEnabled(
rsReputations->overallReputationLevel(gxsid) != rsReputations->overallReputationLevel(gxsid) !=
RsReputationLevel::LOCALLY_POSITIVE ); RsReputationLevel::LOCALLY_POSITIVE );
@ -326,8 +352,6 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QList<RsGxs
voteNegativeAct->setEnabled( voteNegativeAct->setEnabled(
rsReputations->overallReputationLevel(gxsid) != rsReputations->overallReputationLevel(gxsid) !=
RsReputationLevel::LOCALLY_NEGATIVE ); RsReputationLevel::LOCALLY_NEGATIVE );
muteAct->setEnabled(true);
muteAct->setChecked(isParticipantMuted(gxsid));
} }
} }
@ -411,7 +435,7 @@ void ChatLobbyDialog::init(const ChatId &/*id*/, const QString &/*title*/)
if(rsIdentity->getIdDetails(gxs_id,details)) if(rsIdentity->getIdDetails(gxs_id,details))
break ; break ;
else else
rstime::rs_usleep(1000*300) ; std::this_thread::sleep_for(std::chrono::milliseconds(300)) ;
ui.chatWidget->setName(QString::fromUtf8(details.mNickname.c_str())); ui.chatWidget->setName(QString::fromUtf8(details.mNickname.c_str()));
//ui.chatWidget->addToolsAction(ui.actionChangeNickname); //ui.chatWidget->addToolsAction(ui.actionChangeNickname);
@ -532,6 +556,13 @@ void ChatLobbyDialog::addChatMsg(const ChatMessage& msg)
QString message = QString::fromUtf8(msg.msg.c_str()); QString message = QString::fromUtf8(msg.msg.c_str());
RsGxsId gxs_id = msg.lobby_peer_gxs_id ; RsGxsId gxs_id = msg.lobby_peer_gxs_id ;
if (isParticipantWaitingArrival(gxs_id))
{
// Who ask a notification for muted? We don't know...
SoundManager::play(SOUND_LOBBY_INCOMING);
idToNotifyWhenComeBack.erase(gxs_id);
}
if(!isParticipantMuted(gxs_id)) if(!isParticipantMuted(gxs_id))
{ {
// We could change addChatMsg to display the peers icon, passing a ChatId // We could change addChatMsg to display the peers icon, passing a ChatId
@ -630,19 +661,20 @@ void ChatLobbyDialog::updateParticipantsList()
widgetitem->setSizeHint(COLUMN_ICON, QSize(20,20)); widgetitem->setSizeHint(COLUMN_ICON, QSize(20,20));
if(isParticipantMuted(it2->first))
widgetitem->setIcon(COLUMN_ICON, bullet_red_128);
else if (tLastAct + timeToInactivity < now)
widgetitem->setIcon(COLUMN_ICON, bullet_grey_128);
else if (tLastAct + timeToInactivity2 < now)
widgetitem->setIcon(COLUMN_ICON, bullet_yellow_128);
else
widgetitem->setIcon(COLUMN_ICON, bullet_green_128);
RsGxsId gxs_id; RsGxsId gxs_id;
rsMsgs->getIdentityForChatLobby(lobbyId, gxs_id); rsMsgs->getIdentityForChatLobby(lobbyId, gxs_id);
bool inNotif = isParticipantWaitingArrival(it2->first);
if (RsGxsId(participant.toStdString()) == gxs_id) widgetitem->setIcon(COLUMN_ICON, bullet_blue_128); if (RsGxsId(participant.toStdString()) == gxs_id)
widgetitem->setIcon(COLUMN_ICON, bullet_blue_128);
else if(isParticipantMuted(it2->first))
widgetitem->setIcon(COLUMN_ICON, inNotif ? bullet_red_128_star : bullet_red_128);
else if (tLastAct + timeToInactivity < now)
widgetitem->setIcon(COLUMN_ICON, inNotif ? bullet_grey_128_star : bullet_grey_128);
else if (tLastAct + timeToInactivity2 < now)
widgetitem->setIcon(COLUMN_ICON, inNotif ? bullet_yellow_128_star : bullet_yellow_128);
else
widgetitem->setIcon(COLUMN_ICON, inNotif ? bullet_green_128_star : bullet_green_128);
widgetitem->updateBannedState(); widgetitem->updateBannedState();
@ -651,6 +683,7 @@ void ChatLobbyDialog::updateParticipantsList()
+tr("This participant is not active since:") +tr("This participant is not active since:")
+qtLastAct.toString() +qtLastAct.toString()
+tr(" seconds") +tr(" seconds")
+ (inNotif ? tr("<br/>A notification (sound) is waiting for this participant come back.") :"")
); );
} }
} }
@ -659,6 +692,31 @@ void ChatLobbyDialog::updateParticipantsList()
filterIds(); filterIds();
} }
void ChatLobbyDialog::changeNotifyForParticipant()
{
QAction *act = dynamic_cast<QAction*>(sender()) ;
if(!act)
{
RS_ERR("No sender! Some bug in the code.");
return ;
}
QList<RsGxsId> idList = act->data().value<QList<RsGxsId>>();
for (auto& item : idList)
{
if (act->isChecked()) {
if(!isParticipantWaitingArrival(item))
idToNotifyWhenComeBack.insert(item);
} else {
if(isParticipantWaitingArrival(item))
idToNotifyWhenComeBack.erase(item);
}
}
updateParticipantsList();
}
/** /**
* Called when a Participant get Clicked / Changed * Called when a Participant get Clicked / Changed
* *
@ -813,6 +871,16 @@ bool ChatLobbyDialog::isNicknameInLobby(const RsGxsId& nickname)
return clinfo.gxs_ids.find(nickname) != clinfo.gxs_ids.end() ; return clinfo.gxs_ids.find(nickname) != clinfo.gxs_ids.end() ;
} }
/**
* @brief Is Lobby waiting this participant new arrival to notify.
* @param participant: GxsID to check.
* @return True if in the list.
*/
bool ChatLobbyDialog::isParticipantWaitingArrival(const RsGxsId &participant)
{
return idToNotifyWhenComeBack.find(participant) != idToNotifyWhenComeBack.end();
}
/** /**
* Should Messages from this Nickname be muted? * Should Messages from this Nickname be muted?
* *
@ -882,7 +950,7 @@ void ChatLobbyDialog::displayLobbyEvent(int event_type, const RsGxsId& gxs_id, c
ui.chatWidget->addChatMsg(true, tr("Chat room management"), QDateTime::currentDateTime(), ui.chatWidget->addChatMsg(true, tr("Chat room management"), QDateTime::currentDateTime(),
QDateTime::currentDateTime(), QDateTime::currentDateTime(),
tr("%1 changed his name to: %2").arg(RsHtml::plainText(name)).arg(RsHtml::plainText(newname)), tr("%1 changed his name to: %2").arg(RsHtml::plainText(name), RsHtml::plainText(newname)),
ChatWidget::MSGTYPE_SYSTEM); ChatWidget::MSGTYPE_SYSTEM);
// TODO if a user was muted and changed his name, update mute list, but only, when the muted peer, dont change his name to a other peer in your chat lobby // TODO if a user was muted and changed his name, update mute list, but only, when the muted peer, dont change his name to a other peer in your chat lobby
@ -903,6 +971,13 @@ void ChatLobbyDialog::displayLobbyEvent(int event_type, const RsGxsId& gxs_id, c
if (qlFoundParticipants.count()!=0) if (qlFoundParticipants.count()!=0)
qlFoundParticipants.at(0)->setText(COLUMN_ACTIVITY,QString::number(time(NULL))); qlFoundParticipants.at(0)->setText(COLUMN_ACTIVITY,QString::number(time(NULL)));
if( (event_type != RS_CHAT_LOBBY_EVENT_PEER_LEFT)
&& isParticipantWaitingArrival(gxs_id))
{
SoundManager::play(SOUND_LOBBY_INCOMING);
idToNotifyWhenComeBack.erase(gxs_id);
}
} }
updateParticipantsList() ; updateParticipantsList() ;

View file

@ -48,6 +48,7 @@ public:
virtual bool hasPeerStatus() { return false; } virtual bool hasPeerStatus() { return false; }
virtual bool notifyBlink(); virtual bool notifyBlink();
void setIdentity(const RsGxsId& gxs_id); void setIdentity(const RsGxsId& gxs_id);
bool isParticipantWaitingArrival(const RsGxsId &participant);
bool isParticipantMuted(const RsGxsId &participant); bool isParticipantMuted(const RsGxsId &participant);
ChatLobbyId id() const { return lobbyId ;} ChatLobbyId id() const { return lobbyId ;}
void sortParcipants(); void sortParcipants();
@ -73,7 +74,7 @@ signals:
protected: protected:
/** Default constructor */ /** Default constructor */
ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent = 0, Qt::WindowFlags flags = 0); ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent = 0, Qt::WindowFlags flags = Qt::WindowFlags());
/** Default destructor */ /** Default destructor */
virtual ~ChatLobbyDialog(); virtual ~ChatLobbyDialog();
@ -85,6 +86,7 @@ protected:
protected slots: protected slots:
void changeNickname(); void changeNickname();
void changeNotifyForParticipant();
void changeParticipationState(); void changeParticipationState();
void distantChatParticipant(); void distantChatParticipant();
void participantsTreeWidgetDoubleClicked(QTreeWidgetItem *item, int column); void participantsTreeWidgetDoubleClicked(QTreeWidgetItem *item, int column);
@ -121,6 +123,13 @@ private:
/** Ignored Users in Chatlobby by nickname until we had implemented Peer Ids in ver 0.6 */ /** Ignored Users in Chatlobby by nickname until we had implemented Peer Ids in ver 0.6 */
std::set<RsGxsId> mutedParticipants; std::set<RsGxsId> mutedParticipants;
/**
* @brief List of GxsId to notify when they arrive.
* This don't use ChatLobbyUserNotify because no need to save it as GxsId can go away before read notification.
*/
std::set<RsGxsId> idToNotifyWhenComeBack;
QAction *notifyNewArrivalAct;
QAction *muteAct; QAction *muteAct;
QAction *votePositiveAct; QAction *votePositiveAct;
QAction *voteNeutralAct; QAction *voteNeutralAct;
@ -134,7 +143,8 @@ private:
GxsIdChooser *ownIdChooser ; GxsIdChooser *ownIdChooser ;
//icons cache //icons cache
QIcon bullet_red_128, bullet_grey_128, bullet_green_128, bullet_yellow_128, bullet_blue_128; QIcon bullet_red_128, bullet_grey_128, bullet_yellow_128, bullet_green_128, bullet_blue_128;
QIcon bullet_red_128_star, bullet_grey_128_star, bullet_yellow_128_star, bullet_green_128_star;
}; };
#endif #endif

View file

@ -30,6 +30,7 @@
#include <QDir> #include <QDir>
#include <QFileDialog> #include <QFileDialog>
#include <QFontDialog> #include <QFontDialog>
#include <QPainter>
#include <QString> #include <QString>
#include <time.h> #include <time.h>
@ -411,10 +412,6 @@ QString misc::getExistingDirectory(QWidget *parent, const QString &caption, cons
#endif #endif
} }
/*!
* Clear a Layout content
* \param layout: Layout to Clear
*/
void misc::clearLayout(QLayout * layout) { void misc::clearLayout(QLayout * layout) {
if (! layout) if (! layout)
return; return;
@ -444,3 +441,15 @@ QSizeF misc::getFontSizeFactor(const QString &group, const qreal defaultFactor /
return QSizeF(appFontWidth*factor,appFontHeight*factor); return QSizeF(appFontWidth*factor,appFontHeight*factor);
} }
QIcon misc::mergeIcon(QString iconB, QString iconF)
{
QIcon icon;
QPixmap pix = FilesDefs::getPixmapFromQtResourcePath(iconB);
QPixmap oli = FilesDefs::getPixmapFromQtResourcePath(iconF);
QPainter painter(&pix);
painter.drawPixmap(0, 0, oli);
icon.addPixmap(pix);
return icon;
}

View file

@ -25,6 +25,7 @@
#include "gui/settings/rsharesettings.h" #include "gui/settings/rsharesettings.h"
#include <QFileDialog> #include <QFileDialog>
#include <QIcon>
#include <QLayout> #include <QLayout>
#include <QObject> #include <QObject>
#include <QPair> #include <QPair>
@ -185,12 +186,29 @@ class misc : public QObject
, const QString &caption = QString() , const QString &caption = QString()
, const QString &dir = QString()); , const QString &dir = QString());
//Clear QLayout /*!
* Clear a Layout content
* \param layout: Layout to Clear
*/
static void clearLayout(QLayout *layout); static void clearLayout(QLayout *layout);
/**
* @brief Get Size depending of application Font Metrics
* @param group: Group name for factor from setting file
* @param defaultFactor: Default factor to use if none is defined
* @return Size factorized font size
*/
static QSizeF getFontSizeFactor(const QString &group, const qreal defaultFactor = 1.0); static QSizeF getFontSizeFactor(const QString &group, const qreal defaultFactor = 1.0);
static QSizeF getFontSizeFactor() {return getFontSizeFactor("Main");} static QSizeF getFontSizeFactor() {return getFontSizeFactor("Main");}
/**
* @brief Merge two icons in one
* @param iconB: Background icon file
* @param iconF: Foreground icon file
* @return Merged icon
*/
static QIcon mergeIcon(QString iconB, QString iconF);
}; };
// Trick to get a portable sleep() function // Trick to get a portable sleep() function