Some work.
This commit is contained in:
parent
dfd193b2de
commit
2feb05328f
7 changed files with 87 additions and 8 deletions
|
@ -207,6 +207,23 @@ void BaseWebView::mouseReleaseEvent(QMouseEvent *event) {
|
||||||
QWebView::mouseReleaseEvent(event);
|
QWebView::mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseWebView::wheelEvent(QWheelEvent *event) {
|
||||||
|
if (event->modifiers() & Qt::ControlModifier) {
|
||||||
|
if (event->delta() > 0) {
|
||||||
|
increaseWebPageZoom();
|
||||||
|
emit zoomFactorChanged();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (event->delta() < 0) {
|
||||||
|
decreaseWebPageZoom();
|
||||||
|
emit zoomFactorChanged();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QWebView::wheelEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
void BaseWebView::paintEvent(QPaintEvent *event) {
|
void BaseWebView::paintEvent(QPaintEvent *event) {
|
||||||
QWebView::paintEvent(event);
|
QWebView::paintEvent(event);
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,9 @@ class BaseWebView : public QWebView {
|
||||||
// User wants to open new empty web browser tab.
|
// User wants to open new empty web browser tab.
|
||||||
void newTabRequested();
|
void newTabRequested();
|
||||||
|
|
||||||
|
// Emitted if user changes zoom factor via CTRL + mouse wheel combo.
|
||||||
|
void zoomFactorChanged();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool increaseWebPageZoom();
|
bool increaseWebPageZoom();
|
||||||
bool decreaseWebPageZoom();
|
bool decreaseWebPageZoom();
|
||||||
|
@ -51,6 +54,9 @@ class BaseWebView : public QWebView {
|
||||||
// Displays custom error page.
|
// Displays custom error page.
|
||||||
void displayErrorPage();
|
void displayErrorPage();
|
||||||
|
|
||||||
|
// Customize mouse wheeling.
|
||||||
|
void wheelEvent(QWheelEvent *event);
|
||||||
|
|
||||||
// Does additional painting.
|
// Does additional painting.
|
||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
|
|
||||||
|
|
|
@ -179,9 +179,13 @@ void FormMain::createConnections() {
|
||||||
void FormMain::loadWebBrowserMenu(int index) {
|
void FormMain::loadWebBrowserMenu(int index) {
|
||||||
WebBrowser *active_browser = m_ui->m_tabWidget->widget(index)->webBrowser();
|
WebBrowser *active_browser = m_ui->m_tabWidget->widget(index)->webBrowser();
|
||||||
|
|
||||||
m_ui->m_menuWebBrowser->clear();
|
m_ui->m_menuCurrentTab->clear();
|
||||||
if (active_browser != NULL) {
|
if (active_browser != NULL) {
|
||||||
m_ui->m_menuWebBrowser->addActions(active_browser->globalMenu());
|
m_ui->m_menuCurrentTab->addActions(active_browser->globalMenu());
|
||||||
|
|
||||||
|
if (m_ui->m_menuCurrentTab->actions().size() == 0) {
|
||||||
|
m_ui->m_menuCurrentTab->insertAction(NULL, m_ui->m_actionNoActions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,16 @@
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Web browser</string>
|
<string>Web browser</string>
|
||||||
</property>
|
</property>
|
||||||
|
<widget class="QMenu" name="m_menuCurrentTab">
|
||||||
|
<property name="title">
|
||||||
|
<string>&Current tab</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<addaction name="m_actionAddBrowser"/>
|
||||||
|
<addaction name="m_actionCloseCurrentTab"/>
|
||||||
|
<addaction name="m_actionCloseAllTabs"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="m_menuCurrentTab"/>
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="m_menuFile"/>
|
<addaction name="m_menuFile"/>
|
||||||
<addaction name="m_menuView"/>
|
<addaction name="m_menuView"/>
|
||||||
|
@ -141,6 +151,38 @@
|
||||||
<string notr="true">Ctrl+Shift+F</string>
|
<string notr="true">Ctrl+Shift+F</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="m_actionAddBrowser">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Add tab</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Add tab</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="m_actionCloseAllTabs">
|
||||||
|
<property name="text">
|
||||||
|
<string>Close &all tabs except current one</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Close all tabs except current one</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="m_actionCloseCurrentTab">
|
||||||
|
<property name="text">
|
||||||
|
<string>Close current &tab</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="m_actionNoActions">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&No actions possible</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>No actions are possible at this point of time.</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|
|
@ -13,6 +13,7 @@ LocationLineEdit::LocationLineEdit(QWidget *parent)
|
||||||
m_progress(0),
|
m_progress(0),
|
||||||
m_defaultPalette(palette()),
|
m_defaultPalette(palette()),
|
||||||
m_mouseSelectsAllText(true) {
|
m_mouseSelectsAllText(true) {
|
||||||
|
setPlaceholderText(tr("Website address goes here"));
|
||||||
}
|
}
|
||||||
|
|
||||||
LocationLineEdit::~LocationLineEdit() {
|
LocationLineEdit::~LocationLineEdit() {
|
||||||
|
|
|
@ -133,6 +133,9 @@ void WebBrowser::createConnections() {
|
||||||
// Forward title/icon changes.
|
// Forward title/icon changes.
|
||||||
connect(m_webView, SIGNAL(titleChanged(QString)), this, SLOT(onTitleChanged(QString)));
|
connect(m_webView, SIGNAL(titleChanged(QString)), this, SLOT(onTitleChanged(QString)));
|
||||||
connect(m_webView, SIGNAL(iconChanged()), this, SLOT(onIconChanged()));
|
connect(m_webView, SIGNAL(iconChanged()), this, SLOT(onIconChanged()));
|
||||||
|
|
||||||
|
// Misc connections.
|
||||||
|
connect(m_webView, SIGNAL(zoomFactorChanged()), this, SLOT(updateZoomGui()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebBrowser::onIconChanged() {
|
void WebBrowser::onIconChanged() {
|
||||||
|
@ -160,23 +163,25 @@ void WebBrowser::navigateToUrl(const QUrl &url) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebBrowser::increaseZoom() {
|
void WebBrowser::updateZoomGui() {
|
||||||
m_webView->increaseWebPageZoom();
|
|
||||||
m_btnResetZoom->setText(QString("%1%").arg(QString::number(m_webView->zoomFactor() * 100,
|
m_btnResetZoom->setText(QString("%1%").arg(QString::number(m_webView->zoomFactor() * 100,
|
||||||
'f',
|
'f',
|
||||||
0)));
|
0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebBrowser::increaseZoom() {
|
||||||
|
m_webView->increaseWebPageZoom();
|
||||||
|
updateZoomGui();
|
||||||
|
}
|
||||||
|
|
||||||
void WebBrowser::decreaseZoom() {
|
void WebBrowser::decreaseZoom() {
|
||||||
m_webView->decreaseWebPageZoom();
|
m_webView->decreaseWebPageZoom();
|
||||||
m_btnResetZoom->setText(QString("%1%").arg(QString::number(m_webView->zoomFactor() * 100,
|
updateZoomGui();
|
||||||
'f',
|
|
||||||
0)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebBrowser::resetZoom() {
|
void WebBrowser::resetZoom() {
|
||||||
m_webView->resetWebPageZoom();
|
m_webView->resetWebPageZoom();
|
||||||
m_btnResetZoom->setText("100%");
|
updateZoomGui();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebBrowser::navigateToUrl(const QString &textual_url) {
|
void WebBrowser::navigateToUrl(const QString &textual_url) {
|
||||||
|
|
|
@ -65,6 +65,7 @@ class WebBrowser : public TabContent {
|
||||||
void resetZoom();
|
void resetZoom();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// Creates necessary connections.
|
// Creates necessary connections.
|
||||||
void createConnections();
|
void createConnections();
|
||||||
|
|
||||||
|
@ -72,6 +73,9 @@ class WebBrowser : public TabContent {
|
||||||
void initializeZoomWidget();
|
void initializeZoomWidget();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
|
// Updates zoom-related gui.
|
||||||
|
void updateZoomGui();
|
||||||
|
|
||||||
// Updates url (for example on location text box).
|
// Updates url (for example on location text box).
|
||||||
void updateUrl(const QUrl &url);
|
void updateUrl(const QUrl &url);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue