kwave  18.07.70
MP3CodecPlugin.cpp
Go to the documentation of this file.
1 /*************************************************************************
2  MP3CodecPlugin.cpp - import and export of MP3 data
3  -------------------
4  begin : Mon May 28 2012
5  copyright : (C) 2012 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 "libkwave/String.h"
21 
22 #include "MP3CodecPlugin.h"
23 #include "MP3Decoder.h"
24 #include "MP3Encoder.h"
25 #include "MP3EncoderDialog.h"
26 
27 KWAVE_PLUGIN(codec_mp3, MP3CodecPlugin)
28 
29 // static instance of the codec container
31 
32 /***************************************************************************/
34  const QVariantList &args)
35  :Kwave::CodecPlugin(parent, args, m_codec)
36 {
37 }
38 
39 /***************************************************************************/
41 {
42 }
43 
44 /***************************************************************************/
45 void Kwave::MP3CodecPlugin::load(QStringList &params)
46 {
47  emitCommand(_("menu (plugin:setup(codec_mp3), Settings/%1)").arg(
48  _(I18N_NOOP2("menu: /Settings/MP3 Encoder Setup",
49  "MP3 Encoder Setup"))));
51 }
52 
53 //***************************************************************************
54 QStringList *Kwave::MP3CodecPlugin::setup(QStringList &previous_params)
55 {
56  Q_UNUSED(previous_params);
57 
58  // create the setup dialog
59  MP3EncoderDialog *dialog =
60  new(std::nothrow) MP3EncoderDialog(parentWidget());
61  Q_ASSERT(dialog);
62  if (!dialog) return Q_NULLPTR;
63 
64  QStringList *list = new(std::nothrow) QStringList();
65  Q_ASSERT(list);
66  if (list && dialog->exec()) {
67  // user has pressed "OK"
68  dialog->save();
69  } else {
70  // user pressed "Cancel"
71  if (list) delete list;
72  list = Q_NULLPTR;
73  }
74 
75  if (dialog) delete dialog;
76  return list;
77 
78 }
79 
80 /***************************************************************************/
81 QList<Kwave::Decoder *> Kwave::MP3CodecPlugin::createDecoder()
82 {
83  return singleDecoder<Kwave::MP3Decoder>();
84 }
85 
86 /***************************************************************************/
87 QList<Kwave::Encoder *> Kwave::MP3CodecPlugin::createEncoder()
88 {
89  return singleEncoder<Kwave::MP3Encoder>();
90 }
91 
92 //***************************************************************************
93 #include "MP3CodecPlugin.moc"
94 //***************************************************************************
95 //***************************************************************************
void emitCommand(const QString &command)
Definition: Plugin.cpp:510
virtual QList< Kwave::Decoder * > createDecoder()
virtual QList< Kwave::Encoder * > createEncoder()
Definition: App.h:33
virtual void load(QStringList &) Q_DECL_OVERRIDE
Definition: CodecPlugin.cpp:39
QWidget * parentWidget() const
Definition: Plugin.cpp:450
virtual void load(QStringList &params)
#define EMPTY_CODEC
Definition: CodecPlugin.h:113
#define KWAVE_PLUGIN(name, class)
Definition: Plugin.h:54
#define _(m)
Definition: memcpy.c:66
virtual QStringList * setup(QStringList &previous_params)
MP3CodecPlugin(QObject *parent, const QVariantList &args)
static CodecPlugin::Codec m_codec