Skip to content

Commit

Permalink
Customizable TTS messages (#2282)
Browse files Browse the repository at this point in the history
* Customizable TTS messages

* Use if instead of switch

* Use correct settings key

* Set OK button as default button

* Display current message in extra column

@CoBC change ttseventsmodel.cpp:257

* Return current message on column_message

* Fix build on Qt5

* Improve variables description

* Add customization for joined/left channel events

* Add for messages and question mode events

* Add for subscription changes

* Optional event title for custom dialog label

* Add for classroom events

* Add for file events

* Fix build on Qt5

* Use correct setting key for user logged out event

* Specify extra title for typing event

* Fix state in accessible text role

* Add missing initializers for 'eventName'

* Remove customizable postfix

* Ability to restore default value

---------

Co-authored-by: Bjørn Damstedt Rasmussen <contact@bearware.dk>
  • Loading branch information
CoBC and bear101 committed May 18, 2024
1 parent 5ca5e65 commit f79a760
Show file tree
Hide file tree
Showing 13 changed files with 532 additions and 187 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Default Qt Client
- "Check for Update" in "Help" menu
- Ability to join Last Joined Channel for each server individually
- Use Qt checkable flag in user rights list to allow screenreader to see if an item is checked
- Ability to customize some TTS messages
- Remove option "Announce server name" from TTS options, use customizable messages instead
Android Client
-
iOS Client
Expand Down
4 changes: 2 additions & 2 deletions Client/qtTeamTalk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ if (Qt5_FOUND OR Qt6_FOUND)
utilsound.h utilvideo.h utiltts.h utilui.h utilhotkey.h
serverlogeventsmodel.h mytreeview.h textmessagecontainer.h
useraccountsmodel.h encryptionsetupdlg.h utiltt.h utilxml.h
utilos.h serverdlg.h moveusersdlg.h
utilos.h serverdlg.h moveusersdlg.h custominputdialog.h

main.cpp mainwindow.cpp preferencesdlg.cpp uservideowidget.cpp
channelstree.cpp channeldlg.cpp userinfodlg.cpp
Expand All @@ -109,7 +109,7 @@ if (Qt5_FOUND OR Qt6_FOUND)
utilsound.cpp utilvideo.cpp utiltts.cpp utilui.cpp utilhotkey.cpp
serverlogeventsmodel.cpp mytreeview.cpp textmessagecontainer.cpp
useraccountsmodel.cpp encryptionsetupdlg.cpp utiltt.cpp utilxml.cpp
utilos.cpp serverdlg.cpp moveusersdlg.cpp
utilos.cpp serverdlg.cpp moveusersdlg.cpp custominputdialog.cpp

mainwindow.ui channel.ui preferences.ui
serverlist.ui userinfo.ui bannedusers.ui useraccounts.ui
Expand Down
94 changes: 94 additions & 0 deletions Client/qtTeamTalk/custominputdialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* Copyright (C) 2023, Bjørn D. Rasmussen, BearWare.dk
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include "custominputdialog.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QCursor>

CustomInputDialog::CustomInputDialog(const QString& title, const QString& labelText, const QString& initialText, const QString& defaultValue, const QHash<QString, QString>& variables, QWidget* parent)
: QDialog(parent)
, m_defaultValue(defaultValue)
{
setWindowTitle(title);
QVBoxLayout* mainLayout = new QVBoxLayout(this);

QLabel* label = new QLabel(labelText, this);
m_lineEdit = new QLineEdit(initialText, this);

label->setBuddy(m_lineEdit);
mainLayout->addWidget(label);
mainLayout->addWidget(m_lineEdit);

m_variableButton = new QPushButton(tr("Variables..."), this);
mainLayout->addWidget(m_variableButton);

m_variableMenu = new QMenu(this);
for (auto it = variables.constBegin(); it != variables.constEnd(); ++it)
{
QAction* action = m_variableMenu->addAction(it.value());
action->setData(it.key());
connect(action, &QAction::triggered, this, &CustomInputDialog::insertVariable);
}

QPushButton* resetButton = new QPushButton(tr("Default Value"), this);
mainLayout->addWidget(resetButton);

QHBoxLayout* buttonLayout = new QHBoxLayout;
QPushButton* okButton = new QPushButton(tr("OK"), this);
okButton->setDefault(true);
QPushButton* cancelButton = new QPushButton(tr("Cancel"), this);

buttonLayout->addStretch();
buttonLayout->addWidget(okButton);
buttonLayout->addWidget(cancelButton);

mainLayout->addLayout(buttonLayout);

connect(m_variableButton, &QPushButton::clicked, this, &CustomInputDialog::showVariableMenu);
connect(resetButton, &QPushButton::clicked, this, &CustomInputDialog::resetDefaultValue);
connect(okButton, &QPushButton::clicked, this, &QDialog::accept);
connect(cancelButton, &QPushButton::clicked, this, &QDialog::reject);
}

QString CustomInputDialog::getText() const
{
return m_lineEdit->text();
}

void CustomInputDialog::showVariableMenu()
{
m_variableMenu->exec(QCursor::pos());
}

void CustomInputDialog::insertVariable()
{
QAction* action = qobject_cast<QAction*>(sender());
if (action)
{
QString variable = action->data().toString();
int cursorPos = m_lineEdit->cursorPosition();
m_lineEdit->insert(variable);
m_lineEdit->setCursorPosition(cursorPos + variable.length());
}
}

void CustomInputDialog::resetDefaultValue()
{
m_lineEdit->clear();
m_lineEdit->setText(m_defaultValue);
}
49 changes: 49 additions & 0 deletions Client/qtTeamTalk/custominputdialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2023, Bjørn D. Rasmussen, BearWare.dk
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#ifndef CUSTOMINPUTDIALOG_H
#define CUSTOMINPUTDIALOG_H

#include <QDialog>
#include <QLineEdit>
#include <QLabel>
#include <QPushButton>
#include <QMenu>
#include <QHash>

class CustomInputDialog : public QDialog
{
Q_OBJECT

public:
CustomInputDialog(const QString& title, const QString& labelText, const QString& initialText, const QString& defaultValue, const QHash<QString, QString>& variables, QWidget* parent = nullptr);

QString getText() const;

private slots:
void showVariableMenu();
void insertVariable();
void resetDefaultValue();

private:
QLineEdit* m_lineEdit;
QPushButton* m_variableButton;
QMenu* m_variableMenu;
QString m_defaultValue;
};

#endif // CUSTOMINPUTDIALOG_H

0 comments on commit f79a760

Please sign in to comment.