SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Public Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
EditCommandDialog Class Reference

#include <editcommanddialog.h>

Inherits QDialog.

+ Collaboration diagram for EditCommandDialog:

Public Member Functions

 EditCommandDialog (const QStringList &groups, const QString &group, QWidget *parent=0)
 
 ~EditCommandDialog ()
 
QString getGroup () const
 
void setGroup (const QString &group)
 
QString getDescription () const
 
void setDescription (const QString &description)
 
QString getCommand () const
 
void setCommand (const QString &command)
 
QString getArguments () const
 
void setArguments (const QString &arguments)
 
Qt::Key getKey () const
 
Qt::KeyboardModifiers getKeyModifiers () const
 
void setKey (Qt::Key key, Qt::KeyboardModifiers modifiers)
 
bool getAssociateKey () const
 
void setAssociateKey (bool associate)
 
bool getRelease () const
 
void setRelease (bool release)
 
void toCommand (Command &command) const
 
void fromCommand (const Command &command)
 

Private Slots

void on_showFileDialog_clicked (bool checked)
 
void on_keyCapture_toggled (bool checked)
 
void commandKeyPressed (Qt::Key key, Qt::KeyboardModifiers keyModifiers, bool release)
 

Private Member Functions

void setKeyLabel ()
 
void setKeyAssociate ()
 

Private Attributes

Ui::EditCommandDialog * ui
 
Qt::Key m_key
 
Qt::KeyboardModifiers m_keyModifiers
 
CommandKeyReceiverm_commandKeyReceiver
 

Detailed Description

Definition at line 33 of file editcommanddialog.h.

Constructor & Destructor Documentation

◆ EditCommandDialog()

EditCommandDialog::EditCommandDialog ( const QStringList &  groups,
const QString &  group,
QWidget *  parent = 0 
)
explicit

Definition at line 27 of file editcommanddialog.cpp.

References m_commandKeyReceiver, setKeyAssociate(), setKeyLabel(), and ui.

27  :
28  QDialog(parent),
29  ui(new Ui::EditCommandDialog),
30  m_key(static_cast<Qt::Key>(0))
31 {
32  ui->setupUi(this);
33  ui->group->addItems(groups);
34  ui->group->lineEdit()->setText(group);
36  setKeyLabel();
37 
39  this->installEventFilter(m_commandKeyReceiver);
40 }
CommandKeyReceiver * m_commandKeyReceiver
Ui::EditCommandDialog * ui
+ Here is the call graph for this function:

◆ ~EditCommandDialog()

EditCommandDialog::~EditCommandDialog ( )

Definition at line 42 of file editcommanddialog.cpp.

References m_commandKeyReceiver, and ui.

43 {
44  m_commandKeyReceiver->deleteLater();
45  delete ui;
46 }
CommandKeyReceiver * m_commandKeyReceiver
Ui::EditCommandDialog * ui

Member Function Documentation

◆ commandKeyPressed

void EditCommandDialog::commandKeyPressed ( Qt::Key  key,
Qt::KeyboardModifiers  keyModifiers,
bool  release 
)
privateslot

Definition at line 229 of file editcommanddialog.cpp.

References m_key, m_keyModifiers, setKeyAssociate(), setKeyLabel(), and ui.

Referenced by on_keyCapture_toggled().

230 {
231  (void) release;
232 // qDebug("EditCommandDialog::commandKeyPressed: key: %x", m_key);
233 // qDebug("EditCommandDialog::commandKeyPressed: has modifiers: %x", QFlags<Qt::KeyboardModifier>::Int(keyModifiers));
234  m_key = key;
235  m_keyModifiers = keyModifiers;
236  setKeyAssociate();
237  setKeyLabel();
238  ui->keyCapture->setChecked(false);
239 }
Qt::KeyboardModifiers m_keyModifiers
Ui::EditCommandDialog * ui
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fromCommand()

void EditCommandDialog::fromCommand ( const Command command)

Definition at line 184 of file editcommanddialog.cpp.

References Command::getArgString(), Command::getAssociateKey(), Command::getCommand(), Command::getDescription(), Command::getGroup(), Command::getKey(), Command::getKeyModifiers(), Command::getRelease(), m_key, m_keyModifiers, setKeyAssociate(), setKeyLabel(), and ui.

Referenced by MainWindow::on_commandEdit_clicked(), and MainWindow::on_commandNew_clicked().

185 {
186  ui->group->lineEdit()->setText(command.getGroup());
187  ui->description->setText(command.getDescription());
188  ui->command->setText(command.getCommand());
189  ui->args->setText(command.getArgString());
190  ui->keyAssociate->setChecked(command.getAssociateKey());
191  m_key = command.getKey();
192  m_keyModifiers = command.getKeyModifiers();
193  setKeyAssociate();
194  setKeyLabel();
195  ui->keyRelease->setChecked(command.getRelease());
196 }
Qt::KeyboardModifiers getKeyModifiers() const
Definition: command.h:54
const QString & getDescription() const
Definition: command.h:50
Qt::Key getKey() const
Definition: command.h:52
Qt::KeyboardModifiers m_keyModifiers
const QString & getArgString() const
Definition: command.h:46
const QString & getGroup() const
Definition: command.h:48
Ui::EditCommandDialog * ui
bool getAssociateKey() const
Definition: command.h:56
const QString & getCommand() const
Definition: command.h:44
bool getRelease() const
Definition: command.h:58
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getArguments()

