1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

Fixed problem with showing green (secured) info on unsecured page, when

leaving secured one.
This commit is contained in:
nowrep 2011-07-11 20:30:49 +02:00
parent 74d146ead6
commit b49a133bbe
14 changed files with 200 additions and 95 deletions

View File

@ -148,6 +148,8 @@ void QupZilla::postLaunch()
void QupZilla::setupUi() void QupZilla::setupUi()
{ {
setContentsMargins(0,0,0,0); setContentsMargins(0,0,0,0);
m_tabWidget = new TabWidget(this);
setCentralWidget(m_tabWidget);
m_navigation = new QToolBar(this); m_navigation = new QToolBar(this);
m_navigation->setWindowTitle(tr("Navigation")); m_navigation->setWindowTitle(tr("Navigation"));
@ -186,11 +188,10 @@ void QupZilla::setupUi()
m_navigation->addAction(m_buttonStop); m_navigation->addAction(m_buttonStop);
m_navigation->addAction(m_buttonHome); m_navigation->addAction(m_buttonHome);
m_locationBar = new LocationBar(this);
m_searchLine = new WebSearchBar(this); m_searchLine = new WebSearchBar(this);
m_navigationSplitter = new QSplitter(m_navigation); m_navigationSplitter = new QSplitter(m_navigation);
m_navigationSplitter->addWidget(m_locationBar); m_navigationSplitter->addWidget(m_tabWidget->locationBars());
m_navigationSplitter->addWidget(m_searchLine); m_navigationSplitter->addWidget(m_searchLine);
m_navigationSplitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); m_navigationSplitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
@ -229,9 +230,6 @@ void QupZilla::setupUi()
m_bookmarksToolbar = new BookmarksToolbar(this); m_bookmarksToolbar = new BookmarksToolbar(this);
addToolBar(m_bookmarksToolbar); addToolBar(m_bookmarksToolbar);
insertToolBarBreak(m_bookmarksToolbar); insertToolBarBreak(m_bookmarksToolbar);
m_tabWidget = new TabWidget(this);
setCentralWidget(m_tabWidget);
} }
void QupZilla::setupMenu() void QupZilla::setupMenu()
@ -365,7 +363,6 @@ void QupZilla::setupMenu()
aboutToShowToolsMenu(); aboutToShowToolsMenu();
aboutToShowHelpMenu(); aboutToShowHelpMenu();
connect(m_locationBar, SIGNAL(returnPressed()), this, SLOT(urlEnter()));
connect(m_buttonBack, SIGNAL(triggered()), this, SLOT(goBack())); connect(m_buttonBack, SIGNAL(triggered()), this, SLOT(goBack()));
connect(m_buttonNext, SIGNAL(triggered()), this, SLOT(goNext())); connect(m_buttonNext, SIGNAL(triggered()), this, SLOT(goNext()));
connect(m_buttonStop, SIGNAL(triggered()), this, SLOT(stop())); connect(m_buttonStop, SIGNAL(triggered()), this, SLOT(stop()));
@ -502,7 +499,7 @@ void QupZilla::receiveMessage(MainApplication::MessageType mes, bool state)
case MainApplication::ReloadSettings: case MainApplication::ReloadSettings:
loadSettings(); loadSettings();
m_tabWidget->loadSettings(); m_tabWidget->loadSettings();
m_locationBar->loadSettings(); // m_locationBar->loadSettings();
break; break;
default: default:
@ -513,6 +510,9 @@ void QupZilla::receiveMessage(MainApplication::MessageType mes, bool state)
void QupZilla::refreshHistory(int index) void QupZilla::refreshHistory(int index)
{ {
if (mApp->isClosing())
return;
QWebHistory* history; QWebHistory* history;
if (index == -1) if (index == -1)
history = weView()->page()->history(); history = weView()->page()->history();
@ -856,9 +856,9 @@ void QupZilla::loadActionUrl()
void QupZilla::urlEnter() void QupZilla::urlEnter()
{ {
if (m_locationBar->text().isEmpty()) if (locationBar()->text().isEmpty())
return; return;
loadAddress(QUrl(WebView::guessUrlFromString(m_locationBar->text()))); loadAddress(QUrl(WebView::guessUrlFromString(locationBar()->text())));
weView()->setFocus(); weView()->setFocus();
} }
@ -1180,7 +1180,6 @@ QupZilla::~QupZilla()
delete m_adblockIcon; delete m_adblockIcon;
delete m_menuBack; delete m_menuBack;
delete m_menuForward; delete m_menuForward;
delete m_locationBar;
delete m_searchLine; delete m_searchLine;
delete m_bookmarksToolbar; delete m_bookmarksToolbar;
delete m_webSearchToolbar; delete m_webSearchToolbar;

View File

@ -98,7 +98,7 @@ public:
inline WebView* weView() const { WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(m_tabWidget->currentIndex())); if (!webTab) return 0; return webTab->view(); } inline WebView* weView() const { WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(m_tabWidget->currentIndex())); if (!webTab) return 0; return webTab->view(); }
inline WebView* weView(int index) const { WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index)); if (!webTab) return 0; return webTab->view(); } inline WebView* weView(int index) const { WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index)); if (!webTab) return 0; return webTab->view(); }
inline LocationBar* locationBar() { return m_locationBar; } inline LocationBar* locationBar() { return (LocationBar*) m_tabWidget->locationBars()->currentWidget(); }
inline TabWidget* tabWidget() { return m_tabWidget; } inline TabWidget* tabWidget() { return m_tabWidget; }
inline BookmarksToolbar* bookmarksToolbar() { return m_bookmarksToolbar; } inline BookmarksToolbar* bookmarksToolbar() { return m_bookmarksToolbar; }
inline StatusBarMessage* statusBarMessage() { return m_statusBarMessage; } inline StatusBarMessage* statusBarMessage() { return m_statusBarMessage; }
@ -126,7 +126,7 @@ public slots:
void refreshHistory(int index=-1); void refreshHistory(int index=-1);
void loadActionUrl(); void loadActionUrl();
void bookmarkPage(); void bookmarkPage();
void loadAddress(QUrl url) { weView()->load(url); m_locationBar->setText(url.toEncoded()); } void loadAddress(QUrl url) { weView()->load(url); locationBar()->setText(url.toEncoded()); }
void showSource(); void showSource();
void showPageInfo(); void showPageInfo();
void receiveMessage(MainApplication::MessageType mes, bool state); void receiveMessage(MainApplication::MessageType mes, bool state);
@ -173,7 +173,7 @@ private slots:
void bookmarkAllTabs(); void bookmarkAllTabs();
void newWindow() { mApp->makeNewWindow(false); } void newWindow() { mApp->makeNewWindow(false); }
void openLocation() { m_locationBar->setFocus(); m_locationBar->selectAll(); } void openLocation() { locationBar()->setFocus(); locationBar()->selectAll(); }
void openFile(); void openFile();
void savePage(); void savePage();
void sendLink() { QDesktopServices::openUrl(QUrl("mailto:?body="+weView()->url().toString())); } void sendLink() { QDesktopServices::openUrl(QUrl("mailto:?body="+weView()->url().toString())); }
@ -236,7 +236,6 @@ private:
WebSearchBar* m_searchLine; WebSearchBar* m_searchLine;
SearchToolBar* m_webSearchToolbar; SearchToolBar* m_webSearchToolbar;
BookmarksToolbar* m_bookmarksToolbar; BookmarksToolbar* m_bookmarksToolbar;
LocationBar* m_locationBar;
TabWidget* m_tabWidget; TabWidget* m_tabWidget;
QPointer<SideBar> m_sideBar; QPointer<SideBar> m_sideBar;
StatusBarMessage* m_statusBarMessage; StatusBarMessage* m_statusBarMessage;

