GUI: start with the exception range
This commit is contained in:
parent
a4d3470897
commit
dce8ddcac7
|
@ -25,7 +25,7 @@ extern "C"
|
|||
#endif
|
||||
|
||||
//Bridge defines
|
||||
#define MAX_SETTING_SIZE 2048
|
||||
#define MAX_SETTING_SIZE 65536
|
||||
|
||||
//Bridge functions
|
||||
BRIDGE_IMPEXP const char* BridgeInit();
|
||||
|
|
|
@ -58,7 +58,8 @@ SOURCES += \
|
|||
Src/BasicView/SearchListView.cpp \
|
||||
Src/BasicView/ReferenceView.cpp \
|
||||
Src/BasicView/ThreadView.cpp \
|
||||
Src/Gui/SettingsDialog.cpp
|
||||
Src/Gui/SettingsDialog.cpp \
|
||||
Src/Gui/ExceptionRangeDialog.cpp
|
||||
|
||||
|
||||
HEADERS += \
|
||||
|
@ -97,7 +98,8 @@ HEADERS += \
|
|||
Src/BasicView/SearchListView.h \
|
||||
Src/BasicView/ReferenceView.h \
|
||||
Src/BasicView/ThreadView.h \
|
||||
Src/Gui/SettingsDialog.h
|
||||
Src/Gui/SettingsDialog.h \
|
||||
Src/Gui/ExceptionRangeDialog.h
|
||||
|
||||
INCLUDEPATH += \
|
||||
Src \
|
||||
|
@ -120,7 +122,8 @@ FORMS += \
|
|||
Src/BasicView/LineEditDialog.ui \
|
||||
Src/BasicView/SymbolView.ui \
|
||||
Src/BasicView/SearchListView.ui \
|
||||
Src/Gui/SettingsDialog.ui
|
||||
Src/Gui/SettingsDialog.ui \
|
||||
Src/Gui/ExceptionRangeDialog.ui
|
||||
|
||||
INCLUDEPATH += $$PWD/Src/Bridge
|
||||
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
#include "ExceptionRangeDialog.h"
|
||||
#include "ui_ExceptionRangeDialog.h"
|
||||
|
||||
ExceptionRangeDialog::ExceptionRangeDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::ExceptionRangeDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
//set window flags
|
||||
setModal(true);
|
||||
setWindowFlags(Qt::Dialog | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
|
||||
setFixedSize(this->size()); //fixed size
|
||||
ui->editStart->setCursorPosition(0);
|
||||
ui->editEnd->setCursorPosition(0);
|
||||
ui->btnOk->setEnabled(false);
|
||||
}
|
||||
|
||||
ExceptionRangeDialog::~ExceptionRangeDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ExceptionRangeDialog::on_editStart_textChanged(const QString &arg1)
|
||||
{
|
||||
if(!ui->editStart->text().size()) //nothing entered
|
||||
{
|
||||
ui->btnOk->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
bool converted=false;
|
||||
unsigned long start=ui->editStart->text().toLong(&converted, 16);
|
||||
if(!converted)
|
||||
{
|
||||
ui->btnOk->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
unsigned long end=ui->editEnd->text().toLong(&converted, 16);
|
||||
if(converted && end<start)
|
||||
ui->btnOk->setEnabled(false);
|
||||
else
|
||||
ui->btnOk->setEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
void ExceptionRangeDialog::on_editEnd_textChanged(const QString &arg1)
|
||||
{
|
||||
if(!ui->editEnd->text().size() || !ui->editStart->text().size())
|
||||
{
|
||||
ui->btnOk->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
bool converted=false;
|
||||
unsigned long start=ui->editStart->text().toLong(&converted, 16);
|
||||
if(!converted)
|
||||
{
|
||||
ui->btnOk->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
unsigned long end=ui->editEnd->text().toLong(&converted, 16);
|
||||
if(!converted)
|
||||
{
|
||||
ui->btnOk->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
if(end<start)
|
||||
ui->btnOk->setEnabled(false);
|
||||
else
|
||||
ui->btnOk->setEnabled(true);
|
||||
}
|
||||
|
||||
void ExceptionRangeDialog::on_btnOk_clicked()
|
||||
{
|
||||
rangeStart=ui->editStart->text().toLong(0, 16);
|
||||
bool converted=false;
|
||||
rangeEnd=ui->editEnd->text().toLong(&converted, 16);
|
||||
if(!converted)
|
||||
rangeEnd=rangeStart;
|
||||
accept();
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
#ifndef EXCEPTIONRANGEDIALOG_H
|
||||
#define EXCEPTIONRANGEDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class ExceptionRangeDialog;
|
||||
}
|
||||
|
||||
class ExceptionRangeDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ExceptionRangeDialog(QWidget *parent = 0);
|
||||
~ExceptionRangeDialog();
|
||||
|
||||
unsigned long rangeStart;
|
||||
unsigned long rangeEnd;
|
||||
|
||||
private slots:
|
||||
void on_editStart_textChanged(const QString &arg1);
|
||||
void on_editEnd_textChanged(const QString &arg1);
|
||||
void on_btnOk_clicked();
|
||||
|
||||
private:
|
||||
Ui::ExceptionRangeDialog *ui;
|
||||
};
|
||||
|
||||
#endif // EXCEPTIONRANGEDIALOG_H
|
|
@ -0,0 +1,163 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ExceptionRangeDialog</class>
|
||||
<widget class="QDialog" name="ExceptionRangeDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>131</width>
|
||||
<height>106</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Range</string>
|
||||
</property>
|
||||
<widget class="QLineEdit" name="editStart">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>10</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Courier New</family>
|
||||
</font>
|
||||
</property>
|
||||
<property name="inputMask">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="editEnd">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>40</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Courier New</family>
|
||||
</font>
|
||||
</property>
|
||||
<property name="inputMask">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="lblStart">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>31</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="lblEnd">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>31</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>End:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>70</y>
|
||||
<width>111</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="layoutButtons">
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnOk">
|
||||
<property name="text">
|
||||
<string>OK</string>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnCancel">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>btnCancel</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>ExceptionRangeDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>95</x>
|
||||
<y>86</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>96</x>
|
||||
<y>64</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -45,6 +45,7 @@ void SettingsDialog::LoadSettings()
|
|||
settings.eventEntryBreakpoint=true;
|
||||
settings.engineCalcType=calc_unsigned;
|
||||
settings.engineBreakpointType=break_int3short;
|
||||
settings.exceptionRanges=&realExceptionRanges;
|
||||
|
||||
//Events tab
|
||||
GetSettingBool("Events", "SystemBreakpoint", &settings.eventSystemBreakpoint);
|
||||
|
@ -112,6 +113,25 @@ void SettingsDialog::LoadSettings()
|
|||
ui->radioUd2->setChecked(true);
|
||||
break;
|
||||
}
|
||||
|
||||
//Exceptions tab
|
||||
char exceptionRange[MAX_SETTING_SIZE]="";
|
||||
if(BridgeSettingGet("Exceptions", "IgnoreRange", exceptionRange))
|
||||
{
|
||||
QStringList ranges=QString(exceptionRange).split(QString(","), QString::SkipEmptyParts);
|
||||
for(int i=0; i<ranges.size(); i++)
|
||||
{
|
||||
unsigned long start;
|
||||
unsigned long end;
|
||||
if(sscanf(ranges.at(i).toUtf8().constData(), "%.8X-%.8X", &start, &end)==2 && start<end)
|
||||
{
|
||||
RangeStruct newRange;
|
||||
newRange.start=start;
|
||||
newRange.end=end;
|
||||
AddRangeToList(newRange);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsDialog::SaveSettings()
|
||||
|
@ -131,6 +151,42 @@ void SettingsDialog::SaveSettings()
|
|||
//Engine tab
|
||||
BridgeSettingSetUint("Engine", "CalculationType", settings.engineCalcType);
|
||||
BridgeSettingSetUint("Engine", "BreakpointType", settings.engineBreakpointType);
|
||||
|
||||
//Exceptions tab
|
||||
QString exceptionRange="";
|
||||
for(int i=0; i<settings.exceptionRanges->size(); i++)
|
||||
exceptionRange.append(QString().sprintf("%.8X-%.8X", settings.exceptionRanges->at(i).start, settings.exceptionRanges->at(i).end)+QString(","));
|
||||
exceptionRange.chop(1); //remove last comma
|
||||
if(exceptionRange.size())
|
||||
BridgeSettingSet("Exceptions", "IgnoreRange", exceptionRange.toUtf8().constData());
|
||||
}
|
||||
|
||||
void SettingsDialog::AddRangeToList(RangeStruct range)
|
||||
{
|
||||
//check range
|
||||
unsigned long start=range.start;
|
||||
unsigned long end=range.end;
|
||||
|
||||
for(int i=settings.exceptionRanges->size()-1; i>-1; i--)
|
||||
{
|
||||
unsigned long curStart=settings.exceptionRanges->at(i).start;
|
||||
unsigned long curEnd=settings.exceptionRanges->at(i).end;
|
||||
if(curStart<=end && curEnd>=start) //ranges overlap
|
||||
{
|
||||
if(curStart<start) //extend range to the left
|
||||
start=curStart;
|
||||
if(curEnd>end) //extend range to the right
|
||||
end=curEnd;
|
||||
settings.exceptionRanges->erase(settings.exceptionRanges->begin()+i); //remove old range
|
||||
}
|
||||
}
|
||||
range.start=start;
|
||||
range.end=end;
|
||||
settings.exceptionRanges->push_back(range);
|
||||
qSort(settings.exceptionRanges->begin(), settings.exceptionRanges->end(), RangeStructLess());
|
||||
ui->listExceptions->clear();
|
||||
for(int i=0; i<settings.exceptionRanges->size(); i++)
|
||||
ui->listExceptions->addItem(QString().sprintf("%.8X-%.8X", settings.exceptionRanges->at(i).start, settings.exceptionRanges->at(i).end));
|
||||
}
|
||||
|
||||
void SettingsDialog::on_chkSystemBreakpoint_stateChanged(int arg1)
|
||||
|
@ -243,3 +299,31 @@ void SettingsDialog::on_btnSave_clicked()
|
|||
SaveSettings();
|
||||
DbgSettingsUpdated();
|
||||
}
|
||||
|
||||
|
||||
void SettingsDialog::on_btnAddRange_clicked()
|
||||
{
|
||||
ExceptionRangeDialog exceptionRange(this);
|
||||
if(exceptionRange.exec()!=QDialog::Accepted)
|
||||
return;
|
||||
RangeStruct range;
|
||||
range.start=exceptionRange.rangeStart;
|
||||
range.end=exceptionRange.rangeEnd;
|
||||
AddRangeToList(range);
|
||||
}
|
||||
|
||||
void SettingsDialog::on_btnDeleteRange_clicked()
|
||||
{
|
||||
QModelIndexList indexes=ui->listExceptions->selectionModel()->selectedIndexes();
|
||||
if(!indexes.size()) //no selection
|
||||
return;
|
||||
settings.exceptionRanges->erase(settings.exceptionRanges->begin()+indexes.at(0).row());
|
||||
ui->listExceptions->clear();
|
||||
for(int i=0; i<settings.exceptionRanges->size(); i++)
|
||||
ui->listExceptions->addItem(QString().sprintf("%.8X-%.8X", settings.exceptionRanges->at(i).start, settings.exceptionRanges->at(i).end));
|
||||
}
|
||||
|
||||
void SettingsDialog::on_btnAddLast_clicked()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -3,9 +3,10 @@
|
|||
|
||||
#include <QDialog>
|
||||
#include "Bridge.h"
|
||||
#include "ExceptionRangeDialog.h"
|
||||
|
||||
namespace Ui {
|
||||
class SettingsDialog;
|
||||
class SettingsDialog;
|
||||
}
|
||||
|
||||
class SettingsDialog : public QDialog
|
||||
|
@ -34,6 +35,9 @@ private slots:
|
|||
void on_radioInt3Long_clicked();
|
||||
void on_radioUd2_clicked();
|
||||
void on_btnSave_clicked();
|
||||
void on_btnAddRange_clicked();
|
||||
void on_btnDeleteRange_clicked();
|
||||
void on_btnAddLast_clicked();
|
||||
|
||||
private:
|
||||
//enums
|
||||
|
@ -51,6 +55,20 @@ private:
|
|||
};
|
||||
|
||||
//structures
|
||||
struct RangeStruct
|
||||
{
|
||||
unsigned long start;
|
||||
unsigned long end;
|
||||
};
|
||||
|
||||
struct RangeStructLess
|
||||
{
|
||||
bool operator()(const RangeStruct a, const RangeStruct b) const
|
||||
{
|
||||
return a.start < b.start;
|
||||
}
|
||||
};
|
||||
|
||||
struct SettingsStruct
|
||||
{
|
||||
//Event Tab
|
||||
|
@ -68,16 +86,19 @@ private:
|
|||
CalcType engineCalcType;
|
||||
BreakpointType engineBreakpointType;
|
||||
//Exception Tab
|
||||
QList<RangeStruct>* exceptionRanges;
|
||||
};
|
||||
|
||||
//variables
|
||||
Ui::SettingsDialog *ui;
|
||||
SettingsStruct settings;
|
||||
QList<RangeStruct> realExceptionRanges;
|
||||
|
||||
//functions
|
||||
void GetSettingBool(const char* section, const char* name, bool* set);
|
||||
Qt::CheckState bool2check(bool checked);
|
||||
void LoadSettings();
|
||||
void AddRangeToList(RangeStruct range);
|
||||
};
|
||||
|
||||
#endif // SETTINGSDIALOG_H
|
||||
|
|
Loading…
Reference in New Issue