Merge lp:~renatofilho/mediaplayer-app/open-file-dialog into lp:mediaplayer-app

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Francis Ginther
Approved revision: 195
Merged at revision: 192
Proposed branch: lp:~renatofilho/mediaplayer-app/open-file-dialog
Merge into: lp:mediaplayer-app
Prerequisite: lp:~renatofilho/mediaplayer-app/no-fullscreen
Diff against target: 212 lines (+64/-9)
6 files modified
src/CMakeLists.txt (+1/-1)
src/mediaplayer.cpp (+33/-2)
src/mediaplayer.h (+6/-2)
src/qml/player.qml (+10/-2)
src/qml/player/Controls.qml (+3/-2)
src/qml/player/VideoPlayer.qml (+11/-0)
To merge this branch: bzr merge lp:~renatofilho/mediaplayer-app/open-file-dialog
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Bill Filler (community) Approve
Review via email: mp+200728@code.launchpad.net

This proposal supersedes a proposal from 2014-01-07.

Commit message

Implemented open file dialog to open a new video.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote :

works much better, but weird now the file dialog looks much different than before. it's not the system one anymore but instead the Qt looking one. Not sure why this happened, maybe it happened because of add the additional file name filter?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote :

moving back to the QFileDialog::getOpenFileName() makes the problems occur for me again. It worked fine in Rev 193. I think we should go back to that for now.

review: Needs Fixing
Revision history for this message
Bill Filler (bfiller) wrote :

tested, works

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2013-09-25 23:08:08 +0000
+++ src/CMakeLists.txt 2014-01-08 13:41:19 +0000
@@ -24,7 +24,7 @@
24 ${mediaplayer_SRCS}24 ${mediaplayer_SRCS}
25 )25 )
2626
27qt5_use_modules(${MEDIAPLAYER} Gui Core Qml Quick Multimedia)27qt5_use_modules(${MEDIAPLAYER} Gui Widgets Core Qml Quick Multimedia)
2828
29target_link_libraries(${MEDIAPLAYER}29target_link_libraries(${MEDIAPLAYER}
30 sdkhelper30 sdkhelper
3131
=== modified file 'src/mediaplayer.cpp'
--- src/mediaplayer.cpp 2014-01-07 23:19:30 +0000
+++ src/mediaplayer.cpp 2014-01-08 13:41:19 +0000
@@ -24,6 +24,8 @@
24#include <QtCore/QStringList>24#include <QtCore/QStringList>
25#include <QtCore/QLibrary>25#include <QtCore/QLibrary>
26#include <QtCore/QTimer>26#include <QtCore/QTimer>
27#include <QtCore/QStandardPaths>
28#include <QtWidgets/QFileDialog>
27#include <QtQml/QQmlContext>29#include <QtQml/QQmlContext>
28#include <QtQml/QQmlEngine>30#include <QtQml/QQmlEngine>
29#include <QtQuick/QQuickItem>31#include <QtQuick/QQuickItem>
@@ -43,7 +45,7 @@
43}45}
4446
45MediaPlayer::MediaPlayer(int &argc, char **argv)47MediaPlayer::MediaPlayer(int &argc, char **argv)
46 : QGuiApplication(argc, argv), m_view(0)48 : QApplication(argc, argv), m_view(0), m_fileChooser(0)
47{49{
48}50}
4951
@@ -116,7 +118,7 @@
116 connect(m_view->engine(), SIGNAL(quit()), SLOT(quit()));118 connect(m_view->engine(), SIGNAL(quit()), SLOT(quit()));
117119
118 // Set the orientation changes that this app is interested in being signaled about120 // Set the orientation changes that this app is interested in being signaled about
119 QGuiApplication::primaryScreen()->setOrientationUpdateMask(Qt::PortraitOrientation |121 QApplication::primaryScreen()->setOrientationUpdateMask(Qt::PortraitOrientation |
120 Qt::LandscapeOrientation |122 Qt::LandscapeOrientation |
121 Qt::InvertedPortraitOrientation |123 Qt::InvertedPortraitOrientation |
122 Qt::InvertedLandscapeOrientation);124 Qt::InvertedLandscapeOrientation);
@@ -139,6 +141,10 @@
139 if (m_view) {141 if (m_view) {
140 delete m_view;142 delete m_view;
141 }143 }
144 if (m_fileChooser) {
145 delete m_fileChooser;
146 m_fileChooser = 0;
147 }
142}148}
143149
144void150void
@@ -175,3 +181,28 @@
175{181{
176 return (qEnvironmentVariableIsSet("DESKTOP_MODE") && (qgetenv("DESKTOP_MODE") == "1"));182 return (qEnvironmentVariableIsSet("DESKTOP_MODE") && (qgetenv("DESKTOP_MODE") == "1"));
177}183}
184
185QUrl MediaPlayer::chooseFile()
186{
187 QUrl fileName;
188 if (!m_fileChooser) {
189 m_fileChooser = new QFileDialog(0,
190 tr("Open Video"),
191 QStandardPaths::writableLocation(QStandardPaths::MoviesLocation),
192 tr("Video files (*.avi *.mov *.mp4 *.divx *.ogg *.ogv *.mpeg);;All files (*)"));
193 m_fileChooser->setModal(true);
194 int result = m_fileChooser->exec();
195 if (result == QDialog::Accepted) {
196 QStringList selectedFiles = m_fileChooser->selectedFiles();
197 if (selectedFiles.count() > 0) {
198 fileName = selectedFiles[0];
199 }
200 }
201 delete m_fileChooser;
202 m_fileChooser = 0;
203 } else {
204 m_fileChooser->raise();
205 }
206
207 return fileName;
208}
178209
=== modified file 'src/mediaplayer.h'
--- src/mediaplayer.h 2014-01-07 23:19:30 +0000
+++ src/mediaplayer.h 2014-01-08 13:41:19 +0000
@@ -18,9 +18,11 @@
18#define MEDIAPLAYER_H18#define MEDIAPLAYER_H
1919
20#include <QtQuick/QQuickView>20#include <QtQuick/QQuickView>
21#include <QGuiApplication>21#include <QtWidgets/QApplication>
22#include <QtWidgets/QFileDialog>
23#include <QUrl>
2224
23class MediaPlayer : public QGuiApplication25class MediaPlayer : public QApplication
24{26{
25 Q_OBJECT27 Q_OBJECT
26 Q_PROPERTY(bool desktopMode READ isDesktopMode)28 Q_PROPERTY(bool desktopMode READ isDesktopMode)
@@ -37,9 +39,11 @@
37 void onWidthChanged(int);39 void onWidthChanged(int);
38 void onHeightChanged(int);40 void onHeightChanged(int);
39 bool isDesktopMode() const;41 bool isDesktopMode() const;
42 QUrl chooseFile();
4043
41private:44private:
42 QQuickView *m_view;45 QQuickView *m_view;
46 QFileDialog *m_fileChooser;
43};47};
4448
45#endif // MEDIAPLAYER_H49#endif // MEDIAPLAYER_H
4650
=== modified file 'src/qml/player.qml'
--- src/qml/player.qml 2014-01-07 17:28:00 +0000
+++ src/qml/player.qml 2014-01-08 13:41:19 +0000
@@ -26,6 +26,7 @@
26import Ubuntu.Components 0.126import Ubuntu.Components 0.1
27import Ubuntu.Components.Popups 0.1 as Popups27import Ubuntu.Components.Popups 0.1 as Popups
2828
29
29Rectangle {30Rectangle {
30 id: mediaPlayer31 id: mediaPlayer
31 width: screenWidth32 width: screenWidth
@@ -76,6 +77,7 @@
7677
77 Loader {78 Loader {
78 id: playerLoader79 id: playerLoader
80
79 source: "player/VideoPlayer.qml"81 source: "player/VideoPlayer.qml"
80 focus: true82 focus: true
81 anchors.fill: parent83 anchors.fill: parent
@@ -86,12 +88,18 @@
86 if (playUri != "") {88 if (playUri != "") {
87 item.playUri(playUri)89 item.playUri(playUri)
88 } else {90 } else {
89 PopupUtils.open(dialogNoUrl, null)91 if (mpApplication.desktopMode) {
92 var videoFile = mpApplication.chooseFile()
93 if (videoFile != "") {
94 item.playUri(videoFile)
95 }
96 } else {
97 PopupUtils.open(dialogNoUrl, null)
98 }
90 }99 }
91 }100 }
92101
93 state: mediaPlayer.orientation != "" ? mediaPlayer.orientation : (screenHeight <= screenWidth ? "0" : "270")102 state: mediaPlayer.orientation != "" ? mediaPlayer.orientation : (screenHeight <= screenWidth ? "0" : "270")
94
95 Component.onCompleted: {103 Component.onCompleted: {
96 state = Qt.binding(function () {104 state = Qt.binding(function () {
97 return mediaPlayer.orientation != "" ? mediaPlayer.orientation : (screenHeight <= screenWidth ? "0" : "270")105 return mediaPlayer.orientation != "" ? mediaPlayer.orientation : (screenHeight <= screenWidth ? "0" : "270")
98106
=== modified file 'src/qml/player/Controls.qml'
--- src/qml/player/Controls.qml 2013-12-20 20:04:41 +0000
+++ src/qml/player/Controls.qml 2014-01-08 13:41:19 +0000
@@ -30,6 +30,8 @@
30 property alias sceneSelectorVisible: _sceneSelector.visible30 property alias sceneSelectorVisible: _sceneSelector.visible
31 property int heightOffset: 031 property int heightOffset: 0
3232
33 property alias settingsEnabled: _settingsButton.enabled
34
33 signal fullscreenClicked35 signal fullscreenClicked
34 signal playbackClicked36 signal playbackClicked
35 signal settingsClicked37 signal settingsClicked
@@ -188,7 +190,6 @@
188 maximumValue: video ? video.duration / 1000 : 0190 maximumValue: video ? video.duration / 1000 : 0
189 value: video ? video.position / 1000 : 0191 value: video ? video.position / 1000 : 0
190192
191
192 // pause the video during the seek193 // pause the video during the seek
193 onPressedChanged: {194 onPressedChanged: {
194 if (!pressed && seeking) {195 if (!pressed && seeking) {
@@ -255,7 +256,7 @@
255 width: units.gu(9)256 width: units.gu(9)
256 height: units.gu(3)257 height: units.gu(3)
257 enabled: false258 enabled: false
258 opacity: 0.2259 opacity: enabled ? 1.0 : 0.2
259260
260 onClicked: settingsClicked()261 onClicked: settingsClicked()
261 }262 }
262263
=== modified file 'src/qml/player/VideoPlayer.qml'
--- src/qml/player/VideoPlayer.qml 2014-01-07 23:19:30 +0000
+++ src/qml/player/VideoPlayer.qml 2014-01-08 13:41:19 +0000
@@ -101,6 +101,8 @@
101101
102 property bool isPaused: false102 property bool isPaused: false
103103
104 settingsEnabled: mpApplication.desktopMode
105
104 objectName: "controls"106 objectName: "controls"
105 state: player.state107 state: player.state
106 video: player.video108 video: player.video
@@ -139,6 +141,15 @@
139 }141 }
140142
141 onShareClicked: player.startSharing()143 onShareClicked: player.startSharing()
144 onSettingsClicked: {
145 if (mpApplication.desktopMode) {
146 var videoFile = mpApplication.chooseFile()
147 if (videoFile != "") {
148 player.stop()
149 item.playUri(videoFile)
150 }
151 }
152 }
142 }153 }
143 }154 }
144155

Subscribers

People subscribed via source and target branches