Merge lp:~schwann/gallery-app/gallery-cmd-pick-mode into lp:gallery-app

Proposed by Günter Schwann
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 746
Merged at revision: 747
Proposed branch: lp:~schwann/gallery-app/gallery-cmd-pick-mode
Merge into: lp:gallery-app
Diff against target: 231 lines (+52/-20)
5 files modified
src/gallery-application.cpp (+13/-7)
src/gallery-application.h (+0/-4)
src/util/command-line-parser.cpp (+13/-1)
src/util/command-line-parser.h (+10/-5)
tests/unittests/command-line-parser/tst_commandlineparser.cpp (+16/-3)
To merge this branch: bzr merge lp:~schwann/gallery-app/gallery-cmd-pick-mode
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+171060@code.launchpad.net

Commit message

Add command line arguments for photo and video pick mode

Description of the change

Add command line arguments for photo and video pick mode

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/gallery-application.cpp'
2--- src/gallery-application.cpp 2013-06-14 12:58:49 +0000
3+++ src/gallery-application.cpp 2013-06-24 11:11:29 +0000
4@@ -78,8 +78,8 @@
5
6 registerQML();
7
8- GalleryManager::instance(cmdLineParser()->picturesDir(), &m_view,
9- cmdLineParser()->logImageLoading());
10+ GalleryManager::instance(m_cmdLineParser->picturesDir(), &m_view,
11+ m_cmdLineParser->logImageLoading());
12 }
13
14 /*!
15@@ -87,6 +87,7 @@
16 */
17 GalleryApplication::~GalleryApplication()
18 {
19+ delete m_cmdLineParser;
20 }
21
22 /*!
23@@ -138,20 +139,25 @@
24 {
25 m_view.setTitle("Gallery");
26
27- QSize size = m_formFactors[cmdLineParser()->formFactor()];
28+ QSize size = m_formFactors[m_cmdLineParser->formFactor()];
29
30 if (m_cmdLineParser->isPortrait())
31 size.transpose();
32
33 m_view.setResizeMode(QQuickView::SizeRootObjectToView);
34- if (cmdLineParser()->formFactor() == "desktop") {
35+ if (m_cmdLineParser->formFactor() == "desktop") {
36 m_view.setMinimumSize(QSize(60 * m_bguSize, 60 * m_bguSize));
37 }
38
39 QQmlContext *rootContext = m_view.engine()->rootContext();
40 rootContext->setContextProperty("DEVICE_WIDTH", QVariant(size.width()));
41 rootContext->setContextProperty("DEVICE_HEIGHT", QVariant(size.height()));
42- rootContext->setContextProperty("FORM_FACTOR", QVariant(cmdLineParser()->formFactor()));
43+ rootContext->setContextProperty("FORM_FACTOR", QVariant(m_cmdLineParser->formFactor()));
44+ rootContext->setContextProperty("PICK_MODE_ENABLED", QVariant(m_cmdLineParser->pickModeEnabled()));
45+ if (m_cmdLineParser->pickPhoto())
46+ rootContext->setContextProperty("PICK_TYPE", QVariant(MediaSource::Photo));
47+ else
48+ rootContext->setContextProperty("PICK_TYPE", QVariant(MediaSource::Video));
49 rootContext->setContextProperty("MAX_GL_TEXTURE_SIZE",
50 QVariant(GalleryManager::instance()->resource()->maxTextureSize()));
51
52@@ -170,7 +176,7 @@
53 QObject* rootObject = dynamic_cast<QObject*>(m_view.rootObject());
54 QObject::connect(this, SIGNAL(mediaLoaded()), rootObject, SLOT(onLoaded()));
55
56- if (cmdLineParser()->isFullscreen())
57+ if (m_cmdLineParser->isFullscreen())
58 m_view.showFullScreen();
59 else
60 m_view.show();
61@@ -185,7 +191,7 @@
62
63 emit mediaLoaded();
64
65- if (cmdLineParser()->startupTimer())
66+ if (m_cmdLineParser->startupTimer())
67 qDebug() << "Startup took" << m_timer.elapsed() << "milliseconds";
68 }
69
70
71=== modified file 'src/gallery-application.h'
72--- src/gallery-application.h 2013-06-14 12:58:49 +0000
73+++ src/gallery-application.h 2013-06-24 11:11:29 +0000
74@@ -45,10 +45,6 @@
75
76 Q_INVOKABLE bool runCommand(const QString &cmd, const QString &arg);
77
78- QHash<QString, QSize>& formFactors() { return m_formFactors; }
79-
80- CommandLineParser* cmdLineParser() { return m_cmdLineParser; }
81-
82 private:
83 void registerQML();
84 void createView();
85
86=== modified file 'src/util/command-line-parser.cpp'
87--- src/util/command-line-parser.cpp 2013-06-14 13:27:05 +0000
88+++ src/util/command-line-parser.cpp 2013-06-24 11:11:29 +0000
89@@ -30,6 +30,9 @@
90 m_isFullscreen(false),
91 m_isPortrait(false),
92 m_picturesDir(""),
93+ m_pickMode(false),
94+ m_pickPhoto(false),
95+ m_pickVideo(false),
96 m_logImageLoading(false),
97 m_formFactors(form_factors),
98 m_formFactor("desktop")
99@@ -43,7 +46,6 @@
100 */
101 bool CommandLineParser::processArguments(const QStringList& args)
102 {
103- qDebug() << "cml argument:" << args;
104 bool valid_args = true;
105
106 for (int i = 1; i < args.count(); ++i)
107@@ -69,6 +71,14 @@
108 else if (args[i] == "--log-image-loading") {
109 m_logImageLoading = true;
110 }
111+ else if (args[i] == "--pick-photo") {
112+ m_pickMode = true;
113+ m_pickPhoto = true;
114+ }
115+ else if (args[i] == "--pick-video") {
116+ m_pickMode = true;
117+ m_pickVideo = true;
118+ }
119 else {
120 QString form_factor = args[i].mid(2); // minus initial "--"
121
122@@ -108,6 +118,8 @@
123
124 out << " --startup-timer\n\t\tdebug-print startup time" << endl;
125 out << " --log-image-loading\n\t\tlog image loading" << endl;
126+ out << " --pick-photo\n\t\tEnable mode to pick one photo" << endl;
127+ out << " --pick-video\n\t\tEnable mode to pick one video" << endl;
128 out << "pictures_dir defaults to ~/Pictures, and must exist prior to running gallery" << endl;
129 }
130
131
132=== modified file 'src/util/command-line-parser.h'
133--- src/util/command-line-parser.h 2013-06-14 13:27:05 +0000
134+++ src/util/command-line-parser.h 2013-06-24 11:11:29 +0000
135@@ -26,7 +26,8 @@
136 #include <QString>
137
138 /*!
139- * @brief The CommandLineParser is used to parse our commandline inputs and set parameters accordingly.
140+ * @brief The CommandLineParser is used to parse our commandline inputs and set
141+ * parameters accordingly.
142 */
143 class CommandLineParser
144 {
145@@ -35,13 +36,15 @@
146
147 bool processArguments(const QStringList& args);
148
149- QString picturesDir() const { return m_picturesDir; }
150+ const QString &picturesDir() const { return m_picturesDir; }
151 bool isPortrait() const { return m_isPortrait; }
152 bool isFullscreen() const { return m_isFullscreen; }
153 bool startupTimer() const { return m_startupTimer; }
154 bool logImageLoading() const { return m_logImageLoading; }
155-
156- QString formFactor() { return m_formFactor; }
157+ bool pickModeEnabled() const { return m_pickMode; }
158+ bool pickPhoto() const { return m_pickPhoto; }
159+ bool pickVideo() const { return m_pickVideo; }
160+ const QString &formFactor() const { return m_formFactor; }
161
162 private:
163 bool invalidArg(QString arg);
164@@ -51,7 +54,9 @@
165 bool m_isFullscreen;
166 bool m_isPortrait;
167 QString m_picturesDir;
168-
169+ bool m_pickMode;
170+ bool m_pickPhoto;
171+ bool m_pickVideo;
172 bool m_logImageLoading;
173
174 const QHash<QString, QSize> m_formFactors;
175
176=== modified file 'tests/unittests/command-line-parser/tst_commandlineparser.cpp'
177--- tests/unittests/command-line-parser/tst_commandlineparser.cpp 2013-06-10 04:59:30 +0000
178+++ tests/unittests/command-line-parser/tst_commandlineparser.cpp 2013-06-24 11:11:29 +0000
179@@ -87,6 +87,9 @@
180 QTest::addColumn<bool>("is_fullscreen");
181 QTest::addColumn<bool>("startup_timer");
182 QTest::addColumn<bool>("log_image_loading");
183+ QTest::addColumn<bool>("pick_mode_enabled");
184+ QTest::addColumn<bool>("pick_photo");
185+ QTest::addColumn<bool>("pick_video");
186 QTest::addColumn<bool>("invalid_arg");
187
188 QStringList boolean_test;
189@@ -95,6 +98,7 @@
190 boolean_test.append("--fullscreen");
191 boolean_test.append("--startup-timer");
192 boolean_test.append("--log-image-loading");
193+ boolean_test.append("--pick-photo");
194
195 QStringList invalid_arg_test;
196 invalid_arg_test.append("gallery");
197@@ -105,9 +109,12 @@
198 help_test.append("-h");
199 help_test.append("--landscape");
200
201- QTest::newRow("Boolean member test") << boolean_test << true << true << true << true << true;
202- QTest::newRow("Invalid arg test") << invalid_arg_test << false << false << false << false << false;
203- QTest::newRow("Help test") << help_test << false << false << false << false << false;
204+ QTest::newRow("Boolean member test") << boolean_test << true << true << true << true
205+ << true << true << false << true;
206+ QTest::newRow("Invalid arg test") << invalid_arg_test << false << false << false << false
207+ << false << false << false << false;
208+ QTest::newRow("Help test") << help_test << false << false << false << false
209+ << false << false << false << false;
210 }
211
212 void tst_CommandLineParser::process_args_test()
213@@ -121,6 +128,9 @@
214 QFETCH(bool, is_fullscreen);
215 QFETCH(bool, startup_timer);
216 QFETCH(bool, log_image_loading);
217+ QFETCH(bool, pick_mode_enabled);
218+ QFETCH(bool, pick_photo);
219+ QFETCH(bool, pick_video);
220 QFETCH(bool, invalid_arg);
221
222 bool result = test.processArguments(process_args);
223@@ -129,6 +139,9 @@
224 QCOMPARE(test.isFullscreen(), is_fullscreen);
225 QCOMPARE(test.startupTimer(), startup_timer);
226 QCOMPARE(test.logImageLoading(), log_image_loading);
227+ QCOMPARE(test.pickModeEnabled(), pick_mode_enabled);
228+ QCOMPARE(test.pickPhoto(), pick_photo);
229+ QCOMPARE(test.pickVideo(), pick_video);
230 QCOMPARE(result, invalid_arg);
231 }
232

Subscribers

People subscribed via source and target branches