Skip to content

Commit 408f007

Browse files
committed
Configurable option to change chat history to list view
1 parent 5f17c94 commit 408f007

9 files changed

+71
-17
lines changed

ChangeLog.txt

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Default Qt Client
1414
- Last login time shown in "User Accounts" dialog
1515
- Ability to sort by "Last Login Time" in "User Accounts" dialog
1616
- Ability to send toast notifications on Linux and Windows
17+
- Ability to change chat history to list view in "Preferences" dialog
1718
- Improve "Server Properties" dialog accessibility
1819
- WebRTC updated from r4332 to r6818
1920
- Qt updated to 6.9.0beta3 on macOS and Windows

Client/qtTeamTalk/chattextedit.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class ChatTextHistory
3434
virtual void addLogMessage(const QString& msg) = 0;
3535

3636
virtual bool hasFocus() const = 0;
37+
virtual void setFocus() = 0;
3738
};
3839

3940
class ChatTextEdit : public QPlainTextEdit, public ChatTextHistory
@@ -50,7 +51,7 @@ class ChatTextEdit : public QPlainTextEdit, public ChatTextHistory
5051
QString addTextMessage(const MyTextMessage& msg) override;
5152
void addLogMessage(const QString& msg) override;
5253
bool hasFocus() const override { return QPlainTextEdit::hasFocus(); }
53-
54+
void setFocus() override { QPlainTextEdit::setFocus(); }
5455
signals:
5556
void clearHistory();
5657
private:

Client/qtTeamTalk/chattextlist.h

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class ChatTextList : public QListWidget, public ChatTextHistory
3636
QString addTextMessage(const MyTextMessage& msg) override;
3737
void addLogMessage(const QString& msg) override;
3838
bool hasFocus() const override { return QListWidget::hasFocus(); }
39+
void setFocus() override { QListWidget::setFocus(); }
3940

4041
void clearHistory();
4142
void copyAllHistory();

Client/qtTeamTalk/mainwindow.cpp

+23-4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "utilmedia.h"
4949
#include "moveusersdlg.h"
5050
#include "useraccountdlg.h"
51+
#include "chattextlist.h"
5152

5253
#include <QMessageBox>
5354
#include <QInputDialog>
@@ -2764,11 +2765,29 @@ void MainWindow::setupChatHistory()
27642765
{
27652766
m_chathistory.clear();
27662767

2767-
//ui.chatTab->layout()->replaceWidget()
2768+
bool listview = ttSettings->value(SETTINGS_DISPLAY_CHAT_HISTORY_LISTVIEW, SETTINGS_DISPLAY_CHAT_HISTORY_LISTVIEW_DEFAULT).toBool();
2769+
if (listview)
2770+
{
2771+
auto chat = new ChatTextList(ui.chatTab);
2772+
delete ui.chatTab->layout()->replaceWidget(ui.chatEdit, chat);
2773+
m_chathistory[TAB_CHAT] = chat;
2774+
2775+
auto video = new ChatTextList(ui.videoTab);
2776+
delete ui.videoTab->layout()->replaceWidget(ui.videochatEdit, video);
2777+
m_chathistory[TAB_VIDEO] = video;
27682778

2769-
m_chathistory[TAB_CHAT] = ui.chatEdit;
2770-
m_chathistory[TAB_VIDEO] = ui.videochatEdit;
2771-
m_chathistory[TAB_DESKTOP] = ui.desktopchatEdit;
2779+
auto desktop = new ChatTextList(ui.desktopTab);
2780+
delete ui.desktopTab->layout()->replaceWidget(ui.desktopchatEdit, desktop);
2781+
m_chathistory[TAB_DESKTOP] = desktop;
2782+
2783+
ui.chatEdit = ui.videochatEdit = ui.desktopchatEdit = nullptr;
2784+
}
2785+
else
2786+
{
2787+
m_chathistory[TAB_CHAT] = ui.chatEdit;
2788+
m_chathistory[TAB_VIDEO] = ui.videochatEdit;
2789+
m_chathistory[TAB_DESKTOP] = ui.desktopchatEdit;
2790+
}
27722791
}
27732792

