21
21
#include " utilsound.h"
22
22
#include " utiltts.h"
23
23
#include " utilui.h"
24
+ #include " chattextlist.h"
24
25
25
26
#include < QDebug>
26
27
#include < QMessageBox>
@@ -57,6 +58,22 @@ TextMessageDlg::TextMessageDlg(const User& user, const textmessages_t& msgs,
57
58
void TextMessageDlg::init (const User& user)
58
59
{
59
60
ui.setupUi (this );
61
+ bool listview = ttSettings->value (SETTINGS_DISPLAY_CHAT_HISTORY_LISTVIEW, SETTINGS_DISPLAY_CHAT_HISTORY_LISTVIEW_DEFAULT).toBool ();
62
+ if (listview)
63
+ {
64
+ auto chat = new ChatTextList (ui.groupBox );
65
+ delete ui.groupBox ->layout ()->replaceWidget (ui.historyTextEdit , chat);
66
+ m_history = chat;
67
+ ui.historyTextEdit = nullptr ;
68
+ }
69
+ else
70
+ {
71
+ m_history = ui.historyTextEdit ;
72
+ connect (ui.historyTextEdit , &ChatTextEdit::clearHistory, [&]() {
73
+ emit (clearUserTextMessages (m_userid));
74
+ });
75
+ }
76
+
60
77
setWindowIcon (QIcon (APPICON));
61
78
restoreGeometry (ttSettings->value (SETTINGS_DISPLAY_TEXTMSGWINDOWPOS).toByteArray ());
62
79
ui.splitter ->restoreState (ttSettings->value (SETTINGS_DISPLAY_TEXTMSGWINDOWPOS_SPLITTER).toByteArray ());
@@ -67,9 +84,6 @@ void TextMessageDlg::init(const User& user)
67
84
connect (ui.newmsgTextEdit , &QPlainTextEdit::textChanged, this , &TextMessageDlg::slotTextChanged);
68
85
connect (ui.newmsgTextEdit , &SendTextEdit::sendTextMessage,
69
86
this , &TextMessageDlg::slotSendMsg);
70
- connect (ui.historyTextEdit , &ChatTextEdit::clearHistory, [&]() {
71
- emit (clearUserTextMessages (m_userid));
72
- });
73
87
slotUpdateUser (user);
74
88
slotTextChanged ();
75
89
@@ -190,7 +204,7 @@ void TextMessageDlg::newMsg(const MyTextMessage& msg, bool store)
190
204
{
191
205
case MSGTYPE_USER :
192
206
{
193
- QString line = ui. historyTextEdit ->addTextMessage (msg);
207
+ QString line = m_history ->addTextMessage (msg);
194
208
ui.newmsgGroupBox ->setTitle (tr (" New message" ));
195
209
196
210
QString folder = ttSettings->value (SETTINGS_MEDIASTORAGE_USERLOGFOLDER).toString ();
@@ -249,11 +263,11 @@ void TextMessageDlg::keyPressEvent(QKeyEvent* e)
249
263
if (e->key () == Qt::Key_F6)
250
264
{
251
265
if (ui.newmsgTextEdit ->hasFocus ())
252
- ui. historyTextEdit ->setFocus ();
253
- else if (ui. historyTextEdit ->hasFocus ())
266
+ m_history ->setFocus ();
267
+ else if (m_history ->hasFocus ())
254
268
ui.newmsgTextEdit ->setFocus ();
255
269
}
256
- if (ui. historyTextEdit ->hasFocus ())
270
+ if (m_history ->hasFocus ())
257
271
{
258
272
QString key = e->text ();
259
273
if (!key.isEmpty () && key.size () == 1 )
0 commit comments