diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 5e254d6e..e5509fd9 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -40,7 +40,6 @@ #include "utils/Helpers.h" #include "dialogs/NewFileDialog.h" -#include "widgets/PreviewWidget.h" #include "widgets/FunctionsWidget.h" #include "widgets/SectionsWidget.h" #include "widgets/CommentsWidget.h" @@ -84,7 +83,6 @@ static void registerCustomFonts() MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), core(CutterCore::getInstance()), - previewDock(nullptr), notepadDock(nullptr), asmDock(nullptr), calcDock(nullptr), @@ -179,13 +177,6 @@ void MainWindow::initUI() */ dockWidgets.reserve(14); - // Add Memory DockWidget - this->previewDock = new PreviewWidget(tr("Preview"), this); - dockWidgets.push_back(previewDock); - // To use in the future when we handle more than one memory views - // this->previewDock->setAttribute(Qt::WA_DeleteOnClose); - // this->add_debug_output( QString::number(this->dockList.length()) ); - // Add disassembly view (dockable) this->disassemblyDock = new DisassemblyWidget(tr("Disassembly"), this); dockWidgets.push_back(disassemblyDock); @@ -262,7 +253,6 @@ void MainWindow::initUI() // Add Notepad Dock panel this->notepadDock = new Notepad(this); dockWidgets.push_back(notepadDock); - connect(previewDock, SIGNAL(fontChanged(QFont)), notepadDock, SLOT(setFonts(QFont))); //Add Dashboard Dock panel this->dashboardDock = new Dashboard(this); @@ -548,17 +538,6 @@ void MainWindow::on_actionTabs_triggered() } } -void MainWindow::on_actionMem_triggered() -{ - //this->previewDock->show(); - //this->previewDock->raise(); - PreviewWidget *newMemDock = new PreviewWidget(); - this->dockWidgets << newMemDock; - newMemDock->setAttribute(Qt::WA_DeleteOnClose); - this->tabifyDockWidget(this->previewDock, newMemDock); - //newMemDock->refreshDisasm(); -} - void MainWindow::on_actionEntry_points_triggered() { toggleDockWidget(entrypointDock); @@ -680,7 +659,6 @@ void MainWindow::restoreDocks() tabifyDockWidget(dashboardDock, disassemblyDock); tabifyDockWidget(dashboardDock, graphDock); tabifyDockWidget(dashboardDock, hexdumpDock); - tabifyDockWidget(dashboardDock, previewDock); tabifyDockWidget(dashboardDock, entrypointDock); tabifyDockWidget(dashboardDock, flagsDock); tabifyDockWidget(dashboardDock, stringsDock); @@ -708,7 +686,6 @@ void MainWindow::showDefaultDocks() const QList defaultDocks = { sectionsDock, entrypointDock, functionsDock, - previewDock, commentsDock, stringsDock, importsDock, @@ -845,7 +822,7 @@ void MainWindow::on_actionWhite_Theme_triggered() void MainWindow::on_actionSDBBrowser_triggered() { this->sdbDock = new SdbDock(this); - this->tabifyDockWidget(this->previewDock, this->sdbDock); + //this->tabifyDockWidget(this->previewDock, this->sdbDock); this->sdbDock->setFloating(true); this->sdbDock->show(); } diff --git a/src/MainWindow.h b/src/MainWindow.h index 2f9401e5..8d916227 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -123,8 +123,6 @@ public slots: private slots: - void on_actionMem_triggered(); - void on_actionAbout_triggered(); void on_actionRefresh_Panels_triggered(); @@ -167,7 +165,6 @@ private slots: private: CutterCore *core; - PreviewWidget *previewDock; Notepad *notepadDock; DisassemblyWidget *disassemblyDock; SidebarWidget *sidebarDock; @@ -181,7 +178,6 @@ private: Configuration *configuration; bool doLock; - void refreshMem(); ut64 hexdumpTopOffset; ut64 hexdumpBottomOffset; QString filename; diff --git a/src/cutter.pro b/src/cutter.pro index 4accda96..1407b8cb 100644 --- a/src/cutter.pro +++ b/src/cutter.pro @@ -35,7 +35,6 @@ SOURCES += \ main.cpp \ cutter.cpp \ widgets/DisassemblerGraphView.cpp \ - widgets/PreviewWidget.cpp \ utils/RichTextPainter.cpp \ dialogs/OptionsDialog.cpp \ dialogs/AboutDialog.cpp \ @@ -84,7 +83,6 @@ SOURCES += \ HEADERS += \ cutter.h \ widgets/DisassemblerGraphView.h \ - widgets/PreviewWidget.h \ utils/RichTextPainter.h \ utils/CachedFontMetrics.h \ dialogs/AboutDialog.h \ @@ -132,7 +130,6 @@ HEADERS += \ utils/TempConfig.h FORMS += \ - widgets/PreviewWidget.ui \ dialogs/AboutDialog.ui \ dialogs/AsmOptionsDialog.ui \ dialogs/CommentsDialog.ui \ diff --git a/src/dialogs/OptionsDialog.cpp b/src/dialogs/OptionsDialog.cpp index 151b8919..a90edff6 100644 --- a/src/dialogs/OptionsDialog.cpp +++ b/src/dialogs/OptionsDialog.cpp @@ -5,7 +5,6 @@ #include "utils/Helpers.h" // TODO: remove us -#include "widgets/PreviewWidget.h" #include "widgets/Notepad.h" #include diff --git a/src/widgets/PreviewWidget.cpp b/src/widgets/PreviewWidget.cpp deleted file mode 100644 index 871051be..00000000 --- a/src/widgets/PreviewWidget.cpp +++ /dev/null @@ -1,135 +0,0 @@ -#include "PreviewWidget.h" -#include "ui_PreviewWidget.h" -#include "DisassemblerGraphView.h" - -#include "utils/Helpers.h" - -#include -#include - -PreviewWidget::PreviewWidget(QWidget *parent, Qt::WindowFlags flags) : - QDockWidget(parent, flags), - ui(new Ui::PreviewWidget), - core(CutterCore::getInstance()) -{ - ui->setupUi(this); - - // Highlight current line on previews and decompiler - connect(ui->previewTextEdit, SIGNAL(cursorPositionChanged()), this, SLOT(highlightPreviewCurrentLine())); - connect(ui->decoTextEdit, SIGNAL(cursorPositionChanged()), this, SLOT(highlightDecoCurrentLine())); - - // Hide tabs - QTabBar *preTab = ui->memPreviewTab->tabBar(); - preTab->setVisible(false); - - connect(core, SIGNAL(seekChanged(RVA)), this, SLOT(on_seekChanged(RVA))); -} - -PreviewWidget::PreviewWidget(const QString &title, QWidget *parent, Qt::WindowFlags flags) : - PreviewWidget(parent, flags) -{ - setWindowTitle(title); -} - -void PreviewWidget::on_seekChanged(RVA addr) -{ - refresh(addr); -} - -void PreviewWidget::highlightPreviewCurrentLine() -{ - - QList extraSelections; - - if (ui->previewTextEdit->toPlainText() != "") - { - if (ui->previewTextEdit->isReadOnly()) - { - QTextEdit::ExtraSelection selection; - - QColor lineColor = QColor(190, 144, 212); - - selection.format.setBackground(lineColor); - selection.format.setProperty(QTextFormat::FullWidthSelection, true); - selection.cursor = ui->previewTextEdit->textCursor(); - selection.cursor.clearSelection(); - extraSelections.append(selection); - } - } - ui->previewTextEdit->setExtraSelections(extraSelections); -} - -void PreviewWidget::highlightDecoCurrentLine() -{ - - QList extraSelections; - - if (ui->decoTextEdit->toPlainText() != "") - { - if (ui->decoTextEdit->isReadOnly()) - { - QTextEdit::ExtraSelection selection; - - QColor lineColor = QColor(190, 144, 212); - - selection.format.setBackground(lineColor); - selection.format.setProperty(QTextFormat::FullWidthSelection, true); - selection.cursor = ui->decoTextEdit->textCursor(); - selection.cursor.clearSelection(); - extraSelections.append(selection); - } - } - ui->decoTextEdit->setExtraSelections(extraSelections); -} - -PreviewWidget::~PreviewWidget() {} - -void PreviewWidget::refresh(RVA addr) -{ - if (addr == RVA_INVALID) - { - addr = core->getOffset(); - } - - // TODO: pseudo, ... -} - -/* - * Actions callback functions - */ - -void PreviewWidget::on_actionSettings_menu_1_triggered() -{ - bool ok = true; - - QFont font = QFont("Monospace", 8); - // TODO Use global configuration - //QFont font = QFontDialog::getFont(&ok, ui->disasTextEdit_2->font(), this); - - if (ok) - { - setFonts(font); - - emit fontChanged(font); - } -} - -void PreviewWidget::setFonts(QFont font) -{ - ui->previewTextEdit->setFont(font); - ui->decoTextEdit->setFont(font); -} - -/* - * Buttons callback functions - */ - -void PreviewWidget::on_previewToolButton_clicked() -{ - ui->memPreviewTab->setCurrentIndex(0); -} - -void PreviewWidget::on_decoToolButton_clicked() -{ - ui->memPreviewTab->setCurrentIndex(1); -} \ No newline at end of file diff --git a/src/widgets/PreviewWidget.h b/src/widgets/PreviewWidget.h deleted file mode 100644 index ace10f04..00000000 --- a/src/widgets/PreviewWidget.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef PREVIEWWIDGET_H -#define PREVIEWWIDGET_H - -#include "cutter.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "utils/Highlighter.h" -#include "utils/HexAsciiHighlighter.h" -#include "utils/HexHighlighter.h" -#include "Dashboard.h" - - -namespace Ui -{ - class PreviewWidget; -} - -class PreviewWidget : public QDockWidget -{ - Q_OBJECT - -public: - explicit PreviewWidget(const QString &title, QWidget *parent = nullptr, Qt::WindowFlags flags = 0); - explicit PreviewWidget(QWidget *parent = nullptr, Qt::WindowFlags flags = 0); - ~PreviewWidget(); - - Highlighter *highlighter; - -signals: - void fontChanged(QFont font); - -private: - std::unique_ptr ui; - CutterCore *core; - - void refresh(RVA addr = RVA_INVALID); - -private slots: - void on_seekChanged(RVA addr); - - void highlightPreviewCurrentLine(); - void highlightDecoCurrentLine(); - void setFonts(QFont font); - - void on_actionSettings_menu_1_triggered(); - void on_previewToolButton_clicked(); - void on_decoToolButton_clicked(); -}; - -#endif // MEMORYWIDGET_H diff --git a/src/widgets/PreviewWidget.ui b/src/widgets/PreviewWidget.ui deleted file mode 100644 index 628dae54..00000000 --- a/src/widgets/PreviewWidget.ui +++ /dev/null @@ -1,553 +0,0 @@ - - - PreviewWidget - - - - 0 - 0 - 867 - 730 - - - - - 0 - 0 - - - - Preview - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QFrame::NoFrame - - - QFrame::Plain - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - background-color: rgb(255, 255, 255); - - - QFrame::NoFrame - - - QFrame::Plain - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::Horizontal - - - - 55 - 20 - - - - - - - - QToolButton { /* all types of tool button */ - border: 3px solid rgb(255, 255, 255); - border-left: 10px solid rgb(255, 255, 255); - border-right: 10px solid rgb(255, 255, 255); - border-radius: 0px; - background-color: rgb(255, 255, 255); - color: rgb(191, 191, 191); - } - -QToolButton:hover { - border: 3px solid #2180a9; - border-left: 10px solid #2180a9; - border-right: 10px solid #2180a9; - border-radius: 0px; - background-color: #2180a9; - color: rgb(255, 255, 255); - } - -QToolButton:checked { - border: 3px solid #999; - border-left: 10px solid #999; - border-right: 10px solid #999; - border-radius: 0px; - background-color: #999; - color: rgb(255, 255, 255); -} - -QToolTip { - background-color: #444; - border: 3px solid #444; - color: rgb(232, 232, 232); -} - - - Preview - - - true - - - false - - - buttonGroup_3 - - - - - - - QToolButton { /* all types of tool button */ - border: 3px solid rgb(255, 255, 255); - border-left: 10px solid rgb(255, 255, 255); - border-right: 10px solid rgb(255, 255, 255); - border-radius: 0px; - background-color: rgb(255, 255, 255); - color: rgb(191, 191, 191); - } - -QToolButton:hover { - border: 3px solid #2180a9; - border-left: 10px solid #2180a9; - border-right: 10px solid #2180a9; - border-radius: 0px; - background-color: #2180a9; - color: rgb(255, 255, 255); - } - -QToolButton:checked { - border: 3px solid #999; - border-left: 10px solid #999; - border-right: 10px solid #999; - border-radius: 0px; - background-color: #999; - color: rgb(255, 255, 255); -} - -QToolTip { - background-color: #444; - border: 3px solid #444; - color: rgb(232, 232, 232); -} - - - Pseudo - - - true - - - false - - - buttonGroup_3 - - - - - - - Qt::Horizontal - - - - 55 - 20 - - - - - - - - - - - - 0 - 0 - - - - - - - QTabWidget::South - - - 1 - - - - Preview - - - - 0 - - - 0 - - - 0 - - - 5 - - - 0 - - - - - - 0 - 0 - - - - - Anonymous Pro - 13 - - - - QFrame::NoFrame - - - QFrame::Plain - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - QTextEdit::NoWrap - - - Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - Decomp - - - - 0 - - - 0 - - - 0 - - - 5 - - - 0 - - - - - - 0 - 0 - - - - - Anonymous Pro - 13 - - - - QFrame::NoFrame - - - QFrame::Plain - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - false - - - QPlainTextEdit::NoWrap - - - - - - Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - - - - - - - - Change font - - - Change font - - - - - Disasm side panel - - - Disasm side panel - - - - - Hexdump side panel - - - Hexdump side panel - - - - - Graph side panel - - - Graph side panel - - - - - Send to notepad - - - Send to notepad - - - - - Undefine - - - Undefine - - - - - Copy all - - - Copy all - - - - - Copy bytes - - - Copy bytes - - - - - Copy disasm - - - Copy disasm - - - - - Copy Hexpair - - - Copy Hexpair - - - - - Copy ASCII - - - Copy ASCII - - - - - Copy Text - - - Copy Text - - - - - 1 - - - 1 - - - - - 2 - - - 2 - - - - - 4 - - - 4 - - - - - 8 - - - 8 - - - - - 16 - - - 16 - - - - - 32 - - - 32 - - - - - 64 - - - 64 - - - - - Edit - - - Edit - - - - - Paste - - - Paste - - - - - Insert Hex - - - Insert Hex - - - - - Insert String - - - Insert String - - - - - - - - - - -