From d94537d00cdf321c8c995e35477b98434738e641 Mon Sep 17 00:00:00 2001 From: Refuhr Date: Tue, 7 Jul 2026 15:41:37 +0200 Subject: [PATCH] feat: add ctrl + r shortcut to reload all connections --- connections/connectionwindow.cpp | 27 +++++++++++++++++++++------ connections/connectionwindow.h | 2 ++ mainwindow.cpp | 5 +++++ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/connections/connectionwindow.cpp b/connections/connectionwindow.cpp index aa0caf3..21409e0 100644 --- a/connections/connectionwindow.cpp +++ b/connections/connectionwindow.cpp @@ -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 */ diff --git a/connections/connectionwindow.h b/connections/connectionwindow.h index 61a94c5..37f1b3a 100644 --- a/connections/connectionwindow.h +++ b/connections/connectionwindow.h @@ -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 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(); diff --git a/mainwindow.cpp b/mainwindow.cpp index 814e9e1..b26b1c6 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -11,6 +11,7 @@ #include "filterutility.h" #include +#include /* 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);