Merge branch 'RetroShare:master' into macos-guide

This commit is contained in:
defnax 2024-01-02 14:58:07 +01:00 committed by GitHub
commit d3513ffed0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 220 additions and 92 deletions

View File

@ -25,6 +25,7 @@
#include "gui/gxs/GxsIdDetails.h"
#include "gui/common/FilesDefs.h"
#include "util/misc.h"
#include "util/qtthreadsutils.h"
#include "PulseAddDialog.h"
@ -98,11 +99,31 @@ void PulseAddDialog::setGroup(RsWireGroup &group)
// set ReplyWith Group.
void PulseAddDialog::setGroup(const RsGxsGroupId &grpId)
{
/* fetch in the background */
RsWireGroupSPtr pGroup;
rsWire->getWireGroup(grpId, pGroup);
if(grpId.isNull()){
return;
}
setGroup(*pGroup);
RsThread::async([this,grpId](){
RsWireGroupSPtr pGroup;
if(!rsWire->getWireGroup(grpId,pGroup))
{
std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve wire group info for wire id: " << grpId << std::endl;
return;
}
RsQThreadUtils::postToObject( [pGroup,this]()
{
/* Here it goes any code you want to be executed on the Qt Gui
* thread, for example to update the data model with new information
* after a blocking call to RetroShare API complete, note that
* Qt::QueuedConnection is important!
*/
setGroup(*pGroup);
}, this );
});
}
void PulseAddDialog::cleanup()
@ -236,30 +257,46 @@ void PulseAddDialog::setReplyTo(const RsWirePulse &pulse, RsWirePulseSPtr pPulse
void PulseAddDialog::setReplyTo(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId, uint32_t replyType)
{
if(grpId.isNull()){
return;
}
/* fetch in the background */
RsWireGroupSPtr pGroup;
if (!rsWire->getWireGroup(grpId, pGroup))
{
std::cerr << "PulseAddDialog::setRplyTo() failed to fetch group";
std::cerr << std::endl;
return;
}
RsWirePulseSPtr pPulse;
if (!rsWire->getWirePulse(grpId, msgId, pPulse))
{
std::cerr << "PulseAddDialog::setRplyTo() failed to fetch pulse";
std::cerr << std::endl;
return;
}
RsThread::async([this,grpId,msgId,replyType](){
// update GroupPtr
// TODO - this should be handled in libretroshare if possible.
if (pPulse->mGroupPtr == NULL) {
pPulse->mGroupPtr = pGroup;
}
RsWireGroupSPtr pGroup;
RsWirePulseSPtr pPulse;
if(!rsWire->getWireGroup(grpId,pGroup))
{
std::cerr << __PRETTY_FUNCTION__ << "PulseAddDialog::setRplyTo() failed to fetch group id: " << grpId << std::endl;
return;
}
if (!rsWire->getWirePulse(grpId, msgId, pPulse))
{
std::cerr << "PulseAddDialog::setRplyTo() failed to fetch pulse of group id: " << grpId << std::endl;
return;
}
// update GroupPtr
// TODO - this should be handled in libretroshare if possible.
if (pPulse->mGroupPtr == NULL) {
pPulse->mGroupPtr = pGroup;
}
RsQThreadUtils::postToObject( [pGroup,this,pPulse,replyType]()
{
/* Here it goes any code you want to be executed on the Qt Gui
* thread, for example to update the data model with new information
* after a blocking call to RetroShare API complete, note that
* Qt::QueuedConnection is important!
*/
setReplyTo(*pPulse, pPulse, pGroup->mMeta.mGroupName, replyType);
}, this );
});
setReplyTo(*pPulse, pPulse, pGroup->mMeta.mGroupName, replyType);
}
void PulseAddDialog::addURL()
@ -309,26 +346,39 @@ void PulseAddDialog::postOriginalPulse()
std::cerr << "PulseAddDialog::postOriginalPulse()";
std::cerr << std::endl;
RsWirePulseSPtr pPulse(new RsWirePulse());
RsWirePulseSPtr pPulse(new RsWirePulse());
pPulse->mSentiment = WIRE_PULSE_SENTIMENT_NO_SENTIMENT;
pPulse->mPulseText = ui.textEdit_Pulse->toPlainText().toStdString();
// set images here too.
pPulse->mImage1 = mImage1;
pPulse->mImage2 = mImage2;
pPulse->mImage3 = mImage3;
pPulse->mImage4 = mImage4;
pPulse->mSentiment = WIRE_PULSE_SENTIMENT_NO_SENTIMENT;
pPulse->mPulseText = ui.textEdit_Pulse->toPlainText().toStdString();
// set images here too.
pPulse->mImage1 = mImage1;
pPulse->mImage2 = mImage2;
pPulse->mImage3 = mImage3;
pPulse->mImage4 = mImage4;
// this should be in async thread, so doesn't block UI thread.
if (!rsWire->createOriginalPulse(mGroup.mMeta.mGroupId, pPulse))
{
std::cerr << "PulseAddDialog::postOriginalPulse() FAILED";
std::cerr << std::endl;
return;
}
RsThread::async([this,pPulse](){
if (!rsWire->createOriginalPulse(mGroup.mMeta.mGroupId, pPulse))
{
std::cerr << "PulseAddDialog::postOriginalPulse() FAILED";
std::cerr << std::endl;
return;
}
RsQThreadUtils::postToObject( [this]()
{
/* Here it goes any code you want to be executed on the Qt Gui
* thread, for example to update the data model with new information
* after a blocking call to RetroShare API complete, note that
* Qt::QueuedConnection is important!
*/
clearDialog();
hide();
}, this );
});
clearDialog();
hide();
}
uint32_t PulseAddDialog::toPulseSentiment(int index)
@ -358,15 +408,15 @@ void PulseAddDialog::postReplyPulse()
std::cerr << "PulseAddDialog::postReplyPulse()";
std::cerr << std::endl;
RsWirePulseSPtr pPulse(new RsWirePulse());
RsWirePulseSPtr pPulse(new RsWirePulse());
pPulse->mSentiment = toPulseSentiment(ui.comboBox_sentiment->currentIndex());
pPulse->mPulseText = ui.textEdit_Pulse->toPlainText().toStdString();
// set images here too.
pPulse->mImage1 = mImage1;
pPulse->mImage2 = mImage2;
pPulse->mImage3 = mImage3;
pPulse->mImage4 = mImage4;
pPulse->mSentiment = toPulseSentiment(ui.comboBox_sentiment->currentIndex());
pPulse->mPulseText = ui.textEdit_Pulse->toPlainText().toStdString();
// set images here too.
pPulse->mImage1 = mImage1;
pPulse->mImage2 = mImage2;
pPulse->mImage3 = mImage3;
pPulse->mImage4 = mImage4;
if (mReplyType & WIRE_PULSE_TYPE_REPUBLISH) {
// Copy details from parent, and override
@ -380,20 +430,33 @@ void PulseAddDialog::postReplyPulse()
pPulse->mImage4 = mReplyToPulse.mImage4;
}
// this should be in async thread, so doesn't block UI thread.
if (!rsWire->createReplyPulse(mReplyToPulse.mMeta.mGroupId,
mReplyToPulse.mMeta.mOrigMsgId,
mGroup.mMeta.mGroupId,
mReplyType,
pPulse))
{
std::cerr << "PulseAddDialog::postReplyPulse() FAILED";
std::cerr << std::endl;
return;
}
RsThread::async([this, pPulse](){
if (!rsWire->createReplyPulse(mReplyToPulse.mMeta.mGroupId,
mReplyToPulse.mMeta.mOrigMsgId,
mGroup.mMeta.mGroupId,
mReplyType,
pPulse))
{
std::cerr << "PulseAddDialog::postReplyPulse() FAILED";
std::cerr << std::endl;
return;
}
RsQThreadUtils::postToObject( [this]()
{
/* Here it goes any code you want to be executed on the Qt Gui
* thread, for example to update the data model with new information
* after a blocking call to RetroShare API complete, note that
* Qt::QueuedConnection is important!
*/
clearDialog();
hide();
}, this );
});
clearDialog();
hide();
}
void PulseAddDialog::clearDialog()

