1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

Improved javascript alert, confirm, prompt dialogs.

- instead of injecting semi transparent block into page, we
   just set background of the whole widget frame to semi
   transparent image

 - fixes issue, when sometimes background filled only half
   of the page
   this issue occurs sometimes when more than one frames
   were in page
This commit is contained in:
nowrep 2011-11-24 22:18:45 +01:00
parent a3898e48c0
commit 0e82994e7f
13 changed files with 60 additions and 42 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

View File

@ -336,6 +336,11 @@ DownloadManager #list
} }
/*JavaScript Dialogs*/ /*JavaScript Dialogs*/
#jsFrame
{
background: url(images/semi-transp.png);
}
QFrame[js-frame="true"] QFrame[js-frame="true"]
{ {
border: 1px solid black; border: 1px solid black;

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

View File

@ -345,6 +345,11 @@ DownloadManager #list
} }
/*JavaScript Dialogs*/ /*JavaScript Dialogs*/
#jsFrame
{
background: url(images/semi-transp.png);
}
QFrame[js-frame="true"] QFrame[js-frame="true"]
{ {
border: 1px solid black; border: 1px solid black;

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

View File

@ -305,6 +305,11 @@ DownloadManager #list
} }
/*JavaScript Dialogs*/ /*JavaScript Dialogs*/
#jsFrame
{
background: url(images/semi-transp.png);
}
QFrame[js-frame="true"] QFrame[js-frame="true"]
{ {
border: 1px solid black; border: 1px solid black;

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

View File

@ -333,6 +333,11 @@ DownloadManager #list
} }
/*JavaScript Dialogs*/ /*JavaScript Dialogs*/
#jsFrame
{
background: url(images/semi-transp.png);
}
QFrame[js-frame="true"] QFrame[js-frame="true"]
{ {
border: 1px solid black; border: 1px solid black;

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

View File

@ -339,6 +339,11 @@ DownloadManager #list
} }
/*JavaScript Dialogs*/ /*JavaScript Dialogs*/
#jsFrame
{
background: url(images/semi-transp.png);
}
QFrame[js-frame="true"] QFrame[js-frame="true"]
{ {
border: 1px solid black; border: 1px solid black;

View File

@ -17,6 +17,9 @@
* ============================================================ */ * ============================================================ */
#include "widget.h" #include "widget.h"
/*
* class Widget
*/
Widget::Widget(QWidget* parent) : Widget::Widget(QWidget* parent) :
QWidget(parent) QWidget(parent)
{ {
@ -26,3 +29,16 @@ void Widget::slotResize(const QSize &size)
{ {
resize(size); resize(size);
} }
/*
* class ResizableFrame
*/
ResizableFrame::ResizableFrame(QWidget* parent) :
QFrame(parent)
{
}
void ResizableFrame::slotResize(const QSize &size)
{
resize(size);
}

View File

@ -19,6 +19,7 @@
#define WIDGET_H #define WIDGET_H
#include <QWidget> #include <QWidget>
#include <QFrame>
class Widget : public QWidget class Widget : public QWidget
{ {
@ -33,4 +34,16 @@ public slots:
}; };
class ResizableFrame : public QFrame
{
Q_OBJECT
public:
explicit ResizableFrame(QWidget* parent = 0);
signals:
public slots:
void slotResize(const QSize &size);
};
#endif // WIDGET_H #endif // WIDGET_H

View File

@ -351,7 +351,8 @@ bool WebPage::javaScriptPrompt(QWebFrame* originatingFrame, const QString &msg,
{ {
WebView* _view = qobject_cast<WebView*>(originatingFrame->page()->view()); WebView* _view = qobject_cast<WebView*>(originatingFrame->page()->view());
Widget* widget = new Widget(_view->webTab()); ResizableFrame* widget = new ResizableFrame(_view->webTab());
widget->setObjectName("jsFrame");
Ui_jsPrompt* ui = new Ui_jsPrompt(); Ui_jsPrompt* ui = new Ui_jsPrompt();
ui->setupUi(widget); ui->setupUi(widget);
ui->message->setText(msg); ui->message->setText(msg);
@ -363,18 +364,6 @@ bool WebPage::javaScriptPrompt(QWebFrame* originatingFrame, const QString &msg,
connect(_view, SIGNAL(viewportResized(QSize)), widget, SLOT(slotResize(QSize))); connect(_view, SIGNAL(viewportResized(QSize)), widget, SLOT(slotResize(QSize)));
connect(ui->lineEdit, SIGNAL(returnPressed()), ui->buttonBox->button(QDialogButtonBox::Ok), SLOT(animateClick())); connect(ui->lineEdit, SIGNAL(returnPressed()), ui->buttonBox->button(QDialogButtonBox::Ok), SLOT(animateClick()));
QWebElement bodyElement = originatingFrame->findFirstElement("body");
if (!bodyElement.isNull()) {
QString height = QString::number(originatingFrame->contentsSize().height());
QString width = QString::number(originatingFrame->contentsSize().width());
bodyElement.prependInside("<span id='qupzilla-background-content' style='display: block;background: #6b6b6b;"
"position: absolute;opacity: .9;filter: alpha(opacity=90);top: 0px;"
"left: 0px;z-index: 998;overflow: hidden;width:" + width + "px; height:" + height + "px;'> </span>");
}
else {
widget->setAutoFillBackground(true);
}
QEventLoop eLoop; QEventLoop eLoop;
connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), &eLoop, SLOT(quit())); connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), &eLoop, SLOT(quit()));
eLoop.exec(); eLoop.exec();
@ -384,7 +373,6 @@ bool WebPage::javaScriptPrompt(QWebFrame* originatingFrame, const QString &msg,
*result = x; *result = x;
delete widget; delete widget;
originatingFrame->findFirstElement("span[id=\"qupzilla-background-content\"]").removeFromDocument();
_view->setFocus(); _view->setFocus();
return _result; return _result;
@ -394,7 +382,8 @@ bool WebPage::javaScriptConfirm(QWebFrame* originatingFrame, const QString &msg)
{ {
WebView* _view = qobject_cast<WebView*>(originatingFrame->page()->view()); WebView* _view = qobject_cast<WebView*>(originatingFrame->page()->view());
Widget* widget = new Widget(_view->webTab()); ResizableFrame* widget = new ResizableFrame(_view->webTab());
widget->setObjectName("jsFrame");
Ui_jsConfirm* ui = new Ui_jsConfirm(); Ui_jsConfirm* ui = new Ui_jsConfirm();
ui->setupUi(widget); ui->setupUi(widget);
ui->message->setText(msg); ui->message->setText(msg);
@ -404,18 +393,6 @@ bool WebPage::javaScriptConfirm(QWebFrame* originatingFrame, const QString &msg)
connect(_view, SIGNAL(viewportResized(QSize)), widget, SLOT(slotResize(QSize))); connect(_view, SIGNAL(viewportResized(QSize)), widget, SLOT(slotResize(QSize)));
QWebElement bodyElement = originatingFrame->findFirstElement("body");
if (!bodyElement.isNull()) {
QString height = QString::number(originatingFrame->contentsSize().height());
QString width = QString::number(originatingFrame->contentsSize().width());
bodyElement.prependInside("<span id='qupzilla-background-content' style='display: block;background: #6b6b6b;"
"position: absolute;opacity: .9;filter: alpha(opacity=90);top: 0px;"
"left: 0px;z-index: 998;overflow: hidden;width:" + width + "px; height:" + height + "px;'> </span>");
}
else {
widget->setAutoFillBackground(true);
}
QEventLoop eLoop; QEventLoop eLoop;
connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), &eLoop, SLOT(quit())); connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), &eLoop, SLOT(quit()));
eLoop.exec(); eLoop.exec();
@ -423,7 +400,6 @@ bool WebPage::javaScriptConfirm(QWebFrame* originatingFrame, const QString &msg)
bool result = ui->buttonBox->clickedButtonRole() == QDialogButtonBox::AcceptRole; bool result = ui->buttonBox->clickedButtonRole() == QDialogButtonBox::AcceptRole;
delete widget; delete widget;
originatingFrame->findFirstElement("span[id=\"qupzilla-background-content\"]").removeFromDocument();
_view->setFocus(); _view->setFocus();
return result; return result;
@ -437,7 +413,8 @@ void WebPage::javaScriptAlert(QWebFrame* originatingFrame, const QString &msg)
WebView* _view = qobject_cast<WebView*>(originatingFrame->page()->view()); WebView* _view = qobject_cast<WebView*>(originatingFrame->page()->view());
Widget* widget = new Widget(_view->webTab()); ResizableFrame* widget = new ResizableFrame(_view->webTab());
widget->setObjectName("jsFrame");
Ui_jsAlert* ui = new Ui_jsAlert(); Ui_jsAlert* ui = new Ui_jsAlert();
ui->setupUi(widget); ui->setupUi(widget);
ui->message->setText(msg); ui->message->setText(msg);
@ -447,18 +424,6 @@ void WebPage::javaScriptAlert(QWebFrame* originatingFrame, const QString &msg)
connect(_view, SIGNAL(viewportResized(QSize)), widget, SLOT(slotResize(QSize))); connect(_view, SIGNAL(viewportResized(QSize)), widget, SLOT(slotResize(QSize)));
QWebElement bodyElement = originatingFrame->findFirstElement("body");
if (!bodyElement.isNull()) {
QString height = QString::number(originatingFrame->contentsSize().height());
QString width = QString::number(originatingFrame->contentsSize().width());
bodyElement.prependInside("<span id='qupzilla-background-content' style='display: block;background: #6b6b6b;"
"position: absolute;opacity: .9;filter: alpha(opacity=90);top: 0px;"
"left: 0px;z-index: 998;overflow: hidden;width:" + width + "px; height:" + height + "px;'> </span>");
}
else {
widget->setAutoFillBackground(true);
}
QEventLoop eLoop; QEventLoop eLoop;
connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), &eLoop, SLOT(quit())); connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), &eLoop, SLOT(quit()));
eLoop.exec(); eLoop.exec();
@ -467,7 +432,6 @@ void WebPage::javaScriptAlert(QWebFrame* originatingFrame, const QString &msg)
delete widget; delete widget;
originatingFrame->findFirstElement("span[id=\"qupzilla-background-content\"]").removeFromDocument();
_view->setFocus(); _view->setFocus();
} }