From 00bb99ac80741fc50ef8a289719373032f2391eb Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeaccessibility@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kmouth/configwizard.cpp | 144 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 kmouth/configwizard.cpp (limited to 'kmouth/configwizard.cpp') diff --git a/kmouth/configwizard.cpp b/kmouth/configwizard.cpp new file mode 100644 index 0000000..d22c463 --- /dev/null +++ b/kmouth/configwizard.cpp @@ -0,0 +1,144 @@ +/*************************************************************************** + configwizard.cpp - description + ------------------- + begin : Mit Nov 20 2002 + copyright : (C) 2002 by Gunnar Schmi Dt + email : kmouth@schmi-dt.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + + +#include "configwizard.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#include "texttospeechconfigurationwidget.h" +#include "phrasebook/phrasebookdialog.h" +#include "wordcompletion/wordcompletion.h" +#include "wordcompletion/dictionarycreationwizard.h" + +ConfigWizard::ConfigWizard (QWidget *parent, const char *name, KConfig *config) + : KWizard(parent, name, true) +{ + setCaption (i18n("Initial Configuration - KMouth")); + + initCommandPage (config); + initBookPage (); + initCompletion (config); +} + +ConfigWizard::~ConfigWizard() { +} + +void ConfigWizard::initCommandPage(KConfig *config) { + config->setGroup("TTS System"); + bool displayCommand = false; + if (!config->hasKey("Command")) displayCommand = true; + if (!config->hasKey("StdIn")) displayCommand = true; + if (!config->hasKey("Codec")) displayCommand = true; + + if (displayCommand) { + commandWidget = new TextToSpeechConfigurationWidget (this, "ttsPage"); + commandWidget->readOptions (config, "TTS System"); + addPage (commandWidget, i18n("Text-to-Speech Configuration")); + setHelpEnabled (commandWidget, true); + setFinishEnabled (commandWidget, true); + } + else + commandWidget = 0; +} + +void ConfigWizard::initBookPage() { + QString standardBook = KApplication::kApplication()->dirs()->findResource("appdata", "standard.phrasebook"); + bool displayBook = (standardBook.isNull() || standardBook.isEmpty()); + + if (displayBook) { + bookWidget = new InitialPhraseBookWidget (this, "pbPage"); + addPage (bookWidget, i18n("Initial Phrase Book")); + setHelpEnabled (bookWidget, true); + setFinishEnabled (bookWidget, true); + if (commandWidget != 0) + setFinishEnabled (commandWidget, false); + } + else + bookWidget = 0; +} + +void ConfigWizard::initCompletion (KConfig *config) { + if (!WordCompletion::isConfigured()) { + QString dictionaryFile = KApplication::kApplication()->dirs()->findResource("appdata", "dictionary.txt"); + QFile file(dictionaryFile); + if (file.exists()) { + // If there is a word completion dictionary but no entry in the + // configuration file, we need to add it there. + config->setGroup("Dictionary 0"); + config->writeEntry ("Filename", "dictionary.txt"); + config->writeEntry ("Name", "Default"); + config->writeEntry ("Language", QString::null); + config->sync(); + } + } + + if (config->hasGroup("Completion")) { + completionWidget = 0; + return; + } + + if (!WordCompletion::isConfigured()) { + completionWidget = new CompletionWizardWidget(this, "completionPage"); + addPage (completionWidget, i18n("Word Completion")); + setHelpEnabled (completionWidget, true); + setFinishEnabled (completionWidget, true); + + if (commandWidget != 0) + setFinishEnabled (commandWidget, false); + if (bookWidget != 0) + setFinishEnabled (bookWidget, false); + } + else + completionWidget = 0; +} + +void ConfigWizard::saveConfig (KConfig *config) { + if (commandWidget != 0) { + commandWidget->ok(); + commandWidget->saveOptions (config, "TTS System"); + } + + if (bookWidget != 0) + bookWidget->createBook(); + + if (completionWidget != 0) + completionWidget->ok (config); +} + +bool ConfigWizard::requestConfiguration () { + if (commandWidget != 0 || bookWidget != 0 || completionWidget != 0) + return (exec() == QDialog::Accepted); + else + return false; +} + +bool ConfigWizard::configurationNeeded () { + return (commandWidget != 0 || bookWidget != 0 || completionWidget != 0); +} + +void ConfigWizard::help () { + KApplication::kApplication()->invokeHelp ("Wizard"); +} + +#include "configwizard.moc" -- cgit v1.2.1