View File

@ -140,6 +140,7 @@ WireDialog::~WireDialog()
processSettings(false);
clearTwitterView();
std::cerr << "WireDialog::~WireDialog()" << std::endl;
delete(mWireQueue);
rsEvents->unregisterEventsHandler(mEventHandlerId);
@ -474,13 +475,13 @@ bool WireDialog::loadGroupData(const uint32_t &token)
std::cerr << "WireDialog::loadGroupData()";
std::cerr << std::endl;
std::vector<RsWireGroup> groups;
rsWire->getGroupData(token, groups);
std::vector<RsWireGroup> groups;
rsWire->getGroupData(token, groups);
// save list of groups.
updateGroups(groups);
showGroups();
return true;
// save list of groups.
updateGroups(groups);
showGroups();
return true;
}
rstime_t WireDialog::getFilterTimestamp()
@ -688,6 +689,7 @@ void WireDialog::PVHrate(const RsGxsId &authorId)
void WireDialog::postTestTwitterView()
{
clearTwitterView();
std::cerr << "WireDialog::postTestTwitterView()" << std::endl;
addTwitterView(new PulseTopLevel(NULL,RsWirePulseSPtr()));
addTwitterView(new PulseReply(NULL,RsWirePulseSPtr()));
@ -844,6 +846,7 @@ void WireDialog::requestPulseFocus(const RsGxsGroupId groupId, const RsGxsMessag
void WireDialog::showPulseFocus(const RsGxsGroupId groupId, const RsGxsMessageId msgId)
{
clearTwitterView();
std::cerr << "WireDialog::showPulseFocus()" << std::endl;
// background thread for loading.
RsThread::async([this, groupId, msgId]()
@ -873,6 +876,8 @@ void WireDialog::showPulseFocus(const RsGxsGroupId groupId, const RsGxsMessageId
void WireDialog::postPulseFocus(RsWirePulseSPtr pPulse)
{
clearTwitterView();
std::cerr << "WireDialog::postPulseFocus()" << std::endl;
if (!pPulse)
{
std::cerr << "WireDialog::postPulseFocus() Invalid pulse";
@ -945,7 +950,7 @@ void WireDialog::requestGroupFocus(const RsGxsGroupId groupId)
void WireDialog::showGroupFocus(const RsGxsGroupId groupId)
{
clearTwitterView();
std::cerr << "WireDialog::showGroupFocus()" << std::endl;
// background thread for loading.
RsThread::async([this, groupId]()
{
@ -1022,6 +1027,7 @@ void WireDialog::requestGroupsPulses(const std::list<RsGxsGroupId>& groupIds)
void WireDialog::showGroupsPulses(const std::list<RsGxsGroupId>& groupIds)
{
clearTwitterView();
std::cerr << "WireDialog::showGroupPulses()" << std::endl;
// background thread for loading.
RsThread::async([this, groupIds]()

View File

@ -150,7 +150,7 @@ private:
// Loading Data.
void requestGroupData();
bool loadGroupData(const uint32_t &token);
bool loadGroupData(const uint32_t &token);
void acknowledgeGroup(const uint32_t &token, const uint32_t &userType);
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req) override;

View File

@ -146,8 +146,48 @@ QString ChatLobbyUserNotify::getNotifyMessage(bool plural)
void ChatLobbyUserNotify::iconClicked()
{
#if defined(Q_OS_DARWIN)
std::list<ChatLobbyId> lobbies;
rsMsgs->getChatLobbyList(lobbies);
bool doUpdate=false;
for (lobby_map::iterator itCL=_listMsg.begin(); itCL!=_listMsg.end();)
{
bool bFound=false;
QString strLobbyName=tr("Unknown Lobby");
QIcon icoLobby=QIcon();
std::list<ChatLobbyId>::const_iterator lobbyIt;
for (lobbyIt = lobbies.begin(); lobbyIt != lobbies.end(); ++lobbyIt) {
ChatLobbyId clId = *lobbyIt;
if (clId==itCL->first) {
ChatLobbyInfo clInfo;
if (rsMsgs->getChatLobbyInfo(clId,clInfo))
strLobbyName=QString::fromUtf8(clInfo.lobby_name.c_str()) ;
bFound=true;
break;
}
}
if (bFound)
{
MainWindow::showWindow(MainWindow::ChatLobby);
ChatLobbyWidget *chatLobbyWidget = dynamic_cast<ChatLobbyWidget*>(MainWindow::getPage(MainWindow::ChatLobby));
if (chatLobbyWidget) chatLobbyWidget->showLobbyAnchor(itCL->first,strLobbyName);
++itCL ;
}
else
{
lobby_map::iterator ittmp(itCL);
++ittmp ;
_listMsg.erase(itCL);
itCL=ittmp ;
doUpdate=true;
}
}
#else
/// Tray icon Menu ///
QMenu* trayMenu = new QMenu(MainWindow::getInstance());
QMenu* trayMenu = createMenu();
std::list<ChatLobbyId> lobbies;
rsMsgs->getChatLobbyList(lobbies);
bool doUpdate=false;
@ -186,27 +226,25 @@ void ChatLobbyUserNotify::iconClicked()
}
}
if (notifyCombined()) {
QSystemTrayIcon* trayIcon=getTrayIcon();
if (trayIcon!=NULL) trayIcon->setContextMenu(trayMenu);
} else {
QAction* action=getNotifyIcon();
if (action!=NULL) {
action->setMenu(trayMenu);
}
}
QString strName=tr("Remove All");
QAction *pAction = new QAction( QIcon(), strName, trayMenu);
ActionTag actionTag={0x0, "", true};
pAction->setData(qVariantFromValue(actionTag));
connect(trayMenu, SIGNAL(triggered(QAction*)), this, SLOT(subMenuClicked(QAction*)));
connect(trayMenu, SIGNAL(hovered(QAction*)), this, SLOT(subMenuHovered(QAction*)));
trayMenu->addAction(pAction);
trayMenu->exec(QCursor::pos());
delete(trayMenu);
if (doUpdate) updateIcon();
#endif
}
QMenu* ChatLobbyUserNotify::createMenu()
{
QMenu* menu = new QMenu(MainWindow::getInstance());
connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(subMenuClicked(QAction*)));
connect(menu, SIGNAL(hovered(QAction*)), this, SLOT(subMenuHovered(QAction*)));
return menu;
}
void ChatLobbyUserNotify::makeSubMenu(QMenu* parentMenu, QIcon icoLobby, QString strLobbyName, ChatLobbyId id)
@ -217,11 +255,7 @@ void ChatLobbyUserNotify::makeSubMenu(QMenu* parentMenu, QIcon icoLobby, QString
unsigned int msgCount=msgMap.size();
if(!parentMenu) parentMenu = new QMenu(MainWindow::getInstance());
QMenu *lobbyMenu = parentMenu->addMenu(icoLobby, strLobbyName);
connect(lobbyMenu, SIGNAL(triggered(QAction*)), this, SLOT(subMenuClicked(QAction*)));
connect(lobbyMenu, SIGNAL(hovered(QAction*)), this, SLOT(subMenuHovered(QAction*)));
lobbyMenu->setToolTip(getNotifyMessage(msgCount>1).arg(msgCount));
for (msg_map::iterator itMsg=msgMap.begin(); itMsg!=msgMap.end(); ++itMsg) {
@ -243,7 +277,6 @@ void ChatLobbyUserNotify::makeSubMenu(QMenu* parentMenu, QIcon icoLobby, QString
ActionTag actionTag={itCL->first, "", true};
pAction->setData(qVariantFromValue(actionTag));
lobbyMenu->addAction(pAction);
}
void ChatLobbyUserNotify::iconHovered()
@ -251,7 +284,6 @@ void ChatLobbyUserNotify::iconHovered()
iconClicked();
}
void ChatLobbyUserNotify::chatLobbyNewMessage(ChatLobbyId lobby_id, QDateTime time, QString senderName, QString msg)
{

View File

@ -49,6 +49,7 @@ public:
ChatLobbyUserNotify(QObject *parent = 0);
virtual bool hasSetting(QString *name, QString *group);
QMenu* createMenu();
void makeSubMenu(QMenu* parentMenu, QIcon icoLobby, QString strLobbyName, ChatLobbyId id);
void chatLobbyNewMessage(ChatLobbyId lobby_id, QDateTime time, QString senderName, QString msg);
void chatLobbyCleared(ChatLobbyId lobby_id, QString anchor, bool onlyUnread=false);

View File

@ -76,7 +76,7 @@ bool ChatUserNotify::hasSetting(QString *name, QString *group)
QIcon ChatUserNotify::getIcon()
{
return FilesDefs::getIconFromQtResourcePath(":/images/chat.png");
return FilesDefs::getIconFromQtResourcePath(":/images/orange-bubble-64.png");
}
QIcon ChatUserNotify::getMainIcon(bool hasNew)

View File

@ -982,11 +982,12 @@ void ChatWidget::on_notifyButton_clicked()
if(!notify) return;
if (chatType() != CHATTYPE_LOBBY) return;
QMenu* menu = new QMenu(MainWindow::getInstance());
QMenu* menu = notify->createMenu();
QIcon icoLobby=(ui->notifyButton->icon());
notify->makeSubMenu(menu, icoLobby, title, chatId.toLobbyId());
menu->exec(ui->notifyButton->mapToGlobal(QPoint(0,ui->notifyButton->geometry().height())));
delete(menu);
}

View File

@ -287,7 +287,7 @@ uint32_t RsFriendListModel::EntryIndex::parentRow(uint32_t nb_groups) const
QModelIndex RsFriendListModel::index(int row, int column, const QModelIndex& parent) const
{
if(row < 0 || column < 0 || column >= COLUMN_THREAD_NB_COLUMNS)
if(row < 0 || column < 0 || column >= columnCount(parent) || row >= rowCount(parent))
return QModelIndex();
if(parent.internalId() == 0)

View File

@ -21,6 +21,8 @@
#include "GxsCommentTreeWidget.h"
#include "gui/common/FilesDefs.h"
#include "gui/Identity/IdDialog.h"
#include "gui/MainWindow.h"
#include "gui/common/RSElidedItemDelegate.h"
#include "gui/common/RSTreeWidgetItem.h"
#include "gui/gxs/GxsCreateCommentDialog.h"
@ -346,6 +348,10 @@ void GxsCommentTreeWidget::customPopUpMenu(const QPoint& point)
action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_VOTEDOWN), tr("Vote Down"), this, SLOT(voteDown()));
action->setDisabled(!item || mCurrentCommentMsgId.isNull() || mVoterId.isNull());
contextMnu.addSeparator();
action = contextMnu.addAction(tr("Show Author"), this, SLOT(showAuthor()));
action->setDisabled(!item || mCurrentCommentMsgId.isNull() || mVoterId.isNull());
if (!mCurrentCommentMsgId.isNull())
{
@ -464,6 +470,19 @@ void GxsCommentTreeWidget::replyToComment()
pcc.exec();
}
void GxsCommentTreeWidget::showAuthor()
{
/* window will destroy itself! */
IdDialog *idDialog = dynamic_cast<IdDialog*>(MainWindow::getPage(MainWindow::People));
if (!idDialog)
return ;
MainWindow::showWindow(MainWindow::People);
idDialog->navigate(RsGxsId(mCurrentCommentAuthorId));
}
void GxsCommentTreeWidget::copyComment()
{
QString txt = dynamic_cast<QAction*>(sender())->data().toString();

View File

@ -72,6 +72,7 @@ public slots:
void makeComment();
void replyToComment();
void showAuthor();
void copyComment();

View File

@ -10,6 +10,11 @@ project(retroshare-service)
include(CMakeDependentOption)
if(APPLE)
include_directories("/usr/local/include")
LINK_DIRECTORIES("/usr/local/lib")
endif()
set(
RS_BIN_INSTALL_DIR
"${CMAKE_INSTALL_PREFIX}/bin"