diff options
Diffstat (limited to 'lib/kofficecore/KoSpeaker.cpp')
-rw-r--r-- | lib/kofficecore/KoSpeaker.cpp | 294 |
1 files changed, 147 insertions, 147 deletions
diff --git a/lib/kofficecore/KoSpeaker.cpp b/lib/kofficecore/KoSpeaker.cpp index db975623..b8c0c098 100644 --- a/lib/kofficecore/KoSpeaker.cpp +++ b/lib/kofficecore/KoSpeaker.cpp @@ -21,26 +21,26 @@ * Boston, MA 02110-1301, USA. */ -// Qt includes. -#include <qtimer.h> -#include <qcursor.h> -#include <qtooltip.h> -#include <qwhatsthis.h> -#include <qmenubar.h> -#include <qlabel.h> -#include <qbutton.h> -#include <qcombobox.h> -#include <qtabbar.h> -#include <qgroupbox.h> -#include <qlineedit.h> -#include <qtextedit.h> -#include <qlistview.h> -#include <qlistbox.h> -#include <qiconview.h> -#include <qtable.h> -#include <qgridview.h> -#include <qregexp.h> -#include <qstylesheet.h> +// TQt includes. +#include <tqtimer.h> +#include <tqcursor.h> +#include <tqtooltip.h> +#include <tqwhatsthis.h> +#include <tqmenubar.h> +#include <tqlabel.h> +#include <tqbutton.h> +#include <tqcombobox.h> +#include <tqtabbar.h> +#include <tqgroupbox.h> +#include <tqlineedit.h> +#include <tqtextedit.h> +#include <tqlistview.h> +#include <tqlistbox.h> +#include <tqiconview.h> +#include <tqtable.h> +#include <tqgridview.h> +#include <tqregexp.h> +#include <tqstylesheet.h> // KDE includes. #include <kapplication.h> @@ -76,29 +76,29 @@ public: {} // List of text jobs. - QValueList<uint> m_jobNums; + TQValueList<uint> m_jobNums; // Whether the version of KTTSD has been requested from the daemon. bool m_versionChecked; // KTTSD version string. - QString m_kttsdVersion; + TQString m_kttsdVersion; // Language code of last spoken text. - QString m_langCode; + TQString m_langCode; // Word used before speaking an accelerator letter. - QString m_acceleratorPrefix; + TQString m_acceleratorPrefix; // Whether TTS service is available or not. bool m_enabled; // TTS options. uint m_speakFlags; // Timer which implements the polling interval. int m_timeout; - QTimer* m_timer; + TQTimer* m_timer; // Widget and part of widget for 1) last widget under mouse pointer, 2) last widget with focus, and // last widget spoken. - QWidget* m_prevPointerWidget; + TQWidget* m_prevPointerWidget; int m_prevPointerId; - QWidget* m_prevFocusWidget; + TQWidget* m_prevFocusWidget; int m_prevFocusId; - QWidget* m_prevWidget; + TQWidget* m_prevWidget; int m_prevId; // True when cancelSpeakWidget has been called in response to customSpeakWidget signal. bool m_cancelSpeakWidget; @@ -132,11 +132,11 @@ bool KoSpeaker::isEnabled() const { return d->m_enabled; } void KoSpeaker::probe() { d->m_timer->stop(); - QWidget* w; - QPoint pos; + TQWidget* w; + TQPoint pos; bool spoke = false; if ( d->m_speakFlags & SpeakFocusWidget ) { - w = kapp->focusWidget(); + w = kapp->tqfocusWidget(); if (w) { spoke = maybeSayWidget(w); if (!spoke) @@ -144,7 +144,7 @@ void KoSpeaker::probe() } } if ( !spoke && d->m_speakFlags & SpeakPointerWidget ) { - pos = QCursor::pos(); + pos = TQCursor::pos(); w = kapp->widgetAt(pos, true); if (w) { if (!maybeSayWidget(w, pos)) @@ -154,7 +154,7 @@ void KoSpeaker::probe() d->m_timer->start(d->m_timeout); } -void KoSpeaker::queueSpeech(const QString& msg, const QString& langCode /*= QString()*/, bool first /*= true*/) +void KoSpeaker::queueSpeech(const TQString& msg, const TQString& langCode /*= TQString()*/, bool first /*= true*/) { if (!startKttsd()) return; int jobCount = d->m_jobNums.count(); @@ -164,11 +164,11 @@ void KoSpeaker::queueSpeech(const QString& msg, const QString& langCode /*= QStr d->m_jobNums.clear(); jobCount = 0; } - QString s = msg.stripWhiteSpace(); + TQString s = msg.stripWhiteSpace(); if (s.isEmpty()) return; // kdDebug() << "KoSpeaker::queueSpeech: s = [" << s << "]" << endl; // If no language code given, assume desktop setting. - QString languageCode = langCode; + TQString languageCode = langCode; if (langCode.isEmpty()) languageCode = KGlobal::locale()->language(); // kdDebug() << "KoSpeaker::queueSpeech:languageCode = " << languageCode << endl; @@ -209,45 +209,45 @@ void KoSpeaker::readConfig(KConfig* config) d->m_acceleratorPrefix = config->readEntry("AcceleratorPrefixWord", i18n("Accelerator")); if (d->m_speakFlags & (SpeakPointerWidget | SpeakFocusWidget)) { if (startKttsd()) { - d->m_timer = new QTimer( this ); - connect( d->m_timer, SIGNAL(timeout()), this, SLOT(probe()) ); + d->m_timer = new TQTimer( this ); + connect( d->m_timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(probe()) ); d->m_timer->start( d->m_timeout ); } } } -bool KoSpeaker::maybeSayWidget(QWidget* w, const QPoint& pos /*=QPoint()*/) +bool KoSpeaker::maybeSayWidget(TQWidget* w, const TQPoint& pos /*=TQPoint()*/) { if (!w) return false; int id = -1; - QString text; + TQString text; - if (w->inherits("QViewportWidget")) { - w = w->parentWidget(); + if (w->inherits("TQViewportWidget")) { + w = w->tqparentWidget(); if (!w) return false; } // Handle widgets that have multiple parts. - if ( w->inherits("QMenuBar") ) { - QMenuBar* menuBar = dynamic_cast<QMenuBar *>(w); - if (pos == QPoint()) { + if ( w->inherits(TQMENUBAR_OBJECT_NAME_STRING) ) { + TQMenuBar* menuBar = dynamic_cast<TQMenuBar *>(w); + if (pos == TQPoint()) { for (uint i = 0; i < menuBar->count(); ++i) if (menuBar->isItemActive(menuBar->idAt(i))) { id = menuBar->idAt(i); break; } } - // TODO: This doesn't work. Need way to figure out the QMenuItem underneath mouse pointer. + // TODO: This doesn't work. Need way to figure out the TQMenuItem underneath mouse pointer. // id = menuBarItemAt(menuBar, pos); if ( id != -1 ) text = menuBar->text(id); } else - if (w->inherits("QPopupMenu")) { - QPopupMenu* popupMenu = dynamic_cast<QPopupMenu *>(w); - if (pos == QPoint()) { + if (w->inherits(TQPOPUPMENU_OBJECT_NAME_STRING)) { + TQPopupMenu* popupMenu = dynamic_cast<TQPopupMenu *>(w); + if (pos == TQPoint()) { for (uint i = 0; i < popupMenu->count(); ++i) if (popupMenu->isItemActive(popupMenu->idAt(i))) { id = popupMenu->idAt(i); @@ -259,10 +259,10 @@ bool KoSpeaker::maybeSayWidget(QWidget* w, const QPoint& pos /*=QPoint()*/) text = popupMenu->text(id); } else - if (w->inherits("QTabBar")) { - QTabBar* tabBar = dynamic_cast<QTabBar *>(w); - QTab* tab = 0; - if (pos == QPoint()) + if (w->inherits(TQTABBAR_OBJECT_NAME_STRING)) { + TQTabBar* tabBar = dynamic_cast<TQTabBar *>(w); + TQTab* tab = 0; + if (pos == TQPoint()) tab = tabBar->tabAt(tabBar->currentTab()); else tab = tabBar->selectTab(tabBar->mapFromGlobal(pos)); @@ -272,10 +272,10 @@ bool KoSpeaker::maybeSayWidget(QWidget* w, const QPoint& pos /*=QPoint()*/) } } else - if (w->inherits("QListView")) { - QListView* lv = dynamic_cast<QListView *>(w); - QListViewItem* item = 0; - if (pos == QPoint()) + if (w->inherits(TQLISTVIEW_OBJECT_NAME_STRING)) { + TQListView* lv = dynamic_cast<TQListView *>(w); + TQListViewItem* item = 0; + if (pos == TQPoint()) item = lv->currentItem(); else item = lv->itemAt(lv->viewport()->mapFromGlobal(pos)); @@ -287,11 +287,11 @@ bool KoSpeaker::maybeSayWidget(QWidget* w, const QPoint& pos /*=QPoint()*/) } } else - if (w->inherits("QListBox")) { - QListBox* lb = dynamic_cast<QListBox *>(w); + if (w->inherits(TQLISTBOX_OBJECT_NAME_STRING)) { + TQListBox* lb = dynamic_cast<TQListBox *>(w); // qt docs say coordinates are in "on-screen" coordinates. What does that mean? - QListBoxItem* item = 0; - if (pos == QPoint()) + TQListBoxItem* item = 0; + if (pos == TQPoint()) item = lb->item(lb->currentItem()); else item = lb->itemAt(lb->mapFromGlobal(pos)); @@ -301,28 +301,28 @@ bool KoSpeaker::maybeSayWidget(QWidget* w, const QPoint& pos /*=QPoint()*/) } } else - if (w->inherits("QIconView")) { - QIconView* iv = dynamic_cast<QIconView *>(w); - QIconViewItem* item = 0; - if (pos == QPoint()) + if (w->inherits(TQICONVIEW_OBJECT_NAME_STRING)) { + TQIconView* iv = dynamic_cast<TQIconView *>(w); + TQIconViewItem* item = 0; + if (pos == TQPoint()) item = iv->currentItem(); else - item = iv->findItem(iv->viewportToContents(iv->viewport()->mapFromGlobal(pos))); + item = iv->tqfindItem(iv->viewportToContents(iv->viewport()->mapFromGlobal(pos))); if (item) { id = item->index(); text = item->text(); } } else - if (w->inherits("QTable")) { - QTable* tbl = dynamic_cast<QTable *>(w); + if (w->inherits(TQTABLE_OBJECT_NAME_STRING)) { + TQTable* tbl = dynamic_cast<TQTable *>(w); int row = -1; int col = -1; - if (pos == QPoint()) { + if (pos == TQPoint()) { row = tbl->currentRow(); col = tbl->currentColumn(); } else { - QPoint p = tbl->viewportToContents(tbl->viewport()->mapFromGlobal(pos)); + TQPoint p = tbl->viewportToContents(tbl->viewport()->mapFromGlobal(pos)); row = tbl->rowAt(p.y()); col = tbl->columnAt(p.x()); } @@ -332,13 +332,13 @@ bool KoSpeaker::maybeSayWidget(QWidget* w, const QPoint& pos /*=QPoint()*/) } } else - if (w->inherits("QGridView")) { - QGridView* gv = dynamic_cast<QGridView *>(w); - // TODO: QGridView does not have a "current" row or column. Don't think they can even get focus? + if (w->inherits(TQGRIDVIEW_OBJECT_NAME_STRING)) { + TQGridView* gv = dynamic_cast<TQGridView *>(w); + // TODO: TQGridView does not have a "current" row or column. Don't think they can even get focus? int row = -1; int col = -1; - if (pos != QPoint()) { - QPoint p = gv->viewportToContents(gv->viewport()->mapFromGlobal(pos)); + if (pos != TQPoint()) { + TQPoint p = gv->viewportToContents(gv->viewport()->mapFromGlobal(pos)); row = gv->rowAt(p.y()); col = gv->columnAt(p.x()); } @@ -346,7 +346,7 @@ bool KoSpeaker::maybeSayWidget(QWidget* w, const QPoint& pos /*=QPoint()*/) id = (row * gv->numCols()) + col; } - if (pos == QPoint()) { + if (pos == TQPoint()) { if ( w == d->m_prevFocusWidget && id == d->m_prevFocusId) return false; d->m_prevFocusWidget = w; d->m_prevFocusId = id; @@ -366,29 +366,29 @@ bool KoSpeaker::maybeSayWidget(QWidget* w, const QPoint& pos /*=QPoint()*/) if (d->m_cancelSpeakWidget) return true; // Handle simple, single-part widgets. - if ( w->inherits("QButton") ) - text = dynamic_cast<QButton *>(w)->text(); + if ( w->inherits(TQBUTTON_OBJECT_NAME_STRING) ) + text = dynamic_cast<TQButton *>(w)->text(); else - if (w->inherits("QComboBox")) - text = dynamic_cast<QComboBox *>(w)->currentText(); + if (w->inherits(TQCOMBOBOX_OBJECT_NAME_STRING)) + text = dynamic_cast<TQComboBox *>(w)->currentText(); else - if (w->inherits("QLineEdit")) - text = dynamic_cast<QLineEdit *>(w)->text(); + if (w->inherits(TQLINEEDIT_OBJECT_NAME_STRING)) + text = dynamic_cast<TQLineEdit *>(w)->text(); else - if (w->inherits("QTextEdit")) - text = dynamic_cast<QTextEdit *>(w)->text(); + if (w->inherits(TQTEXTEDIT_OBJECT_NAME_STRING)) + text = dynamic_cast<TQTextEdit *>(w)->text(); else - if (w->inherits("QLabel")) - text = dynamic_cast<QLabel *>(w)->text(); + if (w->inherits(TQLABEL_OBJECT_NAME_STRING)) + text = dynamic_cast<TQLabel *>(w)->text(); else - if (w->inherits("QGroupBox")) { + if (w->inherits(TQGROUPBOX_OBJECT_NAME_STRING)) { // TODO: Should calculate this number from font size? if (w->mapFromGlobal(pos).y() < 30) - text = dynamic_cast<QGroupBox *>(w)->title(); + text = dynamic_cast<TQGroupBox *>(w)->title(); } // else -// if (w->inherits("QWhatsThat")) { -// text = dynamic_cast<QWhatsThat *>(w)->text(); +// if (w->inherits("TQWhatsThat")) { +// text = dynamic_cast<TQWhatsThat *>(w)->text(); // } text = text.stripWhiteSpace(); @@ -400,9 +400,9 @@ bool KoSpeaker::maybeSayWidget(QWidget* w, const QPoint& pos /*=QPoint()*/) } if (d->m_speakFlags & SpeakTooltip || text.isEmpty()) { // kdDebug() << "pos = " << pos << endl; - // QPoint p = w->mapFromGlobal(pos); + // TQPoint p = w->mapFromGlobal(pos); // kdDebug() << "p = " << p << endl; - QString t = QToolTip::textFor(w, pos); + TQString t = TQToolTip::textFor(w, pos); t = t.stripWhiteSpace(); if (!t.isEmpty()) { if (t.right(1) != ".") t += "."; @@ -411,7 +411,7 @@ bool KoSpeaker::maybeSayWidget(QWidget* w, const QPoint& pos /*=QPoint()*/) } if (d->m_speakFlags & SpeakWhatsThis || text.isEmpty()) { - QString t = QWhatsThis::textFor(w, pos); + TQString t = TQWhatsThis::textFor(w, pos); t = t.stripWhiteSpace(); if (!t.isEmpty()) { if (t.right(1) != ".") t += "."; @@ -427,48 +427,48 @@ bool KoSpeaker::maybeSayWidget(QWidget* w, const QPoint& pos /*=QPoint()*/) return sayWidget(text); } -bool KoSpeaker::sayWidget(const QString& msg) +bool KoSpeaker::sayWidget(const TQString& msg) { - QString s = msg; + TQString s = msg; if (d->m_speakFlags & SpeakAccelerator) { - int amp = s.find("&"); + int amp = s.tqfind("&"); if (amp >= 0) { - QString acc = s.mid(++amp,1); + TQString acc = s.mid(++amp,1); acc = acc.stripWhiteSpace(); if (!acc.isEmpty()) s += ". " + d->m_acceleratorPrefix + " " + acc + "."; } } s.remove("&"); - if (QStyleSheet::mightBeRichText(s)) { + if (TQStyleSheet::mightBeRichText(s)) { // kdDebug() << "richtext" << endl; - s.replace(QRegExp("</?[pbius]>"), ""); - s.replace(QRegExp("</?h\\d>"), ""); - s.replace(QRegExp("<(br|hr)>"), " "); - s.replace(QRegExp( + s.tqreplace(TQRegExp("</?[pbius]>"), ""); + s.tqreplace(TQRegExp("</?h\\d>"), ""); + s.tqreplace(TQRegExp("<(br|hr)>"), " "); + s.tqreplace(TQRegExp( "</?(qt|center|li|pre|div|span|em|strong|big|small|sub|sup|code|tt|font|nobr|ul|ol|dl|dt)>"), ""); - s.replace(QRegExp("</?(table|tr|th|td).*>"), ""); - s.replace(QRegExp("</?a\\s.+>"), ""); + s.tqreplace(TQRegExp("</?(table|tr|th|td).*>"), ""); + s.tqreplace(TQRegExp("</?a\\s.+>"), ""); // Replace <img source="small|frame_text"> with "small frame_text image. " - s.replace(QRegExp("<img\\s.*(?:source=|src=)\"([^|\"]+)[|]?([^|\"]*)\">"), "\\1 \\2 image. "); + s.tqreplace(TQRegExp("<img\\s.*(?:source=|src=)\"([^|\"]+)[|]?([^|\"]*)\">"), "\\1 \\2 image. "); } if (s.isEmpty()) return false; - s.replace("Ctrl+", i18n("control plus ")); - s.replace("Alt+", i18n("alt plus ")); - s.replace("+", i18n(" plus ")); + s.tqreplace("Ctrl+", i18n("control plus ")); + s.tqreplace("Alt+", i18n("alt plus ")); + s.tqreplace("+", i18n(" plus ")); sayScreenReaderOutput(s, ""); return true; } // This doesn't work. Anybody know how to find the menu item underneath mouse pointer -// in a QMenuBar? -// int KoSpeaker::menuBarItemAt(QMenuBar* m, const QPoint& p) +// in a TQMenuBar? +// int KoSpeaker::menuBarItemAt(TQMenuBar* m, const TQPoint& p) // { // for (uint i = 0; i < m->count(); i++) { // int id = m->idAt(i); -// QMenuItem* mi = m->findItem(id); -// QWidget* w = mi->widget(); -// if (w->rect().contains(w->mapFromGlobal(p))) return id; +// TQMenuItem* mi = m->findItem(id); +// TQWidget* w = mi->widget(); +// if (w->rect().tqcontains(w->mapFromGlobal(p))) return id; // } // return -1; // } @@ -485,8 +485,8 @@ bool KoSpeaker::startKttsd() // If KTTSD not running, start it. if (!client->isApplicationRegistered("kttsd")) { - QString error; - if (kapp->startServiceByDesktopName("kttsd", QStringList(), &error)) { + TQString error; + if (kapp->startServiceByDesktopName("kttsd", TQStringList(), &error)) { kdDebug() << "KoSpeaker::startKttsd: error starting KTTSD service: " << error << endl; d->m_enabled = false; } else @@ -496,18 +496,18 @@ bool KoSpeaker::startKttsd() return d->m_enabled; } -QString KoSpeaker::getKttsdVersion() +TQString KoSpeaker::getKttsdVersion() { // Determine which version of KTTSD is running. Note that earlier versions of KSpeech interface // did not support version() method, so we must manually marshall this call ourselves. if (d->m_enabled) { if (!d->m_versionChecked) { DCOPClient *client = kapp->dcopClient(); - QByteArray data; - QCString replyType; - QByteArray replyData; + TQByteArray data; + TQCString replyType; + TQByteArray replyData; if ( client->call("kttsd", "KSpeech", "version()", data, replyType, replyData, true) ) { - QDataStream arg(replyData, IO_ReadOnly); + TQDataStream arg(replyData, IO_ReadOnly); arg >> d->m_kttsdVersion; kdDebug() << "KoSpeaker::startKttsd: KTTSD version = " << d->m_kttsdVersion << endl; } @@ -517,56 +517,56 @@ QString KoSpeaker::getKttsdVersion() return d->m_kttsdVersion; } -void KoSpeaker::sayScreenReaderOutput(const QString &msg, const QString &talker) +void KoSpeaker::sayScreenReaderOutput(const TQString &msg, const TQString &talker) { if (msg.isEmpty()) return; DCOPClient *client = kapp->dcopClient(); - QByteArray data; - QCString replyType; - QByteArray replyData; - QDataStream arg(data, IO_WriteOnly); + TQByteArray data; + TQCString replyType; + TQByteArray replyData; + TQDataStream arg(data, IO_WriteOnly); arg << msg << talker; - if ( !client->call("kttsd", "KSpeech", "sayScreenReaderOutput(QString,QString)", + if ( !client->call("kttsd", "KSpeech", "sayScreenReaderOutput(TQString,TQString)", data, replyType, replyData, true) ) { kdDebug() << "KoSpeaker::sayScreenReaderOutput: failed" << endl; } } -uint KoSpeaker::setText(const QString &text, const QString &talker) +uint KoSpeaker::setText(const TQString &text, const TQString &talker) { if (text.isEmpty()) return 0; DCOPClient *client = kapp->dcopClient(); - QByteArray data; - QCString replyType; - QByteArray replyData; - QDataStream arg(data, IO_WriteOnly); + TQByteArray data; + TQCString replyType; + TQByteArray replyData; + TQDataStream arg(data, IO_WriteOnly); arg << text << talker; uint jobNum = 0; - if ( !client->call("kttsd", "KSpeech", "setText(QString,QString)", + if ( !client->call("kttsd", "KSpeech", "setText(TQString,TQString)", data, replyType, replyData, true) ) { kdDebug() << "KoSpeaker::sayText: failed" << endl; } else { - QDataStream arg2(replyData, IO_ReadOnly); + TQDataStream arg2(replyData, IO_ReadOnly); arg2 >> jobNum; } return jobNum; } -int KoSpeaker::appendText(const QString &text, uint jobNum /*=0*/) +int KoSpeaker::appendText(const TQString &text, uint jobNum /*=0*/) { if (text.isEmpty()) return 0; DCOPClient *client = kapp->dcopClient(); - QByteArray data; - QCString replyType; - QByteArray replyData; - QDataStream arg(data, IO_WriteOnly); + TQByteArray data; + TQCString replyType; + TQByteArray replyData; + TQDataStream arg(data, IO_WriteOnly); arg << text << jobNum; int partNum = 0; - if ( !client->call("kttsd", "KSpeech", "appendText(QString,uint)", + if ( !client->call("kttsd", "KSpeech", "appendText(TQString,uint)", data, replyType, replyData, true) ) { kdDebug() << "KoSpeaker::appendText: failed" << endl; } else { - QDataStream arg2(replyData, IO_ReadOnly); + TQDataStream arg2(replyData, IO_ReadOnly); arg2 >> partNum; } return partNum; @@ -575,10 +575,10 @@ int KoSpeaker::appendText(const QString &text, uint jobNum /*=0*/) void KoSpeaker::startText(uint jobNum /*=0*/) { DCOPClient *client = kapp->dcopClient(); - QByteArray data; - QCString replyType; - QByteArray replyData; - QDataStream arg(data, IO_WriteOnly); + TQByteArray data; + TQCString replyType; + TQByteArray replyData; + TQDataStream arg(data, IO_WriteOnly); arg << jobNum; if ( !client->call("kttsd", "KSpeech", "startText(uint)", data, replyType, replyData, true) ) { @@ -589,10 +589,10 @@ void KoSpeaker::startText(uint jobNum /*=0*/) void KoSpeaker::removeText(uint jobNum /*=0*/) { DCOPClient *client = kapp->dcopClient(); - QByteArray data; - QCString replyType; - QByteArray replyData; - QDataStream arg(data, IO_WriteOnly); + TQByteArray data; + TQCString replyType; + TQByteArray replyData; + TQDataStream arg(data, IO_WriteOnly); arg << jobNum; if ( !client->call("kttsd", "KSpeech", "removeText(uint)", data, replyType, replyData, true) ) { |