Skip to content

Commit

Permalink
support attaching file to HTML5 input with multiple attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
hubertlepicki committed Jul 20, 2011
1 parent a449008 commit 0c8e347
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/WebPage.cpp
Expand Up @@ -137,7 +137,18 @@ QString WebPage::chooseFile(QWebFrame *parentFrame, const QString &suggestedFile
Q_UNUSED(parentFrame);
Q_UNUSED(suggestedFile);

QString javascript = QString("Capybara.lastAttachedFile");
return currentFrame()->evaluateJavaScript(javascript).toString();
return getLastAttachedFileName();
}

bool WebPage::extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output) {
if (extension == ChooseMultipleFilesExtension) {
QStringList names = QStringList() << getLastAttachedFileName();
static_cast<ChooseMultipleFilesExtensionReturn*>(output)->fileNames = names;
return true;
}
return false;
}

QString WebPage::getLastAttachedFileName() {
return currentFrame()->evaluateJavaScript(QString("Capybara.lastAttachedFile")).toString();
}
2 changes: 2 additions & 0 deletions src/WebPage.h
Expand Up @@ -11,6 +11,7 @@ class WebPage : public QWebPage {
QString userAgentForUrl(const QUrl &url ) const;
void setUserAgent(QString userAgent);
bool render(const QString &fileName);
virtual bool extension (Extension extension, const ExtensionOption *option=0, ExtensionReturn *output=0);

public slots:
bool shouldInterruptJavaScript();
Expand All @@ -31,5 +32,6 @@ class WebPage : public QWebPage {
QString m_capybaraJavascript;
QString m_userAgent;
bool m_loading;
QString getLastAttachedFileName();
};

0 comments on commit 0c8e347

Please sign in to comment.