mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-19 18:26:34 +01:00
Improved PopupWindow + added correspoding tests.
Added menu to popup windows. It is now also possible to search on page in popup window (Ctrl+F).
This commit is contained in:
parent
88c2c25490
commit
b7cc728d63
15
TODO
15
TODO
@ -1,15 +0,0 @@
|
||||
TODO List
|
||||
----------------------------------------------------------------------------------
|
||||
|
||||
There are some features, which I plan to implement in future.
|
||||
The list is not sorted by priority.
|
||||
|
||||
* Export Bookmarks (html, ...)
|
||||
* FTP Protocol support
|
||||
* Zoom Widget in statusbar
|
||||
* Password Manager: save more than one account for site + input completer
|
||||
* (KDE) Nepomuk integration
|
||||
* Support for remote Web inspector
|
||||
* Session manager
|
||||
* Editable toolbar
|
||||
* NoScript plugin
|
@ -985,7 +985,7 @@ void QupZilla::aboutToShowViewMenu()
|
||||
m_actionShowStatusbar->setChecked(statusBar()->isVisible());
|
||||
m_actionShowBookmarksToolbar->setChecked(m_bookmarksToolbar->isVisible());
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
#if QTWEBKIT_FROM_2_3
|
||||
m_actionCaretBrowsing->setChecked(mApp->webSettings()->testAttribute(QWebSettings::CaretBrowsingEnabled));
|
||||
#endif
|
||||
}
|
||||
@ -1421,6 +1421,11 @@ void QupZilla::currentTabChanged()
|
||||
m_ipLabel->setText(view->getIp());
|
||||
view->setFocus();
|
||||
|
||||
SearchToolBar* search = searchToolBar();
|
||||
if (search) {
|
||||
search->setWebView(view);
|
||||
}
|
||||
|
||||
updateLoadingActions();
|
||||
|
||||
// Setting correct tab order (LocationBar -> WebSearchBar -> WebView)
|
||||
@ -1483,19 +1488,14 @@ void QupZilla::webSearch()
|
||||
|
||||
void QupZilla::searchOnPage()
|
||||
{
|
||||
if (m_mainLayout->count() == 4) {
|
||||
SearchToolBar* search = qobject_cast<SearchToolBar*>(m_mainLayout->itemAt(3)->widget());
|
||||
if (!search) {
|
||||
return;
|
||||
}
|
||||
SearchToolBar* toolBar = searchToolBar();
|
||||
|
||||
search->focusSearchLine();
|
||||
return;
|
||||
if (!toolBar) {
|
||||
toolBar = new SearchToolBar(weView(), this);
|
||||
m_mainLayout->insertWidget(3, toolBar);
|
||||
}
|
||||
|
||||
SearchToolBar* search = new SearchToolBar(this);
|
||||
m_mainLayout->insertWidget(3, search);
|
||||
search->focusSearchLine();
|
||||
toolBar->focusSearchLine();
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
if (QtWin::isCompositionEnabled()) {
|
||||
@ -1857,6 +1857,17 @@ void QupZilla::closeEvent(QCloseEvent* event)
|
||||
event->accept();
|
||||
}
|
||||
|
||||
SearchToolBar* QupZilla::searchToolBar()
|
||||
{
|
||||
SearchToolBar* toolBar = 0;
|
||||
|
||||
if (m_mainLayout->count() == 4) {
|
||||
toolBar = qobject_cast<SearchToolBar*>(m_mainLayout->itemAt(3)->widget());
|
||||
}
|
||||
|
||||
return toolBar;
|
||||
}
|
||||
|
||||
void QupZilla::disconnectObjects()
|
||||
{
|
||||
// Disconnecting all important widgets before deleting this window
|
||||
|
@ -202,6 +202,8 @@ private:
|
||||
void keyReleaseEvent(QKeyEvent* event);
|
||||
void closeEvent(QCloseEvent* event);
|
||||
|
||||
SearchToolBar* searchToolBar();
|
||||
|
||||
void setupUi();
|
||||
void setupMenu();
|
||||
|
||||
|
@ -56,20 +56,11 @@ PopupWebPage::PopupWebPage(QWebPage::WebWindowType type, QupZilla* mainClass)
|
||||
|
||||
void PopupWebPage::slotGeometryChangeRequested(const QRect &rect)
|
||||
{
|
||||
/* Very ugly hack for QtWebKit 2.3
|
||||
* It now sends QRect(0, y, 100x100) if the popup window
|
||||
* geometry was not set in window.open call.
|
||||
*/
|
||||
|
||||
if (rect.isValid()
|
||||
//#if QTWEBKIT_FROM_2_3
|
||||
#if 0
|
||||
&& rect.size() != QSize(100, 100)
|
||||
#endif
|
||||
) {
|
||||
m_geometry = rect;
|
||||
if (rect.isValid()) {
|
||||
m_createNewWindow = true;
|
||||
}
|
||||
|
||||
m_geometry = rect;
|
||||
}
|
||||
|
||||
void PopupWebPage::slotMenuBarVisibilityChangeRequested(bool visible)
|
||||
@ -108,11 +99,19 @@ void PopupWebPage::slotLoadFinished(bool state)
|
||||
|
||||
void PopupWebPage::checkBehaviour()
|
||||
{
|
||||
// If menubar/statusbar/toolbar visibility is explicitly set in window.open call,
|
||||
// at least one of those variables will be false.
|
||||
// If so, we should open new window.
|
||||
|
||||
if (!m_createNewWindow && (!m_menuBarVisible || !m_statusBarVisible || !m_toolBarVisible)) {
|
||||
m_createNewWindow = true;
|
||||
}
|
||||
|
||||
if (m_createNewWindow) {
|
||||
PopupWebView* view = new PopupWebView;
|
||||
view->setWebPage(this);
|
||||
|
||||
PopupWindow* popup = new PopupWindow(view, p_QupZilla);
|
||||
PopupWindow* popup = new PopupWindow(view);
|
||||
popup->setWindowGeometry(m_geometry);
|
||||
popup->setMenuBarVisibility(m_menuBarVisible);
|
||||
popup->setStatusBarVisibility(m_statusBarVisible);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
||||
* Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,21 +20,24 @@
|
||||
#include "popupwebpage.h"
|
||||
#include "popupstatusbarmessage.h"
|
||||
#include "progressbar.h"
|
||||
#include "qupzilla.h"
|
||||
#include "pagescreen.h"
|
||||
#include "searchtoolbar.h"
|
||||
#include "qzsettings.h"
|
||||
#include "popuplocationbar.h"
|
||||
#include "qztools.h"
|
||||
#include "iconprovider.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QStatusBar>
|
||||
#include <QWebFrame>
|
||||
#include <QCloseEvent>
|
||||
#include <QMenuBar>
|
||||
|
||||
PopupWindow::PopupWindow(PopupWebView* view, QupZilla* mainClass)
|
||||
PopupWindow::PopupWindow(PopupWebView* view)
|
||||
: QWidget()
|
||||
, p_QupZilla(mainClass)
|
||||
, m_view(view)
|
||||
, m_page(qobject_cast<PopupWebPage*>(view->page()))
|
||||
, m_search(0)
|
||||
{
|
||||
m_layout = new QVBoxLayout(this);
|
||||
m_layout->setContentsMargins(0, 0, 0, 0);
|
||||
@ -45,14 +48,61 @@ PopupWindow::PopupWindow(PopupWebView* view, QupZilla* mainClass)
|
||||
|
||||
m_statusBar = new QStatusBar(this);
|
||||
m_statusBar->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
|
||||
m_statusBar->setVisible(p_QupZilla->statusBar()->isVisible());
|
||||
|
||||
m_progressBar = new ProgressBar(m_statusBar);
|
||||
m_statusBar->addPermanentWidget(m_progressBar);
|
||||
m_progressBar->hide();
|
||||
|
||||
m_view->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
m_statusBarMessage = new PopupStatusBarMessage(this);
|
||||
|
||||
m_menuBar = new QMenuBar(this);
|
||||
|
||||
QMenu* menuFile = new QMenu(tr("File"));
|
||||
menuFile->addAction(QIcon::fromTheme("document-save"), tr("&Save Page As..."), m_view, SLOT(savePageAs()))->setShortcut(QKeySequence("Ctrl+S"));
|
||||
menuFile->addAction(tr("Save Page Screen"), this, SLOT(savePageScreen()));
|
||||
menuFile->addAction(QIcon::fromTheme("mail-message-new"), tr("Send Link..."), m_view, SLOT(sendPageByMail()));
|
||||
menuFile->addAction(QIcon::fromTheme("document-print"), tr("&Print..."), m_view, SLOT(printPage()))->setShortcut(QKeySequence("Ctrl+P"));
|
||||
menuFile->addSeparator();
|
||||
menuFile->addAction(QIcon::fromTheme("window-close"), tr("Close"), this, SLOT(close()))->setShortcut(QKeySequence("Ctrl+W"));
|
||||
m_menuBar->addMenu(menuFile);
|
||||
|
||||
m_menuEdit = new QMenu(tr("Edit"));
|
||||
m_menuEdit->addAction(QIcon::fromTheme("edit-undo"), tr("&Undo"), this, SLOT(editUndo()))->setShortcut(QKeySequence("Ctrl+Z"));
|
||||
m_menuEdit->addAction(QIcon::fromTheme("edit-redo"), tr("&Redo"), this, SLOT(editRedo()))->setShortcut(QKeySequence("Ctrl+Shift+Z"));
|
||||
m_menuEdit->addSeparator();
|
||||
m_menuEdit->addAction(QIcon::fromTheme("edit-cut"), tr("&Cut"), this, SLOT(editCut()))->setShortcut(QKeySequence("Ctrl+X"));
|
||||
m_menuEdit->addAction(QIcon::fromTheme("edit-copy"), tr("C&opy"), this, SLOT(editCopy()))->setShortcut(QKeySequence("Ctrl+C"));
|
||||
m_menuEdit->addAction(QIcon::fromTheme("edit-paste"), tr("&Paste"), this, SLOT(editPaste()))->setShortcut(QKeySequence("Ctrl+V"));
|
||||
m_menuEdit->addSeparator();
|
||||
m_menuEdit->addAction(QIcon::fromTheme("edit-select-all"), tr("Select All"), m_view, SLOT(selectAll()))->setShortcut(QKeySequence("Ctrl+A"));
|
||||
m_menuEdit->addAction(QIcon::fromTheme("edit-find"), tr("Find"), this, SLOT(searchOnPage()))->setShortcut(QKeySequence("Ctrl+F"));
|
||||
connect(m_menuEdit, SIGNAL(aboutToShow()), this, SLOT(aboutToShowEditMenu()));
|
||||
m_menuBar->addMenu(m_menuEdit);
|
||||
|
||||
m_menuView = new QMenu(tr("View"));
|
||||
m_actionStop = m_menuView->addAction(qIconProvider->standardIcon(QStyle::SP_BrowserStop), tr("&Stop"), m_view, SLOT(stop()));
|
||||
m_actionStop->setShortcut(QKeySequence("Esc"));
|
||||
m_actionReload = m_menuView->addAction(qIconProvider->standardIcon(QStyle::SP_BrowserReload), tr("&Reload"), m_view, SLOT(reload()));
|
||||
m_actionReload->setShortcut(QKeySequence("F5"));
|
||||
m_menuView->addSeparator();
|
||||
m_menuView->addAction(QIcon::fromTheme("zoom-in"), tr("Zoom &In"), m_view, SLOT(zoomIn()))->setShortcut(QKeySequence("Ctrl++"));
|
||||
m_menuView->addAction(QIcon::fromTheme("zoom-out"), tr("Zoom &Out"), m_view, SLOT(zoomOut()))->setShortcut(QKeySequence("Ctrl+-"));
|
||||
m_menuView->addAction(QIcon::fromTheme("zoom-original"), tr("Reset"), m_view, SLOT(zoomReset()))->setShortcut(QKeySequence("Ctrl+0"));
|
||||
m_menuView->addSeparator();
|
||||
m_menuView->addAction(QIcon::fromTheme("text-html"), tr("&Page Source"), m_view, SLOT(showSource()))->setShortcut(QKeySequence("Ctrl+U"));
|
||||
m_menuBar->addMenu(m_menuView);
|
||||
|
||||
// Make shortcuts available even with hidden menubar
|
||||
QList<QAction*> actions = m_menuBar->actions();
|
||||
foreach(QAction * action, actions) {
|
||||
if (action->menu()) {
|
||||
actions += action->menu()->actions();
|
||||
}
|
||||
addAction(action);
|
||||
}
|
||||
|
||||
m_layout->insertWidget(0, m_menuBar);
|
||||
m_layout->addWidget(m_locationBar);
|
||||
m_layout->addWidget(m_view);
|
||||
m_layout->addWidget(m_statusBar);
|
||||
@ -125,6 +175,11 @@ void PopupWindow::loadStarted()
|
||||
m_progressBar->show();
|
||||
|
||||
m_locationBar->startLoading();
|
||||
|
||||
if (m_actionStop) {
|
||||
m_actionStop->setEnabled(true);
|
||||
m_actionReload->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void PopupWindow::loadProgress(int value)
|
||||
@ -138,6 +193,11 @@ void PopupWindow::loadFinished()
|
||||
m_progressBar->hide();
|
||||
|
||||
m_locationBar->stopLoading();
|
||||
|
||||
if (m_actionStop) {
|
||||
m_actionStop->setEnabled(false);
|
||||
m_actionReload->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void PopupWindow::closeEvent(QCloseEvent* event)
|
||||
@ -153,17 +213,80 @@ void PopupWindow::closeEvent(QCloseEvent* event)
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void PopupWindow::editSelectAll()
|
||||
{
|
||||
m_view->selectAll();
|
||||
}
|
||||
|
||||
void PopupWindow::aboutToShowEditMenu()
|
||||
{
|
||||
m_menuEdit->actions().at(0)->setEnabled(m_view->pageAction(QWebPage::Undo)->isEnabled());
|
||||
m_menuEdit->actions().at(1)->setEnabled(m_view->pageAction(QWebPage::Redo)->isEnabled());
|
||||
// Separator
|
||||
m_menuEdit->actions().at(3)->setEnabled(m_view->pageAction(QWebPage::Cut)->isEnabled());
|
||||
m_menuEdit->actions().at(4)->setEnabled(m_view->pageAction(QWebPage::Copy)->isEnabled());
|
||||
m_menuEdit->actions().at(5)->setEnabled(m_view->pageAction(QWebPage::Paste)->isEnabled());
|
||||
// Separator
|
||||
m_menuEdit->actions().at(7)->setEnabled(m_view->pageAction(QWebPage::SelectAll)->isEnabled());
|
||||
}
|
||||
|
||||
void PopupWindow::savePageScreen()
|
||||
{
|
||||
PageScreen* pageScreen = new PageScreen(m_view, this);
|
||||
pageScreen->show();
|
||||
}
|
||||
|
||||
void PopupWindow::searchOnPage()
|
||||
{
|
||||
if (!m_search) {
|
||||
m_search = new SearchToolBar(m_view, this);
|
||||
m_layout->insertWidget(m_layout->count() - 1, m_search);
|
||||
}
|
||||
|
||||
m_search->focusSearchLine();
|
||||
}
|
||||
|
||||
void PopupWindow::editUndo()
|
||||
{
|
||||
m_view->triggerPageAction(QWebPage::Undo);
|
||||
}
|
||||
|
||||
void PopupWindow::editRedo()
|
||||
{
|
||||
m_view->triggerPageAction(QWebPage::Redo);
|
||||
}
|
||||
|
||||
void PopupWindow::editCut()
|
||||
{
|
||||
m_view->triggerPageAction(QWebPage::Cut);
|
||||
}
|
||||
|
||||
void PopupWindow::editCopy()
|
||||
{
|
||||
m_view->triggerPageAction(QWebPage::Copy);
|
||||
}
|
||||
|
||||
void PopupWindow::editPaste()
|
||||
{
|
||||
m_view->triggerPageAction(QWebPage::Paste);
|
||||
}
|
||||
|
||||
void PopupWindow::titleChanged()
|
||||
{
|
||||
setWindowTitle(tr("%1 - QupZilla").arg(m_view->title()));
|
||||
}
|
||||
|
||||
void PopupWindow::setWindowGeometry(const QRect &newRect)
|
||||
void PopupWindow::setWindowGeometry(QRect newRect)
|
||||
{
|
||||
if (!qzSettings->allowJsGeometryChange) {
|
||||
return;
|
||||
}
|
||||
|
||||
// left/top was set while width/height not
|
||||
if (!newRect.topLeft().isNull() && newRect.size().isNull()) {
|
||||
newRect.setSize(QSize(550, 585));
|
||||
}
|
||||
|
||||
if (newRect.isValid()) {
|
||||
QRect oldRect = rect();
|
||||
move(newRect.topLeft());
|
||||
@ -179,33 +302,19 @@ void PopupWindow::setWindowGeometry(const QRect &newRect)
|
||||
}
|
||||
}
|
||||
|
||||
// From my testing, these 3 slots are always fired with false
|
||||
// visible argument (even if true should be passed)
|
||||
// So for now, we just do nothing here
|
||||
|
||||
void PopupWindow::setStatusBarVisibility(bool visible)
|
||||
{
|
||||
if (!qzSettings->allowJsHideStatusBar) {
|
||||
return;
|
||||
}
|
||||
|
||||
Q_UNUSED(visible)
|
||||
m_statusBar->setVisible(qzSettings->allowJsHideStatusBar ? visible : true);
|
||||
}
|
||||
|
||||
void PopupWindow::setMenuBarVisibility(bool visible)
|
||||
{
|
||||
if (!qzSettings->allowJsHideMenuBar) {
|
||||
return;
|
||||
}
|
||||
|
||||
Q_UNUSED(visible)
|
||||
m_menuBar->setVisible(qzSettings->allowJsHideMenuBar ? visible : true);
|
||||
}
|
||||
|
||||
void PopupWindow::setToolBarVisibility(bool visible)
|
||||
{
|
||||
if (!qzSettings->allowJsHideToolBar) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Does nothing now
|
||||
// m_toolBar->setVisible(qzSettings->allowJsHideToolBar ? visible : true);
|
||||
Q_UNUSED(visible)
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
||||
* Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -19,32 +19,33 @@
|
||||
#define POPUPWINDOW_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPointer>
|
||||
|
||||
#include "qz_namespace.h"
|
||||
|
||||
class QVBoxLayout;
|
||||
class QStatusBar;
|
||||
class QMenuBar;
|
||||
class QMenu;
|
||||
|
||||
class QupZilla;
|
||||
class PopupWebView;
|
||||
class PopupWebPage;
|
||||
class PopupStatusBarMessage;
|
||||
class PopupLocationBar;
|
||||
class ProgressBar;
|
||||
class SearchToolBar;
|
||||
|
||||
class QT_QUPZILLA_EXPORT PopupWindow : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PopupWindow(PopupWebView* view, QupZilla* mainClass);
|
||||
explicit PopupWindow(PopupWebView* view);
|
||||
|
||||
QStatusBar* statusBar();
|
||||
PopupWebView* webView();
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void setWindowGeometry(const QRect &newRect);
|
||||
void setWindowGeometry(QRect newRect);
|
||||
void setStatusBarVisibility(bool visible);
|
||||
void setMenuBarVisibility(bool visible);
|
||||
void setToolBarVisibility(bool visible);
|
||||
@ -58,10 +59,21 @@ private slots:
|
||||
void loadProgress(int value);
|
||||
void loadFinished();
|
||||
|
||||
void editUndo();
|
||||
void editRedo();
|
||||
void editCut();
|
||||
void editCopy();
|
||||
void editPaste();
|
||||
void editSelectAll();
|
||||
|
||||
void aboutToShowEditMenu();
|
||||
|
||||
void savePageScreen();
|
||||
void searchOnPage();
|
||||
|
||||
private:
|
||||
void closeEvent(QCloseEvent* event);
|
||||
|
||||
QupZilla* p_QupZilla;
|
||||
PopupWebView* m_view;
|
||||
PopupWebPage* m_page;
|
||||
PopupLocationBar* m_locationBar;
|
||||
@ -70,7 +82,12 @@ private:
|
||||
|
||||
QVBoxLayout* m_layout;
|
||||
QStatusBar* m_statusBar;
|
||||
|
||||
QMenuBar* m_menuBar;
|
||||
QMenu* m_menuEdit;
|
||||
QMenu* m_menuView;
|
||||
QAction* m_actionReload;
|
||||
QAction* m_actionStop;
|
||||
QPointer<SearchToolBar> m_search;
|
||||
};
|
||||
|
||||
#endif // POPUPWINDOW_H
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
||||
* Copyright (C) 2013 David Rosca <nowrep@gmail.com>
|
||||
2013 Mladen Pejaković <pejakm@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -44,6 +45,8 @@ JsOptions::JsOptions(QWidget* parent)
|
||||
#if QTWEBKIT_TO_2_2
|
||||
ui->jscanCloseWindow->setHidden(true);
|
||||
#endif
|
||||
// Disable for now, as it does not do anything (yet)
|
||||
ui->jscanHideTool->setHidden(true);
|
||||
}
|
||||
|
||||
void JsOptions::accept()
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
||||
* Copyright (C) 2013 David Rosca <nowrep@gmail.com>
|
||||
2013 Mladen Pejaković <pejakm@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
||||
* Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */
|
||||
#include "searchtoolbar.h"
|
||||
#include "qupzilla.h"
|
||||
#include "tabbedwebview.h"
|
||||
#include "lineedit.h"
|
||||
#include "ui_searchtoolbar.h"
|
||||
@ -25,10 +24,10 @@
|
||||
#include <QKeyEvent>
|
||||
#include <QShortcut>
|
||||
|
||||
SearchToolBar::SearchToolBar(QupZilla* mainClass, QWidget* parent)
|
||||
SearchToolBar::SearchToolBar(WebView* view, QWidget* parent)
|
||||
: AnimatedWidget(AnimatedWidget::Up, 300, parent)
|
||||
, ui(new Ui::SearchToolbar)
|
||||
, p_QupZilla(mainClass)
|
||||
, m_view(view)
|
||||
, m_findFlags(0)
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
@ -53,7 +52,12 @@ SearchToolBar::SearchToolBar(QupZilla* mainClass, QWidget* parent)
|
||||
QShortcut* findPreviousAction = new QShortcut(QKeySequence("Shift+F3"), this);
|
||||
connect(findPreviousAction, SIGNAL(activated()), this, SLOT(findPrevious()));
|
||||
|
||||
mainClass->installEventFilter(this);
|
||||
parent->installEventFilter(this);
|
||||
}
|
||||
|
||||
void SearchToolBar::setWebView(WebView* view)
|
||||
{
|
||||
m_view = view;
|
||||
}
|
||||
|
||||
void SearchToolBar::focusSearchLine()
|
||||
@ -66,7 +70,7 @@ void SearchToolBar::hide()
|
||||
AnimatedWidget::hide();
|
||||
|
||||
searchText(QString());
|
||||
p_QupZilla->weView()->setFocus();
|
||||
m_view->setFocus();
|
||||
}
|
||||
|
||||
void SearchToolBar::findNext()
|
||||
@ -97,13 +101,11 @@ void SearchToolBar::updateFindFlags()
|
||||
|
||||
void SearchToolBar::highlightChanged()
|
||||
{
|
||||
WebView* view = p_QupZilla->weView();
|
||||
|
||||
if (ui->highligh->isChecked()) {
|
||||
view->findText(ui->lineEdit->text(), m_findFlags | QWebPage::HighlightAllOccurrences);
|
||||
m_view->findText(ui->lineEdit->text(), m_findFlags | QWebPage::HighlightAllOccurrences);
|
||||
}
|
||||
else {
|
||||
view->findText(QString(), QWebPage::HighlightAllOccurrences);
|
||||
m_view->findText(QString(), QWebPage::HighlightAllOccurrences);
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,12 +118,10 @@ void SearchToolBar::caseSensitivityChanged()
|
||||
|
||||
void SearchToolBar::searchText(const QString &text)
|
||||
{
|
||||
WebView* view = p_QupZilla->weView();
|
||||
|
||||
// Clear highlighting on page
|
||||
view->findText(QString(), QWebPage::HighlightAllOccurrences);
|
||||
m_view->findText(QString(), QWebPage::HighlightAllOccurrences);
|
||||
|
||||
bool found = view->findText(text, m_findFlags);
|
||||
bool found = m_view->findText(text, m_findFlags);
|
||||
|
||||
if (text.isEmpty()) {
|
||||
found = true;
|
||||
@ -130,10 +130,10 @@ void SearchToolBar::searchText(const QString &text)
|
||||
if (ui->highligh->isChecked()) {
|
||||
m_findFlags = QWebPage::HighlightAllOccurrences;
|
||||
updateFindFlags();
|
||||
view->findText(text, m_findFlags);
|
||||
m_view->findText(text, m_findFlags);
|
||||
}
|
||||
else {
|
||||
view->findText(QString(), QWebPage::HighlightAllOccurrences);
|
||||
m_view->findText(QString(), QWebPage::HighlightAllOccurrences);
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
||||
* Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -30,16 +30,18 @@ class SearchToolbar;
|
||||
|
||||
class QLineEdit;
|
||||
|
||||
class QupZilla;
|
||||
class WebView;
|
||||
class LineEdit;
|
||||
|
||||
class QT_QUPZILLA_EXPORT SearchToolBar : public AnimatedWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SearchToolBar(QupZilla* mainClass, QWidget* parent = 0);
|
||||
explicit SearchToolBar(WebView* view, QWidget* parent = 0);
|
||||
~SearchToolBar();
|
||||
|
||||
void setWebView(WebView* view);
|
||||
|
||||
void focusSearchLine();
|
||||
bool eventFilter(QObject* obj, QEvent* event);
|
||||
|
||||
@ -58,7 +60,7 @@ public slots:
|
||||
|
||||
private:
|
||||
Ui::SearchToolbar* ui;
|
||||
QupZilla* p_QupZilla;
|
||||
WebView* m_view;
|
||||
|
||||
QWebPage::FindFlags m_findFlags;
|
||||
};
|
||||
|
@ -45,6 +45,7 @@ private:
|
||||
void completeWithData(const QString &html, const QByteArray &data);
|
||||
PageFormData extractFormData(const QString &html, const QByteArray &data);
|
||||
QVariant getElementByIdValue(const QString &id);
|
||||
|
||||
QWebView *view;
|
||||
|
||||
};
|
||||
|
11
tests/popup.html
Normal file
11
tests/popup.html
Normal file
@ -0,0 +1,11 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
<title>Popup window</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Popup window</h2>
|
||||
<input type="button" onclick="window.close()" value="Close window"/>
|
||||
<input type="button" onclick="window.print()" value="Print window"/>
|
||||
</body>
|
||||
</html>
|
40
tests/popupwindows.html
Normal file
40
tests/popupwindows.html
Normal file
@ -0,0 +1,40 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
<title>Popup windows test</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Popup windows test</h2>
|
||||
<b>Will be opened in new tab</b>
|
||||
<p>
|
||||
<a href="javascript:window.open('popup.html')">Popup 1</a>
|
||||
- can be opened in new tab
|
||||
</p>
|
||||
<p>
|
||||
<a href="javascript:window.open('popup.html', '_blank')">Popup 1</a>
|
||||
- with second argument _blank
|
||||
</p>
|
||||
<b>Will be opened in popup window</b>
|
||||
<p>
|
||||
<a href="javascript:window.open('popup.html', '_blank', 'width=150,height=150')">Popup 1</a>
|
||||
- with width and height
|
||||
</p>
|
||||
<p>
|
||||
<a href="javascript:window.open('popup.html', '_blank', 'width=150,height=150,left=15,top=20')">Popup 1</a>
|
||||
- with width, height, left and top
|
||||
</p>
|
||||
<p>
|
||||
<a href="javascript:window.open('popup.html', '_blank', 'left=100,right=200')">Popup 1</a>
|
||||
- with left and righ
|
||||
</p>
|
||||
<p>
|
||||
<a href="javascript:window.open('popup.html', '_blank', 'menubar=yes')">Popup 1</a>
|
||||
- with menubar
|
||||
</p>
|
||||
<p>
|
||||
<a href="javascript:window.open('popup.html', '_blank', 'status=yes')">Popup 1</a>
|
||||
- with statusbar
|
||||
</p>
|
||||
<p>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user