kwave  18.07.70
StringEnterPlugin.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  StringEnterPlugin.cpp - plugin for entering a text command
3  -------------------
4  begin : Sat Mar 14 2015
5  copyright : (C) 2015 by Thomas Eschenbacher
6  email : Thomas.Eschenbacher@gmx.de
7 
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 #include "config.h"
20 #include "errno.h"
21 
22 #include <QPointer>
23 #include <QStringList>
24 
25 #include <KLocalizedString>
26 
27 #include "libkwave/String.h"
28 #include "libkwave/Utils.h"
29 
30 #include "StringEnterDialog.h"
31 #include "StringEnterPlugin.h"
32 
33 KWAVE_PLUGIN(stringenter, StringEnterPlugin)
34 
35 //***************************************************************************
37  const QVariantList &args)
38  :Kwave::Plugin(parent, args)
39 {
40 }
41 
42 //***************************************************************************
44 {
45 }
46 
47 //***************************************************************************
48 void Kwave::StringEnterPlugin::load(QStringList &params)
49 {
50  Q_UNUSED(params);
51  QString entry =
52  _("menu(plugin:setup(stringenter),%1/%2/#icon(editor),F12)");
53  emitCommand(entry.arg(_("Settings")).arg(_(I18N_NOOP2(
54  "menu: /Settings/Enter Command",
55  "Enter Command")
56  )));
57 }
58 
59 //***************************************************************************
60 QStringList *Kwave::StringEnterPlugin::setup(QStringList &previous_params)
61 {
62  QString preset;
63  if (previous_params.count() == 1)
64  preset = previous_params[0];
65 
66  // create the setup dialog
67  QPointer<Kwave::StringEnterDialog> dialog =
69  Q_ASSERT(dialog);
70  if (!dialog) return Q_NULLPTR;
71 
72  QStringList *list = new QStringList();
73  Q_ASSERT(list);
74  if (list && dialog->exec()) {
75  // user has pressed "OK"
76  QString command = dialog->command();
77  emitCommand(command);
78  } else {
79  // user pressed "Cancel"
80  if (list) delete list;
81  list = Q_NULLPTR;
82  }
83 
84  if (dialog) delete dialog;
85  return list;
86 }
87 
88 //***************************************************************************
89 #include "StringEnterPlugin.moc"
90 //***************************************************************************
91 //***************************************************************************
void emitCommand(const QString &command)
Definition: Plugin.cpp:510
Definition: App.h:33
QWidget * parentWidget() const
Definition: Plugin.cpp:450
virtual QStringList * setup(QStringList &previous_params) Q_DECL_OVERRIDE
#define KWAVE_PLUGIN(name, class)
Definition: Plugin.h:54
virtual void load(QStringList &params) Q_DECL_OVERRIDE
#define _(m)
Definition: memcpy.c:66
virtual ~StringEnterPlugin() Q_DECL_OVERRIDE