generic: drop text-to-speech support

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-12-18 16:09:43 +02:00
parent 59534f0f32
commit 2ce6520523
15 changed files with 2 additions and 571 deletions

View file

@ -18,8 +18,6 @@ add_subdirectory(kate-ctags)
add_subdirectory(katebuild-plugin)
add_subdirectory(search)
add_subdirectory(kttsd)
add_subdirectory(openheader)
add_subdirectory(tabify)

View file

@ -1,25 +0,0 @@
kde4_add_plugin(kate_kttsd katekttsd.cpp)
target_link_libraries(kate_kttsd
${KDE4_KDECORE_LIBS}
${KDE4_KTEXTEDITOR_LIBS}
${KDE4_KPARTS_LIBS}
${KDE4_KSPEECH_LIBS}
kateinterfaces
)
install(
TARGETS kate_kttsd
DESTINATION ${KDE4_PLUGIN_INSTALL_DIR}
)
########### install files ###############
install(
FILES kate_kttsd.desktop
DESTINATION ${KDE4_SERVICES_INSTALL_DIR}
)
install(
FILES ui.rc
DESTINATION ${KDE4_DATA_INSTALL_DIR}/kate/plugins/kate_kttsd
)

View file

@ -1,3 +0,0 @@
#! /bin/sh
$EXTRACTRC *.rc >> rc.cpp
$XGETTEXT *.cpp -o $podir/kate_kttsd.pot

View file

@ -1,65 +0,0 @@
[Desktop Entry]
Type=Service
ServiceTypes=Kate/Plugin
X-KDE-Library=kate_kttsd
X-Kate-Version=3.0
Icon=preferences-desktop-text-to-speech
Name=Text-to-Speech
Name[bg]=Четене на текст
Name[x-test]=xxText-to-Speechxx
Comment=Adds a menu entry for speaking the text
Comment[ar]=يضيف مُدخلة قائمة لنطق النصّ
Comment[ast]=Amestar una entrada al menú pa lleer el testu
Comment[bg]=Добавяне на запис в менюто за изговаряне на текст
Comment[bs]=Dodaje stavku menija za izgovaranje teksta
Comment[ca]=Afegeix una entrada al menú per parlar el text
Comment[ca@valencia]=Afig una entrada al menú per parlar el text
Comment[cs]=Přidá položku v nabídce pro čtení textu
Comment[da]=Tilføjer en menu til oplæsning af tekst
Comment[de]=Fügt einen Menüeintrag zum Vorlesen des Textes hinzu
Comment[el]=Προσθέτει μία καταχώρηση στο μενού για τη φωνητική απόδοση κειμένου
Comment[en_GB]=Adds a menu entry for speaking the text
Comment[es]=Añade una entrada de menú para leer el texto
Comment[et]=Lisab menüükirje teksti kõnelemiseks
Comment[eu]=Menuko sarrera gehitzen du testua hitzegiteko
Comment[fi]=Lisää tekstin puhumismahdollisuuden valikkoon
Comment[fr]=Ajoute une ligne de menu pour énoncer le texte
Comment[ga]=Cuir iontráil sa roghchlár chun an téacs a léamh
Comment[gl]=Engade unha entrada no menú para falar o texto
Comment[he]=מוסיף תפריט להקראת הטקסט
Comment[hu]=Menübejegyzés szövegfelolvasáshoz
Comment[ia]=Adde un entrata de menu pro pronunciar le texto
Comment[it]=Aggiunge una voce del menu per pronunciare il testo
Comment[ja]=
Comment[kk]=Мәзірге мәтінді дауыстау жолын қосу
Comment[km]=
Comment[ko]=
Comment[lt]=Prideda meniu elementą teksto skaitymui
Comment[lv]=Pievieno izvēlnes komandu, kas izrunā tekstu
Comment[mr]= ि
Comment[nb]=Legger til en menyoppføring for å si teksten høyt
Comment[nds]=Föögt en Menüindrag för't Vörlesen vun Text to
Comment[nl]=Voegt een menuoptie toe voor het uitspreken van de tekst
Comment[nn]=Legg til ei menyoppføring for opplesing av tekst
Comment[pl]=Dodaje element menu, który powoduje wypowiedzenie tekstu
Comment[pt]=Adiciona um item de menu para sintetizar o texto
Comment[pt_BR]=Adiciona um item no menu para ler o texto
Comment[ro]=Adaugă un element de meniu pentru vorbirea textului
Comment[ru]=Добавляет меню синтеза речи
Comment[si]=
Comment[sk]=Pridá položku ponuky pre hovorenie textu
Comment[sl]=V meni doda vnos za izgovorjavo besedila
Comment[sr]=Додаје ставку менија за изговарање текста
Comment[sr@ijekavian]=Додаје ставку менија за изговарање текста
Comment[sr@ijekavianlatin]=Dodaje stavku menija za izgovaranje teksta
Comment[sr@latin]=Dodaje stavku menija za izgovaranje teksta
Comment[sv]=Lägger till ett menyalternativ för att läsa upp texten
Comment[tg]=Вориди менюро барои талаффузи матн илова мекунад
Comment[tr]=Metni okumak için bir menü girdisi oluşturur
Comment[ug]=تېكىست ئوقۇش ئۈچۈن تىزىملىككە بىر تۈر قوشىدۇ
Comment[uk]=Додає елемент меню для декламування тексту
Comment[wa]=Radjoute ene intrêye el dressêye po lére li tecse
Comment[x-test]=xxAdds a menu entry for speaking the textxx
Comment[zh_CN]=
Comment[zh_TW]=
author=Olaf Jan Schmidt, ojschmidt@kde.org

