mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 11:37:56 -04:00
Implement zoom action.
This commit is contained in:
parent
089a1753eb
commit
67f2d1f067
@ -241,15 +241,12 @@ void KiwixApp::createAction()
|
||||
|
||||
CREATE_ACTION(ZoomInAction, "Zoom in");
|
||||
SET_SHORTCUT(ZoomInAction, QKeySequence::ZoomIn);
|
||||
HIDE_ACTION(ZoomInAction);
|
||||
|
||||
CREATE_ACTION(ZoomOutAction, "Zoom out");
|
||||
SET_SHORTCUT(ZoomOutAction, QKeySequence::ZoomOut);
|
||||
HIDE_ACTION(ZoomOutAction);
|
||||
|
||||
CREATE_ACTION(ZoomResetAction, "Zoom reset");
|
||||
SET_SHORTCUT(ZoomResetAction, QKeySequence(Qt::CTRL+Qt::Key_0));
|
||||
HIDE_ACTION(ZoomResetAction);
|
||||
|
||||
CREATE_ACTION(HelpAction, "Help");
|
||||
SET_SHORTCUT(HelpAction, QKeySequence::HelpContents);
|
||||
|
@ -32,6 +32,30 @@ TabWidget::TabWidget(QWidget *parent) :
|
||||
}
|
||||
this->closeTab(index);
|
||||
});
|
||||
connect(app->getAction(KiwixApp::ZoomInAction), &QAction::triggered,
|
||||
this, [=]() {
|
||||
auto current = this->currentWidget();
|
||||
QUITIFNULL(current);
|
||||
auto zoomFactor = current->zoomFactor();
|
||||
zoomFactor += 0.1;
|
||||
zoomFactor = max(min(zoomFactor, 5.0), 0.25);
|
||||
current->setZoomFactor(zoomFactor);
|
||||
});
|
||||
connect(app->getAction(KiwixApp::ZoomOutAction), &QAction::triggered,
|
||||
this, [=]() {
|
||||
auto current = this->currentWidget();
|
||||
QUITIFNULL(current);
|
||||
auto zoomFactor = current->zoomFactor();
|
||||
zoomFactor -= 0.1;
|
||||
zoomFactor = max(min(zoomFactor, 5.0), 0.25);
|
||||
current->setZoomFactor(zoomFactor);
|
||||
});
|
||||
connect(app->getAction(KiwixApp::ZoomResetAction), &QAction::triggered,
|
||||
this, [=]() {
|
||||
auto current = this->currentWidget();
|
||||
QUITIFNULL(current);
|
||||
current->setZoomFactor(1.0);
|
||||
});
|
||||
}
|
||||
|
||||
WebView* TabWidget::createNewTab(bool setCurrent)
|
||||
|
Loading…
x
Reference in New Issue
Block a user