Remove PreviewWidget, Fix #114

This commit is contained in:
Florian Märkl 2017-11-28 15:55:41 +01:00
parent dd744cb64e
commit ca3efec644
7 changed files with 1 additions and 777 deletions

View File

@ -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<QDockWidget *> 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();
}

View File

@ -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;

View File

@ -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 \

View File

@ -5,7 +5,6 @@
#include "utils/Helpers.h"
// TODO: remove us
#include "widgets/PreviewWidget.h"
#include "widgets/Notepad.h"
#include <QSettings>

View File

@ -1,135 +0,0 @@
#include "PreviewWidget.h"
#include "ui_PreviewWidget.h"
#include "DisassemblerGraphView.h"
#include "utils/Helpers.h"
#include <QClipboard>
#include <QSettings>
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<QTextEdit::ExtraSelection> 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<QTextEdit::ExtraSelection> 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);
}

View File

@ -1,57 +0,0 @@
#ifndef PREVIEWWIDGET_H
#define PREVIEWWIDGET_H
#include "cutter.h"
#include <QDebug>
#include <QTextEdit>
#include <QDockWidget>
#include <QTreeWidget>
#include <QTabWidget>
#include <QUrl>
#include <QPlainTextEdit>
#include <QMouseEvent>
#include <memory>
#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::PreviewWidget> 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

View File

@ -1,553 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PreviewWidget</class>
<widget class="QDockWidget" name="PreviewWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>867</width>
<height>730</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true">Preview</string>
</property>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="frame_3">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="frame_2">
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>55</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="previewToolButton">
<property name="styleSheet">
<string notr="true">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);
}</string>
</property>
<property name="text">
<string notr="true">Preview</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup_3</string>
</attribute>
</widget>
</item>
<item>
<widget class="QToolButton" name="decoToolButton">
<property name="styleSheet">
<string notr="true">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);
}</string>
</property>
<property name="text">
<string notr="true">Pseudo</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup_3</string>
</attribute>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>55</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QTabWidget" name="memPreviewTab">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="tabPosition">
<enum>QTabWidget::South</enum>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string notr="true">Preview</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QTextEdit" name="previewTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Anonymous Pro</family>
<pointsize>13</pointsize>
</font>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="lineWrapMode">
<enum>QTextEdit::NoWrap</enum>
</property>
<property name="textInteractionFlags">
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_5">
<attribute name="title">
<string notr="true">Decomp</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPlainTextEdit" name="decoTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Anonymous Pro</family>
<pointsize>13</pointsize>
</font>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="undoRedoEnabled">
<bool>false</bool>
</property>
<property name="lineWrapMode">
<enum>QPlainTextEdit::NoWrap</enum>
</property>
<property name="plainText">
<string notr="true"/>
</property>
<property name="textInteractionFlags">
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<action name="actionSettings_menu_1">
<property name="text">
<string>Change font</string>
</property>
<property name="toolTip">
<string>Change font</string>
</property>
</action>
<action name="actionHideDisasm_side_panel">
<property name="text">
<string>Disasm side panel</string>
</property>
<property name="toolTip">
<string>Disasm side panel</string>
</property>
</action>
<action name="actionHideHexdump_side_panel">
<property name="text">
<string>Hexdump side panel</string>
</property>
<property name="toolTip">
<string>Hexdump side panel</string>
</property>
</action>
<action name="actionHideGraph_side_panel">
<property name="text">
<string>Graph side panel</string>
</property>
<property name="toolTip">
<string>Graph side panel</string>
</property>
</action>
<action name="actionSend_to_Notepad">
<property name="text">
<string>Send to notepad</string>
</property>
<property name="toolTip">
<string>Send to notepad</string>
</property>
</action>
<action name="actionFunctionsUndefine">
<property name="text">
<string>Undefine</string>
</property>
<property name="toolTip">
<string>Undefine</string>
</property>
</action>
<action name="actionDisasCopy_All">
<property name="text">
<string>Copy all</string>
</property>
<property name="toolTip">
<string>Copy all</string>
</property>
</action>
<action name="actionDisasCopy_Bytes">
<property name="text">
<string>Copy bytes</string>
</property>
<property name="toolTip">
<string>Copy bytes</string>
</property>
</action>
<action name="actionDisasCopy_Disasm">
<property name="text">
<string>Copy disasm</string>
</property>
<property name="toolTip">
<string>Copy disasm</string>
</property>
</action>
<action name="actionHexCopy_Hexpair">
<property name="text">
<string>Copy Hexpair</string>
</property>
<property name="toolTip">
<string>Copy Hexpair</string>
</property>
</action>
<action name="actionHexCopy_ASCII">
<property name="text">
<string>Copy ASCII</string>
</property>
<property name="toolTip">
<string>Copy ASCII</string>
</property>
</action>
<action name="actionHexCopy_Text">
<property name="text">
<string>Copy Text</string>
</property>
<property name="toolTip">
<string>Copy Text</string>
</property>
</action>
<action name="action1column">
<property name="text">
<string>1</string>
</property>
<property name="toolTip">
<string>1</string>
</property>
</action>
<action name="action2columns">
<property name="text">
<string>2</string>
</property>
<property name="toolTip">
<string>2</string>
</property>
</action>
<action name="action4columns">
<property name="text">
<string>4</string>
</property>
<property name="toolTip">
<string>4</string>
</property>
</action>
<action name="action8columns">
<property name="text">
<string>8</string>
</property>
<property name="toolTip">
<string>8</string>
</property>
</action>
<action name="action16columns">
<property name="text">
<string>16</string>
</property>
<property name="toolTip">
<string>16</string>
</property>
</action>
<action name="action32columns">
<property name="text">
<string>32</string>
</property>
<property name="toolTip">
<string>32</string>
</property>
</action>
<action name="action64columns">
<property name="text">
<string>64</string>
</property>
<property name="toolTip">
<string>64</string>
</property>
</action>
<action name="actionHexEdit">
<property name="text">
<string>Edit</string>
</property>
<property name="toolTip">
<string>Edit</string>
</property>
</action>
<action name="actionHexPaste">
<property name="text">
<string>Paste</string>
</property>
<property name="toolTip">
<string>Paste</string>
</property>
</action>
<action name="actionHexInsert_Hex">
<property name="text">
<string>Insert Hex</string>
</property>
<property name="toolTip">
<string>Insert Hex</string>
</property>
</action>
<action name="actionHexInsert_String">
<property name="text">
<string>Insert String</string>
</property>
<property name="toolTip">
<string>Insert String</string>
</property>
</action>
</widget>
<resources>
<include location="../resources.qrc"/>
</resources>
<connections/>
<buttongroups>
<buttongroup name="buttonGroup_3"/>
</buttongroups>
</ui>