mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +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_actionShowStatusbar->setChecked(statusBar()->isVisible());
|
||||||
m_actionShowBookmarksToolbar->setChecked(m_bookmarksToolbar->isVisible());
|
m_actionShowBookmarksToolbar->setChecked(m_bookmarksToolbar->isVisible());
|
||||||
|
|
||||||
#if QT_VERSION >= 0x050000
|
#if QTWEBKIT_FROM_2_3
|
||||||
m_actionCaretBrowsing->setChecked(mApp->webSettings()->testAttribute(QWebSettings::CaretBrowsingEnabled));
|
m_actionCaretBrowsing->setChecked(mApp->webSettings()->testAttribute(QWebSettings::CaretBrowsingEnabled));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -1421,6 +1421,11 @@ void QupZilla::currentTabChanged()
|
|||||||
m_ipLabel->setText(view->getIp());
|
m_ipLabel->setText(view->getIp());
|
||||||
view->setFocus();
|
view->setFocus();
|
||||||
|
|
||||||
|
SearchToolBar* search = searchToolBar();
|
||||||
|
if (search) {
|
||||||
|
search->setWebView(view);
|
||||||
|
}
|
||||||
|
|
||||||
updateLoadingActions();
|
updateLoadingActions();
|
||||||
|
|
||||||
// Setting correct tab order (LocationBar -> WebSearchBar -> WebView)
|
// Setting correct tab order (LocationBar -> WebSearchBar -> WebView)
|
||||||
@ -1483,19 +1488,14 @@ void QupZilla::webSearch()
|
|||||||
|
|
||||||
void QupZilla::searchOnPage()
|
void QupZilla::searchOnPage()
|
||||||
{
|
{
|
||||||
if (m_mainLayout->count() == 4) {
|
SearchToolBar* toolBar = searchToolBar();
|
||||||
SearchToolBar* search = qobject_cast<SearchToolBar*>(m_mainLayout->itemAt(3)->widget());
|
|
||||||
if (!search) {
|
if (!toolBar) {
|
||||||
return;
|
toolBar = new SearchToolBar(weView(), this);
|
||||||
|
m_mainLayout->insertWidget(3, toolBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
search->focusSearchLine();
|
toolBar->focusSearchLine();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SearchToolBar* search = new SearchToolBar(this);
|
|
||||||
m_mainLayout->insertWidget(3, search);
|
|
||||||
search->focusSearchLine();
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
if (QtWin::isCompositionEnabled()) {
|
if (QtWin::isCompositionEnabled()) {
|
||||||
@ -1857,6 +1857,17 @@ void QupZilla::closeEvent(QCloseEvent* event)
|
|||||||
event->accept();
|
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()
|
void QupZilla::disconnectObjects()
|
||||||
{
|
{
|
||||||
// Disconnecting all important widgets before deleting this window
|
// Disconnecting all important widgets before deleting this window
|
||||||
|
@ -202,6 +202,8 @@ private:
|
|||||||
void keyReleaseEvent(QKeyEvent* event);
|
void keyReleaseEvent(QKeyEvent* event);
|
||||||
void closeEvent(QCloseEvent* event);
|
void closeEvent(QCloseEvent* event);
|
||||||
|
|
||||||
|
SearchToolBar* searchToolBar();
|
||||||
|
|
||||||
void setupUi();
|
void setupUi();
|
||||||
void setupMenu();
|
void setupMenu();
|
||||||
|
|
||||||
|
@ -56,20 +56,11 @@ PopupWebPage::PopupWebPage(QWebPage::WebWindowType type, QupZilla* mainClass)
|
|||||||
|
|
||||||
void PopupWebPage::slotGeometryChangeRequested(const QRect &rect)
|
void PopupWebPage::slotGeometryChangeRequested(const QRect &rect)
|
||||||
{
|
{
|
||||||
/* Very ugly hack for QtWebKit 2.3
|
if (rect.isValid()) {
|
||||||
* 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;
|
|
||||||
m_createNewWindow = true;
|
m_createNewWindow = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_geometry = rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupWebPage::slotMenuBarVisibilityChangeRequested(bool visible)
|
void PopupWebPage::slotMenuBarVisibilityChangeRequested(bool visible)
|
||||||
@ -108,11 +99,19 @@ void PopupWebPage::slotLoadFinished(bool state)
|
|||||||
|
|
||||||
void PopupWebPage::checkBehaviour()
|
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) {
|
if (m_createNewWindow) {
|
||||||
PopupWebView* view = new PopupWebView;
|
PopupWebView* view = new PopupWebView;
|
||||||
view->setWebPage(this);
|
view->setWebPage(this);
|
||||||
|
|
||||||
PopupWindow* popup = new PopupWindow(view, p_QupZilla);
|
PopupWindow* popup = new PopupWindow(view);
|
||||||
popup->setWindowGeometry(m_geometry);
|
popup->setWindowGeometry(m_geometry);
|
||||||
popup->setMenuBarVisibility(m_menuBarVisible);
|
popup->setMenuBarVisibility(m_menuBarVisible);
|
||||||
popup->setStatusBarVisibility(m_statusBarVisible);
|
popup->setStatusBarVisibility(m_statusBarVisible);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* 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
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -20,21 +20,24 @@
|
|||||||
#include "popupwebpage.h"
|
#include "popupwebpage.h"
|
||||||
#include "popupstatusbarmessage.h"
|
#include "popupstatusbarmessage.h"
|
||||||
#include "progressbar.h"
|
#include "progressbar.h"
|
||||||
#include "qupzilla.h"
|
#include "pagescreen.h"
|
||||||
|
#include "searchtoolbar.h"
|
||||||
#include "qzsettings.h"
|
#include "qzsettings.h"
|
||||||
#include "popuplocationbar.h"
|
#include "popuplocationbar.h"
|
||||||
#include "qztools.h"
|
#include "qztools.h"
|
||||||
|
#include "iconprovider.h"
|
||||||
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
#include <QWebFrame>
|
#include <QWebFrame>
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
|
#include <QMenuBar>
|
||||||
|
|
||||||
PopupWindow::PopupWindow(PopupWebView* view, QupZilla* mainClass)
|
PopupWindow::PopupWindow(PopupWebView* view)
|
||||||
: QWidget()
|
: QWidget()
|
||||||
, p_QupZilla(mainClass)
|
|
||||||
, m_view(view)
|
, m_view(view)
|
||||||
, m_page(qobject_cast<PopupWebPage*>(view->page()))
|
, m_page(qobject_cast<PopupWebPage*>(view->page()))
|
||||||
|
, m_search(0)
|
||||||
{
|
{
|
||||||
m_layout = new QVBoxLayout(this);
|
m_layout = new QVBoxLayout(this);
|
||||||
m_layout->setContentsMargins(0, 0, 0, 0);
|
m_layout->setContentsMargins(0, 0, 0, 0);
|
||||||
@ -45,14 +48,61 @@ PopupWindow::PopupWindow(PopupWebView* view, QupZilla* mainClass)
|
|||||||
|
|
||||||
m_statusBar = new QStatusBar(this);
|
m_statusBar = new QStatusBar(this);
|
||||||
m_statusBar->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
|
m_statusBar->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
|
||||||
m_statusBar->setVisible(p_QupZilla->statusBar()->isVisible());
|
|
||||||
|
|
||||||
m_progressBar = new ProgressBar(m_statusBar);
|
m_progressBar = new ProgressBar(m_statusBar);
|
||||||
m_statusBar->addPermanentWidget(m_progressBar);
|
m_statusBar->addPermanentWidget(m_progressBar);
|
||||||
m_progressBar->hide();
|
m_progressBar->hide();
|
||||||
|
|
||||||
|
m_view->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
m_statusBarMessage = new PopupStatusBarMessage(this);
|
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_locationBar);
|
||||||
m_layout->addWidget(m_view);
|
m_layout->addWidget(m_view);
|
||||||
m_layout->addWidget(m_statusBar);
|
m_layout->addWidget(m_statusBar);
|
||||||
@ -125,6 +175,11 @@ void PopupWindow::loadStarted()
|
|||||||
m_progressBar->show();
|
m_progressBar->show();
|
||||||
|
|
||||||
m_locationBar->startLoading();
|
m_locationBar->startLoading();
|
||||||
|
|
||||||
|
if (m_actionStop) {
|
||||||
|
m_actionStop->setEnabled(true);
|
||||||
|
m_actionReload->setEnabled(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupWindow::loadProgress(int value)
|
void PopupWindow::loadProgress(int value)
|
||||||
@ -138,6 +193,11 @@ void PopupWindow::loadFinished()
|
|||||||
m_progressBar->hide();
|
m_progressBar->hide();
|
||||||
|
|
||||||
m_locationBar->stopLoading();
|
m_locationBar->stopLoading();
|
||||||
|
|
||||||
|
if (m_actionStop) {
|
||||||
|
m_actionStop->setEnabled(false);
|
||||||
|
m_actionReload->setEnabled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupWindow::closeEvent(QCloseEvent* event)
|
void PopupWindow::closeEvent(QCloseEvent* event)
|
||||||
@ -153,17 +213,80 @@ void PopupWindow::closeEvent(QCloseEvent* event)
|
|||||||
event->accept();
|
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()
|
void PopupWindow::titleChanged()
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("%1 - QupZilla").arg(m_view->title()));
|
setWindowTitle(tr("%1 - QupZilla").arg(m_view->title()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupWindow::setWindowGeometry(const QRect &newRect)
|
void PopupWindow::setWindowGeometry(QRect newRect)
|
||||||
{
|
{
|
||||||
if (!qzSettings->allowJsGeometryChange) {
|
if (!qzSettings->allowJsGeometryChange) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// left/top was set while width/height not
|
||||||
|
if (!newRect.topLeft().isNull() && newRect.size().isNull()) {
|
||||||
|
newRect.setSize(QSize(550, 585));
|
||||||
|
}
|
||||||
|
|
||||||
if (newRect.isValid()) {
|
if (newRect.isValid()) {
|
||||||
QRect oldRect = rect();
|
QRect oldRect = rect();
|
||||||
move(newRect.topLeft());
|
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)
|
void PopupWindow::setStatusBarVisibility(bool visible)
|
||||||
{
|
{
|
||||||
if (!qzSettings->allowJsHideStatusBar) {
|
m_statusBar->setVisible(qzSettings->allowJsHideStatusBar ? visible : true);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_UNUSED(visible)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupWindow::setMenuBarVisibility(bool visible)
|
void PopupWindow::setMenuBarVisibility(bool visible)
|
||||||
{
|
{
|
||||||
if (!qzSettings->allowJsHideMenuBar) {
|
m_menuBar->setVisible(qzSettings->allowJsHideMenuBar ? visible : true);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_UNUSED(visible)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupWindow::setToolBarVisibility(bool visible)
|
void PopupWindow::setToolBarVisibility(bool visible)
|
||||||
{
|
{
|
||||||
if (!qzSettings->allowJsHideToolBar) {
|
// Does nothing now
|
||||||
return;
|
// m_toolBar->setVisible(qzSettings->allowJsHideToolBar ? visible : true);
|
||||||
}
|
|
||||||
|
|
||||||
Q_UNUSED(visible)
|
Q_UNUSED(visible)
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* 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
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -19,32 +19,33 @@
|
|||||||
#define POPUPWINDOW_H
|
#define POPUPWINDOW_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
#include "qz_namespace.h"
|
#include "qz_namespace.h"
|
||||||
|
|
||||||
class QVBoxLayout;
|
class QVBoxLayout;
|
||||||
class QStatusBar;
|
class QStatusBar;
|
||||||
|
class QMenuBar;
|
||||||
|
class QMenu;
|
||||||
|
|
||||||
class QupZilla;
|
|
||||||
class PopupWebView;
|
class PopupWebView;
|
||||||
class PopupWebPage;
|
class PopupWebPage;
|
||||||
class PopupStatusBarMessage;
|
class PopupStatusBarMessage;
|
||||||
class PopupLocationBar;
|
class PopupLocationBar;
|
||||||
class ProgressBar;
|
class ProgressBar;
|
||||||
|
class SearchToolBar;
|
||||||
|
|
||||||
class QT_QUPZILLA_EXPORT PopupWindow : public QWidget
|
class QT_QUPZILLA_EXPORT PopupWindow : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit PopupWindow(PopupWebView* view, QupZilla* mainClass);
|
explicit PopupWindow(PopupWebView* view);
|
||||||
|
|
||||||
QStatusBar* statusBar();
|
QStatusBar* statusBar();
|
||||||
PopupWebView* webView();
|
PopupWebView* webView();
|
||||||
|
|
||||||
signals:
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setWindowGeometry(const QRect &newRect);
|
void setWindowGeometry(QRect newRect);
|
||||||
void setStatusBarVisibility(bool visible);
|
void setStatusBarVisibility(bool visible);
|
||||||
void setMenuBarVisibility(bool visible);
|
void setMenuBarVisibility(bool visible);
|
||||||
void setToolBarVisibility(bool visible);
|
void setToolBarVisibility(bool visible);
|
||||||
@ -58,10 +59,21 @@ private slots:
|
|||||||
void loadProgress(int value);
|
void loadProgress(int value);
|
||||||
void loadFinished();
|
void loadFinished();
|
||||||
|
|
||||||
|
void editUndo();
|
||||||
|
void editRedo();
|
||||||
|
void editCut();
|
||||||
|
void editCopy();
|
||||||
|
void editPaste();
|
||||||
|
void editSelectAll();
|
||||||
|
|
||||||
|
void aboutToShowEditMenu();
|
||||||
|
|
||||||
|
void savePageScreen();
|
||||||
|
void searchOnPage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void closeEvent(QCloseEvent* event);
|
void closeEvent(QCloseEvent* event);
|
||||||
|
|
||||||
QupZilla* p_QupZilla;
|
|
||||||
PopupWebView* m_view;
|
PopupWebView* m_view;
|
||||||
PopupWebPage* m_page;
|
PopupWebPage* m_page;
|
||||||
PopupLocationBar* m_locationBar;
|
PopupLocationBar* m_locationBar;
|
||||||
@ -70,7 +82,12 @@ private:
|
|||||||
|
|
||||||
QVBoxLayout* m_layout;
|
QVBoxLayout* m_layout;
|
||||||
QStatusBar* m_statusBar;
|
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
|
#endif // POPUPWINDOW_H
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* 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
|
* 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
|
* 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
|
#if QTWEBKIT_TO_2_2
|
||||||
ui->jscanCloseWindow->setHidden(true);
|
ui->jscanCloseWindow->setHidden(true);
|
||||||
#endif
|
#endif
|
||||||
|
// Disable for now, as it does not do anything (yet)
|
||||||
|
ui->jscanHideTool->setHidden(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsOptions::accept()
|
void JsOptions::accept()
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* 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
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* 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
|
* 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
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* ============================================================ */
|
* ============================================================ */
|
||||||
#include "searchtoolbar.h"
|
#include "searchtoolbar.h"
|
||||||
#include "qupzilla.h"
|
|
||||||
#include "tabbedwebview.h"
|
#include "tabbedwebview.h"
|
||||||
#include "lineedit.h"
|
#include "lineedit.h"
|
||||||
#include "ui_searchtoolbar.h"
|
#include "ui_searchtoolbar.h"
|
||||||
@ -25,10 +24,10 @@
|
|||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
|
|
||||||
SearchToolBar::SearchToolBar(QupZilla* mainClass, QWidget* parent)
|
SearchToolBar::SearchToolBar(WebView* view, QWidget* parent)
|
||||||
: AnimatedWidget(AnimatedWidget::Up, 300, parent)
|
: AnimatedWidget(AnimatedWidget::Up, 300, parent)
|
||||||
, ui(new Ui::SearchToolbar)
|
, ui(new Ui::SearchToolbar)
|
||||||
, p_QupZilla(mainClass)
|
, m_view(view)
|
||||||
, m_findFlags(0)
|
, m_findFlags(0)
|
||||||
{
|
{
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
@ -53,7 +52,12 @@ SearchToolBar::SearchToolBar(QupZilla* mainClass, QWidget* parent)
|
|||||||
QShortcut* findPreviousAction = new QShortcut(QKeySequence("Shift+F3"), this);
|
QShortcut* findPreviousAction = new QShortcut(QKeySequence("Shift+F3"), this);
|
||||||
connect(findPreviousAction, SIGNAL(activated()), this, SLOT(findPrevious()));
|
connect(findPreviousAction, SIGNAL(activated()), this, SLOT(findPrevious()));
|
||||||
|
|
||||||
mainClass->installEventFilter(this);
|
parent->installEventFilter(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SearchToolBar::setWebView(WebView* view)
|
||||||
|
{
|
||||||
|
m_view = view;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchToolBar::focusSearchLine()
|
void SearchToolBar::focusSearchLine()
|
||||||
@ -66,7 +70,7 @@ void SearchToolBar::hide()
|
|||||||
AnimatedWidget::hide();
|
AnimatedWidget::hide();
|
||||||
|
|
||||||
searchText(QString());
|
searchText(QString());
|
||||||
p_QupZilla->weView()->setFocus();
|
m_view->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchToolBar::findNext()
|
void SearchToolBar::findNext()
|
||||||
@ -97,13 +101,11 @@ void SearchToolBar::updateFindFlags()
|
|||||||
|
|
||||||
void SearchToolBar::highlightChanged()
|
void SearchToolBar::highlightChanged()
|
||||||
{
|
{
|
||||||
WebView* view = p_QupZilla->weView();
|
|
||||||
|
|
||||||
if (ui->highligh->isChecked()) {
|
if (ui->highligh->isChecked()) {
|
||||||
view->findText(ui->lineEdit->text(), m_findFlags | QWebPage::HighlightAllOccurrences);
|
m_view->findText(ui->lineEdit->text(), m_findFlags | QWebPage::HighlightAllOccurrences);
|
||||||
}
|
}
|
||||||
else {
|
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)
|
void SearchToolBar::searchText(const QString &text)
|
||||||
{
|
{
|
||||||
WebView* view = p_QupZilla->weView();
|
|
||||||
|
|
||||||
// Clear highlighting on page
|
// 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()) {
|
if (text.isEmpty()) {
|
||||||
found = true;
|
found = true;
|
||||||
@ -130,10 +130,10 @@ void SearchToolBar::searchText(const QString &text)
|
|||||||
if (ui->highligh->isChecked()) {
|
if (ui->highligh->isChecked()) {
|
||||||
m_findFlags = QWebPage::HighlightAllOccurrences;
|
m_findFlags = QWebPage::HighlightAllOccurrences;
|
||||||
updateFindFlags();
|
updateFindFlags();
|
||||||
view->findText(text, m_findFlags);
|
m_view->findText(text, m_findFlags);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
view->findText(QString(), QWebPage::HighlightAllOccurrences);
|
m_view->findText(QString(), QWebPage::HighlightAllOccurrences);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* 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
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -30,16 +30,18 @@ class SearchToolbar;
|
|||||||
|
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
|
|
||||||
class QupZilla;
|
class WebView;
|
||||||
class LineEdit;
|
class LineEdit;
|
||||||
|
|
||||||
class QT_QUPZILLA_EXPORT SearchToolBar : public AnimatedWidget
|
class QT_QUPZILLA_EXPORT SearchToolBar : public AnimatedWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit SearchToolBar(QupZilla* mainClass, QWidget* parent = 0);
|
explicit SearchToolBar(WebView* view, QWidget* parent = 0);
|
||||||
~SearchToolBar();
|
~SearchToolBar();
|
||||||
|
|
||||||
|
void setWebView(WebView* view);
|
||||||
|
|
||||||
void focusSearchLine();
|
void focusSearchLine();
|
||||||
bool eventFilter(QObject* obj, QEvent* event);
|
bool eventFilter(QObject* obj, QEvent* event);
|
||||||
|
|
||||||
@ -58,7 +60,7 @@ public slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::SearchToolbar* ui;
|
Ui::SearchToolbar* ui;
|
||||||
QupZilla* p_QupZilla;
|
WebView* m_view;
|
||||||
|
|
||||||
QWebPage::FindFlags m_findFlags;
|
QWebPage::FindFlags m_findFlags;
|
||||||
};
|
};
|
||||||
|
@ -45,6 +45,7 @@ private:
|
|||||||
void completeWithData(const QString &html, const QByteArray &data);
|
void completeWithData(const QString &html, const QByteArray &data);
|
||||||
PageFormData extractFormData(const QString &html, const QByteArray &data);
|
PageFormData extractFormData(const QString &html, const QByteArray &data);
|
||||||
QVariant getElementByIdValue(const QString &id);
|
QVariant getElementByIdValue(const QString &id);
|
||||||
|
|
||||||
QWebView *view;
|
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