- implement: tools configuration
This commit is contained in:
parent
d9c02ea6f2
commit
c4c62ec6c0
1
NEWS.md
1
NEWS.md
|
@ -27,6 +27,7 @@ Version 0.6.0
|
||||||
- implement: handle windows logout message
|
- implement: handle windows logout message
|
||||||
- fix: editor's inproject property not correctly setted (and may cause devcpp to crash when close project)
|
- fix: editor's inproject property not correctly setted (and may cause devcpp to crash when close project)
|
||||||
- implement: print
|
- implement: print
|
||||||
|
- implement: tools configuration
|
||||||
|
|
||||||
Version 0.5.0
|
Version 0.5.0
|
||||||
- enhancement: support C++ using type alias;
|
- enhancement: support C++ using type alias;
|
||||||
|
|
|
@ -65,6 +65,7 @@ SOURCES += \
|
||||||
shortcutmanager.cpp \
|
shortcutmanager.cpp \
|
||||||
symbolusagemanager.cpp \
|
symbolusagemanager.cpp \
|
||||||
todoparser.cpp \
|
todoparser.cpp \
|
||||||
|
toolsmanager.cpp \
|
||||||
widgets/aboutdialog.cpp \
|
widgets/aboutdialog.cpp \
|
||||||
widgets/classbrowser.cpp \
|
widgets/classbrowser.cpp \
|
||||||
widgets/codecompletionlistview.cpp \
|
widgets/codecompletionlistview.cpp \
|
||||||
|
@ -113,6 +114,7 @@ SOURCES += \
|
||||||
widgets/functiontooltipwidget.cpp \
|
widgets/functiontooltipwidget.cpp \
|
||||||
widgets/headercompletionpopup.cpp \
|
widgets/headercompletionpopup.cpp \
|
||||||
widgets/issuestable.cpp \
|
widgets/issuestable.cpp \
|
||||||
|
widgets/macroinfomodel.cpp \
|
||||||
widgets/newprojectdialog.cpp \
|
widgets/newprojectdialog.cpp \
|
||||||
widgets/qconsole.cpp \
|
widgets/qconsole.cpp \
|
||||||
widgets/qpatchedcombobox.cpp \
|
widgets/qpatchedcombobox.cpp \
|
||||||
|
@ -172,6 +174,7 @@ HEADERS += \
|
||||||
shortcutmanager.h \
|
shortcutmanager.h \
|
||||||
symbolusagemanager.h \
|
symbolusagemanager.h \
|
||||||
todoparser.h \
|
todoparser.h \
|
||||||
|
toolsmanager.h \
|
||||||
widgets/aboutdialog.h \
|
widgets/aboutdialog.h \
|
||||||
widgets/classbrowser.h \
|
widgets/classbrowser.h \
|
||||||
widgets/codecompletionlistview.h \
|
widgets/codecompletionlistview.h \
|
||||||
|
@ -221,6 +224,7 @@ HEADERS += \
|
||||||
widgets/functiontooltipwidget.h \
|
widgets/functiontooltipwidget.h \
|
||||||
widgets/headercompletionpopup.h \
|
widgets/headercompletionpopup.h \
|
||||||
widgets/issuestable.h \
|
widgets/issuestable.h \
|
||||||
|
widgets/macroinfomodel.h \
|
||||||
widgets/newprojectdialog.h \
|
widgets/newprojectdialog.h \
|
||||||
widgets/qconsole.h \
|
widgets/qconsole.h \
|
||||||
widgets/qpatchedcombobox.h \
|
widgets/qpatchedcombobox.h \
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -14,6 +14,7 @@
|
||||||
#include "widgets/newprojectdialog.h"
|
#include "widgets/newprojectdialog.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "widgets/aboutdialog.h"
|
#include "widgets/aboutdialog.h"
|
||||||
|
#include "shortcutmanager.h"
|
||||||
|
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
@ -137,6 +138,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
mSymbolUsageManager->load();
|
mSymbolUsageManager->load();
|
||||||
mCodeSnippetManager = std::make_shared<CodeSnippetsManager>();
|
mCodeSnippetManager = std::make_shared<CodeSnippetsManager>();
|
||||||
mCodeSnippetManager->load();
|
mCodeSnippetManager->load();
|
||||||
|
mToolsManager = std::make_shared<ToolsManager>();
|
||||||
|
mToolsManager->load();
|
||||||
mSearchResultTreeModel = std::make_shared<SearchResultTreeModel>(&mSearchResultModel);
|
mSearchResultTreeModel = std::make_shared<SearchResultTreeModel>(&mSearchResultModel);
|
||||||
mSearchResultListModel = std::make_shared<SearchResultListModel>(&mSearchResultModel);
|
mSearchResultListModel = std::make_shared<SearchResultListModel>(&mSearchResultModel);
|
||||||
mSearchViewDelegate = std::make_shared<SearchResultTreeViewDelegate>(mSearchResultTreeModel);
|
mSearchViewDelegate = std::make_shared<SearchResultTreeViewDelegate>(mSearchResultTreeModel);
|
||||||
|
@ -179,6 +182,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
updateEditorColorSchemes();
|
updateEditorColorSchemes();
|
||||||
|
|
||||||
updateShortcuts();
|
updateShortcuts();
|
||||||
|
|
||||||
|
updateTools();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
|
@ -584,32 +589,17 @@ void MainWindow::rebuildOpenedFileHisotryMenu()
|
||||||
{
|
{
|
||||||
mMenuRecentFiles->clear();
|
mMenuRecentFiles->clear();
|
||||||
mMenuRecentProjects->clear();
|
mMenuRecentProjects->clear();
|
||||||
|
|
||||||
foreach (QAction* action,mRecentFileActions) {
|
|
||||||
action->setParent(nullptr);
|
|
||||||
action->deleteLater();
|
|
||||||
}
|
|
||||||
mRecentFileActions.clear();
|
|
||||||
|
|
||||||
foreach (QAction* action,mRecentProjectActions) {
|
|
||||||
action->setParent(nullptr);
|
|
||||||
action->deleteLater();
|
|
||||||
}
|
|
||||||
mRecentProjectActions.clear();
|
|
||||||
|
|
||||||
if (pSettings->history().openedFiles().size()==0) {
|
if (pSettings->history().openedFiles().size()==0) {
|
||||||
mMenuRecentFiles->setEnabled(false);
|
mMenuRecentFiles->setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
mMenuRecentFiles->setEnabled(true);
|
mMenuRecentFiles->setEnabled(true);
|
||||||
for (const QString& filename: pSettings->history().openedFiles()) {
|
for (const QString& filename: pSettings->history().openedFiles()) {
|
||||||
QAction* action = new QAction();
|
QAction* action = new QAction(filename,mMenuRecentFiles);
|
||||||
action->setText(filename);
|
|
||||||
connect(action, &QAction::triggered, [&filename,this](bool){
|
connect(action, &QAction::triggered, [&filename,this](bool){
|
||||||
this->openFile(filename);
|
this->openFile(filename);
|
||||||
});
|
});
|
||||||
mRecentFileActions.append(action);
|
mMenuRecentFiles->addAction(action);
|
||||||
}
|
}
|
||||||
mMenuRecentFiles->addActions(mRecentFileActions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSettings->history().openedProjects().size()==0) {
|
if (pSettings->history().openedProjects().size()==0) {
|
||||||
|
@ -617,14 +607,12 @@ void MainWindow::rebuildOpenedFileHisotryMenu()
|
||||||
} else {
|
} else {
|
||||||
mMenuRecentProjects->setEnabled(true);
|
mMenuRecentProjects->setEnabled(true);
|
||||||
for (const QString& filename: pSettings->history().openedProjects()) {
|
for (const QString& filename: pSettings->history().openedProjects()) {
|
||||||
QAction* action = new QAction();
|
QAction* action = new QAction(filename,mMenuRecentProjects);
|
||||||
action->setText(filename);
|
|
||||||
connect(action, &QAction::triggered, [&filename,this](bool){
|
connect(action, &QAction::triggered, [&filename,this](bool){
|
||||||
this->openProject(filename);
|
this->openProject(filename);
|
||||||
});
|
});
|
||||||
mRecentProjectActions.append(action);
|
mMenuRecentProjects->addAction(action);
|
||||||
}
|
}
|
||||||
mMenuRecentProjects->addActions(mRecentProjectActions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1557,6 +1545,36 @@ void MainWindow::loadLastOpens()
|
||||||
focusedEditor->activate();
|
focusedEditor->activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::updateTools()
|
||||||
|
{
|
||||||
|
ui->menuTools->clear();
|
||||||
|
ui->menuTools->addAction(ui->actionOptions);
|
||||||
|
if (!mToolsManager->tools().isEmpty()) {
|
||||||
|
ui->menuTools->addSeparator();
|
||||||
|
int count = 0;
|
||||||
|
foreach (const PToolItem& item, mToolsManager->tools()) {
|
||||||
|
QAction* action = new QAction(item->title,ui->menuTools);
|
||||||
|
connect(action, &QAction::triggered,
|
||||||
|
[item] (){
|
||||||
|
if (item->pauseAfterExit
|
||||||
|
&& programHasConsole(parseMacros(item->program))) {
|
||||||
|
executeFile(
|
||||||
|
includeTrailingPathDelimiter(pSettings->dirs().app())+"ConsolePauser.exe",
|
||||||
|
" 0 \""+parseMacros(item->program)+"\" "+parseMacros(item->parameters),
|
||||||
|
parseMacros(item->workingDirectory));
|
||||||
|
} else {
|
||||||
|
executeFile(
|
||||||
|
parseMacros(item->program),
|
||||||
|
parseMacros(item->parameters),
|
||||||
|
parseMacros(item->workingDirectory));
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ui->menuTools->addAction(action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::newEditor()
|
void MainWindow::newEditor()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
@ -4119,3 +4137,8 @@ void MainWindow::on_actionPrint_triggered()
|
||||||
editor->print();
|
editor->print();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const PToolsManager &MainWindow::toolsManager() const
|
||||||
|
{
|
||||||
|
return mToolsManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
#include "symbolusagemanager.h"
|
#include "symbolusagemanager.h"
|
||||||
#include "codesnippetsmanager.h"
|
#include "codesnippetsmanager.h"
|
||||||
#include "todoparser.h"
|
#include "todoparser.h"
|
||||||
#include "shortcutmanager.h"
|
#include "toolsmanager.h"
|
||||||
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui { class MainWindow; }
|
namespace Ui { class MainWindow; }
|
||||||
|
@ -91,6 +92,7 @@ public:
|
||||||
void updateShortcuts();
|
void updateShortcuts();
|
||||||
void saveLastOpens();
|
void saveLastOpens();
|
||||||
void loadLastOpens();
|
void loadLastOpens();
|
||||||
|
void updateTools();
|
||||||
|
|
||||||
void openFiles(const QStringList& files);
|
void openFiles(const QStringList& files);
|
||||||
|
|
||||||
|
@ -129,6 +131,8 @@ public:
|
||||||
|
|
||||||
const PTodoParser &todoParser() const;
|
const PTodoParser &todoParser() const;
|
||||||
|
|
||||||
|
const PToolsManager &toolsManager() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onCompileLog(const QString& msg);
|
void onCompileLog(const QString& msg);
|
||||||
void onCompileIssue(PCompileIssue issue);
|
void onCompileIssue(PCompileIssue issue);
|
||||||
|
@ -402,8 +406,6 @@ private:
|
||||||
Debugger *mDebugger;
|
Debugger *mDebugger;
|
||||||
CPUDialog *mCPUDialog;
|
CPUDialog *mCPUDialog;
|
||||||
SearchDialog *mSearchDialog;
|
SearchDialog *mSearchDialog;
|
||||||
QList<QAction *> mRecentFileActions;
|
|
||||||
QList<QAction *> mRecentProjectActions;
|
|
||||||
bool mQuitting;
|
bool mQuitting;
|
||||||
QElapsedTimer mParserTimer;
|
QElapsedTimer mParserTimer;
|
||||||
QFileSystemWatcher mFileSystemWatcher;
|
QFileSystemWatcher mFileSystemWatcher;
|
||||||
|
@ -423,6 +425,7 @@ private:
|
||||||
PSymbolUsageManager mSymbolUsageManager;
|
PSymbolUsageManager mSymbolUsageManager;
|
||||||
PCodeSnippetManager mCodeSnippetManager;
|
PCodeSnippetManager mCodeSnippetManager;
|
||||||
PTodoParser mTodoParser;
|
PTodoParser mTodoParser;
|
||||||
|
PToolsManager mToolsManager;
|
||||||
|
|
||||||
bool mCheckSyntaxInBack;
|
bool mCheckSyntaxInBack;
|
||||||
bool mOpenClosingBottomPanel;
|
bool mOpenClosingBottomPanel;
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "projectmakefilewidget.h"
|
#include "projectmakefilewidget.h"
|
||||||
#include "projectversioninfowidget.h"
|
#include "projectversioninfowidget.h"
|
||||||
#include "projectdllhostwidget.h"
|
#include "projectdllhostwidget.h"
|
||||||
|
#include "toolsgeneralwidget.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
|
@ -169,6 +170,10 @@ PSettingsDialog SettingsDialog::optionDialog()
|
||||||
widget->init();
|
widget->init();
|
||||||
dialog->addWidget(widget);
|
dialog->addWidget(widget);
|
||||||
|
|
||||||
|
widget = new ToolsGeneralWidget(tr("General"),tr("Tools"));
|
||||||
|
widget->init();
|
||||||
|
dialog->addWidget(widget);
|
||||||
|
|
||||||
dialog->selectFirstWidget();
|
dialog->selectFirstWidget();
|
||||||
|
|
||||||
return dialog;
|
return dialog;
|
||||||
|
|
|
@ -1,14 +1,228 @@
|
||||||
#include "toolsgeneralwidget.h"
|
#include "toolsgeneralwidget.h"
|
||||||
#include "ui_toolsgeneralwidget.h"
|
#include "ui_toolsgeneralwidget.h"
|
||||||
|
#include "../mainwindow.h"
|
||||||
|
#include "../settings.h"
|
||||||
|
|
||||||
ToolsGeneralWidget::ToolsGeneralWidget(QWidget *parent) :
|
#include <QFileDialog>
|
||||||
QWidget(parent),
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
ToolsGeneralWidget::ToolsGeneralWidget(const QString &name, const QString &group, QWidget *parent) :
|
||||||
|
SettingsWidget(name,group,parent),
|
||||||
ui(new Ui::ToolsGeneralWidget)
|
ui(new Ui::ToolsGeneralWidget)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
ui->cbMacros->setModel(&mMacroInfoModel);
|
||||||
|
ui->lstTools->setModel(&mToolsModel);
|
||||||
|
mEditType = EditType::None;
|
||||||
|
finishEditing(false);
|
||||||
|
connect(ui->lstTools->selectionModel(), &QItemSelectionModel::currentRowChanged,
|
||||||
|
this,&ToolsGeneralWidget::onToolsCurrentChanged);
|
||||||
|
connect(ui->txtDirectory,&QLineEdit::textChanged,
|
||||||
|
this, &ToolsGeneralWidget::updateDemo);
|
||||||
|
connect(ui->txtParameters,&QLineEdit::textChanged,
|
||||||
|
this, &ToolsGeneralWidget::updateDemo);
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolsGeneralWidget::~ToolsGeneralWidget()
|
ToolsGeneralWidget::~ToolsGeneralWidget()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ToolsGeneralWidget::onToolsCurrentChanged()
|
||||||
|
{
|
||||||
|
if (mEditType != EditType::None) {
|
||||||
|
finishEditing(true);
|
||||||
|
}
|
||||||
|
QModelIndex index = ui->lstTools->currentIndex();
|
||||||
|
if (!index.isValid())
|
||||||
|
return;
|
||||||
|
PToolItem item = mToolsModel.getTool(index.row());
|
||||||
|
if (item) {
|
||||||
|
mEditType = EditType::Edit;
|
||||||
|
ui->txtDirectory->setText(item->workingDirectory);
|
||||||
|
ui->txtParameters->setText(item->parameters);
|
||||||
|
ui->txtProgram->setText(item->program);
|
||||||
|
ui->txtTitle->setText(item->title);
|
||||||
|
ui->chkPauseConsole->setChecked(item->pauseAfterExit);
|
||||||
|
ui->panelEdit->setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsGeneralWidget::finishEditing(bool askSave)
|
||||||
|
{
|
||||||
|
if (mEditType == EditType::None) {
|
||||||
|
ui->panelEdit->setVisible(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (askSave && QMessageBox::question(this,
|
||||||
|
tr("Save Changes?"),
|
||||||
|
tr("Do you want to save changes to the current tool?"),
|
||||||
|
QMessageBox::Yes | QMessageBox::No,
|
||||||
|
QMessageBox::Yes) != QMessageBox::Yes) {
|
||||||
|
ui->panelEdit->setVisible(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ui->panelEdit->setVisible(false);
|
||||||
|
if (mEditType == EditType::Add) {
|
||||||
|
mEditType = EditType::None;
|
||||||
|
PToolItem item = std::make_shared<ToolItem>();
|
||||||
|
item->title = ui->txtTitle->text();
|
||||||
|
item->program = ui->txtProgram->text();
|
||||||
|
item->workingDirectory = ui->txtDirectory->text();
|
||||||
|
item->parameters = ui->txtParameters->text();
|
||||||
|
item->pauseAfterExit = ui->chkPauseConsole->isChecked();
|
||||||
|
mToolsModel.addTool(item);
|
||||||
|
} else {
|
||||||
|
mEditType = EditType::None;
|
||||||
|
QModelIndex index = ui->lstTools->currentIndex();
|
||||||
|
if (!index.isValid())
|
||||||
|
return;
|
||||||
|
PToolItem item = mToolsModel.getTool(index.row());
|
||||||
|
item->workingDirectory = ui->txtDirectory->text();
|
||||||
|
item->parameters = ui->txtParameters->text();
|
||||||
|
item->program = ui->txtProgram->text();
|
||||||
|
item->title = ui->txtTitle->text();
|
||||||
|
item->pauseAfterExit = ui->chkPauseConsole->isChecked();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsGeneralWidget::prepareEdit()
|
||||||
|
{
|
||||||
|
ui->txtDirectory->setText("");
|
||||||
|
ui->txtParameters->setText("");
|
||||||
|
ui->txtProgram->setText("");
|
||||||
|
ui->txtTitle->setText("");
|
||||||
|
ui->chkPauseConsole->setChecked(false);
|
||||||
|
ui->panelEdit->setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsGeneralWidget::updateDemo()
|
||||||
|
{
|
||||||
|
ui->txtDemo->setText(
|
||||||
|
parseMacros(ui->txtProgram->text())+ " " +
|
||||||
|
parseMacros(ui->txtParameters->text()));
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolsModel::ToolsModel(QObject *parent):QAbstractListModel(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const QList<PToolItem> &ToolsModel::tools() const
|
||||||
|
{
|
||||||
|
return mTools;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsModel::setTools(const QList<PToolItem> &newTools)
|
||||||
|
{
|
||||||
|
beginResetModel();
|
||||||
|
mTools = newTools;
|
||||||
|
endResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsModel::addTool(PToolItem item)
|
||||||
|
{
|
||||||
|
beginInsertRows(QModelIndex(),mTools.count(),mTools.count());
|
||||||
|
mTools.append(item);
|
||||||
|
endInsertRows();
|
||||||
|
}
|
||||||
|
|
||||||
|
PToolItem ToolsModel::getTool(int index)
|
||||||
|
{
|
||||||
|
return mTools[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsModel::removeTool(int index)
|
||||||
|
{
|
||||||
|
mTools.removeAt(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ToolsModel::rowCount(const QModelIndex &) const
|
||||||
|
{
|
||||||
|
return mTools.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant ToolsModel::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
|
if (!index.isValid())
|
||||||
|
return QVariant();
|
||||||
|
if (role==Qt::DisplayRole) {
|
||||||
|
PToolItem item = mTools[index.row()];
|
||||||
|
return item->title;
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsGeneralWidget::on_btnAdd_clicked()
|
||||||
|
{
|
||||||
|
ui->lstTools->setCurrentIndex(QModelIndex());
|
||||||
|
prepareEdit();
|
||||||
|
mEditType = EditType::Add;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ToolsGeneralWidget::on_btnEditOk_clicked()
|
||||||
|
{
|
||||||
|
finishEditing(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ToolsGeneralWidget::on_btnEditCancel_clicked()
|
||||||
|
{
|
||||||
|
mEditType = EditType::None;
|
||||||
|
ui->panelEdit->setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsGeneralWidget::doLoad()
|
||||||
|
{
|
||||||
|
mToolsModel.setTools(pMainWindow->toolsManager()->tools());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsGeneralWidget::doSave()
|
||||||
|
{
|
||||||
|
finishEditing(true);
|
||||||
|
pMainWindow->toolsManager()->setTools(mToolsModel.tools());
|
||||||
|
pMainWindow->toolsManager()->save();
|
||||||
|
pMainWindow->updateTools();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ToolsGeneralWidget::on_btnRemove_clicked()
|
||||||
|
{
|
||||||
|
mEditType = EditType::None;
|
||||||
|
finishEditing(false);
|
||||||
|
QModelIndex index = ui->lstTools->currentIndex();
|
||||||
|
if (index.isValid()) {
|
||||||
|
mToolsModel.removeTool(index.row());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ToolsGeneralWidget::on_btnInsertMacro_clicked()
|
||||||
|
{
|
||||||
|
ui->txtParameters->setText(
|
||||||
|
ui->txtParameters->text() +
|
||||||
|
ui->cbMacros->currentData(Qt::UserRole).toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsGeneralWidget::on_btnBrowseWorkingDirectory_clicked()
|
||||||
|
{
|
||||||
|
QString folder = QFileDialog::getExistingDirectory(this,tr("Choose Folder"));
|
||||||
|
if (!folder.isEmpty()) {
|
||||||
|
ui->txtDirectory->setText(folder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ToolsGeneralWidget::on_btnBrowseProgram_clicked()
|
||||||
|
{
|
||||||
|
QString fileName = QFileDialog::getOpenFileName(
|
||||||
|
this,
|
||||||
|
tr("Select program"),
|
||||||
|
pSettings->dirs().app(),
|
||||||
|
tr("Executable files (*.exe)"));
|
||||||
|
if (!fileName.isEmpty() ) {
|
||||||
|
ui->txtProgram->setText(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,78 @@
|
||||||
#ifndef TOOLSGENERALWIDGET_H
|
#ifndef TOOLSGENERALWIDGET_H
|
||||||
#define TOOLSGENERALWIDGET_H
|
#define TOOLSGENERALWIDGET_H
|
||||||
|
|
||||||
|
#include <QAbstractListModel>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include "settingswidget.h"
|
||||||
|
#include "../widgets/macroinfomodel.h"
|
||||||
|
#include "../toolsmanager.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class ToolsGeneralWidget;
|
class ToolsGeneralWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ToolsGeneralWidget : public QWidget
|
class ToolsModel: public QAbstractListModel {
|
||||||
|
public:
|
||||||
|
explicit ToolsModel(QObject* parent = nullptr);
|
||||||
|
|
||||||
|
const QList<PToolItem> &tools() const;
|
||||||
|
void setTools(const QList<PToolItem> &newTools);
|
||||||
|
void addTool(PToolItem item);
|
||||||
|
PToolItem getTool(int index);
|
||||||
|
void removeTool(int index);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QList<PToolItem> mTools;
|
||||||
|
|
||||||
|
// QAbstractItemModel interface
|
||||||
|
public:
|
||||||
|
int rowCount(const QModelIndex &parent) const override;
|
||||||
|
QVariant data(const QModelIndex &index, int role) const override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class ToolsGeneralWidget : public SettingsWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ToolsGeneralWidget(QWidget *parent = nullptr);
|
enum class EditType {
|
||||||
|
Add,
|
||||||
|
Edit,
|
||||||
|
None
|
||||||
|
};
|
||||||
|
explicit ToolsGeneralWidget(const QString& name, const QString& group, QWidget *parent = nullptr);
|
||||||
~ToolsGeneralWidget();
|
~ToolsGeneralWidget();
|
||||||
|
private:
|
||||||
|
void onToolsCurrentChanged();
|
||||||
|
private:
|
||||||
|
void finishEditing(bool askSave);
|
||||||
|
void prepareEdit();
|
||||||
|
private slots:
|
||||||
|
void updateDemo();
|
||||||
|
void on_btnAdd_clicked();
|
||||||
|
|
||||||
|
void on_btnEditOk_clicked();
|
||||||
|
|
||||||
|
void on_btnEditCancel_clicked();
|
||||||
|
|
||||||
|
void on_btnRemove_clicked();
|
||||||
|
|
||||||
|
void on_btnInsertMacro_clicked();
|
||||||
|
|
||||||
|
void on_btnBrowseWorkingDirectory_clicked();
|
||||||
|
|
||||||
|
void on_btnBrowseProgram_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ToolsGeneralWidget *ui;
|
Ui::ToolsGeneralWidget *ui;
|
||||||
|
MacroInfoModel mMacroInfoModel;
|
||||||
|
ToolsModel mToolsModel;
|
||||||
|
EditType mEditType;
|
||||||
|
|
||||||
|
// SettingsWidget interface
|
||||||
|
protected:
|
||||||
|
void doLoad() override;
|
||||||
|
void doSave() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TOOLSGENERALWIDGET_H
|
#endif // TOOLSGENERALWIDGET_H
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>833</width>
|
<width>833</width>
|
||||||
<height>300</height>
|
<height>437</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -68,13 +68,40 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" name="widget_2" native="true">
|
<widget class="QWidget" name="widget_5" native="true">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListView" name="listView"/>
|
<widget class="QListView" name="lstTools"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="frame">
|
<widget class="QWidget" name="panelEdit" native="true">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QFrame" name="frmEdit">
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<enum>QFrame::StyledPanel</enum>
|
||||||
</property>
|
</property>
|
||||||
|
@ -82,9 +109,119 @@
|
||||||
<enum>QFrame::Raised</enum>
|
<enum>QFrame::Raised</enum>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QToolButton" name="btnBrowseProgram">
|
||||||
|
<property name="text">
|
||||||
|
<string>Browse</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../icons.qrc">
|
||||||
|
<normaloff>:/icons/images/newlook24/053-open.png</normaloff>:/icons/images/newlook24/053-open.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Parameters</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1" colspan="2">
|
||||||
|
<widget class="QLineEdit" name="txtTitle"/>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0" colspan="3">
|
||||||
|
<widget class="QLineEdit" name="txtDemo">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="0" colspan="3">
|
||||||
|
<widget class="QWidget" name="widget_3" native="true">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<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="QPushButton" name="btnEditOk">
|
||||||
|
<property name="text">
|
||||||
|
<string>Ok</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btnEditCancel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Cancel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLineEdit" name="txtDirectory"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QToolButton" name="btnBrowseWorkingDirectory">
|
||||||
|
<property name="text">
|
||||||
|
<string>Browse</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../icons.qrc">
|
||||||
|
<normaloff>:/icons/images/newlook24/053-open.png</normaloff>:/icons/images/newlook24/053-open.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLineEdit" name="txtProgram"/>
|
||||||
|
</item>
|
||||||
<item row="3" column="1" colspan="2">
|
<item row="3" column="1" colspan="2">
|
||||||
<widget class="QLineEdit" name="txtParameters"/>
|
<widget class="QLineEdit" name="txtParameters"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Title</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0" colspan="3">
|
||||||
|
<widget class="QCheckBox" name="chkPauseConsole">
|
||||||
|
<property name="text">
|
||||||
|
<string>Pause console after the program exit</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -99,74 +236,62 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="7" column="0" colspan="3">
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QWidget" name="widget_2" native="true">
|
||||||
<property name="text">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
<string>Parameters</string>
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="topMargin">
|
||||||
</item>
|
<number>0</number>
|
||||||
<item row="0" column="1" colspan="2">
|
|
||||||
<widget class="QLineEdit" name="txtTitle"/>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>Title</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="rightMargin">
|
||||||
</item>
|
<number>0</number>
|
||||||
<item row="1" column="2">
|
|
||||||
<widget class="QToolButton" name="toolButton_3">
|
|
||||||
<property name="text">
|
|
||||||
<string>Browse</string>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="bottomMargin">
|
||||||
<iconset resource="../icons.qrc">
|
<number>0</number>
|
||||||
<normaloff>:/icons/images/newlook24/053-open.png</normaloff>:/icons/images/newlook24/053-open.png</iconset>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<item>
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QLineEdit" name="txtProgram"/>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QLineEdit" name="txtDirectory"/>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="2">
|
|
||||||
<widget class="QToolButton" name="toolButton_4">
|
|
||||||
<property name="text">
|
|
||||||
<string>Browse</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="../icons.qrc">
|
|
||||||
<normaloff>:/icons/images/newlook24/053-open.png</normaloff>:/icons/images/newlook24/053-open.png</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0" colspan="3">
|
|
||||||
<widget class="QCheckBox" name="chkPauseConsole">
|
|
||||||
<property name="text">
|
|
||||||
<string>Pause console after the program exit</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="0" colspan="3">
|
|
||||||
<widget class="QLineEdit" name="txtDemo">
|
|
||||||
<property name="readOnly">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="6" column="0">
|
|
||||||
<widget class="QPushButton" name="btnInsertMacro">
|
<widget class="QPushButton" name="btnInsertMacro">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Insert Macro</string>
|
<string>Insert Macro</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="1" colspan="2">
|
<item>
|
||||||
<widget class="QComboBox" name="cbMacros"/>
|
<widget class="QComboBox" name="cbMacros">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="editable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="sizeAdjustPolicy">
|
||||||
|
<enum>QComboBox::AdjustToContents</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#define DEV_CODESNIPPET_FILE "codesnippets.json"
|
#define DEV_CODESNIPPET_FILE "codesnippets.json"
|
||||||
#define DEV_AUTOLINK_FILE "autolink.json"
|
#define DEV_AUTOLINK_FILE "autolink.json"
|
||||||
#define DEV_SHORTCUT_FILE "shortcuts.json"
|
#define DEV_SHORTCUT_FILE "shortcuts.json"
|
||||||
|
#define DEV_TOOLS_FILE "tools.json"
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
# define PATH_SENSITIVITY Qt::CaseInsensitive
|
# define PATH_SENSITIVITY Qt::CaseInsensitive
|
||||||
|
|
|
@ -0,0 +1,111 @@
|
||||||
|
#include "toolsmanager.h"
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QJsonArray>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include "settings.h"
|
||||||
|
#include "systemconsts.h"
|
||||||
|
|
||||||
|
ToolsManager::ToolsManager(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsManager::load()
|
||||||
|
{
|
||||||
|
//if config file not exists, copy it from data
|
||||||
|
QString filename = includeTrailingPathDelimiter(pSettings->dirs().config()) + DEV_TOOLS_FILE;
|
||||||
|
if (!fileExists(filename))
|
||||||
|
return;
|
||||||
|
//read config file
|
||||||
|
QFile file(filename);
|
||||||
|
if (!file.open(QFile::ReadOnly)) {
|
||||||
|
QMessageBox::critical(nullptr,
|
||||||
|
tr("Read tools config failed"),
|
||||||
|
tr("Can't open tools config file '%1' for read.")
|
||||||
|
.arg(filename));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray json = file.readAll();
|
||||||
|
QJsonParseError error;
|
||||||
|
QJsonDocument doc = QJsonDocument::fromJson(json,&error);
|
||||||
|
if (error.error != QJsonParseError::NoError) {
|
||||||
|
QMessageBox::critical(nullptr,
|
||||||
|
tr("Read tools config failed"),
|
||||||
|
tr("Read tools config file '%1' failed:%2")
|
||||||
|
.arg(filename)
|
||||||
|
.arg(error.errorString()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mTools.clear();
|
||||||
|
QJsonArray array = doc.array();
|
||||||
|
foreach (const QJsonValue& value,array) {
|
||||||
|
QJsonObject object = value.toObject();
|
||||||
|
PToolItem item = std::make_shared<ToolItem>();
|
||||||
|
item->title = object["title"].toString();
|
||||||
|
if (item->title.isEmpty())
|
||||||
|
continue;
|
||||||
|
item->program = object["program"].toString();
|
||||||
|
item->workingDirectory = object["workingDirectory"].toString();
|
||||||
|
item->parameters = object["parameters"].toString();
|
||||||
|
item->pauseAfterExit = object["pauseAfterExit"].toBool();
|
||||||
|
mTools.append(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsManager::save()
|
||||||
|
{
|
||||||
|
QString filename = includeTrailingPathDelimiter(pSettings->dirs().config()) + DEV_TOOLS_FILE;
|
||||||
|
QFile file(filename);
|
||||||
|
if (!file.open(QFile::WriteOnly | QFile::Truncate)) {
|
||||||
|
QMessageBox::critical(nullptr,
|
||||||
|
tr("Save tools config failed"),
|
||||||
|
tr("Can't open tools config file '%1' for write.")
|
||||||
|
.arg(filename));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QJsonArray array;
|
||||||
|
foreach (const PToolItem& tool,mTools) {
|
||||||
|
QJsonObject object;
|
||||||
|
object["title"]=tool->title;
|
||||||
|
object["program"]=tool->program;
|
||||||
|
object["workingDirectory"] = tool->workingDirectory;
|
||||||
|
object["parameters"]=tool->parameters;
|
||||||
|
object["pauseAfterExit"]=tool->pauseAfterExit;
|
||||||
|
array.append(object);
|
||||||
|
}
|
||||||
|
QJsonDocument doc;
|
||||||
|
doc.setArray(array);
|
||||||
|
if (file.write(doc.toJson())<0) {
|
||||||
|
QMessageBox::critical(nullptr,
|
||||||
|
tr("Save tool config failed"),
|
||||||
|
tr("Write to tool config file '%1' failed.")
|
||||||
|
.arg(filename));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const QList<PToolItem> &ToolsManager::tools() const
|
||||||
|
{
|
||||||
|
return mTools;
|
||||||
|
}
|
||||||
|
|
||||||
|
PToolItem ToolsManager::findTool(const QString &title)
|
||||||
|
{
|
||||||
|
for (int i=0;i<mTools.count();i++) {
|
||||||
|
PToolItem item = mTools[i];
|
||||||
|
if (title == item->title) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return PToolItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsManager::setTools(const QList<PToolItem> &newTools)
|
||||||
|
{
|
||||||
|
mTools = newTools;
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
#ifndef TOOLSMANAGER_H
|
||||||
|
#define TOOLSMANAGER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
struct ToolItem {
|
||||||
|
QString title;
|
||||||
|
QString program;
|
||||||
|
QString workingDirectory;
|
||||||
|
QString parameters;
|
||||||
|
bool pauseAfterExit;
|
||||||
|
};
|
||||||
|
|
||||||
|
using PToolItem = std::shared_ptr<ToolItem>;
|
||||||
|
|
||||||
|
class ToolsManager : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit ToolsManager(QObject *parent = nullptr);
|
||||||
|
void load();
|
||||||
|
void save();
|
||||||
|
const QList<PToolItem> &tools() const;
|
||||||
|
PToolItem findTool(const QString& title);
|
||||||
|
void setTools(const QList<PToolItem> &newTools);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
private:
|
||||||
|
QList<PToolItem> mTools;
|
||||||
|
};
|
||||||
|
|
||||||
|
using PToolsManager = std::shared_ptr<ToolsManager>;
|
||||||
|
|
||||||
|
#endif // TOOLSMANAGER_H
|
|
@ -748,8 +748,8 @@ QString parseMacros(const QString &s)
|
||||||
QString result = s;
|
QString result = s;
|
||||||
Editor *e = pMainWindow->editorList()->getEditor();
|
Editor *e = pMainWindow->editorList()->getEditor();
|
||||||
|
|
||||||
result.replace("<DEFAULT>", pSettings->dirs().app());
|
result.replace("<DEFAULT>", QDir().absolutePath());
|
||||||
result.replace("<DEVCPP>", pSettings->dirs().app());
|
result.replace("<DEVCPP>", pSettings->dirs().executable());
|
||||||
result.replace("<DEVCPPVERSION>", DEVCPP_VERSION);
|
result.replace("<DEVCPPVERSION>", DEVCPP_VERSION);
|
||||||
result.replace("<EXECPATH>", pSettings->dirs().app());
|
result.replace("<EXECPATH>", pSettings->dirs().app());
|
||||||
QDate today = QDate::currentDate();
|
QDate today = QDate::currentDate();
|
||||||
|
@ -780,19 +780,19 @@ QString parseMacros(const QString &s)
|
||||||
result.replace("<PROJECTFILE>", pMainWindow->project()->filename());
|
result.replace("<PROJECTFILE>", pMainWindow->project()->filename());
|
||||||
result.replace("<PROJECTPATH>", pMainWindow->project()->directory());
|
result.replace("<PROJECTPATH>", pMainWindow->project()->directory());
|
||||||
// result.replace("<SOURCESPCLIST>', MainForm.Project.ListUnitStr(' '));
|
// result.replace("<SOURCESPCLIST>', MainForm.Project.ListUnitStr(' '));
|
||||||
result.replace("<SOURCESPCLIST>","");
|
// result.replace("<SOURCESPCLIST>","");
|
||||||
} else if (e!=nullptr) { // Non-project editor macros
|
} else if (e!=nullptr) { // Non-project editor macros
|
||||||
result.replace("<EXENAME>", changeFileExt(e->filename(),EXECUTABLE_EXT));
|
result.replace("<EXENAME>", changeFileExt(e->filename(),EXECUTABLE_EXT));
|
||||||
result.replace("<PROJECTNAME>",e->filename());
|
result.replace("<PROJECTNAME>", extractFileName(e->filename()));
|
||||||
result.replace("<PROJECTFILE>",e->filename());
|
result.replace("<PROJECTFILE>",e->filename());
|
||||||
result.replace("<PROJECTPATH>", extractFileDir(e->filename()));
|
result.replace("<PROJECTPATH>", extractFileDir(e->filename()));
|
||||||
result.replace("<SOURCESPCLIST>", ""); // clear unchanged macros
|
// result.replace("<SOURCESPCLIST>", ""); // clear unchanged macros
|
||||||
} else {
|
} else {
|
||||||
result.replace("<EXENAME>", "");
|
result.replace("<EXENAME>", "");
|
||||||
result.replace("<PROJECTNAME>", "");
|
result.replace("<PROJECTNAME>", "");
|
||||||
result.replace("<PROJECTFILE>", "");
|
result.replace("<PROJECTFILE>", "");
|
||||||
result.replace("<PROJECTPATH>", "");
|
result.replace("<PROJECTPATH>", "");
|
||||||
result.replace("<SOURCESPCLIST>", ""); // clear unchanged macros
|
// result.replace("<SOURCESPCLIST>", ""); // clear unchanged macros
|
||||||
}
|
}
|
||||||
|
|
||||||
// Editor macros
|
// Editor macros
|
||||||
|
@ -809,3 +809,14 @@ QString parseMacros(const QString &s)
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void executeFile(const QString &fileName, const QString ¶ms, const QString &workingDir)
|
||||||
|
{
|
||||||
|
ShellExecuteA(NULL,
|
||||||
|
NULL,
|
||||||
|
fileName.toLocal8Bit(),
|
||||||
|
params.toLocal8Bit(),
|
||||||
|
workingDir.toLocal8Bit(),
|
||||||
|
SW_SHOW
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
@ -121,6 +121,8 @@ QByteArray runAndGetOutput(const QString& cmd, const QString& workingDir, const
|
||||||
const QByteArray& inputContent = QByteArray(),
|
const QByteArray& inputContent = QByteArray(),
|
||||||
bool inheritEnvironment = false);
|
bool inheritEnvironment = false);
|
||||||
|
|
||||||
|
void executeFile(const QString& fileName, const QString& params, const QString& workingDir);
|
||||||
|
|
||||||
bool isNonPrintableAsciiChar(char ch);
|
bool isNonPrintableAsciiChar(char ch);
|
||||||
|
|
||||||
bool fileExists(const QString& file);
|
bool fileExists(const QString& file);
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
#include "macroinfomodel.h"
|
||||||
|
|
||||||
|
MacroInfoModel::MacroInfoModel(QObject *parent) : QAbstractListModel(parent)
|
||||||
|
{
|
||||||
|
addMacroInfo("<Default>", tr("The default directory"));
|
||||||
|
addMacroInfo("<DEVCPP>", tr("Path to the Red Panda C++'s executable file."));
|
||||||
|
addMacroInfo("<DEVCPPVERSION>", tr("Version of the Red Panda C++"));
|
||||||
|
addMacroInfo("<EXECPATH>", tr("PATH to the Red Panda C++'s installation folder."));
|
||||||
|
addMacroInfo("<DATE>", tr("Current date"));
|
||||||
|
addMacroInfo("<DATETIME>", tr("Current date and time"));
|
||||||
|
addMacroInfo("<INCLUDE>", tr("The first include directory of the working compiler set."));
|
||||||
|
addMacroInfo("<LIB>", tr("The first lib directory of the working compiler set."));
|
||||||
|
addMacroInfo("<EXENAME>", tr("The compiled filename"));
|
||||||
|
addMacroInfo("<SOURCENAME>", tr("Filename of the current source file"));
|
||||||
|
addMacroInfo("<SOURCEFILE>", tr("Full path to the current source file"));
|
||||||
|
addMacroInfo("<SOURCEPATH>", tr("Path to the current source file's parent folder"));
|
||||||
|
addMacroInfo("<WORDXY>", tr("Word at the cursor in the active editor"));
|
||||||
|
addMacroInfo("<PROJECTNAME>", tr("Name of the current project"));
|
||||||
|
addMacroInfo("<PROJECTFILE>", tr("Full path to the current project file"));
|
||||||
|
addMacroInfo("<PROJECTPATH>", tr("Path to the current project's folder"));
|
||||||
|
}
|
||||||
|
|
||||||
|
int MacroInfoModel::rowCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
return mMacroInfos.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant MacroInfoModel::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
|
if (!index.isValid())
|
||||||
|
return QVariant();
|
||||||
|
if (role == Qt::DisplayRole) {
|
||||||
|
PMacroInfo info = mMacroInfos[index.row()];
|
||||||
|
return info->description;
|
||||||
|
} else if (role == Qt::UserRole) {
|
||||||
|
PMacroInfo info = mMacroInfos[index.row()];
|
||||||
|
return info->macro;
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
PMacroInfo MacroInfoModel::getInfo(const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
if (!index.isValid())
|
||||||
|
return PMacroInfo();
|
||||||
|
return mMacroInfos[index.row()];
|
||||||
|
}
|
||||||
|
|
||||||
|
void MacroInfoModel::addMacroInfo(const QString& macro, const QString& description) {
|
||||||
|
PMacroInfo info = std::make_shared<MacroInfo>();
|
||||||
|
info->macro = macro;
|
||||||
|
info->description = description;
|
||||||
|
mMacroInfos.append(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
#ifndef MACROINFOMODEL_H
|
||||||
|
#define MACROINFOMODEL_H
|
||||||
|
|
||||||
|
#include <QAbstractListModel>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
struct MacroInfo {
|
||||||
|
QString macro;
|
||||||
|
QString description;
|
||||||
|
};
|
||||||
|
|
||||||
|
using PMacroInfo = std::shared_ptr<MacroInfo>;
|
||||||
|
|
||||||
|
class MacroInfoModel: public QAbstractListModel{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit MacroInfoModel(QObject* parent = nullptr);
|
||||||
|
|
||||||
|
// QAbstractItemModel interface
|
||||||
|
public:
|
||||||
|
int rowCount(const QModelIndex &parent) const override;
|
||||||
|
QVariant data(const QModelIndex &index, int role) const override;
|
||||||
|
PMacroInfo getInfo(const QModelIndex& index) const;
|
||||||
|
private:
|
||||||
|
void addMacroInfo(const QString& macro, const QString& description);
|
||||||
|
private:
|
||||||
|
QList<PMacroInfo> mMacroInfos;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MACROINFOMODEL_H
|
Loading…
Reference in New Issue