View File

@ -29,12 +29,13 @@
#include "progressbar.h" #include "progressbar.h"
#include "statusbarmessage.h" #include "statusbarmessage.h"
LocationBar::LocationBar(QupZilla* mainClass, QWidget* parent) LocationBar::LocationBar(QupZilla* mainClass)
: LineEdit(parent) : LineEdit()
,m_selectAllOnDoubleClick(false) ,m_selectAllOnDoubleClick(false)
,m_addComWithCtrl(false) ,m_addComWithCtrl(false)
,m_addCountryWithAlt(false) ,m_addCountryWithAlt(false)
,p_QupZilla(mainClass) ,p_QupZilla(mainClass)
,m_webView(0)
{ {
m_siteIcon = new QToolButton(this); m_siteIcon = new QToolButton(this);
m_siteIcon->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); m_siteIcon->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
@ -83,14 +84,16 @@ LocationBar::LocationBar(QupZilla* mainClass, QWidget* parent)
// LocationPopup* com = new LocationPopup(this); // LocationPopup* com = new LocationPopup(this);
connect(this, SIGNAL(textEdited(QString)), this, SLOT(textEdit())); connect(this, SIGNAL(textEdited(QString)), this, SLOT(textEdit()));
connect(this, SIGNAL(textEdited(QString)), m_locationCompleter, SLOT(refreshCompleter(QString))); connect(this, SIGNAL(textEdited(QString)), m_locationCompleter, SLOT(refreshCompleter(QString)));
connect(this, SIGNAL(returnPressed()), this, SLOT(urlEnter()));
connect(m_locationCompleter->popup(), SIGNAL(clicked(QModelIndex)), p_QupZilla, SLOT(urlEnter())); connect(m_locationCompleter->popup(), SIGNAL(clicked(QModelIndex)), p_QupZilla, SLOT(urlEnter()));
connect(m_siteIcon, SIGNAL(clicked()), this, SLOT(showSiteInfo())); connect(m_siteIcon, SIGNAL(clicked()), this, SLOT(showSiteInfo()));
// connect(down, SIGNAL(clicked(QPoint)), com, SLOT(show())); // connect(down, SIGNAL(clicked(QPoint)), com, SLOT(show()));
connect(m_goButton, SIGNAL(clicked(QPoint)), p_QupZilla, SLOT(urlEnter())); connect(m_goButton, SIGNAL(clicked(QPoint)), this, SLOT(urlEnter()));
connect(m_rssIcon, SIGNAL(clicked(QPoint)), this, SLOT(rssIconClicked())); connect(m_rssIcon, SIGNAL(clicked(QPoint)), this, SLOT(rssIconClicked()));
setStyleSheet("QLineEdit { background: transparent; border-image: url(:/icons/locationbar/lineedit.png); border-width:4; color:black;}"); setStyleSheet("QLineEdit { background: transparent; border-image: url(:/icons/locationbar/lineedit.png); border-width:4; color:black;}");
setLeftMargin(33); setLeftMargin(33);
clearIcon();
// setLeftMargin(m_siteIcon->sizeHint().width()+1); // setLeftMargin(m_siteIcon->sizeHint().width()+1);
} }
@ -103,6 +106,14 @@ void LocationBar::loadSettings()
m_addCountryWithAlt = settings.value("AddCountryDomainWithAltKey",true).toBool(); m_addCountryWithAlt = settings.value("AddCountryDomainWithAltKey",true).toBool();
} }
void LocationBar::urlEnter()
{
m_webView->setFocus();
QUrl guessedUrl = WebView::guessUrlFromString(text());
m_webView->load(guessedUrl);
setText(guessedUrl.toString());
}
void LocationBar::textEdit() void LocationBar::textEdit()
{ {
m_locationCompleter->popup()->setUpdatesEnabled(false); m_locationCompleter->popup()->setUpdatesEnabled(false);
@ -147,15 +158,20 @@ void LocationBar::showSiteInfo()
void LocationBar::rssIconClicked() void LocationBar::rssIconClicked()
{ {
QList<QPair<QString,QString> > _rss = p_QupZilla->weView()->getRss(); QList<QPair<QString,QString> > _rss = m_webView->getRss();
RSSWidget* rss = new RSSWidget(p_QupZilla->weView(), _rss, this); RSSWidget* rss = new RSSWidget(m_webView, _rss, this);
rss->showAt(this); rss->showAt(this);
} }
void LocationBar::showRSSIcon(bool state)
{
m_rssIcon->setVisible(state);
}
void LocationBar::showUrl(const QUrl &url, bool empty) void LocationBar::showUrl(const QUrl &url, bool empty)
{ {
if (/*hasFocus() || (*/url.isEmpty() && empty/*)*/) if (hasFocus() || (url.isEmpty() && empty))
return; return;
if (url.toEncoded()!=text()) { if (url.toEncoded()!=text()) {
@ -163,29 +179,24 @@ void LocationBar::showUrl(const QUrl &url, bool empty)
setCursorPosition(0); setCursorPosition(0);
} }
WebView* view = p_QupZilla->weView(); // if (m_webView->isLoading()) {
setPrivacy(view->webPage()->sslCertificate().isValid()); // p_QupZilla->ipLabel()->hide();
// p_QupZilla->progressBar()->setVisible(true);
if (view->isLoading()) { // p_QupZilla->progressBar()->setValue(m_webView->getLoading());
p_QupZilla->ipLabel()->hide(); // p_QupZilla->buttonStop()->setVisible(true);
p_QupZilla->progressBar()->setVisible(true); // p_QupZilla->buttonReload()->setVisible(false);
p_QupZilla->progressBar()->setValue(view->getLoading()); // } else {
p_QupZilla->buttonStop()->setVisible(true); // p_QupZilla->progressBar()->setVisible(false);
p_QupZilla->buttonReload()->setVisible(false); // p_QupZilla->buttonStop()->setVisible(false);
} else { // p_QupZilla->buttonReload()->setVisible(true);
p_QupZilla->progressBar()->setVisible(false); // p_QupZilla->ipLabel()->show();
p_QupZilla->buttonStop()->setVisible(false); // }
p_QupZilla->buttonReload()->setVisible(true);
p_QupZilla->ipLabel()->show();
}
p_QupZilla->statusBarMessage()->clearMessage(); p_QupZilla->statusBarMessage()->clearMessage();
hideGoButton(); hideGoButton();
m_bookmarkIcon->checkBookmark(url); m_bookmarkIcon->checkBookmark(url);
m_rssIcon->setVisible(view->hasRss());
} }
void LocationBar::siteIconChanged() void LocationBar::siteIconChanged()
@ -194,16 +205,21 @@ void LocationBar::siteIconChanged()
QIcon icon_; QIcon icon_;
// if (!p_QupZilla->weView()->isLoading()) // if (!p_QupZilla->weView()->isLoading())
// icon_ = p_QupZilla->weView()->animationLoading( p_QupZilla->tabWidget()->currentIndex(), false)->pixmap(); // icon_ = p_QupZilla->weView()->animationLoading( p_QupZilla->tabWidget()->currentIndex(), false)->pixmap();
icon_ = p_QupZilla->weView()->siteIcon(); icon_ = m_webView->siteIcon();
if (icon_.isNull()) { if (icon_.isNull()) {
m_siteIcon->setIcon(QIcon(QIcon::fromTheme("text-plain").pixmap(16,16))); clearIcon();
} else { } else {
// QIcon icon(*icon_); // QIcon icon(*icon_);
m_siteIcon->setIcon(QIcon(icon_.pixmap(16,16))); m_siteIcon->setIcon(QIcon(icon_.pixmap(16,16)));
} }
} }
void LocationBar::clearIcon()
{
m_siteIcon->setIcon(QIcon(QWebSettings::webGraphic(QWebSettings::DefaultFrameIconGraphic)));
}
void LocationBar::setPrivacy(bool state) void LocationBar::setPrivacy(bool state)
{ {
if (state) if (state)
@ -256,7 +272,7 @@ void LocationBar::mouseDoubleClickEvent(QMouseEvent* event)
void LocationBar::keyPressEvent(QKeyEvent *event) void LocationBar::keyPressEvent(QKeyEvent *event)
{ {
if (event->key() == Qt::Key_Escape) { if (event->key() == Qt::Key_Escape) {
showUrl(p_QupZilla->weView()->url()); setText(m_webView->url().toEncoded());
event->accept(); event->accept();
return; return;
} }

View File

@ -37,13 +37,16 @@ class LineEdit;
class LocationCompleter; class LocationCompleter;
class ClickableLabel; class ClickableLabel;
class BookmarkIcon; class BookmarkIcon;
class WebView;
class LocationBar : public LineEdit class LocationBar : public LineEdit
{ {
Q_OBJECT; Q_OBJECT
public: public:
explicit LocationBar(QupZilla* mainClass, QWidget* parent = 0); explicit LocationBar(QupZilla* mainClass);
~LocationBar(); ~LocationBar();
void setWebView(WebView* view) { m_webView = view; }
void loadSettings(); void loadSettings();
public slots: public slots:
@ -56,6 +59,9 @@ private slots:
void showPopup(); void showPopup();
void showSiteInfo(); void showSiteInfo();
void rssIconClicked(); void rssIconClicked();
void urlEnter();
void clearIcon();
void showRSSIcon(bool state);
private: private:
void focusOutEvent(QFocusEvent* e); void focusOutEvent(QFocusEvent* e);
@ -75,6 +81,7 @@ private:
bool m_addComWithCtrl; bool m_addComWithCtrl;
bool m_addCountryWithAlt; bool m_addCountryWithAlt;
QupZilla* p_QupZilla; QupZilla* p_QupZilla;
WebView* m_webView;
LocationCompleter* m_locationCompleter; LocationCompleter* m_locationCompleter;
bool m_rssIconVisible; bool m_rssIconVisible;

View File

@ -37,8 +37,7 @@ void Updater::start()
void Updater::startDownloadingUpdateInfo(const QUrl &url) void Updater::startDownloadingUpdateInfo(const QUrl &url)
{ {
QNetworkAccessManager* manager = new QNetworkAccessManager(); QNetworkAccessManager* manager = new QNetworkAccessManager();
QNetworkReply* reply; manager->get(QNetworkRequest(QUrl(url)));
reply=manager->get(QNetworkRequest(QUrl(url)));
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(downCompleted(QNetworkReply*))); connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(downCompleted(QNetworkReply*)));
} }

View File

@ -234,8 +234,7 @@ void RSSManager::loadFeedInNewTab()
void RSSManager::beginToLoadSlot(const QUrl &url) void RSSManager::beginToLoadSlot(const QUrl &url)
{ {
QNetworkReply* reply; m_networkManager->get(QNetworkRequest(QUrl(url)));
reply=m_networkManager->get(QNetworkRequest(QUrl(url)));
connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(finished(QNetworkReply*))); connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(finished(QNetworkReply*)));
} }

View File

@ -25,6 +25,7 @@
#include "webtab.h" #include "webtab.h"
#include "clickablelabel.h" #include "clickablelabel.h"
#include "closedtabsmanager.h" #include "closedtabsmanager.h"
#include "progressbar.h"
class NewTabButton : public QToolButton class NewTabButton : public QToolButton
{ {
@ -60,7 +61,6 @@ private:
style()->drawItemPixmap(&p, r, Qt::AlignCenter, pix); style()->drawItemPixmap(&p, r, Qt::AlignCenter, pix);
} }
#endif #endif
}; };
class TabListButton : public QToolButton class TabListButton : public QToolButton
@ -97,19 +97,20 @@ private:
TabWidget::TabWidget(QupZilla* mainClass, QWidget* parent) : TabWidget::TabWidget(QupZilla* mainClass, QWidget* parent) :
QTabWidget(parent) QTabWidget(parent)
,p_QupZilla(mainClass) , p_QupZilla(mainClass)
,m_lastTabIndex(0) , m_lastTabIndex(0)
,m_isClosingToLastTabIndex(false) , m_isClosingToLastTabIndex(false)
,m_closedTabsManager(new ClosedTabsManager(this)) , m_closedTabsManager(new ClosedTabsManager(this))
, m_locationBars(new QStackedWidget())
{ {
m_tabBar = new TabBar(p_QupZilla); m_tabBar = new TabBar(p_QupZilla);
setTabBar(m_tabBar); setTabBar(m_tabBar);
setObjectName("tabWidget"); setObjectName("tabWidget");
setStyleSheet("QTabBar::tab{ max-width:250px; }"); setStyleSheet("QTabBar::tab{ max-width:250px; }");
connect(this, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int))); connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int)));
connect(this, SIGNAL(currentChanged(int)), p_QupZilla, SLOT(refreshHistory())); connect(this, SIGNAL(currentChanged(int)), p_QupZilla, SLOT(refreshHistory()));
connect(this, SIGNAL(currentChanged(int)), p_QupZilla->locationBar(), SLOT(siteIconChanged())); // connect(this, SIGNAL(currentChanged(int)), p_QupZilla->locationBar(), SLOT(siteIconChanged()));
connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
connect(m_tabBar, SIGNAL(backTab(int)), this, SLOT(backTab(int))); connect(m_tabBar, SIGNAL(backTab(int)), this, SLOT(backTab(int)));
@ -212,10 +213,15 @@ int TabWidget::addView(QUrl url, const QString &title, OpenUrlIn openIn, bool se
if (url.isEmpty()) if (url.isEmpty())
url = m_urlOnNewTab; url = m_urlOnNewTab;
int index = addTab(new WebTab(p_QupZilla),""); LocationBar* locBar = new LocationBar(p_QupZilla);
m_locationBars->addWidget(locBar);
int index = addTab(new WebTab(p_QupZilla, locBar),"");
WebView* webView = weView(index);
locBar->setWebView(webView);
setTabText(index, title); setTabText(index, title);
weView(index)->animationLoading(index, true)->movie()->stop(); webView->animationLoading(index, true)->movie()->stop();
weView(index)->animationLoading(index, false)->setPixmap(_iconForUrl(url).pixmap(16,16)); webView->animationLoading(index, false)->setPixmap(_iconForUrl(url).pixmap(16,16));
if (openIn == TabWidget::NewSelectedTab) { if (openIn == TabWidget::NewSelectedTab) {
setCurrentIndex(index); setCurrentIndex(index);
@ -230,18 +236,22 @@ int TabWidget::addView(QUrl url, const QString &title, OpenUrlIn openIn, bool se
tabBar()->setTabsClosable(false); tabBar()->setTabsClosable(false);
else tabBar()->setTabsClosable(true); else tabBar()->setTabsClosable(true);
connect(weView(index), SIGNAL(siteIconChanged()), p_QupZilla->locationBar(), SLOT(siteIconChanged())); // connect(weView(index), SIGNAL(siteIconChanged()), p_QupZilla->locationBar(), SLOT(siteIconChanged()));
connect(weView(index), SIGNAL(showUrl(QUrl)), p_QupZilla->locationBar(), SLOT(showUrl(QUrl))); // connect(weView(index), SIGNAL(showUrl(QUrl)), p_QupZilla->locationBar(), SLOT(showUrl(QUrl)));
connect(weView(index), SIGNAL(wantsCloseTab(int)), this, SLOT(closeTab(int))); connect(webView, SIGNAL(wantsCloseTab(int)), this, SLOT(closeTab(int)));
connect(weView(index), SIGNAL(changed()), mApp, SLOT(setChanged())); connect(webView, SIGNAL(changed()), mApp, SLOT(setChanged()));
connect(weView(index), SIGNAL(ipChanged(QString)), p_QupZilla->ipLabel(), SLOT(setText(QString))); connect(webView, SIGNAL(ipChanged(QString)), p_QupZilla->ipLabel(), SLOT(setText(QString)));
if (url.isValid()) if (url.isValid())
weView(index)->load(url); webView->load(url);
if (selectLine) if (selectLine)
p_QupZilla->locationBar()->setFocus(); p_QupZilla->locationBar()->setFocus();
if (openIn == NewSelectedTab)
if (openIn == NewSelectedTab) {
m_isClosingToLastTabIndex = true; m_isClosingToLastTabIndex = true;
m_locationBars->setCurrentWidget(locBar);
}
return index; return index;
} }
@ -264,26 +274,28 @@ void TabWidget::closeTab(int index)
if (index == -1) if (index == -1)
index = currentIndex(); index = currentIndex();
if (weView(index)) { WebView* webView = weView(index);
disconnect(weView(index), SIGNAL(siteIconChanged()), p_QupZilla->locationBar(), SLOT(siteIconChanged())); if (!webView)
disconnect(weView(index), SIGNAL(showUrl(QUrl)), p_QupZilla->locationBar(), SLOT(showUrl(QUrl))); return;
disconnect(weView(index), SIGNAL(wantsCloseTab(int)), this, SLOT(closeTab(int)));
disconnect(weView(index), SIGNAL(changed()), mApp, SLOT(setChanged())); m_locationBars->removeWidget(webView->webTab()->locationBar());
disconnect(weView(index), SIGNAL(ipChanged(QString)), p_QupZilla->ipLabel(), SLOT(setText(QString))); // disconnect(weView(index), SIGNAL(siteIconChanged()), p_QupZilla->locationBar(), SLOT(siteIconChanged()));
// disconnect(weView(index), SIGNAL(showUrl(QUrl)), p_QupZilla->locationBar(), SLOT(showUrl(QUrl)));
disconnect(webView, SIGNAL(wantsCloseTab(int)), this, SLOT(closeTab(int)));
disconnect(webView, SIGNAL(changed()), mApp, SLOT(setChanged()));
disconnect(webView, SIGNAL(ipChanged(QString)), p_QupZilla->ipLabel(), SLOT(setText(QString)));
//Save last tab url and history //Save last tab url and history
m_closedTabsManager->saveView(weView(index)); m_closedTabsManager->saveView(webView);
if (m_isClosingToLastTabIndex && m_lastTabIndex < count()) if (m_isClosingToLastTabIndex && m_lastTabIndex < count())
setCurrentIndex(m_lastTabIndex); setCurrentIndex(m_lastTabIndex);
delete weView(index); delete widget(index);
removeTab(index);
if (count() == 1 && m_hideCloseButtonWithOneTab) if (count() == 1 && m_hideCloseButtonWithOneTab)
tabBar()->setTabsClosable(false); tabBar()->setTabsClosable(false);
if (count() == 1 && m_hideTabBarWithOneTab) if (count() == 1 && m_hideTabBarWithOneTab)
tabBar()->setVisible(false); tabBar()->setVisible(false);
}
// if (count() < 1) // if (count() < 1)
// p_QupZilla->close(); // p_QupZilla->close();
@ -296,24 +308,40 @@ void TabWidget::tabMoved(int before, int after)
m_isClosingToLastTabIndex = false; m_isClosingToLastTabIndex = false;
} }
void TabWidget::tabChanged(int index) void TabWidget::currentTabChanged(int index)
{ {
if (index < 0) if (index < 0)
return; return;
m_isClosingToLastTabIndex = false; m_isClosingToLastTabIndex = false;
WebView* webView = weView();
QString title = p_QupZilla->weView()->title(); QString title = webView->title();
if (title.isEmpty()) if (title.isEmpty())
title = tr("No Named Page"); title = tr("No Named Page");
p_QupZilla->setWindowTitle(title + " - QupZilla"); p_QupZilla->setWindowTitle(title + " - QupZilla");
p_QupZilla->locationBar()->showUrl(weView()->url(),false); // p_QupZilla->locationBar()->showUrl(weView()->url(),false);
p_QupZilla->ipLabel()->setText(weView()->getIp());
m_locationBars->setCurrentWidget(webView->webTab()->locationBar());
p_QupZilla->ipLabel()->setText(webView->getIp());
if (webView->isLoading()) {
p_QupZilla->ipLabel()->hide();
p_QupZilla->progressBar()->setVisible(true);
p_QupZilla->progressBar()->setValue(webView->getLoading());
p_QupZilla->buttonStop()->setVisible(true);
p_QupZilla->buttonReload()->setVisible(false);
} else {
p_QupZilla->progressBar()->setVisible(false);
p_QupZilla->buttonStop()->setVisible(false);
p_QupZilla->buttonReload()->setVisible(true);
p_QupZilla->ipLabel()->show();
}
if (p_QupZilla->inspectorDock() && p_QupZilla->inspectorDock()->isVisible()) if (p_QupZilla->inspectorDock() && p_QupZilla->inspectorDock()->isVisible())
p_QupZilla->showInspector(); p_QupZilla->showInspector();
weView()->setFocus(); webView->setFocus();
m_tabBar->updateCloseButton(index); m_tabBar->updateCloseButton(index);
} }
@ -541,9 +569,6 @@ bool TabWidget::restoreState(const QByteArray &state)
TabWidget::~TabWidget() TabWidget::~TabWidget()
{ {
int index = currentIndex();
closeAllButCurrent(index);
closeTab(index);
delete m_menuTabs; delete m_menuTabs;
delete m_buttonAddTab; delete m_buttonAddTab;
delete m_buttonListTabs; delete m_buttonListTabs;

View File

@ -25,6 +25,7 @@
#include <QDateTime> #include <QDateTime>
#include <QToolButton> #include <QToolButton>
#include <QStylePainter> #include <QStylePainter>
#include <QStackedWidget>
class QupZilla; class QupZilla;
class WebView; class WebView;
@ -54,6 +55,7 @@ public:
inline ClosedTabsManager* closedTabsManager() { return m_closedTabsManager; } inline ClosedTabsManager* closedTabsManager() { return m_closedTabsManager; }
bool canRestoreTab(); bool canRestoreTab();
QList<WebTab*> allTabs(bool withPinned = true); QList<WebTab*> allTabs(bool withPinned = true);
QStackedWidget* locationBars() { return m_locationBars; }
public slots: public slots:
@ -72,7 +74,7 @@ public slots:
private slots: private slots:
void aboutToShowTabsMenu(); void aboutToShowTabsMenu();
void actionChangeIndex(); void actionChangeIndex();
void tabChanged(int index); void currentTabChanged(int index);
void tabMoved(int before, int after); void tabMoved(int before, int after);
private: private:
@ -93,6 +95,8 @@ private:
NewTabButton* m_buttonAddTab; NewTabButton* m_buttonAddTab;
TabListButton* m_buttonListTabs; TabListButton* m_buttonListTabs;
ClosedTabsManager* m_closedTabsManager; ClosedTabsManager* m_closedTabsManager;
QStackedWidget* m_locationBars;
}; };
#endif // TABWIDGET_H #endif // TABWIDGET_H

View File

@ -33,12 +33,25 @@ WebPage::WebPage(WebView* parent, QupZilla* mainClass)
,m_view(parent) ,m_view(parent)
,m_blockAlerts(false) ,m_blockAlerts(false)
,m_lastUploadLocation(QDir::homePath()) ,m_lastUploadLocation(QDir::homePath())
,m_secureStatus(false)
// ,m_isOpeningNextWindowAsNewTab(false) // ,m_isOpeningNextWindowAsNewTab(false)
{ {
setForwardUnsupportedContent(true); setForwardUnsupportedContent(true);
setPluginFactory(new WebPluginFactory(this)); setPluginFactory(new WebPluginFactory(this));
connect(this, SIGNAL(unsupportedContent(QNetworkReply*)), SLOT(handleUnsupportedContent(QNetworkReply*))); connect(this, SIGNAL(unsupportedContent(QNetworkReply*)), SLOT(handleUnsupportedContent(QNetworkReply*)));
connect(this, SIGNAL(loadStarted()), this, SLOT(loadingStarted())); connect(this, SIGNAL(loadStarted()), this, SLOT(loadingStarted()));
connect(this, SIGNAL(loadProgress(int)), this, SLOT(progress(int)));
}
void WebPage::progress(int prog)
{
Q_UNUSED(prog)
bool secStatus = sslCertificate().isValid();
if (secStatus != m_secureStatus) {
m_secureStatus = secStatus;
emit privacyChanged(sslCertificate().isValid());
}
} }
void WebPage::loadingStarted() void WebPage::loadingStarted()

