Skip to content

Commit

Permalink
Add option to disable ctrl+<mouse-wheel> zooming (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenzhiwei authored Feb 16, 2023
1 parent b7bde02 commit abb19ab
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/assets/other/default-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,12 @@
"type": "checkbox",
"text": "Scroll on output",
"default": true
},
{
"key": "zoom_on_ctrl_scrollwheel",
"type": "checkbox",
"text": "Allow Ctrl+scrollwheel to zoom text size",
"default": true
}
]
},
Expand Down
5 changes: 5 additions & 0 deletions src/settings/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,11 @@ bool Settings::OutputtingScroll()
return settings->option("advanced.scroll.scroll_on_output")->value().toBool();
}

bool Settings::ScrollWheelZoom()
{
return settings->option("advanced.scroll.zoom_on_ctrl_scrollwheel")->value().toBool();
}

/*******************************************************************************
1. @函数: reload
2. @作者: ut001121 zhangmeng
Expand Down
6 changes: 6 additions & 0 deletions src/settings/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ class Settings : public QObject
* @return
*/
bool OutputtingScroll();
/**
* @brief 设置界面获取是否允许Ctrl+滚轮扩缩字体
* @author chenzhiwei
* @return
*/
bool ScrollWheelZoom();
// void reload();
/**
* @brief 标签标题
Expand Down
4 changes: 2 additions & 2 deletions src/views/termwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ inline void TermWidget::onTouchPadSignal(QString name, QString direction, int fi
{
qInfo() << name << direction << fingers;
// 当前窗口被激活,且有焦点
if (isActiveWindow() && hasFocus()) {
if (isActiveWindow() && hasFocus() && Settings::instance()->ScrollWheelZoom()) {
if (name == "pinch" && fingers == 2) {
if (direction == "in") {
// 捏合 in是手指捏合的方向 向内缩小
Expand Down Expand Up @@ -1176,7 +1176,7 @@ void TermWidget::onShellMessage(QString currentShell, bool isSuccess)
void TermWidget::wheelEvent(QWheelEvent *event)
{
// 当前窗口被激活,且有焦点
if (isActiveWindow() && hasFocus()) {
if (isActiveWindow() && hasFocus() && Settings::instance()->ScrollWheelZoom()) {
if (Qt::ControlModifier == event->modifiers()) {
int directionY = event->angleDelta().y();
if (directionY < 0) {
Expand Down

0 comments on commit abb19ab

Please sign in to comment.