QString EditCommandDialog::getArguments ( ) const

Definition at line 78 of file editcommanddialog.cpp.

References ui.

79 {
80  return ui->args->text();
81 }
Ui::EditCommandDialog * ui

◆ getAssociateKey()

bool EditCommandDialog::getAssociateKey ( ) const

Definition at line 106 of file editcommanddialog.cpp.

References ui.

107 {
108  return ui->keyAssociate->isChecked();
109 }
Ui::EditCommandDialog * ui

◆ getCommand()

QString EditCommandDialog::getCommand ( ) const

Definition at line 68 of file editcommanddialog.cpp.

References ui.

69 {
70  return ui->command->text();
71 }
Ui::EditCommandDialog * ui

◆ getDescription()

QString EditCommandDialog::getDescription ( ) const

Definition at line 53 of file editcommanddialog.cpp.

References ui.

54 {
55  return ui->description->text();
56 }
Ui::EditCommandDialog * ui

◆ getGroup()

QString EditCommandDialog::getGroup ( ) const

Definition at line 48 of file editcommanddialog.cpp.

References ui.

49 {
50  return ui->group->lineEdit()->text();
51 }
Ui::EditCommandDialog * ui

◆ getKey()

Qt::Key EditCommandDialog::getKey ( ) const

Definition at line 88 of file editcommanddialog.cpp.

References m_key.

89 {
90  return m_key;
91 }

◆ getKeyModifiers()

Qt::KeyboardModifiers EditCommandDialog::getKeyModifiers ( ) const

Definition at line 93 of file editcommanddialog.cpp.

References m_keyModifiers.

94 {
95  return m_keyModifiers;
96 }
Qt::KeyboardModifiers m_keyModifiers

◆ getRelease()

bool EditCommandDialog::getRelease ( ) const

Definition at line 116 of file editcommanddialog.cpp.

References ui.

117 {
118  return ui->keyRelease->isChecked();
119 }
Ui::EditCommandDialog * ui

◆ on_keyCapture_toggled

void EditCommandDialog::on_keyCapture_toggled ( bool  checked)
privateslot

Definition at line 154 of file editcommanddialog.cpp.

References commandKeyPressed(), and m_commandKeyReceiver.

155 {
156  if (checked)
157  {
158  setFocus();
159  setFocusPolicy(Qt::StrongFocus);
160  connect(m_commandKeyReceiver, SIGNAL(capturedKey(Qt::Key, Qt::KeyboardModifiers, bool)),
161  this, SLOT(commandKeyPressed(Qt::Key, Qt::KeyboardModifiers, bool)));
162  }
163  else
164  {
165  disconnect(m_commandKeyReceiver, SIGNAL(capturedKey(Qt::Key, Qt::KeyboardModifiers, bool)),
166  this, SLOT(commandKeyPressed(Qt::Key, Qt::KeyboardModifiers, bool)));
167  setFocusPolicy(Qt::NoFocus);
168  clearFocus();
169  }
170 }
CommandKeyReceiver * m_commandKeyReceiver
void commandKeyPressed(Qt::Key key, Qt::KeyboardModifiers keyModifiers, bool release)
+ Here is the call graph for this function:

◆ on_showFileDialog_clicked

void EditCommandDialog::on_showFileDialog_clicked ( bool  checked)
privateslot

Definition at line 126 of file editcommanddialog.cpp.

References ui.

127 {
128  (void) checked;
129  QString commandFileName = ui->command->text();
130  QFileInfo commandFileInfo(commandFileName);
131  QString commandFolderName = commandFileInfo.baseName();
132  QFileInfo commandDirInfo(commandFolderName);
133  QString dirStr;
134 
135  if (commandFileInfo.exists()) {
136  dirStr = commandFileName;
137  } else if (commandDirInfo.exists()) {
138  dirStr = commandFolderName;
139  } else {
140  dirStr = ".";
141  }
142 
143  QString fileName = QFileDialog::getOpenFileName(
144  this,
145  tr("Select command"),
146  dirStr,
147  tr("All (*);;Python (*.py);;Shell (*.sh *.bat);;Binary (*.bin *.exe)"), 0, QFileDialog::DontUseNativeDialog);
148 
149  if (fileName != "") {
150  ui->command->setText(fileName);
151  }
152 }
Ui::EditCommandDialog * ui

◆ setArguments()

void EditCommandDialog::setArguments ( const QString &  arguments)

Definition at line 83 of file editcommanddialog.cpp.

References ui.

84 {
85  ui->args->setText(arguments);
86 }
Ui::EditCommandDialog * ui

◆ setAssociateKey()

void EditCommandDialog::setAssociateKey ( bool  associate)

Definition at line 111 of file editcommanddialog.cpp.

References ui.

