Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add zoom shortcuts ctrl + (+-0) #1012

Merged
merged 3 commits into from
Oct 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/libs/ui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,15 @@ MainWindow::MainWindow(Core::Application *app, QWidget *parent) :
connect(ui->actionForward, &QAction::triggered, this, [this]() { currentTab()->forward(); });
addAction(ui->actionForward);

shortcut = new QShortcut(QKeySequence::ZoomIn, this);
connect(shortcut, &QShortcut::activated, this, [this]() { currentTab()->zoomIn(); });
shortcut = new QShortcut(QStringLiteral("Ctrl+="), this);
knixeur marked this conversation as resolved.
Show resolved Hide resolved
connect(shortcut, &QShortcut::activated, this, [this]() { currentTab()->zoomIn(); });
shortcut = new QShortcut(QKeySequence::ZoomOut, this);
connect(shortcut, &QShortcut::activated, this, [this]() { currentTab()->zoomOut(); });
shortcut = new QShortcut(QStringLiteral("Ctrl+0"), this);
connect(shortcut, &QShortcut::activated, this, [this]() { currentTab()->resetZoom(); });

// Tools Menu
connect(ui->actionDocsets, &QAction::triggered, [this]() {
QScopedPointer<DocsetsDialog> dialog(new DocsetsDialog(m_application, this));
Expand Down
15 changes: 15 additions & 0 deletions src/libs/ui/widgets/webviewtab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,21 @@ void WebViewTab::setZoomLevel(int level)
m_webView->setZoomLevel(level);
}

void WebViewTab::zoomIn()
{
m_webView->zoomIn();
}

void WebViewTab::zoomOut()
{
m_webView->zoomOut();
}

void WebViewTab::resetZoom()
{
m_webView->resetZoom();
}

void WebViewTab::setJavaScriptEnabled(bool enabled)
{
m_webView->page()->settings()->setAttribute(QWebSettings::JavascriptEnabled, enabled);
Expand Down
4 changes: 4 additions & 0 deletions src/libs/ui/widgets/webviewtab.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public slots:
void activateSearchBar();
void back();
void forward();

void zoomIn();
knixeur marked this conversation as resolved.
Show resolved Hide resolved
void zoomOut();
void resetZoom();

protected:
void keyPressEvent(QKeyEvent *event) override;
Expand Down