View file

@ -1,101 +0,0 @@
/***************************************************************************
A KTextEditor (Kate Part) plugin for speaking text.
Copyright:
(C) 2003-2004 by Olaf Schmidt <ojschmidt@kde.org>
(C) 2005 by Gary Cramblitt <garycramblitt@comcast.net>
(C) 2009 by Laurent Montel <montel@kde.org>
Original Author: Olaf Schmidt <ojschmidt@kde.org>
***************************************************************************/
/***************************************************************************
* *
* 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 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
// KateKttsdPlugin includes.
#include "katekttsd.h"
#include "moc_katekttsd.cpp"
#include <ktexteditor/document.h>
// Qt includes.
#include <QtCore/QTimer>
// KDE includes.
#include <kmessagebox.h>
#include <kaction.h>
#include <klocale.h>
#include <kstandarddirs.h>
#include <ktoolinvocation.h>
#include <KActionCollection>
#include <KAboutData>
#include <KSpeech>
#include <kate/mainwindow.h>
K_PLUGIN_FACTORY(KateKttsdFactory, registerPlugin<KateKttsdPlugin>();)
K_EXPORT_PLUGIN(KateKttsdFactory(KAboutData("kate_kttsd","kate_kttsd",ki18n("Text-to-Speech Plugin"), "0.1", ki18n("Text-to-Speech Plugin"), KAboutData::License_LGPL_V2)) )
KateKttsdPlugin::KateKttsdPlugin(QObject* parent, const QList<QVariant>&)
: Kate::Plugin ((Kate::Application*)parent)
{
}
Kate::PluginView *KateKttsdPlugin::createView (Kate::MainWindow *mainWindow)
{
return new KateKttsdPluginView(mainWindow);
}
KateKttsdPluginView::KateKttsdPluginView( Kate::MainWindow *mw )
: Kate::PluginView (mw),
Kate::XMLGUIClient(KateKttsdFactory::componentData()),
m_kspeech(nullptr)
{
KGlobal::locale()->insertCatalog("kttsd");
KAction *a = actionCollection()->addAction("tools_kttsd");
a->setText(i18n("Speak Text"));
a->setIcon(KIcon("preferences-desktop-text-to-speech"));
connect( a, SIGNAL(triggered(bool)), this, SLOT(slotReadOut()) );
mainWindow()->guiFactory()->addClient(this);
}
KateKttsdPluginView::~KateKttsdPluginView()
{
mainWindow()->guiFactory()->removeClient( this );
}
void KateKttsdPluginView::slotReadOut()
{
KTextEditor::View *v = mainWindow()->activeView();
if ( !v )
return;
KTextEditor::Document *doc = v->document();
QString text;
if ( v->selection() )
{
text = v->selectionText();
}
else
text = doc->text();
if ( text.isEmpty() )
return;
if (!KSpeech::isSupported())
{
KMessageBox::error(0, i18n( "Text-to-Speech not supported") );
return;
}
if (!m_kspeech) {
m_kspeech = new KSpeech(this);
m_kspeech->setSpeechID(QString::fromLatin1("kate"));
}
m_kspeech->say(text);
}

View file

@ -1,54 +0,0 @@
/***************************************************************************
A KTextEditor (Kate Part) plugin for speaking text.
Copyright:
(C) 2003-2004 by Olaf Schmidt <ojschmidt@kde.org>
(C) 2005 by Gary Cramblitt <garycramblitt@comcast.net>
Original Author: Olaf Schmidt <ojschmidt@kde.org>
***************************************************************************/
/***************************************************************************
* *
* 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 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef _KATEKTTSD_H_
#define _KATEKTTSD_H_
#include <ktexteditor/plugin.h>
#include <ktexteditor/view.h>
#include <kate/plugin.h>
#include <kspeech.h>
#include <QtCore/QObject>
class KateKttsdPlugin : public Kate::Plugin
{
Q_OBJECT
public:
explicit KateKttsdPlugin( QObject* parent = 0, const QList<QVariant>& = QList<QVariant>() );
virtual ~KateKttsdPlugin() {};
Kate::PluginView *createView(Kate::MainWindow *mainWindow);
};
class KateKttsdPluginView : public Kate::PluginView, public Kate::XMLGUIClient
{
Q_OBJECT
public:
explicit KateKttsdPluginView(Kate::MainWindow *mw );
~KateKttsdPluginView();
public slots:
void slotReadOut();
private:
KSpeech *m_kspeech;
};
#endif // _KATEKTTSD_H_

View file

@ -1,11 +0,0 @@
<!DOCTYPE kpartgui>
<gui name="kate_kttsd" library="kate_kttsd" version="3">
<MenuBar>
<Menu name="tools"><text>&amp;Tools</text>
<Action name="tools_kttsd" />
</Menu>
</MenuBar>
<ToolBar name="mainToolBar"><text>Main Toolbar</text>
<Action name="tools_kttsd" />
</ToolBar>
</gui>

View file

@ -12,7 +12,6 @@ set(knotify_SRCS
notifybylogfile.cpp
notifybytaskbar.cpp
notifybyexecute.cpp
notifybyktts.cpp
imageconverter.cpp
ksolidnotify.cpp
knotifyplugin.cpp
@ -24,7 +23,6 @@ add_executable(knotify4 ${knotify_SRCS})
target_link_libraries(knotify4
${KDE4_KDEUI_LIBS}
${KDE4_SOLID_LIBS}
${KDE4_KSPEECH_LIBS}
${KDE4_KMEDIAPLAYER_LIBS}
)

View file

@ -37,7 +37,6 @@
#include "notifybyexecute.h"
#include "notifybylogfile.h"
#include "notifybytaskbar.h"
#include "notifybyktts.h"
KNotify::KNotify( QObject *parent )
: QObject( parent ),
@ -66,7 +65,6 @@ void KNotify::loadConfig()
addPlugin(new NotifyByExecute(this));
addPlugin(new NotifyByLogfile(this));
addPlugin(new NotifyByTaskbar(this));
addPlugin(new NotifyByKTTS(this));
}
void KNotify::addPlugin( KNotifyPlugin * p )

View file

@ -1,76 +0,0 @@
/*
Copyright (C) 2007 by Olivier Goffart <ogoffart at kde.org>
Copyright (C) 2009 by Laurent Montel <montel@kde.org>
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 2, 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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "notifybyktts.h"
#include <QtDBus/QtDBus>
#include <QHash>
#include <ktoolinvocation.h>
#include <kmessagebox.h>
#include <kmacroexpander.h>
#include <klocale.h>
#include <knotifyconfig.h>
NotifyByKTTS::NotifyByKTTS(QObject *parent)
: KNotifyPlugin(parent),
m_kspeech(0)
{
}
NotifyByKTTS::~NotifyByKTTS()
{
}
void NotifyByKTTS::notify( int id, KNotifyConfig * config )
{
if ( !KSpeech::isSupported() )
return;
if (!m_kspeech) {
m_kspeech = new KSpeech(this);
}
QString say = config->readEntry( "KTTS" );
QString appId = config->appname;
if (appId.isEmpty()) {
appId = QString::fromLatin1("KNotify");
}
if (!say.isEmpty()) {
QHash<QChar,QString> subst;
subst.insert( 'e', config->eventid );
subst.insert( 'a', config->appname );
subst.insert( 's', config->text );
subst.insert( 'w', QString::number( (quintptr)config->winId ));
subst.insert( 'i', QString::number( id ));
subst.insert( 'm', config->text );
say = KMacroExpander::expandMacrosShellQuote( say, subst );
}
if ( say.isEmpty() )
say = config->text; // fallback
m_kspeech->setSpeechID(appId);
m_kspeech->say(say);
finished(id);
}
#include "moc_notifybyktts.cpp"

View file

@ -1,44 +0,0 @@
/*
Copyright (C) 2007 by Olivier Goffart <ogoffart at kde.org>
Copyright (C) 2009 by Laurent Montel <montel@kde.org>
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 2, 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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef NOTIFYBYKTTS_H
#define NOTIFYBYKTTS_H
#include "knotifyplugin.h"
#include <KSpeech>
class NotifyByKTTS : public KNotifyPlugin
{
Q_OBJECT
public:
NotifyByKTTS(QObject *parent=0l);
virtual ~NotifyByKTTS();
virtual QString optionName() { return "KTTS"; }
virtual void notify(int id , KNotifyConfig *config);
private:
KSpeech *m_kspeech;
};
#endif

View file

@ -4,7 +4,6 @@ set(plasmaclock_LIB_SRCS
calendartable.cpp
wheelytoolbutton.cpp
timezonesConfig.ui
generalConfig.ui
calendarConfig.ui
)
@ -14,7 +13,6 @@ target_link_libraries(plasmaclock
${KDE4_PLASMA_LIBS}
${KDE4_KDEUI_LIBS}
${KDE4_KIO_LIBS}
${KDE4_KSPEECH_LIBS}
)
set_target_properties(plasmaclock PROPERTIES

View file

@ -51,7 +51,6 @@
#include <KTimeZone>
#include <KToolInvocation>
#include <KMessageBox>
#include <KSpeech>
#include <Plasma/Containment>
#include <Plasma/Corona>
@ -63,7 +62,6 @@
#include "calendar.h"
#include "ui_timezonesConfig.h"
#include "ui_generalConfig.h"
class ClockApplet::Private
{
@ -75,13 +73,11 @@ public:
adjustSystemTimeAction(nullptr),
label(nullptr),
calendarWidget(nullptr),
forceTzDisplay(false),
kspeech(nullptr)
forceTzDisplay(false)
{}
ClockApplet *q;
Ui::timezonesConfig timezonesUi;
Ui::generalConfig generalUi;
QString timezone;
QString defaultTimezone;
QPoint clicked;
@ -91,11 +87,8 @@ public:
QString prettyTimezone;
Plasma::Label *label;
Plasma::Calendar *calendarWidget;
int announceInterval;
QTime lastTimeSeen;
bool forceTzDisplay : 1;
bool kttsAvailable;
KSpeech *kspeech;
bool forceTzDisplay;
QDate addTzToTipText(QString &subText, const Plasma::DataEngine::Data &data, const QDate &prevDate, bool highlight)
{
@ -179,64 +172,6 @@ ClockApplet::~ClockApplet()
delete d;
}
void ClockApplet::speakTime(const QTime &time)
{
if (!d->announceInterval) {
return;
}
if ((time.minute() % d->announceInterval) == 0) {
QString text;
if (time.minute() == 0) {
if (KGlobal::locale()->use12Clock()) {
if (time.hour() < 12) {
text = i18ncp("Text sent to the text to speech service "
"when minutes==0 and it is AM",
"It is 1 o clock a m",
"It is %1 o clock a m",
time.hour());
} else {
text = i18ncp("Text sent to the text to speech service "
"when minutes==0 and it is PM",
"It is 1 o clock p m",
"It is %1 o clock p m",
time.hour()-12);
}
} else {
text = i18ncp("Text sent to the text to speech service "
"when minutes==0 and it is the 24 hour clock",
"It is 1 o clock",
"It is %1 o clock",
time.hour());
}
} else {
if (KGlobal::locale()->use12Clock()) {
if (time.hour() < 12) {
text = i18nc("Text sent to the text to speech service for AM",
"It is %1:%2 a m",
time.hour(),
time.minute());
} else {
text = i18nc("Text sent to the text to speech service for PM",
"It is %1:%2 p m",
time.hour()-12,
time.minute());
}
} else {
text = i18nc("Text sent to the text to speech service for the 24 hour clock",
"It is %1:%2",
time.hour(),
time.minute());
}
}
if (!d->kspeech) {
d->kspeech = new KSpeech(this);
d->kspeech->setSpeechID(QString::fromLatin1("plasmaclock"));
}
d->kspeech->say(text);
}
}
void ClockApplet::toolTipAboutToShow()
{
updateTipContent();
@ -332,11 +267,7 @@ void ClockApplet::updateClockApplet(const Plasma::DataEngine::Data &data)
}
}
const QTime t = d->lastTimeSeen;
d->lastTimeSeen = data["Time"].toTime();
if (d->lastTimeSeen.minute() != t.minute() || d->lastTimeSeen.hour() != t.hour()) {
speakTime(d->lastTimeSeen);
}
}
QTime ClockApplet::lastTimeSeen() const
@ -358,32 +289,6 @@ void ClockApplet::createConfigurationInterface(KConfigDialog *parent)
{
createClockConfigurationInterface(parent);
d->kttsAvailable = KSpeech::isSupported();
if (d->kttsAvailable) {
QWidget *generalWidget = new QWidget();
d->generalUi.setupUi(generalWidget);
parent->addPage(generalWidget, i18nc("General configuration page", "General"), Applet::icon());
d->generalUi.intervalCombo->addItem(i18nc("@inmenu interval between speaking clock", "Never"), QVariant(0));
d->generalUi.intervalCombo->addItem(i18nc("@inmenu interval between speaking clock", "Every minute"), QVariant(1));
d->generalUi.intervalCombo->addItem(i18nc("@inmenu interval between speaking clock", "Every 2 minutes"), QVariant(2));
d->generalUi.intervalCombo->addItem(i18nc("@inmenu interval between speaking clock", "Every 5 minutes"), QVariant(5));
d->generalUi.intervalCombo->addItem(i18nc("@inmenu interval between speaking clock", "Every 10 minutes"), QVariant(10));
d->generalUi.intervalCombo->addItem(i18nc("@inmenu interval between speaking clock", "Every 15 minutes"), QVariant(15));
d->generalUi.intervalCombo->addItem(i18nc("@inmenu interval between speaking clock", "Every 30 minutes"), QVariant(30));
d->generalUi.intervalCombo->addItem(i18nc("@inmenu interval between speaking clock", "Every hour"), QVariant(60));
for (int i=0; i< d->generalUi.intervalCombo->count() ; i++) {
if (d->generalUi.intervalCombo->itemData(i).toInt() == d->announceInterval) {
d->generalUi.intervalCombo->setCurrentIndex(i);
break;
}
}
connect(d->generalUi.intervalCombo, SIGNAL(currentIndexChanged(int)), parent, SLOT(settingsModified()));
}
if (d->calendarWidget) {
d->calendarWidget->createConfigurationInterface(parent);
}
@ -435,7 +340,6 @@ void ClockApplet::configChanged()
d->defaultTimezone = cg.readEntry("defaultTimezone", d->timezone);
d->forceTzDisplay = d->timezone != d->defaultTimezone;
d->setPrettyTimezone();
d->announceInterval = cg.readEntry("announceInterval", 0);
clockConfigChanged();
@ -480,12 +384,6 @@ void ClockApplet::configAccepted()
d->calendarWidget->configAccepted(cg);
}
if (d->kttsAvailable) {
cg.writeEntry("announceInterval", d->generalUi.intervalCombo->itemData(d->generalUi.intervalCombo->currentIndex()));
} else {
cg.writeEntry("announceInterval", 0);
}
clockConfigAccepted();
emit configNeedsSaving();

View file

@ -86,7 +86,6 @@ class PLASMACLOCK_EXPORT ClockApplet : public Plasma::PopupApplet
void setCurrentTimezone(const QString &tz);
void configAccepted();
void updateClockDefaultsTo();
void speakTime(const QTime &);
void launchTimeControlPanel();
private Q_SLOTS:

View file

@ -1,79 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>generalConfig</class>
<widget class="QWidget" name="generalConfig">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>270</width>
<height>62</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Text to Speech</string>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>13</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Speak time:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="3">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>67</width>
<height>259</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2">
<widget class="KComboBox" name="intervalCombo"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KComboBox</class>
<extends>QComboBox</extends>
<header>kcombobox.h</header>
</customwidget>
</customwidgets>
<connections/>
</ui>