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.
This commit is contained in:
Simon Latapie 2023-03-17 16:54:48 +01:00 committed by Jean-Baptiste Kempf
parent f808bdd6b8
commit f7d4afc821
1 changed files with 3 additions and 2 deletions

View File

@ -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;