[Webkit-unassigned] [Bug 32925] [Qt] Add Open File dialog to QtLauncher
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Tue Dec 29 07:17:09 PST 2009
https://bugs.webkit.org/show_bug.cgi?id=32925
--- Comment #4 from Simon Hausmann <hausmann at webkit.org> 2009-12-29 07:17:09 PST ---
(From update of attachment 45480)
> + QFileDialog fileDialog(this, tr("Open"), "", filter);
Please use QString() instead of "".
> + fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
> + fileDialog.setFileMode(QFileDialog::ExistingFile);
> + fileDialog.setOptions(QFileDialog::ReadOnly);
> +
> + if (fileDialog.exec()) {
> + QString selectedFile = fileDialog.selectedFiles()[0];
> + if (!selectedFile.isEmpty()) {
> + QUrl fileURL("file://" + selectedFile);
This should be done using QUrl::fromLocalFile instead, to convert slashes
correctly, support drives on Windows and support spaces in filenames, etc.
> + void loadURL(const QUrl& url)
> + {
> + if (!url.isValid())
> + return;
> +
> + urlEdit->setText(url.toEncoded());
That doesn't look correct. toEncoded() returns a QByteArray, urlEdit takes a
QString. The conversion from a QByteArray to a QString must be done using a
known encoding. It seems the use of toString() would be better.
> + view->load(url);
> + view->setFocus(Qt::OtherFocusReason);
> + }
> +
> // create the status bar, tool bar & menu
> void setupUI()
> {
> @@ -515,6 +539,7 @@ private:
>
> QMenu* fileMenu = menuBar()->addMenu("&File");
> QAction* newWindow = fileMenu->addAction("New Window", this, SLOT(newWindow()));
> + fileMenu->addAction(tr("Open File..."), this, SLOT(openFile()), QKeySequence(Qt::CTRL | Qt::Key_O));
> fileMenu->addAction(tr("Print"), this, SLOT(print()), QKeySequence::Print);
> QAction* screenshot = fileMenu->addAction("Screenshot", this, SLOT(screenshot()));
> fileMenu->addAction("Close", this, SLOT(close()));
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list