Merge lp:camera-app/staging into lp:camera-app
- staging
- Merge into trunk
Status: | Merged | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Approved by: | Florian Boucault | ||||||||||||||||||||||||||||||||
Approved revision: | 658 | ||||||||||||||||||||||||||||||||
Merged at revision: | 636 | ||||||||||||||||||||||||||||||||
Proposed branch: | lp:camera-app/staging | ||||||||||||||||||||||||||||||||
Merge into: | lp:camera-app | ||||||||||||||||||||||||||||||||
Diff against target: |
2752 lines (+657/-1424) 31 files modified
BottomEdgeIndicators.qml (+1/-1) CameraApp/CMakeLists.txt (+2/-4) CameraApp/advancedcamerasettings.cpp (+3/-3) CameraApp/components.cpp (+9/-0) CameraApp/qstorageinfo.cpp (+0/-378) CameraApp/qstorageinfo.h (+0/-102) CameraApp/qstorageinfo_p.h (+0/-84) CameraApp/qstorageinfo_unix.cpp (+0/-442) CameraApp/storagelocations.cpp (+121/-0) CameraApp/storagelocations.h (+50/-0) CameraApp/storagemonitor.cpp (+34/-1) CameraApp/storagemonitor.h (+5/-0) GalleryView.qml (+3/-3) GalleryViewHeader.qml (+3/-3) PictureReview.qml (+46/-0) ProcessingFeedback.qml (+43/-0) SharePopover.qml (+1/-9) Snapshot.qml (+0/-98) ViewFinderExportConfirmation.qml (+40/-21) ViewFinderOverlay.qml (+103/-40) ViewFinderOverlayLoader.qml (+4/-1) ViewFinderView.qml (+112/-65) cameraapplication.cpp (+0/-106) cameraapplication.h (+0/-15) debian/rules (+0/-4) manifest.json.in (+1/-1) run_tests.sh (+0/-13) tests/autopilot/camera_app/tests/test_focus.py (+32/-28) tests/autopilot/camera_app/tests/test_options.py (+27/-0) tests/unittests/CMakeLists.txt (+1/-0) tests/unittests/qstorageinfo_stub.cpp (+16/-2) |
||||||||||||||||||||||||||||||||
To merge this branch: | bzr merge lp:camera-app/staging | ||||||||||||||||||||||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Needs Fixing | |
Ubuntu Phablet Team | Pending | ||
Review via email: mp+284427@code.launchpad.net |
Commit message
New release:
- Allow tap to focus up to the left/right edge of the screen
- Query the manual focus support to enable/disable tap-to-focus as the backend supports it
- Do not crash if no QCameraExposure
- Before setting a photo capture resolution, always checks it is included in the possible resolution options
- Fix bottom edge mouse handling: ensure that clicks on the bottom edge open it and that any click outside of option buttons dismiss the bottom edge
- Various performance improvements to minimize the time between shots and between pressing the shutter button and the actual capture
- When the GPS fix is accurate to less than 100m display the GPS icon in red and don't save location
- Display error messages when disk write fails and when SD card is not writeable when switching to it
- Disable record/shuttle button while PhotoRoll hint is visible
Description of the change
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:643
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:651
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:656
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:658
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 659. By Florian Boucault
-
Add flake8 tests to unit tests
Preview Diff
1 | === modified file 'BottomEdgeIndicators.qml' | |||
2 | --- BottomEdgeIndicators.qml 2015-11-17 15:25:03 +0000 | |||
3 | +++ BottomEdgeIndicators.qml 2016-02-26 17:17:00 +0000 | |||
4 | @@ -83,7 +83,7 @@ | |||
5 | 83 | Icon { | 83 | Icon { |
6 | 84 | id: indicatorIcon | 84 | id: indicatorIcon |
7 | 85 | anchors.fill: parent | 85 | anchors.fill: parent |
9 | 86 | color: "white" | 86 | color: modelData.colorize ? "red" : "white" |
10 | 87 | name: modelData && modelData.isToggle ? modelData.icon : (modelData.get(model.selectedIndex) ? modelData.get(model.selectedIndex).icon : "") | 87 | name: modelData && modelData.isToggle ? modelData.icon : (modelData.get(model.selectedIndex) ? modelData.get(model.selectedIndex).icon : "") |
11 | 88 | source: name ? "image://theme/%1".arg(name) : (modelData.iconSource || "") | 88 | source: name ? "image://theme/%1".arg(name) : (modelData.iconSource || "") |
12 | 89 | visible: source != "" | 89 | visible: source != "" |
13 | 90 | 90 | ||
14 | === modified file 'CameraApp/CMakeLists.txt' | |||
15 | --- CameraApp/CMakeLists.txt 2015-11-18 06:44:35 +0000 | |||
16 | +++ CameraApp/CMakeLists.txt 2016-02-26 17:17:00 +0000 | |||
17 | @@ -7,8 +7,7 @@ | |||
18 | 7 | fileoperations.cpp | 7 | fileoperations.cpp |
19 | 8 | foldersmodel.cpp | 8 | foldersmodel.cpp |
20 | 9 | storagemonitor.cpp | 9 | storagemonitor.cpp |
23 | 10 | qstorageinfo.cpp | 10 | storagelocations.cpp |
22 | 11 | qstorageinfo_unix.cpp | ||
24 | 12 | ) | 11 | ) |
25 | 13 | 12 | ||
26 | 14 | set(plugin_HDRS | 13 | set(plugin_HDRS |
27 | @@ -17,8 +16,7 @@ | |||
28 | 17 | fileoperations.h | 16 | fileoperations.h |
29 | 18 | foldersmodel.h | 17 | foldersmodel.h |
30 | 19 | storagemonitor.h | 18 | storagemonitor.h |
33 | 20 | qstorageinfo.h | 19 | storagelocations.h |
32 | 21 | qstorageinfo_p.h | ||
34 | 22 | ) | 20 | ) |
35 | 23 | 21 | ||
36 | 24 | add_library(camera-qml SHARED ${plugin_SRCS} ${plugin_HDRS}) | 22 | add_library(camera-qml SHARED ${plugin_SRCS} ${plugin_HDRS}) |
37 | 25 | 23 | ||
38 | === modified file 'CameraApp/advancedcamerasettings.cpp' | |||
39 | --- CameraApp/advancedcamerasettings.cpp 2016-01-05 13:08:28 +0000 | |||
40 | +++ CameraApp/advancedcamerasettings.cpp 2016-02-26 17:17:00 +0000 | |||
41 | @@ -237,11 +237,11 @@ | |||
42 | 237 | 237 | ||
43 | 238 | m_cameraFlashControl = flashControlFromCamera(m_camera); | 238 | m_cameraFlashControl = flashControlFromCamera(m_camera); |
44 | 239 | m_cameraExposureControl = exposureControlFromCamera(m_camera); | 239 | m_cameraExposureControl = exposureControlFromCamera(m_camera); |
45 | 240 | QVariant exposureMode = m_hdrEnabled ? QVariant::fromValue(ExposureHdr) | ||
46 | 241 | : QVariant::fromValue(QCameraExposure::ExposureAuto); | ||
47 | 242 | m_cameraExposureControl->setValue(QCameraExposureControl::ExposureMode, exposureMode); | ||
48 | 243 | 240 | ||
49 | 244 | if (m_cameraExposureControl) { | 241 | if (m_cameraExposureControl) { |
50 | 242 | QVariant exposureMode = m_hdrEnabled ? QVariant::fromValue(ExposureHdr) | ||
51 | 243 | : QVariant::fromValue(QCameraExposure::ExposureAuto); | ||
52 | 244 | m_cameraExposureControl->setValue(QCameraExposureControl::ExposureMode, exposureMode); | ||
53 | 245 | QObject::connect(m_cameraExposureControl, | 245 | QObject::connect(m_cameraExposureControl, |
54 | 246 | SIGNAL(actualValueChanged(int)), | 246 | SIGNAL(actualValueChanged(int)), |
55 | 247 | this, SLOT(onExposureValueChanged(int))); | 247 | this, SLOT(onExposureValueChanged(int))); |
56 | 248 | 248 | ||
57 | === modified file 'CameraApp/components.cpp' | |||
58 | --- CameraApp/components.cpp 2015-01-22 16:15:08 +0000 | |||
59 | +++ CameraApp/components.cpp 2016-02-26 17:17:00 +0000 | |||
60 | @@ -24,6 +24,14 @@ | |||
61 | 24 | #include "fileoperations.h" | 24 | #include "fileoperations.h" |
62 | 25 | #include "foldersmodel.h" | 25 | #include "foldersmodel.h" |
63 | 26 | #include "storagemonitor.h" | 26 | #include "storagemonitor.h" |
64 | 27 | #include "storagelocations.h" | ||
65 | 28 | |||
66 | 29 | static QObject* StorageLocations_singleton_factory(QQmlEngine* engine, QJSEngine* scriptEngine) | ||
67 | 30 | { | ||
68 | 31 | Q_UNUSED(engine); | ||
69 | 32 | Q_UNUSED(scriptEngine); | ||
70 | 33 | return new StorageLocations(); | ||
71 | 34 | } | ||
72 | 27 | 35 | ||
73 | 28 | void Components::registerTypes(const char *uri) | 36 | void Components::registerTypes(const char *uri) |
74 | 29 | { | 37 | { |
75 | @@ -34,6 +42,7 @@ | |||
76 | 34 | qmlRegisterType<FileOperations>(uri, 0, 1, "FileOperations"); | 42 | qmlRegisterType<FileOperations>(uri, 0, 1, "FileOperations"); |
77 | 35 | qmlRegisterType<FoldersModel>(uri, 0, 1, "FoldersModel"); | 43 | qmlRegisterType<FoldersModel>(uri, 0, 1, "FoldersModel"); |
78 | 36 | qmlRegisterType<StorageMonitor>(uri, 0, 1, "StorageMonitor"); | 44 | qmlRegisterType<StorageMonitor>(uri, 0, 1, "StorageMonitor"); |
79 | 45 | qmlRegisterSingletonType<StorageLocations>(uri, 0, 1, "StorageLocations", StorageLocations_singleton_factory); | ||
80 | 37 | } | 46 | } |
81 | 38 | 47 | ||
82 | 39 | void Components::initializeEngine(QQmlEngine *engine, const char *uri) | 48 | void Components::initializeEngine(QQmlEngine *engine, const char *uri) |
83 | 40 | 49 | ||
84 | === removed file 'CameraApp/qstorageinfo.cpp' | |||
85 | --- CameraApp/qstorageinfo.cpp 2015-01-27 14:34:31 +0000 | |||
86 | +++ CameraApp/qstorageinfo.cpp 1970-01-01 00:00:00 +0000 | |||
87 | @@ -1,378 +0,0 @@ | |||
88 | 1 | /**************************************************************************** | ||
89 | 2 | ** | ||
90 | 3 | ** Copyright (C) 2014 Ivan Komissarov <ABBAPOH@gmail.com> | ||
91 | 4 | ** Contact: http://www.qt-project.org/legal | ||
92 | 5 | ** | ||
93 | 6 | ** This file is part of the QtCore module of the Qt Toolkit. | ||
94 | 7 | ** | ||
95 | 8 | ** This program is free software; you can redistribute it and/or modify | ||
96 | 9 | ** it under the terms of the GNU General Public License as published by | ||
97 | 10 | ** the Free Software Foundation; version 3. | ||
98 | 11 | ** | ||
99 | 12 | ** This program is distributed in the hope that it will be useful, | ||
100 | 13 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
101 | 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
102 | 15 | ** GNU General Public License for more details. | ||
103 | 16 | ** | ||
104 | 17 | ** You should have received a copy of the GNU General Public License | ||
105 | 18 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
106 | 19 | ** | ||
107 | 20 | ****************************************************************************/ | ||
108 | 21 | |||
109 | 22 | #include "qstorageinfo.h" | ||
110 | 23 | #include "qstorageinfo_p.h" | ||
111 | 24 | |||
112 | 25 | QT_BEGIN_NAMESPACE | ||
113 | 26 | |||
114 | 27 | /*! | ||
115 | 28 | \class QStorageInfo | ||
116 | 29 | \inmodule QtCore | ||
117 | 30 | \since 5.4 | ||
118 | 31 | \brief Provides information about currently mounted storage and drives. | ||
119 | 32 | |||
120 | 33 | \ingroup io | ||
121 | 34 | \ingroup shared | ||
122 | 35 | |||
123 | 36 | Allows retrieving information about the volume's space, its mount point, | ||
124 | 37 | label, and filesystem name. | ||
125 | 38 | |||
126 | 39 | You can create an instance of QStorageInfo by passing the path to the | ||
127 | 40 | volume's mount point as a constructor parameter, or you can set it using | ||
128 | 41 | the setPath() method. The static mountedVolumes() method can be used to get the | ||
129 | 42 | list of all mounted filesystems. | ||
130 | 43 | |||
131 | 44 | QStorageInfo always caches the retrieved information, but you can call | ||
132 | 45 | refresh() to invalidate the cache. | ||
133 | 46 | |||
134 | 47 | The following example retrieves the most common information about the root | ||
135 | 48 | volume of the system, and prints information about it. | ||
136 | 49 | |||
137 | 50 | \snippet code/src_corelib_io_qstorageinfo.cpp 2 | ||
138 | 51 | */ | ||
139 | 52 | |||
140 | 53 | /*! | ||
141 | 54 | Constructs an empty QStorageInfo object. | ||
142 | 55 | |||
143 | 56 | Objects created with the default constructor will be invalid and therefore | ||
144 | 57 | not ready for use. | ||
145 | 58 | |||
146 | 59 | \sa setPath(), isReady(), isValid() | ||
147 | 60 | */ | ||
148 | 61 | QStorageInfo::QStorageInfo() | ||
149 | 62 | : d(new QStorageInfoPrivate) | ||
150 | 63 | { | ||
151 | 64 | } | ||
152 | 65 | |||
153 | 66 | /*! | ||
154 | 67 | Constructs a new QStorageInfo object that gives information about the volume | ||
155 | 68 | mounted at \a path. | ||
156 | 69 | |||
157 | 70 | If you pass a directory or file, the QStorageInfo object will refer to the | ||
158 | 71 | volume where this directory or file is located. | ||
159 | 72 | You can check if the created object is correct using the isValid() method. | ||
160 | 73 | |||
161 | 74 | The following example shows how to get the volume on which the application is | ||
162 | 75 | located. It is recommended to always check that the volume is ready and valid. | ||
163 | 76 | |||
164 | 77 | \snippet code/src_corelib_io_qstorageinfo.cpp 0 | ||
165 | 78 | |||
166 | 79 | \sa setPath() | ||
167 | 80 | */ | ||
168 | 81 | QStorageInfo::QStorageInfo(const QString &path) | ||
169 | 82 | : d(new QStorageInfoPrivate) | ||
170 | 83 | { | ||
171 | 84 | setPath(path); | ||
172 | 85 | } | ||
173 | 86 | |||
174 | 87 | /*! | ||
175 | 88 | Constructs a new QStorageInfo object that gives information about the volume | ||
176 | 89 | containing the \a dir folder. | ||
177 | 90 | */ | ||
178 | 91 | QStorageInfo::QStorageInfo(const QDir &dir) | ||
179 | 92 | : d(new QStorageInfoPrivate) | ||
180 | 93 | { | ||
181 | 94 | setPath(dir.absolutePath()); | ||
182 | 95 | } | ||
183 | 96 | |||
184 | 97 | /*! | ||
185 | 98 | Constructs a new QStorageInfo object that is a copy of the \a other QStorageInfo object. | ||
186 | 99 | */ | ||
187 | 100 | QStorageInfo::QStorageInfo(const QStorageInfo &other) | ||
188 | 101 | : d(other.d) | ||
189 | 102 | { | ||
190 | 103 | } | ||
191 | 104 | |||
192 | 105 | /*! | ||
193 | 106 | Destroys the QStorageInfo object and frees its resources. | ||
194 | 107 | */ | ||
195 | 108 | QStorageInfo::~QStorageInfo() | ||
196 | 109 | { | ||
197 | 110 | } | ||
198 | 111 | |||
199 | 112 | /*! | ||
200 | 113 | Makes a copy of the QStorageInfo object \a other and assigns it to this QStorageInfo object. | ||
201 | 114 | */ | ||
202 | 115 | QStorageInfo &QStorageInfo::operator=(const QStorageInfo &other) | ||
203 | 116 | { | ||
204 | 117 | d = other.d; | ||
205 | 118 | return *this; | ||
206 | 119 | } | ||
207 | 120 | |||
208 | 121 | /*! | ||
209 | 122 | \fn QStorageInfo &QStorageInfo::operator=(QStorageInfo &&other) | ||
210 | 123 | |||
211 | 124 | Assigns \a other to this QStorageInfo instance. | ||
212 | 125 | */ | ||
213 | 126 | |||
214 | 127 | /*! | ||
215 | 128 | \fn void QStorageInfo::swap(QStorageInfo &other) | ||
216 | 129 | |||
217 | 130 | Swaps this volume info with \a other. This function is very fast and | ||
218 | 131 | never fails. | ||
219 | 132 | */ | ||
220 | 133 | |||
221 | 134 | /*! | ||
222 | 135 | Sets this QStorageInfo object to the filesystem mounted where \a path is located. | ||
223 | 136 | |||
224 | 137 | \a path can either be a root path of the filesystem, a directory, or a file | ||
225 | 138 | within that filesystem. | ||
226 | 139 | |||
227 | 140 | \sa rootPath() | ||
228 | 141 | */ | ||
229 | 142 | void QStorageInfo::setPath(const QString &path) | ||
230 | 143 | { | ||
231 | 144 | if (d->rootPath == path) | ||
232 | 145 | return; | ||
233 | 146 | d.detach(); | ||
234 | 147 | d->rootPath = path; | ||
235 | 148 | d->doStat(); | ||
236 | 149 | } | ||
237 | 150 | |||
238 | 151 | /*! | ||
239 | 152 | Returns the mount point of the filesystem this QStorageInfo object | ||
240 | 153 | represents. | ||
241 | 154 | |||
242 | 155 | On Windows, it returns the volume letter in case the volume is not mounted to | ||
243 | 156 | a directory. | ||
244 | 157 | |||
245 | 158 | Note that the value returned by rootPath() is the real mount point of a | ||
246 | 159 | volume, and may not be equal to the value passed to the constructor or setPath() | ||
247 | 160 | method. For example, if you have only the root volume in the system, and | ||
248 | 161 | pass '/directory' to setPath(), then this method will return '/'. | ||
249 | 162 | |||
250 | 163 | \sa setPath(), device() | ||
251 | 164 | */ | ||
252 | 165 | QString QStorageInfo::rootPath() const | ||
253 | 166 | { | ||
254 | 167 | return d->rootPath; | ||
255 | 168 | } | ||
256 | 169 | |||
257 | 170 | /*! | ||
258 | 171 | Returns the size (in bytes) available for the current user. It returns | ||
259 | 172 | the total size available if the user is the root user or a system administrator. | ||
260 | 173 | |||
261 | 174 | This size can be less than or equal to the free size returned by | ||
262 | 175 | bytesFree() function. | ||
263 | 176 | |||
264 | 177 | \sa bytesTotal(), bytesFree() | ||
265 | 178 | */ | ||
266 | 179 | qint64 QStorageInfo::bytesAvailable() const | ||
267 | 180 | { | ||
268 | 181 | return d->bytesAvailable; | ||
269 | 182 | } | ||
270 | 183 | |||
271 | 184 | /*! | ||
272 | 185 | Returns the number of free bytes in a volume. Note that if there are | ||
273 | 186 | quotas on the filesystem, this value can be larger than the value | ||
274 | 187 | returned by bytesAvailable(). | ||
275 | 188 | |||
276 | 189 | \sa bytesTotal(), bytesAvailable() | ||
277 | 190 | */ | ||
278 | 191 | qint64 QStorageInfo::bytesFree() const | ||
279 | 192 | { | ||
280 | 193 | return d->bytesFree; | ||
281 | 194 | } | ||
282 | 195 | |||
283 | 196 | /*! | ||
284 | 197 | Returns the total volume size in bytes. | ||
285 | 198 | |||
286 | 199 | \sa bytesFree(), bytesAvailable() | ||
287 | 200 | */ | ||
288 | 201 | qint64 QStorageInfo::bytesTotal() const | ||
289 | 202 | { | ||
290 | 203 | return d->bytesTotal; | ||
291 | 204 | } | ||
292 | 205 | |||
293 | 206 | /*! | ||
294 | 207 | Returns the type name of the filesystem. | ||
295 | 208 | |||
296 | 209 | This is a platform-dependent function, and filesystem names can vary | ||
297 | 210 | between different operating systems. For example, on Windows filesystems | ||
298 | 211 | they can be named \c NTFS, and on Linux they can be named \c ntfs-3g or \c fuseblk. | ||
299 | 212 | |||
300 | 213 | \sa name() | ||
301 | 214 | */ | ||
302 | 215 | QByteArray QStorageInfo::fileSystemType() const | ||
303 | 216 | { | ||
304 | 217 | return d->fileSystemType; | ||
305 | 218 | } | ||
306 | 219 | |||
307 | 220 | /*! | ||
308 | 221 | Returns the device for this volume. | ||
309 | 222 | |||
310 | 223 | For example, on Unix filesystems (including OS X), this returns the | ||
311 | 224 | devpath like \c /dev/sda0 for local storages. On Windows, it returns the UNC | ||
312 | 225 | path starting with \c \\\\?\\ for local storages (in other words, the volume GUID). | ||
313 | 226 | |||
314 | 227 | \sa rootPath() | ||
315 | 228 | */ | ||
316 | 229 | QByteArray QStorageInfo::device() const | ||
317 | 230 | { | ||
318 | 231 | return d->device; | ||
319 | 232 | } | ||
320 | 233 | |||
321 | 234 | /*! | ||
322 | 235 | Returns the human-readable name of a filesystem, usually called \c label. | ||
323 | 236 | |||
324 | 237 | Not all filesystems support this feature. In this case, the value returned by | ||
325 | 238 | this method could be empty. An empty string is returned if the file system | ||
326 | 239 | does not support labels, or if no label is set. | ||
327 | 240 | |||
328 | 241 | On Linux, retrieving the volume's label requires \c udev to be present in the | ||
329 | 242 | system. | ||
330 | 243 | |||
331 | 244 | \sa fileSystemType() | ||
332 | 245 | */ | ||
333 | 246 | QString QStorageInfo::name() const | ||
334 | 247 | { | ||
335 | 248 | return d->name; | ||
336 | 249 | } | ||
337 | 250 | |||
338 | 251 | /*! | ||
339 | 252 | Returns the volume's name, if available, or the root path if not. | ||
340 | 253 | */ | ||
341 | 254 | QString QStorageInfo::displayName() const | ||
342 | 255 | { | ||
343 | 256 | if (!d->name.isEmpty()) | ||
344 | 257 | return d->name; | ||
345 | 258 | return d->rootPath; | ||
346 | 259 | } | ||
347 | 260 | |||
348 | 261 | /*! | ||
349 | 262 | \fn bool QStorageInfo::isRoot() const | ||
350 | 263 | |||
351 | 264 | Returns true if this QStorageInfo represents the system root volume; false | ||
352 | 265 | otherwise. | ||
353 | 266 | |||
354 | 267 | On Unix filesystems, the root volume is a volume mounted on \c /. On Windows, | ||
355 | 268 | the root volume is the volume where the OS is installed. | ||
356 | 269 | |||
357 | 270 | \sa root() | ||
358 | 271 | */ | ||
359 | 272 | |||
360 | 273 | /*! | ||
361 | 274 | Returns true if the current filesystem is protected from writing; false | ||
362 | 275 | otherwise. | ||
363 | 276 | */ | ||
364 | 277 | bool QStorageInfo::isReadOnly() const | ||
365 | 278 | { | ||
366 | 279 | return d->readOnly; | ||
367 | 280 | } | ||
368 | 281 | |||
369 | 282 | /*! | ||
370 | 283 | Returns true if the current filesystem is ready to work; false otherwise. For | ||
371 | 284 | example, false is returned if the CD volume is not inserted. | ||
372 | 285 | |||
373 | 286 | Note that fileSystemType(), name(), bytesTotal(), bytesFree(), and | ||
374 | 287 | bytesAvailable() will return invalid data until the volume is ready. | ||
375 | 288 | |||
376 | 289 | \sa isValid() | ||
377 | 290 | */ | ||
378 | 291 | bool QStorageInfo::isReady() const | ||
379 | 292 | { | ||
380 | 293 | return d->ready; | ||
381 | 294 | } | ||
382 | 295 | |||
383 | 296 | /*! | ||
384 | 297 | Returns true if the QStorageInfo specified by rootPath exists and is mounted | ||
385 | 298 | correctly. | ||
386 | 299 | |||
387 | 300 | \sa isReady() | ||
388 | 301 | */ | ||
389 | 302 | bool QStorageInfo::isValid() const | ||
390 | 303 | { | ||
391 | 304 | return d->valid; | ||
392 | 305 | } | ||
393 | 306 | |||
394 | 307 | /*! | ||
395 | 308 | Resets QStorageInfo's internal cache. | ||
396 | 309 | |||
397 | 310 | QStorageInfo caches information about storage to speed up performance. | ||
398 | 311 | QStorageInfo retrieves information during object construction and/or when calling | ||
399 | 312 | the setPath() method. You have to manually reset the cache by calling this | ||
400 | 313 | function to update storage information. | ||
401 | 314 | */ | ||
402 | 315 | void QStorageInfo::refresh() | ||
403 | 316 | { | ||
404 | 317 | d.detach(); | ||
405 | 318 | d->doStat(); | ||
406 | 319 | } | ||
407 | 320 | |||
408 | 321 | /*! | ||
409 | 322 | Returns the list of QStorageInfo objects that corresponds to the list of currently | ||
410 | 323 | mounted filesystems. | ||
411 | 324 | |||
412 | 325 | On Windows, this returns the drives visible in the \gui{My Computer} folder. On Unix | ||
413 | 326 | operating systems, it returns the list of all mounted filesystems (except for | ||
414 | 327 | pseudo filesystems). | ||
415 | 328 | |||
416 | 329 | Returns all currently mounted filesystems by default. | ||
417 | 330 | |||
418 | 331 | The example shows how to retrieve all available filesystems, skipping read-only ones. | ||
419 | 332 | |||
420 | 333 | \snippet code/src_corelib_io_qstorageinfo.cpp 1 | ||
421 | 334 | |||
422 | 335 | \sa root() | ||
423 | 336 | */ | ||
424 | 337 | QList<QStorageInfo> QStorageInfo::mountedVolumes() | ||
425 | 338 | { | ||
426 | 339 | return QStorageInfoPrivate::mountedVolumes(); | ||
427 | 340 | } | ||
428 | 341 | |||
429 | 342 | Q_GLOBAL_STATIC_WITH_ARGS(QStorageInfo, getRoot, (QStorageInfoPrivate::root())) | ||
430 | 343 | |||
431 | 344 | /*! | ||
432 | 345 | Returns a QStorageInfo object that represents the system root volume. | ||
433 | 346 | |||
434 | 347 | On Unix systems this call returns the root ('/') volume; in Windows the volume where | ||
435 | 348 | the operating system is installed. | ||
436 | 349 | |||
437 | 350 | \sa isRoot() | ||
438 | 351 | */ | ||
439 | 352 | QStorageInfo QStorageInfo::root() | ||
440 | 353 | { | ||
441 | 354 | return *getRoot(); | ||
442 | 355 | } | ||
443 | 356 | |||
444 | 357 | /*! | ||
445 | 358 | \fn inline bool operator==(const QStorageInfo &first, const QStorageInfo &second) | ||
446 | 359 | |||
447 | 360 | \relates QStorageInfo | ||
448 | 361 | |||
449 | 362 | Returns true if the \a first QStorageInfo object refers to the same drive or volume | ||
450 | 363 | as the \a second; otherwise it returns false. | ||
451 | 364 | |||
452 | 365 | Note that the result of comparing two invalid QStorageInfo objects is always | ||
453 | 366 | positive. | ||
454 | 367 | */ | ||
455 | 368 | |||
456 | 369 | /*! | ||
457 | 370 | \fn inline bool operator!=(const QStorageInfo &first, const QStorageInfo &second) | ||
458 | 371 | |||
459 | 372 | \relates QStorageInfo | ||
460 | 373 | |||
461 | 374 | Returns true if the \a first QStorageInfo object refers to a different drive or | ||
462 | 375 | volume than the \a second; otherwise returns false. | ||
463 | 376 | */ | ||
464 | 377 | |||
465 | 378 | QT_END_NAMESPACE | ||
466 | 379 | 0 | ||
467 | === removed file 'CameraApp/qstorageinfo.h' | |||
468 | --- CameraApp/qstorageinfo.h 2015-01-27 14:34:31 +0000 | |||
469 | +++ CameraApp/qstorageinfo.h 1970-01-01 00:00:00 +0000 | |||
470 | @@ -1,102 +0,0 @@ | |||
471 | 1 | /**************************************************************************** | ||
472 | 2 | ** | ||
473 | 3 | ** Copyright (C) 2014 Ivan Komissarov <ABBAPOH@gmail.com> | ||
474 | 4 | ** Contact: http://www.qt-project.org/legal | ||
475 | 5 | ** | ||
476 | 6 | ** This file is part of the QtCore module of the Qt Toolkit. | ||
477 | 7 | ** | ||
478 | 8 | ** This program is free software; you can redistribute it and/or modify | ||
479 | 9 | ** it under the terms of the GNU General Public License as published by | ||
480 | 10 | ** the Free Software Foundation; version 3. | ||
481 | 11 | ** | ||
482 | 12 | ** This program is distributed in the hope that it will be useful, | ||
483 | 13 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
484 | 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
485 | 15 | ** GNU General Public License for more details. | ||
486 | 16 | ** | ||
487 | 17 | ** You should have received a copy of the GNU General Public License | ||
488 | 18 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
489 | 19 | ** | ||
490 | 20 | ****************************************************************************/ | ||
491 | 21 | |||
492 | 22 | #ifndef QSTORAGEINFO_H | ||
493 | 23 | #define QSTORAGEINFO_H | ||
494 | 24 | |||
495 | 25 | #include <QtCore/qbytearray.h> | ||
496 | 26 | #include <QtCore/qdir.h> | ||
497 | 27 | #include <QtCore/qlist.h> | ||
498 | 28 | #include <QtCore/qmetatype.h> | ||
499 | 29 | #include <QtCore/qstring.h> | ||
500 | 30 | #include <QtCore/qshareddata.h> | ||
501 | 31 | |||
502 | 32 | QT_BEGIN_NAMESPACE | ||
503 | 33 | |||
504 | 34 | class QStorageInfoPrivate; | ||
505 | 35 | class Q_CORE_EXPORT QStorageInfo | ||
506 | 36 | { | ||
507 | 37 | public: | ||
508 | 38 | QStorageInfo(); | ||
509 | 39 | explicit QStorageInfo(const QString &path); | ||
510 | 40 | explicit QStorageInfo(const QDir &dir); | ||
511 | 41 | QStorageInfo(const QStorageInfo &other); | ||
512 | 42 | ~QStorageInfo(); | ||
513 | 43 | |||
514 | 44 | QStorageInfo &operator=(const QStorageInfo &other); | ||
515 | 45 | #ifdef Q_COMPILER_RVALUE_REFS | ||
516 | 46 | inline QStorageInfo &operator=(QStorageInfo &&other) | ||
517 | 47 | { qSwap(d, other.d); return *this; } | ||
518 | 48 | #endif | ||
519 | 49 | |||
520 | 50 | inline void swap(QStorageInfo &other) | ||
521 | 51 | { qSwap(d, other.d); } | ||
522 | 52 | |||
523 | 53 | void setPath(const QString &path); | ||
524 | 54 | |||
525 | 55 | QString rootPath() const; | ||
526 | 56 | QByteArray device() const; | ||
527 | 57 | QByteArray fileSystemType() const; | ||
528 | 58 | QString name() const; | ||
529 | 59 | QString displayName() const; | ||
530 | 60 | |||
531 | 61 | qint64 bytesTotal() const; | ||
532 | 62 | qint64 bytesFree() const; | ||
533 | 63 | qint64 bytesAvailable() const; | ||
534 | 64 | |||
535 | 65 | inline bool isRoot() const; | ||
536 | 66 | bool isReadOnly() const; | ||
537 | 67 | bool isReady() const; | ||
538 | 68 | bool isValid() const; | ||
539 | 69 | |||
540 | 70 | void refresh(); | ||
541 | 71 | |||
542 | 72 | static QList<QStorageInfo> mountedVolumes(); | ||
543 | 73 | static QStorageInfo root(); | ||
544 | 74 | |||
545 | 75 | private: | ||
546 | 76 | friend class QStorageInfoPrivate; | ||
547 | 77 | friend bool operator==(const QStorageInfo &first, const QStorageInfo &second); | ||
548 | 78 | QExplicitlySharedDataPointer<QStorageInfoPrivate> d; | ||
549 | 79 | }; | ||
550 | 80 | |||
551 | 81 | inline bool operator==(const QStorageInfo &first, const QStorageInfo &second) | ||
552 | 82 | { | ||
553 | 83 | if (first.d == second.d) | ||
554 | 84 | return true; | ||
555 | 85 | return first.device() == second.device(); | ||
556 | 86 | } | ||
557 | 87 | |||
558 | 88 | inline bool operator!=(const QStorageInfo &first, const QStorageInfo &second) | ||
559 | 89 | { | ||
560 | 90 | return !(first == second); | ||
561 | 91 | } | ||
562 | 92 | |||
563 | 93 | inline bool QStorageInfo::isRoot() const | ||
564 | 94 | { return *this == QStorageInfo::root(); } | ||
565 | 95 | |||
566 | 96 | Q_DECLARE_SHARED(QStorageInfo) | ||
567 | 97 | |||
568 | 98 | QT_END_NAMESPACE | ||
569 | 99 | |||
570 | 100 | Q_DECLARE_METATYPE(QStorageInfo) | ||
571 | 101 | |||
572 | 102 | #endif // QSTORAGEINFO_H | ||
573 | 103 | 0 | ||
574 | === removed file 'CameraApp/qstorageinfo_p.h' | |||
575 | --- CameraApp/qstorageinfo_p.h 2015-01-27 14:34:31 +0000 | |||
576 | +++ CameraApp/qstorageinfo_p.h 1970-01-01 00:00:00 +0000 | |||
577 | @@ -1,84 +0,0 @@ | |||
578 | 1 | /**************************************************************************** | ||
579 | 2 | ** | ||
580 | 3 | ** Copyright (C) 2014 Ivan Komissarov <ABBAPOH@gmail.com> | ||
581 | 4 | ** Contact: http://www.qt-project.org/legal | ||
582 | 5 | ** | ||
583 | 6 | ** | ||
584 | 7 | ** This file is part of the QtCore module of the Qt Toolkit. | ||
585 | 8 | ** | ||
586 | 9 | ** This program is free software; you can redistribute it and/or modify | ||
587 | 10 | ** it under the terms of the GNU General Public License as published by | ||
588 | 11 | ** the Free Software Foundation; version 3. | ||
589 | 12 | ** | ||
590 | 13 | ** This program is distributed in the hope that it will be useful, | ||
591 | 14 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
592 | 15 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
593 | 16 | ** GNU General Public License for more details. | ||
594 | 17 | ** | ||
595 | 18 | ** You should have received a copy of the GNU General Public License | ||
596 | 19 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
597 | 20 | ** | ||
598 | 21 | ****************************************************************************/ | ||
599 | 22 | |||
600 | 23 | #ifndef QSTORAGEINFO_P_H | ||
601 | 24 | #define QSTORAGEINFO_P_H | ||
602 | 25 | |||
603 | 26 | // | ||
604 | 27 | // W A R N I N G | ||
605 | 28 | // ------------- | ||
606 | 29 | // | ||
607 | 30 | // This file is not part of the Qt API. It exists purely as an | ||
608 | 31 | // implementation detail. This header file may change from version to | ||
609 | 32 | // version without notice, or even be removed. | ||
610 | 33 | // | ||
611 | 34 | // We mean it. | ||
612 | 35 | // | ||
613 | 36 | |||
614 | 37 | #include "qstorageinfo.h" | ||
615 | 38 | |||
616 | 39 | QT_BEGIN_NAMESPACE | ||
617 | 40 | |||
618 | 41 | class QStorageInfoPrivate : public QSharedData | ||
619 | 42 | { | ||
620 | 43 | public: | ||
621 | 44 | inline QStorageInfoPrivate() : QSharedData(), | ||
622 | 45 | bytesTotal(0), bytesFree(0), bytesAvailable(0), | ||
623 | 46 | readOnly(false), ready(false), valid(false) | ||
624 | 47 | {} | ||
625 | 48 | |||
626 | 49 | void initRootPath(); | ||
627 | 50 | void doStat(); | ||
628 | 51 | |||
629 | 52 | static QList<QStorageInfo> mountedVolumes(); | ||
630 | 53 | static QStorageInfo root(); | ||
631 | 54 | |||
632 | 55 | protected: | ||
633 | 56 | #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) | ||
634 | 57 | void retreiveVolumeInfo(); | ||
635 | 58 | void retreiveDiskFreeSpace(); | ||
636 | 59 | #elif defined(Q_OS_MAC) | ||
637 | 60 | void retrievePosixInfo(); | ||
638 | 61 | void retrieveUrlProperties(bool initRootPath = false); | ||
639 | 62 | void retrieveLabel(); | ||
640 | 63 | #elif defined(Q_OS_UNIX) | ||
641 | 64 | void retreiveVolumeInfo(); | ||
642 | 65 | #endif | ||
643 | 66 | |||
644 | 67 | public: | ||
645 | 68 | QString rootPath; | ||
646 | 69 | QByteArray device; | ||
647 | 70 | QByteArray fileSystemType; | ||
648 | 71 | QString name; | ||
649 | 72 | |||
650 | 73 | qint64 bytesTotal; | ||
651 | 74 | qint64 bytesFree; | ||
652 | 75 | qint64 bytesAvailable; | ||
653 | 76 | |||
654 | 77 | bool readOnly; | ||
655 | 78 | bool ready; | ||
656 | 79 | bool valid; | ||
657 | 80 | }; | ||
658 | 81 | |||
659 | 82 | QT_END_NAMESPACE | ||
660 | 83 | |||
661 | 84 | #endif // QSTORAGEINFO_P_H | ||
662 | 85 | 0 | ||
663 | === removed file 'CameraApp/qstorageinfo_unix.cpp' | |||
664 | --- CameraApp/qstorageinfo_unix.cpp 2015-01-27 14:34:31 +0000 | |||
665 | +++ CameraApp/qstorageinfo_unix.cpp 1970-01-01 00:00:00 +0000 | |||
666 | @@ -1,442 +0,0 @@ | |||
667 | 1 | /**************************************************************************** | ||
668 | 2 | ** | ||
669 | 3 | ** Copyright (C) 2014 Ivan Komissarov <ABBAPOH@gmail.com> | ||
670 | 4 | ** Contact: http://www.qt-project.org/legal | ||
671 | 5 | ** | ||
672 | 6 | ** This file is part of the QtCore module of the Qt Toolkit. | ||
673 | 7 | ** | ||
674 | 8 | ** This program is free software; you can redistribute it and/or modify | ||
675 | 9 | ** it under the terms of the GNU General Public License as published by | ||
676 | 10 | ** the Free Software Foundation; version 3. | ||
677 | 11 | ** | ||
678 | 12 | ** This program is distributed in the hope that it will be useful, | ||
679 | 13 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
680 | 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
681 | 15 | ** GNU General Public License for more details. | ||
682 | 16 | ** | ||
683 | 17 | ** You should have received a copy of the GNU General Public License | ||
684 | 18 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
685 | 19 | ** | ||
686 | 20 | ****************************************************************************/ | ||
687 | 21 | |||
688 | 22 | #include "qstorageinfo_p.h" | ||
689 | 23 | |||
690 | 24 | #include <QtCore/qdiriterator.h> | ||
691 | 25 | #include <QtCore/qfileinfo.h> | ||
692 | 26 | #include <QtCore/qtextstream.h> | ||
693 | 27 | |||
694 | 28 | // Copy this definition directly instead of importing the whole file which | ||
695 | 29 | // would pull in more dependencies we don't need. | ||
696 | 30 | //#include <QtCore/private/qcore_unix_p.h> | ||
697 | 31 | #define EINTR_LOOP(var, cmd) \ | ||
698 | 32 | do { \ | ||
699 | 33 | var = cmd; \ | ||
700 | 34 | } while (var == -1 && errno == EINTR) | ||
701 | 35 | |||
702 | 36 | #include <errno.h> | ||
703 | 37 | #include <sys/stat.h> | ||
704 | 38 | |||
705 | 39 | #if defined(Q_OS_BSD4) | ||
706 | 40 | # include <sys/mount.h> | ||
707 | 41 | # include <sys/statvfs.h> | ||
708 | 42 | #elif defined(Q_OS_ANDROID) | ||
709 | 43 | # include <sys/mount.h> | ||
710 | 44 | # include <sys/vfs.h> | ||
711 | 45 | # include <mntent.h> | ||
712 | 46 | #elif defined(Q_OS_LINUX) | ||
713 | 47 | # include <mntent.h> | ||
714 | 48 | # include <sys/statvfs.h> | ||
715 | 49 | #elif defined(Q_OS_SOLARIS) | ||
716 | 50 | # include <sys/mnttab.h> | ||
717 | 51 | #else | ||
718 | 52 | # include <sys/statvfs.h> | ||
719 | 53 | #endif | ||
720 | 54 | |||
721 | 55 | #if defined(Q_OS_BSD4) | ||
722 | 56 | # define QT_STATFSBUF struct statvfs | ||
723 | 57 | # define QT_STATFS ::statvfs | ||
724 | 58 | #elif defined(Q_OS_ANDROID) | ||
725 | 59 | # define QT_STATFS ::statfs | ||
726 | 60 | # define QT_STATFSBUF struct statfs | ||
727 | 61 | # if !defined(ST_RDONLY) | ||
728 | 62 | # define ST_RDONLY 1 // hack for missing define on Android | ||
729 | 63 | # endif | ||
730 | 64 | #else | ||
731 | 65 | # if defined(QT_LARGEFILE_SUPPORT) | ||
732 | 66 | # define QT_STATFSBUF struct statvfs64 | ||
733 | 67 | # define QT_STATFS ::statvfs64 | ||
734 | 68 | # else | ||
735 | 69 | # define QT_STATFSBUF struct statvfs | ||
736 | 70 | # define QT_STATFS ::statvfs | ||
737 | 71 | # endif // QT_LARGEFILE_SUPPORT | ||
738 | 72 | #endif // Q_OS_BSD4 | ||
739 | 73 | |||
740 | 74 | QT_BEGIN_NAMESPACE | ||
741 | 75 | |||
742 | 76 | static bool isPseudoFs(const QString &mountDir, const QByteArray &type) | ||
743 | 77 | { | ||
744 | 78 | if (mountDir.startsWith(QLatin1String("/dev")) | ||
745 | 79 | || mountDir.startsWith(QLatin1String("/proc")) | ||
746 | 80 | || mountDir.startsWith(QLatin1String("/sys")) | ||
747 | 81 | || mountDir.startsWith(QLatin1String("/var/run")) | ||
748 | 82 | || mountDir.startsWith(QLatin1String("/var/lock"))) { | ||
749 | 83 | return true; | ||
750 | 84 | } | ||
751 | 85 | if (type == "tmpfs") | ||
752 | 86 | return true; | ||
753 | 87 | #if defined(Q_OS_LINUX) | ||
754 | 88 | if (type == "rootfs" || type == "rpc_pipefs") | ||
755 | 89 | return true; | ||
756 | 90 | #endif | ||
757 | 91 | |||
758 | 92 | return false; | ||
759 | 93 | } | ||
760 | 94 | |||
761 | 95 | class QStorageIterator | ||
762 | 96 | { | ||
763 | 97 | public: | ||
764 | 98 | QStorageIterator(); | ||
765 | 99 | ~QStorageIterator(); | ||
766 | 100 | |||
767 | 101 | inline bool isValid() const; | ||
768 | 102 | inline bool next(); | ||
769 | 103 | inline QString rootPath() const; | ||
770 | 104 | inline QByteArray fileSystemType() const; | ||
771 | 105 | inline QByteArray device() const; | ||
772 | 106 | private: | ||
773 | 107 | #if defined(Q_OS_BSD4) | ||
774 | 108 | struct statfs *stat_buf; | ||
775 | 109 | int entryCount; | ||
776 | 110 | int currentIndex; | ||
777 | 111 | #elif defined(Q_OS_SOLARIS) | ||
778 | 112 | FILE *fp; | ||
779 | 113 | mnttab mnt; | ||
780 | 114 | #elif defined(Q_OS_ANDROID) | ||
781 | 115 | QFile file; | ||
782 | 116 | QByteArray m_rootPath; | ||
783 | 117 | QByteArray m_fileSystemType; | ||
784 | 118 | QByteArray m_device; | ||
785 | 119 | #elif defined(Q_OS_LINUX) | ||
786 | 120 | FILE *fp; | ||
787 | 121 | mntent mnt; | ||
788 | 122 | QByteArray buffer; | ||
789 | 123 | #endif | ||
790 | 124 | }; | ||
791 | 125 | |||
792 | 126 | #if defined(Q_OS_BSD4) | ||
793 | 127 | |||
794 | 128 | inline QStorageIterator::QStorageIterator() | ||
795 | 129 | : entryCount(::getmntinfo(&stat_buf, 0)), | ||
796 | 130 | currentIndex(-1) | ||
797 | 131 | { | ||
798 | 132 | } | ||
799 | 133 | |||
800 | 134 | inline QStorageIterator::~QStorageIterator() | ||
801 | 135 | { | ||
802 | 136 | } | ||
803 | 137 | |||
804 | 138 | inline bool QStorageIterator::isValid() const | ||
805 | 139 | { | ||
806 | 140 | return entryCount != -1; | ||
807 | 141 | } | ||
808 | 142 | |||
809 | 143 | inline bool QStorageIterator::next() | ||
810 | 144 | { | ||
811 | 145 | return ++currentIndex < entryCount; | ||
812 | 146 | } | ||
813 | 147 | |||
814 | 148 | inline QString QStorageIterator::rootPath() const | ||
815 | 149 | { | ||
816 | 150 | return QFile::decodeName(stat_buf[currentIndex].f_mntonname); | ||
817 | 151 | } | ||
818 | 152 | |||
819 | 153 | inline QByteArray QStorageIterator::fileSystemType() const | ||
820 | 154 | { | ||
821 | 155 | return QByteArray(stat_buf[currentIndex].f_fstypename); | ||
822 | 156 | } | ||
823 | 157 | |||
824 | 158 | inline QByteArray QStorageIterator::device() const | ||
825 | 159 | { | ||
826 | 160 | return QByteArray(stat_buf[currentIndex].f_mntfromname); | ||
827 | 161 | } | ||
828 | 162 | |||
829 | 163 | #elif defined(Q_OS_SOLARIS) | ||
830 | 164 | |||
831 | 165 | static const char pathMounted[] = "/etc/mnttab"; | ||
832 | 166 | |||
833 | 167 | inline QStorageIterator::QStorageIterator() | ||
834 | 168 | { | ||
835 | 169 | const int fd = qt_safe_open(pathMounted, O_RDONLY); | ||
836 | 170 | fp = ::fdopen(fd, "r"); | ||
837 | 171 | } | ||
838 | 172 | |||
839 | 173 | inline QStorageIterator::~QStorageIterator() | ||
840 | 174 | { | ||
841 | 175 | if (fp) | ||
842 | 176 | ::fclose(fp); | ||
843 | 177 | } | ||
844 | 178 | |||
845 | 179 | inline bool QStorageIterator::isValid() const | ||
846 | 180 | { | ||
847 | 181 | return fp != Q_NULLPTR; | ||
848 | 182 | } | ||
849 | 183 | |||
850 | 184 | inline bool QStorageIterator::next() | ||
851 | 185 | { | ||
852 | 186 | return ::getmntent(fp, &mnt) == Q_NULLPTR; | ||
853 | 187 | } | ||
854 | 188 | |||
855 | 189 | inline QString QStorageIterator::rootPath() const | ||
856 | 190 | { | ||
857 | 191 | return QFile::decodeName(mnt->mnt_mountp); | ||
858 | 192 | } | ||
859 | 193 | |||
860 | 194 | inline QByteArray QStorageIterator::fileSystemType() const | ||
861 | 195 | { | ||
862 | 196 | return QByteArray(mnt->mnt_fstype); | ||
863 | 197 | } | ||
864 | 198 | |||
865 | 199 | inline QByteArray QStorageIterator::device() const | ||
866 | 200 | { | ||
867 | 201 | return QByteArray(mnt->mnt_mntopts); | ||
868 | 202 | } | ||
869 | 203 | |||
870 | 204 | #elif defined(Q_OS_ANDROID) | ||
871 | 205 | |||
872 | 206 | static const char pathMounted[] = "/proc/mounts"; | ||
873 | 207 | |||
874 | 208 | inline QStorageIterator::QStorageIterator() | ||
875 | 209 | { | ||
876 | 210 | file.setFileName(pathMounted); | ||
877 | 211 | file.open(QIODevice::ReadOnly | QIODevice::Text); | ||
878 | 212 | } | ||
879 | 213 | |||
880 | 214 | inline QStorageIterator::~QStorageIterator() | ||
881 | 215 | { | ||
882 | 216 | } | ||
883 | 217 | |||
884 | 218 | inline bool QStorageIterator::isValid() const | ||
885 | 219 | { | ||
886 | 220 | return file.isOpen(); | ||
887 | 221 | } | ||
888 | 222 | |||
889 | 223 | inline bool QStorageIterator::next() | ||
890 | 224 | { | ||
891 | 225 | QList<QByteArray> data; | ||
892 | 226 | do { | ||
893 | 227 | const QByteArray line = file.readLine(); | ||
894 | 228 | data = line.split(' '); | ||
895 | 229 | } while (data.count() < 3 && !file.atEnd()); | ||
896 | 230 | |||
897 | 231 | if (file.atEnd()) | ||
898 | 232 | return false; | ||
899 | 233 | m_device = data.at(0); | ||
900 | 234 | m_rootPath = data.at(1); | ||
901 | 235 | m_fileSystemType = data.at(2); | ||
902 | 236 | |||
903 | 237 | return true; | ||
904 | 238 | } | ||
905 | 239 | |||
906 | 240 | inline QString QStorageIterator::rootPath() const | ||
907 | 241 | { | ||
908 | 242 | return QFile::decodeName(m_rootPath); | ||
909 | 243 | } | ||
910 | 244 | |||
911 | 245 | inline QByteArray QStorageIterator::fileSystemType() const | ||
912 | 246 | { | ||
913 | 247 | return m_fileSystemType; | ||
914 | 248 | } | ||
915 | 249 | |||
916 | 250 | inline QByteArray QStorageIterator::device() const | ||
917 | 251 | { | ||
918 | 252 | return m_device; | ||
919 | 253 | } | ||
920 | 254 | |||
921 | 255 | #elif defined(Q_OS_LINUX) | ||
922 | 256 | |||
923 | 257 | static const char pathMounted[] = "/etc/mtab"; | ||
924 | 258 | static const int bufferSize = 3*PATH_MAX; // 2 paths (mount point+device) and metainfo | ||
925 | 259 | |||
926 | 260 | inline QStorageIterator::QStorageIterator() : | ||
927 | 261 | buffer(QByteArray(bufferSize, 0)) | ||
928 | 262 | { | ||
929 | 263 | fp = ::setmntent(pathMounted, "r"); | ||
930 | 264 | } | ||
931 | 265 | |||
932 | 266 | inline QStorageIterator::~QStorageIterator() | ||
933 | 267 | { | ||
934 | 268 | if (fp) | ||
935 | 269 | ::endmntent(fp); | ||
936 | 270 | } | ||
937 | 271 | |||
938 | 272 | inline bool QStorageIterator::isValid() const | ||
939 | 273 | { | ||
940 | 274 | return fp != Q_NULLPTR; | ||
941 | 275 | } | ||
942 | 276 | |||
943 | 277 | inline bool QStorageIterator::next() | ||
944 | 278 | { | ||
945 | 279 | return ::getmntent_r(fp, &mnt, buffer.data(), buffer.size()) != Q_NULLPTR; | ||
946 | 280 | } | ||
947 | 281 | |||
948 | 282 | inline QString QStorageIterator::rootPath() const | ||
949 | 283 | { | ||
950 | 284 | return QFile::decodeName(mnt.mnt_dir); | ||
951 | 285 | } | ||
952 | 286 | |||
953 | 287 | inline QByteArray QStorageIterator::fileSystemType() const | ||
954 | 288 | { | ||
955 | 289 | return QByteArray(mnt.mnt_type); | ||
956 | 290 | } | ||
957 | 291 | |||
958 | 292 | inline QByteArray QStorageIterator::device() const | ||
959 | 293 | { | ||
960 | 294 | return QByteArray(mnt.mnt_fsname); | ||
961 | 295 | } | ||
962 | 296 | |||
963 | 297 | #else | ||
964 | 298 | |||
965 | 299 | inline QStorageIterator::QStorageIterator() | ||
966 | 300 | { | ||
967 | 301 | } | ||
968 | 302 | |||
969 | 303 | inline QStorageIterator::~QStorageIterator() | ||
970 | 304 | { | ||
971 | 305 | } | ||
972 | 306 | |||
973 | 307 | inline bool QStorageIterator::isValid() const | ||
974 | 308 | { | ||
975 | 309 | return false; | ||
976 | 310 | } | ||
977 | 311 | |||
978 | 312 | inline bool QStorageIterator::next() | ||
979 | 313 | { | ||
980 | 314 | return false; | ||
981 | 315 | } | ||
982 | 316 | |||
983 | 317 | inline QString QStorageIterator::rootPath() const | ||
984 | 318 | { | ||
985 | 319 | return QString(); | ||
986 | 320 | } | ||
987 | 321 | |||
988 | 322 | inline QByteArray QStorageIterator::fileSystemType() const | ||
989 | 323 | { | ||
990 | 324 | return QByteArray(); | ||
991 | 325 | } | ||
992 | 326 | |||
993 | 327 | inline QByteArray QStorageIterator::device() const | ||
994 | 328 | { | ||
995 | 329 | return QByteArray(); | ||
996 | 330 | } | ||
997 | 331 | |||
998 | 332 | #endif | ||
999 | 333 | |||
1000 | 334 | void QStorageInfoPrivate::initRootPath() | ||
1001 | 335 | { | ||
1002 | 336 | rootPath = QFileInfo(rootPath).canonicalFilePath(); | ||
1003 | 337 | |||
1004 | 338 | if (rootPath.isEmpty()) | ||
1005 | 339 | return; | ||
1006 | 340 | |||
1007 | 341 | QStorageIterator it; | ||
1008 | 342 | if (!it.isValid()) { | ||
1009 | 343 | rootPath = QStringLiteral("/"); | ||
1010 | 344 | return; | ||
1011 | 345 | } | ||
1012 | 346 | |||
1013 | 347 | int maxLength = 0; | ||
1014 | 348 | const QString oldRootPath = rootPath; | ||
1015 | 349 | rootPath.clear(); | ||
1016 | 350 | |||
1017 | 351 | while (it.next()) { | ||
1018 | 352 | const QString mountDir = it.rootPath(); | ||
1019 | 353 | const QByteArray fsName = it.fileSystemType(); | ||
1020 | 354 | if (isPseudoFs(mountDir, fsName)) | ||
1021 | 355 | continue; | ||
1022 | 356 | // we try to find most suitable entry | ||
1023 | 357 | if (oldRootPath.startsWith(mountDir) && maxLength < mountDir.length()) { | ||
1024 | 358 | maxLength = mountDir.length(); | ||
1025 | 359 | rootPath = mountDir; | ||
1026 | 360 | device = it.device(); | ||
1027 | 361 | fileSystemType = fsName; | ||
1028 | 362 | } | ||
1029 | 363 | } | ||
1030 | 364 | } | ||
1031 | 365 | |||
1032 | 366 | static inline QString retrieveLabel(const QByteArray &device) | ||
1033 | 367 | { | ||
1034 | 368 | #ifdef Q_OS_LINUX | ||
1035 | 369 | static const char pathDiskByLabel[] = "/dev/disk/by-label"; | ||
1036 | 370 | |||
1037 | 371 | QDirIterator it(QLatin1String(pathDiskByLabel), QDir::NoDotAndDotDot); | ||
1038 | 372 | while (it.hasNext()) { | ||
1039 | 373 | it.next(); | ||
1040 | 374 | QFileInfo fileInfo(it.fileInfo()); | ||
1041 | 375 | if (fileInfo.isSymLink() && fileInfo.symLinkTarget().toLocal8Bit() == device) | ||
1042 | 376 | return fileInfo.fileName(); | ||
1043 | 377 | } | ||
1044 | 378 | #else | ||
1045 | 379 | Q_UNUSED(device); | ||
1046 | 380 | #endif | ||
1047 | 381 | |||
1048 | 382 | return QString(); | ||
1049 | 383 | } | ||
1050 | 384 | |||
1051 | 385 | void QStorageInfoPrivate::doStat() | ||
1052 | 386 | { | ||
1053 | 387 | initRootPath(); | ||
1054 | 388 | if (rootPath.isEmpty()) | ||
1055 | 389 | return; | ||
1056 | 390 | |||
1057 | 391 | retreiveVolumeInfo(); | ||
1058 | 392 | name = retrieveLabel(device); | ||
1059 | 393 | } | ||
1060 | 394 | |||
1061 | 395 | void QStorageInfoPrivate::retreiveVolumeInfo() | ||
1062 | 396 | { | ||
1063 | 397 | QT_STATFSBUF statfs_buf; | ||
1064 | 398 | int result; | ||
1065 | 399 | EINTR_LOOP(result, QT_STATFS(QFile::encodeName(rootPath).constData(), &statfs_buf)); | ||
1066 | 400 | if (result == 0) { | ||
1067 | 401 | valid = true; | ||
1068 | 402 | ready = true; | ||
1069 | 403 | |||
1070 | 404 | bytesTotal = statfs_buf.f_blocks * statfs_buf.f_bsize; | ||
1071 | 405 | bytesFree = statfs_buf.f_bfree * statfs_buf.f_bsize; | ||
1072 | 406 | bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_bsize; | ||
1073 | 407 | #if defined(Q_OS_ANDROID) | ||
1074 | 408 | #if defined(_STATFS_F_FLAGS) | ||
1075 | 409 | readOnly = (statfs_buf.f_flags & ST_RDONLY) != 0; | ||
1076 | 410 | #endif | ||
1077 | 411 | #else | ||
1078 | 412 | readOnly = (statfs_buf.f_flag & ST_RDONLY) != 0; | ||
1079 | 413 | #endif | ||
1080 | 414 | } | ||
1081 | 415 | } | ||
1082 | 416 | |||
1083 | 417 | QList<QStorageInfo> QStorageInfoPrivate::mountedVolumes() | ||
1084 | 418 | { | ||
1085 | 419 | QStorageIterator it; | ||
1086 | 420 | if (!it.isValid()) | ||
1087 | 421 | return QList<QStorageInfo>() << root(); | ||
1088 | 422 | |||
1089 | 423 | QList<QStorageInfo> volumes; | ||
1090 | 424 | |||
1091 | 425 | while (it.next()) { | ||
1092 | 426 | const QString mountDir = it.rootPath(); | ||
1093 | 427 | const QByteArray fsName = it.fileSystemType(); | ||
1094 | 428 | if (isPseudoFs(mountDir, fsName)) | ||
1095 | 429 | continue; | ||
1096 | 430 | |||
1097 | 431 | volumes.append(QStorageInfo(mountDir)); | ||
1098 | 432 | } | ||
1099 | 433 | |||
1100 | 434 | return volumes; | ||
1101 | 435 | } | ||
1102 | 436 | |||
1103 | 437 | QStorageInfo QStorageInfoPrivate::root() | ||
1104 | 438 | { | ||
1105 | 439 | return QStorageInfo(QStringLiteral("/")); | ||
1106 | 440 | } | ||
1107 | 441 | |||
1108 | 442 | QT_END_NAMESPACE | ||
1109 | 443 | 0 | ||
1110 | === added file 'CameraApp/storagelocations.cpp' | |||
1111 | --- CameraApp/storagelocations.cpp 1970-01-01 00:00:00 +0000 | |||
1112 | +++ CameraApp/storagelocations.cpp 2016-02-26 17:17:00 +0000 | |||
1113 | @@ -0,0 +1,121 @@ | |||
1114 | 1 | /* | ||
1115 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
1116 | 3 | * | ||
1117 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1118 | 5 | * it under the terms of the GNU General Public License as published by | ||
1119 | 6 | * the Free Software Foundation; version 3. | ||
1120 | 7 | * | ||
1121 | 8 | * This program is distributed in the hope that it will be useful, | ||
1122 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1123 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1124 | 11 | * GNU General Public License for more details. | ||
1125 | 12 | * | ||
1126 | 13 | * You should have received a copy of the GNU General Public License | ||
1127 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1128 | 15 | */ | ||
1129 | 16 | |||
1130 | 17 | #include "storagelocations.h" | ||
1131 | 18 | |||
1132 | 19 | #include <QCoreApplication> | ||
1133 | 20 | #include <QStandardPaths> | ||
1134 | 21 | #include <QStorageInfo> | ||
1135 | 22 | |||
1136 | 23 | StorageLocations::StorageLocations(QObject *parent) : QObject(parent) | ||
1137 | 24 | { | ||
1138 | 25 | } | ||
1139 | 26 | |||
1140 | 27 | QString StorageLocations::picturesLocation() const | ||
1141 | 28 | { | ||
1142 | 29 | QStringList locations = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation); | ||
1143 | 30 | if (locations.isEmpty()) { | ||
1144 | 31 | return QString(); | ||
1145 | 32 | } | ||
1146 | 33 | QString location = locations.at(0) + "/" + QCoreApplication::applicationName(); | ||
1147 | 34 | QDir dir; | ||
1148 | 35 | // Transition from old directory 'camera' to new one; see bug #1363112 | ||
1149 | 36 | // https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1363112 | ||
1150 | 37 | dir.rename(locations.at(0) + "/" + "camera", location); | ||
1151 | 38 | dir.mkpath(location); | ||
1152 | 39 | return location; | ||
1153 | 40 | } | ||
1154 | 41 | |||
1155 | 42 | QString StorageLocations::videosLocation() const | ||
1156 | 43 | { | ||
1157 | 44 | QStringList locations = QStandardPaths::standardLocations(QStandardPaths::MoviesLocation); | ||
1158 | 45 | if (locations.isEmpty()) { | ||
1159 | 46 | return QString(); | ||
1160 | 47 | } | ||
1161 | 48 | QString location = locations.at(0) + "/" + QCoreApplication::applicationName(); | ||
1162 | 49 | QDir dir; | ||
1163 | 50 | // Transition from old directory 'camera' to new one; see bug #1363112 | ||
1164 | 51 | // https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1363112 | ||
1165 | 52 | dir.rename(locations.at(0) + "/" + "camera", location); | ||
1166 | 53 | dir.mkpath(location); | ||
1167 | 54 | return location; | ||
1168 | 55 | } | ||
1169 | 56 | |||
1170 | 57 | QString StorageLocations::temporaryLocation() const | ||
1171 | 58 | { | ||
1172 | 59 | QStringList locations = QStandardPaths::standardLocations(QStandardPaths::TempLocation); | ||
1173 | 60 | if (locations.isEmpty()) { | ||
1174 | 61 | return QString(); | ||
1175 | 62 | } | ||
1176 | 63 | QString location = locations.at(0); | ||
1177 | 64 | QDir dir; | ||
1178 | 65 | dir.mkpath(location); | ||
1179 | 66 | return location; | ||
1180 | 67 | } | ||
1181 | 68 | |||
1182 | 69 | QString StorageLocations::removableStorageLocation() const | ||
1183 | 70 | { | ||
1184 | 71 | QString mediaRoot("/media/" + qgetenv("USER")); | ||
1185 | 72 | Q_FOREACH(QStorageInfo volume, QStorageInfo::mountedVolumes()) { | ||
1186 | 73 | if (volume.rootPath().startsWith(mediaRoot) && | ||
1187 | 74 | volume.isValid() && volume.isReady()) { | ||
1188 | 75 | return volume.rootPath(); | ||
1189 | 76 | } | ||
1190 | 77 | } | ||
1191 | 78 | |||
1192 | 79 | return QString(); | ||
1193 | 80 | } | ||
1194 | 81 | |||
1195 | 82 | QString StorageLocations::removableStoragePicturesLocation() const | ||
1196 | 83 | { | ||
1197 | 84 | QString storageLocation = removableStorageLocation(); | ||
1198 | 85 | if (storageLocation.isEmpty()) { | ||
1199 | 86 | return QString(); | ||
1200 | 87 | } | ||
1201 | 88 | |||
1202 | 89 | QStringList locations = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation); | ||
1203 | 90 | QString pictureDir = QString(locations.at(0)).split("/").value(3); | ||
1204 | 91 | if (pictureDir.isEmpty()){ | ||
1205 | 92 | return QString(); | ||
1206 | 93 | } | ||
1207 | 94 | QString location = storageLocation + "/" + pictureDir + "/" + QCoreApplication::applicationName(); | ||
1208 | 95 | QDir dir; | ||
1209 | 96 | dir.mkpath(location); | ||
1210 | 97 | return location; | ||
1211 | 98 | } | ||
1212 | 99 | |||
1213 | 100 | QString StorageLocations::removableStorageVideosLocation() const | ||
1214 | 101 | { | ||
1215 | 102 | QString storageLocation = removableStorageLocation(); | ||
1216 | 103 | if (storageLocation.isEmpty()) { | ||
1217 | 104 | return QString(); | ||
1218 | 105 | } | ||
1219 | 106 | |||
1220 | 107 | QStringList locations = QStandardPaths::standardLocations(QStandardPaths::MoviesLocation); | ||
1221 | 108 | QString movieDir = QString(locations.at(0)).split("/").value(3); | ||
1222 | 109 | if (movieDir.isEmpty()){ | ||
1223 | 110 | return QString(); | ||
1224 | 111 | } | ||
1225 | 112 | QString location = storageLocation + "/" + movieDir + "/" + QCoreApplication::applicationName(); | ||
1226 | 113 | QDir dir; | ||
1227 | 114 | dir.mkpath(location); | ||
1228 | 115 | return location; | ||
1229 | 116 | } | ||
1230 | 117 | |||
1231 | 118 | bool StorageLocations::removableStoragePresent() const | ||
1232 | 119 | { | ||
1233 | 120 | return !removableStorageLocation().isEmpty(); | ||
1234 | 121 | } | ||
1235 | 0 | 122 | ||
1236 | === added file 'CameraApp/storagelocations.h' | |||
1237 | --- CameraApp/storagelocations.h 1970-01-01 00:00:00 +0000 | |||
1238 | +++ CameraApp/storagelocations.h 2016-02-26 17:17:00 +0000 | |||
1239 | @@ -0,0 +1,50 @@ | |||
1240 | 1 | /* | ||
1241 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
1242 | 3 | * | ||
1243 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1244 | 5 | * it under the terms of the GNU General Public License as published by | ||
1245 | 6 | * the Free Software Foundation; version 3. | ||
1246 | 7 | * | ||
1247 | 8 | * This program is distributed in the hope that it will be useful, | ||
1248 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1249 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1250 | 11 | * GNU General Public License for more details. | ||
1251 | 12 | * | ||
1252 | 13 | * You should have received a copy of the GNU General Public License | ||
1253 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1254 | 15 | */ | ||
1255 | 16 | |||
1256 | 17 | #ifndef STORAGELOCATIONS_H | ||
1257 | 18 | #define STORAGELOCATIONS_H | ||
1258 | 19 | |||
1259 | 20 | #include <QObject> | ||
1260 | 21 | |||
1261 | 22 | class StorageLocations : public QObject | ||
1262 | 23 | { | ||
1263 | 24 | Q_OBJECT | ||
1264 | 25 | |||
1265 | 26 | Q_PROPERTY(QString picturesLocation READ picturesLocation CONSTANT) | ||
1266 | 27 | Q_PROPERTY(QString videosLocation READ videosLocation CONSTANT) | ||
1267 | 28 | Q_PROPERTY(QString temporaryLocation READ temporaryLocation CONSTANT) | ||
1268 | 29 | Q_PROPERTY(QString removableStorageLocation READ removableStorageLocation CONSTANT) | ||
1269 | 30 | Q_PROPERTY(QString removableStoragePicturesLocation READ removableStoragePicturesLocation CONSTANT) | ||
1270 | 31 | Q_PROPERTY(QString removableStorageVideosLocation READ removableStorageVideosLocation CONSTANT) | ||
1271 | 32 | Q_PROPERTY(bool removableStoragePresent READ removableStoragePresent NOTIFY removableStoragePresentChanged) | ||
1272 | 33 | |||
1273 | 34 | public: | ||
1274 | 35 | explicit StorageLocations(QObject *parent = 0); | ||
1275 | 36 | |||
1276 | 37 | QString picturesLocation() const; | ||
1277 | 38 | QString videosLocation() const; | ||
1278 | 39 | QString temporaryLocation() const; | ||
1279 | 40 | QString removableStorageLocation() const; | ||
1280 | 41 | QString removableStoragePicturesLocation() const; | ||
1281 | 42 | QString removableStorageVideosLocation() const; | ||
1282 | 43 | |||
1283 | 44 | bool removableStoragePresent() const; | ||
1284 | 45 | |||
1285 | 46 | Q_SIGNALS: | ||
1286 | 47 | void removableStoragePresentChanged(); | ||
1287 | 48 | }; | ||
1288 | 49 | |||
1289 | 50 | #endif // STORAGELOCATIONS_H | ||
1290 | 0 | 51 | ||
1291 | === modified file 'CameraApp/storagemonitor.cpp' | |||
1292 | --- CameraApp/storagemonitor.cpp 2015-01-23 19:28:44 +0000 | |||
1293 | +++ CameraApp/storagemonitor.cpp 2016-02-26 17:17:00 +0000 | |||
1294 | @@ -15,9 +15,10 @@ | |||
1295 | 15 | */ | 15 | */ |
1296 | 16 | 16 | ||
1297 | 17 | #include "storagemonitor.h" | 17 | #include "storagemonitor.h" |
1298 | 18 | #include "storagelocations.h" | ||
1299 | 18 | 19 | ||
1300 | 19 | StorageMonitor::StorageMonitor(QObject *parent) : | 20 | StorageMonitor::StorageMonitor(QObject *parent) : |
1302 | 20 | QObject(parent), m_low(false), m_criticallyLow(false) | 21 | QObject(parent), m_low(false), m_criticallyLow(false), m_writeable(true) |
1303 | 21 | { | 22 | { |
1304 | 22 | m_timer.setInterval(POLL_INTERVAL); | 23 | m_timer.setInterval(POLL_INTERVAL); |
1305 | 23 | m_timer.setSingleShot(false); | 24 | m_timer.setSingleShot(false); |
1306 | @@ -54,6 +55,32 @@ | |||
1307 | 54 | } | 55 | } |
1308 | 55 | } | 56 | } |
1309 | 56 | 57 | ||
1310 | 58 | void StorageMonitor::checkWriteable() | ||
1311 | 59 | { | ||
1312 | 60 | bool writeable = true; | ||
1313 | 61 | |||
1314 | 62 | QString mediaRoot("/media/" + qgetenv("USER")); | ||
1315 | 63 | if (m_storage.rootPath().startsWith(mediaRoot)) { | ||
1316 | 64 | // check only for external media, assume internal media is always writeable | ||
1317 | 65 | if (m_storage.isReadOnly()) { | ||
1318 | 66 | writeable = false; | ||
1319 | 67 | } else { | ||
1320 | 68 | StorageLocations locations; | ||
1321 | 69 | QDir storageRoot(locations.removableStoragePicturesLocation()); | ||
1322 | 70 | QFile testFile(storageRoot.absoluteFilePath(".write_test")); | ||
1323 | 71 | bool opened = testFile.open(QIODevice::WriteOnly | QIODevice::Unbuffered); | ||
1324 | 72 | if (!opened || testFile.write("x", 1) != 1) writeable = false; | ||
1325 | 73 | testFile.close(); | ||
1326 | 74 | testFile.remove(); | ||
1327 | 75 | } | ||
1328 | 76 | } | ||
1329 | 77 | |||
1330 | 78 | if (m_writeable != writeable) { | ||
1331 | 79 | m_writeable = writeable; | ||
1332 | 80 | Q_EMIT isWriteableChanged(); | ||
1333 | 81 | } | ||
1334 | 82 | } | ||
1335 | 83 | |||
1336 | 57 | void StorageMonitor::setLocation(QString location) | 84 | void StorageMonitor::setLocation(QString location) |
1337 | 58 | { | 85 | { |
1338 | 59 | if (location != m_location) { | 86 | if (location != m_location) { |
1339 | @@ -62,6 +89,7 @@ | |||
1340 | 62 | 89 | ||
1341 | 63 | m_storage.setPath(m_location); | 90 | m_storage.setPath(m_location); |
1342 | 64 | checkDiskSpace(); | 91 | checkDiskSpace(); |
1343 | 92 | checkWriteable(); | ||
1344 | 65 | if (m_storage.isValid()) { | 93 | if (m_storage.isValid()) { |
1345 | 66 | m_timer.start(); | 94 | m_timer.start(); |
1346 | 67 | } | 95 | } |
1347 | @@ -84,3 +112,8 @@ | |||
1348 | 84 | { | 112 | { |
1349 | 85 | return m_criticallyLow; | 113 | return m_criticallyLow; |
1350 | 86 | } | 114 | } |
1351 | 115 | |||
1352 | 116 | bool StorageMonitor::isWriteable() const | ||
1353 | 117 | { | ||
1354 | 118 | return m_writeable; | ||
1355 | 119 | } | ||
1356 | 87 | 120 | ||
1357 | === modified file 'CameraApp/storagemonitor.h' | |||
1358 | --- CameraApp/storagemonitor.h 2015-01-23 19:29:03 +0000 | |||
1359 | +++ CameraApp/storagemonitor.h 2016-02-26 17:17:00 +0000 | |||
1360 | @@ -34,6 +34,7 @@ | |||
1361 | 34 | Q_PROPERTY(QString location READ location WRITE setLocation NOTIFY locationChanged) | 34 | Q_PROPERTY(QString location READ location WRITE setLocation NOTIFY locationChanged) |
1362 | 35 | Q_PROPERTY(bool diskSpaceLow READ diskSpaceLow NOTIFY diskSpaceLowChanged) | 35 | Q_PROPERTY(bool diskSpaceLow READ diskSpaceLow NOTIFY diskSpaceLowChanged) |
1363 | 36 | Q_PROPERTY(bool diskSpaceCriticallyLow READ diskSpaceCriticallyLow NOTIFY diskSpaceCriticallyLowChanged) | 36 | Q_PROPERTY(bool diskSpaceCriticallyLow READ diskSpaceCriticallyLow NOTIFY diskSpaceCriticallyLowChanged) |
1364 | 37 | Q_PROPERTY(bool isWriteable READ isWriteable NOTIFY isWriteableChanged) | ||
1365 | 37 | 38 | ||
1366 | 38 | public: | 39 | public: |
1367 | 39 | explicit StorageMonitor(QObject *parent = 0); | 40 | explicit StorageMonitor(QObject *parent = 0); |
1368 | @@ -42,21 +43,25 @@ | |||
1369 | 42 | void setLocation(QString location); | 43 | void setLocation(QString location); |
1370 | 43 | bool diskSpaceLow() const; | 44 | bool diskSpaceLow() const; |
1371 | 44 | bool diskSpaceCriticallyLow() const; | 45 | bool diskSpaceCriticallyLow() const; |
1372 | 46 | bool isWriteable() const; | ||
1373 | 45 | 47 | ||
1374 | 46 | Q_SIGNALS: | 48 | Q_SIGNALS: |
1375 | 47 | void locationChanged(); | 49 | void locationChanged(); |
1376 | 48 | void diskSpaceLowChanged(); | 50 | void diskSpaceLowChanged(); |
1377 | 49 | void diskSpaceCriticallyLowChanged(); | 51 | void diskSpaceCriticallyLowChanged(); |
1378 | 52 | void isWriteableChanged(); | ||
1379 | 50 | 53 | ||
1380 | 51 | private Q_SLOTS: | 54 | private Q_SLOTS: |
1381 | 52 | void refresh(); | 55 | void refresh(); |
1382 | 53 | 56 | ||
1383 | 54 | private: | 57 | private: |
1384 | 55 | void checkDiskSpace(); | 58 | void checkDiskSpace(); |
1385 | 59 | void checkWriteable(); | ||
1386 | 56 | 60 | ||
1387 | 57 | private: | 61 | private: |
1388 | 58 | bool m_low; | 62 | bool m_low; |
1389 | 59 | bool m_criticallyLow; | 63 | bool m_criticallyLow; |
1390 | 64 | bool m_writeable; | ||
1391 | 60 | QTimer m_timer; | 65 | QTimer m_timer; |
1392 | 61 | QString m_location; | 66 | QString m_location; |
1393 | 62 | QStorageInfo m_storage; | 67 | QStorageInfo m_storage; |
1394 | 63 | 68 | ||
1395 | === modified file 'GalleryView.qml' | |||
1396 | --- GalleryView.qml 2015-11-26 11:29:18 +0000 | |||
1397 | +++ GalleryView.qml 2016-02-26 17:17:00 +0000 | |||
1398 | @@ -30,9 +30,9 @@ | |||
1399 | 30 | property bool userSelectionMode: false | 30 | property bool userSelectionMode: false |
1400 | 31 | property Item currentView: state == "GRID" ? photogridView : slideshowView | 31 | property Item currentView: state == "GRID" ? photogridView : slideshowView |
1401 | 32 | property var model: FoldersModel { | 32 | property var model: FoldersModel { |
1405 | 33 | folders: [application.picturesLocation, application.videosLocation, | 33 | folders: [StorageLocations.picturesLocation, StorageLocations.videosLocation, |
1406 | 34 | application.removableStoragePicturesLocation, | 34 | StorageLocations.removableStoragePicturesLocation, |
1407 | 35 | application.removableStorageVideosLocation] | 35 | StorageLocations.removableStorageVideosLocation] |
1408 | 36 | typeFilters: !main.contentExportMode ? [ "image", "video" ] | 36 | typeFilters: !main.contentExportMode ? [ "image", "video" ] |
1409 | 37 | : [MimeTypeMapper.contentTypeToMimeType(main.transferContentType)] | 37 | : [MimeTypeMapper.contentTypeToMimeType(main.transferContentType)] |
1410 | 38 | singleSelectionOnly: main.transfer.selectionType === ContentTransfer.Single | 38 | singleSelectionOnly: main.transfer.selectionType === ContentTransfer.Single |
1411 | 39 | 39 | ||
1412 | === modified file 'GalleryViewHeader.qml' | |||
1413 | --- GalleryViewHeader.qml 2015-10-30 15:01:10 +0000 | |||
1414 | +++ GalleryViewHeader.qml 2016-02-26 17:17:00 +0000 | |||
1415 | @@ -73,7 +73,7 @@ | |||
1416 | 73 | } | 73 | } |
1417 | 74 | width: units.gu(8) | 74 | width: units.gu(8) |
1418 | 75 | iconName: "back" | 75 | iconName: "back" |
1420 | 76 | iconColor: theme.palette.normal.foregroundText | 76 | iconColor: "white" |
1421 | 77 | onClicked: editMode ? header.exitEditor() : header.exit() | 77 | onClicked: editMode ? header.exitEditor() : header.exit() |
1422 | 78 | } | 78 | } |
1423 | 79 | 79 | ||
1424 | @@ -81,7 +81,7 @@ | |||
1425 | 81 | text: main.contentExportMode || userSelectionMode ? i18n.tr("Select") : | 81 | text: main.contentExportMode || userSelectionMode ? i18n.tr("Select") : |
1426 | 82 | (editMode ? i18n.tr("Edit Photo") : i18n.tr("Photo Roll")) | 82 | (editMode ? i18n.tr("Edit Photo") : i18n.tr("Photo Roll")) |
1427 | 83 | fontSize: "x-large" | 83 | fontSize: "x-large" |
1429 | 84 | color: theme.palette.normal.foregroundText | 84 | color: "white" |
1430 | 85 | elide: Text.ElideRight | 85 | elide: Text.ElideRight |
1431 | 86 | Layout.fillWidth: true | 86 | Layout.fillWidth: true |
1432 | 87 | } | 87 | } |
1433 | @@ -228,7 +228,7 @@ | |||
1434 | 228 | } | 228 | } |
1435 | 229 | text: model.text | 229 | text: model.text |
1436 | 230 | elide: Text.ElideRight | 230 | elide: Text.ElideRight |
1438 | 231 | color: action.enabled ? theme.palette.normal.foregroundText : Qt.darker(theme.palette.normal.foregroundText, 2.0) | 231 | color: action.enabled ? "white" : Qt.darker("white", 2.0) |
1439 | 232 | } | 232 | } |
1440 | 233 | 233 | ||
1441 | 234 | Icon { | 234 | Icon { |
1442 | 235 | 235 | ||
1443 | === added file 'PictureReview.qml' | |||
1444 | --- PictureReview.qml 1970-01-01 00:00:00 +0000 | |||
1445 | +++ PictureReview.qml 2016-02-26 17:17:00 +0000 | |||
1446 | @@ -0,0 +1,46 @@ | |||
1447 | 1 | /* | ||
1448 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
1449 | 3 | * | ||
1450 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1451 | 5 | * it under the terms of the GNU General Public License as published by | ||
1452 | 6 | * the Free Software Foundation; version 3. | ||
1453 | 7 | * | ||
1454 | 8 | * This program is distributed in the hope that it will be useful, | ||
1455 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1456 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1457 | 11 | * GNU General Public License for more details. | ||
1458 | 12 | * | ||
1459 | 13 | * You should have received a copy of the GNU General Public License | ||
1460 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1461 | 15 | */ | ||
1462 | 16 | |||
1463 | 17 | import QtQuick 2.4 | ||
1464 | 18 | import QtQuick.Window 2.2 | ||
1465 | 19 | |||
1466 | 20 | Item { | ||
1467 | 21 | id: snapshotRoot | ||
1468 | 22 | property alias source: image.source | ||
1469 | 23 | property ViewFinderGeometry geometry | ||
1470 | 24 | property bool loaded: image.status == Image.Ready | ||
1471 | 25 | |||
1472 | 26 | // Rotation is locked at the moment the picture is shoot | ||
1473 | 27 | // (in case processing is long, such as with HDR) | ||
1474 | 28 | function lockOrientation() { | ||
1475 | 29 | image.rotation = Screen.angleBetween(Screen.primaryOrientation, Screen.orientation) | ||
1476 | 30 | } | ||
1477 | 31 | |||
1478 | 32 | Image { | ||
1479 | 33 | id: image | ||
1480 | 34 | anchors.centerIn: parent | ||
1481 | 35 | anchors.verticalCenterOffset: -geometry.y | ||
1482 | 36 | |||
1483 | 37 | asynchronous: true | ||
1484 | 38 | cache: false | ||
1485 | 39 | fillMode: Image.PreserveAspectFit | ||
1486 | 40 | smooth: false | ||
1487 | 41 | width: rotation == 0 ? geometry.width : geometry.height | ||
1488 | 42 | height: rotation == 0 ? geometry.height : geometry.width | ||
1489 | 43 | sourceSize.width: width | ||
1490 | 44 | sourceSize.height: height | ||
1491 | 45 | } | ||
1492 | 46 | } | ||
1493 | 0 | 47 | ||
1494 | === added file 'ProcessingFeedback.qml' | |||
1495 | --- ProcessingFeedback.qml 1970-01-01 00:00:00 +0000 | |||
1496 | +++ ProcessingFeedback.qml 2016-02-26 17:17:00 +0000 | |||
1497 | @@ -0,0 +1,43 @@ | |||
1498 | 1 | /* | ||
1499 | 2 | * Copyright 2016 Canonical Ltd. | ||
1500 | 3 | * | ||
1501 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1502 | 5 | * it under the terms of the GNU General Public License as published by | ||
1503 | 6 | * the Free Software Foundation; version 3. | ||
1504 | 7 | * | ||
1505 | 8 | * This program is distributed in the hope that it will be useful, | ||
1506 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1507 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1508 | 11 | * GNU General Public License for more details. | ||
1509 | 12 | * | ||
1510 | 13 | * You should have received a copy of the GNU General Public License | ||
1511 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1512 | 15 | */ | ||
1513 | 16 | |||
1514 | 17 | import QtQuick 2.4 | ||
1515 | 18 | import Ubuntu.Components 1.3 | ||
1516 | 19 | |||
1517 | 20 | Item { | ||
1518 | 21 | id: processingFeedback | ||
1519 | 22 | |||
1520 | 23 | property bool processing: false | ||
1521 | 24 | |||
1522 | 25 | Timer { | ||
1523 | 26 | interval: 2000 | ||
1524 | 27 | running: processing | ||
1525 | 28 | onTriggered: spinner.running = true | ||
1526 | 29 | } | ||
1527 | 30 | |||
1528 | 31 | onProcessingChanged: if (!processing) spinner.running = false | ||
1529 | 32 | |||
1530 | 33 | ActivityIndicator { | ||
1531 | 34 | id: spinner | ||
1532 | 35 | opacity: running ? 1.0 : 0.0 | ||
1533 | 36 | Behavior on opacity { | ||
1534 | 37 | OpacityAnimator { | ||
1535 | 38 | duration: UbuntuAnimation.SnapDuration | ||
1536 | 39 | easing: UbuntuAnimation.StandardEasing | ||
1537 | 40 | } | ||
1538 | 41 | } | ||
1539 | 42 | } | ||
1540 | 43 | } | ||
1541 | 0 | 44 | ||
1542 | === modified file 'SharePopover.qml' | |||
1543 | --- SharePopover.qml 2015-10-22 12:46:34 +0000 | |||
1544 | +++ SharePopover.qml 2016-02-26 17:17:00 +0000 | |||
1545 | @@ -17,7 +17,7 @@ | |||
1546 | 17 | import QtQuick 2.4 | 17 | import QtQuick 2.4 |
1547 | 18 | import Ubuntu.Components 1.3 | 18 | import Ubuntu.Components 1.3 |
1548 | 19 | import Ubuntu.Components.Popups 1.3 | 19 | import Ubuntu.Components.Popups 1.3 |
1550 | 20 | import Ubuntu.Content 0.1 | 20 | import Ubuntu.Content 1.3 |
1551 | 21 | 21 | ||
1552 | 22 | PopupBase { | 22 | PopupBase { |
1553 | 23 | property var transferContentType | 23 | property var transferContentType |
1554 | @@ -31,17 +31,9 @@ | |||
1555 | 31 | contentPeerPicker.peerSelected.connect(contentPeerSelected); | 31 | contentPeerPicker.peerSelected.connect(contentPeerSelected); |
1556 | 32 | } | 32 | } |
1557 | 33 | 33 | ||
1558 | 34 | // FIXME: ContentPeerPicker should either have a background or not, not half of one | ||
1559 | 35 | Rectangle { | ||
1560 | 36 | anchors.fill: parent | ||
1561 | 37 | color: theme.palette.normal.overlay | ||
1562 | 38 | } | ||
1563 | 39 | |||
1564 | 40 | ContentPeerPicker { | 34 | ContentPeerPicker { |
1565 | 41 | id: contentPeerPicker | 35 | id: contentPeerPicker |
1566 | 42 | // FIXME: ContentPeerPicker should define an implicit size and not refer to its parent | 36 | // FIXME: ContentPeerPicker should define an implicit size and not refer to its parent |
1567 | 43 | // FIXME: ContentPeerPicker should not be visible: false by default | ||
1568 | 44 | visible: true | ||
1569 | 45 | Component.onCompleted: { | 37 | Component.onCompleted: { |
1570 | 46 | contentType = parent.transferContentType; | 38 | contentType = parent.transferContentType; |
1571 | 47 | } | 39 | } |
1572 | 48 | 40 | ||
1573 | === removed file 'Snapshot.qml' | |||
1574 | --- Snapshot.qml 2015-10-22 12:21:14 +0000 | |||
1575 | +++ Snapshot.qml 1970-01-01 00:00:00 +0000 | |||
1576 | @@ -1,98 +0,0 @@ | |||
1577 | 1 | /* | ||
1578 | 2 | * Copyright (C) 2012 Canonical, Ltd. | ||
1579 | 3 | * | ||
1580 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1581 | 5 | * it under the terms of the GNU General Public License as published by | ||
1582 | 6 | * the Free Software Foundation; version 3. | ||
1583 | 7 | * | ||
1584 | 8 | * This program is distributed in the hope that it will be useful, | ||
1585 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1586 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1587 | 11 | * GNU General Public License for more details. | ||
1588 | 12 | * | ||
1589 | 13 | * You should have received a copy of the GNU General Public License | ||
1590 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1591 | 15 | */ | ||
1592 | 16 | |||
1593 | 17 | import QtQuick 2.4 | ||
1594 | 18 | import QtQuick.Window 2.2 | ||
1595 | 19 | import Ubuntu.Components 1.3 | ||
1596 | 20 | |||
1597 | 21 | Item { | ||
1598 | 22 | id: snapshotRoot | ||
1599 | 23 | property alias source: snapshot.source | ||
1600 | 24 | property alias sliding: shoot.running | ||
1601 | 25 | property int orientation | ||
1602 | 26 | property ViewFinderGeometry geometry | ||
1603 | 27 | property bool deviceDefaultIsPortrait: true | ||
1604 | 28 | property bool loading: snapshot.status == Image.Loading | ||
1605 | 29 | |||
1606 | 30 | function startOutAnimation() { | ||
1607 | 31 | shoot.restart() | ||
1608 | 32 | } | ||
1609 | 33 | |||
1610 | 34 | visible: false | ||
1611 | 35 | |||
1612 | 36 | Item { | ||
1613 | 37 | id: container | ||
1614 | 38 | width: parent.width | ||
1615 | 39 | height: parent.height | ||
1616 | 40 | |||
1617 | 41 | Image { | ||
1618 | 42 | id: snapshot | ||
1619 | 43 | anchors.centerIn: parent | ||
1620 | 44 | anchors.verticalCenterOffset: -geometry.y | ||
1621 | 45 | rotation: snapshotRoot.orientation * -1 | ||
1622 | 46 | |||
1623 | 47 | asynchronous: true | ||
1624 | 48 | cache: false | ||
1625 | 49 | fillMode: Image.PreserveAspectFit | ||
1626 | 50 | smooth: false | ||
1627 | 51 | width: deviceDefaultIsPortrait ? geometry.height : geometry.width | ||
1628 | 52 | height: deviceDefaultIsPortrait ? geometry.width : geometry.height | ||
1629 | 53 | sourceSize.width: width | ||
1630 | 54 | sourceSize.height: height | ||
1631 | 55 | } | ||
1632 | 56 | |||
1633 | 57 | Image { | ||
1634 | 58 | id: shadow | ||
1635 | 59 | |||
1636 | 60 | property bool rotated: (snapshot.rotation % 180) != 0 | ||
1637 | 61 | height: rotated ? snapshot.width : snapshot.height | ||
1638 | 62 | width: units.gu(2) | ||
1639 | 63 | x: (container.width - (rotated ? snapshot.height : snapshot.width)) / 2 - width | ||
1640 | 64 | source: "assets/shadow.png" | ||
1641 | 65 | fillMode: Image.Stretch | ||
1642 | 66 | asynchronous: true | ||
1643 | 67 | cache: false | ||
1644 | 68 | } | ||
1645 | 69 | } | ||
1646 | 70 | property int orientationAngle: Screen.angleBetween(Screen.primaryOrientation, Screen.orientation) | ||
1647 | 71 | property var angleToOrientation: {0: "PORTRAIT", | ||
1648 | 72 | 90: "LANDSCAPE", | ||
1649 | 73 | 270: "INVERTED_LANDSCAPE"} | ||
1650 | 74 | |||
1651 | 75 | SequentialAnimation { | ||
1652 | 76 | id: shoot | ||
1653 | 77 | |||
1654 | 78 | PropertyAction { target: snapshotRoot; property: "visible"; value: true } | ||
1655 | 79 | PauseAnimation { duration: 150 } | ||
1656 | 80 | XAnimator { | ||
1657 | 81 | target: container | ||
1658 | 82 | to: angleToOrientation[orientationAngle] == "PORTRAIT" ? container.width + shadow.width : 0 | ||
1659 | 83 | duration: UbuntuAnimation.BriskDuration | ||
1660 | 84 | easing: UbuntuAnimation.StandardEasing | ||
1661 | 85 | } | ||
1662 | 86 | YAnimator { | ||
1663 | 87 | target: container | ||
1664 | 88 | to: angleToOrientation[orientationAngle] == "LANDSCAPE" ? container.height + shadow.width : | ||
1665 | 89 | angleToOrientation[orientationAngle] == "INVERTED_LANDSCAPE" ? -(container.height + shadow.width) : 0 | ||
1666 | 90 | duration: UbuntuAnimation.BriskDuration | ||
1667 | 91 | easing: UbuntuAnimation.StandardEasing | ||
1668 | 92 | } | ||
1669 | 93 | PropertyAction { target: snapshot; property: "source"; value: ""} | ||
1670 | 94 | PropertyAction { target: snapshotRoot; property: "visible"; value: false } | ||
1671 | 95 | PropertyAction { target: container; property: "x"; value: 0 } | ||
1672 | 96 | PropertyAction { target: container; property: "y"; value: 0 } | ||
1673 | 97 | } | ||
1674 | 98 | } | ||
1675 | 99 | 0 | ||
1676 | === modified file 'ViewFinderExportConfirmation.qml' | |||
1677 | --- ViewFinderExportConfirmation.qml 2015-12-10 12:17:49 +0000 | |||
1678 | +++ ViewFinderExportConfirmation.qml 2016-02-26 17:17:00 +0000 | |||
1679 | @@ -22,39 +22,56 @@ | |||
1680 | 22 | 22 | ||
1681 | 23 | property bool isVideo | 23 | property bool isVideo |
1682 | 24 | property string mediaPath | 24 | property string mediaPath |
1700 | 25 | property Snapshot snapshot | 25 | property bool waitingForPictureCapture: false |
1701 | 26 | 26 | ||
1702 | 27 | function confirmExport(path) { | 27 | signal hideRequested() |
1703 | 28 | viewFinder.visible = false; | 28 | signal showRequested() |
1704 | 29 | viewFinderOverlay.visible = false; | 29 | property ViewFinderGeometry viewFinderGeometry |
1688 | 30 | mediaPath = path; | ||
1689 | 31 | if (!isVideo) snapshot.visible = true; | ||
1690 | 32 | visible = true; | ||
1691 | 33 | } | ||
1692 | 34 | |||
1693 | 35 | function hide() { | ||
1694 | 36 | viewFinder.visible = true; | ||
1695 | 37 | viewFinderOverlay.visible = true; | ||
1696 | 38 | snapshot.source = ""; | ||
1697 | 39 | snapshot.visible = false; | ||
1698 | 40 | visible = false; | ||
1699 | 41 | } | ||
1705 | 42 | 30 | ||
1706 | 43 | visible: false | 31 | visible: false |
1707 | 44 | 32 | ||
1708 | 33 | // For videos show immediately without waiting for the preview to load, | ||
1709 | 34 | // since we will show a progress indicator instead of the preview | ||
1710 | 35 | onMediaPathChanged: if (mediaPath && isVideo) showRequested() | ||
1711 | 36 | |||
1712 | 37 | function photoCaptureStarted() { | ||
1713 | 38 | controls.item.lockPictureOrientation() | ||
1714 | 39 | waitingForPictureCapture = true | ||
1715 | 40 | } | ||
1716 | 41 | |||
1717 | 45 | Loader { | 42 | Loader { |
1718 | 43 | id: controls | ||
1719 | 46 | anchors.fill: parent | 44 | anchors.fill: parent |
1720 | 47 | asynchronous: true | 45 | asynchronous: true |
1721 | 48 | sourceComponent: Component { | 46 | sourceComponent: Component { |
1722 | 49 | Item { | 47 | Item { |
1723 | 48 | function lockPictureOrientation() { pictureReview.lockOrientation() } | ||
1724 | 49 | |||
1725 | 50 | VideoReview { | 50 | VideoReview { |
1726 | 51 | id: videoReview | 51 | id: videoReview |
1727 | 52 | anchors.fill: parent | 52 | anchors.fill: parent |
1728 | 53 | bottomMargin: buttons.height | 53 | bottomMargin: buttons.height |
1730 | 54 | videoPath: mediaPath | 54 | videoPath: isVideo ? mediaPath : "" |
1731 | 55 | visible: isVideo | 55 | visible: isVideo |
1732 | 56 | } | 56 | } |
1733 | 57 | 57 | ||
1734 | 58 | PictureReview { | ||
1735 | 59 | id: pictureReview | ||
1736 | 60 | anchors.fill: parent | ||
1737 | 61 | visible: !isVideo | ||
1738 | 62 | geometry: viewFinderGeometry | ||
1739 | 63 | source: !isVideo ? mediaPath : "" | ||
1740 | 64 | |||
1741 | 65 | // Show export confirmation only when the snapshot is loaded to prevent the | ||
1742 | 66 | // screen being black while the image loads | ||
1743 | 67 | onLoadedChanged: { | ||
1744 | 68 | if (loaded) { | ||
1745 | 69 | viewFinderExportConfirmation.showRequested() | ||
1746 | 70 | waitingForPictureCapture = false | ||
1747 | 71 | } | ||
1748 | 72 | } | ||
1749 | 73 | } | ||
1750 | 74 | |||
1751 | 58 | Item { | 75 | Item { |
1752 | 59 | id: buttons | 76 | id: buttons |
1753 | 60 | anchors.bottom: parent.bottom | 77 | anchors.bottom: parent.bottom |
1754 | @@ -74,7 +91,7 @@ | |||
1755 | 74 | } | 91 | } |
1756 | 75 | 92 | ||
1757 | 76 | iconName: "reload" | 93 | iconName: "reload" |
1759 | 77 | onClicked: viewFinderExportConfirmation.hide() | 94 | onClicked: hideRequested() |
1760 | 78 | } | 95 | } |
1761 | 79 | 96 | ||
1762 | 80 | CircleButton { | 97 | CircleButton { |
1763 | @@ -90,8 +107,9 @@ | |||
1764 | 90 | 107 | ||
1765 | 91 | iconName: "ok" | 108 | iconName: "ok" |
1766 | 92 | onClicked: { | 109 | onClicked: { |
1768 | 93 | viewFinderExportConfirmation.hide(); | 110 | hideRequested(); |
1769 | 94 | main.exportContent([mediaPath]); | 111 | main.exportContent([mediaPath]); |
1770 | 112 | mediaPath = ""; | ||
1771 | 95 | } | 113 | } |
1772 | 96 | } | 114 | } |
1773 | 97 | 115 | ||
1774 | @@ -108,8 +126,9 @@ | |||
1775 | 108 | 126 | ||
1776 | 109 | iconName: "close" | 127 | iconName: "close" |
1777 | 110 | onClicked: { | 128 | onClicked: { |
1779 | 111 | viewFinderExportConfirmation.hide(); | 129 | hideRequested(); |
1780 | 112 | main.cancelExport(); | 130 | main.cancelExport(); |
1781 | 131 | mediaPath = ""; | ||
1782 | 113 | } | 132 | } |
1783 | 114 | } | 133 | } |
1784 | 115 | } | 134 | } |
1785 | 116 | 135 | ||
1786 | === modified file 'ViewFinderOverlay.qml' | |||
1787 | --- ViewFinderOverlay.qml 2016-01-11 15:07:58 +0000 | |||
1788 | +++ ViewFinderOverlay.qml 2016-02-26 17:17:00 +0000 | |||
1789 | @@ -32,6 +32,7 @@ | |||
1790 | 32 | property real revealProgress: noSpaceHint.visible ? 1.0 : bottomEdge.progress | 32 | property real revealProgress: noSpaceHint.visible ? 1.0 : bottomEdge.progress |
1791 | 33 | property var controls: controls | 33 | property var controls: controls |
1792 | 34 | property var settings: settings | 34 | property var settings: settings |
1793 | 35 | property bool readyForCapture | ||
1794 | 35 | 36 | ||
1795 | 36 | function showFocusRing(x, y) { | 37 | function showFocusRing(x, y) { |
1796 | 37 | focusRing.center = Qt.point(x, y); | 38 | focusRing.center = Qt.point(x, y); |
1797 | @@ -217,12 +218,31 @@ | |||
1798 | 217 | photoResolutionOptionsModel.insert(1, optionFitting); | 218 | photoResolutionOptionsModel.insert(1, optionFitting); |
1799 | 218 | } | 219 | } |
1800 | 219 | 220 | ||
1801 | 221 | // If resolution setting is not supported select the resolution automatically | ||
1802 | 220 | var photoResolution = settings["photoResolution" + camera.advanced.activeCameraIndex]; | 222 | var photoResolution = settings["photoResolution" + camera.advanced.activeCameraIndex]; |
1808 | 221 | // If resolution setting chosen is not supported select the fitting resolution | 223 | if (!isResolutionAnOption(photoResolution)) { |
1809 | 222 | if (photoResolution != optionFitting.value && | 224 | settings["photoResolution" + camera.advanced.activeCameraIndex] = getAutomaticResolution(); |
1810 | 223 | photoResolution != optionMaximum.value) { | 225 | } |
1811 | 224 | settings["photoResolution" + camera.advanced.activeCameraIndex] = optionFitting.value; | 226 | } |
1812 | 225 | } | 227 | |
1813 | 228 | function getAutomaticResolution() { | ||
1814 | 229 | var fittingResolution = sizeToString(camera.advanced.fittingResolution); | ||
1815 | 230 | var maximumResolution = sizeToString(camera.advanced.maximumResolution); | ||
1816 | 231 | if (isResolutionAnOption(fittingResolution)) { | ||
1817 | 232 | return fittingResolution; | ||
1818 | 233 | } else { | ||
1819 | 234 | return maximumResolution; | ||
1820 | 235 | } | ||
1821 | 236 | } | ||
1822 | 237 | |||
1823 | 238 | function isResolutionAnOption(resolution) { | ||
1824 | 239 | for (var i=0; i<photoResolutionOptionsModel.count; i++) { | ||
1825 | 240 | var option = photoResolutionOptionsModel.get(i); | ||
1826 | 241 | if (option.value == resolution) { | ||
1827 | 242 | return true; | ||
1828 | 243 | } | ||
1829 | 244 | } | ||
1830 | 245 | return false; | ||
1831 | 226 | } | 246 | } |
1832 | 227 | 247 | ||
1833 | 228 | function updateResolutionOptions() { | 248 | function updateResolutionOptions() { |
1834 | @@ -249,9 +269,9 @@ | |||
1835 | 249 | settings.videoResolution = sizeToString(camera.advanced.videoRecorderResolution); | 269 | settings.videoResolution = sizeToString(camera.advanced.videoRecorderResolution); |
1836 | 250 | updateResolutionOptions(); | 270 | updateResolutionOptions(); |
1837 | 251 | 271 | ||
1839 | 252 | // If no resolution has ever been chosen, select the one that fits the screen | 272 | // If no resolution has ever been chosen, select one automatically |
1840 | 253 | if (!hasPhotoResolutionSetting) { | 273 | if (!hasPhotoResolutionSetting) { |
1842 | 254 | settings["photoResolution" + camera.advanced.activeCameraIndex] = sizeToString(camera.advanced.fittingResolution); | 274 | settings["photoResolution" + camera.advanced.activeCameraIndex] = getAutomaticResolution(); |
1843 | 255 | } | 275 | } |
1844 | 256 | } | 276 | } |
1845 | 257 | } | 277 | } |
1846 | @@ -288,16 +308,6 @@ | |||
1847 | 288 | && !camera.photoCaptureInProgress | 308 | && !camera.photoCaptureInProgress |
1848 | 289 | opacity: enabled ? 1.0 : 0.3 | 309 | opacity: enabled ? 1.0 : 0.3 |
1849 | 290 | 310 | ||
1850 | 291 | Item { | ||
1851 | 292 | /* Use the 'trigger' feature of Panel so that tapping on the Panel | ||
1852 | 293 | has the same effect as tapping outside of it (bottomEdgeClose) */ | ||
1853 | 294 | id: clickReceiver | ||
1854 | 295 | anchors.fill: parent | ||
1855 | 296 | function trigger() { | ||
1856 | 297 | optionsOverlayClose(); | ||
1857 | 298 | } | ||
1858 | 299 | } | ||
1859 | 300 | |||
1860 | 301 | /* At startup, opened is false and 'bottomEdge.height' is 0 until | 311 | /* At startup, opened is false and 'bottomEdge.height' is 0 until |
1861 | 302 | optionsOverlayLoader has finished loading. When that happens | 312 | optionsOverlayLoader has finished loading. When that happens |
1862 | 303 | 'bottomEdge.height' becomes non 0 and 'bottomEdge.position' which | 313 | 'bottomEdge.height' becomes non 0 and 'bottomEdge.position' which |
1863 | @@ -321,6 +331,7 @@ | |||
1864 | 321 | property bool available: true | 331 | property bool available: true |
1865 | 322 | property bool visible: true | 332 | property bool visible: true |
1866 | 323 | property bool showInIndicators: true | 333 | property bool showInIndicators: true |
1867 | 334 | property bool colorize: !positionSource.isPrecise | ||
1868 | 324 | 335 | ||
1869 | 325 | ListElement { | 336 | ListElement { |
1870 | 326 | icon: "" | 337 | icon: "" |
1871 | @@ -492,7 +503,7 @@ | |||
1872 | 492 | property string label: i18n.tr("SD") | 503 | property string label: i18n.tr("SD") |
1873 | 493 | property bool isToggle: true | 504 | property bool isToggle: true |
1874 | 494 | property int selectedIndex: bottomEdge.indexForValue(removableStorageOptionsModel, settings.preferRemovableStorage) | 505 | property int selectedIndex: bottomEdge.indexForValue(removableStorageOptionsModel, settings.preferRemovableStorage) |
1876 | 495 | property bool available: application.removableStoragePresent | 506 | property bool available: StorageLocations.removableStoragePresent |
1877 | 496 | property bool visible: available | 507 | property bool visible: available |
1878 | 497 | 508 | ||
1879 | 498 | ListElement { | 509 | ListElement { |
1880 | @@ -555,12 +566,12 @@ | |||
1881 | 555 | } | 566 | } |
1882 | 556 | ] | 567 | ] |
1883 | 557 | 568 | ||
1885 | 558 | /* FIXME: application.removableStoragePresent is not updated dynamically. | 569 | /* FIXME: StorageLocations.removableStoragePresent is not updated dynamically. |
1886 | 559 | Workaround that by reading it when the bottom edge is opened/closed. | 570 | Workaround that by reading it when the bottom edge is opened/closed. |
1887 | 560 | */ | 571 | */ |
1888 | 561 | Connections { | 572 | Connections { |
1889 | 562 | target: bottomEdge | 573 | target: bottomEdge |
1891 | 563 | onOpenedChanged: removableStorageOptionsModel.available = application.removableStoragePresent | 574 | onOpenedChanged: removableStorageOptionsModel.available = StorageLocations.removableStoragePresent |
1892 | 564 | } | 575 | } |
1893 | 565 | 576 | ||
1894 | 566 | function indexForValue(model, value) { | 577 | function indexForValue(model, value) { |
1895 | @@ -601,6 +612,24 @@ | |||
1896 | 601 | } | 612 | } |
1897 | 602 | } | 613 | } |
1898 | 603 | } | 614 | } |
1899 | 615 | |||
1900 | 616 | triggerSize: units.gu(3) | ||
1901 | 617 | |||
1902 | 618 | Item { | ||
1903 | 619 | /* Use the 'trigger' feature of Panel so that tapping on the Panel | ||
1904 | 620 | can be acted upon */ | ||
1905 | 621 | id: clickReceiver | ||
1906 | 622 | anchors.fill: parent | ||
1907 | 623 | anchors.topMargin: -bottomEdge.triggerSize | ||
1908 | 624 | |||
1909 | 625 | function trigger() { | ||
1910 | 626 | if (bottomEdge.opened) { | ||
1911 | 627 | optionsOverlayClose(); | ||
1912 | 628 | } else { | ||
1913 | 629 | bottomEdge.open(); | ||
1914 | 630 | } | ||
1915 | 631 | } | ||
1916 | 632 | } | ||
1917 | 604 | } | 633 | } |
1918 | 605 | } | 634 | } |
1919 | 606 | 635 | ||
1920 | @@ -669,11 +698,11 @@ | |||
1921 | 669 | 698 | ||
1922 | 670 | if (camera.captureMode == Camera.CaptureVideo) { | 699 | if (camera.captureMode == Camera.CaptureVideo) { |
1923 | 671 | if (main.contentExportMode) { | 700 | if (main.contentExportMode) { |
1927 | 672 | camera.videoRecorder.outputLocation = application.temporaryLocation; | 701 | camera.videoRecorder.outputLocation = StorageLocations.temporaryLocation; |
1928 | 673 | } else if (application.removableStoragePresent && settings.preferRemovableStorage) { | 702 | } else if (StorageLocations.removableStoragePresent && settings.preferRemovableStorage) { |
1929 | 674 | camera.videoRecorder.outputLocation = application.removableStorageVideosLocation; | 703 | camera.videoRecorder.outputLocation = StorageLocations.removableStorageVideosLocation; |
1930 | 675 | } else { | 704 | } else { |
1932 | 676 | camera.videoRecorder.outputLocation = application.videosLocation; | 705 | camera.videoRecorder.outputLocation = StorageLocations.videosLocation; |
1933 | 677 | } | 706 | } |
1934 | 678 | 707 | ||
1935 | 679 | if (camera.videoRecorder.recorderState == CameraRecorder.StoppedState) { | 708 | if (camera.videoRecorder.recorderState == CameraRecorder.StoppedState) { |
1936 | @@ -684,11 +713,10 @@ | |||
1937 | 684 | if (!main.contentExportMode) { | 713 | if (!main.contentExportMode) { |
1938 | 685 | shootFeedback.start(); | 714 | shootFeedback.start(); |
1939 | 686 | } | 715 | } |
1940 | 716 | camera.photoCaptureInProgress = true; | ||
1941 | 687 | camera.imageCapture.setMetadata("Orientation", orientation); | 717 | camera.imageCapture.setMetadata("Orientation", orientation); |
1942 | 688 | var position = positionSource.position; | 718 | var position = positionSource.position; |
1946 | 689 | if (settings.gpsEnabled && positionSource.valid | 719 | if (settings.gpsEnabled && positionSource.isPrecise) { |
1944 | 690 | && position.latitudeValid | ||
1945 | 691 | && position.longitudeValid) { | ||
1947 | 692 | camera.imageCapture.setMetadata("GPSLatitude", position.coordinate.latitude); | 720 | camera.imageCapture.setMetadata("GPSLatitude", position.coordinate.latitude); |
1948 | 693 | camera.imageCapture.setMetadata("GPSLongitude", position.coordinate.longitude); | 721 | camera.imageCapture.setMetadata("GPSLongitude", position.coordinate.longitude); |
1949 | 694 | camera.imageCapture.setMetadata("GPSTimeStamp", position.timestamp); | 722 | camera.imageCapture.setMetadata("GPSTimeStamp", position.timestamp); |
1950 | @@ -698,13 +726,12 @@ | |||
1951 | 698 | } | 726 | } |
1952 | 699 | } | 727 | } |
1953 | 700 | 728 | ||
1954 | 701 | camera.photoCaptureInProgress = true; | ||
1955 | 702 | if (main.contentExportMode) { | 729 | if (main.contentExportMode) { |
1959 | 703 | camera.imageCapture.captureToLocation(application.temporaryLocation); | 730 | camera.imageCapture.captureToLocation(StorageLocations.temporaryLocation); |
1960 | 704 | } else if (application.removableStoragePresent && settings.preferRemovableStorage) { | 731 | } else if (StorageLocations.removableStoragePresent && settings.preferRemovableStorage) { |
1961 | 705 | camera.imageCapture.captureToLocation(application.removableStoragePicturesLocation); | 732 | camera.imageCapture.captureToLocation(StorageLocations.removableStoragePicturesLocation); |
1962 | 706 | } else { | 733 | } else { |
1964 | 707 | camera.imageCapture.captureToLocation(application.picturesLocation); | 734 | camera.imageCapture.captureToLocation(StorageLocations.picturesLocation); |
1965 | 708 | } | 735 | } |
1966 | 709 | } | 736 | } |
1967 | 710 | } | 737 | } |
1968 | @@ -760,6 +787,11 @@ | |||
1969 | 760 | id: positionSource | 787 | id: positionSource |
1970 | 761 | updateInterval: 1000 | 788 | updateInterval: 1000 |
1971 | 762 | active: settings.gpsEnabled | 789 | active: settings.gpsEnabled |
1972 | 790 | property bool isPrecise: valid | ||
1973 | 791 | && position.latitudeValid | ||
1974 | 792 | && position.longitudeValid | ||
1975 | 793 | && (!position.horizontalAccuracyValid || | ||
1976 | 794 | position.horizontalAccuracy <= 100) | ||
1977 | 763 | } | 795 | } |
1978 | 764 | 796 | ||
1979 | 765 | Connections { | 797 | Connections { |
1980 | @@ -800,7 +832,7 @@ | |||
1981 | 800 | horizontalCenter: parent.horizontalCenter | 832 | horizontalCenter: parent.horizontalCenter |
1982 | 801 | } | 833 | } |
1983 | 802 | 834 | ||
1985 | 803 | enabled: camera.imageCapture.ready && !storageMonitor.diskSpaceCriticallyLow | 835 | enabled: viewFinderOverlay.readyForCapture && !storageMonitor.diskSpaceCriticallyLow |
1986 | 804 | state: (camera.captureMode == Camera.CaptureVideo) ? | 836 | state: (camera.captureMode == Camera.CaptureVideo) ? |
1987 | 805 | ((camera.videoRecorder.recorderState == CameraRecorder.StoppedState) ? "record_off" : "record_on") : | 837 | ((camera.videoRecorder.recorderState == CameraRecorder.StoppedState) ? "record_off" : "record_on") : |
1988 | 806 | "camera" | 838 | "camera" |
1989 | @@ -878,15 +910,19 @@ | |||
1990 | 878 | 910 | ||
1991 | 879 | MouseArea { | 911 | MouseArea { |
1992 | 880 | id: manualFocusMouseArea | 912 | id: manualFocusMouseArea |
1995 | 881 | anchors.fill: parent | 913 | anchors { |
1996 | 882 | enabled: !camera.photoCaptureInProgress | 914 | fill: parent |
1997 | 915 | // Pinch gestures need more clearance at the edges of the screen, but | ||
1998 | 916 | // tap to focus should be safe all the way to the edges themselves instead. | ||
1999 | 917 | leftMargin: -bottomEdgeIndicators.height | ||
2000 | 918 | rightMargin: -bottomEdgeIndicators.height | ||
2001 | 919 | } | ||
2002 | 920 | enabled: camera.focus.isFocusPointModeSupported(Camera.FocusPointCustom) && | ||
2003 | 921 | !camera.photoCaptureInProgress | ||
2004 | 883 | onClicked: { | 922 | onClicked: { |
2005 | 884 | camera.manualFocus(mouse.x, mouse.y); | 923 | camera.manualFocus(mouse.x, mouse.y); |
2006 | 885 | mouse.accepted = false; | 924 | mouse.accepted = false; |
2007 | 886 | } | 925 | } |
2008 | 887 | // FIXME: calling 'isFocusPointModeSupported' fails with | ||
2009 | 888 | // "Error: Unknown method parameter type: QDeclarativeCamera::FocusPointMode" | ||
2010 | 889 | //enabled: camera.focus.isFocusPointModeSupported(Camera.FocusPointCustom) | ||
2011 | 890 | } | 926 | } |
2012 | 891 | } | 927 | } |
2013 | 892 | 928 | ||
2014 | @@ -941,16 +977,29 @@ | |||
2015 | 941 | } | 977 | } |
2016 | 942 | } | 978 | } |
2017 | 943 | 979 | ||
2018 | 980 | ProcessingFeedback { | ||
2019 | 981 | anchors { | ||
2020 | 982 | top: parent.top | ||
2021 | 983 | topMargin: units.gu(2) | ||
2022 | 984 | left: parent.left | ||
2023 | 985 | leftMargin: units.gu(2) | ||
2024 | 986 | } | ||
2025 | 987 | processing: camera.photoCaptureInProgress | ||
2026 | 988 | } | ||
2027 | 989 | |||
2028 | 944 | StorageMonitor { | 990 | StorageMonitor { |
2029 | 945 | id: storageMonitor | 991 | id: storageMonitor |
2032 | 946 | location: (application.removableStoragePresent && settings.preferRemovableStorage) ? | 992 | location: (StorageLocations.removableStoragePresent && settings.preferRemovableStorage) ? |
2033 | 947 | application.removableStorageLocation : application.videosLocation | 993 | StorageLocations.removableStorageLocation : StorageLocations.videosLocation |
2034 | 948 | onDiskSpaceLowChanged: if (storageMonitor.diskSpaceLow && !storageMonitor.diskSpaceCriticallyLow) { | 994 | onDiskSpaceLowChanged: if (storageMonitor.diskSpaceLow && !storageMonitor.diskSpaceCriticallyLow) { |
2035 | 949 | PopupUtils.open(freeSpaceLowDialogComponent); | 995 | PopupUtils.open(freeSpaceLowDialogComponent); |
2036 | 950 | } | 996 | } |
2037 | 951 | onDiskSpaceCriticallyLowChanged: if (storageMonitor.diskSpaceCriticallyLow) { | 997 | onDiskSpaceCriticallyLowChanged: if (storageMonitor.diskSpaceCriticallyLow) { |
2038 | 952 | camera.videoRecorder.stop(); | 998 | camera.videoRecorder.stop(); |
2039 | 953 | } | 999 | } |
2040 | 1000 | onIsWriteableChanged: if (!isWriteable && !diskSpaceLow && !main.contentExportMode) { | ||
2041 | 1001 | PopupUtils.open(readOnlyMediaDialogComponent); | ||
2042 | 1002 | } | ||
2043 | 954 | } | 1003 | } |
2044 | 955 | 1004 | ||
2045 | 956 | NoSpaceHint { | 1005 | NoSpaceHint { |
2046 | @@ -974,6 +1023,20 @@ | |||
2047 | 974 | } | 1023 | } |
2048 | 975 | } | 1024 | } |
2049 | 976 | 1025 | ||
2050 | 1026 | Component { | ||
2051 | 1027 | id: readOnlyMediaDialogComponent | ||
2052 | 1028 | Dialog { | ||
2053 | 1029 | id: readOnlyMediaDialog | ||
2054 | 1030 | objectName: "readOnlyMediaDialog" | ||
2055 | 1031 | title: i18n.tr("External storage not writeable") | ||
2056 | 1032 | text: i18n.tr("It does not seem possible to write to your external storage media. Trying to eject and insert it again might solve the issue, or you might need to format it.") | ||
2057 | 1033 | Button { | ||
2058 | 1034 | text: i18n.tr("Cancel") | ||
2059 | 1035 | onClicked: PopupUtils.close(readOnlyMediaDialog) | ||
2060 | 1036 | } | ||
2061 | 1037 | } | ||
2062 | 1038 | } | ||
2063 | 1039 | |||
2064 | 977 | Connections { | 1040 | Connections { |
2065 | 978 | id: permissionErrorMonitor | 1041 | id: permissionErrorMonitor |
2066 | 979 | property var currentPermissionsDialog: null | 1042 | property var currentPermissionsDialog: null |
2067 | 980 | 1043 | ||
2068 | === modified file 'ViewFinderOverlayLoader.qml' | |||
2069 | --- ViewFinderOverlayLoader.qml 2016-01-07 08:03:57 +0000 | |||
2070 | +++ ViewFinderOverlayLoader.qml 2016-02-26 17:17:00 +0000 | |||
2071 | @@ -24,6 +24,7 @@ | |||
2072 | 24 | property real revealProgress: loader.item ? loader.item.revealProgress : 0 | 24 | property real revealProgress: loader.item ? loader.item.revealProgress : 0 |
2073 | 25 | property var controls: loader.item ? loader.item.controls : null | 25 | property var controls: loader.item ? loader.item.controls : null |
2074 | 26 | property var settings: loader.item.settings | 26 | property var settings: loader.item.settings |
2075 | 27 | property bool readyForCapture | ||
2076 | 27 | 28 | ||
2077 | 28 | function showFocusRing(x, y) { | 29 | function showFocusRing(x, y) { |
2078 | 29 | loader.item.showFocusRing(x, y); | 30 | loader.item.showFocusRing(x, y); |
2079 | @@ -35,6 +36,8 @@ | |||
2080 | 35 | 36 | ||
2081 | 36 | asynchronous: true | 37 | asynchronous: true |
2082 | 37 | Component.onCompleted: { | 38 | Component.onCompleted: { |
2084 | 38 | loader.setSource("ViewFinderOverlay.qml", { "camera": loader.camera }); | 39 | loader.setSource("ViewFinderOverlay.qml", { "camera": loader.camera, |
2085 | 40 | "readyForCapture": Qt.binding(function() { return loader.readyForCapture}) | ||
2086 | 41 | }); | ||
2087 | 39 | } | 42 | } |
2088 | 40 | } | 43 | } |
2089 | 41 | 44 | ||
2090 | === modified file 'ViewFinderView.qml' | |||
2091 | --- ViewFinderView.qml 2016-01-14 15:55:52 +0000 | |||
2092 | +++ ViewFinderView.qml 2016-02-26 17:17:00 +0000 | |||
2093 | @@ -17,6 +17,7 @@ | |||
2094 | 17 | import QtQuick 2.4 | 17 | import QtQuick 2.4 |
2095 | 18 | import QtQuick.Window 2.2 | 18 | import QtQuick.Window 2.2 |
2096 | 19 | import Ubuntu.Components 1.3 | 19 | import Ubuntu.Components 1.3 |
2097 | 20 | import Ubuntu.Components.Popups 1.3 | ||
2098 | 20 | import QtMultimedia 5.0 | 21 | import QtMultimedia 5.0 |
2099 | 21 | import CameraApp 0.1 | 22 | import CameraApp 0.1 |
2100 | 22 | import QtGraphicalEffects 1.0 | 23 | import QtGraphicalEffects 1.0 |
2101 | @@ -96,36 +97,41 @@ | |||
2102 | 96 | property bool switchInProgress: false | 97 | property bool switchInProgress: false |
2103 | 97 | property bool photoCaptureInProgress: false | 98 | property bool photoCaptureInProgress: false |
2104 | 98 | 99 | ||
2105 | 100 | onPhotoCaptureInProgressChanged: { | ||
2106 | 101 | if (main.contentExportMode && camera.photoCaptureInProgress) { | ||
2107 | 102 | viewFinderExportConfirmation.photoCaptureStarted(); | ||
2108 | 103 | } | ||
2109 | 104 | } | ||
2110 | 105 | |||
2111 | 99 | imageCapture { | 106 | imageCapture { |
2112 | 100 | onReadyChanged: { | 107 | onReadyChanged: { |
2118 | 101 | if (camera.imageCapture.ready && main.transfer) { | 108 | if (camera.imageCapture.ready) { |
2119 | 102 | if (main.transfer.contentType === ContentType.Videos) { | 109 | if (camera.photoCaptureInProgress) { |
2120 | 103 | viewFinderView.captureMode = Camera.CaptureVideo; | 110 | if (photoRollHint.necessary && !main.transfer) photoRollHint.enable(); |
2121 | 104 | } else { | 111 | camera.photoCaptureInProgress = false; |
2122 | 105 | viewFinderView.captureMode = Camera.CaptureStillImage; | 112 | } |
2123 | 113 | |||
2124 | 114 | if (main.transfer) { | ||
2125 | 115 | if (main.transfer.contentType === ContentType.Videos) { | ||
2126 | 116 | viewFinderView.captureMode = Camera.CaptureVideo; | ||
2127 | 117 | } else { | ||
2128 | 118 | viewFinderView.captureMode = Camera.CaptureStillImage; | ||
2129 | 119 | } | ||
2130 | 106 | } | 120 | } |
2131 | 107 | } | 121 | } |
2132 | 108 | } | 122 | } |
2133 | 123 | |||
2134 | 109 | onCaptureFailed: { | 124 | onCaptureFailed: { |
2135 | 125 | console.log("Image capture failed for request " + requestId + ": " + message); | ||
2136 | 110 | camera.photoCaptureInProgress = false; | 126 | camera.photoCaptureInProgress = false; |
2149 | 111 | console.log("Capture failed for request " + requestId + ": " + message); | 127 | viewFinderOverlay.visible = true; |
2150 | 112 | } | 128 | PopupUtils.open(captureFailedDialogComponent); |
2151 | 113 | onImageCaptured: { | 129 | } |
2152 | 114 | snapshot.source = preview; | 130 | |
2141 | 115 | if (!main.contentExportMode) { | ||
2142 | 116 | viewFinderOverlay.visible = true; | ||
2143 | 117 | snapshot.startOutAnimation(); | ||
2144 | 118 | if (photoRollHint.necessary) { | ||
2145 | 119 | photoRollHint.enable(); | ||
2146 | 120 | } | ||
2147 | 121 | } | ||
2148 | 122 | } | ||
2153 | 123 | onImageSaved: { | 131 | onImageSaved: { |
2157 | 124 | if (main.contentExportMode) { | 132 | if (main.contentExportMode) viewFinderExportConfirmation.mediaPath = path; |
2158 | 125 | viewFinderExportConfirmation.confirmExport(path); | 133 | |
2156 | 126 | } | ||
2159 | 127 | viewFinderView.photoTaken(path); | 134 | viewFinderView.photoTaken(path); |
2160 | 128 | camera.photoCaptureInProgress = false; | ||
2161 | 129 | metricPhotos.increment(); | 135 | metricPhotos.increment(); |
2162 | 130 | console.log("Picture saved as " + path); | 136 | console.log("Picture saved as " + path); |
2163 | 131 | } | 137 | } |
2164 | @@ -135,15 +141,19 @@ | |||
2165 | 135 | onRecorderStateChanged: { | 141 | onRecorderStateChanged: { |
2166 | 136 | if (videoRecorder.recorderState === CameraRecorder.StoppedState) { | 142 | if (videoRecorder.recorderState === CameraRecorder.StoppedState) { |
2167 | 137 | metricVideos.increment() | 143 | metricVideos.increment() |
2168 | 138 | viewFinderOverlay.visible = true; | ||
2169 | 139 | viewFinderView.videoShot(videoRecorder.actualLocation); | 144 | viewFinderView.videoShot(videoRecorder.actualLocation); |
2170 | 140 | if (main.contentExportMode) { | 145 | if (main.contentExportMode) { |
2172 | 141 | viewFinderExportConfirmation.confirmExport(videoRecorder.actualLocation); | 146 | viewFinderExportConfirmation.mediaPath = videoRecorder.actualLocation |
2173 | 142 | } else if (photoRollHint.necessary) { | 147 | } else if (photoRollHint.necessary) { |
2174 | 143 | photoRollHint.enable(); | 148 | photoRollHint.enable(); |
2175 | 144 | } | 149 | } |
2176 | 145 | } | 150 | } |
2177 | 146 | } | 151 | } |
2178 | 152 | onErrorCodeChanged: { | ||
2179 | 153 | if (videoRecorder.errorCode !== CameraRecorder.NoError) { | ||
2180 | 154 | PopupUtils.open(captureFailedDialogComponent); | ||
2181 | 155 | } | ||
2182 | 156 | } | ||
2183 | 147 | } | 157 | } |
2184 | 148 | } | 158 | } |
2185 | 149 | 159 | ||
2186 | @@ -235,18 +245,21 @@ | |||
2187 | 235 | width: parent.width | 245 | width: parent.width |
2188 | 236 | height: parent.height | 246 | height: parent.height |
2189 | 237 | source: camera | 247 | source: camera |
2190 | 248 | opacity: ((main.contentExportMode && viewFinderExportConfirmation.waitingForPictureCapture) || | ||
2191 | 249 | (!main.contentExportMode && camera.photoCaptureInProgress && !camera.imageCapture.ready)) | ||
2192 | 250 | ? 0.1 : 1.0 | ||
2193 | 238 | 251 | ||
2194 | 239 | /* This rotation need to be applied since the camera hardware in the | 252 | /* This rotation need to be applied since the camera hardware in the |
2201 | 240 | Galaxy Nexus phone is mounted at an angle inside the device, so the video | 253 | Galaxy Nexus phone is mounted at an angle inside the device, so the video |
2202 | 241 | feed is rotated too. | 254 | feed is rotated too. |
2203 | 242 | FIXME: This should come from a system configuration option so that we | 255 | FIXME: This should come from a system configuration option so that we |
2204 | 243 | don't have to have a different codebase for each different device we want | 256 | don't have to have a different codebase for each different device we want |
2205 | 244 | to run on. Android has that information and QML has an API to reflect it: | 257 | to run on. Android has that information and QML has an API to reflect it: |
2206 | 245 | the camera.orientation property. Unfortunately it is not hooked up yet. | 258 | the camera.orientation property. Unfortunately it is not hooked up yet. |
2207 | 246 | 259 | ||
2211 | 247 | Ref.: http://doc.qt.io/qt-5/qml-qtmultimedia-camera.html#orientation-prop | 260 | Ref.: http://doc.qt.io/qt-5/qml-qtmultimedia-camera.html#orientation-prop |
2212 | 248 | http://doc.qt.io/qt-5/qcamerainfocontrol.html#cameraOrientation | 261 | http://doc.qt.io/qt-5/qcamerainfocontrol.html#cameraOrientation |
2213 | 249 | http://developer.android.com/reference/android/hardware/Camera.CameraInfo.html#orientation | 262 | http://developer.android.com/reference/android/hardware/Camera.CameraInfo.html#orientation |
2214 | 250 | */ | 263 | */ |
2215 | 251 | Component.onCompleted: { | 264 | Component.onCompleted: { |
2216 | 252 | // Set orientation only at startup because later on Screen.primaryOrientation | 265 | // Set orientation only at startup because later on Screen.primaryOrientation |
2217 | @@ -254,14 +267,6 @@ | |||
2218 | 254 | orientation = Screen.primaryOrientation === Qt.PortraitOrientation ? -90 : 0; | 267 | orientation = Screen.primaryOrientation === Qt.PortraitOrientation ? -90 : 0; |
2219 | 255 | } | 268 | } |
2220 | 256 | 269 | ||
2221 | 257 | /* Convenience item tracking the real position and size of the real video feed. | ||
2222 | 258 | Having this helps since these values depend on a lot of rules: | ||
2223 | 259 | - the feed is automatically scaled to fit the viewfinder | ||
2224 | 260 | - the viewfinder might apply a rotation to the feed, depending on device orientation | ||
2225 | 261 | - the resolution and aspect ratio of the feed changes depending on the active camera | ||
2226 | 262 | The item is also separated in a component so it can be unit tested. | ||
2227 | 263 | */ | ||
2228 | 264 | |||
2229 | 265 | transform: Rotation { | 270 | transform: Rotation { |
2230 | 266 | origin.x: viewFinder.width / 2 | 271 | origin.x: viewFinder.width / 2 |
2231 | 267 | origin.y: viewFinder.height / 2 | 272 | origin.y: viewFinder.height / 2 |
2232 | @@ -270,6 +275,13 @@ | |||
2233 | 270 | } | 275 | } |
2234 | 271 | } | 276 | } |
2235 | 272 | 277 | ||
2236 | 278 | /* Convenience item tracking the real position and size of the real video feed. | ||
2237 | 279 | Having this helps since these values depend on a lot of rules: | ||
2238 | 280 | - the feed is automatically scaled to fit the viewfinder | ||
2239 | 281 | - the viewfinder might apply a rotation to the feed, depending on device orientation | ||
2240 | 282 | - the resolution and aspect ratio of the feed changes depending on the active camera | ||
2241 | 283 | The item is also separated in a component so it can be unit tested. | ||
2242 | 284 | */ | ||
2243 | 273 | ViewFinderGeometry { | 285 | ViewFinderGeometry { |
2244 | 274 | id: viewFinderGeometry | 286 | id: viewFinderGeometry |
2245 | 275 | anchors.centerIn: parent | 287 | anchors.centerIn: parent |
2246 | @@ -330,12 +342,10 @@ | |||
2247 | 330 | anchors.fill: parent | 342 | anchors.fill: parent |
2248 | 331 | 343 | ||
2249 | 332 | function start() { | 344 | function start() { |
2250 | 333 | viewFinderOverlay.visible = false; | ||
2251 | 334 | } | 345 | } |
2252 | 335 | 346 | ||
2253 | 336 | function stop() { | 347 | function stop() { |
2254 | 337 | remainingSecsLabel.text = ""; | 348 | remainingSecsLabel.text = ""; |
2255 | 338 | viewFinderOverlay.visible = true; | ||
2256 | 339 | } | 349 | } |
2257 | 340 | 350 | ||
2258 | 341 | function showRemainingSecs(secs) { | 351 | function showRemainingSecs(secs) { |
2259 | @@ -384,7 +394,6 @@ | |||
2260 | 384 | 394 | ||
2261 | 385 | function start() { | 395 | function start() { |
2262 | 386 | shootFeedback.opacity = 1.0; | 396 | shootFeedback.opacity = 1.0; |
2263 | 387 | viewFinderOverlay.visible = false; | ||
2264 | 388 | shootFeedbackAnimation.restart(); | 397 | shootFeedbackAnimation.restart(); |
2265 | 389 | } | 398 | } |
2266 | 390 | 399 | ||
2267 | @@ -393,7 +402,7 @@ | |||
2268 | 393 | target: shootFeedback | 402 | target: shootFeedback |
2269 | 394 | from: 1.0 | 403 | from: 1.0 |
2270 | 395 | to: 0.0 | 404 | to: 0.0 |
2272 | 396 | duration: 50 | 405 | duration: UbuntuAnimation.SnapDuration |
2273 | 397 | easing: UbuntuAnimation.StandardEasing | 406 | easing: UbuntuAnimation.StandardEasing |
2274 | 398 | } | 407 | } |
2275 | 399 | } | 408 | } |
2276 | @@ -410,38 +419,76 @@ | |||
2277 | 410 | visible: radius !== 0 | 419 | visible: radius !== 0 |
2278 | 411 | } | 420 | } |
2279 | 412 | 421 | ||
2280 | 422 | PhotoRollHint { | ||
2281 | 423 | id: photoRollHint | ||
2282 | 424 | anchors.fill: parent | ||
2283 | 425 | visible: enabled | ||
2284 | 426 | |||
2285 | 427 | Connections { | ||
2286 | 428 | target: viewFinderView | ||
2287 | 429 | onInViewChanged: if (!viewFinderView.inView) photoRollHint.disable() | ||
2288 | 430 | } | ||
2289 | 431 | } | ||
2290 | 432 | |||
2291 | 413 | ViewFinderOverlayLoader { | 433 | ViewFinderOverlayLoader { |
2292 | 414 | id: viewFinderOverlay | 434 | id: viewFinderOverlay |
2293 | 415 | 435 | ||
2294 | 416 | anchors.fill: parent | 436 | anchors.fill: parent |
2295 | 417 | camera: camera | 437 | camera: camera |
2296 | 418 | opacity: status == Loader.Ready && overlayVisible && !photoRollHint.enabled ? 1.0 : 0.0 | 438 | opacity: status == Loader.Ready && overlayVisible && !photoRollHint.enabled ? 1.0 : 0.0 |
2317 | 419 | Behavior on opacity {UbuntuNumberAnimation {duration: UbuntuAnimation.SnapDuration}} | 439 | readyForCapture: main.contentExportMode && |
2318 | 420 | } | 440 | viewFinderExportConfirmation.waitingForPictureCapture ? false : camera.imageCapture.ready |
2319 | 421 | 441 | ||
2320 | 422 | PhotoRollHint { | 442 | Behavior on opacity { |
2321 | 423 | id: photoRollHint | 443 | enabled: !photoRollHint.enabled |
2322 | 424 | anchors.fill: parent | 444 | UbuntuNumberAnimation {duration: UbuntuAnimation.SnapDuration} |
2323 | 425 | visible: enabled && !snapshot.loading | 445 | } |
2324 | 426 | 446 | ||
2325 | 427 | Connections { | 447 | // Tapping anywhere on the screen should not trigger any camera |
2326 | 428 | target: viewFinderView | 448 | // controls while PhotoRoll hint is visible |
2327 | 429 | onInViewChanged: if (!viewFinderView.inView) photoRollHint.disable() | 449 | MouseArea { |
2328 | 430 | } | 450 | anchors.fill: parent |
2329 | 431 | } | 451 | enabled: photoRollHint.visible |
2330 | 432 | 452 | } | |
2311 | 433 | Snapshot { | ||
2312 | 434 | id: snapshot | ||
2313 | 435 | anchors.fill: parent | ||
2314 | 436 | orientation: viewFinder.orientation | ||
2315 | 437 | geometry: viewFinderGeometry | ||
2316 | 438 | deviceDefaultIsPortrait: Screen.primaryOrientation === Qt.PortraitOrientation | ||
2331 | 439 | } | 453 | } |
2332 | 440 | 454 | ||
2333 | 441 | ViewFinderExportConfirmation { | 455 | ViewFinderExportConfirmation { |
2334 | 442 | id: viewFinderExportConfirmation | 456 | id: viewFinderExportConfirmation |
2335 | 443 | anchors.fill: parent | 457 | anchors.fill: parent |
2337 | 444 | snapshot: snapshot | 458 | |
2338 | 445 | isVideo: main.transfer.contentType == ContentType.Videos | 459 | isVideo: main.transfer.contentType == ContentType.Videos |
2339 | 460 | viewFinderGeometry: viewFinderGeometry | ||
2340 | 461 | |||
2341 | 462 | onShowRequested: { | ||
2342 | 463 | viewFinder.visible = false; | ||
2343 | 464 | viewFinderOverlay.visible = false; | ||
2344 | 465 | visible = true; | ||
2345 | 466 | } | ||
2346 | 467 | |||
2347 | 468 | onHideRequested: { | ||
2348 | 469 | viewFinder.visible = true; | ||
2349 | 470 | viewFinderOverlay.visible = true; | ||
2350 | 471 | visible = false; | ||
2351 | 472 | } | ||
2352 | 473 | } | ||
2353 | 474 | |||
2354 | 475 | Component { | ||
2355 | 476 | id: captureFailedDialogComponent | ||
2356 | 477 | Dialog { | ||
2357 | 478 | id: captureFailedDialog | ||
2358 | 479 | objectName: "captureFailedDialog" | ||
2359 | 480 | title: i18n.tr("Capture failed") | ||
2360 | 481 | |||
2361 | 482 | // If we are capturing to an SD card the problem can be a broken card, otherwise it is probably a | ||
2362 | 483 | // crash in the driver and a reboot might fix things. | ||
2363 | 484 | text: StorageLocations.removableStorageLocation && viewFinderOverlay.settings.preferRemovableStorage ? | ||
2364 | 485 | i18n.tr("Replacing your external media, formatting it, or restarting the device might fix the problem.") : | ||
2365 | 486 | i18n.tr("Restarting your device might fix the problem.") | ||
2366 | 487 | |||
2367 | 488 | Button { | ||
2368 | 489 | text: i18n.tr("Cancel") | ||
2369 | 490 | onClicked: PopupUtils.close(captureFailedDialog) | ||
2370 | 491 | } | ||
2371 | 492 | } | ||
2372 | 446 | } | 493 | } |
2373 | 447 | } | 494 | } |
2374 | 448 | 495 | ||
2375 | === modified file 'cameraapplication.cpp' | |||
2376 | --- cameraapplication.cpp 2015-11-25 17:47:00 +0000 | |||
2377 | +++ cameraapplication.cpp 2016-02-26 17:17:00 +0000 | |||
2378 | @@ -19,14 +19,8 @@ | |||
2379 | 19 | 19 | ||
2380 | 20 | #include "cameraapplication.h" | 20 | #include "cameraapplication.h" |
2381 | 21 | 21 | ||
2382 | 22 | #include <QtCore/QDir> | ||
2383 | 23 | #include <QtCore/QUrl> | ||
2384 | 24 | #include <QtCore/QDebug> | 22 | #include <QtCore/QDebug> |
2385 | 25 | #include <QtCore/QStringList> | ||
2386 | 26 | #include <QtCore/QLibrary> | 23 | #include <QtCore/QLibrary> |
2387 | 27 | #include <QtCore/QStandardPaths> | ||
2388 | 28 | #include <QtCore/QDir> | ||
2389 | 29 | #include <QDate> | ||
2390 | 30 | #include <QQmlContext> | 24 | #include <QQmlContext> |
2391 | 31 | #include <QQmlEngine> | 25 | #include <QQmlEngine> |
2392 | 32 | #include <QScreen> | 26 | #include <QScreen> |
2393 | @@ -95,103 +89,3 @@ | |||
2394 | 95 | 89 | ||
2395 | 96 | return true; | 90 | return true; |
2396 | 97 | } | 91 | } |
2397 | 98 | |||
2398 | 99 | QString CameraApplication::picturesLocation() const | ||
2399 | 100 | { | ||
2400 | 101 | QStringList locations = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation); | ||
2401 | 102 | if (locations.isEmpty()) { | ||
2402 | 103 | return QString(); | ||
2403 | 104 | } | ||
2404 | 105 | QString location = locations.at(0) + "/" + QCoreApplication::applicationName(); | ||
2405 | 106 | QDir dir; | ||
2406 | 107 | // Transition from old directory 'camera' to new one; see bug #1363112 | ||
2407 | 108 | // https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1363112 | ||
2408 | 109 | dir.rename(locations.at(0) + "/" + "camera", location); | ||
2409 | 110 | dir.mkpath(location); | ||
2410 | 111 | return location; | ||
2411 | 112 | } | ||
2412 | 113 | |||
2413 | 114 | QString CameraApplication::videosLocation() const | ||
2414 | 115 | { | ||
2415 | 116 | QStringList locations = QStandardPaths::standardLocations(QStandardPaths::MoviesLocation); | ||
2416 | 117 | if (locations.isEmpty()) { | ||
2417 | 118 | return QString(); | ||
2418 | 119 | } | ||
2419 | 120 | QString location = locations.at(0) + "/" + QCoreApplication::applicationName(); | ||
2420 | 121 | QDir dir; | ||
2421 | 122 | // Transition from old directory 'camera' to new one; see bug #1363112 | ||
2422 | 123 | // https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1363112 | ||
2423 | 124 | dir.rename(locations.at(0) + "/" + "camera", location); | ||
2424 | 125 | dir.mkpath(location); | ||
2425 | 126 | return location; | ||
2426 | 127 | } | ||
2427 | 128 | |||
2428 | 129 | QString CameraApplication::temporaryLocation() const | ||
2429 | 130 | { | ||
2430 | 131 | QStringList locations = QStandardPaths::standardLocations(QStandardPaths::TempLocation); | ||
2431 | 132 | if (locations.isEmpty()) { | ||
2432 | 133 | return QString(); | ||
2433 | 134 | } | ||
2434 | 135 | QString location = locations.at(0); | ||
2435 | 136 | QDir dir; | ||
2436 | 137 | dir.mkpath(location); | ||
2437 | 138 | return location; | ||
2438 | 139 | } | ||
2439 | 140 | |||
2440 | 141 | bool CameraApplication::removableStoragePresent() const | ||
2441 | 142 | { | ||
2442 | 143 | return !removableStorageLocation().isEmpty(); | ||
2443 | 144 | } | ||
2444 | 145 | |||
2445 | 146 | QString CameraApplication::removableStorageLocation() const | ||
2446 | 147 | { | ||
2447 | 148 | /* FIXME: when Qt5.4 is available, switch to using newly introduced | ||
2448 | 149 | * QStorageInfo API. | ||
2449 | 150 | * Ref.: http://doc-snapshot.qt-project.org/qt5-5.4/qstorageinfo.html | ||
2450 | 151 | */ | ||
2451 | 152 | QString userName = qgetenv("USER"); | ||
2452 | 153 | QDir media("/media/" + userName); | ||
2453 | 154 | QStringList mediaDirs = media.entryList(QDir::Dirs | QDir::NoDotAndDotDot); | ||
2454 | 155 | |||
2455 | 156 | if (mediaDirs.size() > 0) { | ||
2456 | 157 | return QString("/media/" + userName + "/" + mediaDirs.at(0)); | ||
2457 | 158 | } else { | ||
2458 | 159 | return QString(); | ||
2459 | 160 | } | ||
2460 | 161 | } | ||
2461 | 162 | |||
2462 | 163 | QString CameraApplication::removableStoragePicturesLocation() const | ||
2463 | 164 | { | ||
2464 | 165 | QString storageLocation = removableStorageLocation(); | ||
2465 | 166 | if (storageLocation.isEmpty()) { | ||
2466 | 167 | return QString(); | ||
2467 | 168 | } | ||
2468 | 169 | |||
2469 | 170 | QStringList locations = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation); | ||
2470 | 171 | QString pictureDir = QString(locations.at(0)).split("/").value(3); | ||
2471 | 172 | if (pictureDir.isEmpty()){ | ||
2472 | 173 | return QString(); | ||
2473 | 174 | } | ||
2474 | 175 | QString location = storageLocation + "/" + pictureDir + "/" + QCoreApplication::applicationName(); | ||
2475 | 176 | QDir dir; | ||
2476 | 177 | dir.mkpath(location); | ||
2477 | 178 | return location; | ||
2478 | 179 | } | ||
2479 | 180 | |||
2480 | 181 | QString CameraApplication::removableStorageVideosLocation() const | ||
2481 | 182 | { | ||
2482 | 183 | QString storageLocation = removableStorageLocation(); | ||
2483 | 184 | if (storageLocation.isEmpty()) { | ||
2484 | 185 | return QString(); | ||
2485 | 186 | } | ||
2486 | 187 | |||
2487 | 188 | QStringList locations = QStandardPaths::standardLocations(QStandardPaths::MoviesLocation); | ||
2488 | 189 | QString movieDir = QString(locations.at(0)).split("/").value(3); | ||
2489 | 190 | if (movieDir.isEmpty()){ | ||
2490 | 191 | return QString(); | ||
2491 | 192 | } | ||
2492 | 193 | QString location = storageLocation + "/" + movieDir + "/" + QCoreApplication::applicationName(); | ||
2493 | 194 | QDir dir; | ||
2494 | 195 | dir.mkpath(location); | ||
2495 | 196 | return location; | ||
2496 | 197 | } | ||
2497 | 198 | 92 | ||
2498 | === modified file 'cameraapplication.h' | |||
2499 | --- cameraapplication.h 2015-11-25 17:47:00 +0000 | |||
2500 | +++ cameraapplication.h 2016-02-26 17:17:00 +0000 | |||
2501 | @@ -29,29 +29,14 @@ | |||
2502 | 29 | { | 29 | { |
2503 | 30 | Q_OBJECT | 30 | Q_OBJECT |
2504 | 31 | Q_PROPERTY(bool desktopMode READ isDesktopMode CONSTANT) | 31 | Q_PROPERTY(bool desktopMode READ isDesktopMode CONSTANT) |
2505 | 32 | Q_PROPERTY(QString picturesLocation READ picturesLocation CONSTANT) | ||
2506 | 33 | Q_PROPERTY(QString videosLocation READ videosLocation CONSTANT) | ||
2507 | 34 | Q_PROPERTY(QString temporaryLocation READ temporaryLocation CONSTANT) | ||
2508 | 35 | Q_PROPERTY(bool removableStoragePresent READ removableStoragePresent NOTIFY removableStoragePresentChanged) | ||
2509 | 36 | Q_PROPERTY(QString removableStorageLocation READ removableStorageLocation CONSTANT) | ||
2510 | 37 | Q_PROPERTY(QString removableStoragePicturesLocation READ removableStoragePicturesLocation CONSTANT) | ||
2511 | 38 | Q_PROPERTY(QString removableStorageVideosLocation READ removableStorageVideosLocation CONSTANT) | ||
2512 | 39 | 32 | ||
2513 | 40 | public: | 33 | public: |
2514 | 41 | CameraApplication(int &argc, char **argv); | 34 | CameraApplication(int &argc, char **argv); |
2515 | 42 | virtual ~CameraApplication(); | 35 | virtual ~CameraApplication(); |
2516 | 43 | bool setup(); | 36 | bool setup(); |
2517 | 44 | bool isDesktopMode() const; | 37 | bool isDesktopMode() const; |
2518 | 45 | QString picturesLocation() const; | ||
2519 | 46 | QString videosLocation() const; | ||
2520 | 47 | QString temporaryLocation() const; | ||
2521 | 48 | bool removableStoragePresent() const; | ||
2522 | 49 | QString removableStorageLocation() const; | ||
2523 | 50 | QString removableStoragePicturesLocation() const; | ||
2524 | 51 | QString removableStorageVideosLocation() const; | ||
2525 | 52 | 38 | ||
2526 | 53 | Q_SIGNALS: | 39 | Q_SIGNALS: |
2527 | 54 | void removableStoragePresentChanged(); | ||
2528 | 55 | 40 | ||
2529 | 56 | private: | 41 | private: |
2530 | 57 | QScopedPointer<QQmlApplicationEngine> m_engine; | 42 | QScopedPointer<QQmlApplicationEngine> m_engine; |
2531 | 58 | 43 | ||
2532 | === modified file 'debian/rules' | |||
2533 | --- debian/rules 2015-11-18 06:44:35 +0000 | |||
2534 | +++ debian/rules 2016-02-26 17:17:00 +0000 | |||
2535 | @@ -11,10 +11,6 @@ | |||
2536 | 11 | override_dh_auto_configure: | 11 | override_dh_auto_configure: |
2537 | 12 | dh_auto_configure -- -DCLICK_MODE=OFF -DINSTALL_TESTS=ON | 12 | dh_auto_configure -- -DCLICK_MODE=OFF -DINSTALL_TESTS=ON |
2538 | 13 | 13 | ||
2539 | 14 | override_dh_auto_test: | ||
2540 | 15 | python3 -m flake8 . | ||
2541 | 16 | dh_auto_test | ||
2542 | 17 | |||
2543 | 18 | override_dh_install: | 14 | override_dh_install: |
2544 | 19 | dh_install --fail-missing | 15 | dh_install --fail-missing |
2545 | 20 | 16 | ||
2546 | 21 | 17 | ||
2547 | === modified file 'manifest.json.in' | |||
2548 | --- manifest.json.in 2015-11-25 17:56:59 +0000 | |||
2549 | +++ manifest.json.in 2016-02-26 17:17:00 +0000 | |||
2550 | @@ -1,6 +1,6 @@ | |||
2551 | 1 | { | 1 | { |
2552 | 2 | "description": "An application to take pictures and videos with the device cameras", | 2 | "description": "An application to take pictures and videos with the device cameras", |
2554 | 3 | "framework": "ubuntu-sdk-15.04.3", | 3 | "framework": "ubuntu-sdk-15.04.4", |
2555 | 4 | "architecture": "@CLICK_ARCH@", | 4 | "architecture": "@CLICK_ARCH@", |
2556 | 5 | "hooks": { | 5 | "hooks": { |
2557 | 6 | "camera": { | 6 | "camera": { |
2558 | 7 | 7 | ||
2559 | === removed file 'run_tests.sh' | |||
2560 | --- run_tests.sh 2012-10-24 15:18:16 +0000 | |||
2561 | +++ run_tests.sh 1970-01-01 00:00:00 +0000 | |||
2562 | @@ -1,13 +0,0 @@ | |||
2563 | 1 | #!/bin/bash | ||
2564 | 2 | export PATH=/opt/qt5/bin:$PATH | ||
2565 | 3 | cd tests/autopilot | ||
2566 | 4 | |||
2567 | 5 | echo running with arg: $1 | ||
2568 | 6 | |||
2569 | 7 | if [ "$1" == "" ]; then | ||
2570 | 8 | autopilot run camera_app | ||
2571 | 9 | else | ||
2572 | 10 | autopilot run -o ../../$1 -f xml -r -rd ../../ camera_app | ||
2573 | 11 | fi | ||
2574 | 12 | |||
2575 | 13 | exit 0 | ||
2576 | 14 | 0 | ||
2577 | === modified file 'tests/autopilot/camera_app/tests/test_focus.py' | |||
2578 | --- tests/autopilot/camera_app/tests/test_focus.py 2015-10-05 13:14:12 +0000 | |||
2579 | +++ tests/autopilot/camera_app/tests/test_focus.py 2016-02-26 17:17:00 +0000 | |||
2580 | @@ -28,6 +28,20 @@ | |||
2581 | 28 | def tearDown(self): | 28 | def tearDown(self): |
2582 | 29 | super(TestFocus, self).tearDown() | 29 | super(TestFocus, self).tearDown() |
2583 | 30 | 30 | ||
2584 | 31 | def verify_focus_ring_after_click_at(self, ring, x, y): | ||
2585 | 32 | # The focus ring should be invisible in the beginning | ||
2586 | 33 | self.assertThat(ring.opacity, Eventually(Equals(0.0))) | ||
2587 | 34 | |||
2588 | 35 | # Click in the designated spot | ||
2589 | 36 | self.pointing_device.move(x, y) | ||
2590 | 37 | self.pointing_device.click() | ||
2591 | 38 | |||
2592 | 39 | # The focus ring sould be visible now | ||
2593 | 40 | self.assertThat(ring.opacity, Eventually(GreaterThan(0.5))) | ||
2594 | 41 | |||
2595 | 42 | # After some seconds the focus ring should fade out | ||
2596 | 43 | self.assertThat(ring.opacity, Eventually(Equals(0.0))) | ||
2597 | 44 | |||
2598 | 31 | """Test focusing in an area where we know the picture is""" | 45 | """Test focusing in an area where we know the picture is""" |
2599 | 32 | @unittest.skipIf(model() == 'Galaxy Nexus', 'Unusable with Mir on maguro') | 46 | @unittest.skipIf(model() == 'Galaxy Nexus', 'Unusable with Mir on maguro') |
2600 | 33 | def test_focus_valid_and_disappear(self): | 47 | def test_focus_valid_and_disappear(self): |
2601 | @@ -36,21 +50,16 @@ | |||
2602 | 36 | switch_cameras = self.main_window.get_swap_camera_button() | 50 | switch_cameras = self.main_window.get_swap_camera_button() |
2603 | 37 | exposure_button = self.main_window.get_exposure_button() | 51 | exposure_button = self.main_window.get_exposure_button() |
2604 | 38 | 52 | ||
2620 | 39 | # The focus ring should be invisible in the beginning | 53 | # Click in the center of the viewfinder area |
2621 | 40 | self.assertThat(focus_ring.opacity, Eventually(Equals(0.0))) | 54 | mid_x, mid_y = self.get_center(feed) |
2622 | 41 | 55 | self.verify_focus_ring_after_click_at(focus_ring, mid_x, mid_y) | |
2623 | 42 | self.pointing_device.move_to_object(feed) | 56 | |
2624 | 43 | self.pointing_device.click() | 57 | # Then try on the side edges and top edge to verify they |
2625 | 44 | click_coords = list(self.pointing_device.position()) | 58 | # are focusable too |
2626 | 45 | 59 | self.verify_focus_ring_after_click_at(focus_ring, 1, mid_y) | |
2627 | 46 | # The focus ring sould be visible and centered to the mouse click | 60 | self.verify_focus_ring_after_click_at(focus_ring, feed.width - 1, |
2628 | 47 | # coords now | 61 | mid_y) |
2629 | 48 | # focus_ring_center = self.get_center(focus_ring) | 62 | self.verify_focus_ring_after_click_at(focus_ring, mid_x, 1) |
2615 | 49 | self.assertThat(focus_ring.opacity, Eventually(GreaterThan(0.5))) | ||
2616 | 50 | # self.assertEquals(focus_ring_center, click_coords) | ||
2617 | 51 | |||
2618 | 52 | # After some seconds the focus ring should fade out | ||
2619 | 53 | self.assertThat(focus_ring.opacity, Eventually(Equals(0.0))) | ||
2630 | 54 | 63 | ||
2631 | 55 | # Switch cameras, wait for camera to settle, and try again | 64 | # Switch cameras, wait for camera to settle, and try again |
2632 | 56 | self.pointing_device.move_to_object(switch_cameras) | 65 | self.pointing_device.move_to_object(switch_cameras) |
2633 | @@ -58,19 +67,14 @@ | |||
2634 | 58 | self.assertThat(exposure_button.enabled, Eventually(Equals(True))) | 67 | self.assertThat(exposure_button.enabled, Eventually(Equals(True))) |
2635 | 59 | 68 | ||
2636 | 60 | # Click in the center of the viewfinder area | 69 | # Click in the center of the viewfinder area |
2650 | 61 | click_coords = [feed.globalRect[2] // 2 + feed.globalRect[0], | 70 | self.verify_focus_ring_after_click_at(focus_ring, mid_x, mid_y) |
2651 | 62 | feed.globalRect[3] // 2 + feed.globalRect[1]] | 71 | |
2652 | 63 | self.pointing_device.move(click_coords[0], click_coords[1]) | 72 | # Then try on the side edges and top edge to verify they |
2653 | 64 | self.pointing_device.click() | 73 | # are focusable too |
2654 | 65 | 74 | self.verify_focus_ring_after_click_at(focus_ring, 1, mid_y) | |
2655 | 66 | # The focus ring sould be visible and centered to the mouse | 75 | self.verify_focus_ring_after_click_at(focus_ring, feed.width - 1, |
2656 | 67 | # click coords now | 76 | mid_y) |
2657 | 68 | # focus_ring_center = self.get_center(focus_ring) | 77 | self.verify_focus_ring_after_click_at(focus_ring, mid_x, 1) |
2645 | 69 | self.assertThat(focus_ring.opacity, Eventually(GreaterThan(0.5))) | ||
2646 | 70 | # self.assertEquals(focus_ring_center, click_coords) | ||
2647 | 71 | |||
2648 | 72 | # After some seconds the focus ring should fade out | ||
2649 | 73 | self.assertThat(focus_ring.opacity, Eventually(Equals(0.0))) | ||
2658 | 74 | 78 | ||
2659 | 75 | @unittest.skipIf(model() == 'Galaxy Nexus', 'Unusable with Mir on maguro') | 79 | @unittest.skipIf(model() == 'Galaxy Nexus', 'Unusable with Mir on maguro') |
2660 | 76 | def test_focus_invalid(self): | 80 | def test_focus_invalid(self): |
2661 | 77 | 81 | ||
2662 | === modified file 'tests/autopilot/camera_app/tests/test_options.py' | |||
2663 | --- tests/autopilot/camera_app/tests/test_options.py 2015-11-20 15:01:02 +0000 | |||
2664 | +++ tests/autopilot/camera_app/tests/test_options.py 2016-02-26 17:17:00 +0000 | |||
2665 | @@ -42,6 +42,33 @@ | |||
2666 | 42 | # check overlay is closed | 42 | # check overlay is closed |
2667 | 43 | self.assertThat(bottom_edge.opened, Eventually(Equals(False))) | 43 | self.assertThat(bottom_edge.opened, Eventually(Equals(False))) |
2668 | 44 | 44 | ||
2669 | 45 | # try opening and closing by tapping on the bottom of the viewfinder | ||
2670 | 46 | bottom_edge = self.main_window.get_bottom_edge() | ||
2671 | 47 | bottom_edge.open() | ||
2672 | 48 | |||
2673 | 49 | # check overlay is opened | ||
2674 | 50 | self.assertThat(bottom_edge.opened, Eventually(Equals(True))) | ||
2675 | 51 | |||
2676 | 52 | # tap on the bottom of the viewfinder to close overlay | ||
2677 | 53 | viewfinder = self.main_window.get_viewfinder() | ||
2678 | 54 | x = viewfinder.globalRect.x + viewfinder.width / 2.0 | ||
2679 | 55 | y = viewfinder.globalRect.y + viewfinder.height - 1.0 | ||
2680 | 56 | self.pointing_device.move(x, y) | ||
2681 | 57 | self.pointing_device.click() | ||
2682 | 58 | |||
2683 | 59 | # check overlay is closed | ||
2684 | 60 | self.assertThat(bottom_edge.opened, Eventually(Equals(False))) | ||
2685 | 61 | |||
2686 | 62 | """Test that the options overlay opens properly by tapping on the hint""" | ||
2687 | 63 | def test_overlay_open_tapping_hint(self): | ||
2688 | 64 | options_hint = self.app.wait_select_single(objectName="indicatorsRow") | ||
2689 | 65 | self.pointing_device.move_to_object(options_hint) | ||
2690 | 66 | self.pointing_device.click() | ||
2691 | 67 | |||
2692 | 68 | # check overlay is opened | ||
2693 | 69 | bottom_edge = self.main_window.get_bottom_edge() | ||
2694 | 70 | self.assertThat(bottom_edge.opened, Eventually(Equals(True))) | ||
2695 | 71 | |||
2696 | 45 | """Test toggling on/off grid lines option""" | 72 | """Test toggling on/off grid lines option""" |
2697 | 46 | def test_toggle_grid_lines(self): | 73 | def test_toggle_grid_lines(self): |
2698 | 47 | gridlines = self.app.wait_select_single( | 74 | gridlines = self.app.wait_select_single( |
2699 | 48 | 75 | ||
2700 | === modified file 'tests/unittests/CMakeLists.txt' | |||
2701 | --- tests/unittests/CMakeLists.txt 2015-03-12 22:36:12 +0000 | |||
2702 | +++ tests/unittests/CMakeLists.txt 2016-02-26 17:17:00 +0000 | |||
2703 | @@ -33,6 +33,7 @@ | |||
2704 | 33 | 33 | ||
2705 | 34 | qt5_use_modules(tst_storagemonitor Widgets Core Quick Qml Test) | 34 | qt5_use_modules(tst_storagemonitor Widgets Core Quick Qml Test) |
2706 | 35 | add_test(tst_storagemonitor tst_storagemonitor -xunitxml -o test.xml) | 35 | add_test(tst_storagemonitor tst_storagemonitor -xunitxml -o test.xml) |
2707 | 36 | add_test(flake8 python3 -m flake8 ${CMAKE_SOURCE_DIR}/tests/autopilot) | ||
2708 | 36 | set_tests_properties(tst_storagemonitor PROPERTIES | 37 | set_tests_properties(tst_storagemonitor PROPERTIES |
2709 | 37 | TIMEOUT ${CTEST_TESTING_TIMEOUT} | 38 | TIMEOUT ${CTEST_TESTING_TIMEOUT} |
2710 | 38 | ENVIRONMENT "QT_QPA_PLATFORM=minimal" | 39 | ENVIRONMENT "QT_QPA_PLATFORM=minimal" |
2711 | 39 | 40 | ||
2712 | === modified file 'tests/unittests/qstorageinfo_stub.cpp' | |||
2713 | --- tests/unittests/qstorageinfo_stub.cpp 2015-01-26 10:57:36 +0000 | |||
2714 | +++ tests/unittests/qstorageinfo_stub.cpp 2016-02-26 17:17:00 +0000 | |||
2715 | @@ -14,14 +14,23 @@ | |||
2716 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2717 | 15 | */ | 15 | */ |
2718 | 16 | 16 | ||
2721 | 17 | #include "qstorageinfo.h" | 17 | #include <QStorageInfo> |
2720 | 18 | #include "qstorageinfo_p.h" | ||
2722 | 19 | #include "storageinfocontrol.h" | 18 | #include "storageinfocontrol.h" |
2723 | 20 | 19 | ||
2724 | 21 | #include <QDebug> | 20 | #include <QDebug> |
2725 | 22 | 21 | ||
2726 | 23 | QString location; | 22 | QString location; |
2727 | 24 | 23 | ||
2728 | 24 | class QStorageInfoPrivateRef { | ||
2729 | 25 | public: | ||
2730 | 26 | bool deref() { return false; } | ||
2731 | 27 | }; | ||
2732 | 28 | |||
2733 | 29 | class QStorageInfoPrivate { | ||
2734 | 30 | public: | ||
2735 | 31 | QStorageInfoPrivateRef ref; | ||
2736 | 32 | }; | ||
2737 | 33 | |||
2738 | 25 | QStorageInfo::QStorageInfo() | 34 | QStorageInfo::QStorageInfo() |
2739 | 26 | { | 35 | { |
2740 | 27 | } | 36 | } |
2741 | @@ -47,6 +56,11 @@ | |||
2742 | 47 | location = path; | 56 | location = path; |
2743 | 48 | } | 57 | } |
2744 | 49 | 58 | ||
2745 | 59 | QString QStorageInfo::rootPath() const | ||
2746 | 60 | { | ||
2747 | 61 | return location; | ||
2748 | 62 | } | ||
2749 | 63 | |||
2750 | 50 | qint64 QStorageInfo::bytesAvailable() const | 64 | qint64 QStorageInfo::bytesAvailable() const |
2751 | 51 | { | 65 | { |
2752 | 52 | return StorageInfoControl::instance()->freeSpaceMap[location]; | 66 | return StorageInfoControl::instance()->freeSpaceMap[location]; |
FAILED: Continuous integration, rev:642 jenkins. qa.ubuntu. com/job/ camera- app-ci/ 483/ jenkins. qa.ubuntu. com/job/ camera- app-vivid- amd64-ci/ 178 jenkins. qa.ubuntu. com/job/ camera- app-vivid- armhf-ci/ 179 jenkins. qa.ubuntu. com/job/ camera- app-vivid- armhf-ci/ 179/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ camera- app-vivid- i386-ci/ 178 jenkins. qa.ubuntu. com/job/ generic- click-autopilot -vivid- touch/392 jenkins. qa.ubuntu. com/job/ generic- click-autopilot -runner- touch/1062 jenkins. qa.ubuntu. com/job/ generic- click-builder- vivid-armhf/ 950 s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 27167
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/camera- app-ci/ 483/rebuild
http://