- enhancement: Set shortcuts for tools menu item.

This commit is contained in:
Roy Qu 2024-04-01 19:25:14 +08:00
parent 6339b44d5f
commit e10b5b1d39
5 changed files with 18 additions and 2 deletions

View File

@ -112,6 +112,7 @@ Red Panda C++ Version 2.27
- enhancement: Make colors in header suggestion popup consistent with the editor.
- fix: C++ source after ';' are treated as comments in cpu info window.
- enhancement: Support "extern template" in code parser.
- enhancement: Set shortcuts for tools menu item.
Red Panda C++ Version 2.26
- enhancement: Code suggestion for embedded std::vectors.

View File

@ -489,8 +489,8 @@ MainWindow::MainWindow(QWidget *parent)
updateEditorActions();
updateCaretActions();
updateEditorColorSchemes();
updateShortcuts();
updateTools();
updateShortcuts();
updateEditorSettings();
//updateEditorBookmarks();
}
@ -3424,8 +3424,9 @@ void MainWindow::updateTools()
ui->menuTools->addAction(ui->actionOptions);
if (!mToolsManager->tools().isEmpty()) {
ui->menuTools->addSeparator();
QList<QAction*> actions;
foreach (const PToolItem& item, mToolsManager->tools()) {
QAction* action = new QAction(item->title,ui->menuTools);
QAction* action = createShortcutCustomableAction(item->title,"tool-"+item->id);
connect(action, &QAction::triggered,
[item] (){
QMap<QString, QString> macros = devCppMacroVariables();
@ -3482,7 +3483,11 @@ void MainWindow::updateTools()
});
ui->menuTools->addAction(action);
actions.append(action);
}
ShortcutManager shortcutManager;
shortcutManager.load();
shortcutManager.applyTo(actions);
}
}

View File

@ -26,6 +26,7 @@
#include <QFileDialog>
#include <QMessageBox>
#include <QUuid>
ToolsGeneralWidget::ToolsGeneralWidget(const QString &name, const QString &group, QWidget *parent) :
SettingsWidget(name,group,parent),
@ -197,6 +198,7 @@ void ToolsGeneralWidget::on_btnAdd_clicked()
{
ui->lstTools->setCurrentIndex(QModelIndex());
PToolItem item = std::make_shared<ToolItem>();
item->id=QUuid::createUuid().toString();
item->title = tr("untitled");
item->pauseAfterExit = false;
mToolsModel.addTool(item);

View File

@ -36,6 +36,7 @@ void ToolsManager::load()
if (!fileExists(filename)) {
mTools.clear();
PToolItem item = std::make_shared<ToolItem>();
item->id = QUuid::createUuid().toString();
item->title = tr("Remove Compiled");
#ifdef Q_OS_WIN
item->program = "del";
@ -55,6 +56,7 @@ void ToolsManager::load()
// item->pauseAfterExit = false;
// mTools.append(item);
//#endif
save();
return;
}
//read config file
@ -82,6 +84,10 @@ void ToolsManager::load()
foreach (const QJsonValue& value,array) {
QJsonObject object = value.toObject();
PToolItem item = std::make_shared<ToolItem>();
if (!object.contains("id"))
item->id = QUuid::createUuid().toString();
else
item->id = object["id"].toString();
item->title = object["title"].toString();
if (item->title.isEmpty())
continue;
@ -107,6 +113,7 @@ void ToolsManager::save()
QJsonArray array;
foreach (const PToolItem& tool,mTools) {
QJsonObject object;
object["id"]=tool->id;
object["title"]=tool->title;
object["program"]=tool->program;
object["workingDirectory"] = tool->workingDirectory;

View File

@ -21,6 +21,7 @@
#include <memory>
struct ToolItem {
QString id;
QString title;
QString program;
QString workingDirectory;