Create/Open system breakpoint script
This commit is contained in:
parent
4a924d320a
commit
83db837b66
|
@ -3,8 +3,11 @@
|
|||
#include "Bridge.h"
|
||||
#include "Configuration.h"
|
||||
#include <QDirModel>
|
||||
#include <QFile>
|
||||
#include <QFileDialog>
|
||||
#include <QDesktopServices>
|
||||
#include <QCompleter>
|
||||
#include <QMessageBox>
|
||||
|
||||
SystemBreakpointScriptDialog::SystemBreakpointScriptDialog(QWidget* parent) :
|
||||
QDialog(parent),
|
||||
|
@ -43,6 +46,11 @@ SystemBreakpointScriptDialog::SystemBreakpointScriptDialog(QWidget* parent) :
|
|||
ui->groupBoxDebuggee->setEnabled(false);
|
||||
}
|
||||
|
||||
if(ui->lineEditGlobal->text().isEmpty())
|
||||
ui->openGlobal->setText(tr("Create"));
|
||||
if(ui->lineEditDebuggee->text().isEmpty())
|
||||
ui->openDebuggee->setText(tr("Create"));
|
||||
|
||||
Config()->setupWindowPos(this);
|
||||
}
|
||||
|
||||
|
@ -56,6 +64,10 @@ void SystemBreakpointScriptDialog::on_pushButtonGlobal_clicked()
|
|||
QString file = QFileDialog::getOpenFileName(this, ui->groupBoxGlobal->title(), ui->lineEditGlobal->text(), tr("Script files (*.txt *.scr);;All files (*.*)"));
|
||||
if(!file.isEmpty())
|
||||
ui->lineEditGlobal->setText(QDir::toNativeSeparators(file));
|
||||
if(ui->lineEditGlobal->text().isEmpty())
|
||||
ui->openGlobal->setText(tr("Create"));
|
||||
else
|
||||
ui->openGlobal->setText(tr("Open"));
|
||||
}
|
||||
|
||||
void SystemBreakpointScriptDialog::on_pushButtonDebuggee_clicked()
|
||||
|
@ -63,6 +75,74 @@ void SystemBreakpointScriptDialog::on_pushButtonDebuggee_clicked()
|
|||
QString file = QFileDialog::getOpenFileName(this, ui->groupBoxDebuggee->title(), ui->lineEditDebuggee->text(), tr("Script files (*.txt *.scr);;All files (*.*)"));
|
||||
if(!file.isEmpty())
|
||||
ui->lineEditDebuggee->setText(QDir::toNativeSeparators(file));
|
||||
if(ui->lineEditDebuggee->text().isEmpty())
|
||||
ui->openDebuggee->setText(tr("Create"));
|
||||
else
|
||||
ui->openDebuggee->setText(tr("Open"));
|
||||
}
|
||||
|
||||
void SystemBreakpointScriptDialog::on_openGlobal_clicked()
|
||||
{
|
||||
// First open the script if that is available
|
||||
if(!ui->lineEditGlobal->text().isEmpty())
|
||||
QDesktopServices::openUrl(QUrl(QDir::fromNativeSeparators(ui->lineEditGlobal->text())));
|
||||
else
|
||||
{
|
||||
// Ask the user to create a new script
|
||||
QMessageBox msgyn(QMessageBox::Question, tr("File not found"), tr("Would you like to create a new script?"), QMessageBox::Yes | QMessageBox::No, this);
|
||||
if(msgyn.exec() == QMessageBox::Yes)
|
||||
{
|
||||
// The new script is at app dir
|
||||
QString defaultFileName("autorun.txt");
|
||||
defaultFileName = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + QDir::separator() + defaultFileName);
|
||||
// Create it
|
||||
if(!QFile::exists(defaultFileName))
|
||||
{
|
||||
QFile newScript(defaultFileName);
|
||||
newScript.open(QFile::NewOnly);
|
||||
newScript.close();
|
||||
}
|
||||
ui->lineEditGlobal->setText(defaultFileName);
|
||||
ui->openGlobal->setText(tr("Open"));
|
||||
// Open the file
|
||||
QDesktopServices::openUrl(QUrl(QDir::fromNativeSeparators(ui->lineEditGlobal->text())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SystemBreakpointScriptDialog::on_openDebuggee_clicked()
|
||||
{
|
||||
// First open the script if that is available
|
||||
if(!ui->lineEditDebuggee->text().isEmpty())
|
||||
QDesktopServices::openUrl(QUrl(QDir::fromNativeSeparators(ui->lineEditDebuggee->text())));
|
||||
else
|
||||
{
|
||||
// Ask the user to create a new script
|
||||
QMessageBox msgyn(QMessageBox::Question, tr("File not found"), tr("Would you like to create a new script?"), QMessageBox::Yes | QMessageBox::No, this);
|
||||
if(msgyn.exec() == QMessageBox::Yes)
|
||||
{
|
||||
// The new script is at db dir
|
||||
QString defaultFileName;
|
||||
char moduleName[MAX_MODULE_SIZE];
|
||||
if(DbgFunctions()->ModNameFromAddr(DbgValFromString("mod.main()"), moduleName, false))
|
||||
{
|
||||
defaultFileName = QString::fromUtf8(moduleName);
|
||||
}
|
||||
defaultFileName = defaultFileName + ".autorun.txt";
|
||||
defaultFileName = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + QDir::separator() + "db" + QDir::separator() + defaultFileName);
|
||||
// Create it
|
||||
if(!QFile::exists(defaultFileName))
|
||||
{
|
||||
QFile newScript(defaultFileName);
|
||||
newScript.open(QFile::NewOnly);
|
||||
newScript.close();
|
||||
}
|
||||
ui->lineEditDebuggee->setText(defaultFileName);
|
||||
ui->openDebuggee->setText(tr("Open"));
|
||||
// Open the file
|
||||
QDesktopServices::openUrl(QUrl(QDir::fromNativeSeparators(ui->lineEditDebuggee->text())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SystemBreakpointScriptDialog::on_SystemBreakpointScriptDialog_accepted()
|
||||
|
|
|
@ -18,6 +18,8 @@ public:
|
|||
private slots:
|
||||
void on_pushButtonGlobal_clicked();
|
||||
void on_pushButtonDebuggee_clicked();
|
||||
void on_openGlobal_clicked();
|
||||
void on_openDebuggee_clicked();
|
||||
void on_SystemBreakpointScriptDialog_accepted();
|
||||
|
||||
private:
|
||||
|
|
|
@ -41,6 +41,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="openGlobal">
|
||||
<property name="text">
|
||||
<string>Open</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -67,6 +74,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="openDebuggee">
|
||||
<property name="text">
|
||||
<string>Open</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Loading…
Reference in New Issue