├── README.md ├── LICENSE ├── dialogdiehexviewer.ui ├── dialogdiehexviewer.cpp ├── dialogdiehexviewer.h ├── die_widget.pri ├── dialogdiesignatureselapsed.h ├── die_highlighter.h ├── dieoptionswidget.h ├── dialogdiesignatureselapsed.ui ├── dialogdiescandirectory.h ├── diewidgetadvanced.h ├── die_widget.cmake ├── die_signatureedit.h ├── dialogdiesignatureselapsed.cpp ├── dialogdiesignatures.h ├── die_widget.h ├── die_highlighter.cpp ├── dialogdiescandirectory.ui ├── die_signatureedit.cpp ├── dialogdiescandirectory.cpp ├── diewidgetadvanced.ui ├── diewidgetadvanced.cpp ├── dieoptionswidget.cpp ├── dialogdiesignatures.ui ├── die_widget.ui ├── dieoptionswidget.ui ├── dialogdiesignatures.cpp └── die_widget.cpp /README.md: -------------------------------------------------------------------------------- 1 | # die_widget 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020-2025 hors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /dialogdiehexviewer.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | DialogDieHexViewer 4 | 5 | 6 | 7 | 0 8 | 0 9 | 835 10 | 425 11 | 12 | 13 | 14 | Scripts 15 | 16 | 17 | 18 | 19 | 20 | Qt::Vertical 21 | 22 | 23 | 24 | 20 25 | 371 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | Qt::Horizontal 36 | 37 | 38 | 39 | 40 40 | 20 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | OK 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /dialogdiehexviewer.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2019-2025 hors 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 | #include "dialogdiehexviewer.h" 22 | #include "ui_dialogdiehexviewer.h" 23 | 24 | DialogDieHexViewer::DialogDieHexViewer(QWidget *pParent) : XShortcutsDialog(pParent, true), ui(new Ui::DialogDieHexViewer) 25 | { 26 | ui->setupUi(this); 27 | } 28 | 29 | DialogDieHexViewer::~DialogDieHexViewer() 30 | { 31 | delete ui; 32 | } 33 | 34 | void DialogDieHexViewer::adjustView() 35 | { 36 | } 37 | 38 | void DialogDieHexViewer::on_pushButtonOK_clicked() 39 | { 40 | this->close(); 41 | } 42 | 43 | void DialogDieHexViewer::registerShortcuts(bool bState) 44 | { 45 | Q_UNUSED(bState) 46 | } 47 | -------------------------------------------------------------------------------- /dialogdiehexviewer.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2019-2025 hors 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 DIALOGDIEHEXVIEWER_H 22 | #define DIALOGDIEHEXVIEWER_H 23 | 24 | #include "xshortcutsdialog.h" 25 | #include "xbinary.h" 26 | 27 | namespace Ui { 28 | class DialogDieHexViewer; 29 | } 30 | 31 | class DialogDieHexViewer : public XShortcutsDialog { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit DialogDieHexViewer(QWidget *pParent = nullptr); 36 | ~DialogDieHexViewer(); 37 | 38 | virtual void adjustView(); 39 | 40 | private slots: 41 | void on_pushButtonOK_clicked(); 42 | 43 | protected: 44 | virtual void registerShortcuts(bool bState); 45 | 46 | private: 47 | Ui::DialogDieHexViewer *ui; 48 | }; 49 | 50 | #endif // DIALOGDIEHEXVIEWER_H 51 | -------------------------------------------------------------------------------- /die_widget.pri: -------------------------------------------------------------------------------- 1 | QT += concurrent 2 | lessThan(QT_MAJOR_VERSION, 6): QT += scripttools 3 | 4 | INCLUDEPATH += $$PWD 5 | DEPENDPATH += $$PWD 6 | 7 | HEADERS += \ 8 | $$PWD/dialogdiehexviewer.h \ 9 | $$PWD/dialogdiescandirectory.h \ 10 | $$PWD/dialogdiesignatures.h \ 11 | $$PWD/dialogdiesignatureselapsed.h \ 12 | $$PWD/die_highlighter.h \ 13 | $$PWD/die_signatureedit.h \ 14 | $$PWD/die_widget.h \ 15 | $$PWD/dieoptionswidget.h \ 16 | $$PWD/diewidgetadvanced.h 17 | 18 | SOURCES += \ 19 | $$PWD/dialogdiehexviewer.cpp \ 20 | $$PWD/dialogdiescandirectory.cpp \ 21 | $$PWD/dialogdiesignatures.cpp \ 22 | $$PWD/dialogdiesignatureselapsed.cpp \ 23 | $$PWD/die_highlighter.cpp \ 24 | $$PWD/die_signatureedit.cpp \ 25 | $$PWD/die_widget.cpp \ 26 | $$PWD/dieoptionswidget.cpp \ 27 | $$PWD/diewidgetadvanced.cpp 28 | 29 | FORMS += \ 30 | $$PWD/dialogdiehexviewer.ui \ 31 | $$PWD/dialogdiescandirectory.ui \ 32 | $$PWD/dialogdiesignatures.ui \ 33 | $$PWD/dialogdiesignatureselapsed.ui \ 34 | $$PWD/die_widget.ui \ 35 | $$PWD/dieoptionswidget.ui \ 36 | $$PWD/diewidgetadvanced.ui 37 | 38 | !contains(XCONFIG, die_script) { 39 | XCONFIG += die_script 40 | include($$PWD/../die_script/die_script.pri) 41 | } 42 | 43 | !contains(XCONFIG, dialogtextinfo) { 44 | XCONFIG += dialogtextinfo 45 | include($$PWD/../FormatDialogs/dialogtextinfo.pri) 46 | } 47 | 48 | !contains(XCONFIG, xdialogprocess) { 49 | XCONFIG += xdialogprocess 50 | include($$PWD/../FormatDialogs/xdialogprocess.pri) 51 | } 52 | 53 | !contains(XCONFIG, dialogfindtext) { 54 | XCONFIG += dialogfindtext 55 | include($$PWD/../FormatDialogs/dialogfindtext.pri) 56 | } 57 | 58 | !contains(XCONFIG, xcomboboxex) { 59 | XCONFIG += xcomboboxex 60 | include($$PWD/../Controls/xcomboboxex.pri) 61 | } 62 | 63 | DISTFILES += \ 64 | $$PWD/LICENSE \ 65 | $$PWD/README.md \ 66 | $$PWD/die_widget.cmake 67 | -------------------------------------------------------------------------------- /dialogdiesignatureselapsed.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 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 DIALOGDIESIGNATURESELAPSED_H 22 | #define DIALOGDIESIGNATURESELAPSED_H 23 | 24 | #include "xshortcutsdialog.h" 25 | #include "die_script.h" 26 | 27 | namespace Ui { 28 | class DialogDIESignaturesElapsed; 29 | } 30 | 31 | class DialogDIESignaturesElapsed : public XShortcutsDialog { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit DialogDIESignaturesElapsed(QWidget *pParent = nullptr); 36 | ~DialogDIESignaturesElapsed(); 37 | 38 | virtual void adjustView(); 39 | 40 | void setData(XScanEngine::SCAN_RESULT *pScanResult); 41 | 42 | private slots: 43 | void on_pushButtonOK_clicked(); 44 | 45 | protected: 46 | virtual void registerShortcuts(bool bState); 47 | 48 | private: 49 | Ui::DialogDIESignaturesElapsed *ui; 50 | XScanEngine::SCAN_RESULT *m_pScanResult; 51 | }; 52 | 53 | #endif // DIALOGDIESIGNATURESELAPSED_H 54 | -------------------------------------------------------------------------------- /die_highlighter.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2019-2025 hors 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 DIE_HIGHLIGHTER_H 22 | #define DIE_HIGHLIGHTER_H 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | class DIE_Highlighter : public QSyntaxHighlighter { 29 | Q_OBJECT 30 | 31 | public: 32 | explicit DIE_Highlighter(QObject *pParent = nullptr); 33 | 34 | protected: 35 | void highlightBlock(const QString &text); 36 | 37 | private: 38 | struct HighlightingRule { 39 | QRegularExpression pattern; 40 | QTextCharFormat format; 41 | }; 42 | QVector listHighlightingRules; 43 | QRegularExpression commentStartExpression; 44 | QRegularExpression commentEndExpression; 45 | QTextCharFormat keywordFormat; 46 | QTextCharFormat classFormat; 47 | QTextCharFormat singleLineCommentFormat; 48 | QTextCharFormat multiLineCommentFormat; 49 | QTextCharFormat quotationFormat; 50 | QTextCharFormat functionFormat; 51 | }; 52 | 53 | #endif // DIE_HIGHLIGHTER_H 54 | -------------------------------------------------------------------------------- /dieoptionswidget.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2019-2025 hors 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 DIEOPTIONSWIDGET_H 22 | #define DIEOPTIONSWIDGET_H 23 | 24 | #include "xshortcutswidget.h" 25 | #include "xbinary.h" 26 | 27 | namespace Ui { 28 | class DIEOptionsWidget; 29 | } 30 | 31 | // TODO remove, use ScanOptionsWidget 32 | class DIEOptionsWidget : public XShortcutsWidget { 33 | Q_OBJECT 34 | 35 | public: 36 | explicit DIEOptionsWidget(QWidget *pParent = nullptr); 37 | ~DIEOptionsWidget(); 38 | 39 | virtual void adjustView(); 40 | 41 | void setOptions(XOptions *pOptions); 42 | 43 | static void setDefaultValues(XOptions *pOptions); 44 | virtual void reloadData(bool bSaveSelection); 45 | 46 | public slots: 47 | void save(); 48 | void reload(); 49 | 50 | private slots: 51 | void on_toolButtonDIEDatabase_clicked(); 52 | void on_toolButtonDIEDatabaseExtra_clicked(); 53 | void on_toolButtonDIEDatabaseCustom_clicked(); 54 | void on_toolButtonYaraRules_clicked(); 55 | 56 | protected: 57 | virtual void registerShortcuts(bool bState); 58 | 59 | private: 60 | Ui::DIEOptionsWidget *ui; 61 | XOptions *m_pOptions; 62 | }; 63 | 64 | #endif // DIEOPTIONSWIDGET_H 65 | -------------------------------------------------------------------------------- /dialogdiesignatureselapsed.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | DialogDIESignaturesElapsed 4 | 5 | 6 | Qt::ApplicationModal 7 | 8 | 9 | 10 | 0 11 | 0 12 | 400 13 | 300 14 | 15 | 16 | 17 | Elapsed 18 | 19 | 20 | true 21 | 22 | 23 | 24 | 25 | 26 | QAbstractItemView::NoEditTriggers 27 | 28 | 29 | QAbstractItemView::SingleSelection 30 | 31 | 32 | QAbstractItemView::SelectRows 33 | 34 | 35 | true 36 | 37 | 38 | false 39 | 40 | 41 | 20 42 | 43 | 44 | 20 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | Qt::Horizontal 54 | 55 | 56 | 57 | 40 58 | 20 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | OK 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /dialogdiescandirectory.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2018-2025 hors 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 DIALOGDIESCANDIRECTORY_H 22 | #define DIALOGDIESCANDIRECTORY_H 23 | 24 | #include "xshortcutsdialog.h" 25 | #include "xdialogprocess.h" 26 | #include "scanitemmodel.h" 27 | #include "die_script.h" 28 | 29 | namespace Ui { 30 | class DialogDIEScanDirectory; 31 | } 32 | 33 | class DialogDIEScanDirectory : public XShortcutsDialog { 34 | Q_OBJECT 35 | 36 | public: 37 | explicit DialogDIEScanDirectory(QWidget *pParent, const QString &sDirName); 38 | ~DialogDIEScanDirectory(); 39 | 40 | virtual void adjustView(); 41 | 42 | private slots: 43 | void on_pushButtonOpenDirectory_clicked(); 44 | void on_pushButtonScan_clicked(); 45 | void scanDirectory(const QString &sDirectoryName); 46 | void scanResult(const XScanEngine::SCAN_RESULT &scanResult); 47 | void appendResult(const QString &sResult); 48 | void on_pushButtonOK_clicked(); 49 | void on_pushButtonClear_clicked(); 50 | void on_pushButtonSave_clicked(); 51 | 52 | signals: 53 | void resultSignal(const QString &sText); 54 | 55 | protected: 56 | virtual void registerShortcuts(bool bState); 57 | 58 | private: 59 | Ui::DialogDIEScanDirectory *ui; 60 | XScanEngine::SCAN_OPTIONS m_scanOptions; 61 | }; 62 | 63 | #endif // DIALOGDIESCANDIRECTORY_H 64 | -------------------------------------------------------------------------------- /diewidgetadvanced.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2019-2025 hors 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 DIEWIDGETADVANCED_H 22 | #define DIEWIDGETADVANCED_H 23 | 24 | #include "xshortcutswidget.h" 25 | #include "die_widget.h" 26 | 27 | namespace Ui { 28 | class DIEWidgetAdvanced; 29 | } 30 | 31 | class DIEWidgetAdvanced : public XShortcutsWidget { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit DIEWidgetAdvanced(QWidget *pParent = nullptr); 36 | ~DIEWidgetAdvanced(); 37 | 38 | void setData(QIODevice *pDevice, bool bScan, XBinary::FT fileType = XBinary::FT_UNKNOWN); 39 | 40 | virtual void adjustView(); 41 | void setGlobal(XShortcuts *pShortcuts, XOptions *pXOptions); 42 | virtual void reloadData(bool bSaveSelection); 43 | 44 | protected: 45 | virtual void registerShortcuts(bool bState); 46 | 47 | private slots: 48 | void process(); 49 | void on_toolButtonSave_clicked(); 50 | void on_toolButtonScan_clicked(); 51 | void onSelectionChanged(const QItemSelection &itemSelected, const QItemSelection &itemDeselected); 52 | void on_comboBoxType_currentIndexChanged(int nIndex); 53 | void on_toolButtonSignatures_clicked(); 54 | 55 | private: 56 | Ui::DIEWidgetAdvanced *ui; 57 | QIODevice *m_pDevice; 58 | ScanItemModel *m_pModel; 59 | XScanEngine::SCAN_RESULT m_scanResult; 60 | XScanEngine::SCAN_OPTIONS m_scanOptions; 61 | }; 62 | 63 | #endif // DIEWIDGETADVANCED_H 64 | -------------------------------------------------------------------------------- /die_widget.cmake: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_CURRENT_LIST_DIR}) 2 | 3 | if (NOT DEFINED DIE_SCRIPT_SOURCES) 4 | include(${CMAKE_CURRENT_LIST_DIR}/../die_script/die_script.cmake) 5 | set(DIE_WIDGET_SOURCES ${DIE_WIDGET_SOURCES} ${DIE_SCRIPT_SOURCES}) 6 | endif() 7 | if (NOT DEFINED DIALOGTEXTINFO_SOURCES) 8 | include(${CMAKE_CURRENT_LIST_DIR}/../FormatDialogs/dialogtextinfo.cmake) 9 | set(DIE_WIDGET_SOURCES ${DIE_WIDGET_SOURCES} ${DIALOGTEXTINFO_SOURCES}) 10 | endif() 11 | if (NOT DEFINED XDIALOGPROCESS_SOURCES) 12 | include(${CMAKE_CURRENT_LIST_DIR}/../FormatDialogs/xdialogprocess.cmake) 13 | set(DIE_WIDGET_SOURCES ${DIE_WIDGET_SOURCES} ${XDIALOGPROCESS_SOURCES}) 14 | endif() 15 | if (NOT DEFINED DIALOGFINDTEXT_SOURCES) 16 | include(${CMAKE_CURRENT_LIST_DIR}/../FormatDialogs/dialogfindtext.cmake) 17 | set(DIE_WIDGET_SOURCES ${DIE_WIDGET_SOURCES} ${DIALOGFINDTEXT_SOURCES}) 18 | endif() 19 | if (NOT DEFINED XCOMBOBOXEX_SOURCES) 20 | include(${CMAKE_CURRENT_LIST_DIR}/../Controls/xcomboboxex.cmake) 21 | set(DIE_WIDGET_SOURCES ${DIE_WIDGET_SOURCES} ${XCOMBOBOXEX_SOURCES}) 22 | endif() 23 | 24 | set(DIE_WIDGET_SOURCES 25 | ${DIE_WIDGET_SOURCES} 26 | ${CMAKE_CURRENT_LIST_DIR}/dialogdiehexviewer.cpp 27 | ${CMAKE_CURRENT_LIST_DIR}/dialogdiehexviewer.h 28 | ${CMAKE_CURRENT_LIST_DIR}/dialogdiehexviewer.ui 29 | ${CMAKE_CURRENT_LIST_DIR}/dialogdiescandirectory.cpp 30 | ${CMAKE_CURRENT_LIST_DIR}/dialogdiescandirectory.h 31 | ${CMAKE_CURRENT_LIST_DIR}/dialogdiescandirectory.ui 32 | ${CMAKE_CURRENT_LIST_DIR}/dialogdiesignatures.cpp 33 | ${CMAKE_CURRENT_LIST_DIR}/dialogdiesignatures.h 34 | ${CMAKE_CURRENT_LIST_DIR}/dialogdiesignatures.ui 35 | ${CMAKE_CURRENT_LIST_DIR}/dialogdiesignatureselapsed.cpp 36 | ${CMAKE_CURRENT_LIST_DIR}/dialogdiesignatureselapsed.h 37 | ${CMAKE_CURRENT_LIST_DIR}/dialogdiesignatureselapsed.ui 38 | ${CMAKE_CURRENT_LIST_DIR}/die_highlighter.cpp 39 | ${CMAKE_CURRENT_LIST_DIR}/die_highlighter.h 40 | ${CMAKE_CURRENT_LIST_DIR}/die_signatureedit.cpp 41 | ${CMAKE_CURRENT_LIST_DIR}/die_signatureedit.h 42 | ${CMAKE_CURRENT_LIST_DIR}/die_widget.cpp 43 | ${CMAKE_CURRENT_LIST_DIR}/die_widget.h 44 | ${CMAKE_CURRENT_LIST_DIR}/die_widget.ui 45 | ${CMAKE_CURRENT_LIST_DIR}/dieoptionswidget.cpp 46 | ${CMAKE_CURRENT_LIST_DIR}/dieoptionswidget.h 47 | ${CMAKE_CURRENT_LIST_DIR}/dieoptionswidget.ui 48 | ${CMAKE_CURRENT_LIST_DIR}/diewidgetadvanced.cpp 49 | ${CMAKE_CURRENT_LIST_DIR}/diewidgetadvanced.h 50 | ${CMAKE_CURRENT_LIST_DIR}/diewidgetadvanced.ui 51 | ) 52 | -------------------------------------------------------------------------------- /die_signatureedit.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2019-2025 hors 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 DIE_SIGNATUREEDIT_H 22 | #define DIE_SIGNATUREEDIT_H 23 | 24 | #include 25 | #include 26 | 27 | #include "die_highlighter.h" 28 | #include "xoptions.h" 29 | 30 | class DIE_SignatureEdit : public QPlainTextEdit { 31 | Q_OBJECT 32 | 33 | public: 34 | explicit DIE_SignatureEdit(QWidget *pParent = nullptr); 35 | void lineNumberAreaPaintEvent(QPaintEvent *pEvent); 36 | qint32 lineNumberAreaWidth(); 37 | void setPlainText(const QString &sText); 38 | 39 | protected: 40 | virtual void keyPressEvent(QKeyEvent *pEvent) override; 41 | void resizeEvent(QResizeEvent *pEvent) override; 42 | 43 | private slots: 44 | void updateLineNumberAreaWidth(qint32 newBlockCount); 45 | void highlightCurrentLine(); 46 | void updateLineNumberArea(const QRect &rect, qint32 nDy); 47 | 48 | private: 49 | DIE_Highlighter *m_pHighlighter; 50 | QWidget *m_pLineNumberArea; 51 | }; 52 | 53 | class DIE_LineNumberArea : public QWidget { 54 | Q_OBJECT 55 | 56 | public: 57 | DIE_LineNumberArea(QPlainTextEdit *pPlainTextEdit) : QWidget(pPlainTextEdit) 58 | { 59 | g_pPlainTextEdit = pPlainTextEdit; 60 | } 61 | 62 | QSize sizeHint() const 63 | { 64 | return QSize(((DIE_SignatureEdit *)g_pPlainTextEdit)->lineNumberAreaWidth(), 0); 65 | } 66 | 67 | protected: 68 | void paintEvent(QPaintEvent *pEvent) 69 | { 70 | ((DIE_SignatureEdit *)g_pPlainTextEdit)->lineNumberAreaPaintEvent(pEvent); 71 | } 72 | 73 | private: 74 | QPlainTextEdit *g_pPlainTextEdit; 75 | }; 76 | 77 | #endif // DIE_SIGNATUREEDIT_H 78 | -------------------------------------------------------------------------------- /dialogdiesignatureselapsed.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 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 | #include "dialogdiesignatureselapsed.h" 22 | 23 | #include "ui_dialogdiesignatureselapsed.h" 24 | 25 | DialogDIESignaturesElapsed::DialogDIESignaturesElapsed(QWidget *pParent) : XShortcutsDialog(pParent, true), ui(new Ui::DialogDIESignaturesElapsed) 26 | { 27 | m_pScanResult = nullptr; 28 | 29 | ui->setupUi(this); 30 | } 31 | 32 | DialogDIESignaturesElapsed::~DialogDIESignaturesElapsed() 33 | { 34 | delete ui; 35 | } 36 | 37 | void DialogDIESignaturesElapsed::adjustView() 38 | { 39 | } 40 | 41 | void DialogDIESignaturesElapsed::setData(XScanEngine::SCAN_RESULT *pScanResult) 42 | { 43 | m_pScanResult = pScanResult; 44 | 45 | qint32 nNumberOfRecords = pScanResult->listDebugRecords.count(); 46 | 47 | ui->tableWidgetResult->setColumnCount(2); 48 | ui->tableWidgetResult->setRowCount(nNumberOfRecords); 49 | 50 | QStringList listHeaders; 51 | listHeaders.append(tr("Time")); 52 | listHeaders.append(tr("Script")); 53 | 54 | ui->tableWidgetResult->setHorizontalHeaderLabels(listHeaders); 55 | 56 | for (qint32 i = 0; i < nNumberOfRecords; i++) { 57 | QTableWidgetItem *pItemTime = new QTableWidgetItem; 58 | 59 | pItemTime->setData(Qt::DisplayRole, pScanResult->listDebugRecords.at(i).nElapsedTime); 60 | pItemTime->setTextAlignment(Qt::AlignRight); 61 | ui->tableWidgetResult->setItem(i, 0, pItemTime); 62 | 63 | QTableWidgetItem *pItemScript = new QTableWidgetItem; 64 | 65 | pItemScript->setText(pScanResult->listDebugRecords.at(i).sScript); 66 | pItemScript->setTextAlignment(Qt::AlignLeft); 67 | ui->tableWidgetResult->setItem(i, 1, pItemScript); 68 | } 69 | 70 | ui->tableWidgetResult->setColumnWidth(0, 60); 71 | ui->tableWidgetResult->setColumnWidth(1, 120); 72 | 73 | ui->tableWidgetResult->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch); 74 | 75 | ui->tableWidgetResult->horizontalHeader()->setVisible(true); 76 | } 77 | 78 | void DialogDIESignaturesElapsed::on_pushButtonOK_clicked() 79 | { 80 | this->close(); 81 | } 82 | 83 | void DialogDIESignaturesElapsed::registerShortcuts(bool bState) 84 | { 85 | Q_UNUSED(bState) 86 | } 87 | -------------------------------------------------------------------------------- /dialogdiesignatures.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2019-2025 hors 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 DIALOGDIESIGNATURES_H 22 | #define DIALOGDIESIGNATURES_H 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include "dialogfindtext.h" 29 | #include "die_script.h" 30 | #include "xshortcutsdialog.h" 31 | #include "scanitemmodel.h" 32 | 33 | namespace Ui { 34 | class DialogDIESignatures; 35 | } 36 | 37 | // TODO rename DialogDieSignatures 38 | class DialogDIESignatures : public XShortcutsDialog { 39 | Q_OBJECT 40 | 41 | enum SHORTCUT { 42 | SC_FIND_STRING, 43 | SC_FIND_NEXT, 44 | __SC_SIZE, 45 | // TODO more 46 | }; 47 | 48 | enum UD { 49 | UD_FILEPATH = 0, 50 | UD_FILETYPE, 51 | UD_NAME 52 | }; 53 | 54 | public: 55 | explicit DialogDIESignatures(QWidget *pParent, DiE_Script *pDieScript); 56 | ~DialogDIESignatures(); 57 | 58 | void setData(QIODevice *pDevice, XBinary::FT fileType, const QString &sSignature); 59 | 60 | virtual void adjustView(); 61 | 62 | private slots: 63 | void on_treeWidgetSignatures_currentItemChanged(QTreeWidgetItem *pItemCurrent, QTreeWidgetItem *pItemPrevious); 64 | void on_pushButtonSave_clicked(); 65 | void save(); 66 | void on_pushButtonRun_clicked(); 67 | void on_pushButtonDebug_clicked(); 68 | void on_pushButtonClearResult_clicked(); 69 | void on_pushButtonClose_clicked(); 70 | 71 | qint32 handleTreeItems(QTreeWidgetItem *pRootItem, XBinary::FT fileType, const QString &sText); 72 | qint32 _handleTreeItems(QTreeWidgetItem *pItemParent, XBinary::FT fileType); 73 | void runScript(const QString &sFunction, bool bIsDebug); 74 | void on_plainTextEditSignature_textChanged(); 75 | void on_checkBoxReadOnly_toggled(bool bChecked); 76 | 77 | bool _setTreeItem(QTreeWidget *pTree, QTreeWidgetItem *pItem, XBinary::FT fileType, const QString &sSignature); 78 | void enableControls(bool bState); 79 | void infoMessage(const QString &sInfoMessage); 80 | void warningMessage(const QString &sWarningMessage); 81 | void errorMessage(const QString &sErrorMessage); 82 | void on_pushButtonFind_clicked(); 83 | void on_pushButtonFindNext_clicked(); 84 | void findString(); 85 | void findNext(); 86 | 87 | private: 88 | Ui::DialogDIESignatures *ui; 89 | DiE_Script *m_pDieScript; 90 | QIODevice *m_pDevice; 91 | XBinary::FT m_fileType; 92 | QString m_sSignature; 93 | QString m_sCurrentSignatureFilePath; 94 | bool m_bCurrentEdited; 95 | DialogFindText::DATA m_data; 96 | }; 97 | 98 | #endif // DIALOGDIESIGNATURES_H 99 | -------------------------------------------------------------------------------- /die_widget.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2019-2025 hors 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 DIE_WIDGET_H 22 | #define DIE_WIDGET_H 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "dialogdiescandirectory.h" 32 | #include "dialogdiesignatureselapsed.h" 33 | #include "dialogdiesignatures.h" 34 | #include "dialogtextinfo.h" 35 | #include "die_script.h" 36 | #include "xshortcutswidget.h" 37 | 38 | namespace Ui { 39 | class DIE_Widget; 40 | } 41 | 42 | class DIE_Widget : public XShortcutsWidget { 43 | Q_OBJECT 44 | 45 | public: 46 | enum ST { 47 | ST_UNKNOWN = 0, 48 | ST_FILE 49 | }; 50 | 51 | enum COLUMN { 52 | // COLUMN_TYPE=0, 53 | COLUMN_STRING = 0, 54 | COLUMN_SIGNATURE, 55 | COLUMN_INFO 56 | }; 57 | 58 | explicit DIE_Widget(QWidget *pParent = nullptr); 59 | ~DIE_Widget(); 60 | 61 | // void setOptions(OPTIONS *pOptions); 62 | void setData(const QString &sFileName, bool bScan = false, XBinary::FT fileType = XBinary::FT_UNKNOWN); 63 | virtual void adjustView(); 64 | void setGlobal(XShortcuts *pShortcuts, XOptions *pXOptions); 65 | virtual void reloadData(bool bSaveSelection); 66 | 67 | private slots: 68 | void clear(); 69 | void process(); 70 | void scan(); 71 | void stop(); 72 | void onScanFinished(); 73 | void on_pushButtonDieSignatures_clicked(); 74 | void on_pushButtonDieExtraInformation_clicked(); 75 | void on_pushButtonDieLog_clicked(); 76 | void showInfo(const QString &sName); 77 | void showSignature(XBinary::FT fileType, const QString &sName); 78 | void enableControls(bool bState); 79 | QString getInfoFileName(const QString &sName); 80 | void copyResult(); 81 | void on_pushButtonDieScanDirectory_clicked(); 82 | void on_toolButtonElapsedTime_clicked(); 83 | void on_treeViewResult_clicked(const QModelIndex &index); 84 | void on_treeViewResult_customContextMenuRequested(const QPoint &pos); 85 | void timerSlot(); 86 | void on_pushButtonDieScanStart_clicked(); 87 | void on_pushButtonDieScanStop_clicked(); 88 | void handleErrorString(const QString &sErrorString); 89 | void handleWarningString(const QString &sWarningString); 90 | 91 | protected: 92 | virtual void registerShortcuts(bool bState); 93 | 94 | signals: 95 | void scanStarted(); 96 | void scanFinished(); 97 | void currentFileType(qint32 nFT); 98 | void scanProgress(int value); 99 | 100 | private: 101 | Ui::DIE_Widget *ui; 102 | ST m_scanType; 103 | DiE_Script m_dieScript; 104 | XScanEngine::SCAN_OPTIONS m_scanOptions; 105 | XScanEngine::SCAN_RESULT m_scanResult; 106 | QFutureWatcher m_watcher; 107 | QString m_sFileName; 108 | XBinary::FT m_fileType; 109 | bool m_bProcess; 110 | QString m_sInfoPath; 111 | XBinary::PDSTRUCT m_pdStruct; 112 | QTimer *m_pTimer; 113 | bool m_bInitDatabase; 114 | ScanItemModel *m_pModel; 115 | QList m_listErrorsAndWarnings; 116 | }; 117 | 118 | #endif // DIE_WIDGET_H 119 | -------------------------------------------------------------------------------- /die_highlighter.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2019-2025 hors 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 | #include "die_highlighter.h" 22 | 23 | DIE_Highlighter::DIE_Highlighter(QObject *pParent) : QSyntaxHighlighter(pParent) 24 | { 25 | HighlightingRule rule; 26 | 27 | keywordFormat.setForeground(Qt::darkBlue); 28 | keywordFormat.setFontWeight(QFont::Bold); 29 | const QString keywordPatterns[] = {QStringLiteral("\\bvar\\b"), QStringLiteral("\\bfunction\\b"), QStringLiteral("\\bbShowType\\b"), 30 | QStringLiteral("\\bbShowVersion\\b"), QStringLiteral("\\bbShowOptions\\b"), QStringLiteral("\\bsVersion\\b"), 31 | QStringLiteral("\\bsOptions\\b"), QStringLiteral("\\bsName\\b"), QStringLiteral("\\bbDetected\\b"), 32 | QStringLiteral("\\breturn\\b")}; 33 | 34 | for (const QString &pattern : keywordPatterns) { 35 | rule.pattern = QRegularExpression(pattern); 36 | rule.format = keywordFormat; 37 | listHighlightingRules.append(rule); 38 | } 39 | 40 | classFormat.setFontWeight(QFont::Bold); 41 | classFormat.setForeground(Qt::darkMagenta); 42 | rule.pattern = QRegularExpression(QStringLiteral("\\bQ[A-Za-z]+\\b")); 43 | rule.format = classFormat; 44 | listHighlightingRules.append(rule); 45 | 46 | quotationFormat.setForeground(Qt::darkGreen); 47 | // rule.pattern = QRegularExpression(QStringLiteral("\".*\"")); 48 | rule.pattern = QRegularExpression(QStringLiteral("\".*?\"")); 49 | rule.format = quotationFormat; 50 | listHighlightingRules.append(rule); 51 | 52 | functionFormat.setFontItalic(true); 53 | functionFormat.setForeground(Qt::blue); 54 | rule.pattern = QRegularExpression(QStringLiteral("\\b[A-Za-z0-9_]+(?=\\()")); 55 | rule.format = functionFormat; 56 | listHighlightingRules.append(rule); 57 | 58 | singleLineCommentFormat.setForeground(Qt::red); 59 | rule.pattern = QRegularExpression(QStringLiteral("//[^\n]*")); 60 | rule.format = singleLineCommentFormat; 61 | listHighlightingRules.append(rule); 62 | 63 | multiLineCommentFormat.setForeground(Qt::red); 64 | 65 | commentStartExpression = QRegularExpression(QStringLiteral("/\\*")); 66 | commentEndExpression = QRegularExpression(QStringLiteral("\\*/")); 67 | } 68 | 69 | void DIE_Highlighter::highlightBlock(const QString &text) 70 | { 71 | // TODO Check qConst 72 | for (const HighlightingRule &rule : listHighlightingRules) { 73 | QRegularExpressionMatchIterator matchIterator = rule.pattern.globalMatch(text); 74 | 75 | while (matchIterator.hasNext()) { 76 | QRegularExpressionMatch match = matchIterator.next(); 77 | setFormat(match.capturedStart(), match.capturedLength(), rule.format); 78 | } 79 | } 80 | 81 | setCurrentBlockState(0); 82 | 83 | qint32 startIndex = 0; 84 | if (previousBlockState() != 1) { 85 | startIndex = text.indexOf(commentStartExpression); 86 | } 87 | 88 | while (startIndex >= 0) { 89 | QRegularExpressionMatch match = commentEndExpression.match(text, startIndex); 90 | qint32 endIndex = match.capturedStart(); 91 | qint32 commentLength = 0; 92 | 93 | if (endIndex == -1) { 94 | setCurrentBlockState(1); 95 | commentLength = text.length() - startIndex; 96 | } else { 97 | commentLength = endIndex - startIndex + match.capturedLength(); 98 | } 99 | setFormat(startIndex, commentLength, multiLineCommentFormat); 100 | startIndex = text.indexOf(commentStartExpression, startIndex + commentLength); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /dialogdiescandirectory.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | DialogDIEScanDirectory 4 | 5 | 6 | Qt::ApplicationModal 7 | 8 | 9 | 10 | 0 11 | 0 12 | 785 13 | 478 14 | 15 | 16 | 17 | Directory scan 18 | 19 | 20 | true 21 | 22 | 23 | 24 | 25 | 26 | Directory 27 | 28 | 29 | Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter 30 | 31 | 32 | 33 | 2 34 | 35 | 36 | 2 37 | 38 | 39 | 2 40 | 41 | 42 | 2 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | Subdirectories 55 | 56 | 57 | false 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 150 66 | 0 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | Qt::Horizontal 75 | 76 | 77 | 78 | 158 79 | 20 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | true 95 | 96 | 97 | 98 | ... 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | true 107 | 108 | 109 | 110 | Scan 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | false 123 | 124 | 125 | true 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | Clear 135 | 136 | 137 | 138 | 139 | 140 | 141 | Save 142 | 143 | 144 | 145 | 146 | 147 | 148 | Qt::Horizontal 149 | 150 | 151 | 152 | 40 153 | 20 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | OK 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | XComboBoxEx 172 | QComboBox 173 |
xcomboboxex.h
174 |
175 |
176 | 177 | 178 |
179 | -------------------------------------------------------------------------------- /die_signatureedit.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2019-2025 hors 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 | #include "die_signatureedit.h" 22 | 23 | DIE_SignatureEdit::DIE_SignatureEdit(QWidget *pParent) : QPlainTextEdit(pParent) 24 | { 25 | m_pHighlighter = new DIE_Highlighter(this->document()); 26 | 27 | m_pHighlighter->setDocument(this->document()); 28 | 29 | m_pLineNumberArea = new DIE_LineNumberArea(this); 30 | 31 | connect(this, &DIE_SignatureEdit::blockCountChanged, this, &DIE_SignatureEdit::updateLineNumberAreaWidth); 32 | connect(this, &DIE_SignatureEdit::updateRequest, this, &DIE_SignatureEdit::updateLineNumberArea); 33 | connect(this, &DIE_SignatureEdit::cursorPositionChanged, this, &DIE_SignatureEdit::highlightCurrentLine); 34 | 35 | updateLineNumberAreaWidth(0); 36 | highlightCurrentLine(); 37 | } 38 | 39 | void DIE_SignatureEdit::lineNumberAreaPaintEvent(QPaintEvent *pEvent) 40 | { 41 | QPainter painter(m_pLineNumberArea); 42 | painter.fillRect(pEvent->rect(), Qt::lightGray); 43 | 44 | QTextBlock block = firstVisibleBlock(); 45 | qint32 nBlockNumber = block.blockNumber(); 46 | qint32 nTop = qRound(blockBoundingGeometry(block).translated(contentOffset()).top()); 47 | qint32 nBottom = nTop + qRound(blockBoundingRect(block).height()); 48 | 49 | while (block.isValid() && (nTop <= pEvent->rect().bottom())) { 50 | if (block.isVisible() && (nBottom >= pEvent->rect().top())) { 51 | QString number = QString::number(nBlockNumber + 1); 52 | painter.setPen(Qt::black); 53 | painter.drawText(0, nTop, m_pLineNumberArea->width() - 5, fontMetrics().height(), Qt::AlignRight, number); 54 | } 55 | 56 | block = block.next(); 57 | nTop = nBottom; 58 | nBottom = nTop + qRound(blockBoundingRect(block).height()); 59 | ++nBlockNumber; 60 | } 61 | } 62 | 63 | qint32 DIE_SignatureEdit::lineNumberAreaWidth() 64 | { 65 | qint32 nDigits = 3; 66 | #if (QT_VERSION < QT_VERSION_CHECK(5, 11, 0)) 67 | qint32 nSpace = 10 + fontMetrics().width(QLatin1Char('9')) * nDigits; 68 | #else 69 | qint32 nSpace = 10 + fontMetrics().horizontalAdvance(QLatin1Char('9')) * nDigits; 70 | #endif 71 | 72 | return nSpace; 73 | } 74 | 75 | void DIE_SignatureEdit::setPlainText(const QString &sText) 76 | { 77 | QPlainTextEdit::setPlainText(sText); 78 | 79 | highlightCurrentLine(); 80 | 81 | m_pLineNumberArea->update(); 82 | } 83 | 84 | void DIE_SignatureEdit::keyPressEvent(QKeyEvent *pEvent) 85 | { 86 | if (pEvent->key() == Qt::Key_Tab) { 87 | qint32 nPosition = textCursor().positionInBlock(); 88 | 89 | qint32 nAppend = nPosition % 4; // TODO options 90 | 91 | QString sAppend; 92 | 93 | sAppend = sAppend.fill(QChar(' '), 4 - nAppend); 94 | 95 | QKeyEvent *pEventNew = new QKeyEvent(QEvent::KeyPress, 0, Qt::NoModifier, sAppend); 96 | QPlainTextEdit::keyPressEvent(pEventNew); 97 | 98 | delete pEventNew; 99 | } else { 100 | QPlainTextEdit::keyPressEvent(pEvent); 101 | } 102 | } 103 | 104 | void DIE_SignatureEdit::resizeEvent(QResizeEvent *pEvent) 105 | { 106 | QPlainTextEdit::resizeEvent(pEvent); 107 | 108 | QRect cr = contentsRect(); 109 | m_pLineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height())); 110 | } 111 | 112 | void DIE_SignatureEdit::updateLineNumberAreaWidth(qint32 newBlockCount) 113 | { 114 | Q_UNUSED(newBlockCount) 115 | 116 | setViewportMargins(lineNumberAreaWidth() + 5, 0, 0, 0); 117 | } 118 | 119 | void DIE_SignatureEdit::highlightCurrentLine() 120 | { 121 | QList extraSelections; 122 | 123 | if (!isReadOnly()) { 124 | QTextEdit::ExtraSelection selection; 125 | 126 | QColor lineColor = QColor(Qt::yellow).lighter(160); 127 | 128 | selection.format.setBackground(lineColor); 129 | selection.format.setProperty(QTextFormat::FullWidthSelection, true); 130 | selection.cursor = textCursor(); 131 | selection.cursor.clearSelection(); 132 | extraSelections.append(selection); 133 | } 134 | 135 | setExtraSelections(extraSelections); 136 | } 137 | 138 | void DIE_SignatureEdit::updateLineNumberArea(const QRect &rect, qint32 nDy) 139 | { 140 | if (nDy) { 141 | m_pLineNumberArea->scroll(0, nDy); 142 | } else { 143 | m_pLineNumberArea->update(0, rect.y(), m_pLineNumberArea->width(), rect.height()); 144 | } 145 | 146 | if (rect.contains(viewport()->rect())) { 147 | updateLineNumberAreaWidth(0); 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /dialogdiescandirectory.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2019-2025 hors 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 | #include "dialogdiescandirectory.h" 22 | 23 | #include "ui_dialogdiescandirectory.h" 24 | 25 | DialogDIEScanDirectory::DialogDIEScanDirectory(QWidget *pParent, const QString &sDirName) : XShortcutsDialog(pParent, true), ui(new Ui::DialogDIEScanDirectory) 26 | { 27 | ui->setupUi(this); 28 | 29 | // Qt::WindowTitleHint 30 | 31 | connect(this, SIGNAL(resultSignal(QString)), this, SLOT(appendResult(QString))); 32 | 33 | ui->checkBoxScanSubdirectories->setChecked(true); 34 | 35 | if (sDirName != "") { 36 | ui->lineEditDirectoryName->setText(QDir().toNativeSeparators(sDirName)); 37 | } 38 | 39 | m_scanOptions = {}; 40 | 41 | ui->comboBoxFlags->setData(XScanEngine::getScanFlags(), XComboBoxEx::CBTYPE_FLAGS, 0, tr("Flags")); 42 | } 43 | 44 | DialogDIEScanDirectory::~DialogDIEScanDirectory() 45 | { 46 | delete ui; 47 | } 48 | 49 | void DialogDIEScanDirectory::adjustView() 50 | { 51 | quint64 nFlags = XScanEngine::getScanFlagsFromGlobalOptions(getGlobalOptions()); 52 | ui->comboBoxFlags->setValue(nFlags); 53 | } 54 | 55 | void DialogDIEScanDirectory::on_pushButtonOpenDirectory_clicked() 56 | { 57 | QString sInitDirectory = ui->lineEditDirectoryName->text(); 58 | 59 | QString sDirectoryName = QFileDialog::getExistingDirectory(this, tr("Open directory") + QString("..."), sInitDirectory, QFileDialog::ShowDirsOnly); 60 | 61 | if (!sDirectoryName.isEmpty()) { 62 | ui->lineEditDirectoryName->setText(QDir().toNativeSeparators(sDirectoryName)); 63 | } 64 | } 65 | 66 | void DialogDIEScanDirectory::on_pushButtonScan_clicked() 67 | { 68 | QString sDirectoryName = ui->lineEditDirectoryName->text().trimmed(); 69 | 70 | scanDirectory(sDirectoryName); 71 | } 72 | 73 | void DialogDIEScanDirectory::scanDirectory(const QString &sDirectoryName) 74 | { 75 | if (sDirectoryName != "") { 76 | ui->textBrowserResult->clear(); 77 | 78 | // TODO 79 | m_scanOptions.bUseCustomDatabase = true; 80 | m_scanOptions.bUseExtraDatabase = true; 81 | m_scanOptions.bShowType = true; 82 | m_scanOptions.bShowVersion = true; 83 | m_scanOptions.bShowInfo = true; 84 | m_scanOptions.bSubdirectories = ui->checkBoxScanSubdirectories->isChecked(); 85 | m_scanOptions.nBufferSize = getGlobalOptions()->getValue(XOptions::ID_ENGINE_BUFFERSIZE).toULongLong(); 86 | 87 | quint64 nFlags = ui->comboBoxFlags->getValue().toULongLong(); 88 | XScanEngine::setScanFlags(&m_scanOptions, nFlags); 89 | 90 | XScanEngine::setScanFlagsToGlobalOptions(getGlobalOptions(), nFlags); 91 | // TODO Filter 92 | // |flags|x all| 93 | 94 | DiE_Script dieScript; 95 | 96 | // connect(&dieScript, SIGNAL(scanFileStarted(QString)), this, SIGNAL(scanFileStarted(QString)), Qt::DirectConnection); 97 | connect(&dieScript, SIGNAL(scanResult(const XScanEngine::SCAN_RESULT &)), this, SLOT(scanResult(const XScanEngine::SCAN_RESULT &)), Qt::DirectConnection); 98 | 99 | dieScript.loadDatabaseFromGlobalOptions(getGlobalOptions()); 100 | 101 | XDialogProcess ds(this, &dieScript); 102 | ds.setGlobal(getShortcuts(), getGlobalOptions()); 103 | dieScript.setData(sDirectoryName, &m_scanOptions, ds.getPdStruct()); 104 | ds.start(); 105 | ds.exec(); 106 | } 107 | } 108 | 109 | void DialogDIEScanDirectory::scanResult(const XScanEngine::SCAN_RESULT &scanResult) 110 | { 111 | // TODO 112 | QString sResult = QString("%1 %2 %3").arg(QDir().toNativeSeparators(scanResult.sFileName), QString::number(scanResult.nScanTime), tr("msec")); 113 | sResult += "\r\n"; 114 | 115 | ScanItemModel model(&m_scanOptions, &(scanResult.listRecords), 1); 116 | 117 | sResult += model.toFormattedString(); 118 | 119 | emit resultSignal(sResult); 120 | } 121 | 122 | void DialogDIEScanDirectory::appendResult(const QString &sResult) 123 | { 124 | ui->textBrowserResult->append(sResult); 125 | } 126 | 127 | void DialogDIEScanDirectory::on_pushButtonOK_clicked() 128 | { 129 | this->close(); 130 | } 131 | 132 | void DialogDIEScanDirectory::on_pushButtonClear_clicked() 133 | { 134 | ui->textBrowserResult->clear(); 135 | } 136 | 137 | void DialogDIEScanDirectory::on_pushButtonSave_clicked() 138 | { 139 | QString sFilter = QString("%1 (*.txt)").arg(tr("Text documents")); 140 | QString sSaveFileName = ui->lineEditDirectoryName->text() + QDir::separator() + "result"; 141 | QString sFileName = QFileDialog::getSaveFileName(this, tr("Save result"), sSaveFileName, sFilter); 142 | 143 | if (!sFileName.isEmpty()) { 144 | QFile file; 145 | file.setFileName(sFileName); 146 | 147 | if (file.open(QIODevice::ReadWrite)) { 148 | QString sText = ui->textBrowserResult->toPlainText(); 149 | file.write(sText.toUtf8().data()); 150 | file.close(); 151 | } 152 | } 153 | } 154 | 155 | void DialogDIEScanDirectory::registerShortcuts(bool bState) 156 | { 157 | Q_UNUSED(bState) 158 | } 159 | -------------------------------------------------------------------------------- /diewidgetadvanced.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | DIEWidgetAdvanced 4 | 5 | 6 | 7 | 0 8 | 0 9 | 944 10 | 482 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 0 19 | 20 | 21 | 0 22 | 23 | 24 | 0 25 | 26 | 27 | 0 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 120 36 | 0 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 150 46 | 0 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 150 56 | 0 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | Qt::Horizontal 65 | 66 | 67 | 68 | 40 69 | 20 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 0 79 | 0 80 | 81 | 82 | 83 | Signatures 84 | 85 | 86 | Qt::ToolButtonTextBesideIcon 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 0 95 | 0 96 | 97 | 98 | 99 | Save 100 | 101 | 102 | Qt::ToolButtonTextBesideIcon 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 0 111 | 0 112 | 113 | 114 | 115 | Scan 116 | 117 | 118 | Qt::ToolButtonTextBesideIcon 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | Qt::Vertical 128 | 129 | 130 | 131 | QAbstractItemView::NoEditTriggers 132 | 133 | 134 | false 135 | 136 | 137 | 138 | 139 | Qt::ScrollBarAlwaysOn 140 | 141 | 142 | QPlainTextEdit::NoWrap 143 | 144 | 145 | true 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | true 156 | 157 | 158 | 159 | 160 | 161 | 162 | Qt::Horizontal 163 | 164 | 165 | 166 | 40 167 | 20 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | Qt::Horizontal 176 | 177 | 178 | 179 | 40 180 | 20 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | XComboBoxEx 192 | QComboBox 193 |
xcomboboxex.h
194 |
195 | 196 | DIE_SignatureEdit 197 | QPlainTextEdit 198 |
die_signatureedit.h
199 |
200 |
201 | 202 | 203 |
204 | -------------------------------------------------------------------------------- /diewidgetadvanced.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2019-2025 hors 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 | #include "diewidgetadvanced.h" 22 | #include "ui_diewidgetadvanced.h" 23 | 24 | DIEWidgetAdvanced::DIEWidgetAdvanced(QWidget *pParent) : XShortcutsWidget(pParent), ui(new Ui::DIEWidgetAdvanced) 25 | { 26 | ui->setupUi(this); 27 | 28 | XOptions::adjustToolButton(ui->toolButtonScan, XOptions::ICONTYPE_SCAN); 29 | XOptions::adjustToolButton(ui->toolButtonSave, XOptions::ICONTYPE_SAVE); 30 | XOptions::adjustToolButton(ui->toolButtonSignatures, XOptions::ICONTYPE_SIGNATURE); 31 | 32 | ui->comboBoxType->setToolTip(tr("Type")); 33 | ui->comboBoxFlags->setToolTip(tr("Flags")); 34 | ui->comboBoxDatabases->setToolTip(tr("Database")); 35 | ui->treeViewResult->setToolTip(tr("Result")); 36 | ui->plainTextEditSignature->setToolTip(tr("Signature")); 37 | ui->lineEditSignatureName->setToolTip(tr("Signature name")); 38 | ui->toolButtonSave->setToolTip(tr("Save")); 39 | ui->toolButtonScan->setToolTip(tr("Scan")); 40 | ui->toolButtonSignatures->setToolTip(tr("Signatures")); 41 | 42 | m_scanResult = {}; 43 | m_pDevice = nullptr; 44 | m_pModel = nullptr; 45 | 46 | m_scanOptions = {}; 47 | 48 | ui->comboBoxFlags->setData(XScanEngine::getScanFlags(), XComboBoxEx::CBTYPE_FLAGS, 0, tr("Flags")); 49 | ui->comboBoxDatabases->setData(XScanEngine::getDatabases(), XComboBoxEx::CBTYPE_FLAGS, 0, tr("Database")); 50 | } 51 | 52 | DIEWidgetAdvanced::~DIEWidgetAdvanced() 53 | { 54 | delete ui; 55 | } 56 | 57 | void DIEWidgetAdvanced::setData(QIODevice *pDevice, bool bScan, XBinary::FT fileType) 58 | { 59 | m_pDevice = pDevice; 60 | 61 | XFormats::setFileTypeComboBox(fileType, pDevice, ui->comboBoxType, XBinary::TL_OPTION_ALL); 62 | 63 | if (bScan) { 64 | process(); 65 | } 66 | } 67 | 68 | void DIEWidgetAdvanced::adjustView() 69 | { 70 | getGlobalOptions()->adjustWidget(ui->plainTextEditSignature, XOptions::ID_VIEW_FONT_TEXTEDITS); 71 | getGlobalOptions()->adjustTreeView(ui->treeViewResult, XOptions::ID_VIEW_FONT_TREEVIEWS); 72 | 73 | quint64 nFlags = XScanEngine::getScanFlagsFromGlobalOptions(getGlobalOptions()); 74 | ui->comboBoxFlags->setValue(nFlags); 75 | 76 | quint64 nDatabases = XScanEngine::getDatabasesFromGlobalOptions(getGlobalOptions()); 77 | ui->comboBoxDatabases->setValue(nDatabases); 78 | } 79 | 80 | void DIEWidgetAdvanced::setGlobal(XShortcuts *pShortcuts, XOptions *pXOptions) 81 | { 82 | XShortcutsWidget::setGlobal(pShortcuts, pXOptions); 83 | } 84 | 85 | void DIEWidgetAdvanced::reloadData(bool bSaveSelection) 86 | { 87 | Q_UNUSED(bSaveSelection) 88 | // TODO 89 | process(); 90 | } 91 | 92 | void DIEWidgetAdvanced::registerShortcuts(bool bState) 93 | { 94 | Q_UNUSED(bState) 95 | // TODO 96 | } 97 | 98 | void DIEWidgetAdvanced::process() 99 | { 100 | m_scanOptions.bUseCustomDatabase = true; 101 | m_scanOptions.bUseExtraDatabase = true; 102 | m_scanOptions.bShowType = true; 103 | m_scanOptions.bShowVersion = true; 104 | m_scanOptions.bShowInfo = true; 105 | m_scanOptions.bLogProfiling = false; 106 | m_scanOptions.bShowScanTime = false; 107 | m_scanOptions.fileType = (XBinary::FT)(ui->comboBoxType->currentData().toInt()); 108 | m_scanOptions.nBufferSize = getGlobalOptions()->getValue(XOptions::ID_ENGINE_BUFFERSIZE).toULongLong(); 109 | m_scanOptions.bIsHighlight = getGlobalOptions()->getValue(XOptions::ID_SCAN_HIGHLIGHT).toBool(); 110 | m_scanOptions.bHideUnknown = getGlobalOptions()->getValue(XOptions::ID_SCAN_HIDEUNKNOWN).toBool(); 111 | m_scanOptions.bIsSort = getGlobalOptions()->getValue(XOptions::ID_SCAN_SORT).toBool(); 112 | 113 | DiE_Script dieScript; 114 | 115 | dieScript.loadDatabaseFromGlobalOptions(getGlobalOptions()); // TODO optimize 116 | 117 | quint64 nFlags = ui->comboBoxFlags->getValue().toULongLong(); 118 | XScanEngine::setScanFlags(&m_scanOptions, nFlags); 119 | 120 | quint64 nDatabases = ui->comboBoxDatabases->getValue().toULongLong(); 121 | XScanEngine::setDatabases(&m_scanOptions, nDatabases); 122 | 123 | XScanEngine::SCAN_RESULT scanResult = {}; 124 | 125 | XDialogProcess ds(this, &dieScript); 126 | ds.setGlobal(getShortcuts(), getGlobalOptions()); 127 | dieScript.setData(m_pDevice, &m_scanOptions, &scanResult, ds.getPdStruct()); 128 | ds.start(); 129 | ds.exec(); 130 | 131 | // QAbstractItemModel *pOldModel = ui->treeViewResult->model(); 132 | ScanItemModel *pOldModel = m_pModel; 133 | 134 | m_pModel = new ScanItemModel(&m_scanOptions, &(scanResult.listRecords), 1); 135 | ui->treeViewResult->setModel(m_pModel); 136 | ui->treeViewResult->expandAll(); 137 | 138 | connect(ui->treeViewResult->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), SLOT(onSelectionChanged(QItemSelection, QItemSelection))); 139 | 140 | // deleteOldAbstractModel(&pOldModel); 141 | delete pOldModel; 142 | } 143 | 144 | void DIEWidgetAdvanced::on_toolButtonSave_clicked() 145 | { 146 | QString sSaveFileName = XBinary::getResultFileName(m_pDevice, QString("%1.txt").arg(QString("DiE"))); 147 | 148 | QString _sFileName = QFileDialog::getSaveFileName(this, tr("Save"), sSaveFileName, QString("%1 (*.txt);;%2 (*)").arg(tr("Text files"), tr("All files"))); 149 | 150 | if (!_sFileName.isEmpty()) { 151 | if (!XOptions::saveTreeView(ui->treeViewResult, sSaveFileName)) { 152 | QMessageBox::critical(XOptions::getMainWidget(this), tr("Error"), QString("%1: %2").arg(tr("Cannot save file"), _sFileName)); 153 | } 154 | } 155 | } 156 | 157 | void DIEWidgetAdvanced::on_toolButtonScan_clicked() 158 | { 159 | process(); 160 | } 161 | 162 | void DIEWidgetAdvanced::onSelectionChanged(const QItemSelection &itemSelected, const QItemSelection &itemDeselected) 163 | { 164 | Q_UNUSED(itemDeselected) 165 | 166 | ui->plainTextEditSignature->clear(); 167 | ui->lineEditSignatureName->clear(); 168 | 169 | QModelIndexList listSelected = itemSelected.indexes(); 170 | 171 | if (listSelected.count() >= 1) { 172 | QString sSignatureName = listSelected.at(0).data(Qt::UserRole + ScanItemModel::UD_INFO).toString(); 173 | QString sSignatureFileName = listSelected.at(0).data(Qt::UserRole + ScanItemModel::UD_INFO2).toString(); // TODO 174 | 175 | QByteArray baData = XBinary::readFile(sSignatureFileName); 176 | ui->plainTextEditSignature->setPlainText(baData); 177 | ui->lineEditSignatureName->setText(sSignatureName); 178 | } 179 | } 180 | 181 | void DIEWidgetAdvanced::on_comboBoxType_currentIndexChanged(int nIndex) 182 | { 183 | Q_UNUSED(nIndex) 184 | 185 | process(); 186 | } 187 | 188 | void DIEWidgetAdvanced::on_toolButtonSignatures_clicked() 189 | { 190 | DiE_Script dieScript; 191 | dieScript.loadDatabaseFromGlobalOptions(getGlobalOptions()); 192 | 193 | DialogDIESignatures dialogSignatures(this, &dieScript); 194 | dialogSignatures.setGlobal(getShortcuts(), getGlobalOptions()); 195 | dialogSignatures.setData(m_pDevice, (XBinary::FT)(ui->comboBoxType->currentData().toInt()), ""); 196 | 197 | dialogSignatures.exec(); 198 | } 199 | -------------------------------------------------------------------------------- /dieoptionswidget.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2019-2025 hors 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 | #include "dieoptionswidget.h" 22 | 23 | #include "ui_dieoptionswidget.h" 24 | 25 | DIEOptionsWidget::DIEOptionsWidget(QWidget *pParent) : XShortcutsWidget(pParent), ui(new Ui::DIEOptionsWidget) 26 | { 27 | ui->setupUi(this); 28 | 29 | #ifndef USE_YARA 30 | ui->groupBoxYaraRules->hide(); 31 | #endif 32 | } 33 | 34 | DIEOptionsWidget::~DIEOptionsWidget() 35 | { 36 | delete ui; 37 | } 38 | 39 | void DIEOptionsWidget::adjustView() 40 | { 41 | // TODO 42 | } 43 | 44 | void DIEOptionsWidget::setOptions(XOptions *pOptions) 45 | { 46 | m_pOptions = pOptions; 47 | 48 | reload(); 49 | } 50 | 51 | void DIEOptionsWidget::save() 52 | { 53 | m_pOptions->getCheckBox(ui->checkBoxDeepScan, XOptions::ID_SCAN_FLAG_DEEP); 54 | m_pOptions->getCheckBox(ui->checkBoxScanAfterOpen, XOptions::ID_SCAN_SCANAFTEROPEN); 55 | m_pOptions->getCheckBox(ui->checkBoxRecursiveScan, XOptions::ID_SCAN_FLAG_RECURSIVE); 56 | m_pOptions->getCheckBox(ui->checkBoxHeuristicScan, XOptions::ID_SCAN_FLAG_HEURISTIC); 57 | m_pOptions->getCheckBox(ui->checkBoxAggressiveScan, XOptions::ID_SCAN_FLAG_AGGRESSIVE); 58 | m_pOptions->getCheckBox(ui->checkBoxVerbose, XOptions::ID_SCAN_FLAG_VERBOSE); 59 | m_pOptions->getCheckBox(ui->checkBoxAllTypesScan, XOptions::ID_SCAN_FLAG_ALLTYPES); 60 | m_pOptions->getCheckBox(ui->checkBoxFormatResult, XOptions::ID_SCAN_FORMATRESULT); 61 | m_pOptions->getCheckBox(ui->checkBoxProfiling, XOptions::ID_SCAN_LOG_PROFILING); 62 | m_pOptions->getCheckBox(ui->checkBoxHighlight, XOptions::ID_SCAN_HIGHLIGHT); 63 | m_pOptions->getCheckBox(ui->checkBoxSort, XOptions::ID_SCAN_SORT); 64 | m_pOptions->getCheckBox(ui->checkBoxHideUnknown, XOptions::ID_SCAN_HIDEUNKNOWN); 65 | m_pOptions->getLineEdit(ui->lineEditDIEDatabase, XOptions::ID_SCAN_DATABASE_MAIN_PATH); 66 | m_pOptions->getLineEdit(ui->lineEditDIEDatabaseExtra, XOptions::ID_SCAN_DATABASE_EXTRA_PATH); 67 | m_pOptions->getLineEdit(ui->lineEditDIEDatabaseCustom, XOptions::ID_SCAN_DATABASE_CUSTOM_PATH); 68 | m_pOptions->getCheckBox(ui->groupBoxDIEDatabaseExtra, XOptions::ID_SCAN_DATABASE_EXTRA_ENABLED); 69 | m_pOptions->getCheckBox(ui->groupBoxDIEDatabaseCustom, XOptions::ID_SCAN_DATABASE_CUSTOM_ENABLED); 70 | #ifdef USE_YARA 71 | if (m_pOptions->isIDPresent(XOptions::ID_SCAN_YARARULESPATH)) { 72 | m_pOptions->getLineEdit(ui->lineEditYaraRules, XOptions::ID_SCAN_YARARULESPATH); 73 | } 74 | #endif 75 | if (m_pOptions->isIDPresent(XOptions::ID_SCAN_ENGINE)) { 76 | m_pOptions->getComboBox(ui->comboBoxScanEngine, XOptions::ID_SCAN_ENGINE); 77 | } else if (m_pOptions->isIDPresent(XOptions::ID_SCAN_ENGINE_EMPTY)) { 78 | m_pOptions->getComboBox(ui->comboBoxScanEngine, XOptions::ID_SCAN_ENGINE_EMPTY); 79 | } 80 | } 81 | 82 | void DIEOptionsWidget::reload() 83 | { 84 | m_pOptions->setCheckBox(ui->checkBoxScanAfterOpen, XOptions::ID_SCAN_SCANAFTEROPEN); 85 | m_pOptions->setCheckBox(ui->checkBoxRecursiveScan, XOptions::ID_SCAN_FLAG_RECURSIVE); 86 | m_pOptions->setCheckBox(ui->checkBoxDeepScan, XOptions::ID_SCAN_FLAG_DEEP); 87 | m_pOptions->setCheckBox(ui->checkBoxHeuristicScan, XOptions::ID_SCAN_FLAG_HEURISTIC); 88 | m_pOptions->setCheckBox(ui->checkBoxAggressiveScan, XOptions::ID_SCAN_FLAG_AGGRESSIVE); 89 | m_pOptions->setCheckBox(ui->checkBoxVerbose, XOptions::ID_SCAN_FLAG_VERBOSE); 90 | m_pOptions->setCheckBox(ui->checkBoxFormatResult, XOptions::ID_SCAN_FORMATRESULT); 91 | m_pOptions->setCheckBox(ui->checkBoxAllTypesScan, XOptions::ID_SCAN_FLAG_ALLTYPES); 92 | m_pOptions->setCheckBox(ui->checkBoxHighlight, XOptions::ID_SCAN_HIGHLIGHT); 93 | m_pOptions->setCheckBox(ui->checkBoxSort, XOptions::ID_SCAN_SORT); 94 | m_pOptions->setCheckBox(ui->checkBoxHideUnknown, XOptions::ID_SCAN_HIDEUNKNOWN); 95 | m_pOptions->setCheckBox(ui->checkBoxProfiling, XOptions::ID_SCAN_LOG_PROFILING); 96 | m_pOptions->setLineEdit(ui->lineEditDIEDatabase, XOptions::ID_SCAN_DATABASE_MAIN_PATH); 97 | m_pOptions->setLineEdit(ui->lineEditDIEDatabaseExtra, XOptions::ID_SCAN_DATABASE_EXTRA_PATH); 98 | m_pOptions->setLineEdit(ui->lineEditDIEDatabaseCustom, XOptions::ID_SCAN_DATABASE_CUSTOM_PATH); 99 | m_pOptions->setLineEdit(ui->lineEditYaraRules, XOptions::ID_SCAN_YARARULESPATH); 100 | m_pOptions->setCheckBox(ui->groupBoxDIEDatabaseExtra, XOptions::ID_SCAN_DATABASE_EXTRA_ENABLED); 101 | m_pOptions->setCheckBox(ui->groupBoxDIEDatabaseCustom, XOptions::ID_SCAN_DATABASE_CUSTOM_ENABLED); 102 | 103 | if (m_pOptions->isIDPresent(XOptions::ID_SCAN_YARARULESPATH)) { 104 | ui->groupBoxYaraRules->show(); 105 | m_pOptions->getLineEdit(ui->lineEditYaraRules, XOptions::ID_SCAN_YARARULESPATH); 106 | } else { 107 | ui->groupBoxYaraRules->hide(); 108 | } 109 | 110 | if (m_pOptions->isIDPresent(XOptions::ID_SCAN_ENGINE)) { 111 | ui->groupBoxScanEngine->show(); 112 | m_pOptions->setComboBox(ui->comboBoxScanEngine, XOptions::ID_SCAN_ENGINE); 113 | } else if (m_pOptions->isIDPresent(XOptions::ID_SCAN_ENGINE_EMPTY)) { 114 | ui->groupBoxScanEngine->show(); 115 | m_pOptions->setComboBox(ui->comboBoxScanEngine, XOptions::ID_SCAN_ENGINE_EMPTY); 116 | } else { 117 | ui->groupBoxScanEngine->hide(); 118 | } 119 | } 120 | 121 | void DIEOptionsWidget::setDefaultValues(XOptions *pOptions) 122 | { 123 | pOptions->addID(XOptions::ID_SCAN_SCANAFTEROPEN, true); 124 | pOptions->addID(XOptions::ID_SCAN_FLAG_RECURSIVE, true); 125 | pOptions->addID(XOptions::ID_SCAN_FLAG_DEEP, true); 126 | pOptions->addID(XOptions::ID_SCAN_FLAG_HEURISTIC, true); 127 | pOptions->addID(XOptions::ID_SCAN_FLAG_AGGRESSIVE, false); 128 | pOptions->addID(XOptions::ID_SCAN_FLAG_VERBOSE, true); 129 | pOptions->addID(XOptions::ID_SCAN_FLAG_ALLTYPES, false); 130 | pOptions->addID(XOptions::ID_SCAN_FORMATRESULT, true); 131 | pOptions->addID(XOptions::ID_SCAN_LOG_PROFILING, false); 132 | pOptions->addID(XOptions::ID_SCAN_HIGHLIGHT, true); 133 | pOptions->addID(XOptions::ID_SCAN_SORT, true); 134 | pOptions->addID(XOptions::ID_SCAN_HIDEUNKNOWN, false); 135 | pOptions->addID(XOptions::ID_SCAN_DATABASE_MAIN_PATH, "$data/db"); 136 | pOptions->addID(XOptions::ID_SCAN_DATABASE_EXTRA_PATH, "$data/db_extra"); 137 | pOptions->addID(XOptions::ID_SCAN_DATABASE_CUSTOM_PATH, "$data/db_custom"); 138 | pOptions->addID(XOptions::ID_SCAN_DATABASE_EXTRA_ENABLED, true); 139 | pOptions->addID(XOptions::ID_SCAN_DATABASE_CUSTOM_ENABLED, true); 140 | pOptions->addID(XOptions::ID_ENGINE_BUFFERSIZE, 2 * 1024 * 1024); // Obsolete TODO remove 141 | } 142 | 143 | void DIEOptionsWidget::reloadData(bool bSaveSelection) 144 | { 145 | Q_UNUSED(bSaveSelection) 146 | 147 | reload(); 148 | } 149 | 150 | void DIEOptionsWidget::on_toolButtonDIEDatabase_clicked() 151 | { 152 | QString sText = ui->lineEditDIEDatabase->text(); 153 | QString sInitDirectory = XBinary::convertPathName(sText); 154 | 155 | QString sDirectoryName = QFileDialog::getExistingDirectory(this, tr("Open directory") + QString("..."), sInitDirectory, QFileDialog::ShowDirsOnly); 156 | 157 | if (!sDirectoryName.isEmpty()) { 158 | ui->lineEditDIEDatabase->setText(sDirectoryName); 159 | } 160 | } 161 | 162 | void DIEOptionsWidget::on_toolButtonDIEDatabaseExtra_clicked() 163 | { 164 | QString sText = ui->lineEditDIEDatabaseExtra->text(); 165 | QString sInitDirectory = XBinary::convertPathName(sText); 166 | 167 | QString sDirectoryName = QFileDialog::getExistingDirectory(this, tr("Open directory") + QString("..."), sInitDirectory, QFileDialog::ShowDirsOnly); 168 | 169 | if (!sDirectoryName.isEmpty()) { 170 | ui->lineEditDIEDatabaseExtra->setText(sDirectoryName); 171 | } 172 | } 173 | 174 | void DIEOptionsWidget::on_toolButtonDIEDatabaseCustom_clicked() 175 | { 176 | QString sText = ui->lineEditDIEDatabaseCustom->text(); 177 | QString sInitDirectory = XBinary::convertPathName(sText); 178 | 179 | QString sDirectoryName = QFileDialog::getExistingDirectory(this, tr("Open directory") + QString("..."), sInitDirectory, QFileDialog::ShowDirsOnly); 180 | 181 | if (!sDirectoryName.isEmpty()) { 182 | ui->lineEditDIEDatabaseCustom->setText(sDirectoryName); 183 | } 184 | } 185 | 186 | void DIEOptionsWidget::on_toolButtonYaraRules_clicked() 187 | { 188 | QString sText = ui->lineEditYaraRules->text(); 189 | QString sInitDirectory = XBinary::convertPathName(sText); 190 | 191 | QString sDirectoryName = QFileDialog::getExistingDirectory(this, tr("Open directory") + QString("..."), sInitDirectory, QFileDialog::ShowDirsOnly); 192 | 193 | if (!sDirectoryName.isEmpty()) { 194 | ui->lineEditYaraRules->setText(sDirectoryName); 195 | } 196 | } 197 | 198 | void DIEOptionsWidget::registerShortcuts(bool bState) 199 | { 200 | Q_UNUSED(bState) 201 | } 202 | -------------------------------------------------------------------------------- /dialogdiesignatures.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | DialogDIESignatures 4 | 5 | 6 | Qt::WindowModal 7 | 8 | 9 | 10 | 0 11 | 0 12 | 1001 13 | 509 14 | 15 | 16 | 17 | Signatures 18 | 19 | 20 | true 21 | 22 | 23 | 24 | 25 | 26 | Qt::Horizontal 27 | 28 | 29 | 30 | 31 | 200 32 | 0 33 | 34 | 35 | 36 | 37 | 400 38 | 16777215 39 | 40 | 41 | 42 | 43 | 0 44 | 45 | 46 | 0 47 | 48 | 49 | 0 50 | 51 | 52 | 0 53 | 54 | 55 | 56 | 57 | QAbstractItemView::NoEditTriggers 58 | 59 | 60 | false 61 | 62 | 63 | 64 | 1 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | Save 79 | 80 | 81 | 82 | 83 | 84 | 85 | Readonly 86 | 87 | 88 | 89 | 90 | 91 | 92 | Qt::Horizontal 93 | 94 | 95 | 96 | 68 97 | 20 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 100 107 | 0 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | Run 116 | 117 | 118 | 119 | 120 | 121 | 122 | Debug 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | Recursive scan 134 | 135 | 136 | 137 | 138 | 139 | 140 | Deep scan 141 | 142 | 143 | 144 | 145 | 146 | 147 | Verbose 148 | 149 | 150 | 151 | 152 | 153 | 154 | Heuristic scan 155 | 156 | 157 | 158 | 159 | 160 | 161 | Profiling 162 | 163 | 164 | 165 | 166 | 167 | 168 | Qt::Horizontal 169 | 170 | 171 | 172 | 40 173 | 20 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | Find 186 | 187 | 188 | 189 | 190 | 191 | 192 | Next 193 | 194 | 195 | 196 | 197 | 198 | 199 | Qt::Horizontal 200 | 201 | 202 | 203 | 40 204 | 20 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | Detect 213 | 214 | 215 | 216 | 0 217 | 218 | 219 | 0 220 | 221 | 222 | 0 223 | 224 | 225 | 0 226 | 227 | 228 | 229 | 230 | Show type 231 | 232 | 233 | 234 | 235 | 236 | 237 | Show version 238 | 239 | 240 | 241 | 242 | 243 | 244 | Show info 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 0 261 | 0 262 | 263 | 264 | 265 | true 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | Qt::AlignCenter 275 | 276 | 277 | true 278 | 279 | 280 | 281 | 282 | 283 | 284 | Qt::Horizontal 285 | 286 | 287 | 288 | 40 289 | 20 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | Clear result 298 | 299 | 300 | 301 | 302 | 303 | 304 | Close 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | DIE_SignatureEdit 319 | QPlainTextEdit 320 |
die_signatureedit.h
321 |
322 |
323 | 324 | 325 |
326 | -------------------------------------------------------------------------------- /die_widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | DIE_Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 873 10 | 645 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 0 19 | 20 | 21 | 0 22 | 23 | 24 | 0 25 | 26 | 27 | 0 28 | 29 | 30 | 31 | 32 | Qt::CustomContextMenu 33 | 34 | 35 | QAbstractItemView::NoEditTriggers 36 | 37 | 38 | QAbstractItemView::SingleSelection 39 | 40 | 41 | QAbstractItemView::SelectItems 42 | 43 | 44 | false 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 0 53 | 0 54 | 55 | 56 | 57 | 58 | 16777215 59 | 60 60 | 61 | 62 | 63 | 0 64 | 65 | 66 | 67 | 68 | 0 69 | 70 | 71 | 0 72 | 73 | 74 | 0 75 | 76 | 77 | 0 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | Signatures 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 150 95 | 0 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 150 105 | 0 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | Qt::Horizontal 114 | 115 | 116 | 117 | 0 118 | 0 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | Directory 131 | 132 | 133 | 134 | 135 | 136 | 137 | Log 138 | 139 | 140 | 141 | 142 | 143 | 144 | Qt::Horizontal 145 | 146 | 147 | 148 | 0 149 | 0 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 0 159 | 0 160 | 161 | 162 | 163 | 164 | 23 165 | 16777215 166 | 167 | 168 | 169 | > 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 0 178 | 0 179 | 180 | 181 | 182 | 183 | 90 184 | 0 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 0 201 | 0 202 | 203 | 204 | 205 | 206 | 100 207 | 0 208 | 209 | 210 | 211 | Scan 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 0 221 | 222 | 223 | 0 224 | 225 | 226 | 0 227 | 228 | 229 | 0 230 | 231 | 232 | 233 | 234 | 0 235 | 236 | 237 | 238 | 239 | 0 240 | 241 | 242 | 0 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 0 253 | 254 | 255 | 0 256 | 257 | 258 | true 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 0 269 | 270 | 271 | 0 272 | 273 | 274 | true 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 0 285 | 286 | 287 | 0 288 | 289 | 290 | true 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 0 301 | 302 | 303 | 0 304 | 305 | 306 | true 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | Qt::Horizontal 317 | 318 | 319 | 320 | 40 321 | 2 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 0 333 | 0 334 | 335 | 336 | 337 | 338 | 100 339 | 0 340 | 341 | 342 | 343 | Stop 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | XComboBoxEx 356 | QComboBox 357 |
xcomboboxex.h
358 |
359 |
360 | 361 | 362 |
363 | -------------------------------------------------------------------------------- /dieoptionswidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | DIEOptionsWidget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 466 10 | 567 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 0 19 | 20 | 21 | 0 22 | 23 | 24 | 0 25 | 26 | 27 | 0 28 | 29 | 30 | 31 | 32 | QFrame::NoFrame 33 | 34 | 35 | QFrame::Plain 36 | 37 | 38 | 0 39 | 40 | 41 | true 42 | 43 | 44 | 45 | 46 | 0 47 | 0 48 | 466 49 | 567 50 | 51 | 52 | 53 | 54 | 0 55 | 56 | 57 | 0 58 | 59 | 60 | 0 61 | 62 | 63 | 0 64 | 65 | 66 | 67 | 68 | Scan after open 69 | 70 | 71 | 72 | 73 | 74 | 75 | Flags 76 | 77 | 78 | 79 | 6 80 | 81 | 82 | 6 83 | 84 | 85 | 1 86 | 87 | 88 | 1 89 | 90 | 91 | 1 92 | 93 | 94 | 1 95 | 96 | 97 | 98 | 99 | Recursive scan 100 | 101 | 102 | 103 | 104 | 105 | 106 | Aggressive scan 107 | 108 | 109 | 110 | 111 | 112 | 113 | Deep scan 114 | 115 | 116 | 117 | 118 | 119 | 120 | Verbose 121 | 122 | 123 | 124 | 125 | 126 | 127 | Heuristic scan 128 | 129 | 130 | 131 | 132 | 133 | 134 | All types 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 0 146 | 50 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 1 155 | 156 | 157 | 1 158 | 159 | 160 | 1 161 | 162 | 163 | 1 164 | 165 | 166 | 167 | 168 | Sort 169 | 170 | 171 | 172 | 173 | 174 | 175 | Highlight 176 | 177 | 178 | 179 | 180 | 181 | 182 | Format result 183 | 184 | 185 | 186 | 187 | 188 | 189 | Profiling 190 | 191 | 192 | 193 | 194 | 195 | 196 | Hide unknown 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | Scan 207 | 208 | 209 | Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter 210 | 211 | 212 | 213 | 2 214 | 215 | 216 | 2 217 | 218 | 219 | 2 220 | 221 | 222 | 2 223 | 224 | 225 | 226 | 227 | 228 | 200 229 | 0 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | Database 241 | 242 | 243 | 244 | 2 245 | 246 | 247 | 2 248 | 249 | 250 | 2 251 | 252 | 253 | 2 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | ... 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | Extra database 272 | 273 | 274 | true 275 | 276 | 277 | 278 | 2 279 | 280 | 281 | 2 282 | 283 | 284 | 2 285 | 286 | 287 | 2 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | ... 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | Custom database 306 | 307 | 308 | true 309 | 310 | 311 | 312 | 2 313 | 314 | 315 | 2 316 | 317 | 318 | 2 319 | 320 | 321 | 2 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | ... 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | YARA 340 | 341 | 342 | 343 | 2 344 | 345 | 346 | 2 347 | 348 | 349 | 2 350 | 351 | 352 | 2 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | ... 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | Qt::Vertical 371 | 372 | 373 | 374 | 20 375 | 40 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | -------------------------------------------------------------------------------- /dialogdiesignatures.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2019-2025 hors 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 | #include "dialogdiesignatures.h" 22 | 23 | #include "ui_dialogdiesignatures.h" 24 | 25 | DialogDIESignatures::DialogDIESignatures(QWidget *pParent, DiE_Script *pDieScript) : XShortcutsDialog(pParent, true), ui(new Ui::DialogDIESignatures) 26 | { 27 | ui->setupUi(this); 28 | 29 | addShortcut(X_ID_SCAN_EDITOR_FIND_STRING, this, SLOT(findString())); 30 | addShortcut(X_ID_SCAN_EDITOR_FIND_NEXT, this, SLOT(findNext())); 31 | 32 | m_data = {}; 33 | 34 | this->m_pDieScript = pDieScript; 35 | 36 | connect(pDieScript, SIGNAL(infoMessage(QString)), this, SLOT(infoMessage(QString))); 37 | connect(pDieScript, SIGNAL(warningMessage(QString)), this, SLOT(warningMessage(QString))); 38 | connect(pDieScript, SIGNAL(errorMessage(QString)), this, SLOT(errorMessage(QString))); 39 | 40 | ui->plainTextEditSignature->setLineWrapMode(QPlainTextEdit::NoWrap); 41 | 42 | ui->treeWidgetSignatures->setSortingEnabled(false); 43 | 44 | QTreeWidgetItem *pRootItem = new QTreeWidgetItem(ui->treeWidgetSignatures); 45 | pRootItem->setText(0, tr("Database")); 46 | 47 | _handleTreeItems(pRootItem, XBinary::FT_UNKNOWN); 48 | 49 | handleTreeItems(pRootItem, XBinary::FT_BINARY, "Binary"); 50 | handleTreeItems(pRootItem, XBinary::FT_COM, "COM"); 51 | handleTreeItems(pRootItem, XBinary::FT_ARCHIVE, "Archive"); 52 | handleTreeItems(pRootItem, XBinary::FT_MSDOS, "MSDOS"); 53 | handleTreeItems(pRootItem, XBinary::FT_NE, "NE"); 54 | handleTreeItems(pRootItem, XBinary::FT_LE, "LE"); 55 | handleTreeItems(pRootItem, XBinary::FT_LX, "LX"); 56 | handleTreeItems(pRootItem, XBinary::FT_PE, "PE"); 57 | handleTreeItems(pRootItem, XBinary::FT_MACHO, "MACH"); 58 | handleTreeItems(pRootItem, XBinary::FT_ELF, "ELF"); 59 | handleTreeItems(pRootItem, XBinary::FT_ZIP, "ZIP"); 60 | handleTreeItems(pRootItem, XBinary::FT_JAR, "JAR"); 61 | handleTreeItems(pRootItem, XBinary::FT_APK, "APK"); 62 | handleTreeItems(pRootItem, XBinary::FT_IPA, "IPA"); 63 | handleTreeItems(pRootItem, XBinary::FT_DEX, "DEX"); 64 | handleTreeItems(pRootItem, XBinary::FT_NPM, "NPM"); 65 | handleTreeItems(pRootItem, XBinary::FT_MACHOFAT, "MACHOFAT"); 66 | handleTreeItems(pRootItem, XBinary::FT_DEB, "DEB"); 67 | handleTreeItems(pRootItem, XBinary::FT_DOS16M, "DOS16M"); 68 | handleTreeItems(pRootItem, XBinary::FT_DOS4G, "DOS4G"); 69 | handleTreeItems(pRootItem, XBinary::FT_AMIGAHUNK, "Amiga"); 70 | handleTreeItems(pRootItem, XBinary::FT_JAVACLASS, "JavaClass"); 71 | handleTreeItems(pRootItem, XBinary::FT_PDF, "PDF"); 72 | handleTreeItems(pRootItem, XBinary::FT_JPEG, "JPEG"); 73 | handleTreeItems(pRootItem, XBinary::FT_RAR, "RAR"); 74 | 75 | ui->treeWidgetSignatures->setSortingEnabled(true); 76 | ui->treeWidgetSignatures->sortByColumn(0, Qt::AscendingOrder); 77 | 78 | m_bCurrentEdited = false; 79 | ui->pushButtonSave->setEnabled(false); 80 | 81 | ui->checkBoxShowType->setChecked(true); 82 | ui->checkBoxShowInfo->setChecked(true); 83 | ui->checkBoxShowVersion->setChecked(true); 84 | ui->checkBoxDeepScan->setChecked(true); 85 | ui->checkBoxHeuristicScan->setChecked(true); 86 | ui->checkBoxRecursiveScan->setChecked(false); 87 | ui->checkBoxVerbose->setChecked(true); 88 | ui->checkBoxProfiling->setChecked(true); 89 | 90 | ui->checkBoxReadOnly->setChecked(true); 91 | 92 | ui->comboBoxFunction->addItem("detect", "detect"); 93 | 94 | #ifndef QT_SCRIPTTOOLS_LIB 95 | ui->pushButtonDebug->hide(); 96 | #endif 97 | } 98 | 99 | DialogDIESignatures::~DialogDIESignatures() 100 | { 101 | delete ui; 102 | } 103 | 104 | void DialogDIESignatures::setData(QIODevice *pDevice, XBinary::FT fileType, const QString &sSignature) 105 | { 106 | this->m_pDevice = pDevice; 107 | this->m_fileType = fileType; 108 | this->m_sSignature = sSignature; 109 | 110 | if (m_fileType != XBinary::FT_UNKNOWN) { 111 | qint32 nNumberOfTopLevelItems = ui->treeWidgetSignatures->topLevelItemCount(); 112 | 113 | for (qint32 i = 0; i < nNumberOfTopLevelItems; i++) { 114 | if (_setTreeItem(ui->treeWidgetSignatures, ui->treeWidgetSignatures->topLevelItem(i), fileType, sSignature)) { 115 | break; 116 | } 117 | } 118 | } else { 119 | ui->treeWidgetSignatures->expandAll(); 120 | } 121 | } 122 | 123 | void DialogDIESignatures::adjustView() 124 | { 125 | getGlobalOptions()->adjustWidget(this, XOptions::ID_VIEW_FONT_CONTROLS); 126 | getGlobalOptions()->adjustWidget(ui->plainTextEditSignature, XOptions::ID_VIEW_FONT_TEXTEDITS); 127 | } 128 | 129 | qint32 DialogDIESignatures::handleTreeItems(QTreeWidgetItem *pRootItem, XBinary::FT fileType, const QString &sText) 130 | { 131 | qint32 nResult = 0; 132 | 133 | if (m_pDieScript->isSignaturesPresent(fileType)) { 134 | QTreeWidgetItem *pItem = new QTreeWidgetItem(pRootItem); 135 | pItem->setText(0, sText); 136 | nResult = _handleTreeItems(pItem, fileType); 137 | } 138 | 139 | return nResult; 140 | } 141 | 142 | qint32 DialogDIESignatures::_handleTreeItems(QTreeWidgetItem *pItemParent, XBinary::FT fileType) 143 | { 144 | qint32 nResult = 0; 145 | 146 | QList *pListSignatures = m_pDieScript->getSignatures(); 147 | 148 | qint32 nNumberOfSignatures = pListSignatures->count(); 149 | 150 | for (qint32 i = 0; i < nNumberOfSignatures; i++) { 151 | if (pListSignatures->at(i).fileType == fileType) { 152 | QTreeWidgetItem *pRootItem = new QTreeWidgetItem(pItemParent); 153 | pRootItem->setText(0, pListSignatures->at(i).sName); 154 | pRootItem->setData(0, Qt::UserRole + UD_FILEPATH, pListSignatures->at(i).sFilePath); 155 | pRootItem->setData(0, Qt::UserRole + UD_FILETYPE, pListSignatures->at(i).fileType); 156 | pRootItem->setData(0, Qt::UserRole + UD_NAME, pListSignatures->at(i).sName); 157 | 158 | nResult++; 159 | } 160 | } 161 | 162 | return nResult; 163 | } 164 | 165 | void DialogDIESignatures::runScript(const QString &sFunction, bool bIsDebug) 166 | { 167 | enableControls(false); 168 | 169 | QTreeWidgetItem *pItemCurrent = ui->treeWidgetSignatures->currentItem(); 170 | 171 | if (pItemCurrent) { 172 | if (m_bCurrentEdited) { 173 | save(); 174 | } 175 | 176 | ui->plainTextEditResult->clear(); 177 | 178 | XScanEngine::SCAN_OPTIONS scanOptions = {}; 179 | 180 | scanOptions.bUseCustomDatabase = true; 181 | scanOptions.bUseExtraDatabase = true; 182 | scanOptions.bShowType = ui->checkBoxShowType->isChecked(); 183 | scanOptions.bShowInfo = ui->checkBoxShowInfo->isChecked(); 184 | scanOptions.bShowVersion = ui->checkBoxShowVersion->isChecked(); 185 | scanOptions.bIsDeepScan = ui->checkBoxDeepScan->isChecked(); 186 | scanOptions.bIsHeuristicScan = ui->checkBoxHeuristicScan->isChecked(); 187 | scanOptions.bIsVerbose = ui->checkBoxVerbose->isChecked(); 188 | scanOptions.bIsRecursiveScan = ui->checkBoxRecursiveScan->isChecked(); 189 | scanOptions.bLogProfiling = ui->checkBoxProfiling->isChecked(); 190 | scanOptions.nBufferSize = getGlobalOptions()->getValue(XOptions::ID_ENGINE_BUFFERSIZE).toLongLong(); 191 | 192 | scanOptions.sSignatureName = pItemCurrent->data(0, Qt::UserRole + UD_NAME).toString(); 193 | scanOptions.fileType = (XBinary::FT)ui->treeWidgetSignatures->currentItem()->data(0, Qt::UserRole + UD_FILETYPE).toInt(); 194 | scanOptions.sDetectFunction = sFunction; 195 | 196 | XScanEngine::SCAN_RESULT scanResult = {}; 197 | 198 | if (bIsDebug) { 199 | #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) 200 | QScriptEngineDebugger debugger(this); 201 | QMainWindow *debugWindow = debugger.standardWindow(); 202 | debugWindow->setWindowModality(Qt::WindowModal); 203 | debugWindow->setWindowTitle(tr("Debugger")); 204 | // debugWindow->resize(600,350); 205 | m_pDieScript->setDebugger(&debugger); 206 | #endif 207 | 208 | scanResult = m_pDieScript->scanDevice(m_pDevice, &scanOptions); 209 | } else { 210 | scanResult = m_pDieScript->scanDevice(m_pDevice, &scanOptions); 211 | } 212 | 213 | if (bIsDebug) { 214 | #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) 215 | m_pDieScript->removeDebugger(); 216 | #endif 217 | } 218 | 219 | ScanItemModel model(&scanOptions, &(scanResult.listRecords), 1); 220 | 221 | ui->plainTextEditResult->appendPlainText(model.toFormattedString()); 222 | 223 | if (scanResult.listErrors.count()) { 224 | ui->plainTextEditResult->appendPlainText(DiE_Script::getErrorsString(&scanResult)); 225 | } 226 | 227 | ui->lineEditElapsedTime->setText(QString("%1 %2").arg(scanResult.nScanTime).arg(tr("msec"))); 228 | // TODO only scripts for this type if not messagebox 229 | } 230 | 231 | enableControls(true); 232 | } 233 | 234 | void DialogDIESignatures::on_treeWidgetSignatures_currentItemChanged(QTreeWidgetItem *pItemCurrent, QTreeWidgetItem *pItemPrevious) 235 | { 236 | Q_UNUSED(pItemPrevious) 237 | 238 | QString sSignatureFilePath = pItemCurrent->data(0, Qt::UserRole).toString(); 239 | 240 | if (sSignatureFilePath != m_sCurrentSignatureFilePath) { 241 | const bool bBlocked1 = ui->plainTextEditSignature->blockSignals(true); 242 | 243 | if (m_bCurrentEdited) { 244 | // TODO handle warning 245 | } 246 | 247 | m_sCurrentSignatureFilePath = sSignatureFilePath; 248 | DiE_ScriptEngine::SIGNATURE_RECORD signatureRecord = m_pDieScript->getSignatureByFilePath(m_sCurrentSignatureFilePath); 249 | 250 | ui->plainTextEditSignature->setPlainText(signatureRecord.sText); 251 | ui->pushButtonSave->setEnabled(false); 252 | 253 | ui->plainTextEditSignature->blockSignals(bBlocked1); 254 | } 255 | } 256 | 257 | void DialogDIESignatures::on_pushButtonSave_clicked() 258 | { 259 | save(); 260 | } 261 | 262 | void DialogDIESignatures::save() 263 | { 264 | if (m_pDieScript->updateSignature(m_sCurrentSignatureFilePath, ui->plainTextEditSignature->toPlainText())) { 265 | m_bCurrentEdited = false; 266 | ui->pushButtonSave->setEnabled(false); 267 | } else { 268 | // Handle error 269 | } 270 | } 271 | 272 | void DialogDIESignatures::on_pushButtonRun_clicked() 273 | { 274 | runScript(ui->comboBoxFunction->currentData().toString(), false); 275 | } 276 | 277 | void DialogDIESignatures::on_pushButtonDebug_clicked() 278 | { 279 | runScript(ui->comboBoxFunction->currentData().toString(), true); 280 | } 281 | 282 | void DialogDIESignatures::on_pushButtonClearResult_clicked() 283 | { 284 | ui->plainTextEditResult->clear(); 285 | } 286 | 287 | void DialogDIESignatures::on_pushButtonClose_clicked() 288 | { 289 | this->close(); 290 | } 291 | 292 | void DialogDIESignatures::on_plainTextEditSignature_textChanged() 293 | { 294 | m_bCurrentEdited = true; 295 | ui->pushButtonSave->setEnabled(true); 296 | } 297 | 298 | void DialogDIESignatures::on_checkBoxReadOnly_toggled(bool bChecked) 299 | { 300 | ui->plainTextEditSignature->setReadOnly(bChecked); 301 | } 302 | 303 | bool DialogDIESignatures::_setTreeItem(QTreeWidget *pTree, QTreeWidgetItem *pItem, XBinary::FT fileType, const QString &sSignature) 304 | { 305 | bool bResult = false; 306 | 307 | XBinary::FT _fileType = (XBinary::FT)pItem->data(0, Qt::UserRole + UD_FILETYPE).toInt(); 308 | QString _sSignature = pItem->data(0, Qt::UserRole + UD_NAME).toString(); 309 | 310 | if ((XBinary::checkFileType(_fileType, fileType)) && ((sSignature == "") || (_sSignature == sSignature))) { 311 | pTree->setCurrentItem(pItem); 312 | 313 | bResult = true; 314 | } else { 315 | qint32 nNumberOfChildren = pItem->childCount(); 316 | 317 | for (qint32 i = 0; i < nNumberOfChildren; i++) { 318 | if (_setTreeItem(pTree, pItem->child(i), fileType, sSignature)) { 319 | bResult = true; 320 | break; 321 | } 322 | } 323 | } 324 | 325 | return bResult; 326 | } 327 | 328 | void DialogDIESignatures::enableControls(bool bState) 329 | { 330 | ui->treeWidgetSignatures->setEnabled(bState); 331 | ui->pushButtonClearResult->setEnabled(bState); 332 | ui->pushButtonClose->setEnabled(bState); 333 | ui->pushButtonDebug->setEnabled(bState); 334 | ui->pushButtonRun->setEnabled(bState); 335 | 336 | if (m_bCurrentEdited) { 337 | ui->pushButtonSave->setEnabled(bState); 338 | } 339 | } 340 | 341 | void DialogDIESignatures::infoMessage(const QString &sInfoMessage) 342 | { 343 | ui->plainTextEditResult->appendPlainText(sInfoMessage); 344 | } 345 | 346 | void DialogDIESignatures::warningMessage(const QString &sWarningMessage) 347 | { 348 | ui->plainTextEditResult->appendPlainText(sWarningMessage); 349 | } 350 | 351 | void DialogDIESignatures::errorMessage(const QString &sErrorMessage) 352 | { 353 | ui->plainTextEditResult->appendPlainText(sErrorMessage); 354 | } 355 | 356 | void DialogDIESignatures::on_pushButtonFind_clicked() 357 | { 358 | findString(); 359 | } 360 | 361 | void DialogDIESignatures::on_pushButtonFindNext_clicked() 362 | { 363 | findNext(); 364 | } 365 | 366 | void DialogDIESignatures::findString() 367 | { 368 | DialogFindText dialogFindText(this); 369 | dialogFindText.setGlobal(getShortcuts(), getGlobalOptions()); 370 | dialogFindText.setData(&m_data); 371 | 372 | if (dialogFindText.exec() == QDialog::Accepted) { 373 | findNext(); 374 | } 375 | } 376 | 377 | void DialogDIESignatures::findNext() 378 | { 379 | if (m_data.bIsMatchCase) { 380 | ui->plainTextEditSignature->find(m_data.sText, QTextDocument::FindCaseSensitively); 381 | } else { 382 | ui->plainTextEditSignature->find(m_data.sText); 383 | } 384 | } 385 | -------------------------------------------------------------------------------- /die_widget.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2019-2025 hors 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 | #include "die_widget.h" 22 | 23 | #include "ui_die_widget.h" 24 | 25 | // bool _scanEngineCallback(const QString &sCurrentSignature, qint32 nNumberOfSignatures, qint32 nCurrentIndex, void *pUserData) 26 | // { 27 | // return false; 28 | // } 29 | 30 | DIE_Widget::DIE_Widget(QWidget *pParent) : XShortcutsWidget(pParent), ui(new Ui::DIE_Widget) 31 | { 32 | ui->setupUi(this); 33 | 34 | m_pdStruct = XBinary::createPdStruct(); 35 | m_pModel = nullptr; 36 | m_bProcess = false; 37 | 38 | connect(&m_watcher, SIGNAL(finished()), this, SLOT(onScanFinished())); 39 | 40 | connect(&m_dieScript, SIGNAL(errorMessage(QString)), this, SLOT(handleErrorString(QString))); 41 | connect(&m_dieScript, SIGNAL(warningMessage(QString)), this, SLOT(handleWarningString(QString))); 42 | // connect(&m_dieScript, SIGNAL(infoMessage(QString)), this, SLOT(handleInfoString(QString))); 43 | 44 | ui->pushButtonDieLog->setEnabled(false); 45 | 46 | m_pTimer = new QTimer(this); 47 | connect(m_pTimer, SIGNAL(timeout()), this, SLOT(timerSlot())); 48 | 49 | clear(); 50 | 51 | m_bInitDatabase = false; 52 | 53 | ui->comboBoxFlags->setData(XScanEngine::getScanFlags(), XComboBoxEx::CBTYPE_FLAGS, 0, tr("Flags")); 54 | ui->comboBoxDatabases->setData(XScanEngine::getDatabases(), XComboBoxEx::CBTYPE_FLAGS, 0, tr("Database")); 55 | 56 | ui->comboBoxDatabases->setItemEnabled(1, false); 57 | 58 | ui->stackedWidgetDieScan->setCurrentIndex(0); 59 | 60 | ui->toolButtonElapsedTime->setText(QString("%1 %2").arg(0).arg(tr("msec"))); // TODO Function 61 | } 62 | 63 | DIE_Widget::~DIE_Widget() 64 | { 65 | if (m_bProcess) { 66 | stop(); 67 | m_watcher.waitForFinished(); 68 | } 69 | 70 | delete ui; 71 | } 72 | 73 | // void DIE_Widget::setOptions(DIE_Widget::OPTIONS *pOptions) 74 | //{ 75 | // ui->checkBoxRecursiveScan->setChecked(pOptions->bRecursiveScan); 76 | // ui->checkBoxDeepScan->setChecked(pOptions->bDeepScan); 77 | // ui->checkBoxAllTypes->setChecked(pOptions->bAllTypesScan); 78 | 79 | // if(m_dieScript.getDatabasePath()!=pOptions->sDatabasePath) 80 | // { 81 | // m_dieScript.loadDatabase(pOptions->sDatabasePath); 82 | // } 83 | //} 84 | 85 | void DIE_Widget::setData(const QString &sFileName, bool bScan, XBinary::FT fileType) 86 | { 87 | clear(); 88 | 89 | // if(fileType==XBinary::FT_BINARY) 90 | // { 91 | // // TODO Check !!! 92 | // fileType=XBinary::FT_COM; 93 | // } 94 | 95 | // TODO 96 | // if ((fileType == XBinary::FT_ZIP) || (fileType == XBinary::FT_DEX)) // TODO 97 | // { 98 | // fileType = XBinary::FT_BINARY; 99 | // } 100 | 101 | this->m_sFileName = sFileName; 102 | this->m_fileType = fileType; 103 | m_scanType = ST_FILE; 104 | 105 | if (bScan) { 106 | process(); 107 | } 108 | } 109 | 110 | void DIE_Widget::adjustView() 111 | { 112 | this->m_sInfoPath = getGlobalOptions()->getInfoPath(); 113 | m_bInitDatabase = false; 114 | 115 | quint64 nFlags = XScanEngine::getScanFlagsFromGlobalOptions(getGlobalOptions()); 116 | ui->comboBoxFlags->setValue(nFlags); 117 | 118 | quint64 nDatabases = XScanEngine::getDatabasesFromGlobalOptions(getGlobalOptions()); 119 | ui->comboBoxDatabases->setValue(nDatabases); 120 | } 121 | 122 | void DIE_Widget::setGlobal(XShortcuts *pShortcuts, XOptions *pXOptions) 123 | { 124 | XShortcutsWidget::setGlobal(pShortcuts, pXOptions); 125 | } 126 | 127 | void DIE_Widget::reloadData(bool bSaveSelection) 128 | { 129 | Q_UNUSED(bSaveSelection) 130 | process(); 131 | } 132 | 133 | void DIE_Widget::clear() 134 | { 135 | m_scanType = ST_UNKNOWN; 136 | m_scanOptions = {}; 137 | m_scanResult = {}; 138 | m_bProcess = false; 139 | 140 | ui->treeViewResult->setModel(0); 141 | } 142 | 143 | void DIE_Widget::process() 144 | { 145 | if (!m_bProcess) { 146 | enableControls(false); 147 | m_bProcess = true; 148 | // ui->progressBarProgress->setValue(0); 149 | 150 | m_scanOptions.bUseCustomDatabase = true; 151 | m_scanOptions.bUseExtraDatabase = true; 152 | m_scanOptions.bShowType = true; 153 | m_scanOptions.bShowVersion = true; 154 | m_scanOptions.bShowInfo = true; 155 | m_scanOptions.bLogProfiling = getGlobalOptions()->getValue(XOptions::ID_SCAN_LOG_PROFILING).toBool(); 156 | m_scanOptions.fileType = m_fileType; 157 | m_scanOptions.bShowScanTime = true; 158 | m_scanOptions.nBufferSize = getGlobalOptions()->getValue(XOptions::ID_ENGINE_BUFFERSIZE).toULongLong(); 159 | m_scanOptions.bIsHighlight = getGlobalOptions()->getValue(XOptions::ID_SCAN_HIGHLIGHT).toBool(); 160 | m_scanOptions.bHideUnknown = getGlobalOptions()->getValue(XOptions::ID_SCAN_HIDEUNKNOWN).toBool(); 161 | m_scanOptions.bIsSort = getGlobalOptions()->getValue(XOptions::ID_SCAN_SORT).toBool(); 162 | // m_scanOptions.scanEngineCallback = _scanEngineCallback; 163 | // m_scanOptions.pUserData = (void *)123; 164 | 165 | quint64 nFlags = ui->comboBoxFlags->getValue().toULongLong(); 166 | XScanEngine::setScanFlags(&m_scanOptions, nFlags); 167 | 168 | quint64 nDatabases = ui->comboBoxDatabases->getValue().toULongLong(); 169 | XScanEngine::setDatabases(&m_scanOptions, nDatabases); 170 | 171 | XScanEngine::setScanFlagsToGlobalOptions(getGlobalOptions(), nFlags); 172 | XScanEngine::setDatabasesToGlobalOptions(getGlobalOptions(), nDatabases); 173 | 174 | m_pTimer->start(200); // TODO const 175 | 176 | ui->progressBar0->hide(); 177 | ui->progressBar1->hide(); 178 | ui->progressBar2->hide(); 179 | ui->progressBar3->hide(); 180 | ui->progressBar4->hide(); 181 | 182 | #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) 183 | QFuture future = QtConcurrent::run(&DIE_Widget::scan, this); 184 | #else 185 | QFuture future = QtConcurrent::run(this, &DIE_Widget::scan); 186 | #endif 187 | 188 | m_watcher.setFuture(future); 189 | } else { 190 | stop(); 191 | m_watcher.waitForFinished(); 192 | enableControls(true); 193 | } 194 | } 195 | 196 | void DIE_Widget::scan() 197 | { 198 | m_listErrorsAndWarnings.clear(); 199 | 200 | if (m_scanType != ST_UNKNOWN) { 201 | if (m_scanType == ST_FILE) { 202 | emit scanStarted(); 203 | 204 | m_pdStruct = XBinary::createPdStruct(); 205 | 206 | if (!m_bInitDatabase) { 207 | m_bInitDatabase = m_dieScript.loadDatabaseFromGlobalOptions(getGlobalOptions()); 208 | } 209 | 210 | m_scanResult = m_dieScript.scanFile(m_sFileName, &m_scanOptions, &m_pdStruct); 211 | 212 | if (m_scanResult.ftInit == XBinary::FT_COM) { 213 | emit currentFileType(m_scanResult.ftInit); 214 | } 215 | 216 | emit scanFinished(); 217 | } 218 | } 219 | } 220 | 221 | void DIE_Widget::stop() 222 | { 223 | m_pdStruct.bIsStop = true; 224 | } 225 | 226 | void DIE_Widget::onScanFinished() 227 | { 228 | m_bProcess = false; 229 | 230 | m_pTimer->stop(); 231 | 232 | qint32 nNumberOfErrors = m_scanResult.listErrors.count() + m_listErrorsAndWarnings.count(); 233 | 234 | QString sLogButtonText; 235 | 236 | if (nNumberOfErrors) { 237 | sLogButtonText = QString("%1(%2)").arg(tr("Log"), QString::number(nNumberOfErrors)); 238 | } else { 239 | sLogButtonText = tr("Log"); 240 | } 241 | 242 | ui->pushButtonDieLog->setText(sLogButtonText); 243 | ui->pushButtonDieLog->setEnabled(nNumberOfErrors); 244 | 245 | ui->toolButtonElapsedTime->setText(QString("%1 %2").arg(m_scanResult.nScanTime).arg(tr("msec"))); 246 | 247 | // QAbstractItemModel *pOldModel = ui->treeViewResult->model(); 248 | ScanItemModel *pOldModel = m_pModel; 249 | 250 | m_pModel = new ScanItemModel(&m_scanOptions, &(m_scanResult.listRecords), 3); 251 | ui->treeViewResult->setModel(m_pModel); 252 | ui->treeViewResult->expandAll(); 253 | 254 | if (pOldModel) { 255 | delete pOldModel; 256 | } 257 | 258 | // ui->tableWidgetResult->horizontalHeader()->setVisible(true); 259 | //// ui->tableWidgetResult->horizontalHeader()->setFixedHeight(0); 260 | 261 | // ui->tableWidgetResult->horizontalHeader()->setSectionResizeMode(COLUMN_TYPE,QHeaderView::ResizeToContents); 262 | ui->treeViewResult->header()->setSectionResizeMode(COLUMN_STRING, QHeaderView::Stretch); 263 | ui->treeViewResult->header()->setSectionResizeMode(COLUMN_SIGNATURE, QHeaderView::Fixed); 264 | ui->treeViewResult->header()->setSectionResizeMode(COLUMN_INFO, QHeaderView::Fixed); 265 | 266 | ui->treeViewResult->setColumnWidth(COLUMN_SIGNATURE, 20); 267 | ui->treeViewResult->setColumnWidth(COLUMN_INFO, 20); 268 | 269 | ui->treeViewResult->header()->setVisible(false); 270 | 271 | // ui->progressBarProgress->setMaximum(100); 272 | // ui->progressBarProgress->setValue(100); 273 | enableControls(true); 274 | } 275 | 276 | void DIE_Widget::on_pushButtonDieSignatures_clicked() 277 | { 278 | if (m_sFileName != "") { 279 | QFile file; 280 | file.setFileName(m_sFileName); 281 | 282 | if (file.open(QIODevice::ReadOnly)) { 283 | DialogDIESignatures dialogSignatures(this, &m_dieScript); 284 | dialogSignatures.setGlobal(getShortcuts(), getGlobalOptions()); 285 | dialogSignatures.setData(&file, m_scanOptions.fileType, ""); 286 | 287 | dialogSignatures.exec(); 288 | 289 | file.close(); 290 | } 291 | } 292 | } 293 | 294 | void DIE_Widget::on_pushButtonDieExtraInformation_clicked() 295 | { 296 | DialogTextInfo dialogInfo(this); 297 | dialogInfo.setGlobal(getShortcuts(), getGlobalOptions()); 298 | 299 | ScanItemModel model(&m_scanOptions, &(m_scanResult.listRecords), 1); 300 | 301 | dialogInfo.setText(model.toFormattedString()); 302 | 303 | dialogInfo.exec(); 304 | } 305 | 306 | void DIE_Widget::on_pushButtonDieLog_clicked() 307 | { 308 | DialogTextInfo dialogInfo(this); 309 | dialogInfo.setGlobal(getShortcuts(), getGlobalOptions()); 310 | 311 | QList listMessages; 312 | listMessages.append(m_listErrorsAndWarnings); 313 | listMessages.append(DiE_Script::getErrorsAndWarningsStringList(&m_scanResult)); 314 | 315 | dialogInfo.setStringList(listMessages); 316 | dialogInfo.setTitle(tr("Log")); 317 | 318 | dialogInfo.exec(); 319 | } 320 | 321 | void DIE_Widget::showInfo(const QString &sName) 322 | { 323 | if (sName != "") { 324 | QString sFileName = getInfoFileName(sName); 325 | 326 | if (XBinary::isFileExists(sFileName)) { 327 | DialogTextInfo dialogInfo(this); 328 | dialogInfo.setGlobal(getShortcuts(), getGlobalOptions()); 329 | dialogInfo.setFileName(sFileName); 330 | 331 | dialogInfo.exec(); 332 | } else { 333 | QString _sName = QUrl::toPercentEncoding(sName); 334 | QString sLink = QString("http://www.google.com/search?q=%1").arg(_sName); // TODO Set Search Engine 335 | QDesktopServices::openUrl(QUrl(sLink)); 336 | } 337 | } 338 | } 339 | 340 | void DIE_Widget::showSignature(XBinary::FT fileType, const QString &sName) 341 | { 342 | if (sName != "") { 343 | QFile file; 344 | file.setFileName(m_sFileName); 345 | 346 | if (file.open(QIODevice::ReadOnly)) { 347 | DialogDIESignatures dialogSignatures(this, &m_dieScript); 348 | dialogSignatures.setGlobal(getShortcuts(), getGlobalOptions()); 349 | dialogSignatures.setData(&file, fileType, sName); 350 | 351 | dialogSignatures.exec(); 352 | 353 | file.close(); 354 | } 355 | } 356 | } 357 | 358 | void DIE_Widget::enableControls(bool bState) 359 | { 360 | if (!bState) { 361 | ScanItemModel *pOldModel = m_pModel; 362 | ui->treeViewResult->setModel(0); 363 | 364 | if (pOldModel) { 365 | delete pOldModel; 366 | m_pModel = nullptr; 367 | } 368 | } 369 | 370 | ui->treeViewResult->setEnabled(bState); 371 | ui->comboBoxFlags->setEnabled(bState); 372 | ui->pushButtonDieSignatures->setEnabled(bState); 373 | ui->pushButtonDieLog->setEnabled(bState); 374 | ui->pushButtonDieExtraInformation->setEnabled(bState); 375 | ui->toolButtonElapsedTime->setEnabled(bState); 376 | ui->pushButtonDieScanDirectory->setEnabled(bState); 377 | 378 | if (bState) { 379 | ui->stackedWidgetDieScan->setCurrentIndex(0); 380 | } else { 381 | ui->stackedWidgetDieScan->setCurrentIndex(1); 382 | } 383 | } 384 | 385 | QString DIE_Widget::getInfoFileName(const QString &sName) 386 | { 387 | QString sResult = XBinary::convertPathName(m_sInfoPath) + QDir::separator() + QString("html") + QDir::separator() + QString("%1.html").arg(sName); 388 | 389 | return sResult; 390 | } 391 | 392 | void DIE_Widget::copyResult() 393 | { 394 | QModelIndexList listIndexes = ui->treeViewResult->selectionModel()->selectedIndexes(); 395 | 396 | if (listIndexes.size() > 0) { 397 | QModelIndex index = listIndexes.at(0); 398 | 399 | if (index.column() == 0) { 400 | QString sString = ui->treeViewResult->model()->data(index).toString(); 401 | QApplication::clipboard()->setText(sString); 402 | } 403 | } 404 | } 405 | 406 | void DIE_Widget::on_pushButtonDieScanDirectory_clicked() 407 | { 408 | DialogDIEScanDirectory dds(this, QFileInfo(m_sFileName).absolutePath()); 409 | dds.setGlobal(getShortcuts(), getGlobalOptions()); 410 | dds.exec(); 411 | } 412 | 413 | void DIE_Widget::registerShortcuts(bool bState) 414 | { 415 | Q_UNUSED(bState) 416 | } 417 | 418 | void DIE_Widget::on_toolButtonElapsedTime_clicked() 419 | { 420 | DialogDIESignaturesElapsed dialogElapsed(this); 421 | dialogElapsed.setGlobal(getShortcuts(), getGlobalOptions()); 422 | dialogElapsed.setData(&m_scanResult); 423 | 424 | dialogElapsed.exec(); 425 | } 426 | 427 | void DIE_Widget::on_treeViewResult_clicked(const QModelIndex &index) 428 | { 429 | if (index.column() == COLUMN_SIGNATURE) { 430 | QString sSignature = ui->treeViewResult->model()->data(index, Qt::UserRole + ScanItemModel::UD_INFO).toString(); 431 | XBinary::FT fileType = (XBinary::FT)(ui->treeViewResult->model()->data(index, Qt::UserRole + ScanItemModel::UD_FILETYPE).toInt()); 432 | 433 | showSignature(fileType, sSignature); 434 | } else if (index.column() == COLUMN_INFO) { 435 | QString sName = ui->treeViewResult->model()->data(index, Qt::UserRole + ScanItemModel::UD_NAME).toString(); 436 | 437 | showInfo(sName); 438 | } 439 | } 440 | 441 | void DIE_Widget::on_treeViewResult_customContextMenuRequested(const QPoint &pos) 442 | { 443 | QModelIndexList listIndexes = ui->treeViewResult->selectionModel()->selectedIndexes(); 444 | 445 | if (listIndexes.size() > 0) { 446 | QModelIndex index = listIndexes.at(0); 447 | 448 | if (index.column() == 0) { 449 | QString sString = ui->treeViewResult->model()->data(index).toString(); 450 | 451 | // TODO more 452 | QMenu contextMenu(this); // TODO 453 | 454 | QAction actionCopy(QString("%1 \"%2\"").arg(tr("Copy as"), sString), this); 455 | connect(&actionCopy, SIGNAL(triggered()), this, SLOT(copyResult())); 456 | 457 | contextMenu.addAction(&actionCopy); 458 | 459 | contextMenu.exec(ui->treeViewResult->viewport()->mapToGlobal(pos)); 460 | } 461 | } 462 | } 463 | 464 | void DIE_Widget::timerSlot() 465 | { 466 | XFormats::setProgressBar(ui->progressBar0, m_pdStruct._pdRecord[0]); 467 | XFormats::setProgressBar(ui->progressBar1, m_pdStruct._pdRecord[1]); 468 | XFormats::setProgressBar(ui->progressBar2, m_pdStruct._pdRecord[2]); 469 | XFormats::setProgressBar(ui->progressBar3, m_pdStruct._pdRecord[3]); 470 | XFormats::setProgressBar(ui->progressBar4, m_pdStruct._pdRecord[4]); 471 | 472 | qint64 nOverallCurrent = 0; 473 | qint64 nOverallTotal = 0; 474 | 475 | for (int i = 0; i < 5; i++) { 476 | nOverallCurrent += m_pdStruct._pdRecord[i].nCurrent; 477 | nOverallTotal += m_pdStruct._pdRecord[i].nTotal; 478 | } 479 | 480 | qint32 nOverallProgress = 0; 481 | if (nOverallTotal > 0) { 482 | nOverallProgress = (qint32)((qreal)nOverallCurrent / nOverallTotal * 100); 483 | } 484 | 485 | emit scanProgress(nOverallProgress); 486 | } 487 | 488 | void DIE_Widget::on_pushButtonDieScanStart_clicked() 489 | { 490 | ui->pushButtonDieScanStart->setEnabled(false); 491 | process(); 492 | ui->pushButtonDieScanStart->setEnabled(true); 493 | } 494 | 495 | void DIE_Widget::on_pushButtonDieScanStop_clicked() 496 | { 497 | ui->pushButtonDieScanStop->setEnabled(false); 498 | process(); 499 | ui->pushButtonDieScanStop->setEnabled(true); 500 | } 501 | 502 | void DIE_Widget::handleErrorString(const QString &sErrorString) 503 | { 504 | m_listErrorsAndWarnings.append(sErrorString); 505 | } 506 | 507 | void DIE_Widget::handleWarningString(const QString &sWarningString) 508 | { 509 | m_listErrorsAndWarnings.append(sWarningString); 510 | } 511 | --------------------------------------------------------------------------------