|
|
|
@ -32,6 +32,8 @@ |
|
|
|
|
|
|
|
|
|
#include <smartcardauth.hxx> |
|
|
|
|
#include <downloadmanager.hxx> |
|
|
|
|
#include <authentication.hxx> |
|
|
|
|
#include <webpage.hxx> |
|
|
|
|
#include <settings.hxx> |
|
|
|
|
#include <sslclientnetworkmanager.hxx> |
|
|
|
|
|
|
|
|
@ -201,751 +203,9 @@ class Browser: public QMainWindow, protected Ui::Browser { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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 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::aboutQt(this); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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"); |
|
|
|
|
if (ok) statusBar()->showMessage(tr("done.")); |
|
|
|
|
activateTab(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
//@name QWebPage WebAction slots
|
|
|
|
|
//@{
|
|
|
|
|
|
|
|
|
|
void triggeredOpenLink(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredOpenLinkInNewWindow(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredOpenFrameInNewWindow(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredDownloadLinkToDisk(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredCopyLinkToClipboard(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredOpenImageInNewWindow(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredDownloadImageToDisk(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredCopyImageToClipboard(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredBack(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredForward(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredStop(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredReload(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredCut(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredCopy(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredPaste(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredUndo(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredRedo(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredMoveToNextChar(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredMoveToPreviousChar(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredMoveToNextWord(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredMoveToPreviousWord(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredMoveToNextLine(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredMoveToPreviousLine(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredMoveToStartOfLine(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredMoveToEndOfLine(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredMoveToStartOfBlock(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredMoveToEndOfBlock(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredMoveToStartOfDocument(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredMoveToEndOfDocument(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredSelectNextChar(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredSelectPreviousChar(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredSelectNextWord(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredSelectPreviousWord(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredSelectNextLine(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredSelectPreviousLine(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredSelectStartOfLine(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredSelectEndOfLine(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredSelectStartOfBlock(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredSelectEndOfBlock(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredSelectStartOfDocument(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredSelectEndOfDocument(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredDeleteStartOfWord(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredDeleteEndOfWord(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredSetTextDirectionDefault(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredSetTextDirectionLeftToRight(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredSetTextDirectionRightToLeft(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredToggleBold(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredToggleItalic(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredToggleUnderline(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredInspectElement(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredInsertParagraphSeparator(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredInsertLineSeparator(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void triggeredSelectAll(bool) { |
|
|
|
|
LOG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
//@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:"<<networkError(reply->error()); |
|
|
|
|
assert(connect(reply, SIGNAL(finished()), SLOT(downloadFinished()))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void downloadFinished() { |
|
|
|
|
QNetworkReply *reply(qobject_cast<QNetworkReply*>(sender())); |
|
|
|
|
LOG<<"Location:"<<reply->header(QNetworkRequest::LocationHeader) |
|
|
|
|
.toString(); |
|
|
|
|
LOG<<"Content-Type:"<<reply->header(QNetworkRequest::ContentTypeHeader) |
|
|
|
|
.toString(); |
|
|
|
|
LOG<<"Status:"<<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())); |
|
|
|
|
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() { |
|
|
|
|
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); |
|
|
|
|
_progress->hide(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
//@name QNetworkAccessManager signals
|
|
|
|
|
//@{
|
|
|
|
|
|
|
|
|
|
void authenticationRequired(QNetworkReply* reply, |
|
|
|
|
QAuthenticator* authenticator) { |
|
|
|
|
LOG; |
|
|
|
|
statusBar()->showMessage(tr("authentication required")); |
|
|
|
|
// _error[sender()] += tr("<h2>%1</h2><p>URL: %3</p><p>%2</p>")
|
|
|
|
|
// .arg(tr("Authentication Required"))
|
|
|
|
|
// .arg(networkError(reply->error()))
|
|
|
|
|
// .arg(reply->url().toString());
|
|
|
|
|
// _errorUrl[sender()] = reply->url();
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
// 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(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(); |
|
|
|
|
actionForward->setEnabled(dynamic_cast<QWebView*>(_tabs->currentWidget()) |
|
|
|
|
->history()->canGoForward()); |
|
|
|
|
actionBack->setEnabled(dynamic_cast<QWebView*>(_tabs->currentWidget()) |
|
|
|
|
->history()->canGoBack()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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); |
|
|
|
@ -1205,7 +465,747 @@ class Browser: public QMainWindow, protected Ui::Browser { |
|
|
|
|
SLOT(sslErrors(QNetworkReply*, const QList<QSslError>&)))); |
|
|
|
|
_tabs->setCurrentIndex(_tabs->addTab(browser, "*empty*")); |
|
|
|
|
_tabs->setTabsClosable(_tabs->count()>1); |
|
|
|
|
return browser; |
|
|
|
|
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 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::aboutQt(this); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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"); |
|
|
|
|
if (ok) statusBar()->showMessage(tr("done.")); |
|
|
|
|
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:"<<networkError(reply->error()); |
|
|
|
|
assert(connect(reply, SIGNAL(finished()), SLOT(downloadFinished()))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void downloadFinished() { |
|
|
|
|
QNetworkReply *reply(qobject_cast<QNetworkReply*>(sender())); |
|
|
|
|
LOG<<"Location:"<<reply->header(QNetworkRequest::LocationHeader) |
|
|
|
|
.toString(); |
|
|
|
|
LOG<<"Content-Type:"<<reply->header(QNetworkRequest::ContentTypeHeader) |
|
|
|
|
.toString(); |
|
|
|
|
LOG<<"Status:"<<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())); |
|
|
|
|
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() { |
|
|
|
|
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); |
|
|
|
|
_progress->hide(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
//@name QNetworkAccessManager signals
|
|
|
|
|
//@{
|
|
|
|
|
|
|
|
|
|
void authenticationRequired(QNetworkReply* reply, |
|
|
|
|
QAuthenticator* authenticator) { |
|
|
|
|
LOG; |
|
|
|
|
statusBar()->showMessage(tr("authentication required")); |
|
|
|
|
Authentication auth(authenticator, this); |
|
|
|
|
auth.exec(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
// 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(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(); |
|
|
|
|
actionForward->setEnabled(dynamic_cast<QWebView*>(_tabs->currentWidget()) |
|
|
|
|
->history()->canGoForward()); |
|
|
|
|
actionBack->setEnabled(dynamic_cast<QWebView*>(_tabs->currentWidget()) |
|
|
|
|
->history()->canGoBack()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|