1 /***************************************************************************
2   AmplifyFreeDialog.cpp  -  dialog for the "amplifyfree" plugin
3                              -------------------
4     begin                : Sun Sep 02 2001
5     copyright            : (C) 2001 by Thomas Eschenbacher
6     email                : Thomas.Eschenbacher@gmx.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17 
18 #include "config.h"
19 
20 #include <QPushButton>
21 
22 #include <KHelpClient>
23 #include <KLocalizedString>
24 
25 #include "libkwave/Parser.h"
26 #include "libkwave/String.h"
27 
28 #include "libgui/CurveWidget.h"
29 #include "libgui/ScaleWidget.h"
30 
31 #include "AmplifyFreeDialog.h"
32 
33 //***************************************************************************
AmplifyFreeDialog(QWidget * parent)34 Kwave::AmplifyFreeDialog::AmplifyFreeDialog(QWidget *parent)
35     :QDialog(parent), Ui::AmplifyFreeDlg()
36 {
37     setupUi(this);
38     curveWidget->setMinimumSize(150, 100);
39 
40     xScale->setMinimumSize(250,  30);
41     xScale->setMinMax(0, 100);
42     xScale->setLogMode(false);
43     xScale->setUnit(i18n("ms"));
44 
45     yScale->setMinimumSize( 30, 150);
46     yScale->setMinMax(0, 100);
47     yScale->setLogMode(false);
48     yScale->setUnit(i18n("%"));
49 
50     connect(buttonBox_Help->button(QDialogButtonBox::Help), SIGNAL(clicked()),
51             this,   SLOT(invokeHelp()));
52 
53     // set the focus onto the "OK" button
54     buttonBox->button(QDialogButtonBox::Ok)->setFocus();
55 }
56 
57 //***************************************************************************
~AmplifyFreeDialog()58 Kwave::AmplifyFreeDialog::~AmplifyFreeDialog()
59 {
60 }
61 
62 //***************************************************************************
getCommand()63 QString Kwave::AmplifyFreeDialog::getCommand()
64 {
65     QString cmd;
66     Q_ASSERT(curveWidget);
67     Kwave::Parser p(curveWidget->getCommand());
68 
69     cmd = _("amplifyfree(");
70     if (p.hasParams()) cmd += p.nextParam();
71     while (!p.isDone()) {
72 	cmd += _(",") + p.nextParam();
73     }
74     cmd += _(")");
75 
76     return cmd;
77 }
78 
79 //***************************************************************************
setParams(QStringList & params)80 void Kwave::AmplifyFreeDialog::setParams(QStringList &params)
81 {
82     QStringList::Iterator it;
83     QString cmd = _("curve(");
84 
85     it = params.begin();
86     if (it != params.end()) cmd += *(it++);
87 
88     for (; it != params.end(); ++it)
89 	cmd += _(",") + *it;
90     cmd += _(")");
91 
92     if (curveWidget) curveWidget->setCurve(cmd);
93 }
94 
95 //***************************************************************************
invokeHelp()96 void Kwave::AmplifyFreeDialog::invokeHelp()
97 {
98     KHelpClient::invokeHelp(_("plugin_sect_amplifyfree"));
99 }
100 
101 //***************************************************************************
102 //***************************************************************************
103