diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 23b9b7a7..9bad3191 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -93,7 +93,8 @@ MainWindow::MainWindow(QWidget *parent) : timer(this), qcontrol(this), pulseButtonColor(255, 40, 40), - isSearchOngoing(false) + isSearchOngoing(false), + shortcutDialog(this) { dltIndexer = NULL; settings = QDltSettingsManager::getInstance(); @@ -5551,6 +5552,98 @@ void MainWindow::on_action_menuHelp_Command_Line_triggered() { QDltOptManager::getInstance()->getHelpText()); } +void MainWindow::on_actionShortcuts_List_triggered(){ + qDebug() <<"Shortcuts Triggered"; + + shortcutDialog.setWindowTitle("Shortcuts List"); + shortcutDialog.resize(600, 400); + + QTableView *table = new QTableView(&shortcutDialog); + table->setObjectName("Shortcuts Summarise Table"); + QStandardItemModel *model = new QStandardItemModel(0, 2, &shortcutDialog); + + QFont headerFont; + headerFont.setBold(true); + + QStandardItem *headerName = new QStandardItem("Action Name"); + headerName->setFont(headerFont); + model->setHorizontalHeaderItem(0, headerName); + + QStandardItem *headerFeature = new QStandardItem("Shortcuts"); + headerFeature->setFont(headerFont); + model->setHorizontalHeaderItem(1, headerFeature); + + // Define shortcut variables + const QString shortcutNew = "Ctrl + N"; + const QString shortcutOpen = "Ctrl + O"; + const QString shortcutSave = "Ctrl + S"; + const QString shortcutClear = "Ctrl + E"; + const QString shortcutimportDLT = "Ctrl + I"; + const QString shortcutimportSerialHeader = "Ctrl + J"; + const QString shortcutFind = "Ctrl + F"; + const QString shortcutJumpTo = "Ctrl + G"; + const QString shortcutNewProject = "Ctrl + Shift + G"; + const QString shortcutOpenProject = "Ctrl + Shift + O"; + const QString shortcutSaveProject = "Ctrl + Shift + S"; + const QString shortcutExpandAllECU = "Ctrl++"; + const QString shortcutCollapseAllECU = "Ctrl+"; + const QString shortcutCopyPayload = "Ctrl + P"; + const QString shortcutInfo = "F1"; + const QString shortcutQuit = "Ctrl +- Q"; + + // Store shortcuts dynamically using a list of pairs + QList> shortcutsList = { + + {"New", shortcutNew}, + {"Open", shortcutOpen}, + {"Save As", shortcutSave}, + {"Clear", shortcutClear}, + {"Import DLT Stream", shortcutimportDLT}, + {"Import DLT Stream with serial header", shortcutimportSerialHeader}, + {"Find", shortcutFind}, + {"Jump To", shortcutJumpTo}, + {"New Project", shortcutNewProject}, + {"Open Project", shortcutOpenProject}, + {"Save Project", shortcutSaveProject}, + {"Expand All ECU", shortcutExpandAllECU}, + {"Collapse All ECU", shortcutCollapseAllECU}, + {"Copy Payload", shortcutCopyPayload}, + {"Info", shortcutInfo}, + {"Quit", shortcutQuit}, + }; + + for (int i = 0; i < shortcutsList.size(); ++i) { + model->insertRow(i); + model->setData(model->index(i, 0), shortcutsList[i].first); + model->setData(model->index(i, 1), shortcutsList[i].second); + + // Make the items non-editable + for (int j = 0; j < 2; ++j) { + QStandardItem *item = model->item(i, j); + if (item) { + item->setFlags(item->flags() & ~Qt::ItemIsEditable); + } + } + } + + // Center-align + for (int row = 0; row < model->rowCount(); ++row) { + for (int col = 0; col < model->columnCount(); ++col) { + QModelIndex index = model->index(row, col); + model->setData(index, Qt::AlignCenter, Qt::TextAlignmentRole); + } + } + + table->setModel(model); + table->setColumnWidth(0, 275); + table->setColumnWidth(1, 275); + QVBoxLayout *layout = new QVBoxLayout(&shortcutDialog); + layout->addWidget(table); + + shortcutDialog.setLayout(layout); + shortcutDialog.exec(); +} + void MainWindow::on_pluginWidget_itemSelectionChanged() { QList list = project.plugin->selectedItems(); diff --git a/src/mainwindow.h b/src/mainwindow.h index 67054da2..b46b1ed1 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -28,8 +28,13 @@ #include #include #include + +#include +#include +#include #include + #include "tablemodel.h" #include "settingsdialog.h" #include "searchdialog.h" @@ -370,6 +375,8 @@ class MainWindow : public QMainWindow void writeDLTMessageToFile(const QByteArray& bufferHeader, std::string_view payload, const EcuItem* ecuitem); + QDialog shortcutDialog; + protected: void keyPressEvent ( QKeyEvent * event ) override; void dragEnterEvent(QDragEnterEvent *event) override; @@ -455,6 +462,7 @@ private slots: void on_action_menuHelp_Support_triggered(); void on_action_menuHelp_Info_triggered(); void on_action_menuHelp_Command_Line_triggered(); + void on_actionShortcuts_List_triggered(); // Config methods void on_action_menuConfig_Context_Delete_triggered(); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 1c9dc0cc..4d526eb0 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -81,7 +81,7 @@ false - 23 + 27 @@ -93,7 +93,7 @@ 0 0 1001 - 22 + 26 @@ -211,6 +211,7 @@ + @@ -1691,6 +1692,11 @@ Append... + + + Shortcuts List + +