Commit 5a566224 authored by staikos's avatar staikos

Implement the javascript dialogs and file chooser dialog, along with some

cleanups.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@23528 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a7ac083f
2007-06-14 George Staikos <staikos@kde.org>
Reviewed by Lars.
Implement the file chooser for Qt.
* platform/qt/FileChooserQt.cpp:
(WebCore::FileChooser::openFileChooser):
(WebCore::FileChooser::basenameForWidth):
2007-06-14 George Staikos <staikos@kde.org>
Reviewed by Lars.
......@@ -21,8 +21,13 @@
#include "config.h"
#include "FileChooser.h"
#include "Document.h"
#include "Frame.h"
#include "FrameLoaderClientQt.h"
#include "Icon.h"
#include "NotImplemented.h"
#include "Page.h"
#include <QFontMetrics>
namespace WebCore {
......@@ -37,15 +42,26 @@ FileChooser::~FileChooser()
{
}
void FileChooser::openFileChooser(Document*)
void FileChooser::openFileChooser(Document* doc)
{
notImplemented();
Page *page = doc->page();
Frame *frame = doc->frame();
if (!page || !frame)
return;
FrameLoaderClientQt *fl = static_cast<FrameLoaderClientQt*>(frame->loader()->client());
if (!fl)
return;
QString f = fl->chooseFile(m_filename);
if (!f.isEmpty())
chooseFile(f);
}
String FileChooser::basenameForWidth(const Font&, int width) const
String FileChooser::basenameForWidth(const Font& f, int width) const
{
notImplemented();
return String();
QFontMetrics fm((QFont)f);
return fm.elidedText(m_filename, Qt::ElideLeft, width);
}
}
......
......@@ -48,16 +48,20 @@
#include <QDragLeaveEvent>
#include <QDragMoveEvent>
#include <QDropEvent>
#include <QFileDialog>
#include <QHttpRequestHeader>
#include <QInputDialog>
#include <QMessageBox>
#include <QUndoStack>
#include <QUrl>
#include <QVBoxLayout>
#include <QHttpRequestHeader>
using namespace WebCore;
QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
: q(qq), modified(false)
{
q->setFocusPolicy(Qt::ClickFocus);
chromeClient = new ChromeClientQt(q);
contextMenuClient = new ContextMenuClientQt();
editorClient = new EditorClientQt(q);
......@@ -216,12 +220,24 @@ void QWebPage::javaScriptConsoleMessage(const QString& message, unsigned int lin
{
}
void QWebPage::statusTextChanged(const QString& text)
void QWebPage::javaScriptAlert(QWebFrame *frame, const QString& msg)
{
QMessageBox::information(frame, title(), msg, QMessageBox::Ok);
}
bool QWebPage::javaScriptConfirm(QWebFrame *frame, const QString& msg)
{
return 0 == QMessageBox::information(frame, title(), msg, QMessageBox::Yes, QMessageBox::No);
}
void QWebPage::runJavaScriptAlert(QWebFrame *frame, const QString& msg)
bool QWebPage::javaScriptPrompt(QWebFrame *frame, const QString& msg, const QString& defaultValue, QString* result)
{
bool ok = false;
QString x = QInputDialog::getText(frame, title(), msg, QLineEdit::Normal, defaultValue, &ok);
if (ok && result) {
*result = x;
}
return ok;
}
QWebPage *QWebPage::createWindow()
......@@ -406,3 +422,9 @@ QWebSettings QWebPage::settings() const
return settings;
}
QString QWebPage::chooseFile(QWebFrame *parentFrame, const QString& oldFile)
{
return QFileDialog::getOpenFileName(parentFrame, QString::null, oldFile);
}
......@@ -60,7 +60,6 @@ public:
QWebPage(QWidget *parent);
~QWebPage();
void open(const QUrl &url);
void open(const QWebNetworkRequest &request);
......@@ -79,19 +78,8 @@ public:
bool isModified() const;
virtual void javaScriptConsoleMessage(const QString& message, unsigned int lineNumber, const QString& sourceID);
virtual void statusTextChanged(const QString& text);
virtual void runJavaScriptAlert(QWebFrame *frame, const QString& msg);
QUndoStack *undoStack();
virtual void dragEnterEvent(QDragEnterEvent *);
virtual void dragLeaveEvent(QDragLeaveEvent *);
virtual void dragMoveEvent(QDragMoveEvent *);
virtual void dropEvent(QDropEvent *);
void setNetworkInterface(QWebNetworkInterface *interface);
QWebNetworkInterface *networkInterface() const;
......@@ -137,12 +125,26 @@ signals:
* isn't hovering over any link element.
*/
void hoveringOverLink(const QString &link, const QString &title);
/**
* Signal is emitted when the statusbar text is changed by the page.
*/
void statusBarTextChanged(const QString& text);
protected:
virtual QWebFrame *createFrame(QWebFrame *parentFrame, QWebFrameData *frameData);
virtual QWebPage *createWindow();
virtual NavigationRequestResponse navigationRequested(QWebFrame *frame, const QWebNetworkRequest &request);
virtual QString chooseFile(QWebFrame *frame, const QString& oldFile);
virtual void javaScriptAlert(QWebFrame *frame, const QString& msg);
virtual bool javaScriptConfirm(QWebFrame *frame, const QString& msg);
virtual bool javaScriptPrompt(QWebFrame *frame, const QString& msg, const QString& defaultValue, QString* result);
virtual void javaScriptConsoleMessage(const QString& message, unsigned int lineNumber, const QString& sourceID);
virtual void dragEnterEvent(QDragEnterEvent *);
virtual void dragLeaveEvent(QDragLeaveEvent *);
virtual void dragMoveEvent(QDragMoveEvent *);
virtual void dropEvent(QDropEvent *);
private:
friend class QWebFrame;
......
2007-06-14 George Staikos <staikos@kde.org>
Reviewed by Lars.
Implement all of the Javascript dialogs and file chooser.
Also makes the statusbar virtual into a signal and shuffles some
virtuals around a bit. The helper in FrameLoaderClientQt may go away
shortly.
* Api/qwebpage.cpp:
(QWebPagePrivate::QWebPagePrivate):
(QWebPage::javaScriptAlert):
(QWebPage::javaScriptConfirm):
(QWebPage::javaScriptPrompt):
(QWebPage::chooseFile):
* Api/qwebpage.h:
* WebCoreSupport/ChromeClientQt.cpp:
(WebCore::ChromeClientQt::canRunBeforeUnloadConfirmPanel):
(WebCore::ChromeClientQt::runBeforeUnloadConfirmPanel):
(WebCore::ChromeClientQt::runJavaScriptAlert):
(WebCore::ChromeClientQt::runJavaScriptConfirm):
(WebCore::ChromeClientQt::runJavaScriptPrompt):
(WebCore::ChromeClientQt::setStatusbarText):
* WebCoreSupport/FrameLoaderClientQt.cpp:
(WebCore::FrameLoaderClientQt::chooseFile):
* WebCoreSupport/FrameLoaderClientQt.h:
2007-06-14 Simon Hausmann <hausmann@kde.org>
Reviewed by Zack.
......
......@@ -29,8 +29,10 @@
#include "ChromeClientQt.h"
#include "Frame.h"
#include "FrameView.h"
#include "FrameLoadRequest.h"
#include "FrameLoader.h"
#include "FrameLoaderClientQt.h"
#include "FrameView.h"
#include "NotImplemented.h"
#include "qwebpage.h"
......@@ -222,14 +224,12 @@ void ChromeClientQt::chromeDestroyed()
bool ChromeClientQt::canRunBeforeUnloadConfirmPanel()
{
notImplemented();
return false;
return true;
}
bool ChromeClientQt::runBeforeUnloadConfirmPanel(const String& message, Frame* frame)
{
notImplemented();
return false;
return runJavaScriptConfirm(frame, message);
}
void ChromeClientQt::closeWindowSoon()
......@@ -237,27 +237,33 @@ void ChromeClientQt::closeWindowSoon()
notImplemented();
}
void ChromeClientQt::runJavaScriptAlert(Frame*, const String& msg)
void ChromeClientQt::runJavaScriptAlert(Frame* f, const String& msg)
{
QString x = msg;
m_webPage->runJavaScriptAlert(0, x);
FrameLoaderClientQt *fl = static_cast<FrameLoaderClientQt*>(f->loader()->client());
m_webPage->javaScriptAlert(fl->webFrame(), x);
}
bool ChromeClientQt::runJavaScriptConfirm(Frame*, const String&)
bool ChromeClientQt::runJavaScriptConfirm(Frame* f, const String& msg)
{
notImplemented();
return false;
QString x = msg;
FrameLoaderClientQt *fl = static_cast<FrameLoaderClientQt*>(f->loader()->client());
return m_webPage->javaScriptConfirm(fl->webFrame(), x);
}
bool ChromeClientQt::runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result)
bool ChromeClientQt::runJavaScriptPrompt(Frame* f, const String& message, const String& defaultValue, String& result)
{
notImplemented();
return false;
QString x = result;
FrameLoaderClientQt *fl = static_cast<FrameLoaderClientQt*>(f->loader()->client());
bool rc = m_webPage->javaScriptPrompt(fl->webFrame(), (QString)message, (QString)defaultValue, &x);
result = x;
return rc;
}
void ChromeClientQt::setStatusbarText(const String&)
void ChromeClientQt::setStatusbarText(const String& msg)
{
notImplemented();
QString x = msg;
emit m_webPage->statusBarTextChanged(x);
}
bool ChromeClientQt::shouldInterruptJavaScript()
......
......@@ -948,4 +948,9 @@ String FrameLoaderClientQt::overrideMediaType() const
return String();
}
QString FrameLoaderClientQt::chooseFile(const QString& oldFile)
{
return webFrame()->page()->chooseFile(webFrame(), oldFile);
}
}
......@@ -222,6 +222,8 @@ namespace WebCore {
virtual void windowObjectCleared() const;
QString chooseFile(const QString& oldFile);
private:
Frame *m_frame;
QWebFrame *m_webFrame;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment