kwave  18.07.70
StringEnterDialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  StringEnterDialog.cpp - dialog for entering a string 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  * 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 <KConfig>
21 #include <KConfigGroup>
22 #include <KHelpClient>
23 #include <KSharedConfig>
24 
25 #include "libkwave/String.h"
26 
27 #include "StringEnterDialog.h"
28 
30 #define CONFIG_GROUP metaObject()->className()
31 
33 #define CONFIG_WIDTH "width"
34 
35 //***************************************************************************
37  const QString &preset)
38  :QDialog(parent), Ui::StringEnterDlg(), m_command()
39 {
40  setupUi(this);
41  setFixedHeight(sizeHint().height());
42  setMaximumWidth(sizeHint().width() * 2);
43 
44  // restore the window width from the previous invocation
45  KConfigGroup cfg = KSharedConfig::openConfig()->group(CONFIG_GROUP);
46  QString result = cfg.readEntry(CONFIG_WIDTH);
47  bool ok = false;
48  int w = result.toUInt(&ok);
49  if (ok && (w > sizeHint().width()))
50  resize(w, height());
51 
52  if (preset.length()) {
53  edCommand->setText(preset);
54  m_command = preset;
55  }
56 }
57 
58 //***************************************************************************
60 {
61  // save the window width for the next invocation
62  KConfigGroup cfg = KSharedConfig::openConfig()->group(CONFIG_GROUP);
63  cfg.writeEntry(CONFIG_WIDTH, width());
64 }
65 
66 //***************************************************************************
68 {
69  return m_command;
70 }
71 
72 //***************************************************************************
74 {
75  m_command = edCommand->text().trimmed();
76  if (m_command.length())
77  QDialog::accept();
78  else
79  QDialog::close();
80 }
81 
82 //***************************************************************************
84 {
85  KHelpClient::invokeHelp(_("plugin_sect_stringenter"));
86 }
87 
88 //***************************************************************************
89 //***************************************************************************
StringEnterDialog(QWidget *parent, const QString &preset)
virtual ~StringEnterDialog() Q_DECL_OVERRIDE
virtual void accept() Q_DECL_OVERRIDE
#define CONFIG_GROUP
#define _(m)
Definition: memcpy.c:66
#define CONFIG_WIDTH