mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-25 09:18:54 -05:00
Massive UI revamping (v7): commands dialog
This commit is contained in:
parent
5abef702e4
commit
44a90939ef
@ -58,7 +58,7 @@ public:
|
||||
bool getRelease() const { return m_release; }
|
||||
QString getKeyLabel() const;
|
||||
|
||||
void run(const QString& apiAddress, int apiPort, int deviceSetIndex);
|
||||
void run(const QString& apiAddress, int apiPort, int deviceSetIndex = 0);
|
||||
void kill();
|
||||
QProcess::ProcessState getLastProcessState() const;
|
||||
bool getLastProcessError(QProcess::ProcessError& error) const;
|
||||
|
@ -742,6 +742,7 @@ public:
|
||||
friend class MainServer;
|
||||
friend class MainWindow;
|
||||
friend class WebAPIAdapter;
|
||||
friend class CommandsDialog;
|
||||
|
||||
signals:
|
||||
void deviceSetAdded(int index, DeviceAPI *device);
|
||||
|
@ -21,6 +21,7 @@ set(sdrgui_SOURCES
|
||||
gui/clickablelabel.cpp
|
||||
gui/colormapper.cpp
|
||||
gui/commanditem.cpp
|
||||
gui/commandsdialog.cpp
|
||||
gui/commandoutputdialog.cpp
|
||||
gui/crightclickenabler.cpp
|
||||
gui/customtextedit.cpp
|
||||
@ -117,6 +118,7 @@ set(sdrgui_HEADERS
|
||||
gui/channelwindow.h
|
||||
gui/colormapper.h
|
||||
gui/commanditem.h
|
||||
gui/commandsdialog.h
|
||||
gui/commandoutputdialog.h
|
||||
gui/crightclickenabler.h
|
||||
gui/customtextedit.h
|
||||
@ -208,6 +210,7 @@ set(sdrgui_FORMS
|
||||
gui/basicdevicesettingsdialog.ui
|
||||
gui/basicfeaturesettingsdialog.ui
|
||||
gui/channeladddialog.ui
|
||||
gui/commandsdialog.ui
|
||||
gui/commandoutputdialog.ui
|
||||
gui/cwkeyergui.ui
|
||||
gui/devicestreamselectiondialog.ui
|
||||
|
318
sdrgui/gui/commandsdialog.cpp
Normal file
318
sdrgui/gui/commandsdialog.cpp
Normal file
@ -0,0 +1,318 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2022 F4EXB //
|
||||
// written by Edouard Griffiths //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "commands/command.h"
|
||||
#include "commands/commandkeyreceiver.h"
|
||||
#include "editcommanddialog.h"
|
||||
#include "addpresetdialog.h"
|
||||
#include "commandoutputdialog.h"
|
||||
#include "commanditem.h"
|
||||
#include "maincore.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include "commandsdialog.h"
|
||||
#include "ui_commandsdialog.h"
|
||||
|
||||
CommandsDialog::CommandsDialog(QWidget* parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::CommandsDialog),
|
||||
m_apiHost("127.0.0.1"),
|
||||
m_apiPort(8091),
|
||||
m_commandKeyReceiver(nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->commandKeyboardConnect->hide(); // FIXME
|
||||
}
|
||||
|
||||
CommandsDialog::~CommandsDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CommandsDialog::populateTree()
|
||||
{
|
||||
MainCore::instance()->m_settings.sortCommands();
|
||||
ui->commandTree->clear();
|
||||
QTreeWidgetItem *treeItem;
|
||||
|
||||
for (int i = 0; i < MainCore::instance()->m_settings.getCommandCount(); ++i) {
|
||||
treeItem = addCommandToTree(MainCore::instance()->m_settings.getCommand(i));
|
||||
}
|
||||
}
|
||||
|
||||
void CommandsDialog::on_commandNew_clicked()
|
||||
{
|
||||
QStringList groups;
|
||||
QString group = "";
|
||||
QString description = "";
|
||||
|
||||
for(int i = 0; i < ui->commandTree->topLevelItemCount(); i++) {
|
||||
groups.append(ui->commandTree->topLevelItem(i)->text(0));
|
||||
}
|
||||
|
||||
QTreeWidgetItem* item = ui->commandTree->currentItem();
|
||||
|
||||
if(item != 0)
|
||||
{
|
||||
if(item->type() == PGroup) {
|
||||
group = item->text(0);
|
||||
} else if(item->type() == PItem) {
|
||||
group = item->parent()->text(0);
|
||||
description = item->text(0);
|
||||
}
|
||||
}
|
||||
|
||||
Command *command = new Command();
|
||||
command->setGroup(group);
|
||||
command->setDescription(description);
|
||||
EditCommandDialog editCommandDialog(groups, group, this);
|
||||
editCommandDialog.fromCommand(*command);
|
||||
|
||||
if (editCommandDialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
editCommandDialog.toCommand(*command);
|
||||
MainCore::instance()->m_settings.addCommand(command);
|
||||
ui->commandTree->setCurrentItem(addCommandToTree(command));
|
||||
MainCore::instance()->m_settings.sortCommands();
|
||||
}
|
||||
}
|
||||
|
||||
void CommandsDialog::on_commandDuplicate_clicked()
|
||||
{
|
||||
QTreeWidgetItem* item = ui->commandTree->currentItem();
|
||||
const Command* command = qvariant_cast<const Command*>(item->data(0, Qt::UserRole));
|
||||
Command *commandCopy = new Command(*command);
|
||||
MainCore::instance()->m_settings.addCommand(commandCopy);
|
||||
ui->commandTree->setCurrentItem(addCommandToTree(commandCopy));
|
||||
MainCore::instance()->m_settings.sortCommands();
|
||||
}
|
||||
|
||||
void CommandsDialog::on_commandEdit_clicked()
|
||||
{
|
||||
QTreeWidgetItem* item = ui->commandTree->currentItem();
|
||||
bool change = false;
|
||||
const Command *changedCommand = 0;
|
||||
QString newGroupName;
|
||||
|
||||
QStringList groups;
|
||||
|
||||
for(int i = 0; i < ui->commandTree->topLevelItemCount(); i++) {
|
||||
groups.append(ui->commandTree->topLevelItem(i)->text(0));
|
||||
}
|
||||
|
||||
if(item != 0)
|
||||
{
|
||||
if (item->type() == PItem)
|
||||
{
|
||||
const Command* command = qvariant_cast<const Command*>(item->data(0, Qt::UserRole));
|
||||
|
||||
if (command != 0)
|
||||
{
|
||||
EditCommandDialog editCommandDialog(groups, command->getGroup(), this);
|
||||
editCommandDialog.fromCommand(*command);
|
||||
|
||||
if (editCommandDialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
Command* command_mod = const_cast<Command*>(command);
|
||||
editCommandDialog.toCommand(*command_mod);
|
||||
change = true;
|
||||
changedCommand = command;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (item->type() == PGroup)
|
||||
{
|
||||
AddPresetDialog dlg(groups, item->text(0), this);
|
||||
dlg.showGroupOnly();
|
||||
dlg.setDialogTitle("Edit command group");
|
||||
dlg.setDescriptionBoxTitle("Command details");
|
||||
|
||||
if (dlg.exec() == QDialog::Accepted)
|
||||
{
|
||||
MainCore::instance()->m_settings.renameCommandGroup(item->text(0), dlg.group());
|
||||
newGroupName = dlg.group();
|
||||
change = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (change)
|
||||
{
|
||||
MainCore::instance()->m_settings.sortCommands();
|
||||
ui->commandTree->clear();
|
||||
|
||||
for (int i = 0; i < MainCore::instance()->m_settings.getCommandCount(); ++i)
|
||||
{
|
||||
QTreeWidgetItem *item_x = addCommandToTree(MainCore::instance()->m_settings.getCommand(i));
|
||||
const Command* command_x = qvariant_cast<const Command*>(item_x->data(0, Qt::UserRole));
|
||||
if (changedCommand && (command_x == changedCommand)) { // set cursor on changed command
|
||||
ui->commandTree->setCurrentItem(item_x);
|
||||
}
|
||||
}
|
||||
|
||||
if (!changedCommand) // on group name change set cursor on the group that has been changed
|
||||
{
|
||||
for(int i = 0; i < ui->commandTree->topLevelItemCount(); i++)
|
||||
{
|
||||
QTreeWidgetItem* item = ui->commandTree->topLevelItem(i);
|
||||
|
||||
if (item->text(0) == newGroupName) {
|
||||
ui->commandTree->setCurrentItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CommandsDialog::on_commandRun_clicked()
|
||||
{
|
||||
QTreeWidgetItem* item = ui->commandTree->currentItem();
|
||||
|
||||
if (item)
|
||||
{
|
||||
if (item->type() == PItem) // run individual command
|
||||
{
|
||||
const Command* command = qvariant_cast<const Command*>(item->data(0, Qt::UserRole));
|
||||
Command* command_mod = const_cast<Command*>(command);
|
||||
command_mod->run(m_apiHost, m_apiPort);
|
||||
}
|
||||
else if (item->type() == PGroup) // run all commands in this group
|
||||
{
|
||||
QString group = item->text(0);
|
||||
|
||||
for (int i = 0; i < MainCore::instance()->m_settings.getCommandCount(); ++i)
|
||||
{
|
||||
Command *command_mod = const_cast<Command*>(MainCore::instance()->m_settings.getCommand(i));
|
||||
|
||||
if (command_mod->getGroup() == group) {
|
||||
command_mod->run(m_apiHost, m_apiPort);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CommandsDialog::on_commandOutput_clicked()
|
||||
{
|
||||
QTreeWidgetItem* item = ui->commandTree->currentItem();
|
||||
|
||||
if ((item != 0) && (item->type() == PItem))
|
||||
{
|
||||
const Command* command = qvariant_cast<const Command*>(item->data(0, Qt::UserRole));
|
||||
Command* command_mod = const_cast<Command*>(command);
|
||||
CommandOutputDialog commandOutputDialog(*command_mod);
|
||||
commandOutputDialog.exec();
|
||||
}
|
||||
}
|
||||
|
||||
void CommandsDialog::on_commandsSave_clicked()
|
||||
{
|
||||
MainCore::instance()->m_settings.save();
|
||||
}
|
||||
|
||||
void CommandsDialog::on_commandDelete_clicked()
|
||||
{
|
||||
QTreeWidgetItem* item = ui->commandTree->currentItem();
|
||||
|
||||
if (item != 0)
|
||||
{
|
||||
if (item->type() == PItem) // delete individual command
|
||||
{
|
||||
const Command* command = qvariant_cast<const Command*>(item->data(0, Qt::UserRole));
|
||||
|
||||
if(command)
|
||||
{
|
||||
if (QMessageBox::question(this,
|
||||
tr("Delete command"),
|
||||
tr("Do you want to delete command '%1'?")
|
||||
.arg(command->getDescription()), QMessageBox::No | QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
|
||||
{
|
||||
delete item;
|
||||
MainCore::instance()->m_settings.deleteCommand(command);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (item->type() == PGroup) // delete all commands in this group
|
||||
{
|
||||
if (QMessageBox::question(this,
|
||||
tr("Delete command group"),
|
||||
tr("Do you want to delete command group '%1'?")
|
||||
.arg(item->text(0)), QMessageBox::No | QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
|
||||
{
|
||||
MainCore::instance()->m_settings.deleteCommandGroup(item->text(0));
|
||||
|
||||
ui->commandTree->clear();
|
||||
|
||||
for (int i = 0; i < MainCore::instance()->m_settings.getCommandCount(); ++i) {
|
||||
addCommandToTree(MainCore::instance()->m_settings.getCommand(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CommandsDialog::on_commandKeyboardConnect_toggled(bool checked)
|
||||
{
|
||||
qDebug("CommandsDialog::on_commandKeyboardConnect_toggled: %s", checked ? "true" : "false");
|
||||
|
||||
if (checked) {
|
||||
MainWindow::getInstance()->commandKeysConnect(MainWindow::getInstance(), SLOT(commandKeyPressed(Qt::Key, Qt::KeyboardModifiers, bool)));
|
||||
} else {
|
||||
MainWindow::getInstance()->commandKeysDisconnect(MainWindow::getInstance(), SLOT(commandKeyPressed(Qt::Key, Qt::KeyboardModifiers, bool)));
|
||||
}
|
||||
}
|
||||
|
||||
QTreeWidgetItem* CommandsDialog::addCommandToTree(const Command* command)
|
||||
{
|
||||
QTreeWidgetItem* group = 0;
|
||||
|
||||
for(int i = 0; i < ui->commandTree->topLevelItemCount(); i++)
|
||||
{
|
||||
if(ui->commandTree->topLevelItem(i)->text(0) == command->getGroup())
|
||||
{
|
||||
group = ui->commandTree->topLevelItem(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(group == 0)
|
||||
{
|
||||
QStringList sl;
|
||||
sl.append(command->getGroup());
|
||||
group = new QTreeWidgetItem(ui->commandTree, sl, PGroup);
|
||||
group->setFirstColumnSpanned(true);
|
||||
group->setExpanded(true);
|
||||
ui->commandTree->sortByColumn(0, Qt::AscendingOrder);
|
||||
}
|
||||
|
||||
QStringList sl;
|
||||
sl.append(QString("%1").arg(command->getDescription())); // Descriptions column
|
||||
sl.append(QString("%1").arg(command->getAssociateKey() ? command->getRelease() ? "R" : "P" : "-")); // key press/release column
|
||||
sl.append(QString("%1").arg(command->getKeyLabel())); // key column
|
||||
CommandItem* item = new CommandItem(group, sl, command->getDescription(), PItem);
|
||||
item->setData(0, Qt::UserRole, QVariant::fromValue(command));
|
||||
item->setTextAlignment(0, Qt::AlignLeft);
|
||||
ui->commandTree->resizeColumnToContents(0); // Resize description column to minimum
|
||||
ui->commandTree->resizeColumnToContents(1); // Resize key column to minimum
|
||||
ui->commandTree->resizeColumnToContents(2); // Resize key press/release column to minimum
|
||||
|
||||
//updatePresetControls();
|
||||
return item;
|
||||
}
|
68
sdrgui/gui/commandsdialog.h
Normal file
68
sdrgui/gui/commandsdialog.h
Normal file
@ -0,0 +1,68 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2022 F4EXB //
|
||||
// written by Edouard Griffiths //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SDRGUI_GUI_COMMANDSDIALOG_H_
|
||||
#define SDRGUI_GUI_COMMANDSDIALOG_H_
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "export.h"
|
||||
|
||||
class CommandKeyReceiver;
|
||||
|
||||
namespace Ui {
|
||||
class CommandsDialog;
|
||||
}
|
||||
|
||||
class SDRGUI_API CommandsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CommandsDialog(QWidget* parent = nullptr);
|
||||
~CommandsDialog();
|
||||
|
||||
void setApiHost(const QString& apiHost) { m_apiHost = apiHost; }
|
||||
void setApiPort(int apiPort) { m_apiPort = apiPort; }
|
||||
void setCommandKeyReceiver(CommandKeyReceiver *commandKeyReceiver) { m_commandKeyReceiver = commandKeyReceiver; }
|
||||
void populateTree();
|
||||
|
||||
private:
|
||||
enum {
|
||||
PGroup,
|
||||
PItem
|
||||
};
|
||||
|
||||
Ui::CommandsDialog* ui;
|
||||
QString m_apiHost;
|
||||
int m_apiPort;
|
||||
CommandKeyReceiver *m_commandKeyReceiver;
|
||||
|
||||
QTreeWidgetItem* addCommandToTree(const Command* command);
|
||||
|
||||
private slots:
|
||||
void on_commandNew_clicked();
|
||||
void on_commandDuplicate_clicked();
|
||||
void on_commandEdit_clicked();
|
||||
void on_commandRun_clicked();
|
||||
void on_commandOutput_clicked();
|
||||
void on_commandsSave_clicked();
|
||||
void on_commandDelete_clicked();
|
||||
void on_commandKeyboardConnect_toggled(bool checked);
|
||||
};
|
||||
|
||||
#endif // SDRGUI_GUI_COMMANDSDIALOG_H_
|
252
sdrgui/gui/commandsdialog.ui
Normal file
252
sdrgui/gui/commandsdialog.ui
Normal file
@ -0,0 +1,252 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CommandsDialog</class>
|
||||
<widget class="QDialog" name="CommandsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Liberation Sans</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Commands</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="commandTree">
|
||||
<property name="indentation">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="allColumnsShowFocus">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<attribute name="headerMinimumSectionSize">
|
||||
<number>5</number>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Description</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>P/R</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Key</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="commandsControl">
|
||||
<item>
|
||||
<widget class="QToolButton" name="commandNew">
|
||||
<property name="toolTip">
|
||||
<string>Create new command</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources/res.qrc">
|
||||
<normaloff>:/create.png</normaloff>:/create.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="commandDuplicate">
|
||||
<property name="toolTip">
|
||||
<string>Duplicate command</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources/res.qrc">
|
||||
<normaloff>:/duplicate.png</normaloff>:/duplicate.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="commandEdit">
|
||||
<property name="toolTip">
|
||||
<string>Edit command details</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources/res.qrc">
|
||||
<normaloff>:/edit.png</normaloff>:/edit.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="commandRun">
|
||||
<property name="toolTip">
|
||||
<string>Run command</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources/res.qrc">
|
||||
<normaloff>:/play.png</normaloff>:/play.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="commandOutput">
|
||||
<property name="toolTip">
|
||||
<string>View last run status and output</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources/res.qrc">
|
||||
<normaloff>:/listing.png</normaloff>:/listing.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="commandsSave">
|
||||
<property name="toolTip">
|
||||
<string>Save commands in settings</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources/res.qrc">
|
||||
<normaloff>:/save.png</normaloff>:/save.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="commandDelete">
|
||||
<property name="toolTip">
|
||||
<string>Delete selected command</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources/res.qrc">
|
||||
<normaloff>:/bin.png</normaloff>:/bin.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="ButtonSwitch" name="commandKeyboardConnect">
|
||||
<property name="toolTip">
|
||||
<string>Toggle keyboard to command connection</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources/res.qrc">
|
||||
<normaloff>:/keyboard.png</normaloff>:/keyboard.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ButtonSwitch</class>
|
||||
<extends>QToolButton</extends>
|
||||
<header>gui/buttonswitch.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../resources/res.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>CommandsDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>CommandsDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -30,6 +30,7 @@
|
||||
#include <QFontDatabase>
|
||||
#include <QStandardPaths>
|
||||
#include <QDesktopServices>
|
||||
#include <QProcess>
|
||||
|
||||
#include <QAction>
|
||||
#include <QMenuBar>
|
||||
@ -49,10 +50,7 @@
|
||||
#include "commands/commandkeyreceiver.h"
|
||||
#include "gui/indicator.h"
|
||||
#include "gui/presetitem.h"
|
||||
#include "gui/commanditem.h"
|
||||
#include "gui/addpresetdialog.h"
|
||||
#include "gui/editcommanddialog.h"
|
||||
#include "gui/commandoutputdialog.h"
|
||||
#include "gui/pluginsdialog.h"
|
||||
#include "gui/aboutdialog.h"
|
||||
#include "gui/rollupwidget.h"
|
||||
@ -67,6 +65,7 @@
|
||||
#include "gui/ambedevicesdialog.h"
|
||||
#include "gui/workspace.h"
|
||||
#include "gui/featurepresetsdialog.h"
|
||||
#include "gui/commandsdialog.h"
|
||||
#include "dsp/dspengine.h"
|
||||
#include "dsp/spectrumvis.h"
|
||||
#include "dsp/dspcommands.h"
|
||||
@ -975,6 +974,9 @@ void MainWindow::createMenuBar()
|
||||
QAction *userArgumentsAction = devicesMenu->addAction("User arguments");
|
||||
userArgumentsAction->setToolTip("Device custom user arguments");
|
||||
QObject::connect(userArgumentsAction, &QAction::triggered, this, &MainWindow::on_action_DeviceUserArguments_triggered);
|
||||
QAction *commandsAction = preferencesMenu->addAction("Commands");
|
||||
commandsAction->setToolTip("External commands dialog");
|
||||
QObject::connect(commandsAction, &QAction::triggered, this, &MainWindow::on_action_commands_triggered);
|
||||
|
||||
QMenu *helpMenu = menuBar->addMenu("Help");
|
||||
QAction *quickStartAction = helpMenu->addAction("Quick start");
|
||||
@ -1427,245 +1429,25 @@ void MainWindow::on_action_View_Fullscreen_toggled(bool checked)
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_commandNew_clicked()
|
||||
{
|
||||
// QStringList groups;
|
||||
// QString group = "";
|
||||
// QString description = "";
|
||||
|
||||
// for(int i = 0; i < ui->commandTree->topLevelItemCount(); i++) {
|
||||
// groups.append(ui->commandTree->topLevelItem(i)->text(0));
|
||||
// }
|
||||
|
||||
// QTreeWidgetItem* item = ui->commandTree->currentItem();
|
||||
|
||||
// if(item != 0)
|
||||
// {
|
||||
// if(item->type() == PGroup) {
|
||||
// group = item->text(0);
|
||||
// } else if(item->type() == PItem) {
|
||||
// group = item->parent()->text(0);
|
||||
// description = item->text(0);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Command *command = new Command();
|
||||
// command->setGroup(group);
|
||||
// command->setDescription(description);
|
||||
// EditCommandDialog editCommandDialog(groups, group, this);
|
||||
// editCommandDialog.fromCommand(*command);
|
||||
|
||||
// if (editCommandDialog.exec() == QDialog::Accepted)
|
||||
// {
|
||||
// editCommandDialog.toCommand(*command);
|
||||
// m_mainCore->m_settings.addCommand(command);
|
||||
// ui->commandTree->setCurrentItem(addCommandToTree(command));
|
||||
// m_mainCore->m_settings.sortCommands();
|
||||
// }
|
||||
}
|
||||
|
||||
void MainWindow::on_commandDuplicate_clicked()
|
||||
{
|
||||
// QTreeWidgetItem* item = ui->commandTree->currentItem();
|
||||
// const Command* command = qvariant_cast<const Command*>(item->data(0, Qt::UserRole));
|
||||
// Command *commandCopy = new Command(*command);
|
||||
// m_mainCore->m_settings.addCommand(commandCopy);
|
||||
// ui->commandTree->setCurrentItem(addCommandToTree(commandCopy));
|
||||
// m_mainCore->m_settings.sortCommands();
|
||||
}
|
||||
|
||||
void MainWindow::on_commandEdit_clicked()
|
||||
{
|
||||
// QTreeWidgetItem* item = ui->commandTree->currentItem();
|
||||
// bool change = false;
|
||||
// const Command *changedCommand = 0;
|
||||
// QString newGroupName;
|
||||
|
||||
// QStringList groups;
|
||||
|
||||
// for(int i = 0; i < ui->commandTree->topLevelItemCount(); i++) {
|
||||
// groups.append(ui->commandTree->topLevelItem(i)->text(0));
|
||||
// }
|
||||
|
||||
// if(item != 0)
|
||||
// {
|
||||
// if (item->type() == PItem)
|
||||
// {
|
||||
// const Command* command = qvariant_cast<const Command*>(item->data(0, Qt::UserRole));
|
||||
|
||||
// if (command != 0)
|
||||
// {
|
||||
// EditCommandDialog editCommandDialog(groups, command->getGroup(), this);
|
||||
// editCommandDialog.fromCommand(*command);
|
||||
|
||||
// if (editCommandDialog.exec() == QDialog::Accepted)
|
||||
// {
|
||||
// Command* command_mod = const_cast<Command*>(command);
|
||||
// editCommandDialog.toCommand(*command_mod);
|
||||
// change = true;
|
||||
// changedCommand = command;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else if (item->type() == PGroup)
|
||||
// {
|
||||
// AddPresetDialog dlg(groups, item->text(0), this);
|
||||
// dlg.showGroupOnly();
|
||||
// dlg.setDialogTitle("Edit command group");
|
||||
// dlg.setDescriptionBoxTitle("Command details");
|
||||
|
||||
// if (dlg.exec() == QDialog::Accepted)
|
||||
// {
|
||||
// m_mainCore->m_settings.renameCommandGroup(item->text(0), dlg.group());
|
||||
// newGroupName = dlg.group();
|
||||
// change = true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (change)
|
||||
// {
|
||||
// m_mainCore->m_settings.sortCommands();
|
||||
// ui->commandTree->clear();
|
||||
|
||||
// for (int i = 0; i < m_mainCore->m_settings.getCommandCount(); ++i)
|
||||
// {
|
||||
// QTreeWidgetItem *item_x = addCommandToTree(m_mainCore->m_settings.getCommand(i));
|
||||
// const Command* command_x = qvariant_cast<const Command*>(item_x->data(0, Qt::UserRole));
|
||||
// if (changedCommand && (command_x == changedCommand)) { // set cursor on changed command
|
||||
// ui->commandTree->setCurrentItem(item_x);
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (!changedCommand) // on group name change set cursor on the group that has been changed
|
||||
// {
|
||||
// for(int i = 0; i < ui->commandTree->topLevelItemCount(); i++)
|
||||
// {
|
||||
// QTreeWidgetItem* item = ui->commandTree->topLevelItem(i);
|
||||
|
||||
// if (item->text(0) == newGroupName) {
|
||||
// ui->commandTree->setCurrentItem(item);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void MainWindow::on_commandDelete_clicked()
|
||||
{
|
||||
// QTreeWidgetItem* item = ui->commandTree->currentItem();
|
||||
|
||||
// if (item != 0)
|
||||
// {
|
||||
// if (item->type() == PItem) // delete individual command
|
||||
// {
|
||||
// const Command* command = qvariant_cast<const Command*>(item->data(0, Qt::UserRole));
|
||||
|
||||
// if(command)
|
||||
// {
|
||||
// if (QMessageBox::question(this,
|
||||
// tr("Delete command"),
|
||||
// tr("Do you want to delete command '%1'?")
|
||||
// .arg(command->getDescription()), QMessageBox::No | QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
|
||||
// {
|
||||
// delete item;
|
||||
// m_mainCore->m_settings.deleteCommand(command);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else if (item->type() == PGroup) // delete all commands in this group
|
||||
// {
|
||||
// if (QMessageBox::question(this,
|
||||
// tr("Delete command group"),
|
||||
// tr("Do you want to delete command group '%1'?")
|
||||
// .arg(item->text(0)), QMessageBox::No | QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
|
||||
// {
|
||||
// m_mainCore->m_settings.deleteCommandGroup(item->text(0));
|
||||
|
||||
// ui->commandTree->clear();
|
||||
|
||||
// for (int i = 0; i < m_mainCore->m_settings.getCommandCount(); ++i) {
|
||||
// addCommandToTree(m_mainCore->m_settings.getCommand(i));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void MainWindow::on_commandRun_clicked()
|
||||
{
|
||||
// QTreeWidgetItem* item = ui->commandTree->currentItem();
|
||||
|
||||
// if (item != 0)
|
||||
// {
|
||||
// int currentDeviceSetIndex = ui->tabInputsView->currentIndex();
|
||||
|
||||
// if (item->type() == PItem) // run individual command
|
||||
// {
|
||||
// const Command* command = qvariant_cast<const Command*>(item->data(0, Qt::UserRole));
|
||||
// Command* command_mod = const_cast<Command*>(command);
|
||||
// command_mod->run(m_apiServer->getHost(), m_apiServer->getPort(), currentDeviceSetIndex);
|
||||
// }
|
||||
// else if (item->type() == PGroup) // run all commands in this group
|
||||
// {
|
||||
// QString group = item->text(0);
|
||||
|
||||
// for (int i = 0; i < m_mainCore->m_settings.getCommandCount(); ++i)
|
||||
// {
|
||||
// Command *command_mod = const_cast<Command*>(m_mainCore->m_settings.getCommand(i));
|
||||
|
||||
// if (command_mod->getGroup() == group) {
|
||||
// command_mod->run(m_apiServer->getHost(), m_apiServer->getPort(), currentDeviceSetIndex);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void MainWindow::on_commandOutput_clicked()
|
||||
{
|
||||
// QTreeWidgetItem* item = ui->commandTree->currentItem();
|
||||
|
||||
// if ((item != 0) && (item->type() == PItem))
|
||||
// {
|
||||
// const Command* command = qvariant_cast<const Command*>(item->data(0, Qt::UserRole));
|
||||
// Command* command_mod = const_cast<Command*>(command);
|
||||
// CommandOutputDialog commandOutputDialog(*command_mod);
|
||||
// commandOutputDialog.exec();
|
||||
// }
|
||||
}
|
||||
|
||||
void MainWindow::on_commandsSave_clicked()
|
||||
{
|
||||
saveCommandSettings();
|
||||
m_mainCore->m_settings.save();
|
||||
}
|
||||
|
||||
void MainWindow::commandKeysConnect(QObject *object, const char *slot)
|
||||
{
|
||||
setFocus();
|
||||
connect(m_commandKeyReceiver, SIGNAL(capturedKey(Qt::Key, Qt::KeyboardModifiers, bool)),
|
||||
object, slot);
|
||||
connect(
|
||||
m_commandKeyReceiver,
|
||||
SIGNAL(capturedKey(Qt::Key, Qt::KeyboardModifiers, bool)),
|
||||
object,
|
||||
slot
|
||||
);
|
||||
}
|
||||
|
||||
void MainWindow::commandKeysDisconnect(QObject *object, const char *slot)
|
||||
{
|
||||
disconnect(m_commandKeyReceiver, SIGNAL(capturedKey(Qt::Key, Qt::KeyboardModifiers, bool)),
|
||||
object, slot);
|
||||
}
|
||||
|
||||
void MainWindow::on_commandKeyboardConnect_toggled(bool checked)
|
||||
{
|
||||
qDebug("on_commandKeyboardConnect_toggled: %s", checked ? "true" : "false");
|
||||
|
||||
if (checked)
|
||||
{
|
||||
commandKeysConnect(this, SLOT(commandKeyPressed(Qt::Key, Qt::KeyboardModifiers, bool)));
|
||||
}
|
||||
else
|
||||
{
|
||||
commandKeysDisconnect(this, SLOT(commandKeyPressed(Qt::Key, Qt::KeyboardModifiers, bool)));
|
||||
}
|
||||
disconnect(
|
||||
m_commandKeyReceiver,
|
||||
SIGNAL(capturedKey(Qt::Key, Qt::KeyboardModifiers, bool)),
|
||||
object,
|
||||
slot
|
||||
);
|
||||
}
|
||||
|
||||
void MainWindow::on_presetSave_clicked()
|
||||
@ -2021,6 +1803,17 @@ void MainWindow::on_action_DeviceUserArguments_triggered()
|
||||
deviceUserArgsDialog.exec();
|
||||
}
|
||||
|
||||
void MainWindow::on_action_commands_triggered()
|
||||
{
|
||||
qDebug("MainWindow::on_action_commands_triggered");
|
||||
CommandsDialog commandsDialog(this);
|
||||
commandsDialog.setApiHost(m_apiServer->getHost());
|
||||
commandsDialog.setApiPort(m_apiServer->getPort());
|
||||
commandsDialog.setCommandKeyReceiver(m_commandKeyReceiver);
|
||||
commandsDialog.populateTree();
|
||||
commandsDialog.exec();
|
||||
}
|
||||
|
||||
void MainWindow::on_action_FFT_triggered()
|
||||
{
|
||||
qDebug("MainWindow::on_action_FFT_triggered");
|
||||
@ -2659,22 +2452,22 @@ void MainWindow::updateStatus()
|
||||
|
||||
void MainWindow::commandKeyPressed(Qt::Key key, Qt::KeyboardModifiers keyModifiers, bool release)
|
||||
{
|
||||
//qDebug("MainWindow::commandKeyPressed: key: %x mod: %x %s", (int) key, (int) keyModifiers, release ? "release" : "press");
|
||||
// int currentDeviceSetIndex = ui->tabInputsView->currentIndex();
|
||||
qDebug("MainWindow::commandKeyPressed: key: %x mod: %x %s", (int) key, (int) keyModifiers, release ? "release" : "press");
|
||||
int currentDeviceSetIndex = 0;
|
||||
|
||||
// for (int i = 0; i < m_mainCore->m_settings.getCommandCount(); ++i)
|
||||
// {
|
||||
// const Command* command = m_mainCore->m_settings.getCommand(i);
|
||||
for (int i = 0; i < m_mainCore->m_settings.getCommandCount(); ++i)
|
||||
{
|
||||
const Command* command = m_mainCore->m_settings.getCommand(i);
|
||||
|
||||
// if (command->getAssociateKey()
|
||||
// && (command->getRelease() == release)
|
||||
// && (command->getKey() == key)
|
||||
// && (command->getKeyModifiers() == keyModifiers))
|
||||
// {
|
||||
// Command* command_mod = const_cast<Command*>(command);
|
||||
// command_mod->run(m_apiServer->getHost(), m_apiServer->getPort(), currentDeviceSetIndex);
|
||||
// }
|
||||
// }
|
||||
if (command->getAssociateKey()
|
||||
&& (command->getRelease() == release)
|
||||
&& (command->getKey() == key)
|
||||
&& (command->getKeyModifiers() == keyModifiers))
|
||||
{
|
||||
Command* command_mod = const_cast<Command*>(command);
|
||||
command_mod->run(m_apiServer->getHost(), m_apiServer->getPort(), currentDeviceSetIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::restoreDeviceTabs()
|
||||
|
@ -174,14 +174,6 @@ private slots:
|
||||
void on_presetDelete_clicked();
|
||||
void on_presetTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
void on_presetTree_itemActivated(QTreeWidgetItem *item, int column);
|
||||
void on_commandNew_clicked();
|
||||
void on_commandDuplicate_clicked();
|
||||
void on_commandEdit_clicked();
|
||||
void on_commandDelete_clicked();
|
||||
void on_commandRun_clicked();
|
||||
void on_commandOutput_clicked();
|
||||
void on_commandsSave_clicked();
|
||||
void on_commandKeyboardConnect_toggled(bool checked);
|
||||
void on_action_Audio_triggered();
|
||||
void on_action_Logging_triggered();
|
||||
void on_action_FFT_triggered();
|
||||
@ -189,6 +181,7 @@ private slots:
|
||||
void on_action_LimeRFE_triggered();
|
||||
void on_action_My_Position_triggered();
|
||||
void on_action_DeviceUserArguments_triggered();
|
||||
void on_action_commands_triggered();
|
||||
void samplingDeviceChanged(int deviceType, int tabIndex, int newDeviceIndex);
|
||||
void channelAddClicked(int channelIndex);
|
||||
void featureAddClicked(Workspace *workspace, int featureIndex);
|
||||
|
Loading…
Reference in New Issue
Block a user