Work on webbrowser.
This commit is contained in:
parent
29664caf9d
commit
1be0ccf2e1
4 changed files with 48 additions and 6 deletions
|
@ -7,6 +7,9 @@ Fixed:
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
Added:
|
Added:
|
||||||
|
<ul>
|
||||||
|
<li>Added "Web browser" menu to corner main menu button.</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
Changed:
|
Changed:
|
||||||
<ul>
|
<ul>
|
||||||
|
|
|
@ -75,6 +75,7 @@ void TabWidget::openMainMenu() {
|
||||||
m_menuMain->addMenu(FormMain::instance()->m_ui->m_menuView);
|
m_menuMain->addMenu(FormMain::instance()->m_ui->m_menuView);
|
||||||
m_menuMain->addMenu(FormMain::instance()->m_ui->m_menuFeeds);
|
m_menuMain->addMenu(FormMain::instance()->m_ui->m_menuFeeds);
|
||||||
m_menuMain->addMenu(FormMain::instance()->m_ui->m_menuMessages);
|
m_menuMain->addMenu(FormMain::instance()->m_ui->m_menuMessages);
|
||||||
|
m_menuMain->addMenu(FormMain::instance()->m_ui->m_menuWebBrowser);
|
||||||
m_menuMain->addMenu(FormMain::instance()->m_ui->m_menuTools);
|
m_menuMain->addMenu(FormMain::instance()->m_ui->m_menuTools);
|
||||||
m_menuMain->addMenu(FormMain::instance()->m_ui->m_menuHelp);
|
m_menuMain->addMenu(FormMain::instance()->m_ui->m_menuHelp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,12 +27,14 @@
|
||||||
#include "gui/tabwidget.h"
|
#include "gui/tabwidget.h"
|
||||||
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QHBoxLayout>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QWebFrame>
|
#include <QWebFrame>
|
||||||
#include <QWidgetAction>
|
#include <QWidgetAction>
|
||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QProgressBar>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
|
||||||
|
|
||||||
|
@ -123,29 +125,55 @@ void WebBrowser::initializeLayout() {
|
||||||
m_toolBar->addAction(m_actionStop);
|
m_toolBar->addAction(m_actionStop);
|
||||||
m_toolBar->addWidget(m_txtLocation);
|
m_toolBar->addWidget(m_txtLocation);
|
||||||
|
|
||||||
|
// Initialize dynamic progress bar which will be displayed
|
||||||
|
// at the bottom of web browser.
|
||||||
|
m_lblProgress = new QLabel(this);
|
||||||
|
m_loadingProgress = new QProgressBar(this);
|
||||||
|
m_loadingProgress->setFixedHeight(15);
|
||||||
|
m_loadingProgress->setMinimum(0);
|
||||||
|
m_loadingProgress->setMaximum(100);
|
||||||
|
m_loadingProgress->setVisible(true);
|
||||||
|
|
||||||
|
m_loadingLayout = new QHBoxLayout();
|
||||||
|
m_loadingLayout->setMargin(0);
|
||||||
|
m_loadingLayout->addWidget(m_lblProgress, 0, Qt::AlignLeft|Qt::AlignVCenter);
|
||||||
|
m_loadingProgress->setLayout(m_loadingLayout);
|
||||||
|
|
||||||
// Setup layout.
|
// Setup layout.
|
||||||
m_layout->addWidget(m_toolBar);
|
m_layout->addWidget(m_toolBar);
|
||||||
m_layout->addWidget(m_webView);
|
m_layout->addWidget(m_webView);
|
||||||
|
m_layout->addWidget(m_loadingProgress);
|
||||||
m_layout->setMargin(0);
|
m_layout->setMargin(0);
|
||||||
m_layout->setSpacing(0);
|
m_layout->setSpacing(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebBrowser::onLoadingStarted() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebBrowser::onLoadingProgress(int progress) {
|
||||||
|
m_txtLocation->setProgress(progress);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebBrowser::onLoadingFinished(bool success) {
|
||||||
|
m_txtLocation->clearProgress();
|
||||||
|
}
|
||||||
|
|
||||||
void WebBrowser::createConnections() {
|
void WebBrowser::createConnections() {
|
||||||
// When user confirms new url, then redirect to it.
|
// When user confirms new url, then redirect to it.
|
||||||
connect(m_txtLocation,SIGNAL(submitted(QString)),
|
connect(m_txtLocation,SIGNAL(submitted(QString)), this, SLOT(navigateToUrl(QString)));
|
||||||
this, SLOT(navigateToUrl(QString)));
|
|
||||||
// If new page loads, then update current url.
|
// If new page loads, then update current url.
|
||||||
connect(m_webView, SIGNAL(urlChanged(QUrl)), this, SLOT(updateUrl(QUrl)));
|
connect(m_webView, SIGNAL(urlChanged(QUrl)), this, SLOT(updateUrl(QUrl)));
|
||||||
|
|
||||||
// Connect this WebBrowser to global TabWidget.
|
// Connect this WebBrowser to global TabWidget.
|
||||||
TabWidget *tab_widget = FormMain::instance()->tabWidget();
|
TabWidget *tab_widget = FormMain::instance()->tabWidget();
|
||||||
connect(m_webView, SIGNAL(newTabRequested()), tab_widget, SLOT(addEmptyBrowser()));
|
connect(m_webView, SIGNAL(newTabRequested()), tab_widget, SLOT(addEmptyBrowser()));
|
||||||
connect(m_webView, SIGNAL(linkMiddleClicked(QUrl)),
|
connect(m_webView, SIGNAL(linkMiddleClicked(QUrl)), tab_widget, SLOT(addLinkedBrowser(QUrl)));
|
||||||
tab_widget, SLOT(addLinkedBrowser(QUrl)));
|
|
||||||
|
|
||||||
// Change location textbox status according to webpage status.
|
// Change location textbox status according to webpage status.
|
||||||
connect(m_webView, SIGNAL(loadProgress(int)), m_txtLocation, SLOT(setProgress(int)));
|
connect(m_webView, SIGNAL(loadStarted()), this, SLOT(onLoadingStarted()));
|
||||||
connect(m_webView, SIGNAL(loadFinished(bool)), m_txtLocation, SLOT(clearProgress()));
|
connect(m_webView, SIGNAL(loadProgress(int)), this, SLOT(onLoadingProgress(int)));
|
||||||
|
connect(m_webView, SIGNAL(loadFinished(bool)), this, SLOT(onLoadingFinished(bool)));
|
||||||
|
|
||||||
// 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)));
|
||||||
|
|
|
@ -31,7 +31,10 @@
|
||||||
|
|
||||||
class QToolButton;
|
class QToolButton;
|
||||||
class QVBoxLayout;
|
class QVBoxLayout;
|
||||||
|
class QHBoxLayout;
|
||||||
|
class QProgressBar;
|
||||||
class QMenu;
|
class QMenu;
|
||||||
|
class QLabel;
|
||||||
class WebBrowserNetworkAccessManager;
|
class WebBrowserNetworkAccessManager;
|
||||||
class TabWidget;
|
class TabWidget;
|
||||||
|
|
||||||
|
@ -111,6 +114,10 @@ class WebBrowser : public TabContent {
|
||||||
void initializeLayout();
|
void initializeLayout();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
|
void onLoadingStarted();
|
||||||
|
void onLoadingProgress(int progress);
|
||||||
|
void onLoadingFinished(bool success);
|
||||||
|
|
||||||
// Updates zoom-related gui.
|
// Updates zoom-related gui.
|
||||||
void updateZoomGui();
|
void updateZoomGui();
|
||||||
|
|
||||||
|
@ -138,6 +145,9 @@ class WebBrowser : public TabContent {
|
||||||
LocationLineEdit *m_txtLocation;
|
LocationLineEdit *m_txtLocation;
|
||||||
QWidget *m_zoomButtons;
|
QWidget *m_zoomButtons;
|
||||||
QToolButton *m_btnResetZoom;
|
QToolButton *m_btnResetZoom;
|
||||||
|
QHBoxLayout *m_loadingLayout;
|
||||||
|
QProgressBar *m_loadingProgress;
|
||||||
|
QLabel *m_lblProgress;
|
||||||
|
|
||||||
QWidgetAction *m_actionZoom;
|
QWidgetAction *m_actionZoom;
|
||||||
QAction *m_actionBack;
|
QAction *m_actionBack;
|
||||||
|
|
Loading…
Add table
Reference in a new issue