View File

@ -57,10 +57,14 @@ public:
void addAdBlockRule(const QString &filter, const QUrl &url); void addAdBlockRule(const QString &filter, const QUrl &url);
QList<AdBlockedEntry> adBlockedEntries() { return m_adBlockedEntries; } QList<AdBlockedEntry> adBlockedEntries() { return m_adBlockedEntries; }
signals:
void privacyChanged(bool status);
protected slots: protected slots:
QWebPage* createWindow(QWebPage::WebWindowType type); QWebPage* createWindow(QWebPage::WebWindowType type);
void handleUnsupportedContent(QNetworkReply* url); void handleUnsupportedContent(QNetworkReply* url);
void loadingStarted(); void loadingStarted();
void progress(int prog);
private: private:
virtual bool supportsExtension(Extension extension) const { return (extension == ErrorPageExtension); } virtual bool supportsExtension(Extension extension) const { return (extension == ErrorPageExtension); }
@ -78,6 +82,8 @@ private:
QList<AdBlockedEntry> m_adBlockedEntries; QList<AdBlockedEntry> m_adBlockedEntries;
bool m_blockAlerts; bool m_blockAlerts;
QString m_lastUploadLocation; QString m_lastUploadLocation;
bool m_secureStatus;
// bool m_isOpeningNextWindowAsNewTab; // bool m_isOpeningNextWindowAsNewTab;
}; };

View File

@ -18,12 +18,15 @@
#include "webtab.h" #include "webtab.h"
#include "qupzilla.h" #include "qupzilla.h"
#include "webview.h" #include "webview.h"
#include "webpage.h"
#include "tabbar.h" #include "tabbar.h"
#include "locationbar.h"
WebTab::WebTab(QupZilla* mainClass, QWidget* parent) WebTab::WebTab(QupZilla* mainClass, LocationBar* locationBar)
:QWidget(parent) :QWidget()
,p_QupZilla(mainClass) ,p_QupZilla(mainClass)
,m_view(0) ,m_view(0)
,m_locationBar(locationBar)
,m_pinned(false) ,m_pinned(false)
{ {
m_layout = new QVBoxLayout(this); m_layout = new QVBoxLayout(this);
@ -36,6 +39,12 @@ WebTab::WebTab(QupZilla* mainClass, QWidget* parent)
setAutoFillBackground(true); // We don't want this transparent setAutoFillBackground(true); // We don't want this transparent
connect(m_view, SIGNAL(showNotification(QWidget*)), this, SLOT(showNotification(QWidget*))); connect(m_view, SIGNAL(showNotification(QWidget*)), this, SLOT(showNotification(QWidget*)));
connect(m_view, SIGNAL(iconChanged()), m_locationBar, SLOT(siteIconChanged()));
connect(m_view, SIGNAL(loadStarted()), m_locationBar, SLOT(clearIcon()));
connect(m_view, SIGNAL(loadFinished(bool)), m_locationBar, SLOT(siteIconChanged()));
connect(m_view, SIGNAL(urlChanged(QUrl)), m_locationBar, SLOT(showUrl(QUrl)));
connect(m_view, SIGNAL(rssChanged(bool)), m_locationBar, SLOT(showRSSIcon(bool)));
connect(m_view->webPage(), SIGNAL(privacyChanged(bool)), m_locationBar, SLOT(setPrivacy(bool)));
} }
void WebTab::showNotification(QWidget* notif) void WebTab::showNotification(QWidget* notif)
@ -74,5 +83,6 @@ void WebTab::pinTab(int index)
WebTab::~WebTab() WebTab::~WebTab()
{ {
delete m_locationBar;
delete m_view; delete m_view;
} }

View File

@ -24,17 +24,21 @@
#include "webview.h" #include "webview.h"
class QupZilla; class QupZilla;
class LocationBar;
class WebTab : public QWidget class WebTab : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit WebTab(QupZilla* mainClass, QWidget* parent = 0); explicit WebTab(QupZilla* mainClass, LocationBar* locationBar);
~WebTab(); ~WebTab();
WebView* view() { return m_view; } WebView* view() { return m_view; }
bool isPinned() { return m_pinned; } bool isPinned() { return m_pinned; }
void pinTab(int index); void pinTab(int index);
void setPinned(bool state) { m_pinned = state; } void setPinned(bool state) { m_pinned = state; }
void setLocationBar(LocationBar* bar) { m_locationBar = bar; }
LocationBar* locationBar() { return m_locationBar; }
private slots: private slots:
void showNotification(QWidget* notif); void showNotification(QWidget* notif);
@ -43,6 +47,7 @@ private:
QupZilla* p_QupZilla; QupZilla* p_QupZilla;
QPointer<WebView> m_view; QPointer<WebView> m_view;
QVBoxLayout* m_layout; QVBoxLayout* m_layout;
LocationBar* m_locationBar;
bool m_pinned; bool m_pinned;
}; };

View File

@ -32,6 +32,7 @@
#include "iconprovider.h" #include "iconprovider.h"
#include "webtab.h" #include "webtab.h"
#include "statusbarmessage.h" #include "statusbarmessage.h"
#include "progressbar.h"
WebView::WebView(QupZilla* mainClass, WebTab* webTab) WebView::WebView(QupZilla* mainClass, WebTab* webTab)
: QWebView() : QWebView()
@ -44,6 +45,7 @@ WebView::WebView(QupZilla* mainClass, WebTab* webTab)
,m_wantsClose(false) ,m_wantsClose(false)
,m_page(new WebPage(this, p_QupZilla)) ,m_page(new WebPage(this, p_QupZilla))
,m_webTab(webTab) ,m_webTab(webTab)
,m_locationBar(0)
,m_mouseTrack(false) ,m_mouseTrack(false)
,m_navigationVisible(false) ,m_navigationVisible(false)
,m_mouseWheelEnabled(true) ,m_mouseWheelEnabled(true)
@ -137,6 +139,14 @@ void WebView::setProgress(int prog)
emit showUrl(url()); emit showUrl(url());
} }
checkRss(); checkRss();
if (isCurrent()) {
p_QupZilla->ipLabel()->hide();
p_QupZilla->progressBar()->setVisible(true);
p_QupZilla->progressBar()->setValue(m_progress);
p_QupZilla->buttonStop()->setVisible(true);
p_QupZilla->buttonReload()->setVisible(false);
}
} }
void WebView::loadStarted() void WebView::loadStarted()
@ -231,6 +241,13 @@ void WebView::loadFinished(bool state)
titleChanged(); titleChanged();
mApp->autoFill()->completePage(this); mApp->autoFill()->completePage(this);
QHostInfo::lookupHost(url().host(), this, SLOT(setIp(QHostInfo))); QHostInfo::lookupHost(url().host(), this, SLOT(setIp(QHostInfo)));
if (isCurrent()) {
p_QupZilla->progressBar()->setVisible(false);
p_QupZilla->buttonStop()->setVisible(false);
p_QupZilla->buttonReload()->setVisible(true);
p_QupZilla->ipLabel()->show();
}
} }
void WebView::titleChanged() void WebView::titleChanged()
@ -354,6 +371,8 @@ void WebView::checkRss()
continue; continue;
m_rss.append(QPair<QString,QString>(title, href)); m_rss.append(QPair<QString,QString>(title, href));
} }
emit rssChanged(!m_rss.isEmpty());
} }
void WebView::mousePressEvent(QMouseEvent* event) void WebView::mousePressEvent(QMouseEvent* event)

View File

@ -36,7 +36,7 @@ class TabWidget;
class WebPage; class WebPage;
class NetworkManagerProxy; class NetworkManagerProxy;
class WebTab; class WebTab;
class LocationBar;
class WebView : public QWebView class WebView : public QWebView
{ {
Q_OBJECT Q_OBJECT
@ -61,6 +61,9 @@ public:
QList<QPair<QString,QString> > getRss() { return m_rss; } //FIXME: Make RSS as struct QList<QPair<QString,QString> > getRss() { return m_rss; } //FIXME: Make RSS as struct
void setMouseWheelEnabled(bool state) { m_mouseWheelEnabled = state; } void setMouseWheelEnabled(bool state) { m_mouseWheelEnabled = state; }
void setLocationBar(LocationBar* bar) { m_locationBar = bar; }
LocationBar* locationBar() { return m_locationBar; }
static QUrl guessUrlFromString(const QString &string); static QUrl guessUrlFromString(const QString &string);
static bool isUrlValid(const QUrl &url); static bool isUrlValid(const QUrl &url);
int tabIndex() const; int tabIndex() const;
@ -134,6 +137,7 @@ private:
WebPage* m_page; WebPage* m_page;
WebTab* m_webTab; WebTab* m_webTab;
NetworkManagerProxy* m_networkProxy; NetworkManagerProxy* m_networkProxy;
LocationBar* m_locationBar;
bool m_mouseTrack; bool m_mouseTrack;
bool m_navigationVisible; bool m_navigationVisible;
@ -143,12 +147,12 @@ private:
signals: signals:
void showUrl(QUrl url); void showUrl(QUrl url);
void siteIconChanged(); void siteIconChanged();
void setPrivacy(bool state);
void wantsCloseTab(int index); void wantsCloseTab(int index);
void changed(); void changed();
void ipChanged(QString ip); void ipChanged(QString ip);
void showNotification(QWidget* notif); void showNotification(QWidget* notif);
void viewportResized(QSize size); void viewportResized(QSize size);
void rssChanged(bool state);
}; };
#endif // WEBVIEW_H #endif // WEBVIEW_H