+
+VideoResolution *VideoSettings::currentResolution() {
+ if (m_currentResolution) {
+ return m_currentResolution;
+ }
+
+ if (!m_cam || !m_cam->device()) {
+ return 0;
+ }
+
+ m_currentResolution = new VideoResolution(m_cam->device()->videoMode()->currentResolution());
+
+ return m_currentResolution;
+}
+
+VideoResolution *VideoSettings::findResolution(const QString& aspectRatio,
+ const QString& name) {
+ if (!isReady()) {
+ return 0;
+ }
+
+ QList<QtCamVideoResolution> res = m_settings->resolutions(aspectRatio);
+
+ foreach (const QtCamVideoResolution& r, res) {
+ if (r.name() == name) {
+ return new VideoResolution(r);
+ }
+ }
+
+ return 0;
+}
+
+bool VideoSettings::setResolution(VideoResolution *resolution) {
+ return setResolution(resolution->resolution());
+}
+
+bool VideoSettings::setResolution(const QtCamVideoResolution& resolution) {
+ if (!isReady()) {
+ return false;
+ }
+
+ if (!m_cam || !m_cam->device()) {
+ return false;
+ }
+
+ if (m_cam->device()->videoMode()->setResolution(resolution)) {
+ delete m_currentResolution;
+ m_currentResolution = 0;
+
+ emit currentResolutionChanged();
+
+ return true;
+ }
+
+ return false;
+}