27742793
void MainWindow::updateTabPages()

Client/qtTeamTalk/preferences.ui

+12-5
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,13 @@
427427
</property>
428428
</widget>
429429
</item>
430+
<item>
431+
<widget class="QCheckBox" name="chatlistviewChkBox">
432+
<property name="text">
433+
<string>Show chat history as list view instead of text edit</string>
434+
</property>
435+
</widget>
436+
</item>
430437
<item>
431438
<widget class="QCheckBox" name="ServnameChkBox">
432439
<property name="text">
@@ -2257,17 +2264,17 @@
22572264
</layout>
22582265
</widget>
22592266
<customwidgets>
2260-
<customwidget>
2261-
<class>MyTableView</class>
2262-
<extends>QTableView</extends>
2263-
<header>mytableview.h</header>
2264-
</customwidget>
22652267
<customwidget>
22662268
<class>MyTabWidget</class>
22672269
<extends>QTabWidget</extends>
22682270
<header>mytabwidget.h</header>
22692271
<container>1</container>
22702272
</customwidget>
2273+
<customwidget>
2274+
<class>MyTableView</class>
2275+
<extends>QTableView</extends>
2276+
<header>mytableview.h</header>
2277+
</customwidget>
22712278
</customwidgets>
22722279
<resources>
22732280
<include location="resources.qrc"/>

Client/qtTeamTalk/preferencesdlg.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,8 @@ void PreferencesDlg::initDisplayTab()
461461
ui.voiceActLevelChkBox->setChecked(ttSettings->value(SETTINGS_DISPLAY_VOICE_ACT_SLIDER,
462462
SETTINGS_DISPLAY_VOICE_ACT_SLIDER_DEFAULT).toBool());
463463
ui.msgpopupChkBox->setChecked(ttSettings->value(SETTINGS_DISPLAY_MESSAGEPOPUP, true).toBool());
464+
ui.chatlistviewChkBox->setChecked(ttSettings->value(SETTINGS_DISPLAY_CHAT_HISTORY_LISTVIEW,
465+
SETTINGS_DISPLAY_CHAT_HISTORY_LISTVIEW_DEFAULT).toBool());
464466
ui.videodlgChkBox->setChecked(ttSettings->value(SETTINGS_DISPLAY_VIDEOPOPUP, false).toBool());
465467
ui.vidtextChkBox->setChecked(ttSettings->value(SETTINGS_DISPLAY_VIDEOTEXT_SHOW, false).toBool());
466468
ui.desktopdlgChkBox->setChecked(ttSettings->value(SETTINGS_DISPLAY_DESKTOPPOPUP, false).toBool());
@@ -787,6 +789,12 @@ void PreferencesDlg::slotSaveChanges()
787789
ttSettings->setValue(SETTINGS_DISPLAY_MOTD_DLG, ui.dlgMOTDChkBox->isChecked());
788790
ttSettings->setValue(SETTINGS_DISPLAY_CHANNEL_TOPIC, ui.chanTopicChkBox->isChecked());
789791
ttSettings->setValue(SETTINGS_DISPLAY_START_SERVERLIST, ui.startServerListChkBox->isChecked());
792+
bool modlistview = ttSettings->value(SETTINGS_DISPLAY_CHAT_HISTORY_LISTVIEW, SETTINGS_DISPLAY_CHAT_HISTORY_LISTVIEW_DEFAULT).toBool() != ui.chatlistviewChkBox->isChecked();
793+
ttSettings->setValue(SETTINGS_DISPLAY_CHAT_HISTORY_LISTVIEW, ui.chatlistviewChkBox->isChecked());
794+
if (modlistview)
795+
QMessageBox::critical(this, tr("Chat History"),
796+
tr("Please restart application to change to chat history control"));
797+
790798
}
791799
if(m_modtab.find(CONNECTION_TAB) != m_modtab.end())
792800
{

Client/qtTeamTalk/settings.h

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
#define SETTINGS_DISPLAY_VU_METER_UPDATES_DEFAULT true
7979
#define SETTINGS_DISPLAY_VOICE_ACT_SLIDER "display/voice-act-slider"
8080
#define SETTINGS_DISPLAY_VOICE_ACT_SLIDER_DEFAULT true
81+
#define SETTINGS_DISPLAY_CHAT_HISTORY_LISTVIEW "display/chat-history-as-listview"
82+
#define SETTINGS_DISPLAY_CHAT_HISTORY_LISTVIEW_DEFAULT false
8183
#define SETTINGS_DISPLAY_USERSCOUNT "display/userscount"
8284
#define SETTINGS_DISPLAY_USERSCOUNT_DEFAULT true
8385
#define SETTINGS_DISPLAY_SHOWUSERNAME "display/showusername"

Client/qtTeamTalk/textmessagedlg.cpp

+21-7
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "utilsound.h"
2222
#include "utiltts.h"
2323
#include "utilui.h"
24+
#include "chattextlist.h"
2425

2526
#include <QDebug>
2627
#include <QMessageBox>
@@ -57,6 +58,22 @@ TextMessageDlg::TextMessageDlg(const User& user, const textmessages_t& msgs,
5758
void TextMessageDlg::init(const User& user)
5859
{
5960
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+
6077
setWindowIcon(QIcon(APPICON));
6178
restoreGeometry(ttSettings->value(SETTINGS_DISPLAY_TEXTMSGWINDOWPOS).toByteArray());
6279
ui.splitter->restoreState(ttSettings->value(SETTINGS_DISPLAY_TEXTMSGWINDOWPOS_SPLITTER).toByteArray());
@@ -67,9 +84,6 @@ void TextMessageDlg::init(const User& user)
6784
connect(ui.newmsgTextEdit, &QPlainTextEdit::textChanged, this, &TextMessageDlg::slotTextChanged);
6885
connect(ui.newmsgTextEdit, &SendTextEdit::sendTextMessage,
6986
this, &TextMessageDlg::slotSendMsg);
70-
connect(ui.historyTextEdit, &ChatTextEdit::clearHistory, [&]() {
71-
emit(clearUserTextMessages(m_userid));
72-
});
7387
slotUpdateUser(user);
7488
slotTextChanged();
7589

@@ -190,7 +204,7 @@ void TextMessageDlg::newMsg(const MyTextMessage& msg, bool store)
190204
{
191205
case MSGTYPE_USER :
192206
{
193-
QString line = ui.historyTextEdit->addTextMessage(msg);
207+
QString line = m_history->addTextMessage(msg);
194208
ui.newmsgGroupBox->setTitle(tr("New message"));
195209

196210
QString folder = ttSettings->value(SETTINGS_MEDIASTORAGE_USERLOGFOLDER).toString();
@@ -249,11 +263,11 @@ void TextMessageDlg::keyPressEvent(QKeyEvent* e)
249263
if (e->key() == Qt::Key_F6)
250264
{
251265
if (ui.newmsgTextEdit->hasFocus())
252-
ui.historyTextEdit->setFocus();
253-
else if (ui.historyTextEdit->hasFocus())
266+
m_history->setFocus();
267+
else if (m_history->hasFocus())
254268
ui.newmsgTextEdit->setFocus();
255269
}
256-
if (ui.historyTextEdit->hasFocus())
270+
if (m_history->hasFocus())
257271
{
258272
QString key = e->text();
259273
if (!key.isEmpty() && key.size() == 1)

Client/qtTeamTalk/textmessagedlg.h

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class TextMessageDlg : public QDialog
5252
void init(const User& user);
5353

5454
Ui::TextMessageDlg ui;
55+
ChatTextHistory* m_history;
5556
int m_userid;
5657
void newMsg(const MyTextMessage& msg, bool store);
5758
bool m_textchanged;

0 commit comments

Comments
 (0)