1 // Copyright (c) 2019-2021 hors<horsicq@gmail.com> 2 // 3 // Permission is hereby granted, free of charge, to any person obtaining a copy 4 // of this software and associated documentation files (the "Software"), to deal 5 // in the Software without restriction, including without limitation the rights 6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 // copies of the Software, and to permit persons to whom the Software is 8 // furnished to do so, subject to the following conditions: 9 10 // The above copyright notice and this permission notice shall be included in all 11 // copies or substantial portions of the Software. 12 13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 // SOFTWARE. 20 // 21 #ifndef GUIMAINWINDOW_H 22 #define GUIMAINWINDOW_H 23 24 #include "../global.h" 25 #include <QMainWindow> 26 #include <QGroupBox> 27 #include <QLineEdit> 28 #include "dialogabout.h" 29 #include "dialogoptions.h" 30 #include "modevalidator.h" 31 #include "../asm/asm.h" 32 #include "../asm_defs.h" 33 #include "xoptions.h" 34 35 namespace Ui { 36 class GuiMainWindow; 37 } 38 39 class GuiMainWindow : public QMainWindow 40 { 41 Q_OBJECT 42 43 enum OG 44 { 45 OG_TWOOPERANDS=0, 46 OG_ONEOPERAND, 47 OG_MULDIV, 48 OG_SHIFT, 49 OG_BITS, 50 OG_SPECIAL 51 }; 52 53 public: 54 explicit GuiMainWindow(QWidget *pParent=nullptr); 55 ~GuiMainWindow(); 56 57 private slots: 58 void on_pushButtonExit_clicked(); 59 void on_pushButtonAbout_clicked(); 60 void on_comboBoxOpcode_currentIndexChanged(int nIndex); 61 void on_lineEditOperand1_textChanged(const QString &arg1); 62 void on_lineEditOperand2_textChanged(const QString &arg1); 63 void on_lineEditResult1_textChanged(const QString &arg1); 64 void on_lineEditResult2_textChanged(const QString &arg1); 65 void on_pushButtonFlagCF_toggled(bool checked); 66 void on_pushButtonFlagPF_toggled(bool checked); 67 void on_pushButtonFlagAF_toggled(bool checked); 68 void on_pushButtonFlagZF_toggled(bool checked); 69 void on_pushButtonFlagSF_toggled(bool checked); 70 void on_pushButtonFlagOF_toggled(bool checked); 71 void on_lineEditFlagsBefore_textChanged(const QString &arg1); 72 void on_comboBoxMode_currentIndexChanged(int index); 73 void adjustWindow(); 74 void calc(); 75 void loadOpcodes(const ASM_DEF::OPCODE_RECORD *pRecords,qint32 nRecordsSize); 76 void adjustValue(QGroupBox *pGroupBox,ASM_DEF::VALUE_RECORD vr); 77 void adjustMode(); 78 XVALUE getLineEditValue(QLineEdit *pLineEdit,ModeValidator::MODE mode); 79 void setLineEditValue(QLineEdit *pLineEdit,ModeValidator::MODE mode,XVALUE nValue); 80 void adjustFlags(XVALUE nFlag, bool bState); 81 void on_comboBoxOpcodeGroup_currentIndexChanged(int index); 82 void on_pushButtonOptions_clicked(); 83 84 private: 85 Ui::GuiMainWindow *ui; 86 XOptions g_xOptions; 87 QMap<ASM_DEF::OP,ASM_DEF::OPCODE_RECORD> g_mapOpcodes; 88 ModeValidator g_modeValidator[2]; 89 ModeValidator g_modeValidatorFlag; 90 ModeValidator::MODE g_currentMode; 91 }; 92 93 #endif // GUIMAINWINDOW_H 94