-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
Showing
13 changed files
with
532 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.