summaryrefslogtreecommitdiffstats
path: root/ksayit/src/voicesetupdlg.cpp
blob: d04aabc3fac4279ea771f50fab5a5415cd60a19b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/***************************************************************************
                          voicesetupdlg.cpp  -  description
                             -------------------
    begin                : Son Nov 2 2003
    copyright            : (C) 2003 by Robert Vogl
    email                : voglrobe@saphir
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 <iostream>
// using namespace std;
 
// QT includes
#include <tqpixmap.h>
#include <tqstringlist.h>
#include <tqcombobox.h>
#include <tqcolor.h>
#include <tqlayout.h>
#include <tqwidget.h>

// KDE includes
#include <kdebug.h>
#include <tdeglobal.h>
#include <tdelocale.h>
#include <kiconloader.h>
#include <tdemessagebox.h>

// App specific includes
#include "voicesetupdlg.h"
#include "fxsetupimpl.h"
#include "fxpluginhandler.h"
#include "kttsdlib.h"

VoiceSetupDlg::VoiceSetupDlg(TQWidget *parent, const char *name, const TQString &caption,
        bool modal,
        TDEConfig *config,
        FXPluginHandler *fxpluginhandler,
        KTTSDLib *ttslib)
 : KDialogBase(IconList, caption, Ok|Cancel, Ok, parent, name, modal, true),
   m_config(config),
   m_fxpluginhandler(fxpluginhandler),
   m_kttslib(ttslib)
{

  setIconListAllVisible(true);
  connect (this, TQ_SIGNAL(aboutToShowPage(TQWidget*)), this, TQ_SLOT(slotPageChanged(TQWidget*)));

  initVoicePage();
  initFXPage();

}


VoiceSetupDlg::~VoiceSetupDlg()
{    
}


void VoiceSetupDlg::initVoicePage()
{
    TQPixmap icon = TDEGlobal::iconLoader()->loadIcon("ksayit", TDEIcon::Toolbar, TDEIcon::SizeMedium);
    TQFrame *voicePage = addPage( i18n( "Voice" ), i18n("Voice Settings"), icon );
    TQVBoxLayout *voiceLayout = new TQVBoxLayout( voicePage, 0, spacingHint() );
    
    const TQWidget *voiceDialog = m_kttslib->getGUI( voicePage );
    voiceLayout->addWidget( const_cast<TQWidget*>(voiceDialog) );
}


void VoiceSetupDlg::initFXPage()
{
    TQPixmap icon = TDEGlobal::iconLoader()->loadIcon("ksysguard", TDEIcon::Toolbar, TDEIcon::SizeMedium);
    m_fxPage = addPage( i18n( "Audio FX" ), i18n("Effect Stack"), icon );
    TQVBoxLayout *fxLayout = new TQVBoxLayout( m_fxPage, 0, spacingHint() );
    
    FX_SetupImpl *fxDialog = new FX_SetupImpl(m_fxPage, "fxsetup", m_config, m_fxpluginhandler);
    fxLayout->addWidget(fxDialog);
    connect( this, TQ_SIGNAL(signalOKWasClicked()), fxDialog, TQ_SLOT(slotSaveWasClicked()) );
    connect( this, TQ_SIGNAL(signalRemoveAllFX()), fxDialog, TQ_SLOT(slotRemoveAll()) );
    connect( this, TQ_SIGNAL(signalReloadFX()), fxDialog, TQ_SLOT(slotReload()) );
    
    // Disable/enable FX-Setup depending on TTS-libs capability
    int status = m_kttslib->getStatus() & TTS::AUDIOFILE;
    if ( status ){
        m_fxPage->setEnabled(true);
    } else {
        m_fxPage->setEnabled(false);
        emit signalRemoveAllFX();
    }
}


void VoiceSetupDlg::slotPageChanged(TQWidget *page)
{
    kdDebug(100200) << "+++ entering VoiceSetupDlg::slotPageChanged: " << page << endl;
    
    if ( page != m_fxPage )
        return;
    
    int status = m_kttslib->getStatus() & TTS::AUDIOFILE;
    if ( status ){
        m_fxPage->setEnabled(true);
    } else {
        TQString q = i18n("The active TTS system does not make use of aRts effects.");
        KMessageBox::information( this, q, i18n("Plugin Configuration"), "KSayIt_Audiofile" );
        m_fxPage->setEnabled(false);
    }
}


void VoiceSetupDlg::slotOk()
{
    kdDebug(100200) << "+++ entering VoiceSetupDlg::slotOK()" << endl;
    
    int status = m_kttslib->getStatus();
    if ( (status & TTS::AUDIOFILE) == 0 ){
        emit signalRemoveAllFX();
    }
    
    // Let all objects save their configuration
    emit signalOKWasClicked();

	// check if configuration was saved O.K.
    if ( m_kttslib->saveWasClicked() ){
		kdDebug(100200) << "--- leaving VoiceSetupDlg::slotOk" << endl;
		TQDialog::accept();
	}
}


void VoiceSetupDlg::slotCancel()
{
    kdDebug(100200) << "VoiceSetupDlg::slotCancel()" << endl;
    TQDialog::reject();
}

#include "voicesetupdlg.moc"