Merge lp:~sylvain-pineau/checkbox/ui_profiles into lp:checkbox

Proposed by Sylvain Pineau
Status: Merged
Approved by: Zygmunt Krynicki
Approved revision: no longer in the source branch.
Merged at revision: 2799
Proposed branch: lp:~sylvain-pineau/checkbox/ui_profiles
Merge into: lp:checkbox
Diff against target: 366 lines (+76/-110)
12 files modified
checkbox-gui/checkbox-gui/WhiteListModelFactory.cpp (+10/-9)
checkbox-gui/checkbox-gui/WhiteListModelFactory.h (+1/-1)
checkbox-gui/checkbox-gui/checkbox-gui.pro (+2/-2)
checkbox-gui/checkbox-gui/commandtool.cpp (+0/-15)
checkbox-gui/checkbox-gui/commandtool.h (+0/-40)
checkbox-gui/checkbox-gui/main.cpp (+10/-14)
checkbox-gui/checkbox-gui/qml/SuiteSelectionView.qml (+0/-3)
checkbox-gui/checkbox-gui/qml/WelcomeView.qml (+2/-6)
checkbox-gui/checkbox-gui/settings.cpp (+26/-0)
checkbox-gui/checkbox-gui/settings.h (+24/-0)
checkbox-gui/gui-engine/gui-engine.cpp (+1/-17)
checkbox-gui/gui-engine/gui-engine.h (+0/-3)
To merge this branch: bzr merge lp:~sylvain-pineau/checkbox/ui_profiles
Reviewer Review Type Date Requested Status
Zygmunt Krynicki (community) Approve
Sylvain Pineau (community) Needs Resubmitting
Brendan Donegan (community) Needs Information
Review via email: mp+211490@code.launchpad.net

Description of the change

Add support for application settings using a QSettings object invokable from both C++ and QML.

An example of configuration file could be this one:

[welcome]

title = "blah blah"

text = "<p>Welcome to System Testing.</p><p></p><p>This program contains
 automated and manual tests to help you assess how well your system works
 with Ubuntu.</p><p></p><p>This application will step the user through these
 tests in a predetermined order and automatically collect both system
 information as well as test results. It will also prompt the user for input
 when manual testing is required.</p><p></p><p>The run time for the tests is
 determined by which tests you decide to execute. The user will have the
 opportunity to customize the test run based on the hardware components they
 are interested in and the amount of time they have
 available.</p><p></p><p>To begin, simply click the Continue button below and
 follow the onscreen instructions.</p><p></p>"

whitelist_filter = "^ihv-.*"

To post a comment you must log in.
Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

316 - whitelist.insert(child->object_path,true);
317 + whitelist.insert(child->object_path, false);

I don't understand this change, can you explain it?

review: Needs Information
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

I can have multiple providers installed on my system, but since I restrict the whitelists shown in the SuiteSelection screen, I can only select/unselect the ones displayed. The rest of the whitelists were automatically selected by gui-engine. So by default nothing is selected and I let the application decide which ones to display/preselect (like the default.whitelist for ubuntu)

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

http://bazaar.launchpad.net/~sylvain-pineau/checkbox/ui_profiles/revision/2798

Missing destructor for non-trivial constructor for QSettings

review: Needs Fixing
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

Added a destructor for the Settings class

review: Needs Resubmitting
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

306 + ~Settings();

I'd mark that as virtual, I know we inherit from QObject but I think that's a good practice, anyway, +1

review: Approve
2797. By Sylvain Pineau

checkbox-gui: Remove unused commandtool files

2798. By Sylvain Pineau

checkbox-gui:settings: Provide a QObject invokable wrapper for QSettings

Meant to be used from both the C++ code and the QML app.
The configuration file hosting all the application settings must be in the
INI-style format.
The first command-line parameter is the path to a such configuration file.

2799. By Sylvain Pineau

checkbox-gui:gui-engine.cpp: Insert whitelists but do not pre-select them

2800. By Sylvain Pineau

checkbox-gui:main.cpp: Use settings values/defaults

To customize the app title, the welcome text and the list of whitelists to
display (using a QRegExp filter).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'checkbox-gui/checkbox-gui/WhiteListModelFactory.cpp'
2--- checkbox-gui/checkbox-gui/WhiteListModelFactory.cpp 2013-12-10 17:41:24 +0000
3+++ checkbox-gui/checkbox-gui/WhiteListModelFactory.cpp 2014-03-18 16:22:23 +0000
4@@ -21,7 +21,7 @@
5
6 #include "WhiteListModelFactory.h"
7
8-ListModel* WhiteListModelFactory::CreateWhiteListModel(ListModel *model)
9+ListModel* WhiteListModelFactory::CreateWhiteListModel(ListModel *model, const QString &filter)
10 {
11 qDebug("WhiteListModelFactory::CreateWhiteListModel()");
12
13@@ -53,15 +53,16 @@
14
15 QMap<QDBusObjectPath,QString>::const_iterator iter = paths_and_names.begin();
16
17+ QRegExp rx(filter);
18+
19 while(iter != paths_and_names.end() ) {
20-
21- qDebug() << iter.key().path();
22-
23- qDebug() << " Name: " << iter.value();
24-
25- model->appendRow(new WhiteListItem(iter.value(), \
26- iter.key().path(), \
27- model));
28+ if (rx.exactMatch(iter.value())) {
29+ qDebug() << iter.key().path();
30+ qDebug() << " Name: " << iter.value();
31+ model->appendRow(new WhiteListItem(iter.value(), \
32+ iter.key().path(), \
33+ model));
34+ }
35 iter++;
36 }
37
38
39=== modified file 'checkbox-gui/checkbox-gui/WhiteListModelFactory.h'
40--- checkbox-gui/checkbox-gui/WhiteListModelFactory.h 2013-12-10 17:41:24 +0000
41+++ checkbox-gui/checkbox-gui/WhiteListModelFactory.h 2014-03-18 16:22:23 +0000
42@@ -36,7 +36,7 @@
43 ~WhiteListModelFactory() {};
44
45 public slots:
46- ListModel* CreateWhiteListModel(ListModel* model=NULL);
47+ ListModel* CreateWhiteListModel(ListModel* model=NULL, const QString &filter=QString());
48 };
49
50 #endif // WHITELISTMODELFACTORY_H
51
52=== modified file 'checkbox-gui/checkbox-gui/checkbox-gui.pro'
53--- checkbox-gui/checkbox-gui/checkbox-gui.pro 2013-12-10 17:41:24 +0000
54+++ checkbox-gui/checkbox-gui/checkbox-gui.pro 2014-03-18 16:22:23 +0000
55@@ -40,8 +40,8 @@
56 whitelistitem.cpp \
57 testitem.cpp \
58 listmodel.cpp \
59- commandtool.cpp \
60 testitemmodel.cpp \
61+ settings.cpp \
62 WhiteListModelFactory.cpp
63
64 # Please do not modify the following two lines. Required for deployment.
65@@ -61,8 +61,8 @@
66 HEADERS += whitelistitem.h \
67 testitem.h \
68 listmodel.h \
69- commandtool.h \
70 testitemmodel.h \
71+ settings.h \
72 WhiteListModelFactory.h
73
74 target.path = $$PREFIX/bin
75
76=== removed file 'checkbox-gui/checkbox-gui/commandtool.cpp'
77--- checkbox-gui/checkbox-gui/commandtool.cpp 2013-07-24 15:21:15 +0000
78+++ checkbox-gui/checkbox-gui/commandtool.cpp 1970-01-01 00:00:00 +0000
79@@ -1,15 +0,0 @@
80-#include "commandtool.h"
81-
82-CommandTool::CommandTool(QObject *parent) :
83- QObject(parent),
84- m_process(new QProcess(this))
85-{
86-}
87-
88-
89-void CommandTool::exec(const QString& cmd, const QString& args)
90-{
91- QStringList arguments;
92- arguments << args;
93- m_process->start(cmd, arguments);
94-}
95
96=== removed file 'checkbox-gui/checkbox-gui/commandtool.h'
97--- checkbox-gui/checkbox-gui/commandtool.h 2013-12-10 17:41:24 +0000
98+++ checkbox-gui/checkbox-gui/commandtool.h 1970-01-01 00:00:00 +0000
99@@ -1,40 +0,0 @@
100-/*
101- * This file is part of Checkbox
102- *
103- * Copyright 2013 Canonical Ltd.
104- *
105- * Authors:
106- * - Julia Segal <julia.segal@cellsoftware.co.uk>
107- *
108- * This program is free software; you can redistribute it and/or modify
109- * it under the terms of the GNU General Public License as published by
110- * the Free Software Foundation; version 3.
111- *
112- * This program is distributed in the hope that it will be useful,
113- * but WITHOUT ANY WARRANTY; without even the implied warranty of
114- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
115- * GNU General Public License for more details.
116- *
117- * You should have received a copy of the GNU General Public License
118- * along with this program. If not, see <http://www.gnu.org/licenses/>.
119- */
120-
121-#ifndef COMMANDTOOL_H
122-#define COMMANDTOOL_H
123-
124-#include <QObject>
125-#include <QProcess>
126-#include <qdebug.h>
127-
128-class CommandTool : public QObject
129-{
130- Q_OBJECT
131-public:
132- explicit CommandTool(QObject *parent = 0);
133- Q_INVOKABLE void exec(const QString& cmd, const QString &args);
134-
135-private:
136- QProcess *m_process;
137-};
138-
139-#endif // COMMAND_H
140
141=== modified file 'checkbox-gui/checkbox-gui/main.cpp'
142--- checkbox-gui/checkbox-gui/main.cpp 2014-01-29 10:00:26 +0000
143+++ checkbox-gui/checkbox-gui/main.cpp 2014-03-18 16:22:23 +0000
144@@ -28,9 +28,9 @@
145 #include <QtQml>
146
147 #include "qtquick2applicationviewer.h"
148-#include "commandtool.h"
149 #include "listmodel.h"
150 #include "whitelistitem.h"
151+#include "settings.h"
152 #include "testitem.h"
153 #include "testitemmodel.h"
154 #include "WhiteListModelFactory.h"
155@@ -61,10 +61,14 @@
156 // Initialise - connect to Plainbox
157 guiengine.Initialise();
158
159+ Settings* settings;
160+ settings = new Settings();
161+ if (app.arguments().size() > 1) {
162+ settings = new Settings(app.arguments().at(1));
163+ }
164+ viewer.rootContext()->setContextProperty("settings", settings);
165
166- // WhiteList Item Model Factory and placeholder model registered with QML engine
167 WhiteListModelFactory whitelistfactory;
168- viewer.rootContext()->setContextProperty("whitelistitemFactory",&whitelistfactory);
169
170 /* We need a placeholder object here or the QML integration is unhappy
171 * that this isnt a recognisable Qt object.
172@@ -76,10 +80,10 @@
173 exit(1);
174 }
175
176+ whitelistfactory.CreateWhiteListModel(whitelistmodel, settings->value("welcome/whitelist_filter", ".*"));
177+
178 viewer.rootContext()->setContextProperty("whiteListModel", whitelistmodel);
179
180-
181-
182 // Test Item Model Factory and placeholder model registered with QML engine
183 TestItemModel testitemFactory;
184 viewer.rootContext()->setContextProperty("testitemFactory",&testitemFactory);
185@@ -96,14 +100,6 @@
186
187 viewer.rootContext()->setContextProperty("testListModel", testlistmodel);
188
189-
190-
191- // We may not need this at all
192- CommandTool cmdTool;
193- viewer.rootContext()->setContextProperty("cmdTool", &cmdTool);
194-
195-
196-
197 // In the beginning, lets see if we need to resume
198 bool resumeSession = false;
199
200@@ -124,7 +120,7 @@
201 // Now, load the main page
202 viewer.setMainQmlFile(QStringLiteral("../share/checkbox-gui/qml/checkbox-gui.qml"));
203
204- viewer.setTitle(app.tr("System Testing"));
205+ viewer.setTitle(settings->value("welcome/title", app.tr("System Testing")));
206
207 // Ensure a reasonable minimum size for this window
208 viewer.setMinimumSize(QSize(800,600));
209
210=== modified file 'checkbox-gui/checkbox-gui/qml/SuiteSelectionView.qml'
211--- checkbox-gui/checkbox-gui/qml/SuiteSelectionView.qml 2014-03-05 10:38:05 +0000
212+++ checkbox-gui/checkbox-gui/qml/SuiteSelectionView.qml 2014-03-18 16:22:23 +0000
213@@ -135,9 +135,6 @@
214
215 suitelist.visible = false;
216
217- // Dump the whitelist as finally selected by the user
218- guiEngine.dump_whitelist_selection();
219-
220 /* Now, we should go run the guiengine update to run the local jobs
221 which happen to match the whitelist. Then we can collect the
222 test jobs and show them to the user.
223
224=== modified file 'checkbox-gui/checkbox-gui/qml/WelcomeView.qml'
225--- checkbox-gui/checkbox-gui/qml/WelcomeView.qml 2014-02-19 11:31:39 +0000
226+++ checkbox-gui/checkbox-gui/qml/WelcomeView.qml 2014-03-18 16:22:23 +0000
227@@ -26,7 +26,7 @@
228
229 Page {
230 id: welcomePage
231- title: i18n.tr("System Testing")
232+ title: settings.value("welcome/title", i18n.tr("System Testing"));
233
234 tools: ToolbarItems {
235 locked: true
236@@ -87,9 +87,8 @@
237 margins: units.gu(2)
238 }
239
240- // TODO load text from Plainbox
241 // TRANSLATORS: The <p> tags are HTML - DO NOT translate them.
242- text: i18n.tr("<p>Welcome to System Testing.</p><p></p><p>This program contains automated and manual tests to help you assess how well your system works with Ubuntu.</p><p></p><p>This application will step the user through these tests in a predetermined order and automatically collect both system information as well as test results. It will also prompt the user for input when manual testing is required.</p><p></p><p>The run time for the tests is determined by which tests you decide to execute. The user will have the opportunity to customize the test run based on the hardware components they are interested in and the amount of time they have available.</p><p></p><p>To begin, simply click the Continue button below and follow the onscreen instructions.</p><p></p>")
243+ text: settings.value("welcome/text", i18n.tr("<p>Welcome to System Testing.</p><p></p><p>This program contains automated and manual tests to help you assess how well your system works with Ubuntu.</p><p></p><p>This application will step the user through these tests in a predetermined order and automatically collect both system information as well as test results. It will also prompt the user for input when manual testing is required.</p><p></p><p>The run time for the tests is determined by which tests you decide to execute. The user will have the opportunity to customize the test run based on the hardware components they are interested in and the amount of time they have available.</p><p></p><p>To begin, simply click the Continue button below and follow the onscreen instructions.</p><p></p>"))
244
245 height: units.gu(60)
246 width: units.gu(30)
247@@ -127,9 +126,6 @@
248 text: i18n.tr("Continue")
249 color: UbuntuColors.lightAubergine
250 onClicked: {
251- // Generate the the list of whitelists
252- whitelistitemFactory.CreateWhiteListModel(whiteListModel);
253-
254 // Move to the whitelist selection screen
255 mainView.state = "SUITESELECTION"
256 }
257
258=== added file 'checkbox-gui/checkbox-gui/settings.cpp'
259--- checkbox-gui/checkbox-gui/settings.cpp 1970-01-01 00:00:00 +0000
260+++ checkbox-gui/checkbox-gui/settings.cpp 2014-03-18 16:22:23 +0000
261@@ -0,0 +1,26 @@
262+#include <QDebug>
263+#include <QStringList>
264+#include "settings.h"
265+
266+Settings::Settings(QObject *parent) : QObject(parent)
267+{
268+ m_settings = new QSettings();
269+}
270+
271+Settings::Settings(const QString &fileName, QObject *parent) : QObject(parent)
272+{
273+ m_settings = new QSettings(fileName, QSettings::NativeFormat);
274+}
275+
276+void Settings::setValue(const QString &key, const QVariant &value) {
277+ m_settings->setValue(key, value);
278+}
279+
280+QString Settings::value(const QString &key, const QString &defaultValue) const {
281+ return m_settings->value(key, defaultValue).toStringList().at(0);
282+}
283+
284+Settings::~Settings()
285+{
286+ delete m_settings;
287+}
288
289=== added file 'checkbox-gui/checkbox-gui/settings.h'
290--- checkbox-gui/checkbox-gui/settings.h 1970-01-01 00:00:00 +0000
291+++ checkbox-gui/checkbox-gui/settings.h 2014-03-18 16:22:23 +0000
292@@ -0,0 +1,24 @@
293+#ifndef SETTINGS_H
294+#define SETTINGS_H
295+
296+#include <QObject>
297+#include <QSettings>
298+
299+class Settings : public QObject
300+{
301+ Q_OBJECT
302+
303+public:
304+ Settings(QObject *parent = 0);
305+ explicit Settings(const QString & filename, QObject *parent = 0);
306+ ~Settings();
307+
308+public slots:
309+ void setValue(const QString & key, const QVariant & value);
310+ QString value(const QString &key, const QString &defaultValue = QString()) const;
311+
312+private:
313+ QSettings* m_settings;
314+};
315+
316+#endif // SETTINGS_H
317
318=== modified file 'checkbox-gui/gui-engine/gui-engine.cpp'
319--- checkbox-gui/gui-engine/gui-engine.cpp 2014-03-18 15:54:05 +0000
320+++ checkbox-gui/gui-engine/gui-engine.cpp 2014-03-18 16:22:23 +0000
321@@ -490,7 +490,7 @@
322
323 // First time round, fill in our whitelist member
324 if (!initialised) {
325- whitelist.insert(child->object_path,true);
326+ whitelist.insert(child->object_path, false);
327 }
328 }
329
330@@ -507,22 +507,6 @@
331 whitelist.insert(opath,check);
332 }
333
334-// temporary helper
335-void GuiEngine::dump_whitelist_selection(void)
336-{
337- // loop around all the children
338- QMap<QDBusObjectPath,bool>::const_iterator iter = whitelist.begin();
339-
340- while(iter != whitelist.end() ) {
341-
342- bool yes = iter.value();
343-
344- qDebug() << iter.key().path() << (yes ? "Yes" : "No");
345-
346- iter++;
347- }
348-}
349-
350 void GuiEngine::Pause(void)
351 {
352 // Very simple
353
354=== modified file 'checkbox-gui/gui-engine/gui-engine.h'
355--- checkbox-gui/gui-engine/gui-engine.h 2014-03-18 15:54:05 +0000
356+++ checkbox-gui/gui-engine/gui-engine.h 2014-03-18 16:22:23 +0000
357@@ -131,9 +131,6 @@
358 /* Helper functions for logging and testing
359 */
360
361- // Logging function
362- void dump_whitelist_selection(void);
363-
364 // Used by the test program test-gui-engine
365 void AcknowledgeJobsDone(void);
366 void AcknowledgeLocalJobsDone(void);

Subscribers

People subscribed via source and target branches