From 9d575ddca14cae07ab9658e542119725df317109 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 2 Mar 2023 09:46:16 +0100 Subject: [PATCH 01/32] implemented new algorithm for sorting channel posts --- .../gui/gxschannels/GxsChannelPostsModel.cpp | 97 ++++++++++++++++++- .../gui/gxschannels/GxsChannelPostsModel.h | 5 +- 2 files changed, 98 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index 06b671532..750db7519 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -571,7 +571,7 @@ void RsGxsChannelPostsModel::setPosts(const RsGxsChannelGroup& group, std::vecto initEmptyHierarchy(); mChannelGroup = group; - createPostsArray(posts); + createPostsArray(posts); std::sort(mPosts.begin(),mPosts.end()); @@ -658,7 +658,7 @@ void RsGxsChannelPostsModel::update_posts(const RsGxsGroupId& group_id) }); } -void RsGxsChannelPostsModel::createPostsArray(std::vector& posts) +void RsGxsChannelPostsModel::old_createPostsArray(std::vector& posts) { // collect new versions of posts if any @@ -776,6 +776,99 @@ void RsGxsChannelPostsModel::createPostsArray(std::vector& pos } } +void RsGxsChannelPostsModel::createPostsArray(std::vector& posts) +{ + // The hierarchy of posts may contain edited posts. In the new model (03/2023), mOrigMsgId points to the original + // top-level post in the hierarchy of edited posts. However, in the old model, mOrigMsgId points to the edited post. + // Therefore the algorithm below is made to cope with both models at once. + // + // In the future, using the new model, it will be possible to delete old versions from the db, and detect new versions + // because they all share the same mOrigMsgId. + // + // We proceed as follows: + // + // 1 - create a search map to convert post IDs into their index in the posts tab + // 2 - recursively climb up the post mOrigMsgId until no parent is found. At top level, create the original post, and add all previous elements as newer versions. + // 3 - go through the list of original posts, select among them the most recent version, and set all others as older versions. + // + // The algorithm handles the case where some parent has been deleted. + +#ifdef DEBUG_CHANNEL_MODEL + std::cerr << "Inserting channel posts" << std::endl; +#endif + + // 1 - create a search map to convert post IDs into their index in the posts tab + + std::map search_map ; + + for (uint32_t i=0;i original_versions ; + + for (uint32_t i=0;i newest_time) + { + newest_index = current_index; + newest_time = m.mPublishTs; + } + + RsGxsMessageId top_level_id; + std::map::const_iterator it; + + if(m.mOrigMsgId.isNull() || m.mOrigMsgId==m.mMsgId) // we have a top-level post. + top_level_id = m.mMsgId; + else if( (it = search_map.find(m.mOrigMsgId)) == search_map.end()) // we don't have the post. Never mind, we store the + top_level_id = m.mOrigMsgId; + else + { + current_index = it->second; + continue; + } + + auto vit = original_versions.find(top_level_id); + + if(vit != original_versions.end()) + { + if(posts[vit->second].mMeta.mPublishTs < newest_time) + vit->second = newest_index; + } + else + original_versions[top_level_id] = newest_index; + + break; + } + } + +#ifdef DEBUG_CHANNEL_MODEL + std::cerr << "Now adding " << posts.size() << " posts into array structure..." << std::endl; +#endif + + mPosts.clear(); + + // make sure the posts are delivered in the same order they appears in the posts[] tab. + + std::vector ids; + + for(auto id:original_versions) + ids.push_back(id.second); + + std::sort(ids.begin(),ids.end()); + + for(uint32_t i=0;i &msgs_array, std::vector &posts, std::map > > &mPostVersions); - void createPostsArray(std::vector &posts); - void setPosts(const RsGxsChannelGroup& group, std::vector &posts); + void old_createPostsArray(std::vector &posts); + void createPostsArray(std::vector& posts); + void setPosts(const RsGxsChannelGroup& group, std::vector &posts); void initEmptyHierarchy(); void handleEvent_main_thread(std::shared_ptr event); From 97265dddab46f94746bc8680a56101997933e0e3 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 2 Mar 2023 22:55:58 +0100 Subject: [PATCH 02/32] updated algorithm for sorting channel posts with debug info and collection of all post versions --- .../gui/gxschannels/GxsChannelPostsModel.cpp | 99 ++++++++++++++----- 1 file changed, 75 insertions(+), 24 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index 750db7519..25fdd6d0f 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -35,7 +35,7 @@ #include "GxsChannelPostsModel.h" #include "GxsChannelPostFilesModel.h" -//#define DEBUG_CHANNEL_MODEL +#define DEBUG_CHANNEL_MODEL Q_DECLARE_METATYPE(RsMsgMetaData) @@ -704,9 +704,6 @@ void RsGxsChannelPostsModel::old_createPostsArray(std::vector& uint32_t current_index = new_versions[i] ; uint32_t source_index = new_versions[i] ; -#ifdef DEBUG_CHANNEL_MODEL - RsGxsMessageId source_msg_id = posts[source_index].mMeta.mMsgId ; -#endif // What we do is everytime we find a replacement post, we climb up the replacement graph until we find the original post // (or the most recent version of it). When we reach this post, we replace it with the data of the source post. @@ -799,30 +796,51 @@ void RsGxsChannelPostsModel::createPostsArray(std::vector& pos // 1 - create a search map to convert post IDs into their index in the posts tab +#ifdef DEBUG_CHANNEL_MODEL + std::cerr << " Given list: " << std::endl; +#endif std::map search_map ; for (uint32_t i=0;i > > original_versions ; for (uint32_t i=0;i& versions,rstime_t newest_time,uint32_t newest_index,int depth)> recurs_find_top_level + = [&posts,&search_map,&recurs_find_top_level,&original_versions](uint32_t index, + std::set& collected_versions, + rstime_t newest_time, + uint32_t newest_index, + int depth) + -> RsGxsMessageId { - const auto& m(posts[current_index].mMeta); + const auto& m(posts[index].mMeta); if(m.mPublishTs > newest_time) { - newest_index = current_index; + newest_index = index; newest_time = m.mPublishTs; } + collected_versions.insert(m.mMsgId); RsGxsMessageId top_level_id; std::map::const_iterator it; @@ -830,44 +848,77 @@ void RsGxsChannelPostsModel::createPostsArray(std::vector& pos if(m.mOrigMsgId.isNull() || m.mOrigMsgId==m.mMsgId) // we have a top-level post. top_level_id = m.mMsgId; else if( (it = search_map.find(m.mOrigMsgId)) == search_map.end()) // we don't have the post. Never mind, we store the + { top_level_id = m.mOrigMsgId; + collected_versions.insert(m.mOrigMsgId); // this one will never be added to the set by the previous call + } else { - current_index = it->second; - continue; + top_level_id = recurs_find_top_level(it->second,collected_versions,newest_time,newest_index,depth+1); + posts[index].mMeta.mOrigMsgId = top_level_id; // this fastens calculation because it will skip already seen posts. + + return top_level_id; } +#ifdef DEBUG_CHANNEL_MODEL + std::cerr << std::string(2*depth,' ') << " top level = " << top_level_id ; +#endif auto vit = original_versions.find(top_level_id); if(vit != original_versions.end()) { - if(posts[vit->second].mMeta.mPublishTs < newest_time) - vit->second = newest_index; - } - else - original_versions[top_level_id] = newest_index; - - break; - } - } + if(posts[vit->second.first].mMeta.mPublishTs < newest_time) + vit->second.first = newest_index; #ifdef DEBUG_CHANNEL_MODEL - std::cerr << "Now adding " << posts.size() << " posts into array structure..." << std::endl; + std::cerr << " already existing. " << std::endl; #endif + } + else + { + original_versions[top_level_id].first = newest_index; +#ifdef DEBUG_CHANNEL_MODEL + std::cerr << " new. " << std::endl; +#endif + } + original_versions[top_level_id].second.insert(collected_versions.begin(),collected_versions.end()); + + return top_level_id; + }; + + auto versions_set = std::set(); + recurs_find_top_level(i,versions_set,posts[i].mMeta.mPublishTs,i,0); + } mPosts.clear(); +#ifdef DEBUG_CHANNEL_MODEL + std::cerr << " Total top_level posts: " << original_versions.size() << std::endl; + + for(auto it:original_versions) + { + std::cerr << " Post " << it.first << ". Total versions = " << it.second.second.size() << " latest: " << posts[it.second.first].mMeta.mMsgId << std::endl; + + for(auto m:it.second.second) + if(m != it.first) + std::cerr << " other (newer version): " << m << std::endl; + } +#endif // make sure the posts are delivered in the same order they appears in the posts[] tab. std::vector ids; for(auto id:original_versions) - ids.push_back(id.second); + ids.push_back(id.second.first); std::sort(ids.begin(),ids.end()); for(uint32_t i=0;i Date: Fri, 3 Mar 2023 00:08:33 +0100 Subject: [PATCH 03/32] switch from createPost() to createPostV2() in channels --- .../gui/gxschannels/CreateGxsChannelMsg.cpp | 45 +++---------------- 1 file changed, 7 insertions(+), 38 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp index c834ae3da..05ce9bda6 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp @@ -794,56 +794,25 @@ void CreateGxsChannelMsg::sendMessage(const std::string &subject, const std::str /* rsGxsChannels */ if (rsGxsChannels) { - RsGxsChannelPost post; - - post.mMeta.mGroupId = mChannelId; - post.mMeta.mParentId.clear() ; - post.mMeta.mThreadId.clear() ; - post.mMeta.mMsgId.clear() ; - - post.mMeta.mOrigMsgId = mOrigPostId; - post.mMeta.mMsgName = subject; - post.mMsg = msg; - post.mFiles = files; - QByteArray ba; QBuffer buffer(&ba); + RsGxsImage image; + if(!picture.isNull()) { // send chan image buffer.open(QIODevice::WriteOnly); preview_W->getCroppedScaledPicture().save(&buffer, "JPG"); // writes image into ba in PNG format - post.mThumbnail.copy((uint8_t *) ba.data(), ba.size()); + image.copy((uint8_t *) ba.data(), ba.size()); } + std::string error_string; + RsGxsMessageId post_id; -#ifdef ENABLE_GENERATE - int generateCount = 0; - if (generateCheckBox->isChecked()) { - generateCount = generateSpinBox->value(); - if (QMessageBox::question(this, tr("Generate mass data"), tr("Do you really want to generate %1 messages ?").arg(generateCount), QMessageBox::Yes|QMessageBox::No, QMessageBox::No) == QMessageBox::No) { - return; - } - } -#endif - - uint32_t token; -#ifdef ENABLE_GENERATE - if (generateCount) { - for (int count = 0; count < generateCount; ++count) { - RsGxsChannelPost generatePost = post; - generatePost.mMeta.mMsgName = QString("%1 %2").arg(QString::fromUtf8(post.mMeta.mMsgName.c_str())).arg(count + 1, 3, 10, QChar('0')).toUtf8().constData(); - - rsGxsChannels->createPost(token, generatePost); - } - } else { -#endif - rsGxsChannels->createPost(token, post); -#ifdef ENABLE_GENERATE - } -#endif + if(!rsGxsChannels->createPostV2(mChannelId,subject,msg,files,image,mOrigPostId,post_id,error_string)) + QMessageBox::critical(nullptr,tr("Cannot publish post"),QString::fromStdString(error_string)); } accept(); From 3b9886a747a29a7cb56f5583e4de9b61ab261538 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 12 Mar 2023 17:43:09 +0100 Subject: [PATCH 04/32] fixed channel mode debug output --- retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index 25fdd6d0f..045a7a8d9 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -35,7 +35,7 @@ #include "GxsChannelPostsModel.h" #include "GxsChannelPostFilesModel.h" -#define DEBUG_CHANNEL_MODEL +//#define DEBUG_CHANNEL_MODEL Q_DECLARE_METATYPE(RsMsgMetaData) From 548ef009608acc746b7aa4e514defed8d177520a Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 21 Mar 2023 21:08:30 +0100 Subject: [PATCH 05/32] enabled channel post model debug --- retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index 045a7a8d9..25fdd6d0f 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -35,7 +35,7 @@ #include "GxsChannelPostsModel.h" #include "GxsChannelPostFilesModel.h" -//#define DEBUG_CHANNEL_MODEL +#define DEBUG_CHANNEL_MODEL Q_DECLARE_METATYPE(RsMsgMetaData) From 22a9cf4236503a0d090b6e3191af9fe844377f49 Mon Sep 17 00:00:00 2001 From: defnax Date: Fri, 7 Apr 2023 16:23:46 +0200 Subject: [PATCH 06/32] moved popup settings for toasters --- .../src/gui/FileTransfer/TransfersDialog.cpp | 3 +- retroshare-gui/src/gui/NewsFeed.cpp | 6 +- .../src/gui/msgs/MessageUserNotify.cpp | 11 ++-- retroshare-gui/src/gui/notifyqt.cpp | 57 ++++++++++++++++--- 4 files changed, 57 insertions(+), 20 deletions(-) diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp index f5659756b..d0b4d5fc7 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp @@ -1120,8 +1120,7 @@ void TransfersDialog::handleEvent_main_thread(std::shared_ptr eve break; SoundManager::play(SOUND_DOWNLOAD_COMPLETE); - if (Settings->getNotifyFlags() & RS_POPUP_DOWNLOAD) - NotifyQt::getInstance()->addToaster(RS_POPUP_DOWNLOAD, fe->mHash.toStdString(), nfo.fname.c_str(),""); + NotifyQt::getInstance()->addToaster(RS_POPUP_DOWNLOAD, fe->mHash.toStdString(), nfo.fname.c_str(),""); } [[fallthrough]]; diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index 36f547738..c73f834fb 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -441,8 +441,7 @@ void NewsFeed::handleConnectionEvent(std::shared_ptr event) { case RsConnectionEventCode::PEER_CONNECTED: addFeedItemIfUnique(new PeerItem(this, NEWSFEED_PEERLIST, e.mSslId, PEER_TYPE_CONNECT, false), true); - if (Settings->getNotifyFlags() & RS_POPUP_CONNECT) - NotifyQt::getInstance()->addToaster(RS_POPUP_CONNECT, e.mSslId.toStdString().c_str(), "", ""); + NotifyQt::getInstance()->addToaster(RS_POPUP_CONNECT, e.mSslId.toStdString().c_str(), "", ""); break; case RsConnectionEventCode::PEER_DISCONNECTED: // not handled yet break; @@ -508,8 +507,7 @@ void NewsFeed::handleSecurityEvent(std::shared_ptr event) if (Settings->getMessageFlags() & RS_MESSAGE_CONNECT_ATTEMPT) MessageComposer::addConnectAttemptMsg(e.mPgpId, e.mSslId, QString::fromStdString(det.name + "(" + det.location + ")")); - if (Settings->getNotifyFlags() & RS_POPUP_CONNECT_ATTEMPT) - NotifyQt::getInstance()->addToaster(RS_POPUP_CONNECT_ATTEMPT, e.mPgpId.toStdString().c_str(), det.location, e.mSslId.toStdString().c_str()); + NotifyQt::getInstance()->addToaster(RS_POPUP_CONNECT_ATTEMPT, e.mPgpId.toStdString().c_str(), det.location, e.mSslId.toStdString().c_str()); } void NewsFeed::testFeeds(uint /*notifyFlags*/) diff --git a/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp b/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp index 60e6ec197..5414802e0 100644 --- a/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp +++ b/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp @@ -96,13 +96,12 @@ void MessageUserNotify::handleEvent_main_thread(std::shared_ptr e switch (fe->mMailStatusEventCode) { case RsMailStatusEventCode::NEW_MESSAGE: - if (Settings->getNotifyFlags() & RS_POPUP_MSG) - for (it = fe->mChangedMsgIds.begin(); it != fe->mChangedMsgIds.end(); ++it) { - MessageInfo msgInfo; - if (rsMail->getMessage(*it, msgInfo)) { - NotifyQt::getInstance()->addToaster(RS_POPUP_MSG, msgInfo.msgId.c_str(), msgInfo.title.c_str(), msgInfo.msg.c_str() ); - } + for (it = fe->mChangedMsgIds.begin(); it != fe->mChangedMsgIds.end(); ++it) { + MessageInfo msgInfo; + if (rsMail->getMessage(*it, msgInfo)) { + NotifyQt::getInstance()->addToaster(RS_POPUP_MSG, msgInfo.msgId.c_str(), msgInfo.title.c_str(), msgInfo.msg.c_str() ); } + } break; case RsMailStatusEventCode::MESSAGE_CHANGED: case RsMailStatusEventCode::MESSAGE_REMOVED: diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index 59d102170..9012e77bd 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -1173,37 +1173,73 @@ void NotifyQt::addToaster(uint notifyFlags, const std::string& id, const std::st ToasterItem *toaster = NULL; + uint popupflags = Settings->getNotifyFlags(); + switch(type) { case RS_POPUP_ENCRYPTED_MSG: SoundManager::play(SOUND_MESSAGE_ARRIVED); - toaster = new ToasterItem(new MessageToaster(std::string(), tr("Unknown title"), QString("[%1]").arg(tr("Encrypted message")))); + if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster) + { + toaster = new ToasterItem(new MessageToaster(std::string(), tr("Unknown title"), QString("[%1]").arg(tr("Encrypted message")))); + } break; case RS_POPUP_MSG: SoundManager::play(SOUND_MESSAGE_ARRIVED); - toaster = new ToasterItem(new MessageToaster(id, QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str()))); + if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster) + { + toaster = new ToasterItem(new MessageToaster(id, QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str()))); + } break; case RS_POPUP_CONNECT: SoundManager::play(SOUND_USER_ONLINE); - toaster = new ToasterItem(new OnlineToaster(RsPeerId(id))); + if ((popupflags & RS_POPUP_CONNECT) && !_disableAllToaster) + { + toaster = new ToasterItem(new OnlineToaster(RsPeerId(id))); + } break; case RS_POPUP_DOWNLOAD: SoundManager::play(SOUND_DOWNLOAD_COMPLETE); - toaster = new ToasterItem(new DownloadToaster(RsFileHash(id), QString::fromUtf8(title.c_str()))); + if ((popupflags & RS_POPUP_DOWNLOAD) && !_disableAllToaster) + { + toaster = new ToasterItem(new DownloadToaster(RsFileHash(id), QString::fromUtf8(title.c_str()))); + } break; case RS_POPUP_CHAT: - toaster = new ToasterItem(new ChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str()))); - break; + if ((popupflags & RS_POPUP_CHAT) && !_disableAllToaster) + { + // TODO: fix for distant chat, look up if dstant chat uses RS_POPUP_CHAT + ChatDialog *chatDialog = ChatDialog::getChat(ChatId(RsPeerId(id))); + ChatWidget *chatWidget; + if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) { + // do not show when active + break; + } + toaster = new ToasterItem(new ChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str()))); + } case RS_POPUP_GROUPCHAT: #ifdef RS_DIRECT_CHAT - toaster = new ToasterItem(new GroupChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str()))); + if ((popupflags & RS_POPUP_GROUPCHAT) && !_disableAllToaster) + { + MainWindow *mainWindow = MainWindow::getInstance(); + if (mainWindow && mainWindow->isActiveWindow() && !mainWindow->isMinimized()) { + if (MainWindow::getActivatePage() == MainWindow::Friends) { + if (FriendsDialog::isGroupChatActive()) { + // do not show when active + break; + } + } + } + toaster = new ToasterItem(new GroupChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str()))); + } #endif // RS_DIRECT_CHAT break; case RS_POPUP_CHATLOBBY: + if ((popupflags & RS_POPUP_CHATLOBBY) && !_disableAllToaster) { ChatId chat_id(id); @@ -1221,13 +1257,16 @@ void NotifyQt::addToaster(uint notifyFlags, const std::string& id, const std::st break; // participant is muted toaster = new ToasterItem(new ChatLobbyToaster(chat_id.toLobbyId(), sender, QString::fromUtf8(msg.c_str()))); - } + } break; case RS_POPUP_CONNECT_ATTEMPT: + if ((popupflags & RS_POPUP_CONNECT_ATTEMPT) && !_disableAllToaster) + { // id = gpgid // title = ssl name // msg = peer id toaster = new ToasterItem(new FriendRequestToaster(RsPgpId(id), QString::fromUtf8(title.c_str()), RsPeerId(msg))); + } break; } @@ -1240,4 +1279,6 @@ void NotifyQt::addToaster(uint notifyFlags, const std::string& id, const std::st waitingToasterList.push_back(toaster); } } + /* Now start the waiting toasters */ + startWaitingToasters(); } From 7299ace57ab15e1e0ceb839c67bba9479dd9e800 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 8 Apr 2023 18:04:22 +0200 Subject: [PATCH 07/32] re-enabled channel debug output --- retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index 11a29903a..3136004a2 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -36,7 +36,7 @@ #include "GxsChannelPostFilesModel.h" //#define DEBUG_CHANNEL_MODEL_DATA -//#define DEBUG_CHANNEL_MODEL +#define DEBUG_CHANNEL_MODEL Q_DECLARE_METATYPE(RsMsgMetaData) Q_DECLARE_METATYPE(RsGxsChannelPost) From 6590a17eb61787bb15052a66d46b35772809c644 Mon Sep 17 00:00:00 2001 From: defnax Date: Tue, 11 Apr 2023 21:59:00 +0200 Subject: [PATCH 08/32] Added paste picture from clipboard feature for picture posts --- .../src/gui/Posted/PostedCreatePostDialog.cpp | 31 +++++++++++++++++ .../src/gui/Posted/PostedCreatePostDialog.h | 1 + .../src/gui/Posted/PostedCreatePostDialog.ui | 34 ++++++++++++------- 3 files changed, 54 insertions(+), 12 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp index aace423f8..ec41434c1 100644 --- a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp +++ b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp @@ -19,6 +19,7 @@ *******************************************************************************/ #include +#include #include #include #include @@ -59,6 +60,7 @@ PostedCreatePostDialog::PostedCreatePostDialog(RsPosted *posted, const RsGxsGrou connect(ui->postButton, SIGNAL(clicked()), this, SLOT(createPost())); connect(ui->addPicButton, SIGNAL(clicked() ), this , SLOT(addPicture())); + connect(ui->pasteButton, SIGNAL(clicked() ), this , SLOT(pastePicture())); connect(ui->RichTextEditWidget, SIGNAL(textSizeOk(bool)),ui->postButton, SLOT(setEnabled(bool))); ui->headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/postedlinks.png")); @@ -256,6 +258,35 @@ void PostedCreatePostDialog::addPicture() } +void PostedCreatePostDialog::pastePicture() +{ + imagefilename = ""; + imagebytes.clear(); + QPixmap empty; + ui->imageLabel->setPixmap(empty); + + // paste picture from clipboard + const QClipboard *clipboard = QApplication::clipboard(); + const QMimeData *mimeData = clipboard->mimeData(); + + QImage image; + if (mimeData->hasImage()) { + image = (qvariant_cast(mimeData->imageData())); + + QImage opt; + if(ImageUtil::optimizeSizeBytes(imagebytes, image, opt,"JPG", 640*480, MAXMESSAGESIZE - 2000)) { //Leave space for other stuff + ui->imageLabel->setPixmap(QPixmap::fromImage(opt)); + ui->stackedWidgetPicture->setCurrentIndex(IMG_PICTURE); + ui->removeButton->show(); + } + } else { + QMessageBox::information(nullptr,tr("No clipboard image found."),tr("There is no image data in the clipboard to paste")); + imagefilename = ""; + imagebytes.clear(); + return; + } +} + int PostedCreatePostDialog::viewMode() { if (ui->viewPostButton->isChecked()) { diff --git a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h index 48ae3cbd4..8576c5ea9 100644 --- a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h +++ b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h @@ -50,6 +50,7 @@ private: private slots: void createPost(); void addPicture(); + void pastePicture(); void on_removeButton_clicked(); void fileHashingFinished(QList hashedFiles); void reject() override; //QDialog diff --git a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.ui b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.ui index a44f226b1..8af895d9c 100644 --- a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.ui +++ b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.ui @@ -7,7 +7,7 @@ 0 0 575 - 518 + 549 @@ -152,8 +152,8 @@ 9 - - + + Qt::Horizontal @@ -182,15 +182,8 @@ - - - - Post size is limited to 32 KB, pictures will be downscaled. - - - - - + + Qt::Horizontal @@ -203,6 +196,13 @@ + + + Post size is limited to 32 KB, pictures will be downscaled. + + + + Qt::Vertical @@ -215,6 +215,16 @@ + + + + Paste image from clipboard + + + Paste Picture + + + From 3c583f67244397d7ce31a62941bcab25ac79166f Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 12 Apr 2023 23:11:45 +0200 Subject: [PATCH 09/32] fixed crash due to calling a method in board item after deletion --- retroshare-gui/src/gui/feeds/BoardsCommentsItem.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/gui/feeds/BoardsCommentsItem.cpp b/retroshare-gui/src/gui/feeds/BoardsCommentsItem.cpp index 02af1afc3..684b85e54 100644 --- a/retroshare-gui/src/gui/feeds/BoardsCommentsItem.cpp +++ b/retroshare-gui/src/gui/feeds/BoardsCommentsItem.cpp @@ -287,14 +287,13 @@ void BaseBoardsCommentsItem::readToggled(bool checked) return; } + setReadStatus(false, checked); // Can't call this inside an async call since the widget may be destroyed afterwards! + // So we do it right away. + RsThread::async( [this,checked]() { RsGxsGrpMsgIdPair msgPair = std::make_pair(groupId(), messageId()); rsPosted->setCommentReadStatus(msgPair, !checked); - - RsQThreadUtils::postToObject( [this,checked]() { - setReadStatus(false, checked); - } ); }); } From a7b2091bb80154c58278bdba9b5ca9384c597acd Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 13 Apr 2023 21:51:37 +0200 Subject: [PATCH 10/32] added a waiting cursor when loading a channel --- .../src/gui/gxschannels/GxsChannelPostsModel.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index 3136004a2..197013c8b 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -27,6 +27,8 @@ #include "retroshare/rsgxschannels.h" #include "retroshare/rsexpr.h" +#include "gui/MainWindow.h" +#include "gui/mainpagestack.h" #include "gui/common/FilesDefs.h" #include "util/qtthreadsutils.h" #include "util/HandleRichText.h" @@ -453,7 +455,6 @@ const RsGxsGroupId& RsGxsChannelPostsModel::currentGroupId() const { return mChannelGroup.mMeta.mGroupId; } - void RsGxsChannelPostsModel::updateChannel(const RsGxsGroupId& channel_group_id) { if(channel_group_id.isNull()) @@ -586,7 +587,9 @@ void RsGxsChannelPostsModel::update_posts(const RsGxsGroupId& group_id) if(group_id.isNull()) return; - RsThread::async([this, group_id]() + MainWindow::getPage(MainWindow::Channels)->setCursor(Qt::WaitCursor) ; // Maybe we should pass that widget when calling update_posts + + RsThread::async([this, group_id]() { // 1 - get message data from p3GxsChannels @@ -641,7 +644,9 @@ void RsGxsChannelPostsModel::update_posts(const RsGxsGroupId& group_id) delete comments; delete votes; - }, this ); + MainWindow::getPage(MainWindow::Channels)->setCursor(Qt::ArrowCursor) ; + + }, this ); }); } From bf0ae5e1ee4f0c976e6e8def9e95626ec1ddade4 Mon Sep 17 00:00:00 2001 From: defnax Date: Fri, 14 Apr 2023 23:19:47 +0200 Subject: [PATCH 11/32] Dsplay on account selection box the headshot image --- retroshare-gui/src/gui/TheWire/WireDialog.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/TheWire/WireDialog.cpp b/retroshare-gui/src/gui/TheWire/WireDialog.cpp index 23031d6ec..7b36ebb90 100644 --- a/retroshare-gui/src/gui/TheWire/WireDialog.cpp +++ b/retroshare-gui/src/gui/TheWire/WireDialog.cpp @@ -23,6 +23,8 @@ #include "WireGroupDialog.h" #include "WireGroupItem.h" #include "gui/settings/rsharesettings.h" +#include "gui/gxs/GxsIdDetails.h" +#include "gui/common/FilesDefs.h" #include "PulseViewGroup.h" #include "PulseReplySeperator.h" @@ -307,8 +309,20 @@ void WireDialog::updateGroups(std::vector& groups) { // grab own groups. // setup Chooser too. - mOwnGroups.push_back(it); - ui.groupChooser->addItem(QString::fromStdString(it.mMeta.mGroupName)); + mOwnGroups.push_back(it); + QPixmap pixmap; + if (it.mHeadshot.mData) + { + if (GxsIdDetails::loadPixmapFromData( it.mHeadshot.mData,it.mHeadshot.mSize,pixmap,GxsIdDetails::ORIGINAL)) + pixmap = pixmap.scaled(32,32); + } + else + { + // default. + pixmap = FilesDefs::getPixmapFromQtResourcePath(":/icons/wire.png").scaled(32,32); + } + + ui.groupChooser->addItem(QPixmap(pixmap),QString::fromStdString(it.mMeta.mGroupName)); } } } From cd14b2e9bb7250303731a8dc41af00937cc7aafc Mon Sep 17 00:00:00 2001 From: defnax Date: Sat, 15 Apr 2023 19:30:00 +0200 Subject: [PATCH 12/32] Added paste icon for boards --- .../src/gui/Posted/PostedCreatePostDialog.ui | 14 +++- retroshare-gui/src/gui/icons.qrc | 1 + .../src/gui/icons/svg/paste_image.svg | 75 +++++++++++++++++++ 3 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 retroshare-gui/src/gui/icons/svg/paste_image.svg diff --git a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.ui b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.ui index 8af895d9c..2a19f02d8 100644 --- a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.ui +++ b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.ui @@ -7,7 +7,7 @@ 0 0 575 - 549 + 468 @@ -223,6 +223,16 @@ Paste Picture + + + :/icons/svg/paste_image.svg:/icons/svg/paste_image.svg + + + + 32 + 32 + + @@ -235,7 +245,7 @@ 267 - 138 + 20 diff --git a/retroshare-gui/src/gui/icons.qrc b/retroshare-gui/src/gui/icons.qrc index 60cb262ca..c92057c29 100644 --- a/retroshare-gui/src/gui/icons.qrc +++ b/retroshare-gui/src/gui/icons.qrc @@ -208,6 +208,7 @@ icons/svg/newsfeed.svg icons/svg/options.svg icons/svg/paste.svg + icons/svg/paste_image.svg icons/svg/people-notify.svg icons/svg/people.svg icons/svg/person.svg diff --git a/retroshare-gui/src/gui/icons/svg/paste_image.svg b/retroshare-gui/src/gui/icons/svg/paste_image.svg new file mode 100644 index 000000000..03a89491e --- /dev/null +++ b/retroshare-gui/src/gui/icons/svg/paste_image.svg @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + From dceda36f6e5501bc7b945c3836cca8a85d0d9897 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Sat, 15 Apr 2023 19:28:37 +0200 Subject: [PATCH 13/32] Moved QAction for saving an image from customContextMenu of GxsForumThreadWidget and ChatWidget to RSTextBrowser --- retroshare-gui/src/gui/chat/ChatWidget.cpp | 15 +----- retroshare-gui/src/gui/chat/ChatWidget.h | 1 - retroshare-gui/src/gui/chat/ChatWidget.ui | 9 ---- .../src/gui/common/RSTextBrowser.cpp | 47 +++++++++++++++++-- retroshare-gui/src/gui/common/RSTextBrowser.h | 15 +++++- .../gui/gxsforums/GxsForumThreadWidget.cpp | 29 ------------ .../src/gui/gxsforums/GxsForumThreadWidget.h | 3 -- .../src/gui/gxsforums/GxsForumThreadWidget.ui | 12 ----- retroshare-gui/src/lang/retroshare_en.ts | 7 ++- 9 files changed, 63 insertions(+), 75 deletions(-) diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index 47c15a137..6a0117f00 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -165,7 +165,6 @@ ChatWidget::ChatWidget(QWidget *parent) connect(ui->actionResetFont, SIGNAL(triggered()), this, SLOT(resetFont())); connect(ui->actionQuote, SIGNAL(triggered()), this, SLOT(quote())); connect(ui->actionDropPlacemark, SIGNAL(triggered()), this, SLOT(dropPlacemark())); - connect(ui->actionSave_image, SIGNAL(triggered()), this, SLOT(saveImage())); connect(ui->actionImport_sticker, SIGNAL(triggered()), this, SLOT(saveSticker())); connect(ui->actionShow_Hidden_Images, SIGNAL(triggered()), ui->textBrowser, SLOT(showImages())); ui->actionShow_Hidden_Images->setIcon(ui->textBrowser->getBlockedImage()); @@ -1151,10 +1150,7 @@ void ChatWidget::pasteText(const QString& S) void ChatWidget::contextMenuTextBrowser(QPoint point) { - QMatrix matrix; - matrix.translate(ui->textBrowser->horizontalScrollBar()->value(), ui->textBrowser->verticalScrollBar()->value()); - - QMenu *contextMnu = ui->textBrowser->createStandardContextMenu(matrix.map(point)); + QMenu *contextMnu = ui->textBrowser->createStandardContextMenuFromPoint(point); contextMnu->addSeparator(); contextMnu->addAction(ui->actionClearChatHistory); @@ -1167,9 +1163,7 @@ void ChatWidget::contextMenuTextBrowser(QPoint point) if (! ui->textBrowser->getShowImages()) contextMnu->addAction(ui->actionShow_Hidden_Images); - ui->actionSave_image->setData(point); ui->actionImport_sticker->setData(point); - contextMnu->addAction(ui->actionSave_image); contextMnu->addAction(ui->actionImport_sticker); } @@ -1995,13 +1989,6 @@ void ChatWidget::dropPlacemark() // or not. } -void ChatWidget::saveImage() -{ - QPoint point = ui->actionSave_image->data().toPoint(); - QTextCursor cursor = ui->textBrowser->cursorForPosition(point); - ImageUtil::extractImage(window(), cursor); -} - void ChatWidget::saveSticker() { QPoint point = ui->actionImport_sticker->data().toPoint(); diff --git a/retroshare-gui/src/gui/chat/ChatWidget.h b/retroshare-gui/src/gui/chat/ChatWidget.h index 82fb6a486..e42df06fe 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.h +++ b/retroshare-gui/src/gui/chat/ChatWidget.h @@ -196,7 +196,6 @@ private slots: void quote(); void dropPlacemark(); - void saveImage(); void saveSticker(); private: diff --git a/retroshare-gui/src/gui/chat/ChatWidget.ui b/retroshare-gui/src/gui/chat/ChatWidget.ui index d46093071..39bd84bb7 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.ui +++ b/retroshare-gui/src/gui/chat/ChatWidget.ui @@ -1049,15 +1049,6 @@ border-image: url(:/images/closepressed.png) Insert horizontal rule - - - - :/images/document_save.png:/images/document_save.png - - - Save image - - diff --git a/retroshare-gui/src/gui/common/RSTextBrowser.cpp b/retroshare-gui/src/gui/common/RSTextBrowser.cpp index cd2bd988e..449f4e1c6 100644 --- a/retroshare-gui/src/gui/common/RSTextBrowser.cpp +++ b/retroshare-gui/src/gui/common/RSTextBrowser.cpp @@ -22,6 +22,7 @@ #include "RSImageBlockWidget.h" #include "gui/common/FilesDefs.h" +#include "util/imageutil.h" #include //To get RsAccounts @@ -33,6 +34,7 @@ #include #include #include +#include #include @@ -317,18 +319,43 @@ QString RSTextBrowser::anchorForPosition(const QPoint &pos) const return anchor; } -QMenu *RSTextBrowser::createStandardContextMenu() +void RSTextBrowser::addContextMenuAction(QAction *action) { - return createStandardContextMenu(QPoint()); + mContextMenuActions.push_back(action); } -QMenu *RSTextBrowser::createStandardContextMenu(const QPoint &position) + +void RSTextBrowser::contextMenuEvent(QContextMenuEvent *event) { - QMenu *menu = QTextBrowser::createStandardContextMenu(position); + emit calculateContextMenuActions(); + + QMenu *contextMenu = createStandardContextMenuFromPoint(event->pos()); + + QList::iterator it; + for (it = mContextMenuActions.begin(); it != mContextMenuActions.end(); ++it) { + contextMenu->addAction(*it); + } + + contextMenu->exec(QCursor::pos()); + + delete(contextMenu); +} + +QMenu *RSTextBrowser::createStandardContextMenuFromPoint(const QPoint &widgetPos) +{ + QMatrix matrix; + matrix.translate(horizontalScrollBar()->value(), verticalScrollBar()->value()); + + QMenu *menu = QTextBrowser::createStandardContextMenu(matrix.map(widgetPos)); menu->addSeparator(); QAction *a = menu->addAction(FilesDefs::getIconFromQtResourcePath("://icons/textedit/code.png"), tr("View &Source"), this, SLOT(viewSource())); a->setEnabled(!this->document()->isEmpty()); + if (checkImage(widgetPos)) { + a = menu->addAction(FilesDefs::getIconFromQtResourcePath(":/images/document_save.png"), tr("Save image"), this, SLOT(saveImage())); + a->setData(widgetPos); + } + return menu; } @@ -350,3 +377,15 @@ void RSTextBrowser::viewSource() delete dialog; } + +void RSTextBrowser::saveImage() +{ + QAction *action = dynamic_cast(sender()) ; + if (!action) { + return; + } + + QPoint point = action->data().toPoint(); + QTextCursor cursor = cursorForPosition(point); + ImageUtil::extractImage(window(), cursor); +} diff --git a/retroshare-gui/src/gui/common/RSTextBrowser.h b/retroshare-gui/src/gui/common/RSTextBrowser.h index 57f351d2b..04de979c5 100644 --- a/retroshare-gui/src/gui/common/RSTextBrowser.h +++ b/retroshare-gui/src/gui/common/RSTextBrowser.h @@ -49,6 +49,8 @@ public: bool checkImage(QPoint pos) {QString imageStr; return checkImage(pos, imageStr); } QString anchorForPosition(const QPoint &pos) const; + // Add QAction to context menu (action won't be deleted) + void addContextMenuAction(QAction *action); void activateLinkClick(bool active); @@ -58,8 +60,10 @@ public: QVariant textColorQuotes() const { return highlighter->textColorQuotes();} bool getShowImages() const { return mShowImages; } - QMenu *createStandardContextMenu(); - QMenu *createStandardContextMenu(const QPoint &position); + QMenu *createStandardContextMenuFromPoint(const QPoint &widgetPos); + +Q_SIGNALS: + void calculateContextMenuActions(); public slots: void showImages(); @@ -70,9 +74,15 @@ private slots: void linkClicked(const QUrl &url); void destroyImageBlockWidget(); void viewSource(); + void saveImage(); protected: void paintEvent(QPaintEvent *event); + virtual void contextMenuEvent(QContextMenuEvent *event); + +private: + // Hide method from QTextBrowser + using QTextBrowser::createStandardContextMenu; private: QString mPlaceholderText; @@ -80,6 +90,7 @@ private: RSImageBlockWidget *mImageBlockWidget; bool mLinkClickActive; RsSyntaxHighlighter *highlighter; + QList mContextMenuActions; #ifdef RSTEXTBROWSER_CHECKIMAGE_DEBUG QRect mCursorRectStart; QRect mCursorRectLeft; diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 5ea514a54..1309848c2 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -276,7 +276,6 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget connect(ui->versions_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(changedVersion())); connect(ui->threadTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(threadListCustomPopupMenu(QPoint))); - connect(ui->postText, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuTextBrowser(QPoint))); connect(ui->forumName, SIGNAL(clicked(QPoint)), this, SLOT(showForumInfo())); ui->subscribeToolButton->hide() ; @@ -303,8 +302,6 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString))); connect(ui->filterLineEdit, SIGNAL(filterChanged(int)), this, SLOT(filterColumnChanged(int))); - connect(ui->actionSave_image, SIGNAL(triggered()), this, SLOT(saveImage())); - connect(ui->threadedView_TB, SIGNAL(toggled(bool)), this, SLOT(toggleThreadedView(bool))); connect(ui->flatView_TB, SIGNAL(toggled(bool)), this, SLOT(toggleFlatView(bool))); connect(ui->latestPostInThreadView_TB, SIGNAL(toggled(bool)), this, SLOT(toggleLstPostInThreadView(bool))); @@ -793,25 +790,6 @@ void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/) contextMnu.exec(QCursor::pos()); } -void GxsForumThreadWidget::contextMenuTextBrowser(QPoint point) -{ - QMatrix matrix; - matrix.translate(ui->postText->horizontalScrollBar()->value(), ui->postText->verticalScrollBar()->value()); - - QMenu *contextMnu = ui->postText->createStandardContextMenu(matrix.map(point)); - - contextMnu->addSeparator(); - - if(ui->postText->checkImage(point)) - { - ui->actionSave_image->setData(point); - contextMnu->addAction(ui->actionSave_image); - } - - contextMnu->exec(ui->postText->viewport()->mapToGlobal(point)); - delete(contextMnu); -} - void GxsForumThreadWidget::headerContextMenuRequested(const QPoint &pos) { QMenu* header_context_menu = new QMenu(tr("Show column"), this); @@ -1823,13 +1801,6 @@ void GxsForumThreadWidget::replyForumMessageData(const RsGxsForumMsg &msg) } } -void GxsForumThreadWidget::saveImage() -{ - QPoint point = ui->actionSave_image->data().toPoint(); - QTextCursor cursor = ui->postText->cursorForPosition(point); - ImageUtil::extractImage(window(), cursor); -} - void GxsForumThreadWidget::toggleThreadedView(bool b) { if(b) changedViewBox(VIEW_THREADED); } void GxsForumThreadWidget::toggleFlatView(bool b) { if(b) changedViewBox(VIEW_FLAT); } void GxsForumThreadWidget::toggleLstPostInThreadView(bool b) { if(b) changedViewBox(VIEW_LAST_POST); } diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h index 8e64c2b75..322c64fae 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h @@ -108,7 +108,6 @@ protected: private slots: /** Create the context popup menu and it's submenus */ void threadListCustomPopupMenu(QPoint point); - void contextMenuTextBrowser(QPoint point); void headerContextMenuRequested(const QPoint& pos); void showForumInfo(); @@ -134,8 +133,6 @@ private slots: // This method is used to perform an asynchroneous action on the message data. Any of the methods above can be used as parameter. void async_msg_action(const MsgMethod& method); - void saveImage(); - void markMsgAsRead(); void markMsgAsReadChildren(); void markMsgAsUnread(); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.ui b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.ui index 0682550cb..5a9c51e93 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.ui +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.ui @@ -568,9 +568,6 @@ MS Sans Serif - - Qt::CustomContextMenu - @@ -578,15 +575,6 @@ - - - - :/images/document_save.png:/images/document_save.png - - - Save image - - diff --git a/retroshare-gui/src/lang/retroshare_en.ts b/retroshare-gui/src/lang/retroshare_en.ts index 3b670aeaa..d11bfb453 100644 --- a/retroshare-gui/src/lang/retroshare_en.ts +++ b/retroshare-gui/src/lang/retroshare_en.ts @@ -19289,7 +19289,12 @@ p, li { white-space: pre-wrap; } - + + Save image + + + + Document source From 09dd588e7f9ee802f1afb4d130cc6749f1444de5 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Sun, 16 Apr 2023 14:02:17 +0200 Subject: [PATCH 14/32] Removed unnecessary include in PostedCreatePostDialog.h --- retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h | 1 - 1 file changed, 1 deletion(-) diff --git a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h index 8576c5ea9..d7b8a261c 100644 --- a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h +++ b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h @@ -24,7 +24,6 @@ #include #include #include "retroshare/rsposted.h" -#include "util/RichTextEdit.h" namespace Ui { class PostedCreatePostDialog; From 4802de9e5242d475a895ab6eb74ed4f9f06e20e3 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Sun, 16 Apr 2023 14:05:40 +0200 Subject: [PATCH 15/32] Removed include of ui_CreateGxsForumMsg.h from CreateGxsForumMsg.h --- .../src/gui/gxsforums/CreateGxsForumMsg.cpp | 173 +++++++++--------- .../src/gui/gxsforums/CreateGxsForumMsg.h | 9 +- 2 files changed, 96 insertions(+), 86 deletions(-) diff --git a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp index e93b81c08..493f254d4 100644 --- a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp +++ b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp @@ -19,6 +19,7 @@ *******************************************************************************/ #include "CreateGxsForumMsg.h" +#include "ui_CreateGxsForumMsg.h" #include #include @@ -54,63 +55,64 @@ /** Constructor */ CreateGxsForumMsg::CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessageId &pId, const RsGxsMessageId& mOId, const RsGxsId& posterId, bool isModerating) : QDialog(NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), - mForumId(fId), mParentId(pId), mOrigMsgId(mOId),mPosterId(posterId),mIsModerating(isModerating) + mForumId(fId), mParentId(pId), mOrigMsgId(mOId),mPosterId(posterId),mIsModerating(isModerating), + ui(new Ui::CreateGxsForumMsg) { /* Invoke the Qt Designer generated object setup routine */ - ui.setupUi(this); + ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose, true); /* Setup UI helper */ mStateHelper = new UIStateHelper(this); - mStateHelper->addWidget(CREATEGXSFORUMMSG_FORUMINFO, ui.postButton); - mStateHelper->addWidget(CREATEGXSFORUMMSG_FORUMINFO, ui.innerFrame); - mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_FORUMINFO, ui.forumName); - mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_FORUMINFO, ui.forumSubject); - mStateHelper->addClear(CREATEGXSFORUMMSG_FORUMINFO, ui.forumName); + mStateHelper->addWidget(CREATEGXSFORUMMSG_FORUMINFO, ui->postButton); + mStateHelper->addWidget(CREATEGXSFORUMMSG_FORUMINFO, ui->innerFrame); + mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_FORUMINFO, ui->forumName); + mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_FORUMINFO, ui->forumSubject); + mStateHelper->addClear(CREATEGXSFORUMMSG_FORUMINFO, ui->forumName); - mStateHelper->addWidget(CREATEGXSFORUMMSG_PARENTMSG, ui.postButton); - mStateHelper->addWidget(CREATEGXSFORUMMSG_PARENTMSG, ui.innerFrame); - mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_PARENTMSG, ui.forumName); - mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_PARENTMSG, ui.forumSubject); - mStateHelper->addClear(CREATEGXSFORUMMSG_PARENTMSG, ui.forumName); + mStateHelper->addWidget(CREATEGXSFORUMMSG_PARENTMSG, ui->postButton); + mStateHelper->addWidget(CREATEGXSFORUMMSG_PARENTMSG, ui->innerFrame); + mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_PARENTMSG, ui->forumName); + mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_PARENTMSG, ui->forumSubject); + mStateHelper->addClear(CREATEGXSFORUMMSG_PARENTMSG, ui->forumName); - mStateHelper->addWidget(CREATEGXSFORUMMSG_ORIGMSG, ui.postButton); - mStateHelper->addWidget(CREATEGXSFORUMMSG_ORIGMSG, ui.innerFrame); - mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_ORIGMSG, ui.forumName); - mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_ORIGMSG, ui.forumSubject); - mStateHelper->addClear(CREATEGXSFORUMMSG_ORIGMSG, ui.forumName); + mStateHelper->addWidget(CREATEGXSFORUMMSG_ORIGMSG, ui->postButton); + mStateHelper->addWidget(CREATEGXSFORUMMSG_ORIGMSG, ui->innerFrame); + mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_ORIGMSG, ui->forumName); + mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_ORIGMSG, ui->forumSubject); + mStateHelper->addClear(CREATEGXSFORUMMSG_ORIGMSG, ui->forumName); QString text = mOId.isNull()?(pId.isNull() ? tr("Start New Thread") : tr("Post Forum Message")):tr("Edit Message"); setWindowTitle(text); if (!mOId.isNull()) - ui.postButton->setText(tr ("Update")); + ui->postButton->setText(tr ("Update")); - ui.forumMessage->setPlaceholderText(tr ("Text")); + ui->forumMessage->setPlaceholderText(tr ("Text")); - ui.headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/forums.png")); - ui.headerFrame->setHeaderText(text); + ui->headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/forums.png")); + ui->headerFrame->setHeaderText(text); - ui.generateSpinBox->setEnabled(false); + ui->generateSpinBox->setEnabled(false); Settings->loadWidgetInformation(this); - connect(ui.hashBox, SIGNAL(fileHashingFinished(QList)), this, SLOT(fileHashingFinished(QList))); + connect(ui->hashBox, SIGNAL(fileHashingFinished(QList)), this, SLOT(fileHashingFinished(QList))); // connect up the buttons. - connect(ui.postButton, SIGNAL(clicked()), this, SLOT(createMsg())); - connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(reject())); - connect(ui.emoticonButton, SIGNAL(clicked()), this, SLOT(smileyWidgetForums())); - connect(ui.attachFileButton, SIGNAL(clicked()), this, SLOT(addFile())); - connect(ui.attachPictureButton, SIGNAL(clicked()), this, SLOT(addPicture())); - connect(ui.forumMessage, SIGNAL(textChanged()), this, SLOT(checkLength())); - connect(ui.generateCheckBox, SIGNAL(toggled(bool)), ui.generateSpinBox, SLOT(setEnabled(bool))); + connect(ui->postButton, SIGNAL(clicked()), this, SLOT(createMsg())); + connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(reject())); + connect(ui->emoticonButton, SIGNAL(clicked()), this, SLOT(smileyWidgetForums())); + connect(ui->attachFileButton, SIGNAL(clicked()), this, SLOT(addFile())); + connect(ui->attachPictureButton, SIGNAL(clicked()), this, SLOT(addPicture())); + connect(ui->forumMessage, SIGNAL(textChanged()), this, SLOT(checkLength())); + connect(ui->generateCheckBox, SIGNAL(toggled(bool)), ui->generateSpinBox, SLOT(setEnabled(bool))); setAcceptDrops(true); - ui.hashBox->setDropWidget(this); - ui.hashBox->setAutoHide(false); + ui->hashBox->setDropWidget(this); + ui->hashBox->setAutoHide(false); mParentMsgLoaded = false; mForumMetaLoaded = false; @@ -118,11 +120,11 @@ CreateGxsForumMsg::CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessage newMsg(); - ui.hashGroupBox->hide(); + ui->hashGroupBox->hide(); #ifndef ENABLE_GENERATE - ui.generateCheckBox->hide(); - ui.generateSpinBox->hide(); + ui->generateCheckBox->hide(); + ui->generateSpinBox->hide(); #endif processSettings(true); } @@ -130,6 +132,9 @@ CreateGxsForumMsg::CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessage CreateGxsForumMsg::~CreateGxsForumMsg() { processSettings(false); + + delete ui; + } void CreateGxsForumMsg::processSettings(bool load) @@ -142,14 +147,14 @@ void CreateGxsForumMsg::processSettings(bool load) RsGxsId gxs_id(Settings->value("IDChooser", QString::fromStdString(RsGxsId().toStdString())).toString().toStdString()); if(!gxs_id.isNull() && rsIdentity->isOwnId(gxs_id)) - ui.idChooser->setChosenId(gxs_id); + ui->idChooser->setChosenId(gxs_id); } else { // state of ID Chooser combobox RsGxsId id; - if(ui.idChooser->getChosenId(id)) + if(ui->idChooser->getChosenId(id)) Settings->setValue("IDChooser", QString::fromStdString(id.toStdString())); } @@ -171,11 +176,11 @@ void CreateGxsForumMsg::newMsg() std::set id_set ; id_set.insert(mPosterId) ; - ui.idChooser->loadIds(IDCHOOSER_ID_REQUIRED | IDCHOOSER_NO_CREATE, mPosterId); - ui.idChooser->setIdConstraintSet(id_set); + ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED | IDCHOOSER_NO_CREATE, mPosterId); + ui->idChooser->setIdConstraintSet(id_set); } else - ui.idChooser->loadIds(IDCHOOSER_ID_REQUIRED, mPosterId); + ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, mPosterId); if (mForumId.isNull()) { mStateHelper->setActive(CREATEGXSFORUMMSG_FORUMINFO, false); @@ -185,7 +190,7 @@ void CreateGxsForumMsg::newMsg() mStateHelper->clear(CREATEGXSFORUMMSG_FORUMINFO); mStateHelper->clear(CREATEGXSFORUMMSG_PARENTMSG); mStateHelper->clear(CREATEGXSFORUMMSG_ORIGMSG); - ui.forumName->setText(tr("No Forum")); + ui->forumName->setText(tr("No Forum")); return; } @@ -306,7 +311,7 @@ void CreateGxsForumMsg::loadFormInformation() if(!mPosterId.isNull()) fl |= IDCHOOSER_NO_CREATE; - ui.idChooser->setFlags(fl) ; + ui->idChooser->setFlags(fl) ; QString name = QString::fromUtf8(mForumMeta.mGroupName.c_str()); QString subj; @@ -327,19 +332,19 @@ void CreateGxsForumMsg::loadFormInformation() subj = "Re: " + title; } - ui.forumName->setText(misc::removeNewLine(name)); + ui->forumName->setText(misc::removeNewLine(name)); std::cerr << "Setting name to \"" << misc::removeNewLine(name).toStdString() << std::endl; if(!subj.isNull()) - ui.forumSubject->setText(misc::removeNewLine(subj)); + ui->forumSubject->setText(misc::removeNewLine(subj)); - if (ui.forumSubject->text().isEmpty()) + if (ui->forumSubject->text().isEmpty()) { - ui.forumSubject->setFocus(); - ui.forumSubject->setPlaceholderText(tr ("Title")); + ui->forumSubject->setFocus(); + ui->forumSubject->setPlaceholderText(tr ("Title")); } else - ui.forumMessage->setFocus(); + ui->forumMessage->setFocus(); #ifdef TOGXS if (mForumMeta.mGroupFlags & RS_DISTRIB_AUTHEN_REQ) @@ -347,18 +352,18 @@ void CreateGxsForumMsg::loadFormInformation() if (1) #endif { - ui.signBox->setChecked(true); - ui.signBox->setEnabled(false); - ui.signBox->hide(); + ui->signBox->setChecked(true); + ui->signBox->setEnabled(false); + ui->signBox->hide(); } else { /* Uncheck sign box by default for anonymous forums */ - ui.signBox->setChecked(false); - ui.signBox->setEnabled(true); + ui->signBox->setChecked(false); + ui->signBox->setEnabled(true); } - //ui.forumMessage->setText(""); + //ui->forumMessage->setText(""); } static const uint32_t MAX_ALLOWED_GXS_MESSAGE_SIZE = 199000; @@ -366,27 +371,27 @@ static const uint32_t MAX_ALLOWED_GXS_MESSAGE_SIZE = 199000; void CreateGxsForumMsg::checkLength() { QString text; - RsHtml::optimizeHtml(ui.forumMessage, text); + RsHtml::optimizeHtml(ui->forumMessage, text); std::wstring msg = text.toStdWString(); int charRemains = MAX_ALLOWED_GXS_MESSAGE_SIZE - msg.length(); if(charRemains >= 0) { text = tr("It remains %1 characters after HTML conversion.").arg(charRemains); - ui.info_Label->setStyleSheet("QLabel#info_Label { }"); + ui->info_Label->setStyleSheet("QLabel#info_Label { }"); }else{ text = tr("Warning: This message is too big of %1 characters after HTML conversion.").arg((0-charRemains)); - ui.info_Label->setStyleSheet("QLabel#info_Label {color: red; font: bold; }"); + ui->info_Label->setStyleSheet("QLabel#info_Label {color: red; font: bold; }"); } - ui.postButton->setToolTip(text); - ui.postButton->setEnabled(charRemains>=0); - ui.info_Label->setText(text); + ui->postButton->setToolTip(text); + ui->postButton->setEnabled(charRemains>=0); + ui->info_Label->setText(text); } void CreateGxsForumMsg::createMsg() { - QString name = misc::removeNewLine(ui.forumSubject->text()); + QString name = misc::removeNewLine(ui->forumSubject->text()); QString desc; - RsHtml::optimizeHtml(ui.forumMessage, desc); + RsHtml::optimizeHtml(ui->forumMessage, desc); if(name.isEmpty() | desc.isEmpty()) { /* error message */ @@ -415,9 +420,9 @@ void CreateGxsForumMsg::createMsg() if ((msg.mMsg == "") && (msg.mMeta.mMsgName == "")) return; /* do nothing */ - if (ui.signBox->isChecked()) { + if (ui->signBox->isChecked()) { RsGxsId authorId; - switch (ui.idChooser->getChosenId(authorId)) { + switch (ui->idChooser->getChosenId(authorId)) { case GxsIdChooser::KnowId: case GxsIdChooser::UnKnowId: msg.mMeta.mAuthorId = authorId; @@ -447,23 +452,23 @@ void CreateGxsForumMsg::createMsg() QMessageBox::warning(this, tr("RetroShare"),tr("Congrats, you found a bug!")+" "+QString(__FILE__)+":"+QString(__LINE__), QMessageBox::Ok, QMessageBox::Ok); return; - }//switch (ui.idChooser->getChosenId(authorId)) + }//switch (ui->idChooser->getChosenId(authorId)) } else { //std::cerr << "CreateGxsForumMsg::createMsg() No Signature (for now :)"; //std::cerr << std::endl; QMessageBox::warning(this, tr("RetroShare"),tr("Please choose Signing Id, it is required"), QMessageBox::Ok, QMessageBox::Ok); return; - }//if (ui.signBox->isChecked()) + }//if (ui->signBox->isChecked()) int generateCount = 0; #ifdef ENABLE_GENERATE - if (ui.generateCheckBox->isChecked()) { - generateCount = ui.generateSpinBox->value(); + if (ui->generateCheckBox->isChecked()) { + generateCount = ui->generateSpinBox->value(); if (QMessageBox::question(this, tr("Generate mass data"), tr("Do you really want to generate %1 messages ?").arg(generateCount), QMessageBox::Yes|QMessageBox::No, QMessageBox::No) == QMessageBox::No) { return; }//if (QMessageBox::question(this, - }//if (ui.generateCheckBox->isChecked()) + }//if (ui->generateCheckBox->isChecked()) #endif uint32_t token; @@ -490,7 +495,7 @@ void CreateGxsForumMsg::closeEvent (QCloseEvent * /*event*/) void CreateGxsForumMsg::reject() { - if (ui.forumMessage->document()->isModified()) { + if (ui->forumMessage->document()->isModified()) { QMessageBox::StandardButton ret; ret = QMessageBox::warning(this, tr("Cancel Forum Message"), tr("Forum Message has not been sent yet!\n" @@ -511,7 +516,7 @@ void CreateGxsForumMsg::reject() void CreateGxsForumMsg::smileyWidgetForums() { - Emoticons::showSmileyWidget(this, ui.emoticonButton, SLOT(addSmileys()), false); + Emoticons::showSmileyWidget(this, ui->emoticonButton, SLOT(addSmileys()), false); } void CreateGxsForumMsg::addSmileys() @@ -520,17 +525,17 @@ void CreateGxsForumMsg::addSmileys() // add trailing space smiley += QString(" "); // add preceding space when needed (not at start of text or preceding space already exists) - if(!ui.forumMessage->textCursor().atStart() && ui.forumMessage->toPlainText()[ui.forumMessage->textCursor().position() - 1] != QChar(' ')) + if(!ui->forumMessage->textCursor().atStart() && ui->forumMessage->toPlainText()[ui->forumMessage->textCursor().position() - 1] != QChar(' ')) smiley = QString(" ") + smiley; - ui.forumMessage->textCursor().insertText(smiley); + ui->forumMessage->textCursor().insertText(smiley); } void CreateGxsForumMsg::addFile() { QStringList files; if (misc::getOpenFileNames(this, RshareSettings::LASTDIR_EXTRAFILE, tr("Add Extra File"), "", files)) { - ui.hashBox->addAttachments(files,RS_FILE_REQ_ANONYMOUS_ROUTING); - ui.hashGroupBox->show(); + ui->hashBox->addAttachments(files,RS_FILE_REQ_ANONYMOUS_ROUTING); + ui->hashGroupBox->show(); } } @@ -541,7 +546,7 @@ void CreateGxsForumMsg::addPicture() QString encodedImage; if (RsHtml::makeEmbeddedImage(file, encodedImage, 640*480, MAX_ALLOWED_GXS_MESSAGE_SIZE - 200)) { QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(encodedImage); - ui.forumMessage->textCursor().insertFragment(fragment); + ui->forumMessage->textCursor().insertFragment(fragment); } } } @@ -563,11 +568,11 @@ void CreateGxsForumMsg::fileHashingFinished(QList hashedFiles) } if (!mesgString.isEmpty()) { - ui.forumMessage->textCursor().insertHtml(mesgString); + ui->forumMessage->textCursor().insertHtml(mesgString); } - ui.forumMessage->setFocus( Qt::OtherFocusReason ); - ui.hashGroupBox->hide(); + ui->forumMessage->setFocus( Qt::OtherFocusReason ); + ui->hashGroupBox->hide(); } void CreateGxsForumMsg::loadCircleInfo(const RsGxsGroupId& circle_id) @@ -603,11 +608,11 @@ void CreateGxsForumMsg::loadCircleInfo(const RsGxsGroupId& circle_id) //for(std::set::const_iterator it(cg.mInvitedMembers.begin());it!=cg.mInvitedMembers.end();++it) // std::cerr << " added constraint to circle element " << *it << std::endl; - ui.idChooser->setIdConstraintSet(cg.mInvitedMembers) ; - ui.idChooser->setFlags(IDCHOOSER_NO_CREATE | ui.idChooser->flags()) ; // since there's a circle involved, no ID creation can be needed + ui->idChooser->setIdConstraintSet(cg.mInvitedMembers) ; + ui->idChooser->setFlags(IDCHOOSER_NO_CREATE | ui->idChooser->flags()) ; // since there's a circle involved, no ID creation can be needed RsGxsId tmpid ; - if(ui.idChooser->countEnabledEntries() == 0) + if(ui->idChooser->countEnabledEntries() == 0) { QMessageBox::information(NULL,tr("No compatible ID for this forum"),tr("None of your identities is allowed to post in this forum. This could be due to the forum being limited to a circle that contains none of your identities, or forum flags requiring a PGP-signed identity.")) ; close() ; @@ -618,10 +623,10 @@ void CreateGxsForumMsg::loadCircleInfo(const RsGxsGroupId& circle_id) void CreateGxsForumMsg::setSubject(const QString& msg) { - ui.forumSubject->setText(msg); + ui->forumSubject->setText(msg); } void CreateGxsForumMsg::insertPastedText(const QString& msg) { - ui.forumMessage->append(msg); + ui->forumMessage->append(msg); } diff --git a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.h b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.h index c542e881d..8697fbbc3 100644 --- a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.h +++ b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.h @@ -21,10 +21,15 @@ #ifndef _CREATE_GXSFORUM_MSG_DIALOG_H #define _CREATE_GXSFORUM_MSG_DIALOG_H -#include "ui_CreateGxsForumMsg.h" +#include #include #include +#include "gui/common/HashBox.h" + +namespace Ui { + class CreateGxsForumMsg; +} class UIStateHelper; @@ -80,7 +85,7 @@ private: UIStateHelper *mStateHelper; /** Qt Designer generated object */ - Ui::CreateGxsForumMsg ui; + Ui::CreateGxsForumMsg *ui; }; #endif From 3004505832cbda8565ef871e50b8d282cdabf565 Mon Sep 17 00:00:00 2001 From: defnax Date: Mon, 17 Apr 2023 21:01:57 +0200 Subject: [PATCH 16/32] Added copy image to clipboard feature --- .../src/gui/common/RSTextBrowser.cpp | 17 +++++++++++ retroshare-gui/src/gui/common/RSTextBrowser.h | 1 + retroshare-gui/src/util/imageutil.cpp | 30 +++++++++++++++++++ retroshare-gui/src/util/imageutil.h | 1 + 4 files changed, 49 insertions(+) diff --git a/retroshare-gui/src/gui/common/RSTextBrowser.cpp b/retroshare-gui/src/gui/common/RSTextBrowser.cpp index 449f4e1c6..c3aaaf454 100644 --- a/retroshare-gui/src/gui/common/RSTextBrowser.cpp +++ b/retroshare-gui/src/gui/common/RSTextBrowser.cpp @@ -356,6 +356,11 @@ QMenu *RSTextBrowser::createStandardContextMenuFromPoint(const QPoint &widgetPos a->setData(widgetPos); } + if (checkImage(widgetPos)) { + a = menu->addAction( tr("Copy image"), this, SLOT(copyImage())); + a->setData(widgetPos); + } + return menu; } @@ -389,3 +394,15 @@ void RSTextBrowser::saveImage() QTextCursor cursor = cursorForPosition(point); ImageUtil::extractImage(window(), cursor); } + +void RSTextBrowser::copyImage() +{ + QAction *action = dynamic_cast(sender()) ; + if (!action) { + return; + } + + QPoint point = action->data().toPoint(); + QTextCursor cursor = cursorForPosition(point); + ImageUtil::copyImage(window(), cursor); +} diff --git a/retroshare-gui/src/gui/common/RSTextBrowser.h b/retroshare-gui/src/gui/common/RSTextBrowser.h index 04de979c5..120dd22e8 100644 --- a/retroshare-gui/src/gui/common/RSTextBrowser.h +++ b/retroshare-gui/src/gui/common/RSTextBrowser.h @@ -75,6 +75,7 @@ private slots: void destroyImageBlockWidget(); void viewSource(); void saveImage(); + void copyImage(); protected: void paintEvent(QPaintEvent *event); diff --git a/retroshare-gui/src/util/imageutil.cpp b/retroshare-gui/src/util/imageutil.cpp index d710a9ae3..9356ae3b2 100644 --- a/retroshare-gui/src/util/imageutil.cpp +++ b/retroshare-gui/src/util/imageutil.cpp @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include #include @@ -68,6 +70,34 @@ void ImageUtil::extractImage(QWidget *window, QTextCursor cursor, QString file) } } +void ImageUtil::copyImage(QWidget *window, QTextCursor cursor) +{ + cursor.movePosition(QTextCursor::Left, QTextCursor::MoveAnchor, 1); + cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, 2); + QString imagestr = cursor.selection().toHtml(); + bool success = false; + int start = imagestr.indexOf("base64,") + 7; + int stop = imagestr.indexOf("\"", start); + int length = stop - start; + if((start >= 0) && (length > 0)) + { + QByteArray ba = QByteArray::fromBase64(imagestr.mid(start, length).toLatin1()); + QImage image = QImage::fromData(ba); + if(!image.isNull()) + { + success = true; + QClipboard *clipboard = QApplication::clipboard(); + QMimeData *data = new QMimeData; + data->setImageData(image); + clipboard->setMimeData(data, QClipboard::Clipboard); + } + } + if(!success) + { + QMessageBox::warning(window, QApplication::translate("ImageUtil", "Copy image"), QApplication::translate("ImageUtil", "Not an image")); + } +} + bool ImageUtil::optimizeSizeBytes(QByteArray &bytearray, const QImage &original, QImage &optimized, const char *format, int maxPixels, int maxBytes) { //nothing to do if it fits into the limits diff --git a/retroshare-gui/src/util/imageutil.h b/retroshare-gui/src/util/imageutil.h index 9e5bf37cb..137c0ea8e 100644 --- a/retroshare-gui/src/util/imageutil.h +++ b/retroshare-gui/src/util/imageutil.h @@ -32,6 +32,7 @@ public: ImageUtil(); static void extractImage(QWidget *window, QTextCursor cursor, QString file = ""); + static void copyImage(QWidget *window, QTextCursor cursor); static bool optimizeSizeHtml(QString &html, const QImage& original, QImage &optimized, int maxPixels = -1, int maxBytes = -1); static bool optimizeSizeBytes(QByteArray &bytearray, const QImage &original, QImage &optimized, const char *format, int maxPixels, int maxBytes); static bool hasAlphaContent(const QImage& image); From bf7c2f7b10530e0013fd35e91ebb05354ee2fd66 Mon Sep 17 00:00:00 2001 From: defnax Date: Mon, 17 Apr 2023 22:35:10 +0200 Subject: [PATCH 17/32] update paste image --- .../src/gui/icons/svg/paste_image.svg | 54 ++++++++++++------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/retroshare-gui/src/gui/icons/svg/paste_image.svg b/retroshare-gui/src/gui/icons/svg/paste_image.svg index 03a89491e..464798ffd 100644 --- a/retroshare-gui/src/gui/icons/svg/paste_image.svg +++ b/retroshare-gui/src/gui/icons/svg/paste_image.svg @@ -1,21 +1,23 @@ + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/"> + id="defs13" /> - - + inkscape:current-layer="svg9" /> + + + + + From 1400d91ef6f897983c65f8cf3085adb90f188aa3 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Tue, 18 Apr 2023 07:50:44 +0200 Subject: [PATCH 18/32] Use ElidedLabel for title in BoardsPostDisplayWidget --- retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp | 4 ++-- retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h | 7 ++++--- .../src/gui/Posted/BoardPostDisplayWidget_card.ui | 8 +++++++- .../src/gui/Posted/BoardPostDisplayWidget_compact.ui | 8 +++++++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 8209b5d1b..d0a09b7e2 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -400,7 +400,7 @@ QLabel *BoardPostDisplayWidget_compact::newLabel() { return ui->ne QToolButton *BoardPostDisplayWidget_compact::readButton() { return ui->readButton; } GxsIdLabel *BoardPostDisplayWidget_compact::fromLabel() { return ui->fromLabel; } QLabel *BoardPostDisplayWidget_compact::dateLabel() { return ui->dateLabel; } -QLabel *BoardPostDisplayWidget_compact::titleLabel() { return ui->titleLabel; } +ElidedLabel *BoardPostDisplayWidget_compact::titleLabel() { return ui->titleLabel; } QLabel *BoardPostDisplayWidget_compact::scoreLabel() { return ui->scoreLabel; } QLabel *BoardPostDisplayWidget_compact::notes() { return ui->notes; } QToolButton *BoardPostDisplayWidget_compact::shareButton() { return ui->shareButton; } @@ -469,7 +469,7 @@ QLabel *BoardPostDisplayWidget_card::newLabel() { return ui->newLa QToolButton *BoardPostDisplayWidget_card::readButton() { return ui->readButton; } GxsIdLabel *BoardPostDisplayWidget_card::fromLabel() { return ui->fromLabel; } QLabel *BoardPostDisplayWidget_card::dateLabel() { return ui->dateLabel; } -QLabel *BoardPostDisplayWidget_card::titleLabel() { return ui->titleLabel; } +ElidedLabel *BoardPostDisplayWidget_card::titleLabel() { return ui->titleLabel; } QLabel *BoardPostDisplayWidget_card::scoreLabel() { return ui->scoreLabel; } QLabel *BoardPostDisplayWidget_card::notes() { return ui->notes; } QToolButton *BoardPostDisplayWidget_card::shareButton() { return ui->shareButton; } diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h index 189f83ae5..27d4a33aa 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h @@ -37,6 +37,7 @@ class QToolButton; class QTextEdit; class ClickableLabel; class GxsIdLabel; +class ElidedLabel; struct RsPostedPost; @@ -72,7 +73,7 @@ protected: virtual QToolButton *commentButton() =0; virtual QToolButton *voteDownButton() =0; virtual QLabel *newLabel() =0; - virtual QLabel *titleLabel()=0; + virtual ElidedLabel *titleLabel()=0; virtual GxsIdLabel *fromLabel()=0; virtual QLabel *dateLabel()=0; virtual QLabel *scoreLabel() =0; @@ -123,7 +124,7 @@ public: QLabel *newLabel() override; GxsIdLabel *fromLabel() override; QLabel *dateLabel() override; - QLabel *titleLabel() override; + ElidedLabel *titleLabel() override; QLabel *scoreLabel() override; QLabel *notes() override; QLabel *pictureLabel() override; @@ -162,7 +163,7 @@ public: QLabel *newLabel() override; GxsIdLabel *fromLabel() override; QLabel *dateLabel() override; - QLabel *titleLabel() override; + ElidedLabel *titleLabel() override; QLabel *scoreLabel() override; QLabel *notes() override; QToolButton *readButton() override; diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_card.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_card.ui index 85eb14906..553577fb8 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_card.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_card.ui @@ -305,7 +305,7 @@ - + 0 @@ -464,6 +464,12 @@ + + ElidedLabel + QLabel +
gui/common/ElidedLabel.h
+ 1 +
GxsIdLabel QLabel diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui index 8c6e89748..5e920cfed 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui @@ -211,7 +211,7 @@ 3 - + 0 @@ -515,6 +515,12 @@ + + ElidedLabel + QLabel +
gui/common/ElidedLabel.h
+ 1 +
GxsIdLabel QLabel From c250b229ed9e625e4c5a466807962107c243c490 Mon Sep 17 00:00:00 2001 From: defnax Date: Tue, 18 Apr 2023 20:10:52 +0200 Subject: [PATCH 19/32] Added ElidedLabel for title in PostedItem --- retroshare-gui/src/gui/Posted/PostedItem.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/Posted/PostedItem.ui b/retroshare-gui/src/gui/Posted/PostedItem.ui index aafc8528c..24d570b16 100644 --- a/retroshare-gui/src/gui/Posted/PostedItem.ui +++ b/retroshare-gui/src/gui/Posted/PostedItem.ui @@ -253,7 +253,7 @@ 6 - + 0 From 7b28bf52569296cf1fb7bceba6aa07a8502f2945 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Wed, 19 Apr 2023 00:42:26 +0200 Subject: [PATCH 20/32] Moved RSTextBrowser::checkImage to ImageUtil for use in MimeTextEdit --- retroshare-gui/src/gui/chat/ChatWidget.cpp | 4 +- .../src/gui/common/MimeTextEdit.cpp | 37 +++++++++ retroshare-gui/src/gui/common/MimeTextEdit.h | 2 + .../src/gui/common/RSTextBrowser.cpp | 75 ++++--------------- retroshare-gui/src/gui/common/RSTextBrowser.h | 2 - retroshare-gui/src/util/imageutil.cpp | 60 +++++++++++++++ retroshare-gui/src/util/imageutil.h | 8 +- 7 files changed, 121 insertions(+), 67 deletions(-) diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index 6a0117f00..03f954964 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -627,7 +627,7 @@ bool ChatWidget::eventFilter(QObject *obj, QEvent *event) QString toolTipText = ui->textBrowser->anchorForPosition(helpEvent->pos()); if (toolTipText.isEmpty() && !ui->textBrowser->getShowImages()){ QString imageStr; - if (ui->textBrowser->checkImage(helpEvent->pos(), imageStr)) { + if (ImageUtil::checkImage(ui->textBrowser, helpEvent->pos(), imageStr)) { toolTipText = imageStr; } } else if (toolTipText.startsWith(PERSONID)){ @@ -1158,7 +1158,7 @@ void ChatWidget::contextMenuTextBrowser(QPoint point) contextMnu->addAction(ui->actionQuote); contextMnu->addAction(ui->actionDropPlacemark); - if(ui->textBrowser->checkImage(point)) + if(ImageUtil::checkImage(ui->textBrowser, point)) { if (! ui->textBrowser->getShowImages()) contextMnu->addAction(ui->actionShow_Hidden_Images); diff --git a/retroshare-gui/src/gui/common/MimeTextEdit.cpp b/retroshare-gui/src/gui/common/MimeTextEdit.cpp index b24a65879..3d3398b0c 100644 --- a/retroshare-gui/src/gui/common/MimeTextEdit.cpp +++ b/retroshare-gui/src/gui/common/MimeTextEdit.cpp @@ -32,6 +32,7 @@ #include "MimeTextEdit.h" #include "util/HandleRichText.h" #include "gui/RetroShareLink.h" +#include "util/imageutil.h" #include @@ -246,6 +247,18 @@ void MimeTextEdit::contextMenuEvent(QContextMenuEvent *e) QMenu *contextMenu = createStandardContextMenu(e->pos()); + if (ImageUtil::checkImage(this, e->pos())) { + contextMenu->addSeparator(); + + QAction *a = contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/images/document_save.png"), tr("Save image"), this, SLOT(saveImage())); + a->setData(e->pos()); + + a = contextMenu->addAction( tr("Copy image"), this, SLOT(copyImage())); + a->setData(e->pos()); + + contextMenu->addSeparator(); + } + /* Add actions for pasting links */ contextMenu->addAction( tr("Paste as plain text"), this, SLOT(pastePlainText())); QAction *spoilerAction = contextMenu->addAction(tr("Spoiler"), this, SLOT(spoiler())); @@ -292,3 +305,27 @@ void MimeTextEdit::spoiler() { RsHtml::insertSpoilerText(this->textCursor()); } + +void MimeTextEdit::saveImage() +{ + QAction *action = dynamic_cast(sender()) ; + if (!action) { + return; + } + + QPoint point = action->data().toPoint(); + QTextCursor cursor = cursorForPosition(point); + ImageUtil::extractImage(window(), cursor); +} + +void MimeTextEdit::copyImage() +{ + QAction *action = dynamic_cast(sender()) ; + if (!action) { + return; + } + + QPoint point = action->data().toPoint(); + QTextCursor cursor = cursorForPosition(point); + ImageUtil::copyImage(window(), cursor); +} diff --git a/retroshare-gui/src/gui/common/MimeTextEdit.h b/retroshare-gui/src/gui/common/MimeTextEdit.h index 9c47cac23..b575c1ac9 100644 --- a/retroshare-gui/src/gui/common/MimeTextEdit.h +++ b/retroshare-gui/src/gui/common/MimeTextEdit.h @@ -75,6 +75,8 @@ private slots: void pasteOwnCertificateLink(); void pastePlainText(); void spoiler(); + void saveImage(); + void copyImage(); private: QString textUnderCursor() const; diff --git a/retroshare-gui/src/gui/common/RSTextBrowser.cpp b/retroshare-gui/src/gui/common/RSTextBrowser.cpp index c3aaaf454..c11d4edef 100644 --- a/retroshare-gui/src/gui/common/RSTextBrowser.cpp +++ b/retroshare-gui/src/gui/common/RSTextBrowser.cpp @@ -234,64 +234,6 @@ void RSTextBrowser::activateLinkClick(bool active) mLinkClickActive = active; } -/** - * @brief RSTextBrowser::checkImage - * @param pos where to check if image is shown in viewport coordinate - * @param imageStr return html source of cursor - * @return True if an image is under cursor - */ -bool RSTextBrowser::checkImage(QPoint pos, QString &imageStr) -{ - //Get text cursor under pos. But if pos is under text browser end line this return last cursor. - QTextCursor cursor = cursorForPosition(pos); - //First get rect of cursor (could be at left or right of image) - QRect cursorRectStart = cursorRect(cursor); - //Second get text - cursor.movePosition(QTextCursor::Left, QTextCursor::MoveAnchor, 1);//To get character just before - QRect cursorRectLeft = cursorRect(cursor); - cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, 2); - QRect cursorRectRight = cursorRect(cursor); - imageStr = cursor.selection().toHtml(); -#ifdef RSTEXTBROWSER_CHECKIMAGE_DEBUG - mCursorRectStart = cursorRectStart; - mCursorRectLeft = cursorRectLeft; - mCursorRectRight = cursorRectRight; - - std::cerr << "cursorRect LTRB :" << cursorRectStart.left() << ";" << cursorRectStart.top() << ";" << cursorRectStart.right() << ";" << cursorRectStart.bottom() << std::endl; - std::cerr << "cursorRectLeft :" << cursorRectLeft.left() << ";" << cursorRectLeft.top() << ";" << cursorRectLeft.right() << ";" << cursorRectLeft.bottom() << std::endl; - std::cerr << "cursorRectRight :" << cursorRectRight.left() << ";" << cursorRectRight.top() << ";" << cursorRectRight.right() << ";" << cursorRectRight.bottom() << std::endl; - std::cerr << "pos XY :" << pos.x() << ";" << pos.y() << std::endl; -#endif - QRect cursorRectEnd = cursorRectStart; - //Finally set left with right of precedent character. - if (cursorRectEnd.top() < cursorRectLeft.bottom()) - { - cursorRectEnd.setLeft(cursorRectLeft.right()); - } else { - //Image on new line - cursorRectEnd.setLeft(0); - } - //And set Right with left of next character. - if (cursorRectEnd.bottom() > cursorRectRight.top()) - { - cursorRectEnd.setRight(cursorRectRight.left()); - } else { - //New line after Image. - } -#ifdef RSTEXTBROWSER_CHECKIMAGE_DEBUG - mCursorRectEnd = cursorRectEnd; - - std::cerr << "final cursorRect:" << cursorRectEnd.left() << ";" << cursorRectEnd.top() << ";" << cursorRectEnd.right() << ";" << cursorRectEnd.bottom() << std::endl; - viewport()->update(); -#endif - //If pos is on text rect - if (cursorRectEnd.contains(pos)) - { - return imageStr.indexOf("base64,") != -1; - } - return false; -} - /** * @brief RSTextBrowser::anchorForPosition Replace anchorAt that doesn't works as expected. * @param pos Where to get anchor from text @@ -351,16 +293,27 @@ QMenu *RSTextBrowser::createStandardContextMenuFromPoint(const QPoint &widgetPos QAction *a = menu->addAction(FilesDefs::getIconFromQtResourcePath("://icons/textedit/code.png"), tr("View &Source"), this, SLOT(viewSource())); a->setEnabled(!this->document()->isEmpty()); - if (checkImage(widgetPos)) { + if (ImageUtil::checkImage(this, widgetPos +#ifdef RSTEXTBROWSER_CHECKIMAGE_DEBUG + , &mCursorRectStart, &mCursorRectLeft, &mCursorRectRight, &mCursorRectEnd +#endif + )) { a = menu->addAction(FilesDefs::getIconFromQtResourcePath(":/images/document_save.png"), tr("Save image"), this, SLOT(saveImage())); a->setData(widgetPos); - } - if (checkImage(widgetPos)) { a = menu->addAction( tr("Copy image"), this, SLOT(copyImage())); a->setData(widgetPos); } +#ifdef RSTEXTBROWSER_CHECKIMAGE_DEBUG + std::cerr << "cursorRect LTRB :" << mCursorRectStart.left() << ";" << mCursorRectStart.top() << ";" << mCursorRectStart.right() << ";" << mCursorRectStart.bottom() << std::endl; + std::cerr << "cursorRectLeft :" << mCursorRectLeft.left() << ";" << mCursorRectLeft.top() << ";" << mCursorRectLeft.right() << ";" << mCursorRectLeft.bottom() << std::endl; + std::cerr << "cursorRectRight :" << mCursorRectRight.left() << ";" << mCursorRectRight.top() << ";" << mCursorRectRight.right() << ";" << mCursorRectRight.bottom() << std::endl; + std::cerr << "pos XY :" << widgetPos.x() << ";" << widgetPos.y() << std::endl; + std::cerr << "final cursorRect:" << mCursorRectEnd.left() << ";" << mCursorRectEnd.top() << ";" << mCursorRectEnd.right() << ";" << mCursorRectEnd.bottom() << std::endl; + viewport()->update(); +#endif + return menu; } diff --git a/retroshare-gui/src/gui/common/RSTextBrowser.h b/retroshare-gui/src/gui/common/RSTextBrowser.h index 120dd22e8..a10a2b30a 100644 --- a/retroshare-gui/src/gui/common/RSTextBrowser.h +++ b/retroshare-gui/src/gui/common/RSTextBrowser.h @@ -45,8 +45,6 @@ public: void setImageBlockWidget(RSImageBlockWidget *widget); void resetImagesStatus(bool load); QPixmap getBlockedImage(); - bool checkImage(QPoint pos, QString &imageStr); - bool checkImage(QPoint pos) {QString imageStr; return checkImage(pos, imageStr); } QString anchorForPosition(const QPoint &pos) const; // Add QAction to context menu (action won't be deleted) diff --git a/retroshare-gui/src/util/imageutil.cpp b/retroshare-gui/src/util/imageutil.cpp index 9356ae3b2..3368db309 100644 --- a/retroshare-gui/src/util/imageutil.cpp +++ b/retroshare-gui/src/util/imageutil.cpp @@ -23,6 +23,8 @@ #include "util/rstime.h" #include +#include +#include #include #include #include @@ -39,6 +41,64 @@ ImageUtil::ImageUtil() {} +bool ImageUtil::checkImage(const QTextEdit *edit, const QPoint &pos, QRect *cursorRectStartOut, QRect *cursorRectLeftOut, QRect *cursorRectRightOut, QRect *cursorRectEndOut) +{ + QString imageStr; + return checkImage(edit, pos, imageStr, cursorRectStartOut, cursorRectLeftOut, cursorRectRightOut, cursorRectEndOut); +} + +bool ImageUtil::checkImage(const QTextEdit *edit, const QPoint &pos, QString &imageStr, QRect *cursorRectStartOut, QRect *cursorRectLeftOut, QRect *cursorRectRightOut, QRect *cursorRectEndOut) +{ + //Get text cursor under pos. But if pos is under text browser end line this return last cursor. + QTextCursor cursor = edit->cursorForPosition(pos); + //First get rect of cursor (could be at left or right of image) + QRect cursorRectStart = edit->cursorRect(cursor); + //Second get text + cursor.movePosition(QTextCursor::Left, QTextCursor::MoveAnchor, 1);//To get character just before + QRect cursorRectLeft = edit->cursorRect(cursor); + cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, 2); + QRect cursorRectRight = edit->cursorRect(cursor); + imageStr = cursor.selection().toHtml(); + + if (cursorRectStartOut) { + *cursorRectStartOut = cursorRectStart; + } + if (cursorRectLeftOut) { + *cursorRectLeftOut = cursorRectLeft; + } + if (cursorRectRightOut) { + *cursorRectRightOut = cursorRectRight; + } + + QRect cursorRectEnd = cursorRectStart; + //Finally set left with right of precedent character. + if (cursorRectEnd.top() < cursorRectLeft.bottom()) + { + cursorRectEnd.setLeft(cursorRectLeft.right()); + } else { + //Image on new line + cursorRectEnd.setLeft(0); + } + //And set Right with left of next character. + if (cursorRectEnd.bottom() > cursorRectRight.top()) + { + cursorRectEnd.setRight(cursorRectRight.left()); + } else { + //New line after Image. + } + + if (cursorRectEndOut) { + *cursorRectEndOut = cursorRectEnd; + } + + //If pos is on text rect + if (cursorRectEnd.contains(pos)) + { + return imageStr.indexOf("base64,") != -1; + } + return false; +} + void ImageUtil::extractImage(QWidget *window, QTextCursor cursor, QString file) { cursor.movePosition(QTextCursor::Left, QTextCursor::MoveAnchor, 1); diff --git a/retroshare-gui/src/util/imageutil.h b/retroshare-gui/src/util/imageutil.h index 137c0ea8e..8e7d26987 100644 --- a/retroshare-gui/src/util/imageutil.h +++ b/retroshare-gui/src/util/imageutil.h @@ -22,15 +22,19 @@ #define IMAGEUTIL_H #include -#include -#include #include +class QWidget; +class QTextEdit; +class QByteArray; + class ImageUtil { public: ImageUtil(); + static bool checkImage(const QTextEdit *edit, const QPoint &pos, QRect *cursorRectStartOut = NULL, QRect *cursorRectLeftOut = NULL, QRect *cursorRectRightOut = NULL, QRect *cursorRectEndOut = NULL); + static bool checkImage(const QTextEdit *edit, const QPoint &pos, QString &imageStr, QRect *cursorRectStartOut = NULL, QRect *cursorRectLeftOut = NULL, QRect *cursorRectRightOut = NULL, QRect *cursorRectEndOut = NULL); static void extractImage(QWidget *window, QTextCursor cursor, QString file = ""); static void copyImage(QWidget *window, QTextCursor cursor); static bool optimizeSizeHtml(QString &html, const QImage& original, QImage &optimized, int maxPixels = -1, int maxBytes = -1); From 4a6938084860d8128fea6b76cc2e76da3f45de8e Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 19 Apr 2023 20:43:12 +0200 Subject: [PATCH 21/32] fixed right-click menu on board posts --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 17 ++- .../src/gui/Posted/BoardPostDisplayWidget.h | 13 +- .../gui/Posted/PostedListWidgetWithModel.cpp | 138 +++++------------- .../gui/Posted/PostedListWidgetWithModel.h | 2 +- 4 files changed, 57 insertions(+), 113 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 8209b5d1b..21ccfc57f 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -43,6 +43,7 @@ #define LINK_IMAGE ":/images/thumb-link.png" + // #ifdef DEBUG_BOARDPOSTDISPLAYWIDGET 1 /** Constructor */ @@ -58,6 +59,7 @@ BoardPostDisplayWidgetBase::BoardPostDisplayWidgetBase(const RsPostedPost& post, { } + void BoardPostDisplayWidgetBase::setCommentsSize(int comNb) { QString sComButText = tr("Comment"); @@ -168,6 +170,7 @@ void BoardPostDisplayWidgetBase::baseSetup() readButton()->setChecked(false); +#ifdef TO_REMOVE QMenu *menu = new QMenu(); menu->addAction(CopyLinkAction); menu->addSeparator(); @@ -175,6 +178,7 @@ void BoardPostDisplayWidgetBase::baseSetup() shareButton()->setPopupMode(QToolButton::InstantPopup); connect(menu,SIGNAL(aboutToShow()),this,SLOT(handleShareButtonClicked())); +#endif RsReputationLevel overall_reputation = rsReputations->overallReputationLevel(mPost.mMeta.mAuthorId); bool redacted = (overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE); @@ -182,7 +186,9 @@ void BoardPostDisplayWidgetBase::baseSetup() if(redacted) { commentButton()->setDisabled(true); +#ifdef TO_REMOVE shareButton()->setDisabled(true); +#endif voteUpButton()->setDisabled(true); voteDownButton()->setDisabled(true); fromLabel()->setId(mPost.mMeta.mAuthorId); @@ -275,6 +281,7 @@ void BoardPostDisplayWidgetBase::baseSetup() emit sizeChanged(this); #endif } +#ifdef TO_REMOVE void BoardPostDisplayWidgetBase::handleShareButtonClicked() { emit shareButtonClicked(); @@ -284,6 +291,8 @@ void BoardPostDisplayWidgetBase::handleCopyLinkClicked() { emit copylinkClicked(); } +#endif + //=================================================================================================================================== //== class BoardPostDisplayWidget == //=================================================================================================================================== @@ -292,6 +301,7 @@ BoardPostDisplayWidget_compact::BoardPostDisplayWidget_compact(const RsPostedPos : BoardPostDisplayWidgetBase(post,display_flags,parent), ui(new Ui::BoardPostDisplayWidget_compact()) { ui->setupUi(this); + ui->shareButton->hide(); BoardPostDisplayWidget_compact::setup(); } @@ -403,7 +413,7 @@ QLabel *BoardPostDisplayWidget_compact::dateLabel() { return ui->da QLabel *BoardPostDisplayWidget_compact::titleLabel() { return ui->titleLabel; } QLabel *BoardPostDisplayWidget_compact::scoreLabel() { return ui->scoreLabel; } QLabel *BoardPostDisplayWidget_compact::notes() { return ui->notes; } -QToolButton *BoardPostDisplayWidget_compact::shareButton() { return ui->shareButton; } +//QToolButton *BoardPostDisplayWidget_compact::shareButton() { return ui->shareButton; } QLabel *BoardPostDisplayWidget_compact::pictureLabel() { return ui->pictureLabel; } QFrame *BoardPostDisplayWidget_compact::feedFrame() { return ui->feedFrame; } @@ -415,7 +425,8 @@ BoardPostDisplayWidget_card::BoardPostDisplayWidget_card(const RsPostedPost& pos : BoardPostDisplayWidgetBase(post,display_flags,parent), ui(new Ui::BoardPostDisplayWidget_card()) { ui->setupUi(this); - BoardPostDisplayWidget_card::setup(); + ui->shareButton->hide(); + BoardPostDisplayWidget_card::setup(); } BoardPostDisplayWidget_card::~BoardPostDisplayWidget_card() @@ -472,7 +483,7 @@ QLabel *BoardPostDisplayWidget_card::dateLabel() { return ui->dateL QLabel *BoardPostDisplayWidget_card::titleLabel() { return ui->titleLabel; } QLabel *BoardPostDisplayWidget_card::scoreLabel() { return ui->scoreLabel; } QLabel *BoardPostDisplayWidget_card::notes() { return ui->notes; } -QToolButton *BoardPostDisplayWidget_card::shareButton() { return ui->shareButton; } +//QToolButton *BoardPostDisplayWidget_card::shareButton() { return ui->shareButton; } QLabel *BoardPostDisplayWidget_card::pictureLabel() { return ui->pictureLabel; } QFrame *BoardPostDisplayWidget_card::feedFrame() { return ui->feedFrame; } diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h index 189f83ae5..78a04a7fb 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h @@ -79,7 +79,7 @@ protected: virtual QLabel *notes() =0; virtual QLabel *pictureLabel()=0; virtual QToolButton *readButton() =0; - virtual QToolButton *shareButton() =0; +// virtual QToolButton *shareButton() =0; virtual QFrame *feedFrame() =0; protected slots: @@ -89,9 +89,10 @@ protected slots: void makeUpVote() ; void makeDownVote() ; void setCommentsSize(int comNb) ; +#ifdef TO_REMOVE void handleShareButtonClicked() ; void handleCopyLinkClicked() ; - +#endif signals: void changeReadStatusRequested(const RsGxsMessageId&,bool); @@ -99,8 +100,8 @@ signals: void expand(RsGxsMessageId,bool); void commentsRequested(const RsGxsMessageId&,bool); void thumbnailOpenned(); - void shareButtonClicked(); - void copylinkClicked(); +// void shareButtonClicked(); +// void copylinkClicked(); protected: RsPostedPost mPost; @@ -128,7 +129,9 @@ public: QLabel *notes() override; QLabel *pictureLabel() override; QToolButton *readButton() override; +#ifdef TO_REMOVE QToolButton *shareButton() override; +#endif QFrame *feedFrame() override; public slots: @@ -166,7 +169,7 @@ public: QLabel *scoreLabel() override; QLabel *notes() override; QToolButton *readButton() override; - QToolButton *shareButton() override; +// QToolButton *shareButton() override; QLabel *pictureLabel() override; QFrame *feedFrame() override; diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index a9c0a95a7..5c63ce2e9 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -219,7 +219,7 @@ QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionVie else w = new BoardPostDisplayWidget_card(post,displayFlags(post.mMeta.mMsgId),parent); - QObject::connect(w,SIGNAL(vote(RsGxsGrpMsgIdPair,bool)),mPostListWidget,SLOT(voteMsg(RsGxsGrpMsgIdPair,bool))); + QObject::connect(w,SIGNAL(vote(RsGxsGrpMsgIdPair,bool)),mPostListWidget,SLOT(voteMsg(RsGxsGrpMsgIdPair,bool))); QObject::connect(w,SIGNAL(expand(RsGxsMessageId,bool)),this,SLOT(expandItem(RsGxsMessageId,bool))); QObject::connect(w,SIGNAL(commentsRequested(RsGxsMessageId,bool)),mPostListWidget,SLOT(openComments(RsGxsMessageId))); QObject::connect(w,SIGNAL(changeReadStatusRequested(RsGxsMessageId,bool)),mPostListWidget,SLOT(changeReadStatus(RsGxsMessageId,bool))); @@ -230,7 +230,6 @@ QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionVie QObject::connect(w,SIGNAL(expand(RsGxsMessageId,bool)),this,SLOT(markCurrentPostAsRead())); QObject::connect(w,SIGNAL(commentsRequested(RsGxsMessageId,bool)),mPostListWidget,SLOT(markCurrentPostAsRead())); QObject::connect(w,SIGNAL(shareButtonClicked()),mPostListWidget,SLOT(markCurrentPostAsRead())); - QObject::connect(w,SIGNAL(copylinkClicked()),mPostListWidget,SLOT(copyMessageLink())); w->setGeometry(option.rect); w->adjustSize(); @@ -277,7 +276,6 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI connect(ui->nextButton,SIGNAL(clicked()),this,SLOT(nextPosts())); connect(ui->prevButton,SIGNAL(clicked()),this,SLOT(prevPosts())); - connect(ui->postsTree,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(postContextMenu(QPoint))); connect(ui->viewModeButton,SIGNAL(clicked()),this,SLOT(switchDisplayMode())); connect(mPostedPostsModel,SIGNAL(boardPostsLoaded()),this,SLOT(postPostLoad())); @@ -296,7 +294,11 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI connect(ui->postsTree,SIGNAL(sizeChanged(QSize)),this,SLOT(handlePostsTreeSizeChange(QSize))); - /* load settings */ + ui->postsTree->setContextMenuPolicy(Qt::CustomContextMenu); + //QObject::connect(this,SIGNAL(copylinkClicked()),this,SLOT(copyMessageLink())); + connect(ui->postsTree,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(postContextMenu(const QPoint&))); + + /* load settings */ processSettings(true); /* Initialize subscribe button */ @@ -325,6 +327,32 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI }, mEventHandlerId, RsEventType::GXS_POSTED ); } +void PostedListWidgetWithModel::postContextMenu(const QPoint& point) +{ + QMenu menu(this); + + // 1 - check that we are clicking on a post + + QModelIndex index = ui->postsTree->indexAt(point); + + if(!index.isValid()) + return; + + // 2 - generate the menu for that post. + + menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyMessageLink()))->setData(index); + menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_AUTHOR), tr("Show author in People tab"), this, SLOT(showAuthorInPeople()))->setData(index); + +#ifdef TODO + // This feature is not implemented yet in libretroshare. + + if(IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags)) + menu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/edit_16.png"), tr("Edit"), this, SLOT(editPost())); +#endif + + menu.exec(QCursor::pos()); +} + void PostedListWidgetWithModel::switchDisplayMode() { if(mPostedPostsDelegate->getDisplayMode() == BoardPostDisplayWidget_compact::DISPLAY_MODE_CARD) @@ -403,7 +431,7 @@ void PostedListWidgetWithModel::prevPosts() void PostedListWidgetWithModel::showAuthorInPeople() { - QModelIndex index = ui->postsTree->selectionModel()->currentIndex(); + QModelIndex index = qobject_cast(QObject::sender())->data().toModelIndex(); if(!index.isValid()) throw std::runtime_error("No post under mouse!"); @@ -428,23 +456,6 @@ void PostedListWidgetWithModel::showAuthorInPeople() MainWindow::showWindow(MainWindow::People); idDialog->navigate(RsGxsId(post.mMeta.mAuthorId)); } -void PostedListWidgetWithModel::postContextMenu(const QPoint&) -{ - QMenu menu(this); - - menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyMessageLink())); - menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_AUTHOR), tr("Show author in People tab"), this, SLOT(showAuthorInPeople())); - -#ifdef TODO - // This feature is not implemented yet in libretroshare. - - if(IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags)) - menu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/edit_16.png"), tr("Edit"), this, SLOT(editPost())); -#endif - - menu.exec(QCursor::pos()); -} - void PostedListWidgetWithModel::copyMessageLink() { try @@ -452,7 +463,7 @@ void PostedListWidgetWithModel::copyMessageLink() if (groupId().isNull()) throw std::runtime_error("No channel currently selected!"); - QModelIndex index = ui->postsTree->selectionModel()->currentIndex(); + QModelIndex index = qobject_cast(QObject::sender())->data().toModelIndex(); if(!index.isValid()) throw std::runtime_error("No post under mouse!"); @@ -528,87 +539,6 @@ void PostedListWidgetWithModel::handleEvent_main_thread(std::shared_ptrpostsTree->selectionModel()->currentIndex(); - RsPostedPost post = index.data(Qt::UserRole).value() ; - - QTextDocument doc; - doc.setHtml(post.mMsg.c_str()); - - if(post.mMeta.mPublishTs == 0) - { - ui->postDetails_TE->clear(); - ui->postLogo_LB->hide(); - ui->postName_LB->hide(); - ui->postTime_LB->hide(); - mChannelPostFilesModel->clear(); - - return; - } - - ui->postLogo_LB->show(); - ui->postName_LB->show(); - ui->postTime_LB->show(); - - if(index.row()==0 && index.column()==0) - std::cerr << "here" << std::endl; - - std::cerr << "showPostDetails: setting mLastSelectedPosts[groupId()] to current post Id " << post.mMeta.mMsgId << ". Previous value: " << mLastSelectedPosts[groupId()] << std::endl; - mLastSelectedPosts[groupId()] = post.mMeta.mMsgId; - - std::list files; - for(auto& file:post.mFiles) - files.push_back(ChannelPostFileInfo(file,post.mMeta.mPublishTs)); - - mChannelPostFilesModel->setFiles(files); - - auto all_msgs_versions(post.mOlderVersions); - all_msgs_versions.insert(post.mMeta.mMsgId); - - ui->commentsDialog->commentLoad(post.mMeta.mGroupId, all_msgs_versions, post.mMeta.mMsgId); - - std::cerr << "Showing details about selected index : "<< index.row() << "," << index.column() << std::endl; - - ui->postDetails_TE->setText(RsHtml().formatText(NULL, QString::fromUtf8(post.mMsg.c_str()), /* RSHTML_FORMATTEXT_EMBED_SMILEYS |*/ RSHTML_FORMATTEXT_EMBED_LINKS)); - - QPixmap postImage; - - if (post.mThumbnail.mData != NULL) - GxsIdDetails::loadPixmapFromData(post.mThumbnail.mData, post.mThumbnail.mSize, postImage,GxsIdDetails::ORIGINAL); - else - postImage = FilesDefs::getPixmapFromQtResourcePath(ChannelPostThumbnailView::CHAN_DEFAULT_IMAGE); - - int W = QFontMetricsF(font()).height() * 8; - - // Using fixed width so that the post will not displace the text when we browse. - - ui->postLogo_LB->setPixmap(postImage); - ui->postLogo_LB->setFixedSize(W,postImage.height()/(float)postImage.width()*W); - - ui->postName_LB->setText(QString::fromUtf8(post.mMeta.mMsgName.c_str())); - ui->postName_LB->setFixedWidth(W); - ui->postTime_LB->setText(QDateTime::fromMSecsSinceEpoch(post.mMeta.mPublishTs*1000).toString("MM/dd/yyyy, hh:mm")); - ui->postTime_LB->setFixedWidth(W); - - //ui->channelPostFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_FILE); - //ui->channelPostFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE); - ui->channelPostFiles_TV->setAutoSelect(true); - - // Now also set the post as read - - if(IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus)) - { - RsGxsGrpMsgIdPair postId; - postId.second = post.mMeta.mMsgId; - postId.first = post.mMeta.mGroupId; - - RsThread::async([postId]() { rsGxsChannels->markRead(postId, true) ; } ); - } -} -#endif - void PostedListWidgetWithModel::updateGroupData() { if(groupId().isNull()) diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h index a447424e8..e6b98120a 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h @@ -136,6 +136,7 @@ private slots: #ifdef TO_REMOVE void showPostDetails(); #endif + void postContextMenu(const QPoint&); void showAuthorInPeople(); void tabCloseRequested(int index); void updateSorting(int); @@ -145,7 +146,6 @@ private slots: void subscribeGroup(bool subscribe); void settingsChanged(); void postPostLoad(); - void postContextMenu(const QPoint&); void copyMessageLink(); void nextPosts(); void prevPosts(); From d04c28cffc2a539378e17065b06a623396204817 Mon Sep 17 00:00:00 2001 From: defnax Date: Thu, 20 Apr 2023 19:00:51 +0200 Subject: [PATCH 22/32] Fixed to get reizable people page * Fixed to get resizable people page * Moved text for auto ban as tooltip, keep short text for the checkbox * Removed empty wasting spacer from Boards bar --- retroshare-gui/src/gui/Identity/IdDialog.ui | 31 +++++++++---------- .../gui/Posted/PostedListWidgetWithModel.ui | 16 ---------- .../src/gui/msgs/MessageComposer.ui | 4 +-- 3 files changed, 17 insertions(+), 34 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.ui b/retroshare-gui/src/gui/Identity/IdDialog.ui index f18ddbc87..196fbdae4 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.ui +++ b/retroshare-gui/src/gui/Identity/IdDialog.ui @@ -301,8 +301,8 @@ 0 0 - 634 - 538 + 479 + 731 @@ -338,21 +338,14 @@ - - - - Qt::Vertical - - - - 518 - 17 - - - - + + + 0 + 0 + + @@ -490,6 +483,9 @@ Invite messages stay into your Outbox until an acknowledgement of receipt has been received. + + true + @@ -895,9 +891,12 @@ border-image: url(:/images/closepressed.png) - + Auto-Ban all identities signed by the same node + + Auto-Ban + diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui index 9ed0fc3db..2bafbc8a2 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui @@ -454,22 +454,6 @@ p, li { white-space: pre-wrap; }
- - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 40 - 20 - - - - diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.ui b/retroshare-gui/src/gui/msgs/MessageComposer.ui index 8b2e3d601..9b5e8605c 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.ui +++ b/retroshare-gui/src/gui/msgs/MessageComposer.ui @@ -6,8 +6,8 @@ 0 0 - 1215 - 825 + 800 + 650 From 7858db9b2c9cc3d5428710d945a52963a0cd9a66 Mon Sep 17 00:00:00 2001 From: defnax Date: Thu, 20 Apr 2023 19:48:13 +0200 Subject: [PATCH 23/32] Use ElidedLabel for post name Label --- .../src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui index c4005cfc6..9afe3e5d0 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui @@ -402,7 +402,7 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'Sans Serif'; font-size:11pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;">Description</span></p></body></html> @@ -534,7 +534,7 @@ p, li { white-space: pre-wrap; } - + 75 From a71d6e243003553396a26b47cd39706daefdf1a6 Mon Sep 17 00:00:00 2001 From: defnax Date: Thu, 20 Apr 2023 23:26:57 +0200 Subject: [PATCH 24/32] Picture attachments improved * Added a remove button to clear pictures * Improved picture attachments --- .../src/gui/TheWire/PulseAddDialog.cpp | 46 ++++++-- .../src/gui/TheWire/PulseAddDialog.h | 3 +- .../src/gui/TheWire/PulseAddDialog.ui | 102 +++++++++--------- 3 files changed, 91 insertions(+), 60 deletions(-) diff --git a/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp b/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp index 572772a1e..8877d5cf6 100644 --- a/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp +++ b/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp @@ -42,15 +42,26 @@ PulseAddDialog::PulseAddDialog(QWidget *parent) connect(ui.pushButton_Cancel, SIGNAL( clicked( void ) ), this, SLOT( cancelPulse( void ) ) ); connect(ui.textEdit_Pulse, SIGNAL( textChanged( void ) ), this, SLOT( pulseTextChanged( void ) ) ); connect(ui.pushButton_picture, SIGNAL(clicked()), this, SLOT( toggle())); + connect(ui.pushButton_remove, SIGNAL(clicked()), this, SLOT( removePictures())); + // this connection is from browse push button to the slot function onBrowseButtonClicked() connect(ui.pushButton_Browse, SIGNAL(clicked()), this, SLOT( onBrowseButtonClicked())); ui.pushButton_picture->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/photo.png"))); + ui.pushButton_Browse->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/add-image.png"))); + ui.pushButton_remove->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/mail/delete.png"))); + ui.frame_picture->hide(); + ui.pushButton_picture->hide(); // initially hiding the browse button as the attach image button is not pressed - ui.frame_PictureBrowse->hide(); + //ui.frame_PictureBrowse->hide(); + + ui.label_image1->hide(); + ui.label_image2->hide(); + ui.label_image3->hide(); + ui.label_image4->hide(); setAcceptDrops(true); } @@ -160,11 +171,10 @@ void PulseAddDialog::cleanup() ui.label_image4->clear(); ui.label_image4->setText(tr("Drag and Drop Image")); - ui.lineEdit_FilePath->clear(); - // Hide Drag & Drop Frame and the browse frame ui.frame_picture->hide(); - ui.frame_PictureBrowse->hide(); + //ui.frame_PictureBrowse->hide(); + ui.pushButton_picture->hide(); ui.pushButton_picture->setChecked(false); } @@ -489,24 +499,29 @@ void PulseAddDialog::addImage(const QString &path) std::cerr << "PulseAddDialog::addImage() Installing in Image1"; std::cerr << std::endl; ui.label_image1->setPixmap(icon); + ui.label_image1->show(); + ui.frame_picture->show(); mImage1.copy((uint8_t *) ba.data(), ba.size()); std::cerr << "PulseAddDialog::addImage() Installing in Image1 Size: " << mImage1.mSize; std::cerr << std::endl; } else if (mImage2.empty()) { ui.label_image2->setPixmap(icon); + ui.label_image2->show(); mImage2.copy((uint8_t *) ba.data(), ba.size()); std::cerr << "PulseAddDialog::addImage() Installing in Image2 Size: " << mImage2.mSize; std::cerr << std::endl; } else if (mImage3.empty()) { ui.label_image3->setPixmap(icon); + ui.label_image3->show(); mImage3.copy((uint8_t *) ba.data(), ba.size()); std::cerr << "PulseAddDialog::addImage() Installing in Image3 Size: " << mImage3.mSize; std::cerr << std::endl; } else if (mImage4.empty()) { ui.label_image4->setPixmap(icon); + ui.label_image4->show(); mImage4.copy((uint8_t *) ba.data(), ba.size()); std::cerr << "PulseAddDialog::addImage() Installing in Image4 Size: " << mImage4.mSize; std::cerr << std::endl; @@ -523,7 +538,6 @@ void PulseAddDialog::toggle() { // Show the input methods (drag and drop field and the browse button) ui.frame_picture->show(); - ui.frame_PictureBrowse->show(); ui.pushButton_picture->setToolTip(tr("Hide Pictures")); } @@ -531,7 +545,6 @@ void PulseAddDialog::toggle() { // Hide the input methods (drag and drop field and the browse button) ui.frame_picture->hide(); - ui.frame_PictureBrowse->hide(); ui.pushButton_picture->setToolTip(tr("Add Pictures")); } @@ -543,8 +556,27 @@ void PulseAddDialog::onBrowseButtonClicked() QString filePath; misc::getOpenFileName(this, RshareSettings::LASTDIR_IMAGES, tr("Load Picture File"), "Pictures (*.png *.xpm *.jpg *.jpeg *.gif *.webp )", filePath); if (!filePath.isEmpty()) { - ui.lineEdit_FilePath->setText(filePath); + //ui.lineEdit_FilePath->setText(filePath); addImage(filePath); } } +void PulseAddDialog::removePictures() +{ + + mImage1.clear(); + ui.label_image1->clear(); + mImage2.clear(); + ui.label_image2->clear(); + mImage3.clear(); + ui.label_image3->clear(); + mImage4.clear(); + ui.label_image4->clear(); + + ui.label_image1->hide(); + ui.label_image2->hide(); + ui.label_image3->hide(); + ui.label_image4->hide(); + + ui.frame_picture->hide(); +} diff --git a/retroshare-gui/src/gui/TheWire/PulseAddDialog.h b/retroshare-gui/src/gui/TheWire/PulseAddDialog.h index 69007b025..b1e8eca47 100644 --- a/retroshare-gui/src/gui/TheWire/PulseAddDialog.h +++ b/retroshare-gui/src/gui/TheWire/PulseAddDialog.h @@ -53,7 +53,8 @@ private slots: void clearDialog(); void pulseTextChanged(); void toggle(); - void onBrowseButtonClicked(); + void onBrowseButtonClicked(); + void removePictures(); private: // OLD VERSIONs, private now. diff --git a/retroshare-gui/src/gui/TheWire/PulseAddDialog.ui b/retroshare-gui/src/gui/TheWire/PulseAddDialog.ui index 5ef30ef19..25738136d 100644 --- a/retroshare-gui/src/gui/TheWire/PulseAddDialog.ui +++ b/retroshare-gui/src/gui/TheWire/PulseAddDialog.ui @@ -6,7 +6,7 @@ 0 0 - 720 + 735 513 @@ -52,6 +52,7 @@ 12 + 75 true @@ -249,6 +250,12 @@ + + + 0 + 0 + + 0 @@ -278,6 +285,22 @@ + + + + + 40 + 40 + + + + Drag and Drop Image + + + Qt::AlignCenter + + + @@ -310,63 +333,22 @@ - - - - - 40 - 40 - + + + + Remove all images - Drag and Drop Image + - - Qt::AlignCenter - - - - - - - - - - - 0 - 50 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - + - 541 - 25 + 24 + 24 - - - - - 101 - 25 - - - - Browse... - - - @@ -413,7 +395,6 @@ frame_URL frame_picture - frame_PictureBrowse textEdit_Pulse
@@ -423,7 +404,7 @@ 6 - + @@ -438,6 +419,22 @@ + + + + Add Picture + + + + + + + 24 + 24 + + + + @@ -456,6 +453,7 @@ 12 + 75 true From 2cb87368042675a01ceb658e9d2f3efda77e12c0 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 22 Apr 2023 15:02:32 +0200 Subject: [PATCH 25/32] fixed update of forum when marking msg as read/unread with children --- retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp index 77292dadf..d793c29fe 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp @@ -1278,8 +1278,8 @@ void RsGxsForumModel::recursSetMsgReadStatus(ForumModelIndex i,bool read_status, void *ref ; convertTabEntryToRefPointer(i,ref); // we dont use i+1 here because i is not a row, but an index in the mPosts tab - QModelIndex itemIndex = createIndex(i - 1, 0, ref); - emit dataChanged(itemIndex, itemIndex); + QModelIndex itemIndex = (mTreeMode == TREE_MODE_FLAT)?createIndex(i - 1, 0, ref):createIndex(mPosts[i].prow,0,ref); + emit dataChanged(itemIndex, itemIndex); } if(!with_children) From 9d956f6126c6d13ff98954217ae69165118060b5 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 22 Apr 2023 16:19:04 +0200 Subject: [PATCH 26/32] fixed layout update problem when switching channels --- .../GxsChannelPostsWidgetWithModel.cpp | 34 ++++++++++++------- .../GxsChannelPostsWidgetWithModel.h | 5 +-- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index b99f71faf..381e4b7b9 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -279,18 +279,18 @@ void ChannelPostDelegate::setWidgetGrid(bool use_grid) QWidget *ChannelPostFilesDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &/*option*/, const QModelIndex& index) const { - ChannelPostFileInfo file = index.data(Qt::UserRole).value() ; + ChannelPostFileInfo file = index.data(Qt::UserRole).value() ; - if(index.column() == RsGxsChannelPostFilesModel::COLUMN_FILES_FILE) - { + if(index.column() == RsGxsChannelPostFilesModel::COLUMN_FILES_FILE) + { GxsChannelFilesStatusWidget* w = new GxsChannelFilesStatusWidget(file,parent,true); w->setFocusPolicy(Qt::StrongFocus); connect(w,SIGNAL(onButtonClick()),this->parent(),SLOT(updateDAll_PB())); - return w; - } - else - return NULL; + return w; + } + else + return NULL; } void ChannelPostFilesDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &/* index */) const { @@ -392,7 +392,7 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI mChannelPostsDelegate->setAspectRatio(ChannelPostThumbnailView::ASPECT_RATIO_16_9); - connect(ui->postsTree,SIGNAL(zoomRequested(bool)),this,SLOT(updateZoomFactor(bool))); + connect(ui->postsTree,SIGNAL(zoomRequested(bool)),this,SLOT(onUpdateZoomFactor(bool))); connect(ui->commentsDialog,SIGNAL(commentsLoaded(int)),this,SLOT(updateCommentsCount(int))); ui->channelPostFiles_TV->setModel(mChannelPostFilesModel = new RsGxsChannelPostFilesModel(this)); @@ -520,9 +520,17 @@ void GxsChannelPostsWidgetWithModel::currentTabChanged(int t) break; } } -void GxsChannelPostsWidgetWithModel::updateZoomFactor(bool zoom_or_unzoom) +void GxsChannelPostsWidgetWithModel::onUpdateZoomFactor(bool zoom_or_unzoom) { - mChannelPostsDelegate->zoom(zoom_or_unzoom); + if(zoom_or_unzoom) + updateZoomFactor(1); + else + updateZoomFactor(-1); +} +void GxsChannelPostsWidgetWithModel::updateZoomFactor(int what_to_do) +{ + if(what_to_do != 0) + mChannelPostsDelegate->zoom(what_to_do > 0); for(int i=0;icolumnCount();++i) ui->postsTree->setColumnWidth(i,mChannelPostsDelegate->cellSize(i,font(),ui->postsTree->width())); @@ -532,8 +540,7 @@ void GxsChannelPostsWidgetWithModel::updateZoomFactor(bool zoom_or_unzoom) int n_columns = std::max(1,(int)floor(s.width() / (mChannelPostsDelegate->cellSize(0,font(),s.width())))); mChannelPostsModel->setNumColumns(n_columns); // forces the update - - ui->postsTree->dataChanged(QModelIndex(),QModelIndex()); + mChannelPostsModel->triggerViewUpdate(); } void GxsChannelPostsWidgetWithModel::sortColumnPostFiles(int col,Qt::SortOrder so) @@ -1067,8 +1074,9 @@ void GxsChannelPostsWidgetWithModel::postChannelPostLoad() best = i; mChannelPostsDelegate->setAspectRatio(static_cast(best)); - mChannelPostsModel->triggerViewUpdate(); handlePostsTreeSizeChange(ui->postsTree->size(),true); // force the update + + updateZoomFactor(0); } void GxsChannelPostsWidgetWithModel::updateDisplay(bool update_group_data,bool update_posts) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h index 70673f57f..874562d32 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h @@ -154,7 +154,7 @@ private slots: void editPost(); void postContextMenu(const QPoint&); void copyMessageLink(); - void updateZoomFactor(bool zoom_or_unzoom); + void onUpdateZoomFactor(bool zoom_or_unzoom); void switchView(); void switchOnlyUnread(bool b); void markMessageUnread(); @@ -168,7 +168,8 @@ public slots: void copyChannelFilesLink(); private: - void processSettings(bool load); + void updateZoomFactor(int what_to_do); // -1=unzoom, 0=nothing, 1=zoom + void processSettings(bool load); RsGxsMessageId getCurrentItemId() const; void selectItem(const RsGxsMessageId& msg_id); From 3e35ce4dddccd13e2b2916e362807bff30d67816 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 22 Apr 2023 18:16:04 +0200 Subject: [PATCH 27/32] improved the logic to make the channel layout update faster --- .../gui/gxschannels/GxsChannelPostsModel.cpp | 22 +++++++------------ .../gui/gxschannels/GxsChannelPostsModel.h | 2 +- .../GxsChannelPostsWidgetWithModel.cpp | 8 +++++-- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index 197013c8b..91a2a578c 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -63,7 +63,7 @@ void RsGxsChannelPostsModel::setMode(TreeMode mode) if(mode == TREE_MODE_LIST) setNumColumns(2); - triggerViewUpdate(); + triggerViewUpdate(true,true); } void RsGxsChannelPostsModel::computeCommentCounts( std::vector& posts, std::vector& comments) @@ -118,12 +118,15 @@ void RsGxsChannelPostsModel::preMods() } void RsGxsChannelPostsModel::postMods() { - triggerViewUpdate(); emit layoutChanged(); } -void RsGxsChannelPostsModel::triggerViewUpdate() +void RsGxsChannelPostsModel::triggerViewUpdate(bool data_changed, bool layout_changed) { - emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(rowCount()-1,mColumns-1,(void*)NULL)); + if(data_changed) + emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(rowCount()-1,mColumns-1,(void*)NULL)); + + if(layout_changed) + emit layoutChanged(); } void RsGxsChannelPostsModel::getFilesList(std::list& files) @@ -316,17 +319,8 @@ bool RsGxsChannelPostsModel::setNumColumns(int n) preMods(); - beginResetModel(); - endResetModel(); - mColumns = n; - if (rowCount()>0) - { - beginInsertRows(QModelIndex(),0,rowCount()-1); - endInsertRows(); - } - postMods(); return true; @@ -548,7 +542,7 @@ void RsGxsChannelPostsModel::updateSinglePost(const RsGxsChannelPost& post,std:: uint32_t count; updateFilter(count); - triggerViewUpdate(); + triggerViewUpdate(true,false); } void RsGxsChannelPostsModel::setPosts(const RsGxsChannelGroup& group, std::vector& posts) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h index c12e31635..42dcbb9f7 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h @@ -115,7 +115,7 @@ public: void updateChannel(const RsGxsGroupId& channel_group_id); const RsGxsGroupId& currentGroupId() const; - void triggerViewUpdate(); + void triggerViewUpdate(bool data_changed,bool layout_changed); // sets the number of columns. Returns 0 if nothing changes. bool setNumColumns(int n); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 381e4b7b9..7593d4e18 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -540,7 +540,11 @@ void GxsChannelPostsWidgetWithModel::updateZoomFactor(int what_to_do) int n_columns = std::max(1,(int)floor(s.width() / (mChannelPostsDelegate->cellSize(0,font(),s.width())))); mChannelPostsModel->setNumColumns(n_columns); // forces the update - mChannelPostsModel->triggerViewUpdate(); + + if(what_to_do) + mChannelPostsModel->triggerViewUpdate(true,false); + else + mChannelPostsModel->triggerViewUpdate(false,true); } void GxsChannelPostsWidgetWithModel::sortColumnPostFiles(int col,Qt::SortOrder so) @@ -646,7 +650,7 @@ void GxsChannelPostsWidgetWithModel::switchView() selectItem(msg_id); ui->postsTree->setFocus(); - mChannelPostsModel->triggerViewUpdate(); // This is already called by setMode(), but the model cannot know how many + mChannelPostsModel->triggerViewUpdate(false,true); // This is already called by setMode(), but the model cannot know how many // columns is actually has until we call handlePostsTreeSizeChange(), so // we have to call it again here. } From 2ab012261b5b63debefe659785c036c16a33beaf Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 22 Apr 2023 22:50:53 +0200 Subject: [PATCH 28/32] fixed wrong column size when first showing the channel posts tab --- .../GxsChannelPostsWidgetWithModel.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 7593d4e18..bd1405915 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -92,9 +92,9 @@ Q_DECLARE_METATYPE(ChannelPostFileInfo) int ChannelPostDelegate::cellSize(int col,const QFont& font,uint32_t parent_width) const { if(mUseGrid || col==0) - return mZoom*COLUMN_SIZE_FONT_FACTOR_W*QFontMetricsF(font).height(); + return (int)floor(mZoom*COLUMN_SIZE_FONT_FACTOR_W*QFontMetricsF(font).height()); else - return 0.8*parent_width - mZoom*COLUMN_SIZE_FONT_FACTOR_W*QFontMetricsF(font).height(); + return (int)floor(0.8*parent_width - mZoom*COLUMN_SIZE_FONT_FACTOR_W*QFontMetricsF(font).height()); } void ChannelPostDelegate::zoom(bool zoom_or_unzoom) @@ -517,6 +517,7 @@ void GxsChannelPostsWidgetWithModel::currentTabChanged(int t) case CHANNEL_TABS_POSTS: ui->showUnread_TB->setHidden(false); ui->viewType_TB->setHidden(false); + updateZoomFactor(0); // fixes a bug due to the widget now knowing its size when not displayed. break; } } @@ -532,15 +533,13 @@ void GxsChannelPostsWidgetWithModel::updateZoomFactor(int what_to_do) if(what_to_do != 0) mChannelPostsDelegate->zoom(what_to_do > 0); + QSize s = ui->postsTree->size(); + int n_columns = std::max(1,(int)floor(s.width() / (float)(mChannelPostsDelegate->cellSize(0,font(),s.width())))); + mChannelPostsModel->setNumColumns(n_columns); // forces the update + for(int i=0;icolumnCount();++i) ui->postsTree->setColumnWidth(i,mChannelPostsDelegate->cellSize(i,font(),ui->postsTree->width())); - QSize s = ui->postsTree->size(); - - int n_columns = std::max(1,(int)floor(s.width() / (mChannelPostsDelegate->cellSize(0,font(),s.width())))); - - mChannelPostsModel->setNumColumns(n_columns); // forces the update - if(what_to_do) mChannelPostsModel->triggerViewUpdate(true,false); else From f06506ec5418315a26d7da88ca1ae23c083c6d30 Mon Sep 17 00:00:00 2001 From: defnax Date: Sun, 23 Apr 2023 19:31:30 +0200 Subject: [PATCH 29/32] Corrected checkbox text --- retroshare-gui/src/gui/Identity/IdDialog.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.ui b/retroshare-gui/src/gui/Identity/IdDialog.ui index 196fbdae4..ff3775aee 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.ui +++ b/retroshare-gui/src/gui/Identity/IdDialog.ui @@ -301,7 +301,7 @@ 0 0 - 479 + 456 731 @@ -895,7 +895,7 @@ border-image: url(:/images/closepressed.png) Auto-Ban all identities signed by the same node - Auto-Ban + Auto-Ban profile From 0ff4426d7203800d50e66075b0ab3f271be7307b Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 23 Apr 2023 22:47:33 +0200 Subject: [PATCH 30/32] removed multiple references to temporary passed accross threads, causing random crashes --- retroshare-gui/src/gui/feeds/BoardsCommentsItem.cpp | 4 ++-- retroshare-gui/src/gui/feeds/ChannelsCommentsItem.cpp | 4 ++-- retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp | 2 +- retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/retroshare-gui/src/gui/feeds/BoardsCommentsItem.cpp b/retroshare-gui/src/gui/feeds/BoardsCommentsItem.cpp index 684b85e54..57adbb39d 100644 --- a/retroshare-gui/src/gui/feeds/BoardsCommentsItem.cpp +++ b/retroshare-gui/src/gui/feeds/BoardsCommentsItem.cpp @@ -186,13 +186,13 @@ void BaseBoardsCommentsItem::loadMessage() if (posts.size() == 1) { std::cerr << (void*)this << ": Obtained post, with msgId = " << posts[0].mMeta.mMsgId << std::endl; - const RsPostedPost& post(posts[0]); + RsPostedPost post(posts[0]); // no reference to temporary because it's passed to a thread! RsQThreadUtils::postToObject( [post,this]() { setPost(post,true); mIsLoadingMessage = false;}, this ); } else if(comments.size() == 1) { - const RsGxsComment& cmt = comments[0]; + RsGxsComment cmt(comments[0]); std::cerr << (void*)this << ": Obtained comment, setting messageId to threadID = " << cmt.mMeta.mThreadId << std::endl; RsQThreadUtils::postToObject( [cmt,this]() diff --git a/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.cpp b/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.cpp index 296f3f173..ecbba96af 100644 --- a/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.cpp +++ b/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.cpp @@ -292,13 +292,13 @@ void ChannelsCommentsItem::loadMessage() #ifdef DEBUG_ITEM std::cerr << (void*)this << ": Obtained post, with msgId = " << posts[0].mMeta.mMsgId << std::endl; #endif - const RsGxsChannelPost& post(posts[0]); + RsGxsChannelPost post(posts[0]); // no reference to temporary here, because we pass this to a thread RsQThreadUtils::postToObject( [post,this]() { setPost(post); }, this ); } else if(comments.size() == 1) { - const RsGxsComment& cmt = comments[0]; + RsGxsComment cmt(comments[0]); #ifdef DEBUG_ITEM std::cerr << (void*)this << ": Obtained comment, setting messageId to threadID = " << cmt.mMeta.mThreadId << std::endl; #endif diff --git a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp index 1d61bb98b..43c94a377 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp @@ -125,7 +125,7 @@ void GxsForumGroupItem::loadGroup() std::cerr << std::endl; return; } - const RsGxsForumGroup& group(groups[0]); + RsGxsForumGroup group(groups[0]);// no reference to teporary accross threads! RsQThreadUtils::postToObject( [group,this]() { diff --git a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp index 556dd1108..eedb4ae20 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp @@ -235,7 +235,7 @@ void GxsForumMsgItem::loadMessage() std::cerr << std::endl; return; } - const RsGxsForumMsg& msg(msgs[0]); + RsGxsForumMsg msg(msgs[0]); RsQThreadUtils::postToObject( [msg,this]() { @@ -280,7 +280,7 @@ void GxsForumMsgItem::loadParentMessage(const RsGxsMessageId& parent_msg) std::cerr << std::endl; return; } - const RsGxsForumMsg& msg(msgs[0]); + RsGxsForumMsg msg(msgs[0]); RsQThreadUtils::postToObject( [msg,this]() { From 35e08e3b665992f9acb36c164da0225e18aa7930 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 25 Apr 2023 11:33:37 +0200 Subject: [PATCH 31/32] fixed keeping post sizes when selelecting unread posts --- retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp | 4 ---- .../src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index 91a2a578c..6179acae7 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -173,11 +173,7 @@ void RsGxsChannelPostsModel::updateFilter(uint32_t& count) { preMods(); - beginResetModel(); - mFilteredPosts.clear(); - //mFilteredPosts.push_back(0); - endResetModel(); for(size_t i=0;iviewType_TB,SIGNAL(clicked()),this,SLOT(switchView())); ui->showUnread_TB->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/message-state-unread.png")); - ui->showUnread_TB->setChecked(false); + whileBlocking(ui->showUnread_TB)->setChecked(false); ui->showUnread_TB->setToolTip(tr("Show unread posts only")); connect(ui->showUnread_TB,SIGNAL(toggled(bool)),this,SLOT(switchOnlyUnread(bool))); From a04ab8664f65e9502403f87710254c2eb520f95a Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 25 Apr 2023 21:26:26 +0200 Subject: [PATCH 32/32] removed double saving of distant chat permissions (GUI + libretroshare) leading to inconsistencies --- retroshare-gui/src/gui/settings/ChatPage.cpp | 23 +++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/retroshare-gui/src/gui/settings/ChatPage.cpp b/retroshare-gui/src/gui/settings/ChatPage.cpp index 86cfaf816..1f35fe62c 100644 --- a/retroshare-gui/src/gui/settings/ChatPage.cpp +++ b/retroshare-gui/src/gui/settings/ChatPage.cpp @@ -125,9 +125,6 @@ void ChatPage::updateFontsAndEmotes() /** Saves the changes on this page */ void ChatPage::updateChatParams() { - // state of distant Chat combobox - Settings->setValue("DistantChat", ui.distantChatComboBox->currentIndex()); - Settings->setChatScreenFont(fontTempChat.toString()); NotifyQt::getInstance()->notifyChatFontChanged(); @@ -395,9 +392,23 @@ ChatPage::load() whileBlocking(ui.minimumContrast)->setValue(Settings->value("MinimumContrast", 4.5).toDouble()); Settings->endGroup(); - // state of distant Chat combobox - int index = Settings->value("DistantChat", 0).toInt(); - whileBlocking(ui.distantChatComboBox)->setCurrentIndex(index); + // state of distant Chat combobox + + switch(rsMsgs->getDistantChatPermissionFlags()) + { + default: + case RS_DISTANT_CHAT_CONTACT_PERMISSION_FLAG_FILTER_NONE: + whileBlocking(ui.distantChatComboBox)->setCurrentIndex(0); + break ; + + case RS_DISTANT_CHAT_CONTACT_PERMISSION_FLAG_FILTER_NON_CONTACTS: + whileBlocking(ui.distantChatComboBox)->setCurrentIndex(1); + break ; + + case RS_DISTANT_CHAT_CONTACT_PERMISSION_FLAG_FILTER_EVERYBODY: + whileBlocking(ui.distantChatComboBox)->setCurrentIndex(2); + break ; + } fontTempChat.fromString(Settings->getChatScreenFont());