Skip to content
Snippets Groups Projects
Commit f7d4afc8 authored by Simon Latapie's avatar Simon Latapie Committed by Jean-Baptiste Kempf
Browse files

doc: QtPlayer: fix file opening on Windows

Using a raw path from the QFileDialog can lead to wrong native
separators in the provided string.
Using URLs instead of paths should be more cross-platform compliant.
parent f808bdd6
No related branches found
No related tags found
1 merge request!3435doc: QtPlayer: fix file opening on Windows
Pipeline #325499 passed with stage
in 17 minutes and 22 seconds
......@@ -17,6 +17,7 @@
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QFileDialog>
#include <QUrl>
Mwindow::Mwindow() {
vlcPlayer = NULL;
......@@ -125,14 +126,14 @@ void Mwindow::initUI() {
void Mwindow::openFile() {
/* The basic file-select box */
QString fileOpen = QFileDialog::getOpenFileName(this, tr("Load a file"), "~");
QUrl url = QFileDialog::getOpenFileUrl(this, tr("Load a file"));
/* Stop if something is playing */
if (vlcPlayer && libvlc_media_player_is_playing(vlcPlayer))
stop();
/* Create a new Media */
libvlc_media_t *vlcMedia = libvlc_media_new_path(qtu(fileOpen));
libvlc_media_t *vlcMedia = libvlc_media_new_location(qtu(url.toString(QUrl::FullyEncoded)));
if (!vlcMedia)
return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment