mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-27 16:35:21 -04:00
Change Chat History Dialog to no modal.
It will be updated when new message comes.
This commit is contained in:
parent
e0ce5632ef
commit
b1129df077
10 changed files with 81 additions and 56 deletions
|
@ -42,7 +42,6 @@
|
|||
#include "gui/settings/rsharesettings.h"
|
||||
#include "gui/settings/rsettingswin.h"
|
||||
#include "gui/settings/RsharePeerSettings.h"
|
||||
#include "gui/im_history/ImHistoryBrowser.h"
|
||||
#include "gui/common/StatusDefs.h"
|
||||
#include "gui/common/FilesDefs.h"
|
||||
#include "gui/common/Emoticons.h"
|
||||
|
@ -78,7 +77,7 @@ ChatWidget::ChatWidget(QWidget *parent)
|
|||
, lastStatusSendTime(0)
|
||||
, firstShow(true), inChatCharFormatChanged(false), firstSearch(true)
|
||||
, lastUpdateCursorPos(0), lastUpdateCursorEnd(0)
|
||||
, completer(NULL), notify(NULL)
|
||||
, completer(NULL), imBrowser(NULL), notify(NULL)
|
||||
, ui(new Ui::ChatWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
@ -87,8 +86,8 @@ ChatWidget::ChatWidget(QWidget *parent)
|
|||
double fmm = iconHeight > FMM_THRESHOLD ? FMM : FMM_SMALLER;
|
||||
iconHeight *= fmm;
|
||||
QSize iconSize = QSize(iconHeight, iconHeight);
|
||||
int butt_size(iconSize.height() + fmm);
|
||||
QSize buttonSize = QSize(butt_size, butt_size);
|
||||
//int butt_size(iconSize.height() + fmm);
|
||||
//QSize buttonSize = QSize(butt_size, butt_size);
|
||||
|
||||
lastMsgDate = QDate::currentDate();
|
||||
|
||||
|
@ -1607,8 +1606,9 @@ void ChatWidget::deleteChatHistory()
|
|||
|
||||
void ChatWidget::messageHistory()
|
||||
{
|
||||
ImHistoryBrowser imBrowser(chatId, ui->chatTextEdit, window());
|
||||
imBrowser.exec();
|
||||
if (!imBrowser)
|
||||
imBrowser = new ImHistoryBrowser(chatId, ui->chatTextEdit, this->title, window());
|
||||
imBrowser->show();
|
||||
}
|
||||
|
||||
void ChatWidget::addExtraFile()
|
||||
|
|
|
@ -23,20 +23,22 @@
|
|||
#ifndef CHATWIDGET_H
|
||||
#define CHATWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QCompleter>
|
||||
#include <QTextCursor>
|
||||
#include <QTextCharFormat>
|
||||
#include <QToolButton>
|
||||
#include "ChatLobbyUserNotify.h"
|
||||
#include "ChatStyle.h"
|
||||
#include "gui/common/HashBox.h"
|
||||
#include "gui/common/RsButtonOnText.h"
|
||||
#include "ChatStyle.h"
|
||||
#include "gui/im_history/ImHistoryBrowser.h"
|
||||
#include "gui/style/RSStyle.h"
|
||||
#include "ChatLobbyUserNotify.h"
|
||||
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include <retroshare/rsfiles.h>
|
||||
|
||||
#include <QCompleter>
|
||||
#include <QTextCharFormat>
|
||||
#include <QTextCursor>
|
||||
#include <QToolButton>
|
||||
#include <QWidget>
|
||||
|
||||
//For PersonId anchor.
|
||||
#define PERSONID "PersonId:"
|
||||
|
||||
|
@ -258,7 +260,8 @@ private:
|
|||
TransferRequestFlags mDefaultExtraFileFlags ; // flags for extra files shared in this chat. Will be 0 by default, but might be ANONYMOUS for chat lobbies.
|
||||
QDate lastMsgDate ;
|
||||
|
||||
QCompleter *completer;
|
||||
QCompleter *completer;
|
||||
ImHistoryBrowser* imBrowser;
|
||||
|
||||
QList<ChatWidgetHolder*> mChatWidgetHolder;
|
||||
ChatLobbyUserNotify* notify;
|
||||
|
|
|
@ -91,14 +91,15 @@ void ImHistoryBrowserCreateItemsThread::run()
|
|||
}
|
||||
|
||||
/** Default constructor */
|
||||
ImHistoryBrowser::ImHistoryBrowser(const ChatId &chatId, QTextEdit *edit, QWidget *parent)
|
||||
ImHistoryBrowser::ImHistoryBrowser(const ChatId &chatId, QTextEdit *edit,const QString &chatTitle, QWidget *parent)
|
||||
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint)
|
||||
{
|
||||
/* Invoke Qt Designer generated QObject setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
setWindowTitle(tr("%1 's Message History").arg(chatTitle));
|
||||
ui.headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/images/user/agt_forum64.png"));
|
||||
ui.headerFrame->setHeaderText(tr("Message History"));
|
||||
ui.headerFrame->setHeaderText(windowTitle());
|
||||
|
||||
m_chatId = chatId;
|
||||
textEdit = edit;
|
||||
|
@ -225,36 +226,43 @@ void ImHistoryBrowser::historyAdd(HistoryMsg& msg)
|
|||
|
||||
void ImHistoryBrowser::historyChanged(uint msgId, int type)
|
||||
{
|
||||
if (type == NOTIFY_TYPE_ADD) {
|
||||
/* history message added */
|
||||
HistoryMsg msg;
|
||||
if (rsHistory->getMessage(msgId, msg) == false) {
|
||||
return;
|
||||
}
|
||||
if (type == NOTIFY_TYPE_ADD) {
|
||||
/* history message added */
|
||||
HistoryMsg msg;
|
||||
if (rsHistory->getMessage(msgId, msg) == false) {
|
||||
return;
|
||||
}
|
||||
RsPeerId virtChatId;
|
||||
if ( rsHistory->chatIdToVirtualPeerId(m_chatId ,virtChatId)
|
||||
&& virtChatId == msg.chatPeerId)
|
||||
historyAdd(msg);
|
||||
|
||||
historyAdd(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
if (type == NOTIFY_TYPE_DEL) {
|
||||
/* history message removed */
|
||||
int count = ui.listWidget->count();
|
||||
for (int i = 0; i < count; ++i) {
|
||||
QListWidgetItem *itemWidget = ui.listWidget->item(i);
|
||||
if (itemWidget->data(ROLE_MSGID).toString().toUInt() == msgId) {
|
||||
delete(ui.listWidget->takeItem(i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == NOTIFY_TYPE_DEL) {
|
||||
/* history message removed */
|
||||
int count = ui.listWidget->count();
|
||||
for (int i = 0; i < count; ++i) {
|
||||
QListWidgetItem *itemWidget = ui.listWidget->item(i);
|
||||
if (itemWidget->data(ROLE_MSGID).toString().toUInt() == msgId) {
|
||||
delete(ui.listWidget->takeItem(i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == NOTIFY_TYPE_MOD) {
|
||||
/* clear history */
|
||||
ui.listWidget->clear();
|
||||
return;
|
||||
}
|
||||
if (type == NOTIFY_TYPE_MOD) {
|
||||
/* clear history */
|
||||
// As no ChatId nor msgId are send via Notify,
|
||||
// only check if history of this chat is empty before clear our list.
|
||||
std::list<HistoryMsg> historyMsgs;
|
||||
rsHistory->getMessages(m_chatId, historyMsgs, 1);
|
||||
if (historyMsgs.empty())
|
||||
ui.listWidget->clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void ImHistoryBrowser::fillItem(QListWidgetItem *itemWidget, HistoryMsg& msg)
|
||||
|
|
|
@ -41,7 +41,7 @@ class ImHistoryBrowser : public QDialog
|
|||
|
||||
public:
|
||||
/** Default constructor */
|
||||
ImHistoryBrowser(const ChatId &chatId, QTextEdit *edit, QWidget *parent = 0);
|
||||
ImHistoryBrowser(const ChatId &chatId, QTextEdit *edit,const QString &chatTitle, QWidget *parent = 0);
|
||||
/** Default destructor */
|
||||
virtual ~ImHistoryBrowser();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue