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
1=== modified file 'src/CMakeLists.txt'
2--- src/CMakeLists.txt 2013-09-25 23:08:08 +0000
3+++ src/CMakeLists.txt 2014-01-08 13:41:19 +0000
4@@ -24,7 +24,7 @@
5 ${mediaplayer_SRCS}
6 )
7
8-qt5_use_modules(${MEDIAPLAYER} Gui Core Qml Quick Multimedia)
9+qt5_use_modules(${MEDIAPLAYER} Gui Widgets Core Qml Quick Multimedia)
10
11 target_link_libraries(${MEDIAPLAYER}
12 sdkhelper
13
14=== modified file 'src/mediaplayer.cpp'
15--- src/mediaplayer.cpp 2014-01-07 23:19:30 +0000
16+++ src/mediaplayer.cpp 2014-01-08 13:41:19 +0000
17@@ -24,6 +24,8 @@
18 #include <QtCore/QStringList>
19 #include <QtCore/QLibrary>
20 #include <QtCore/QTimer>
21+#include <QtCore/QStandardPaths>
22+#include <QtWidgets/QFileDialog>
23 #include <QtQml/QQmlContext>
24 #include <QtQml/QQmlEngine>
25 #include <QtQuick/QQuickItem>
26@@ -43,7 +45,7 @@
27 }
28
29 MediaPlayer::MediaPlayer(int &argc, char **argv)
30- : QGuiApplication(argc, argv), m_view(0)
31+ : QApplication(argc, argv), m_view(0), m_fileChooser(0)
32 {
33 }
34
35@@ -116,7 +118,7 @@
36 connect(m_view->engine(), SIGNAL(quit()), SLOT(quit()));
37
38 // Set the orientation changes that this app is interested in being signaled about
39- QGuiApplication::primaryScreen()->setOrientationUpdateMask(Qt::PortraitOrientation |
40+ QApplication::primaryScreen()->setOrientationUpdateMask(Qt::PortraitOrientation |
41 Qt::LandscapeOrientation |
42 Qt::InvertedPortraitOrientation |
43 Qt::InvertedLandscapeOrientation);
44@@ -139,6 +141,10 @@
45 if (m_view) {
46 delete m_view;
47 }
48+ if (m_fileChooser) {
49+ delete m_fileChooser;
50+ m_fileChooser = 0;
51+ }
52 }
53
54 void
55@@ -175,3 +181,28 @@
56 {
57 return (qEnvironmentVariableIsSet("DESKTOP_MODE") && (qgetenv("DESKTOP_MODE") == "1"));
58 }
59+
60+QUrl MediaPlayer::chooseFile()
61+{
62+ QUrl fileName;
63+ if (!m_fileChooser) {
64+ m_fileChooser = new QFileDialog(0,
65+ tr("Open Video"),
66+ QStandardPaths::writableLocation(QStandardPaths::MoviesLocation),
67+ tr("Video files (*.avi *.mov *.mp4 *.divx *.ogg *.ogv *.mpeg);;All files (*)"));
68+ m_fileChooser->setModal(true);
69+ int result = m_fileChooser->exec();
70+ if (result == QDialog::Accepted) {
71+ QStringList selectedFiles = m_fileChooser->selectedFiles();
72+ if (selectedFiles.count() > 0) {
73+ fileName = selectedFiles[0];
74+ }
75+ }
76+ delete m_fileChooser;
77+ m_fileChooser = 0;
78+ } else {
79+ m_fileChooser->raise();
80+ }
81+
82+ return fileName;
83+}
84
85=== modified file 'src/mediaplayer.h'
86--- src/mediaplayer.h 2014-01-07 23:19:30 +0000
87+++ src/mediaplayer.h 2014-01-08 13:41:19 +0000
88@@ -18,9 +18,11 @@
89 #define MEDIAPLAYER_H
90
91 #include <QtQuick/QQuickView>
92-#include <QGuiApplication>
93+#include <QtWidgets/QApplication>
94+#include <QtWidgets/QFileDialog>
95+#include <QUrl>
96
97-class MediaPlayer : public QGuiApplication
98+class MediaPlayer : public QApplication
99 {
100 Q_OBJECT
101 Q_PROPERTY(bool desktopMode READ isDesktopMode)
102@@ -37,9 +39,11 @@
103 void onWidthChanged(int);
104 void onHeightChanged(int);
105 bool isDesktopMode() const;
106+ QUrl chooseFile();
107
108 private:
109 QQuickView *m_view;
110+ QFileDialog *m_fileChooser;
111 };
112
113 #endif // MEDIAPLAYER_H
114
115=== modified file 'src/qml/player.qml'
116--- src/qml/player.qml 2014-01-07 17:28:00 +0000
117+++ src/qml/player.qml 2014-01-08 13:41:19 +0000
118@@ -26,6 +26,7 @@
119 import Ubuntu.Components 0.1
120 import Ubuntu.Components.Popups 0.1 as Popups
121
122+
123 Rectangle {
124 id: mediaPlayer
125 width: screenWidth
126@@ -76,6 +77,7 @@
127
128 Loader {
129 id: playerLoader
130+
131 source: "player/VideoPlayer.qml"
132 focus: true
133 anchors.fill: parent
134@@ -86,12 +88,18 @@
135 if (playUri != "") {
136 item.playUri(playUri)
137 } else {
138- PopupUtils.open(dialogNoUrl, null)
139+ if (mpApplication.desktopMode) {
140+ var videoFile = mpApplication.chooseFile()
141+ if (videoFile != "") {
142+ item.playUri(videoFile)
143+ }
144+ } else {
145+ PopupUtils.open(dialogNoUrl, null)
146+ }
147 }
148 }
149
150 state: mediaPlayer.orientation != "" ? mediaPlayer.orientation : (screenHeight <= screenWidth ? "0" : "270")
151-
152 Component.onCompleted: {
153 state = Qt.binding(function () {
154 return mediaPlayer.orientation != "" ? mediaPlayer.orientation : (screenHeight <= screenWidth ? "0" : "270")
155
156=== modified file 'src/qml/player/Controls.qml'
157--- src/qml/player/Controls.qml 2013-12-20 20:04:41 +0000
158+++ src/qml/player/Controls.qml 2014-01-08 13:41:19 +0000
159@@ -30,6 +30,8 @@
160 property alias sceneSelectorVisible: _sceneSelector.visible
161 property int heightOffset: 0
162
163+ property alias settingsEnabled: _settingsButton.enabled
164+
165 signal fullscreenClicked
166 signal playbackClicked
167 signal settingsClicked
168@@ -188,7 +190,6 @@
169 maximumValue: video ? video.duration / 1000 : 0
170 value: video ? video.position / 1000 : 0
171
172-
173 // pause the video during the seek
174 onPressedChanged: {
175 if (!pressed && seeking) {
176@@ -255,7 +256,7 @@
177 width: units.gu(9)
178 height: units.gu(3)
179 enabled: false
180- opacity: 0.2
181+ opacity: enabled ? 1.0 : 0.2
182
183 onClicked: settingsClicked()
184 }
185
186=== modified file 'src/qml/player/VideoPlayer.qml'
187--- src/qml/player/VideoPlayer.qml 2014-01-07 23:19:30 +0000
188+++ src/qml/player/VideoPlayer.qml 2014-01-08 13:41:19 +0000
189@@ -101,6 +101,8 @@
190
191 property bool isPaused: false
192
193+ settingsEnabled: mpApplication.desktopMode
194+
195 objectName: "controls"
196 state: player.state
197 video: player.video
198@@ -139,6 +141,15 @@
199 }
200
201 onShareClicked: player.startSharing()
202+ onSettingsClicked: {
203+ if (mpApplication.desktopMode) {
204+ var videoFile = mpApplication.chooseFile()
205+ if (videoFile != "") {
206+ player.stop()
207+ item.playUri(videoFile)
208+ }
209+ }
210+ }
211 }
212 }
213

Subscribers

People subscribed via source and target branches