Commit 434a8a65 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Minor optimization. Remove unused code

parent 79ec0501
......@@ -71,7 +71,7 @@ PhraseList::PhraseList(QWidget *parent, const QString &name) : QWidget(parent)
configureCompletionCombo(completion->wordLists());
rowLayout->addWidget(dictionaryCombo);
lineEdit = new KLineEdit(QLatin1String(""), this);
lineEdit = new KLineEdit(this);
lineEdit->setFocusPolicy(Qt::StrongFocus);
lineEdit->setFrame(true);
lineEdit->setEchoMode(QLineEdit::Normal);
......@@ -88,16 +88,12 @@ PhraseList::PhraseList(QWidget *parent, const QString &name) : QWidget(parent)
speakButton->setWhatsThis(i18n("Speaks the currently active sentence(s). If there is some text in the edit field it is spoken. Otherwise the selected sentences in the history (if any) are spoken."));
rowLayout->addWidget(speakButton);
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
connect(dictionaryCombo, QOverload<const QString &>::of(&KComboBox::activated), completion, &WordCompletion::setWordList);
#else
connect(dictionaryCombo, QOverload<const QString &>::of(&KComboBox::textActivated), completion, &WordCompletion::setWordList);
#endif
connect(completion, &WordCompletion::wordListsChanged, this, &PhraseList::configureCompletionCombo);
connect(m_listView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &PhraseList::selectionChanged);
connect(m_listView, &QWidget::customContextMenuRequested, this, &PhraseList::contextMenuRequested);
connect(lineEdit, &KLineEdit::returnPressed, this, &PhraseList::lineEntered);
connect(lineEdit, &KLineEdit::returnKeyPressed, this, &PhraseList::lineEntered);
connect(lineEdit, &QLineEdit::textChanged, this, &PhraseList::textChanged);
connect(speakButton, &QAbstractButton::clicked, this, &PhraseList::speak);
}
......
......@@ -91,7 +91,7 @@ void Speech::speak(QString command, bool stdIn, const QString &text, const QStri
// 4. start the process
if (stdIn) {
m_process.start(command);
if (encText.size() > 0)
if (!encText.isEmpty())
m_process.write(encText.constData(), encText.size());
else
m_process.close();
......
......@@ -32,7 +32,7 @@ TextToSpeechConfigurationWidget::TextToSpeechConfigurationWidget(QWidget *parent
{
setObjectName(name);
setupUi(this);
ttsSystem = new TextToSpeechSystem();
ttsSystem = new TextToSpeechSystem(this);
buildCodecList();
}
......
......@@ -49,7 +49,7 @@ public:
private:
void buildCodecList();
TextToSpeechSystem *ttsSystem;
TextToSpeechSystem *ttsSystem = nullptr;
};
#endif // TEXTTOSPEECHCONFIGURATIONWIDGET_H
......@@ -28,7 +28,8 @@
#include "speech.h"
TextToSpeechSystem::TextToSpeechSystem()
TextToSpeechSystem::TextToSpeechSystem(QObject *parent)
: QObject(parent)
{
stdIn = true;
useQtSpeech = true;
......
......@@ -34,8 +34,8 @@ class TextToSpeechSystem : public QObject
Q_OBJECT
friend class TextToSpeechConfigurationWidget;
public:
TextToSpeechSystem();
~TextToSpeechSystem();
explicit TextToSpeechSystem(QObject *parent = nullptr);
~TextToSpeechSystem() override;
void readOptions(const QString &langGroup);
void saveOptions(const QString &langGroup);
......
......@@ -54,7 +54,7 @@ void CreationSourceWidget::emptyToggled(bool checked)
setFinalPage(checked);
}
DictionaryCreationWizard::DictionaryCreationWizard(QWidget *parent, const char *name,
DictionaryCreationWizard::DictionaryCreationWizard(QWidget *parent,
const QStringList &dictionaryNames, const QStringList &dictionaryFiles,
const QStringList &dictionaryLanguages)
: QWizard(parent)
......
......@@ -98,7 +98,7 @@ class DictionaryCreationWizard : public QWizard
{
Q_OBJECT
public:
DictionaryCreationWizard(QWidget *parent, const char *name,
DictionaryCreationWizard(QWidget *parent,
const QStringList &dictionaryNames,
const QStringList &dictionaryFiles,
const QStringList &dictionaryLanguages);
......
......@@ -113,7 +113,6 @@ void WordCompletionWidget::save()
if ((*it).startsWith(QLatin1String("Dictionary ")))
KSharedConfig::openConfig()->deleteGroup(*it);
int row = 0;
for (int row = 0; row < model->rowCount(); ++row) {
const QStandardItem *nameItem = model->item(row, 0);
const QStandardItem *languageItem = model->item(row, 1);
......@@ -147,7 +146,7 @@ void WordCompletionWidget::addDictionary()
dictionaryFiles += nameItem->data().toString();
dictionaryLanguages += languageItem->text();
}
DictionaryCreationWizard *wizard = new DictionaryCreationWizard(this, "Dictionary creation wizard", dictionaryNames, dictionaryFiles, dictionaryLanguages);
DictionaryCreationWizard *wizard = new DictionaryCreationWizard(this, dictionaryNames, dictionaryFiles, dictionaryLanguages);
if (wizard->exec() == QDialog::Accepted) {
QString filename = wizard->createDictionary();
newDictionaryFiles += filename;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment