mirror of
https://github.com/rizinorg/cutter.git
synced 2025-02-12 01:42:06 +00:00
Add common zoom action for widgets using font from configuration (#1813)
This commit is contained in:
parent
81f23cbed3
commit
83b1ce2c49
@ -354,18 +354,35 @@ void Configuration::loadDarkStylesheet()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const QFont Configuration::getFont() const
|
const QFont Configuration::getBaseFont() const
|
||||||
{
|
{
|
||||||
QFont font = s.value("font", QFont("Inconsolata", 11)).value<QFont>();
|
QFont font = s.value("font", QFont("Inconsolata", 11)).value<QFont>();
|
||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QFont Configuration::getFont() const
|
||||||
|
{
|
||||||
|
QFont font = getBaseFont();
|
||||||
|
font.setPointSizeF(font.pointSizeF() * getZoomFactor());
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
|
||||||
void Configuration::setFont(const QFont &font)
|
void Configuration::setFont(const QFont &font)
|
||||||
{
|
{
|
||||||
s.setValue("font", font);
|
s.setValue("font", font);
|
||||||
emit fontsUpdated();
|
emit fontsUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qreal Configuration::getZoomFactor() const {
|
||||||
|
qreal fontZoom = s.value("zoomFactor", 1.0).value<qreal>();
|
||||||
|
return qMax(fontZoom, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Configuration::setZoomFactor(qreal zoom) {
|
||||||
|
s.setValue("zoomFactor", qMax(zoom, 0.1));
|
||||||
|
emit fontsUpdated();
|
||||||
|
}
|
||||||
|
|
||||||
QString Configuration::getLastThemeOf(const CutterInterfaceTheme &currInterfaceTheme) const
|
QString Configuration::getLastThemeOf(const CutterInterfaceTheme &currInterfaceTheme) const
|
||||||
{
|
{
|
||||||
return s.value("lastThemeOf." + currInterfaceTheme.name,
|
return s.value("lastThemeOf." + currInterfaceTheme.name,
|
||||||
|
@ -75,8 +75,22 @@ public:
|
|||||||
QStringList getAvailableTranslations();
|
QStringList getAvailableTranslations();
|
||||||
|
|
||||||
// Fonts
|
// Fonts
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the configured font set by the font selection box
|
||||||
|
* @return the configured font
|
||||||
|
*/
|
||||||
|
const QFont getBaseFont() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the configured font with the point size adjusted by the configured zoom
|
||||||
|
* level (minimum of 10%)
|
||||||
|
* @return the configured font size adjusted by zoom level
|
||||||
|
*/
|
||||||
const QFont getFont() const;
|
const QFont getFont() const;
|
||||||
void setFont(const QFont &font);
|
void setFont(const QFont &font);
|
||||||
|
qreal getZoomFactor() const;
|
||||||
|
void setZoomFactor(qreal zoom);
|
||||||
|
|
||||||
// Colors
|
// Colors
|
||||||
bool windowColorIsDark();
|
bool windowColorIsDark();
|
||||||
|
@ -160,6 +160,10 @@ void MainWindow::initUI()
|
|||||||
QShortcut *refresh_shortcut = new QShortcut(QKeySequence(QKeySequence::Refresh), this);
|
QShortcut *refresh_shortcut = new QShortcut(QKeySequence(QKeySequence::Refresh), this);
|
||||||
connect(refresh_shortcut, SIGNAL(activated()), this, SLOT(refreshAll()));
|
connect(refresh_shortcut, SIGNAL(activated()), this, SLOT(refreshAll()));
|
||||||
|
|
||||||
|
connect(ui->actionZoomIn, SIGNAL(triggered()), this, SLOT(onZoomIn()));
|
||||||
|
connect(ui->actionZoomOut, SIGNAL(triggered()), this, SLOT(onZoomOut()));
|
||||||
|
connect(ui->actionZoomReset, SIGNAL(triggered()), this, SLOT(onZoomReset()));
|
||||||
|
|
||||||
connect(core, SIGNAL(projectSaved(bool, const QString &)), this, SLOT(projectSaved(bool,
|
connect(core, SIGNAL(projectSaved(bool, const QString &)), this, SLOT(projectSaved(bool,
|
||||||
const QString &)));
|
const QString &)));
|
||||||
|
|
||||||
@ -1509,3 +1513,18 @@ void MainWindow::chooseThemeIcons()
|
|||||||
static_cast<QAction*>(obj)->setIcon(icon);
|
static_cast<QAction*>(obj)->setIcon(icon);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::onZoomIn()
|
||||||
|
{
|
||||||
|
Config()->setZoomFactor(Config()->getZoomFactor() + 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::onZoomOut()
|
||||||
|
{
|
||||||
|
Config()->setZoomFactor(Config()->getZoomFactor() - 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::onZoomReset()
|
||||||
|
{
|
||||||
|
Config()->setZoomFactor(1.0);
|
||||||
|
}
|
||||||
|
@ -201,6 +201,10 @@ private slots:
|
|||||||
void changeDefinedView();
|
void changeDefinedView();
|
||||||
void chooseThemeIcons();
|
void chooseThemeIcons();
|
||||||
|
|
||||||
|
void onZoomIn();
|
||||||
|
void onZoomOut();
|
||||||
|
void onZoomReset();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CutterCore *core;
|
CutterCore *core;
|
||||||
|
|
||||||
|
@ -81,6 +81,15 @@
|
|||||||
<property name="tabsOnTop" stdset="0">
|
<property name="tabsOnTop" stdset="0">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<widget class="QMenu" name="menuZoom">
|
||||||
|
<property name="title">
|
||||||
|
<string>Zoom</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="actionZoomIn"/>
|
||||||
|
<addaction name="actionZoomOut"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionZoomReset"/>
|
||||||
|
</widget>
|
||||||
<addaction name="actionRefresh_contents"/>
|
<addaction name="actionRefresh_contents"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionDefault"/>
|
<addaction name="actionDefault"/>
|
||||||
@ -89,6 +98,8 @@
|
|||||||
<addaction name="actionLock"/>
|
<addaction name="actionLock"/>
|
||||||
<addaction name="actionTabs_on_Top"/>
|
<addaction name="actionTabs_on_Top"/>
|
||||||
<addaction name="actionGrouped_dock_dragging"/>
|
<addaction name="actionGrouped_dock_dragging"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="menuZoom"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuHelp">
|
<widget class="QMenu" name="menuHelp">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
@ -1072,6 +1083,39 @@
|
|||||||
<string>Grouped dock dragging</string>
|
<string>Grouped dock dragging</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionZoomIn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Zoom In</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl++</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcutContext">
|
||||||
|
<enum>Qt::ApplicationShortcut</enum>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionZoomOut">
|
||||||
|
<property name="text">
|
||||||
|
<string>Zoom Out</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+-</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcutContext">
|
||||||
|
<enum>Qt::ApplicationShortcut</enum>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionZoomReset">
|
||||||
|
<property name="text">
|
||||||
|
<string>Reset</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+=</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcutContext">
|
||||||
|
<enum>Qt::ApplicationShortcut</enum>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<resources>
|
<resources>
|
||||||
|
@ -43,7 +43,7 @@ static QIcon getIconFor(const QString &str, int pos)
|
|||||||
pixPaint.setBrush(getColorFor(pos));
|
pixPaint.setBrush(getColorFor(pos));
|
||||||
pixPaint.drawEllipse(1, 1, w - 2, h - 2);
|
pixPaint.drawEllipse(1, 1, w - 2, h - 2);
|
||||||
pixPaint.setPen(Qt::white);
|
pixPaint.setPen(Qt::white);
|
||||||
QFont font = Config()->getFont();
|
QFont font = Config()->getBaseFont();
|
||||||
font.setBold(true);
|
font.setBold(true);
|
||||||
font.setPointSize(18);
|
font.setPointSize(18);
|
||||||
pixPaint.setFont(font);
|
pixPaint.setFont(font);
|
||||||
|
@ -14,7 +14,7 @@ TypesInteractionDialog::TypesInteractionDialog(QWidget *parent, bool readOnly) :
|
|||||||
ui(new Ui::TypesInteractionDialog)
|
ui(new Ui::TypesInteractionDialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
QFont font = Config()->getFont();
|
QFont font = Config()->getBaseFont();
|
||||||
ui->plainTextEdit->setFont(font);
|
ui->plainTextEdit->setFont(font);
|
||||||
ui->plainTextEdit->setPlainText("");
|
ui->plainTextEdit->setPlainText("");
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||||
|
@ -68,7 +68,7 @@ QString XrefsDialog::normalizeAddr(const QString &addr) const
|
|||||||
|
|
||||||
void XrefsDialog::setupPreviewFont()
|
void XrefsDialog::setupPreviewFont()
|
||||||
{
|
{
|
||||||
ui->previewTextEdit->setFont(Config()->getFont());
|
ui->previewTextEdit->setFont(Config()->getBaseFont());
|
||||||
}
|
}
|
||||||
|
|
||||||
void XrefsDialog::setupPreviewColors()
|
void XrefsDialog::setupPreviewColors()
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <QtSvg/QSvgRenderer>
|
#include <QtSvg/QSvgRenderer>
|
||||||
|
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
#include <QtWidgets/QSpinBox>
|
||||||
#include "PreferencesDialog.h"
|
#include "PreferencesDialog.h"
|
||||||
#include "AppearanceOptionsWidget.h"
|
#include "AppearanceOptionsWidget.h"
|
||||||
#include "ui_AppearanceOptionsWidget.h"
|
#include "ui_AppearanceOptionsWidget.h"
|
||||||
@ -62,13 +63,18 @@ AppearanceOptionsWidget::AppearanceOptionsWidget(PreferencesDialog *dialog)
|
|||||||
|
|
||||||
connect(ui->colorComboBox, &QComboBox::currentTextChanged,
|
connect(ui->colorComboBox, &QComboBox::currentTextChanged,
|
||||||
this, &AppearanceOptionsWidget::updateModificationButtons);
|
this, &AppearanceOptionsWidget::updateModificationButtons);
|
||||||
|
|
||||||
|
connect(ui->fontZoomBox,
|
||||||
|
static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
|
||||||
|
this,
|
||||||
|
&AppearanceOptionsWidget::onFontZoomBoxValueChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
AppearanceOptionsWidget::~AppearanceOptionsWidget() {}
|
AppearanceOptionsWidget::~AppearanceOptionsWidget() {}
|
||||||
|
|
||||||
void AppearanceOptionsWidget::updateFontFromConfig()
|
void AppearanceOptionsWidget::updateFontFromConfig()
|
||||||
{
|
{
|
||||||
QFont currentFont = Config()->getFont();
|
QFont currentFont = Config()->getBaseFont();
|
||||||
ui->fontSelectionLabel->setText(currentFont.toString());
|
ui->fontSelectionLabel->setText(currentFont.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,9 +97,16 @@ void AppearanceOptionsWidget::updateThemeFromConfig(bool interfaceThemeChanged)
|
|||||||
updateModificationButtons(ui->colorComboBox->currentText());
|
updateModificationButtons(ui->colorComboBox->currentText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppearanceOptionsWidget::onFontZoomBoxValueChanged(int zoom)
|
||||||
|
{
|
||||||
|
qreal zoomFactor = zoom / 100.0;
|
||||||
|
Config()->setZoomFactor(zoomFactor);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void AppearanceOptionsWidget::on_fontSelectionButton_clicked()
|
void AppearanceOptionsWidget::on_fontSelectionButton_clicked()
|
||||||
{
|
{
|
||||||
QFont currentFont = Config()->getFont();
|
QFont currentFont = Config()->getBaseFont();
|
||||||
bool ok;
|
bool ok;
|
||||||
QFont newFont = QFontDialog::getFont(&ok, currentFont, this, QString(),
|
QFont newFont = QFontDialog::getFont(&ok, currentFont, this, QString(),
|
||||||
QFontDialog::DontUseNativeDialog);
|
QFontDialog::DontUseNativeDialog);
|
||||||
|
@ -30,6 +30,7 @@ private slots:
|
|||||||
void updateThemeFromConfig(bool interfaceThemeChanged = true);
|
void updateThemeFromConfig(bool interfaceThemeChanged = true);
|
||||||
|
|
||||||
void on_fontSelectionButton_clicked();
|
void on_fontSelectionButton_clicked();
|
||||||
|
void onFontZoomBoxValueChanged(int zoom);
|
||||||
void on_themeComboBox_currentIndexChanged(int index);
|
void on_themeComboBox_currentIndexChanged(int index);
|
||||||
void on_copyButton_clicked();
|
void on_copyButton_clicked();
|
||||||
void on_deleteButton_clicked();
|
void on_deleteButton_clicked();
|
||||||
|
@ -57,6 +57,57 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>30</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Zoom</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="fontZoomBox">
|
||||||
|
<property name="wrapping">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="frame">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="buttonSymbols">
|
||||||
|
<enum>QAbstractSpinBox::PlusMinus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="showGroupSeparator" stdset="0">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="suffix">
|
||||||
|
<string>%</string>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>3000</number>
|
||||||
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>100</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
|
#include <QtWidgets/QShortcut>
|
||||||
|
|
||||||
CutterDockWidget::CutterDockWidget(MainWindow *parent, QAction *action) :
|
CutterDockWidget::CutterDockWidget(MainWindow *parent, QAction *action) :
|
||||||
QDockWidget(parent),
|
QDockWidget(parent),
|
||||||
@ -97,4 +98,3 @@ QString CutterDockWidget::getDockNumber()
|
|||||||
}
|
}
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ DecompilerWidget::DecompilerWidget(MainWindow *main, QAction *action) :
|
|||||||
setupFonts();
|
setupFonts();
|
||||||
colorsUpdatedSlot();
|
colorsUpdatedSlot();
|
||||||
|
|
||||||
connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(fontsUpdated()));
|
connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(fontsUpdatedSlot()));
|
||||||
connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(colorsUpdatedSlot()));
|
connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(colorsUpdatedSlot()));
|
||||||
|
|
||||||
decompiledFunctionAddr = RVA_INVALID;
|
decompiledFunctionAddr = RVA_INVALID;
|
||||||
@ -249,8 +249,7 @@ void DecompilerWidget::updateCursorPosition()
|
|||||||
|
|
||||||
void DecompilerWidget::setupFonts()
|
void DecompilerWidget::setupFonts()
|
||||||
{
|
{
|
||||||
QFont font = Config()->getFont();
|
ui->textEdit->setFont(Config()->getFont());
|
||||||
ui->textEdit->setFont(font);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DecompilerWidget::updateSelection()
|
void DecompilerWidget::updateSelection()
|
||||||
@ -275,7 +274,7 @@ QString DecompilerWidget::getWindowTitle() const
|
|||||||
return tr("Decompiler");
|
return tr("Decompiler");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DecompilerWidget::fontsUpdated()
|
void DecompilerWidget::fontsUpdatedSlot()
|
||||||
{
|
{
|
||||||
setupFonts();
|
setupFonts();
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public slots:
|
|||||||
void showDisasContextMenu(const QPoint &pt);
|
void showDisasContextMenu(const QPoint &pt);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void fontsUpdated();
|
void fontsUpdatedSlot();
|
||||||
void colorsUpdatedSlot();
|
void colorsUpdatedSlot();
|
||||||
void refreshDecompiler();
|
void refreshDecompiler();
|
||||||
void decompilerSelected();
|
void decompilerSelected();
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "DisassemblerGraphView.h"
|
#include "DisassemblerGraphView.h"
|
||||||
#include "common/CutterSeekable.h"
|
#include "common/CutterSeekable.h"
|
||||||
#include "core/Cutter.h"
|
#include "core/Cutter.h"
|
||||||
|
#include "core/MainWindow.h"
|
||||||
#include "common/Colors.h"
|
#include "common/Colors.h"
|
||||||
#include "common/Configuration.h"
|
#include "common/Configuration.h"
|
||||||
#include "common/CachedFontMetrics.h"
|
#include "common/CachedFontMetrics.h"
|
||||||
@ -32,6 +33,10 @@
|
|||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
const int DisassemblerGraphView::KEY_ZOOM_IN = Qt::Key_Plus + Qt::ControlModifier;
|
||||||
|
const int DisassemblerGraphView::KEY_ZOOM_OUT = Qt::Key_Minus + Qt::ControlModifier;
|
||||||
|
const int DisassemblerGraphView::KEY_ZOOM_RESET = Qt::Key_Equal + Qt::ControlModifier;
|
||||||
|
|
||||||
DisassemblerGraphView::DisassemblerGraphView(QWidget *parent, CutterSeekable *seekable,
|
DisassemblerGraphView::DisassemblerGraphView(QWidget *parent, CutterSeekable *seekable,
|
||||||
MainWindow *mainWindow, QList<QAction *> additionalMenuActions)
|
MainWindow *mainWindow, QList<QAction *> additionalMenuActions)
|
||||||
: GraphView(parent),
|
: GraphView(parent),
|
||||||
@ -66,19 +71,6 @@ DisassemblerGraphView::DisassemblerGraphView(QWidget *parent, CutterSeekable *se
|
|||||||
shortcut_escape->setContext(Qt::WidgetShortcut);
|
shortcut_escape->setContext(Qt::WidgetShortcut);
|
||||||
connect(shortcut_escape, SIGNAL(activated()), seekable, SLOT(seekPrev()));
|
connect(shortcut_escape, SIGNAL(activated()), seekable, SLOT(seekPrev()));
|
||||||
|
|
||||||
// Zoom shortcuts
|
|
||||||
QShortcut *shortcut_zoom_in = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Plus), this);
|
|
||||||
shortcut_zoom_in->setContext(Qt::WidgetShortcut);
|
|
||||||
connect(shortcut_zoom_in, &QShortcut::activated, this, std::bind(&DisassemblerGraphView::zoom, this,
|
|
||||||
QPointF(0.5, 0.5), 1));
|
|
||||||
QShortcut *shortcut_zoom_out = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Minus), this);
|
|
||||||
shortcut_zoom_out->setContext(Qt::WidgetShortcut);
|
|
||||||
connect(shortcut_zoom_out, &QShortcut::activated, this, std::bind(&DisassemblerGraphView::zoom,
|
|
||||||
this, QPointF(0.5, 0.5), -1));
|
|
||||||
QShortcut *shortcut_zoom_reset = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Equal), this);
|
|
||||||
shortcut_zoom_reset->setContext(Qt::WidgetShortcut);
|
|
||||||
connect(shortcut_zoom_reset, SIGNAL(activated()), this, SLOT(zoomReset()));
|
|
||||||
|
|
||||||
// Branch shortcuts
|
// Branch shortcuts
|
||||||
QShortcut *shortcut_take_true = new QShortcut(QKeySequence(Qt::Key_T), this);
|
QShortcut *shortcut_take_true = new QShortcut(QKeySequence(Qt::Key_T), this);
|
||||||
shortcut_take_true->setContext(Qt::WidgetShortcut);
|
shortcut_take_true->setContext(Qt::WidgetShortcut);
|
||||||
@ -95,9 +87,6 @@ DisassemblerGraphView::DisassemblerGraphView(QWidget *parent, CutterSeekable *se
|
|||||||
shortcut_prev_instr->setContext(Qt::WidgetShortcut);
|
shortcut_prev_instr->setContext(Qt::WidgetShortcut);
|
||||||
connect(shortcut_prev_instr, SIGNAL(activated()), this, SLOT(prevInstr()));
|
connect(shortcut_prev_instr, SIGNAL(activated()), this, SLOT(prevInstr()));
|
||||||
shortcuts.append(shortcut_escape);
|
shortcuts.append(shortcut_escape);
|
||||||
shortcuts.append(shortcut_zoom_in);
|
|
||||||
shortcuts.append(shortcut_zoom_out);
|
|
||||||
shortcuts.append(shortcut_zoom_reset);
|
|
||||||
shortcuts.append(shortcut_next_instr);
|
shortcuts.append(shortcut_next_instr);
|
||||||
shortcuts.append(shortcut_prev_instr);
|
shortcuts.append(shortcut_prev_instr);
|
||||||
|
|
||||||
@ -412,7 +401,7 @@ void DisassemblerGraphView::cleanupEdges()
|
|||||||
|
|
||||||
void DisassemblerGraphView::initFont()
|
void DisassemblerGraphView::initFont()
|
||||||
{
|
{
|
||||||
setFont(Config()->getFont());
|
setFont(Config()->getBaseFont());
|
||||||
QFontMetricsF metrics(font());
|
QFontMetricsF metrics(font());
|
||||||
baseline = int(metrics.ascent());
|
baseline = int(metrics.ascent());
|
||||||
charWidth = metrics.width('X');
|
charWidth = metrics.width('X');
|
||||||
@ -429,7 +418,7 @@ void DisassemblerGraphView::drawBlock(QPainter &p, GraphView::GraphBlock &block,
|
|||||||
|
|
||||||
p.setPen(Qt::black);
|
p.setPen(Qt::black);
|
||||||
p.setBrush(Qt::gray);
|
p.setBrush(Qt::gray);
|
||||||
p.setFont(Config()->getFont());
|
p.setFont(Config()->getBaseFont());
|
||||||
p.drawRect(blockRect);
|
p.drawRect(blockRect);
|
||||||
|
|
||||||
breakpoints = Core()->getBreakpointsAddresses();
|
breakpoints = Core()->getBreakpointsAddresses();
|
||||||
@ -805,6 +794,16 @@ void DisassemblerGraphView::zoom(QPointF mouseRelativePos, double velocity)
|
|||||||
emit viewZoomed();
|
emit viewZoomed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DisassemblerGraphView::zoomIn()
|
||||||
|
{
|
||||||
|
zoom(QPointF(0.5, 0.5), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisassemblerGraphView::zoomOut()
|
||||||
|
{
|
||||||
|
zoom(QPointF(0.5, 0.5), -1);
|
||||||
|
}
|
||||||
|
|
||||||
void DisassemblerGraphView::zoomReset()
|
void DisassemblerGraphView::zoomReset()
|
||||||
{
|
{
|
||||||
setViewScale(1.0);
|
setViewScale(1.0);
|
||||||
@ -1034,6 +1033,40 @@ void DisassemblerGraphView::blockTransitionedTo(GraphView::GraphBlock *to)
|
|||||||
seekLocal(to->entry);
|
seekLocal(to->entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DisassemblerGraphView::event(QEvent *event)
|
||||||
|
{
|
||||||
|
switch (event->type()) {
|
||||||
|
case QEvent::ShortcutOverride: {
|
||||||
|
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||||
|
int key = keyEvent->key() + keyEvent->modifiers();
|
||||||
|
if (key == KEY_ZOOM_OUT || key == KEY_ZOOM_RESET
|
||||||
|
|| key == KEY_ZOOM_IN || (key == (KEY_ZOOM_IN | Qt::ShiftModifier))) {
|
||||||
|
event->accept();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case QEvent::KeyPress: {
|
||||||
|
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||||
|
int key = keyEvent->key() + keyEvent->modifiers();
|
||||||
|
if (key == KEY_ZOOM_IN || (key == (KEY_ZOOM_IN | Qt::ShiftModifier))) {
|
||||||
|
zoomIn();
|
||||||
|
return true;
|
||||||
|
} else if (key == KEY_ZOOM_OUT) {
|
||||||
|
zoomOut();
|
||||||
|
return true;
|
||||||
|
} else if (key == KEY_ZOOM_RESET) {
|
||||||
|
zoomReset();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return GraphView::event(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(DisassemblerGraphView::GraphExportType);
|
Q_DECLARE_METATYPE(DisassemblerGraphView::GraphExportType);
|
||||||
|
|
||||||
|
@ -101,6 +101,7 @@ public:
|
|||||||
GraphView::GraphBlock *to,
|
GraphView::GraphBlock *to,
|
||||||
bool interactive) override;
|
bool interactive) override;
|
||||||
virtual void blockTransitionedTo(GraphView::GraphBlock *to) override;
|
virtual void blockTransitionedTo(GraphView::GraphBlock *to) override;
|
||||||
|
virtual bool event(QEvent *event) override;
|
||||||
|
|
||||||
void loadCurrentGraph();
|
void loadCurrentGraph();
|
||||||
QString windowTitle;
|
QString windowTitle;
|
||||||
@ -130,6 +131,8 @@ public slots:
|
|||||||
void fontsUpdatedSlot();
|
void fontsUpdatedSlot();
|
||||||
void onSeekChanged(RVA addr);
|
void onSeekChanged(RVA addr);
|
||||||
void zoom(QPointF mouseRelativePos, double velocity);
|
void zoom(QPointF mouseRelativePos, double velocity);
|
||||||
|
void zoomIn();
|
||||||
|
void zoomOut();
|
||||||
void zoomReset();
|
void zoomReset();
|
||||||
|
|
||||||
void takeTrue();
|
void takeTrue();
|
||||||
@ -222,6 +225,10 @@ private:
|
|||||||
QAction actionUnhighlight;
|
QAction actionUnhighlight;
|
||||||
|
|
||||||
QLabel *emptyText = nullptr;
|
QLabel *emptyText = nullptr;
|
||||||
|
|
||||||
|
static const int KEY_ZOOM_IN;
|
||||||
|
static const int KEY_ZOOM_OUT;
|
||||||
|
static const int KEY_ZOOM_RESET;
|
||||||
signals:
|
signals:
|
||||||
void viewRefreshed();
|
void viewRefreshed();
|
||||||
void viewZoomed();
|
void viewZoomed();
|
||||||
|
@ -206,11 +206,6 @@ DisassemblyWidget::DisassemblyWidget(MainWindow *main, QAction *action)
|
|||||||
ADD_ACTION(QKeySequence::MoveToPreviousPage, Qt::WidgetWithChildrenShortcut, [this]() {
|
ADD_ACTION(QKeySequence::MoveToPreviousPage, Qt::WidgetWithChildrenShortcut, [this]() {
|
||||||
moveCursorRelative(true, true);
|
moveCursorRelative(true, true);
|
||||||
})
|
})
|
||||||
|
|
||||||
// Zoom shortcuts
|
|
||||||
ADD_ACTION(QKeySequence(Qt::CTRL + Qt::Key_Plus), Qt::WidgetWithChildrenShortcut, &DisassemblyWidget::zoomIn)
|
|
||||||
ADD_ACTION(QKeySequence(Qt::CTRL + Qt::Key_Minus), Qt::WidgetWithChildrenShortcut, &DisassemblyWidget::zoomOut)
|
|
||||||
ADD_ACTION(QKeySequence(Qt::CTRL + Qt::Key_Equal), Qt::WidgetWithChildrenShortcut, &DisassemblyWidget::zoomReset)
|
|
||||||
#undef ADD_ACTION
|
#undef ADD_ACTION
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,27 +368,6 @@ bool DisassemblyWidget::updateMaxLines()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisassemblyWidget::zoomIn()
|
|
||||||
{
|
|
||||||
mDisasTextEdit->zoomIn();
|
|
||||||
updateMaxLines();
|
|
||||||
leftPanel->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DisassemblyWidget::zoomOut()
|
|
||||||
{
|
|
||||||
mDisasTextEdit->zoomOut();
|
|
||||||
updateMaxLines();
|
|
||||||
leftPanel->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DisassemblyWidget::zoomReset()
|
|
||||||
{
|
|
||||||
setupFonts();
|
|
||||||
updateMaxLines();
|
|
||||||
leftPanel->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DisassemblyWidget::highlightCurrentLine()
|
void DisassemblyWidget::highlightCurrentLine()
|
||||||
{
|
{
|
||||||
QList<QTextEdit::ExtraSelection> extraSelections;
|
QList<QTextEdit::ExtraSelection> extraSelections;
|
||||||
|
@ -46,10 +46,6 @@ protected slots:
|
|||||||
|
|
||||||
void cursorPositionChanged();
|
void cursorPositionChanged();
|
||||||
|
|
||||||
void zoomIn();
|
|
||||||
void zoomOut();
|
|
||||||
void zoomReset();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DisassemblyContextMenu *mCtxMenu;
|
DisassemblyContextMenu *mCtxMenu;
|
||||||
DisassemblyScrollArea *mDisasScrollArea;
|
DisassemblyScrollArea *mDisasScrollArea;
|
||||||
|
@ -40,7 +40,8 @@ HexWidget::HexWidget(QWidget *parent) :
|
|||||||
connect(horizontalScrollBar(), &QScrollBar::valueChanged, this, [this]() { viewport()->update(); });
|
connect(horizontalScrollBar(), &QScrollBar::valueChanged, this, [this]() { viewport()->update(); });
|
||||||
|
|
||||||
connect(Config(), &Configuration::colorsUpdated, this, &HexWidget::updateColors);
|
connect(Config(), &Configuration::colorsUpdated, this, &HexWidget::updateColors);
|
||||||
connect(Config(), &Configuration::fontsUpdated, this, [this]() { setMonospaceFont(Config()->getFont()); });
|
connect(Config(), &Configuration::fontsUpdated, this, [this]() { setMonospaceFont(
|
||||||
|
Config()->getFont()); });
|
||||||
|
|
||||||
auto sizeActionGroup = new QActionGroup(this);
|
auto sizeActionGroup = new QActionGroup(this);
|
||||||
for (int i = 1; i <= 8; i *= 2) {
|
for (int i = 1; i <= 8; i *= 2) {
|
||||||
|
@ -78,7 +78,7 @@ QVariant SearchModel::data(const QModelIndex &index, int role) const
|
|||||||
previewContent = Core()->getHexdumpPreview(exp.offset, kMaxTooltipHexdumpBytes);
|
previewContent = Core()->getHexdumpPreview(exp.offset, kMaxTooltipHexdumpBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QFont &fnt = Config()->getFont();
|
const QFont &fnt = Config()->getBaseFont();
|
||||||
QFontMetrics fm{ fnt };
|
QFontMetrics fm{ fnt };
|
||||||
|
|
||||||
QString toolTipContent = QString("<html><div style=\"font-family: %1; font-size: %2pt; white-space: nowrap;\">")
|
QString toolTipContent = QString("<html><div style=\"font-family: %1; font-size: %2pt; white-space: nowrap;\">")
|
||||||
|
Loading…
Reference in New Issue
Block a user