Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to display server's message of the day in a welcome dialog box #2158

Merged
merged 2 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Version 5.16, unreleased
Default Qt Client
-
- Option to show server's message of the day in a welcome dialog box
Android Client
-
iOS Client
Expand Down
20 changes: 14 additions & 6 deletions Client/qtTeamTalk/chattextedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <QSyntaxHighlighter>
#include <QTextCursor>
#include <QUrl>
#include <QMessageBox>

extern TTInstance* ttInst;
extern QSettings* ttSettings;
Expand Down Expand Up @@ -148,16 +149,23 @@ void ChatTextEdit::updateServer(const ServerProperties& srvprop)
font.setBold(true);
format.setFont(font);
cursor.setCharFormat(format);
QString line = dt + tr("Server Name: %1").arg(_Q(srvprop.szServerName));;
QString line = dt + tr("Server Name: %1").arg(_Q(srvprop.szServerName));
setTextCursor(cursor);
appendPlainText(line);
if (_Q(srvprop.szMOTD).size() > 0)
{
line = dt + tr("Message of the Day: %1").arg(_Q(srvprop.szMOTD)) + "\r\n";
format.setForeground(QBrush(Qt::darkCyan));
cursor.setCharFormat(format);
setTextCursor(cursor);
appendPlainText(line);
if (ttSettings->value(SETTINGS_DISPLAY_MOTD_DLG, SETTINGS_DISPLAY_MOTD_DLG_DEFAULT).toBool() == true)
{
QMessageBox::information(this, tr("Welcome"), QString("Welcome to %1.\r\nMessage of the day: %2").arg(_Q(srvprop.szServerName)).arg(_Q(srvprop.szMOTD)));
}
else
{
line = dt + tr("Message of the Day: %1").arg(_Q(srvprop.szMOTD)) + "\r\n";
format.setForeground(QBrush(Qt::darkCyan));
cursor.setCharFormat(format);
setTextCursor(cursor);
appendPlainText(line);
}
}

//revert bold
Expand Down
7 changes: 7 additions & 0 deletions Client/qtTeamTalk/preferences.ui
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="dlgMOTDChkBox">
<property name="text">
<string>Show dialog box with server's message of the day</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="startServerListChkBox">
<property name="text">
Expand Down
2 changes: 2 additions & 0 deletions Client/qtTeamTalk/preferencesdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ void PreferencesDlg::slotTabChange(int index)

ui.closeFileDlgChkBox->setChecked(ttSettings->value(SETTINGS_DISPLAY_CLOSE_FILEDIALOG, SETTINGS_DISPLAY_CLOSE_FILEDIALOG_DEFAULT).toBool());
ui.dlgExcludeChkBox->setChecked(ttSettings->value(SETTINGS_DISPLAY_CHANEXCLUDE_DLG, SETTINGS_DISPLAY_CHANEXCLUDE_DLG_DEFAULT).toBool());
ui.dlgMOTDChkBox->setChecked(ttSettings->value(SETTINGS_DISPLAY_MOTD_DLG, SETTINGS_DISPLAY_MOTD_DLG_DEFAULT).toBool());
ui.startServerListChkBox->setVisible(!ttSettings->value(SETTINGS_CONNECTION_AUTOCONNECT, SETTINGS_CONNECTION_AUTOCONNECT_DEFAULT).toBool());
ui.startServerListChkBox->setChecked(ttSettings->value(SETTINGS_DISPLAY_START_SERVERLIST, SETTINGS_DISPLAY_START_SERVERLIST_DEFAULT).toBool());
}
Expand Down Expand Up @@ -876,6 +877,7 @@ void PreferencesDlg::slotSaveChanges()
ttSettings->setValue(SETTINGS_DISPLAY_CHANNELSORT, getCurrentItemData(ui.channelsortComboBox, CHANNELSORT_ASCENDING));
ttSettings->setValue(SETTINGS_DISPLAY_CLOSE_FILEDIALOG, ui.closeFileDlgChkBox->isChecked());
ttSettings->setValue(SETTINGS_DISPLAY_CHANEXCLUDE_DLG, ui.dlgExcludeChkBox->isChecked());
ttSettings->setValue(SETTINGS_DISPLAY_MOTD_DLG, ui.dlgMOTDChkBox->isChecked());
ttSettings->setValue(SETTINGS_DISPLAY_START_SERVERLIST, ui.startServerListChkBox->isChecked());
}
if(m_modtab.find(CONNECTION_TAB) != m_modtab.end())
Expand Down
2 changes: 2 additions & 0 deletions Client/qtTeamTalk/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@
#define SETTINGS_DISPLAY_CLOSE_FILEDIALOG_DEFAULT false
#define SETTINGS_DISPLAY_CHANEXCLUDE_DLG "display/dlg-alert-exclude"
#define SETTINGS_DISPLAY_CHANEXCLUDE_DLG_DEFAULT false
#define SETTINGS_DISPLAY_MOTD_DLG "display/MOTD-dlg"
#define SETTINGS_DISPLAY_MOTD_DLG_DEFAULT false
#define SETTINGS_DISPLAY_START_SERVERLIST "display/serverlist-on-start"
#define SETTINGS_DISPLAY_START_SERVERLIST_DEFAULT false
#define SETTINGS_DISPLAY_CHANNELSORT "display/sort-channels"
Expand Down
Loading