112 {
113  ui->keyAssociate->setChecked(release);
114 }
Ui::EditCommandDialog * ui

◆ setCommand()

void EditCommandDialog::setCommand ( const QString &  command)

Definition at line 73 of file editcommanddialog.cpp.

References ui.

74 {
75  ui->command->setText(command);
76 }
Ui::EditCommandDialog * ui

◆ setDescription()

void EditCommandDialog::setDescription ( const QString &  description)

Definition at line 63 of file editcommanddialog.cpp.

References ui.

64 {
65  ui->description->setText(description);
66 }
Ui::EditCommandDialog * ui

◆ setGroup()

void EditCommandDialog::setGroup ( const QString &  group)

Definition at line 58 of file editcommanddialog.cpp.

References ui.

59 {
60  ui->group->lineEdit()->setText(group);
61 }
Ui::EditCommandDialog * ui

◆ setKey()

void EditCommandDialog::setKey ( Qt::Key  key,
Qt::KeyboardModifiers  modifiers 
)

Definition at line 98 of file editcommanddialog.cpp.

References m_key, m_keyModifiers, setKeyAssociate(), and setKeyLabel().

99 {
100  m_key = key;
101  m_keyModifiers = modifiers;
102  setKeyAssociate();
103  setKeyLabel();
104 }
Qt::KeyboardModifiers m_keyModifiers
+ Here is the call graph for this function:

◆ setKeyAssociate()

void EditCommandDialog::setKeyAssociate ( )
private

Definition at line 216 of file editcommanddialog.cpp.

References m_key, and ui.

Referenced by commandKeyPressed(), EditCommandDialog(), fromCommand(), and setKey().

217 {
218  if (m_key == 0)
219  {
220  ui->keyAssociate->setChecked(false);
221  ui->keyAssociate->setEnabled(false);
222  }
223  else
224  {
225  ui->keyAssociate->setEnabled(true);
226  }
227 }
Ui::EditCommandDialog * ui
+ Here is the caller graph for this function:

◆ setKeyLabel()

void EditCommandDialog::setKeyLabel ( )
private

Definition at line 198 of file editcommanddialog.cpp.

References m_key, m_keyModifiers, and ui.

Referenced by commandKeyPressed(), EditCommandDialog(), fromCommand(), and setKey().

199 {
200  if (m_key == 0)
201  {
202  ui->keyLabel->setText("");
203  }
204  else if (m_keyModifiers != Qt::NoModifier)
205  {
206  QString altGrStr = m_keyModifiers & Qt::GroupSwitchModifier ? "Gr " : "";
207  int maskedModifiers = (m_keyModifiers & 0x3FFFFFFF) + ((m_keyModifiers & 0x40000000)>>3);
208  ui->keyLabel->setText(altGrStr + QKeySequence(maskedModifiers, m_key).toString());
209  }
210  else
211  {
212  ui->keyLabel->setText(QKeySequence(m_key).toString());
213  }
214 }
Qt::KeyboardModifiers m_keyModifiers
Ui::EditCommandDialog * ui
+ Here is the caller graph for this function:

◆ setRelease()

void EditCommandDialog::setRelease ( bool  release)

Definition at line 121 of file editcommanddialog.cpp.

References ui.

122 {
123  ui->keyRelease->setChecked(release);
124 }
Ui::EditCommandDialog * ui

◆ toCommand()

void EditCommandDialog::toCommand ( Command command) const

Definition at line 172 of file editcommanddialog.cpp.

References m_key, m_keyModifiers, Command::setArgString(), Command::setAssociateKey(), Command::setCommand(), Command::setDescription(), Command::setGroup(), Command::setKey(), Command::setKeyModifiers(), Command::setRelease(), and ui.

Referenced by MainWindow::on_commandNew_clicked().

173 {
174  command.setGroup(ui->group->currentText());
175  command.setDescription(ui->description->text());
176  command.setCommand(ui->command->text());
177  command.setArgString(ui->args->text());
178  command.setAssociateKey(ui->keyAssociate->isChecked());
179  command.setKey(m_key);
181  command.setRelease(ui->keyRelease->isChecked());
182 }
void setRelease(bool release)
Definition: command.h:57
void setArgString(const QString &argString)
Definition: command.h:45
void setKey(Qt::Key key)
Definition: command.h:51
void setDescription(const QString &description)
Definition: command.h:49
Qt::KeyboardModifiers m_keyModifiers
void setCommand(const QString &command)
Definition: command.h:43
void setAssociateKey(bool associate)
Definition: command.h:55
Ui::EditCommandDialog * ui
void setGroup(const QString &group)
Definition: command.h:47
void setKeyModifiers(Qt::KeyboardModifiers keyModifiers)
Definition: command.h:53
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_commandKeyReceiver

CommandKeyReceiver* EditCommandDialog::m_commandKeyReceiver
private

◆ m_key

Qt::Key EditCommandDialog::m_key
private

◆ m_keyModifiers

Qt::KeyboardModifiers EditCommandDialog::m_keyModifiers
private

◆ ui

Ui::EditCommandDialog* EditCommandDialog::ui
private

The documentation for this class was generated from the following files: