|
|
|
/*! @file
|
|
|
|
|
|
|
|
@id $Id: browser.hxx 15 2010-06-03 14:17:27Z marc $
|
|
|
|
*/
|
|
|
|
// 1 2 3 4 5 6 7 8
|
|
|
|
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
|
|
|
|
|
|
|
#ifndef BROWSER_HXX
|
|
|
|
#define BROWSER_HXX
|
|
|
|
|
|
|
|
#include <ui_browser.h>
|
|
|
|
#include <QtGui/QMainWindow>
|
|
|
|
#include <QtGui/QLineEdit>
|
|
|
|
#include <QtGui/QProgressBar>
|
|
|
|
#include <QtGui/QComboBox>
|
|
|
|
#include <QtGui/QSlider>
|
|
|
|
#include <QtGui/QMessageBox>
|
|
|
|
#include <QtGui/QPrinter>
|
|
|
|
#include <QtGui/QPrintDialog>
|
|
|
|
#include <QtGui/QPrintPreviewDialog>
|
|
|
|
#include <QtWebKit/QWebPage>
|
|
|
|
#include <QtWebKit/QWebView>
|
|
|
|
#include <QtWebKit/QWebFrame>
|
|
|
|
#include <QtWebKit/QWebHistory>
|
|
|
|
#include <QtNetwork/QNetworkReply>
|
|
|
|
#include <QtNetwork/QSslError>
|
|
|
|
#include <QtNetwork/QNetworkProxy>
|
|
|
|
#include <QtCore/QTemporaryFile>
|
|
|
|
#include <QtCore/QProcess>
|
|
|
|
#include <QtCore/QDir>
|
|
|
|
#include <QtGui/QFileDialog>
|
|
|
|
|
|
|
|
#include <smartcardauth.hxx>
|
|
|
|
#include <downloadmanager.hxx>
|
|
|
|
#include <authentication.hxx>
|
|
|
|
#include <webpage.hxx>
|
|
|
|
#include <settings.hxx>
|
|
|
|
#include <sslclientnetworkmanager.hxx>
|
|
|
|
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
#include <QtCore/QDebug>
|
|
|
|
#ifndef LOG
|
|
|
|
#define LOG qDebug()<<__PRETTY_FUNCTION__
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class Browser: public QMainWindow, protected Ui::Browser {
|
|
|
|
|
|
|
|
Q_OBJECT;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
Browser(const QString& actlib, const QStringList& urls = QStringList(),
|
|
|
|
QSettings* settings=0,
|
|
|
|
Settings::MimeTypes mimeTypes = Settings::MimeTypes(),
|
|
|
|
bool kiosk = false):
|
|
|
|
_url(0), _clearUrl(0), _addBookmark(0), _find(0),
|
|
|
|
_kiosk(kiosk),
|
|
|
|
_settings(mimeTypes, this, settings, !kiosk),
|
|
|
|
_scAuth(actlib) {
|
|
|
|
LOG<<urls;
|
|
|
|
if (urls.size()) _home = urls.at(0);
|
|
|
|
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
|
|
|
setupUi(this);
|
|
|
|
statusBar()->addPermanentWidget(_progress = new QProgressBar());
|
|
|
|
statusBar()->addPermanentWidget(_zoom = new QSlider(Qt::Horizontal));
|
|
|
|
_zoom->setMinimum(1);
|
|
|
|
_zoom->setMaximum(100);
|
|
|
|
_zoom->setValue(10);
|
|
|
|
assert(connect(_zoom, SIGNAL(valueChanged(int)), SLOT(zoom(int))));
|
|
|
|
_toolbar->addWidget(_url = new QComboBox(_toolbar));
|
|
|
|
on_actionNewTab_triggered();
|
|
|
|
_url->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,
|
|
|
|
QSizePolicy::Fixed));
|
|
|
|
_url->setEditable(!kiosk);
|
|
|
|
_url->addItems(urls);
|
|
|
|
assert(connect(_url, SIGNAL(currentIndexChanged(const QString&)),
|
|
|
|
SLOT(load(QString))));
|
|
|
|
assert(connect(&_networkManager,
|
|
|
|
SIGNAL(extendedContextInitialization(ssl_ctx_st*,
|
|
|
|
QSslSocket*)),
|
|
|
|
&_scAuth,
|
|
|
|
SLOT(extendedContextInitialization(ssl_ctx_st*,
|
|
|
|
QSslSocket*))));
|
|
|
|
assert(connect(&_networkManager, SIGNAL(created(QNetworkReply*)),
|
|
|
|
&_downloadManager, SLOT(add(QNetworkReply*))));
|
|
|
|
|
|
|
|
assert(connect(&_downloadManager, SIGNAL(progress(qint64, qint64)),
|
|
|
|
SLOT(progress(qint64, qint64))));
|
|
|
|
assert(connect(&_downloadManager, SIGNAL(started()),
|
|
|
|
SLOT(started())));
|
|
|
|
assert(connect(&_downloadManager, SIGNAL(finished()),
|
|
|
|
SLOT(finished())));
|
|
|
|
|
|
|
|
if (_kiosk) {
|
|
|
|
_menu->hide();
|
|
|
|
} else {
|
|
|
|
assert(connect(_url->lineEdit(), SIGNAL(returnPressed()),
|
|
|
|
SLOT(load())));
|
|
|
|
_toolbar->addWidget(_clearUrl = new QPushButton("X", _toolbar));
|
|
|
|
assert(connect(_clearUrl, SIGNAL(clicked(bool)),
|
|
|
|
_url, SLOT(clearEditText())));
|
|
|
|
assert(connect(_clearUrl, SIGNAL(clicked(bool)),
|
|
|
|
_url, SLOT(setFocus())));
|
|
|
|
_toolbar->addWidget(_addBookmark = new QPushButton("+", _toolbar));
|
|
|
|
assert(connect(_addBookmark, SIGNAL(clicked(bool)),
|
|
|
|
SLOT(addBookmark())));
|
|
|
|
}
|
|
|
|
if (!_kiosk && _settings.flag("SaveWindowState") && _settings())
|
|
|
|
loadWin(urls.size());
|
|
|
|
if (urls.size()) load(urls.at(0));
|
|
|
|
for (int i(1); i<urls.size(); ++i) load(urls.at(i), newTab());
|
|
|
|
}
|
|
|
|
|
|
|
|
~Browser() {
|
|
|
|
LOG;
|
|
|
|
for (DownloadProcesses::iterator it(_downloadProcesses.begin());
|
|
|
|
it!=_downloadProcesses.end(); ++it) {
|
|
|
|
LOG<<"delete:"<<it->second->fileName();
|
|
|
|
delete it->second;
|
|
|
|
it->second = 0;
|
|
|
|
it->first->terminate();
|
|
|
|
delete it->first;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Whitelisting
|
|
|
|
bool check(QUrl page) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
QWebView* newTab() {
|
|
|
|
QWebView* browser(new QWebView);
|
|
|
|
browser->setPage(new WebPage(this, browser));
|
|
|
|
browser->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
|
|
|
|
browser->page()->setNetworkAccessManager(&_networkManager);
|
|
|
|
browser->page()->setForwardUnsupportedContent(true);
|
|
|
|
_url->setFocus();
|
|
|
|
// QWebView
|
|
|
|
assert(connect(browser, SIGNAL(urlChanged(const QUrl&)),
|
|
|
|
SLOT(urlChanged(const QUrl&))));
|
|
|
|
assert(connect(browser, SIGNAL(linkClicked(const QUrl&)),
|
|
|
|
SLOT(linkClicked(const QUrl&))));
|
|
|
|
assert(connect(browser, SIGNAL(iconChanged()),
|
|
|
|
SLOT(iconChanged())));
|
|
|
|
assert(connect(browser, SIGNAL(titleChanged(const QString&)),
|
|
|
|
SLOT(titleChanged(const QString&))));
|
|
|
|
assert(connect(browser, SIGNAL(statusBarMessage(const QString&)),
|
|
|
|
SLOT(statusBarMessage(const QString&))));
|
|
|
|
assert(connect(browser, SIGNAL(loadProgress(int)),
|
|
|
|
SLOT(loadProgress(int))));
|
|
|
|
assert(connect(browser, SIGNAL(loadStarted()),
|
|
|
|
SLOT(loadStarted())));
|
|
|
|
assert(connect(browser, SIGNAL(loadFinished(bool)),
|
|
|
|
SLOT(loadFinished(bool))));
|
|
|
|
// QWebPage WebAction
|
|
|
|
assert(connect(browser->pageAction(QWebPage::OpenLink),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredOpenLink(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::OpenLinkInNewWindow),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredOpenLinkInNewWindow(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::OpenFrameInNewWindow),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredOpenFrameInNewWindow(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::DownloadLinkToDisk),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredDownloadLinkToDisk(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::CopyLinkToClipboard),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredCopyLinkToClipboard(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::OpenImageInNewWindow),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredOpenImageInNewWindow(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::DownloadImageToDisk),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredDownloadImageToDisk(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::CopyImageToClipboard),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredCopyImageToClipboard(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::Back),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredBack(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::Forward),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredForward(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::Stop),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredStop(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::Reload),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredReload(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::Cut),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredCut(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::Copy),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredCopy(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::Paste),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredPaste(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::Undo),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredUndo(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::Redo),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredRedo(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::MoveToNextChar),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredMoveToNextChar(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::MoveToPreviousChar),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredMoveToPreviousChar(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::MoveToNextWord),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredMoveToNextWord(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::MoveToPreviousWord),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredMoveToPreviousWord(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::MoveToNextLine),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredMoveToNextLine(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::MoveToPreviousLine),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredMoveToPreviousLine(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::MoveToStartOfLine),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredMoveToStartOfLine(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::MoveToEndOfLine),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredMoveToEndOfLine(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::MoveToStartOfBlock),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredMoveToStartOfBlock(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::MoveToEndOfBlock),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredMoveToEndOfBlock(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::MoveToStartOfDocument),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredMoveToStartOfDocument(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::MoveToEndOfDocument),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredMoveToEndOfDocument(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::SelectNextChar),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredSelectNextChar(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::SelectPreviousChar),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredSelectPreviousChar(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::SelectNextWord),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredSelectNextWord(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::SelectPreviousWord),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredSelectPreviousWord(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::SelectNextLine),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredSelectNextLine(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::SelectPreviousLine),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredSelectPreviousLine(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::SelectStartOfLine),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredSelectStartOfLine(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::SelectEndOfLine),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredSelectEndOfLine(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::SelectStartOfBlock),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredSelectStartOfBlock(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::SelectEndOfBlock),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredSelectEndOfBlock(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::SelectStartOfDocument),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredSelectStartOfDocument(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::SelectEndOfDocument),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredSelectEndOfDocument(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::DeleteStartOfWord),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredDeleteStartOfWord(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::DeleteEndOfWord),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredDeleteEndOfWord(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::SetTextDirectionDefault),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredSetTextDirectionDefault(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::SetTextDirectionLeftToRight),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredSetTextDirectionLeftToRight(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::SetTextDirectionRightToLeft),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredSetTextDirectionRightToLeft(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::ToggleBold),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredToggleBold(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::ToggleItalic),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredToggleItalic(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::ToggleUnderline),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredToggleUnderline(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::InspectElement),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredInspectElement(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::InsertParagraphSeparator),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredInsertParagraphSeparator(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::InsertLineSeparator),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredInsertLineSeparator(bool))));
|
|
|
|
assert(connect(browser->pageAction(QWebPage::SelectAll),
|
|
|
|
SIGNAL(triggered(bool)),
|
|
|
|
SLOT(triggeredSelectAll(bool))));
|
|
|
|
// QWebPage
|
|
|
|
assert(connect(browser->page(), SIGNAL(contentsChanged()),
|
|
|
|
SLOT(contentsChanged())));
|
|
|
|
assert(connect(browser->page(),
|
|
|
|
SIGNAL(databaseQuotaExceeded(QWebFrame*, QString)),
|
|
|
|
SLOT(databaseQuotaExceeded(QWebFrame*, QString))));
|
|
|
|
assert(connect(browser->page(),
|
|
|
|
SIGNAL(downloadRequested(const QNetworkRequest&)),
|
|
|
|
SLOT(downloadRequested(const QNetworkRequest&))));
|
|
|
|
assert(connect(browser->page(), SIGNAL(frameCreated(QWebFrame*)),
|
|
|
|
SLOT(frameCreated(QWebFrame*))));
|
|
|
|
assert(connect(browser->page(),
|
|
|
|
SIGNAL(geometryChangeRequested(const QRect&)),
|
|
|
|
SLOT(geometryChangeRequested(const QRect&))));
|
|
|
|
// assert(connect(browser->page(), SIGNAL(linkClicked(const QUrl&)),
|
|
|
|
// SLOT(linkClicked(const QUrl&))));
|
|
|
|
assert(connect(browser->page(),
|
|
|
|
SIGNAL(linkHovered(const QString&, const QString&,
|
|
|
|
const QString&)),
|
|
|
|
SLOT(linkHovered(const QString&, const QString&,
|
|
|
|
const QString&))));
|
|
|
|
// assert(connect(browser->page(), SIGNAL(loadFinished(bool)),
|
|
|
|
// SLOT(loadFinished(bool))));
|
|
|
|
// assert(connect(browser->page(), SIGNAL(loadProgress(int)),
|
|
|
|
// SLOT(loadProgress(int))));
|
|
|
|
// assert(connect(browser->page(), SIGNAL(loadStarted()),
|
|
|
|
// SLOT(loadStarted())));
|
|
|
|
assert(connect(browser->page(),
|
|
|
|
SIGNAL(menuBarVisibilityChangeRequested(bool)),
|
|
|
|
SLOT(menuBarVisibilityChangeRequested(bool))));
|
|
|
|
assert(connect(browser->page(), SIGNAL(microFocusChanged()),
|
|
|
|
SLOT(microFocusChanged())));
|
|
|
|
assert(connect(browser->page(), SIGNAL(printRequested(QWebFrame*)),
|
|
|
|
SLOT(printRequested(QWebFrame*))));
|
|
|
|
assert(connect(browser->page(), SIGNAL(repaintRequested(const QRect&)),
|
|
|
|
SLOT(repaintRequested(const QRect&))));
|
|
|
|
assert(connect(browser->page(),
|
|
|
|
SIGNAL(restoreFrameStateRequested(QWebFrame*)),
|
|
|
|
SLOT(restoreFrameStateRequested(QWebFrame*))));
|
|
|
|
assert(connect(browser->page(),
|
|
|
|
SIGNAL(saveFrameStateRequested(QWebFrame*,
|
|
|
|
QWebHistoryItem*)),
|
|
|
|
SLOT(saveFrameStateRequested(QWebFrame*,
|
|
|
|
QWebHistoryItem*))));
|
|
|
|
assert(connect(browser->page(),
|
|
|
|
SIGNAL(scrollRequested(int, int, const QRect&)),
|
|
|
|
SLOT(scrollRequested(int, int, const QRect&))));
|
|
|
|
assert(connect(browser->page(), SIGNAL(selectionChanged()),
|
|
|
|
SLOT(selectionChanged())));
|
|
|
|
// assert(connect(browser->page(), SIGNAL(statusBarMessage(const QString&)),
|
|
|
|
// SLOT(statusBarMessage(const QString&))));
|
|
|
|
assert(connect(browser->page(),
|
|
|
|
SIGNAL(statusBarVisibilityChangeRequested(bool)),
|
|
|
|
SLOT(statusBarVisibilityChangeRequested(bool))));
|
|
|
|
assert(connect(browser->page(),
|
|
|
|
SIGNAL(toolBarVisibilityChangeRequested(bool)),
|
|
|
|
SLOT(toolBarVisibilityChangeRequested(bool))));
|
|
|
|
assert(connect(browser->page(),
|
|
|
|
SIGNAL(unsupportedContent(QNetworkReply*)),
|
|
|
|
SLOT(unsupportedContent(QNetworkReply*))));
|
|
|
|
assert(connect(browser->page(), SIGNAL(windowCloseRequested()),
|
|
|
|
SLOT(windowCloseRequested())));
|
|
|
|
// QNetworkAccessManager
|
|
|
|
assert(connect(browser->page()->networkAccessManager(),
|
|
|
|
SIGNAL(authenticationRequired(QNetworkReply*,
|
|
|
|
QAuthenticator*)),
|
|
|
|
SLOT(authenticationRequired(QNetworkReply*,
|
|
|
|
QAuthenticator*))));
|
|
|
|
assert(connect(browser->page()->networkAccessManager(),
|
|
|
|
SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&,
|
|
|
|
QAuthenticator*)),
|
|
|
|
SLOT(proxyAuthenticationRequired(const QNetworkProxy&,
|
|
|
|
QAuthenticator*))));
|
|
|
|
assert(connect(browser->page()->networkAccessManager(),
|
|
|
|
SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)),
|
|
|
|
SLOT(sslErrors(QNetworkReply*, const QList<QSslError>&))));
|
|
|
|
_tabs->setCurrentIndex(_tabs->addTab(browser, "*empty*"));
|
|
|
|
_tabs->setTabsClosable(_tabs->count()>1);
|
|
|
|
return browser;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
void closeEvent(QCloseEvent *event) {
|
|
|
|
LOG;
|
|
|
|
if (!_kiosk && _settings.flag("SaveWindowState") && _settings())
|
|
|
|
saveWin();
|
|
|
|
QMainWindow::closeEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
|
|
|
|
void load() {
|
|
|
|
LOG;
|
|
|
|
load(_url->currentText());
|
|
|
|
}
|
|
|
|
|
|
|
|
void load(QString page) {
|
|
|
|
_settings.replaceSearchEngine(page);
|
|
|
|
if (QUrl(page).scheme()=="") page = "http://"+page;
|
|
|
|
load(QUrl(page));
|
|
|
|
}
|
|
|
|
|
|
|
|
void load(QUrl page, QWebView* view=0) {
|
|
|
|
LOG<<page.toString();
|
|
|
|
statusBar()->showMessage(tr("Checking: %1").arg(page.toString()));
|
|
|
|
if (!check(page)) {
|
|
|
|
LOG<<"########## BLACK LISTED IGNORED ##########";
|
|
|
|
statusBar()->showMessage(tr("Forbidden: %1").arg(page.toString()));
|
|
|
|
QMessageBox::warning(this, tr("Access Denied"),
|
|
|
|
tr("<p>Access denied due to security"
|
|
|
|
" considerations.</p><p>You are not"
|
|
|
|
" allowed to connect to %1.")
|
|
|
|
.arg(page.toString()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
statusBar()->showMessage(tr("Reading: %1").arg(page.toString()));
|
|
|
|
if (!page.isValid()) {
|
|
|
|
statusBar()->showMessage(tr("Illegal URL: %1").arg(page.errorString()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!view) view=qobject_cast<QWebView*>(_tabs->currentWidget());
|
|
|
|
view->load(page);
|
|
|
|
}
|
|
|
|
|
|
|
|
void addBookmark() {
|
|
|
|
_url->addItem(_url->currentText());
|
|
|
|
}
|
|
|
|
|
|
|
|
void zoom(int i) {
|
|
|
|
LOG<<100.0*i/10.0;
|
|
|
|
statusBar()->showMessage(tr("Zoom: %1%").arg(100.0*i/10.0));
|
|
|
|
qobject_cast<QWebView*>(_tabs->currentWidget())->setZoomFactor(i/10.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void loadFromHistory() {
|
|
|
|
load(qobject_cast<QAction*>(sender())->data().toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
void on_actionHome_activated() {
|
|
|
|
LOG;
|
|
|
|
load(_home);
|
|
|
|
}
|
|
|
|
|
|
|
|
void on_actionNew_triggered() {
|
|
|
|
LOG;
|
|
|
|
QStringList args(QCoreApplication::arguments());
|
|
|
|
QString prg(args.takeFirst());
|
|
|
|
QProcess::startDetached(prg, args);
|
|
|
|
}
|
|
|
|
|
|
|
|
void on_actionNewTab_triggered() {
|
|
|
|
newTab();
|
|
|
|
}
|
|
|
|
|
|
|
|
void on__tabs_currentChanged(int index) {
|
|
|
|
_url->setEditText(qobject_cast<QWebView*>(_tabs->currentWidget())
|
|
|
|
->url().toString());
|
|
|
|
activateTab();
|
|
|
|
}
|
|
|
|
|
|
|
|
void on__tabs_tabCloseRequested(int index) {
|
|
|
|
_error.erase(_tabs->widget(index));
|
|
|
|
_errorUrl.erase(_tabs->widget(index));
|
|
|
|
_tabs->removeTab(index);
|
|
|
|
_tabs->setTabsClosable(_tabs->count()>1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void on_actionPrintPreview_triggered() {
|
|
|
|
QPrintPreviewDialog preview(&_printer, this);
|
|
|
|
connect(&preview, SIGNAL(paintRequested(QPrinter*)),
|
|
|
|
qobject_cast<QWebView*>(_tabs->currentWidget()),
|
|
|
|
SLOT(print(QPrinter*)));
|
|
|
|
preview.exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
void on_actionInstantPrint_triggered() {
|
|
|
|
qobject_cast<QWebView*>(_tabs->currentWidget())->print(&_printer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void on_actionPrint_triggered() {
|
|
|
|
QPrintDialog dialog(&_printer, this);
|
|
|
|
dialog.setWindowTitle(tr("Print Document"));
|
|
|
|
if (dialog.exec()!=QDialog::Accepted) return;
|
|
|
|
on_actionInstantPrint_triggered();
|
|
|
|
}
|
|
|
|
|
|
|
|
void on_actionClose_triggered() {
|
|
|
|
LOG;
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
|
|
|
void on_actionBack_triggered() {
|
|
|
|
LOG;
|
|
|
|
qobject_cast<QWebView*>(_tabs->currentWidget())->history()->back();
|
|
|
|
}
|
|
|
|
|
|
|
|
void on_actionBack_hovered() {
|
|
|
|
LOG;
|
|
|
|
if (!qobject_cast<QWebView*>(_tabs->currentWidget())->history()
|
|
|
|
->backItem().isValid())
|
|
|
|
return;
|
|
|
|
actionBack->setStatusTip
|
|
|
|
(tr("%1 - %2", "statusbar actionBack_hovered %1=url %2=title")
|
|
|
|
.arg(qobject_cast<QWebView*>(_tabs->currentWidget())->history()
|
|
|
|
->backItem().url().toString())
|
|
|
|
.arg(qobject_cast<QWebView*>(_tabs->currentWidget())->history()
|
|
|
|
->backItem().title()));
|
|
|
|
actionBack->showStatusText(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void on_actionForward_triggered() {
|
|
|
|
LOG;
|
|
|
|
qobject_cast<QWebView*>(_tabs->currentWidget())->history()->forward();
|
|
|
|
}
|
|
|
|
|
|
|
|
void on_actionForward_hovered() {
|
|
|
|
LOG;
|
|
|
|
if (!qobject_cast<QWebView*>(_tabs->currentWidget())->history()
|
|
|
|
->forwardItem().isValid())
|
|
|
|
return;
|
|
|
|
actionForward->setStatusTip
|
|
|
|
(tr("%1 - %2", "statusbar actionForward_hovered %1=url %2=title")
|
|
|
|
.arg(qobject_cast<QWebView*>(_tabs->currentWidget())->history()
|
|
|
|
->forwardItem().url().toString())
|
|
|
|
.arg(qobject_cast<QWebView*>(_tabs->currentWidget())->history()
|
|
|
|
->forwardItem().title()));
|
|
|
|
actionForward->showStatusText(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void on_actionReload_triggered() {
|
|
|
|
LOG;
|
|
|
|
qobject_cast<QWebView*>(_tabs->currentWidget())->reload();
|
|
|
|
}
|
|
|
|
|
|
|
|
void on_actionStop_triggered() {
|
|
|
|
LOG;
|
|
|
|
for (int i(0); i<_tabs->count(); ++i)
|
|
|
|
qobject_cast<QWebView*>(_tabs->widget(i))->stop();
|
|
|
|
_downloadManager.abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
void on_actionFind_triggered() {
|
|
|
|
if (!_find) {
|
|
|
|
statusBar()->addPermanentWidget(_find = new QLineEdit);
|
|
|
|
_find->setText(qobject_cast<QWebView*>(_tabs->currentWidget())
|
|
|
|
->selectedText());
|
|
|
|
}
|
|
|
|
disconnect(_find, SIGNAL(returnPressed()), this, SLOT(rfind()));
|
|
|
|
disconnect(_find, SIGNAL(textEdited(QString)), this, SLOT(rfind()));
|
|
|
|
assert(connect(_find, SIGNAL(returnPressed()), SLOT(find())));
|
|
|
|
assert(connect(_find, SIGNAL(textEdited(QString)), SLOT(find())));
|
|
|
|
_find->setFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void on_actionReverseFind_triggered() {
|
|
|
|
if (!_find) {
|
|
|
|
statusBar()->addPermanentWidget(_find = new QLineEdit);
|
|
|
|
_find->setText(qobject_cast<QWebView*>(_tabs->currentWidget())
|
|
|
|
->selectedText());
|
|
|
|
}
|
|
|
|
disconnect(_find, SIGNAL(returnPressed()), this, SLOT(find()));
|
|
|
|
disconnect(_find, SIGNAL(textEdited(QString)), this, SLOT(find()));
|
|
|
|
assert(connect(_find, SIGNAL(returnPressed()), SLOT(rfind())));
|
|
|
|
assert(connect(_find, SIGNAL(textEdited(QString)), SLOT(rfind())));
|
|
|
|
_find->setFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void find(const QString& txt=QString()) {
|
|
|
|
qobject_cast<QWebView*>(_tabs->currentWidget())->findText
|
|
|
|
(_find->text(),
|
|
|
|
QWebPage::FindWrapsAroundDocument);
|
|
|
|
}
|
|
|
|
|
|
|
|
void rfind(const QString& txt=QString()) {
|
|
|
|
qobject_cast<QWebView*>(_tabs->currentWidget())->findText
|
|
|
|
(_find->text(),
|
|
|
|
QWebPage::FindWrapsAroundDocument
|
|
|
|
|QWebPage::FindBackward);
|
|
|
|
}
|
|
|
|
|
|
|
|
void on_actionUnFind_triggered() {
|
|
|
|
delete _find; _find=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void on_actionAbout_triggered() {
|
|
|
|
QMessageBox::about(this, tr("About"),
|
|
|
|
tr("SwissSurfer %1 (%2)\n\n"
|
|
|
|
"%3\n"
|
|
|
|
"Using: qt-%4\n"
|
|
|
|
"Compiled: qt-%5")
|
|
|
|
.arg(VERSION)
|
|
|
|
.arg(BUILDDATE)
|
|
|
|
.arg(QString::fromStdString(pcsc::version()))
|
|
|
|
.arg(qVersion())
|
|
|
|
.arg(QT_VERSION_STR));
|
|
|
|
}
|
|
|
|
|
|
|
|
void on_actionSettings_triggered() {
|
|
|
|
_settings.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
//@name QWebView slots
|
|
|
|
//@{
|
|
|
|
|
|
|
|
void urlChanged(const QUrl& url) {
|
|
|
|
LOG<<url.toString();
|
|
|
|
if (sender()!=_tabs->currentWidget()) return;
|
|
|
|
LOG<<"signal on current tab";
|
|
|
|
if (_url) _url->setEditText(url.toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
void linkClicked(const QUrl& url) {
|
|
|
|
LOG<<url.toString();
|
|
|
|
load(url, qobject_cast<QWebView*>(sender()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void iconChanged() {
|
|
|
|
LOG;
|
|
|
|
QWebView* view(qobject_cast<QWebView*>(sender()));
|
|
|
|
int index = _tabs->indexOf(view);
|
|
|
|
if (index<0) return;
|
|
|
|
QIcon icon(QWebSettings::iconForUrl(view->url()));
|
|
|
|
if (icon.isNull()) {
|
|
|
|
LOG<<"Icon for URL is Null"<<view->url();
|
|
|
|
QPixmap pixmap(QWebSettings::webGraphic
|
|
|
|
(QWebSettings::DefaultFrameIconGraphic));
|
|
|
|
if (!pixmap.isNull()) icon = pixmap;
|
|
|
|
} else icon = icon.pixmap(16, 16);
|
|
|
|
if (icon.isNull()) LOG<<"Icon is still null";
|
|
|
|
_tabs->setTabIcon(index, icon);
|
|
|
|
}
|
|
|
|
|
|
|
|
void titleChanged(const QString& text) {
|
|
|
|
LOG<<text;
|
|
|
|
_tabs->setTabText(_tabs->indexOf(qobject_cast<QWidget*>(sender())),
|
|
|
|
trUtf8("%1").arg(text));
|
|
|
|
}
|
|
|
|
|
|
|
|
void statusBarMessage(const QString& text) {
|
|
|
|
LOG<<text;
|
|
|
|
if (text.size()) statusBar()->showMessage(tr("Info: %1").arg(text));
|
|
|
|
}
|
|
|
|
|
|
|
|
void loadProgress(int i) {
|
|
|
|
LOG<<i;
|
|
|
|
}
|
|
|
|
|
|
|
|
void loadStarted() {
|
|
|
|
LOG;
|
|
|
|
}
|
|
|
|
|
|
|
|
void loadFinished(bool ok) {
|
|
|
|
LOG<<(ok?"success":"error");
|
|
|
|
statusBar()->showMessage(ok?tr("done."):tr("page load error."));
|
|
|
|
activateTab();
|
|
|
|
}
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
//@name QWebPage WebAction slots
|
|
|
|
//@{
|
|
|
|
|
|
|
|
void triggeredOpenLink(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredOpenLinkInNewWindow(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredOpenFrameInNewWindow(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredDownloadLinkToDisk(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredCopyLinkToClipboard(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredOpenImageInNewWindow(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredDownloadImageToDisk(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredCopyImageToClipboard(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredBack(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredForward(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredStop(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredReload(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredCut(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredCopy(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredPaste(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredUndo(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredRedo(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredMoveToNextChar(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredMoveToPreviousChar(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredMoveToNextWord(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredMoveToPreviousWord(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredMoveToNextLine(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredMoveToPreviousLine(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredMoveToStartOfLine(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredMoveToEndOfLine(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredMoveToStartOfBlock(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredMoveToEndOfBlock(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredMoveToStartOfDocument(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredMoveToEndOfDocument(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredSelectNextChar(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredSelectPreviousChar(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredSelectNextWord(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredSelectPreviousWord(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredSelectNextLine(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredSelectPreviousLine(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredSelectStartOfLine(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredSelectEndOfLine(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredSelectStartOfBlock(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredSelectEndOfBlock(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredSelectStartOfDocument(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredSelectEndOfDocument(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredDeleteStartOfWord(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredDeleteEndOfWord(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredSetTextDirectionDefault(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredSetTextDirectionLeftToRight(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredSetTextDirectionRightToLeft(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredToggleBold(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredToggleItalic(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredToggleUnderline(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredInspectElement(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredInsertParagraphSeparator(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredInsertLineSeparator(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void triggeredSelectAll(bool) {
|
|
|
|
LOG<<qobject_cast<QAction*>(sender())->data().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
//@name QWebPage slots
|
|
|
|
//@{
|
|
|
|
|
|
|
|
void contentsChanged() {
|
|
|
|
LOG;
|
|
|
|
}
|
|
|
|
|
|
|
|
void databaseQuotaExceeded(QWebFrame* frame, QString databaseName) {
|
|
|
|
LOG<<databaseName;
|
|
|
|
}
|
|
|
|
|
|
|
|
void downloadRequested(const QNetworkRequest& request) {
|
|
|
|
LOG;
|
|
|
|
}
|
|
|
|
|
|
|
|
void frameCreated(QWebFrame* frame) {
|
|
|
|
LOG;
|
|
|
|
}
|
|
|
|
|
|
|
|
void geometryChangeRequested(const QRect& geom) {
|
|
|
|
LOG;
|
|
|
|
}
|
|
|
|
|
|
|
|
// void linkClicked(const QUrl& url) {
|
|
|
|
// LOG<<url.toString();
|
|
|
|
// }
|
|
|
|
|
|
|
|
void linkHovered(const QString& link, const QString& title,
|
|
|
|
const QString& textContent) {
|
|
|
|
LOG<<link<<title<<textContent;
|
|
|
|
statusBar()->showMessage(tr("%1", "statusbar for hovered link %1=url")
|
|
|
|
.arg(link));
|
|
|
|
}
|
|
|
|
|
|
|
|
// void loadFinished(bool ok) {
|
|
|
|
// LOG<<(ok?"succeess":"error");
|
|
|
|
// }
|
|
|
|
|
|
|
|
// void loadProgress(int progress) {
|
|
|
|
// LOG<<progress;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// void loadStarted() {
|
|
|
|
// LOG;
|
|
|
|
// }
|
|
|
|
|
|
|
|
void menuBarVisibilityChangeRequested(bool visible) {
|
|
|
|
LOG;
|
|
|
|
}
|
|
|
|
|
|
|
|
void microFocusChanged() {
|
|
|
|
LOG;
|
|
|
|
}
|
|
|
|
|
|
|
|
void printRequested(QWebFrame* frame) {
|
|
|
|
LOG;
|
|
|
|
}
|
|
|
|
|
|
|
|
void repaintRequested(const QRect& dirtyRect) {
|
|
|
|
//LOG;
|
|
|
|
}
|
|
|
|
|
|
|
|
void restoreFrameStateRequested(QWebFrame* frame) {
|
|
|
|
LOG;
|
|
|
|
}
|
|
|
|
|
|
|
|
void saveFrameStateRequested(QWebFrame* frame, QWebHistoryItem* item) {
|
|
|
|
LOG;
|
|
|
|
}
|
|
|
|
|
|
|
|
void scrollRequested(int dx, int dy, const QRect& rectToScroll) {
|
|
|
|
LOG;
|
|
|
|
}
|
|
|
|
|
|
|
|
void selectionChanged() {
|
|
|
|
LOG;
|
|
|
|
}
|
|
|
|
|
|
|
|
// void statusBarMessage(const QString& text) {
|
|
|
|
// LOG;
|
|
|
|
// }
|
|
|
|
|
|
|
|
void statusBarVisibilityChangeRequested(bool visible) {
|
|
|
|
LOG;
|
|
|
|
}
|
|
|
|
|
|
|
|
void toolBarVisibilityChangeRequested(bool visible) {
|
|
|
|
LOG;
|
|
|
|
}
|
|
|
|
|
|
|
|
//@name handle downloads
|
|
|
|
//@{
|
|
|
|
|
|
|
|
void unsupportedContent(QNetworkReply* reply) {
|
|
|
|
LOG<<reply->header(QNetworkRequest::ContentTypeHeader).toString();
|
|
|
|
LOG<<"Status:"<<_downloadManager.networkError(reply->error());
|
|
|
|
if (reply->isFinished())
|
|
|
|
handleContent(reply);
|
|
|
|
else
|
|
|
|
assert(connect(reply, SIGNAL(finished()), SLOT(downloadFinished())));
|
|
|
|
}
|
|
|
|
|
|
|
|
void downloadFinished() {
|
|
|
|
LOG;
|
|
|
|
QNetworkReply *reply(qobject_cast<QNetworkReply*>(sender()));
|
|
|
|
handleContent(reply);
|
|
|
|
}
|
|
|
|
|
|
|
|
void handleContent(QNetworkReply* reply) {
|
|
|
|
LOG<<"Location:"<<reply->header(QNetworkRequest::LocationHeader)
|
|
|
|
.toString();
|
|
|
|
LOG<<"Content-Type:"<<reply->header(QNetworkRequest::ContentTypeHeader)
|
|
|
|
.toString();
|
|
|
|
LOG<<"Status:"<<_downloadManager.networkError(reply->error());
|
|
|
|
LOG<<"URL:"<<reply->url().toString();
|
|
|
|
LOG<<"File:"<<reply->url().toLocalFile();
|
|
|
|
LOG<<"Path:"<<reply->url().path();
|
|
|
|
Settings::MimeTypes::const_iterator it
|
|
|
|
(_settings.mimetypes().find
|
|
|
|
(reply->header(QNetworkRequest::ContentTypeHeader).toString()
|
|
|
|
.split(';')[0]));
|
|
|
|
if (it!=_settings.mimetypes().end()) {
|
|
|
|
QTemporaryFile *file =
|
|
|
|
new QTemporaryFile(QDir::tempPath()+QDir::separator()
|
|
|
|
+"swisssurferXXXXXX."
|
|
|
|
+it.value().toStringList().at(0), this);
|
|
|
|
file->open();
|
|
|
|
file->write(reply->readAll());
|
|
|
|
file->close();
|
|
|
|
QProcess* process(new QProcess);
|
|
|
|
_downloadProcesses[process] = file;
|
|
|
|
assert(connect(process, SIGNAL(finished(int, QProcess::ExitStatus)),
|
|
|
|
SLOT(processFinished())));
|
|
|
|
QStringList args(it.value().toStringList().at(1).split(" ")
|
|
|
|
.replaceInStrings("%1", file->fileName()));
|
|
|
|
QString prg(args.takeFirst());
|
|
|
|
LOG<<"Running:"<<prg<<args.join(" ");
|
|
|
|
process->start(prg, args);
|
|
|
|
} else {
|
|
|
|
QString saveFile
|
|
|
|
(QFileDialog::getSaveFileName(this, tr("Save File As ..."),
|
|
|
|
!reply->url().toLocalFile().isEmpty()
|
|
|
|
?reply->url().toLocalFile()
|
|
|
|
:reply->url().path()));
|
|
|
|
if (!saveFile.isEmpty()) {
|
|
|
|
QFile file(saveFile);
|
|
|
|
file.open(QIODevice::WriteOnly);
|
|
|
|
file.write(reply->readAll());
|
|
|
|
file.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void processFinished() {
|
|
|
|
LOG;
|
|
|
|
delete _downloadProcesses[qobject_cast<QProcess*>(sender())];
|
|
|
|
_downloadProcesses.erase(qobject_cast<QProcess*>(sender()));
|
|
|
|
}
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
void windowCloseRequested() {
|
|
|
|
LOG;
|
|
|
|
}
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
//@name DownloadManager signals
|
|
|
|
//@{
|
|
|
|
|
|
|
|
void progress(qint64 done, qint64 total) {
|
|
|
|
_progress->setMaximum(total);
|
|
|
|
_progress->setValue(done);
|
|
|
|
}
|
|
|
|
|
|
|
|
void started() {
|
|
|
|
actionStop->setEnabled(true);
|
|
|
|
_progress->setRange(0, 0);
|
|
|
|
_progress->setValue(0);
|
|
|
|
_progress->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
void finished() {
|
|
|
|
LOG;
|
|
|
|
actionStop->setEnabled(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
//@name QNetworkAccessManager signals
|
|
|
|
//@{
|
|
|
|
|
|
|
|
void authenticationRequired(QNetworkReply* reply,
|
|
|
|
QAuthenticator* authenticator) {
|
|
|
|
LOG<<reply->url().toString()<<authenticator->realm();
|
|
|
|
statusBar()->showMessage(tr("authentication required"));
|
|
|
|
Authentication auth(authenticator, this);
|
|
|
|
if (auth.exec()==QDialog::Rejected) reply->abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
void proxyAuthenticationRequired(const QNetworkProxy& proxy,
|
|
|
|
QAuthenticator* authenticator) {
|
|
|
|
LOG;
|
|
|
|
}
|
|
|
|
|
|
|
|
void sslErrors(QNetworkReply* reply, const QList<QSslError>& errors) {
|
|
|
|
LOG;
|
|
|
|
statusBar()->showMessage(tr("ssl error"));
|
|
|
|
// QString e;
|
|
|
|
for (QList<QSslError>::const_iterator err(errors.begin());
|
|
|
|
err!=errors.end(); ++err) {
|
|
|
|
LOG<<"SSL-Error: "<<err->errorString();
|
|
|
|
LOG<<"Certificate Issuer: "
|
|
|
|
<<"O="<<err->certificate().issuerInfo(QSslCertificate::Organization)
|
|
|
|
<<"CN="<<err->certificate().issuerInfo(QSslCertificate::CommonName)
|
|
|
|
<<"L="<<err->certificate().issuerInfo(QSslCertificate::LocalityName)
|
|
|
|
<<"OU="<<err->certificate().issuerInfo(QSslCertificate::OrganizationalUnitName)
|
|
|
|
<<"C="<<err->certificate().issuerInfo(QSslCertificate::CountryName)
|
|
|
|
<<"ST="<<err->certificate().issuerInfo(QSslCertificate::StateOrProvinceName);
|
|
|
|
LOG<<"Certificate Subject: "
|
|
|
|
<<"O="<<err->certificate().subjectInfo(QSslCertificate::Organization)
|
|
|
|
<<"CN="<<err->certificate().subjectInfo(QSslCertificate::CommonName)
|
|
|
|
<<"L="<<err->certificate().subjectInfo(QSslCertificate::LocalityName)
|
|
|
|
<<"OU="<<err->certificate().subjectInfo(QSslCertificate::OrganizationalUnitName)
|
|
|
|
<<"C="<<err->certificate().subjectInfo(QSslCertificate::CountryName)
|
|
|
|
<<"ST="<<err->certificate().subjectInfo(QSslCertificate::StateOrProvinceName);
|
|
|
|
}
|
|
|
|
// e+=tr("<li>%1</li>", "single ssl error").arg(err->errorString());
|
|
|
|
// _error[sender()] += tr("<h2>%1</h2><p>URL: %4</p><p>%2</p>"
|
|
|
|
// "<h3>SSL Errors</h3>"
|
|
|
|
// "<p><ul>%3</ul></p>")
|
|
|
|
// .arg(tr("SSL Error"))
|
|
|
|
// .arg(_downloadManager.networkError(reply->error()))
|
|
|
|
// .arg(e)
|
|
|
|
// .arg(reply->url().toString());
|
|
|
|
// _errorUrl[sender()] = reply->url();
|
|
|
|
}
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void saveWin() {
|
|
|
|
LOG<<"Save Window State";
|
|
|
|
QStringList urls;
|
|
|
|
for (int i(0); i<_url->count(); ++i)
|
|
|
|
urls<<_url->itemText(i);
|
|
|
|
_settings()->setValue("Window/Urls", urls);
|
|
|
|
QStringList tabs;
|
|
|
|
for (int i(0); i<_tabs->count(); ++i)
|
|
|
|
tabs<<qobject_cast<QWebView*>(_tabs->widget(i))->url().toString();
|
|
|
|
_settings()->setValue("Window/Tabs", tabs);
|
|
|
|
_settings()->setValue("Window/CurrentTab", _tabs->currentIndex());
|
|
|
|
_settings()->setValue("Window/Geometry", saveGeometry());
|
|
|
|
_settings()->setValue("Window/WindowState", saveState());
|
|
|
|
}
|
|
|
|
|
|
|
|
void loadWin(bool noRrestoreTabs=true) {
|
|
|
|
QStringList urls(_settings()->value("Window/Urls").toStringList());
|
|
|
|
urls.sort();
|
|
|
|
urls.removeDuplicates();
|
|
|
|
_url->addItems(urls);
|
|
|
|
QStringList tabs(_settings()->value("Window/Tabs").toStringList());
|
|
|
|
if (!noRrestoreTabs)
|
|
|
|
for (QStringList::iterator it(tabs.begin()); it!=tabs.end(); ++it)
|
|
|
|
load(*it, newTab());
|
|
|
|
if (_tabs->count()>1) _tabs->removeTab(0);
|
|
|
|
_tabs->setTabsClosable(_tabs->count()>1);
|
|
|
|
_tabs->setCurrentIndex(_settings()->value("Window/CurrentTab").toInt());
|
|
|
|
restoreGeometry(_settings()->value("Window/Geometry").toByteArray());
|
|
|
|
restoreState(_settings()->value("Window/WindowState").toByteArray());
|
|
|
|
}
|
|
|
|
|
|
|
|
void activateTab() {
|
|
|
|
iconChanged();
|
|
|
|
QWebHistory* history(dynamic_cast<QWebView*>(_tabs->currentWidget())
|
|
|
|
->history());
|
|
|
|
actionForward->setEnabled(history->canGoForward());
|
|
|
|
actionBack->setEnabled(history->canGoBack());
|
|
|
|
_history->clear();
|
|
|
|
QList<QWebHistoryItem> items(history->items());
|
|
|
|
for (int i = 0; i < items.size(); ++i) {
|
|
|
|
QAction* a(_history->addAction(items[i].title()));
|
|
|
|
a->setData(items[i].url());
|
|
|
|
connect(a, SIGNAL(triggered(bool)), SLOT(loadFromHistory()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
QComboBox* _url;
|
|
|
|
QPushButton* _clearUrl;
|
|
|
|
QPushButton* _addBookmark;
|
|
|
|
QLineEdit* _find;
|
|
|
|
QSlider* _zoom;
|
|
|
|
QProgressBar* _progress;
|
|
|
|
QString _home;
|
|
|
|
bool _kiosk;
|
|
|
|
std::map<QObject*, QString> _error;
|
|
|
|
std::map<QObject*, QUrl> _errorUrl;
|
|
|
|
QPrinter _printer;
|
|
|
|
SslClientAuthNetworkAccessManager _networkManager;
|
|
|
|
DownloadManager _downloadManager;
|
|
|
|
typedef std::map<QProcess*, QTemporaryFile*> DownloadProcesses;
|
|
|
|
DownloadProcesses _downloadProcesses;
|
|
|
|
Settings _settings;
|
|
|
|
SmartCardAuth _scAuth;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|