GUI: removed donation button from toolbar + follow in Disassembler in Calculator + title in Calculator + Calculator is not a modal window (still allow working while using the calculator) + AStyle + removed empty resource prefix + fixed a warning in Configuration
This commit is contained in:
parent
60eeff6124
commit
1e8f1928ab
|
@ -2,9 +2,7 @@
|
|||
#include "ui_CalculatorDialog.h"
|
||||
#include <QString>
|
||||
|
||||
CalculatorDialog::CalculatorDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::CalculatorDialog)
|
||||
CalculatorDialog::CalculatorDialog(QWidget *parent) : QDialog(parent), ui(new Ui::CalculatorDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
|
||||
|
@ -13,7 +11,6 @@ CalculatorDialog::CalculatorDialog(QWidget *parent) :
|
|||
connect(this,SIGNAL(validAddress(bool)),ui->btnGoto,SLOT(setEnabled(bool)));
|
||||
emit validAddress(false);
|
||||
ui->txtExpression->setFocus();
|
||||
|
||||
}
|
||||
|
||||
CalculatorDialog::~CalculatorDialog()
|
||||
|
@ -21,17 +18,25 @@ CalculatorDialog::~CalculatorDialog()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void CalculatorDialog::setExpressionFocus()
|
||||
{
|
||||
ui->txtExpression->setFocus();
|
||||
}
|
||||
|
||||
void CalculatorDialog::answerExpression(QString expression){
|
||||
void CalculatorDialog::answerExpression(QString expression)
|
||||
{
|
||||
|
||||
if(!DbgIsValidExpression(expression.toUtf8().constData())){
|
||||
if(!DbgIsValidExpression(expression.toUtf8().constData()))
|
||||
{
|
||||
ui->txtBin->setText("");
|
||||
ui->txtDec->setText("");
|
||||
ui->txtHex->setText("");
|
||||
ui->txtOct->setText("");
|
||||
ui->txtAscii->setText("");
|
||||
ui->txtUnicode->setText("");
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
uint_t ans = DbgValFromString(expression.toUtf8().constData());
|
||||
ui->txtHex->setText(inFormat(ans,N_HEX));
|
||||
ui->txtDec->setText(inFormat(ans,N_DEC));
|
||||
|
@ -44,7 +49,9 @@ void CalculatorDialog::answerExpression(QString expression){
|
|||
ui->txtAscii->setText(QString(c));
|
||||
else
|
||||
ui->txtAscii->setText("???");
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->txtAscii->setText("???");
|
||||
if((ans == (ans & 0xFFF)) ) //UNICODE?
|
||||
{
|
||||
|
@ -53,19 +60,20 @@ void CalculatorDialog::answerExpression(QString expression){
|
|||
ui->txtUnicode->setText(QString(c));
|
||||
else
|
||||
ui->txtUnicode->setText("???");
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->txtUnicode->setText("???");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
emit validAddress(DbgMemIsValidReadPtr(ans));
|
||||
}
|
||||
}
|
||||
|
||||
QString CalculatorDialog::inFormat(const uint_t val, CalculatorDialog::NUMBERFORMAT NF) const
|
||||
{
|
||||
switch(NF){
|
||||
switch(NF)
|
||||
{
|
||||
default:
|
||||
case N_HEX:
|
||||
// 0,...,9 in hex is the same as in dec
|
||||
|
@ -77,15 +85,18 @@ QString CalculatorDialog::inFormat(const uint_t val, CalculatorDialog::NUMBERFOR
|
|||
if(val<10 && val>=0)
|
||||
return QString("%1").arg(val);
|
||||
return QString("%1").arg(val);
|
||||
case N_BIN:{
|
||||
case N_BIN:
|
||||
{
|
||||
QString binary = QString("%1").arg(val,8*4,2,QChar('0')).toUpper();
|
||||
QString ans = "";
|
||||
for(int i=0;i<4*8;i++){
|
||||
for(int i=0; i<4*8; i++)
|
||||
{
|
||||
ans += binary[i];
|
||||
if((i%4==0) && (i!=0))
|
||||
ans += " ";
|
||||
}
|
||||
return ans +"b";}
|
||||
return ans +"b";
|
||||
}
|
||||
case N_OCT:
|
||||
return QString("%1").arg(val,1,8,QChar('0')).toUpper()+"o";
|
||||
case N_ASCII:
|
||||
|
@ -93,3 +104,8 @@ QString CalculatorDialog::inFormat(const uint_t val, CalculatorDialog::NUMBERFOR
|
|||
}
|
||||
}
|
||||
|
||||
void CalculatorDialog::on_btnGoto_clicked()
|
||||
{
|
||||
DbgCmdExecDirect(QString("disasm " + ui->txtExpression->text()).toUtf8().constData());
|
||||
emit showCpu();
|
||||
}
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
|
||||
#include <QDialog>
|
||||
#include "Bridge.h"
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class CalculatorDialog;
|
||||
}
|
||||
|
||||
|
@ -11,14 +12,27 @@ class CalculatorDialog : public QDialog
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
enum NUMBERFORMAT{N_HEX=16,N_DEC=10,N_BIN=2,N_OCT=8,N_ASCII=0,N_UNKNOWN=-1};
|
||||
enum NUMBERFORMAT
|
||||
{
|
||||
N_HEX=16,
|
||||
N_DEC=10,
|
||||
N_BIN=2,
|
||||
N_OCT=8,
|
||||
N_ASCII=0,
|
||||
N_UNKNOWN=-1
|
||||
};
|
||||
public:
|
||||
explicit CalculatorDialog(QWidget *parent = 0);
|
||||
~CalculatorDialog();
|
||||
void setExpressionFocus();
|
||||
signals:
|
||||
bool validAddress(bool valid);
|
||||
void showCpu();
|
||||
public slots:
|
||||
void answerExpression(QString expression);
|
||||
private slots:
|
||||
void on_btnGoto_clicked();
|
||||
|
||||
private:
|
||||
Ui::CalculatorDialog *ui;
|
||||
QString inFormat(const uint_t val, CalculatorDialog::NUMBERFORMAT NF) const;
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>254</height>
|
||||
<width>402</width>
|
||||
<height>242</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -17,48 +17,32 @@
|
|||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
<string>Calculator</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../../resource.qrc">
|
||||
<normaloff>:/icons/images/calculator.png</normaloff>:/icons/images/calculator.png</iconset>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>210</y>
|
||||
<width>341</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnGoto">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>210</y>
|
||||
<width>101</width>
|
||||
<width>141</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>goto Expression</string>
|
||||
<string>&Follow in Disassembler</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="">
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>11</x>
|
||||
<y>21</y>
|
||||
<width>371</width>
|
||||
<height>178</height>
|
||||
<y>8</y>
|
||||
<width>381</width>
|
||||
<height>191</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
|
@ -158,40 +142,37 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>320</x>
|
||||
<y>210</y>
|
||||
<width>75</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../resource.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<sender>pushButton</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>CalculatorDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
<x>347</x>
|
||||
<y>216</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>CalculatorDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
<x>284</x>
|
||||
<y>215</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
|
|
|
@ -111,6 +111,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||
ui->statusBar->addPermanentWidget(mLastLogLabel, 1);
|
||||
|
||||
mPatchDialog = new PatchDialog(this);
|
||||
mCalculatorDialog = new CalculatorDialog(this);
|
||||
connect(mCalculatorDialog, SIGNAL(showCpu()), this, SLOT(displayCpuWidget()));
|
||||
|
||||
// Setup Signals/Slots
|
||||
connect(mCmdLineEdit, SIGNAL(returnPressed()), this, SLOT(executeCommand()));
|
||||
|
@ -642,8 +644,9 @@ void MainWindow::openAppearance()
|
|||
|
||||
void MainWindow::openCalculator()
|
||||
{
|
||||
CalculatorDialog calculator(this);
|
||||
calculator.exec();
|
||||
mCalculatorDialog->showNormal();
|
||||
mCalculatorDialog->setFocus();
|
||||
mCalculatorDialog->setExpressionFocus();
|
||||
}
|
||||
|
||||
void MainWindow::openShortcuts()
|
||||
|
|
|
@ -111,6 +111,7 @@ private:
|
|||
ReferenceView* mReferenceView;
|
||||
ThreadView* mThreadView;
|
||||
PatchDialog* mPatchDialog;
|
||||
CalculatorDialog* mCalculatorDialog;
|
||||
|
||||
StatusLabel* mStatusLabel;
|
||||
StatusLabel* mLastLogLabel;
|
||||
|
|
|
@ -158,10 +158,9 @@
|
|||
<addaction name="separator"/>
|
||||
<addaction name="actionStrings"/>
|
||||
<addaction name="actionCalls"/>
|
||||
<addaction name="actionCalculator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionDonate"/>
|
||||
<addaction name="actionCheckUpdates"/>
|
||||
<addaction name="actionCalculator"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<widget class="QToolBar" name="cmdBar">
|
||||
|
|
|
@ -251,8 +251,6 @@ Configuration::Configuration() : QObject()
|
|||
defaultShortcuts.insert("ActionAbortScript", Shortcut(tr("Actions -> Abort Script"), "Esc"));
|
||||
defaultShortcuts.insert("ActionExecuteCommandScript", Shortcut(tr("Actions -> Execute Script Command"), "X"));
|
||||
|
||||
|
||||
|
||||
Shortcuts = defaultShortcuts;
|
||||
|
||||
load();
|
||||
|
@ -541,7 +539,7 @@ const Configuration::Shortcut Configuration::getShortcut(const QString key_id) c
|
|||
msg.setWindowIcon(QIcon(":/icons/images/compile-warning.png"));
|
||||
msg.setWindowFlags(msg.windowFlags()&(~Qt::WindowContextHelpButtonHint));
|
||||
msg.exec();
|
||||
return QKeySequence();
|
||||
return Shortcut();
|
||||
}
|
||||
|
||||
void Configuration::setShortcut(const QString key_id, const QKeySequence key_sequence)
|
||||
|
|
|
@ -44,5 +44,4 @@
|
|||
<file>images/donate.png</file>
|
||||
<file>images/calculator.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/"/>
|
||||
</RCC>
|
||||
|
|
Loading…
Reference in New Issue