summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorZeno Albisser <zeno.albisser@digia.com>2013-06-18 17:15:00 +0200
committerZeno Albisser <zeno.albisser@digia.com>2013-06-18 17:48:21 +0200
commitf1f5170c062c4a96dd986116631a6d8e1fb1d87f (patch)
tree5d4206785cf0300b894e84274fcd2f04f5777a91 /examples
parentcdb864f35e765cfef374cce18583fffff57359a3 (diff)
Disable the back/forward buttons when appropriate.
Diffstat (limited to 'examples')
-rw-r--r--examples/qtquick/quickwindow.qml2
-rw-r--r--examples/widgets/widgetwindow.cpp6
-rw-r--r--examples/widgets/widgetwindow.h2
3 files changed, 8 insertions, 2 deletions
diff --git a/examples/qtquick/quickwindow.qml b/examples/qtquick/quickwindow.qml
index 7962be141..afaff7c8d 100644
--- a/examples/qtquick/quickwindow.qml
+++ b/examples/qtquick/quickwindow.qml
@@ -20,12 +20,14 @@ ApplicationWindow {
iconName: "go-previous"
iconSource: ":/icons/go-previous.png"
onClicked: webContentsView.goBack()
+ enabled: webContentsView.canGoBack
}
ToolButton {
id: forwardButton
iconName: "go-next"
iconSource: ":/icons/go-next.png"
onClicked: webContentsView.goForward()
+ enabled: webContentsView.canGoForward
}
ToolButton {
id: reloadButton
diff --git a/examples/widgets/widgetwindow.cpp b/examples/widgets/widgetwindow.cpp
index 589ef13c3..a28a6f130 100644
--- a/examples/widgets/widgetwindow.cpp
+++ b/examples/widgets/widgetwindow.cpp
@@ -63,11 +63,11 @@ WidgetWindow::WidgetWindow()
QHBoxLayout* addressBar = new QHBoxLayout;
addressBar->setSpacing(margin); // Bigger buttons, less space between them
- QToolButton* backButton = new QToolButton;
+ backButton = new QToolButton;
backButton->setIcon(QIcon::fromTheme("go-previous"));
addressBar->addWidget(backButton);
- QToolButton* forwardButton = new QToolButton;
+ forwardButton = new QToolButton;
forwardButton->setIcon(QIcon::fromTheme("go-next"));
addressBar->addWidget(forwardButton);
@@ -117,5 +117,7 @@ void WidgetWindow::loadStarted()
void WidgetWindow::loadFinished(bool success)
{
Q_UNUSED(success);
+ forwardButton->setEnabled(m_webView->canGoForward());
+ backButton->setEnabled(m_webView->canGoBack());
reloadButton->setIcon(QIcon::fromTheme("view-refresh"));
}
diff --git a/examples/widgets/widgetwindow.h b/examples/widgets/widgetwindow.h
index 5273d4255..863e8a73f 100644
--- a/examples/widgets/widgetwindow.h
+++ b/examples/widgets/widgetwindow.h
@@ -62,6 +62,8 @@ private Q_SLOTS:
private:
QScopedPointer<QWebContentsView> m_webView;
QLineEdit* addressLineEdit;
+ QToolButton* forwardButton;
+ QToolButton* backButton;
QToolButton* reloadButton;
};