| 836 | } |
| 837 | |
| 838 | void CFrmWebBrowser::slotTabCurrentChanged(int index) |
| 839 | { |
| 840 | if(-1 == index) return; |
| 841 | CFrmWebView* pWeb = CurrentView(); |
| 842 | if(pWeb) { |
| 843 | setWindowTitle(pWeb->title()); |
| 844 | setWindowIcon(pWeb->icon()); |
| 845 | m_pUrlLineEdit->setText(pWeb->url().toString()); |
| 846 | m_pProgressBar->setValue(pWeb->progress()); |
| 847 | EnableAction(true); |
| 848 | auto page = pWeb->page(); |
| 849 | if(page) { |
| 850 | auto action = page->action(QWebEnginePage::Back); |
| 851 | if(action && m_pBack) { |
| 852 | m_pBack->setEnabled(action->isEnabled()); |
| 853 | } |
| 854 | action = page->action(QWebEnginePage::Forward); |
| 855 | if(action && m_pForward) { |
| 856 | m_pForward->setEnabled(action->isEnabled()); |
| 857 | } |
| 858 | action = page->action(QWebEnginePage::Reload); |
| 859 | if(action && m_pRefresh) |
| 860 | m_pRefresh->setEnabled(action->isEnabled()); |
| 861 | if(m_pRefresh->isEnabled()) |
| 862 | m_pToolBar->insertAction(m_pUrl, m_pRefresh); |
| 863 | else |
| 864 | m_pToolBar->removeAction(m_pRefresh); |
| 865 | action = page->action(QWebEnginePage::Stop); |
| 866 | if(action && m_pStop) |
| 867 | m_pStop->setEnabled(action->isEnabled()); |
| 868 | if(m_pStop->isEnabled()) |
| 869 | m_pToolBar->insertAction(m_pUrl, m_pStop); |
| 870 | else |
| 871 | m_pToolBar->removeAction(m_pStop); |
| 872 | if(m_pInspector) { |
| 873 | m_pInspector->setChecked(CurrentView(ViewType::DevTools)); |
| 874 | } |
| 875 | } |
| 876 | } else { |
| 877 | setWindowTitle(tr("Web browser")); |
| 878 | setWindowIcon(QIcon::fromTheme("web-browser")); |
| 879 | m_pUrlLineEdit->setText(""); |
| 880 | m_pProgressBar->setValue(100); |
| 881 | EnableAction(false); |
| 882 | if(m_pInspector) |
| 883 | m_pInspector->setChecked(false); |
| 884 | } |
| 885 | emit sigUpdateTitle(); |
| 886 | } |
| 887 | |
| 888 | void CFrmWebBrowser::EnableAction(bool enable) |
| 889 | { |