feat: add ctrl + r shortcut to reload all connections
This commit is contained in:
@@ -297,19 +297,18 @@ void ConnectionWindow::handleRemoveConn()
|
||||
ui->tableConnections->selectRow(0);
|
||||
}
|
||||
|
||||
void ConnectionWindow::handleResetConn()
|
||||
void ConnectionWindow::resetConnection(int idx)
|
||||
{
|
||||
QString port, driver;
|
||||
CANCon::type type;
|
||||
int serSpeed, busSpeed, dataRate;
|
||||
bool canFd;
|
||||
|
||||
int selIdx = ui->tableConnections->selectionModel()->currentIndex().row();
|
||||
if (selIdx <0) return;
|
||||
if (idx < 0) return;
|
||||
|
||||
qDebug() << "remove connection at index: " << selIdx;
|
||||
qDebug() << "reset connection at index: " << idx;
|
||||
|
||||
CANConnection* conn_p = connModel->getAtIdx(selIdx);
|
||||
CANConnection* conn_p = connModel->getAtIdx(idx);
|
||||
if(!conn_p) return;
|
||||
|
||||
type = conn_p->getType();
|
||||
@@ -327,7 +326,23 @@ void ConnectionWindow::handleResetConn()
|
||||
conn_p = nullptr;
|
||||
|
||||
conn_p = create(type, port, driver, serSpeed, busSpeed,canFd,dataRate);
|
||||
if (conn_p) connModel->replace(selIdx, conn_p);
|
||||
if (conn_p) connModel->replace(idx, conn_p);
|
||||
}
|
||||
|
||||
void ConnectionWindow::handleResetConn()
|
||||
{
|
||||
int selIdx = ui->tableConnections->selectionModel()->currentIndex().row();
|
||||
resetConnection(selIdx);
|
||||
}
|
||||
|
||||
void ConnectionWindow::resetAllConnections()
|
||||
{
|
||||
qDebug() << "resetting all connections";
|
||||
|
||||
for (int i = 0; i < connModel->rowCount(); i++)
|
||||
{
|
||||
resetConnection(i);
|
||||
}
|
||||
}
|
||||
|
||||
/* status */
|
||||
|
||||
@@ -38,6 +38,7 @@ signals:
|
||||
public slots:
|
||||
void getDebugText(QString debugText);
|
||||
void setSuspendAll(bool pSuspend);
|
||||
void resetAllConnections();
|
||||
|
||||
|
||||
private slots:
|
||||
@@ -66,6 +67,7 @@ private:
|
||||
QVector<QString> remoteDeviceKayak;
|
||||
|
||||
CANConnection* create(CANCon::type pTye, QString pPortName, QString pDriver, int pSerialSpeed, int pBusSpeed, bool pCanFd, int pDataRate);
|
||||
void resetConnection(int idx);
|
||||
void populateBusDetails(int offset);
|
||||
void loadConnections();
|
||||
void saveConnections();
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "filterutility.h"
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QShortcut>
|
||||
/*
|
||||
Some notes on things I'd like to put into the program but haven't put on github (yet)
|
||||
|
||||
@@ -231,6 +232,10 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
connectionWindow = new ConnectionWindow();
|
||||
connect(this, SIGNAL(suspendCapturing(bool)), connectionWindow, SLOT(setSuspendAll(bool)));
|
||||
|
||||
//Ctrl+R reloads (resets) all connections, as if resetting each device in the connection window.
|
||||
QShortcut *reloadConnShortcut = new QShortcut(QKeySequence(tr("Ctrl+R")), this);
|
||||
connect(reloadConnShortcut, &QShortcut::activated, connectionWindow, &ConnectionWindow::resetAllConnections);
|
||||
|
||||
//these either are unfinished/not working or are not for general use. But,they exist
|
||||
//so if you want to enable them and play with them then go for it.
|
||||
//ui->actionFirmware_Update->setVisible(false);
|
||||
|
||||
Reference in New Issue
Block a user