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 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
=== modified file 'checkbox-gui/checkbox-gui/WhiteListModelFactory.cpp'
--- checkbox-gui/checkbox-gui/WhiteListModelFactory.cpp 2013-12-10 17:41:24 +0000
+++ checkbox-gui/checkbox-gui/WhiteListModelFactory.cpp 2014-03-18 16:22:23 +0000
@@ -21,7 +21,7 @@
2121
22#include "WhiteListModelFactory.h"22#include "WhiteListModelFactory.h"
2323
24ListModel* WhiteListModelFactory::CreateWhiteListModel(ListModel *model)24ListModel* WhiteListModelFactory::CreateWhiteListModel(ListModel *model, const QString &filter)
25{25{
26 qDebug("WhiteListModelFactory::CreateWhiteListModel()");26 qDebug("WhiteListModelFactory::CreateWhiteListModel()");
2727
@@ -53,15 +53,16 @@
5353
54 QMap<QDBusObjectPath,QString>::const_iterator iter = paths_and_names.begin();54 QMap<QDBusObjectPath,QString>::const_iterator iter = paths_and_names.begin();
5555
56 QRegExp rx(filter);
57
56 while(iter != paths_and_names.end() ) {58 while(iter != paths_and_names.end() ) {
5759 if (rx.exactMatch(iter.value())) {
58 qDebug() << iter.key().path();60 qDebug() << iter.key().path();
5961 qDebug() << " Name: " << iter.value();
60 qDebug() << " Name: " << iter.value();62 model->appendRow(new WhiteListItem(iter.value(), \
6163 iter.key().path(), \
62 model->appendRow(new WhiteListItem(iter.value(), \64 model));
63 iter.key().path(), \65 }
64 model));
65 iter++;66 iter++;
66 }67 }
6768
6869
=== modified file 'checkbox-gui/checkbox-gui/WhiteListModelFactory.h'
--- checkbox-gui/checkbox-gui/WhiteListModelFactory.h 2013-12-10 17:41:24 +0000
+++ checkbox-gui/checkbox-gui/WhiteListModelFactory.h 2014-03-18 16:22:23 +0000
@@ -36,7 +36,7 @@
36 ~WhiteListModelFactory() {};36 ~WhiteListModelFactory() {};
3737
38public slots:38public slots:
39 ListModel* CreateWhiteListModel(ListModel* model=NULL);39 ListModel* CreateWhiteListModel(ListModel* model=NULL, const QString &filter=QString());
40};40};
4141
42#endif // WHITELISTMODELFACTORY_H42#endif // WHITELISTMODELFACTORY_H
4343
=== modified file 'checkbox-gui/checkbox-gui/checkbox-gui.pro'
--- checkbox-gui/checkbox-gui/checkbox-gui.pro 2013-12-10 17:41:24 +0000
+++ checkbox-gui/checkbox-gui/checkbox-gui.pro 2014-03-18 16:22:23 +0000
@@ -40,8 +40,8 @@
40 whitelistitem.cpp \40 whitelistitem.cpp \
41 testitem.cpp \41 testitem.cpp \
42 listmodel.cpp \42 listmodel.cpp \
43 commandtool.cpp \
44 testitemmodel.cpp \43 testitemmodel.cpp \
44 settings.cpp \
45 WhiteListModelFactory.cpp45 WhiteListModelFactory.cpp
4646
47# Please do not modify the following two lines. Required for deployment.47# Please do not modify the following two lines. Required for deployment.
@@ -61,8 +61,8 @@
61HEADERS += whitelistitem.h \61HEADERS += whitelistitem.h \
62 testitem.h \62 testitem.h \
63 listmodel.h \63 listmodel.h \
64 commandtool.h \
65 testitemmodel.h \64 testitemmodel.h \
65 settings.h \
66 WhiteListModelFactory.h66 WhiteListModelFactory.h
6767
68target.path = $$PREFIX/bin68target.path = $$PREFIX/bin
6969
=== removed file 'checkbox-gui/checkbox-gui/commandtool.cpp'
--- checkbox-gui/checkbox-gui/commandtool.cpp 2013-07-24 15:21:15 +0000
+++ checkbox-gui/checkbox-gui/commandtool.cpp 1970-01-01 00:00:00 +0000
@@ -1,15 +0,0 @@
1#include "commandtool.h"
2
3CommandTool::CommandTool(QObject *parent) :
4 QObject(parent),
5 m_process(new QProcess(this))
6{
7}
8
9
10void CommandTool::exec(const QString& cmd, const QString& args)
11{
12 QStringList arguments;
13 arguments << args;
14 m_process->start(cmd, arguments);
15}
160
=== removed file 'checkbox-gui/checkbox-gui/commandtool.h'
--- checkbox-gui/checkbox-gui/commandtool.h 2013-12-10 17:41:24 +0000
+++ checkbox-gui/checkbox-gui/commandtool.h 1970-01-01 00:00:00 +0000
@@ -1,40 +0,0 @@
1/*
2 * This file is part of Checkbox
3 *
4 * Copyright 2013 Canonical Ltd.
5 *
6 * Authors:
7 * - Julia Segal <julia.segal@cellsoftware.co.uk>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef COMMANDTOOL_H
23#define COMMANDTOOL_H
24
25#include <QObject>
26#include <QProcess>
27#include <qdebug.h>
28
29class CommandTool : public QObject
30{
31 Q_OBJECT
32public:
33 explicit CommandTool(QObject *parent = 0);
34 Q_INVOKABLE void exec(const QString& cmd, const QString &args);
35
36private:
37 QProcess *m_process;
38};
39
40#endif // COMMAND_H
410
=== modified file 'checkbox-gui/checkbox-gui/main.cpp'
--- checkbox-gui/checkbox-gui/main.cpp 2014-01-29 10:00:26 +0000
+++ checkbox-gui/checkbox-gui/main.cpp 2014-03-18 16:22:23 +0000
@@ -28,9 +28,9 @@
28#include <QtQml>28#include <QtQml>
2929
30#include "qtquick2applicationviewer.h"30#include "qtquick2applicationviewer.h"
31#include "commandtool.h"
32#include "listmodel.h"31#include "listmodel.h"
33#include "whitelistitem.h"32#include "whitelistitem.h"
33#include "settings.h"
34#include "testitem.h"34#include "testitem.h"
35#include "testitemmodel.h"35#include "testitemmodel.h"
36#include "WhiteListModelFactory.h"36#include "WhiteListModelFactory.h"
@@ -61,10 +61,14 @@
61 // Initialise - connect to Plainbox61 // Initialise - connect to Plainbox
62 guiengine.Initialise();62 guiengine.Initialise();
6363
64 Settings* settings;
65 settings = new Settings();
66 if (app.arguments().size() > 1) {
67 settings = new Settings(app.arguments().at(1));
68 }
69 viewer.rootContext()->setContextProperty("settings", settings);
6470
65 // WhiteList Item Model Factory and placeholder model registered with QML engine
66 WhiteListModelFactory whitelistfactory;71 WhiteListModelFactory whitelistfactory;
67 viewer.rootContext()->setContextProperty("whitelistitemFactory",&whitelistfactory);
6872
69 /* We need a placeholder object here or the QML integration is unhappy73 /* We need a placeholder object here or the QML integration is unhappy
70 * that this isnt a recognisable Qt object.74 * that this isnt a recognisable Qt object.
@@ -76,10 +80,10 @@
76 exit(1);80 exit(1);
77 }81 }
7882
83 whitelistfactory.CreateWhiteListModel(whitelistmodel, settings->value("welcome/whitelist_filter", ".*"));
84
79 viewer.rootContext()->setContextProperty("whiteListModel", whitelistmodel);85 viewer.rootContext()->setContextProperty("whiteListModel", whitelistmodel);
8086
81
82
83 // Test Item Model Factory and placeholder model registered with QML engine87 // Test Item Model Factory and placeholder model registered with QML engine
84 TestItemModel testitemFactory;88 TestItemModel testitemFactory;
85 viewer.rootContext()->setContextProperty("testitemFactory",&testitemFactory);89 viewer.rootContext()->setContextProperty("testitemFactory",&testitemFactory);
@@ -96,14 +100,6 @@
96100
97 viewer.rootContext()->setContextProperty("testListModel", testlistmodel);101 viewer.rootContext()->setContextProperty("testListModel", testlistmodel);
98102
99
100
101 // We may not need this at all
102 CommandTool cmdTool;
103 viewer.rootContext()->setContextProperty("cmdTool", &cmdTool);
104
105
106
107 // In the beginning, lets see if we need to resume103 // In the beginning, lets see if we need to resume
108 bool resumeSession = false;104 bool resumeSession = false;
109105
@@ -124,7 +120,7 @@
124 // Now, load the main page120 // Now, load the main page
125 viewer.setMainQmlFile(QStringLiteral("../share/checkbox-gui/qml/checkbox-gui.qml"));121 viewer.setMainQmlFile(QStringLiteral("../share/checkbox-gui/qml/checkbox-gui.qml"));
126122
127 viewer.setTitle(app.tr("System Testing"));123 viewer.setTitle(settings->value("welcome/title", app.tr("System Testing")));
128124
129 // Ensure a reasonable minimum size for this window125 // Ensure a reasonable minimum size for this window
130 viewer.setMinimumSize(QSize(800,600));126 viewer.setMinimumSize(QSize(800,600));
131127
=== modified file 'checkbox-gui/checkbox-gui/qml/SuiteSelectionView.qml'
--- checkbox-gui/checkbox-gui/qml/SuiteSelectionView.qml 2014-03-05 10:38:05 +0000
+++ checkbox-gui/checkbox-gui/qml/SuiteSelectionView.qml 2014-03-18 16:22:23 +0000
@@ -135,9 +135,6 @@
135135
136 suitelist.visible = false;136 suitelist.visible = false;
137137
138 // Dump the whitelist as finally selected by the user
139 guiEngine.dump_whitelist_selection();
140
141 /* Now, we should go run the guiengine update to run the local jobs138 /* Now, we should go run the guiengine update to run the local jobs
142 which happen to match the whitelist. Then we can collect the139 which happen to match the whitelist. Then we can collect the
143 test jobs and show them to the user.140 test jobs and show them to the user.
144141
=== modified file 'checkbox-gui/checkbox-gui/qml/WelcomeView.qml'
--- checkbox-gui/checkbox-gui/qml/WelcomeView.qml 2014-02-19 11:31:39 +0000
+++ checkbox-gui/checkbox-gui/qml/WelcomeView.qml 2014-03-18 16:22:23 +0000
@@ -26,7 +26,7 @@
2626
27Page {27Page {
28 id: welcomePage28 id: welcomePage
29 title: i18n.tr("System Testing")29 title: settings.value("welcome/title", i18n.tr("System Testing"));
3030
31 tools: ToolbarItems {31 tools: ToolbarItems {
32 locked: true32 locked: true
@@ -87,9 +87,8 @@
87 margins: units.gu(2)87 margins: units.gu(2)
88 }88 }
8989
90 // TODO load text from Plainbox
91 // TRANSLATORS: The <p> tags are HTML - DO NOT translate them.90 // TRANSLATORS: The <p> tags are HTML - DO NOT translate them.
92 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>")91 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>"))
9392
94 height: units.gu(60)93 height: units.gu(60)
95 width: units.gu(30)94 width: units.gu(30)
@@ -127,9 +126,6 @@
127 text: i18n.tr("Continue")126 text: i18n.tr("Continue")
128 color: UbuntuColors.lightAubergine127 color: UbuntuColors.lightAubergine
129 onClicked: {128 onClicked: {
130 // Generate the the list of whitelists
131 whitelistitemFactory.CreateWhiteListModel(whiteListModel);
132
133 // Move to the whitelist selection screen129 // Move to the whitelist selection screen
134 mainView.state = "SUITESELECTION"130 mainView.state = "SUITESELECTION"
135 }131 }
136132
=== added file 'checkbox-gui/checkbox-gui/settings.cpp'
--- checkbox-gui/checkbox-gui/settings.cpp 1970-01-01 00:00:00 +0000
+++ checkbox-gui/checkbox-gui/settings.cpp 2014-03-18 16:22:23 +0000
@@ -0,0 +1,26 @@
1#include <QDebug>
2#include <QStringList>
3#include "settings.h"
4
5Settings::Settings(QObject *parent) : QObject(parent)
6{
7 m_settings = new QSettings();
8}
9
10Settings::Settings(const QString &fileName, QObject *parent) : QObject(parent)
11{
12 m_settings = new QSettings(fileName, QSettings::NativeFormat);
13}
14
15void Settings::setValue(const QString &key, const QVariant &value) {
16 m_settings->setValue(key, value);
17}
18
19QString Settings::value(const QString &key, const QString &defaultValue) const {
20 return m_settings->value(key, defaultValue).toStringList().at(0);
21}
22
23Settings::~Settings()
24{
25 delete m_settings;
26}
027
=== added file 'checkbox-gui/checkbox-gui/settings.h'
--- checkbox-gui/checkbox-gui/settings.h 1970-01-01 00:00:00 +0000
+++ checkbox-gui/checkbox-gui/settings.h 2014-03-18 16:22:23 +0000
@@ -0,0 +1,24 @@
1#ifndef SETTINGS_H
2#define SETTINGS_H
3
4#include <QObject>
5#include <QSettings>
6
7class Settings : public QObject
8{
9 Q_OBJECT
10
11public:
12 Settings(QObject *parent = 0);
13 explicit Settings(const QString & filename, QObject *parent = 0);
14 ~Settings();
15
16public slots:
17 void setValue(const QString & key, const QVariant & value);
18 QString value(const QString &key, const QString &defaultValue = QString()) const;
19
20private:
21 QSettings* m_settings;
22};
23
24#endif // SETTINGS_H
025
=== modified file 'checkbox-gui/gui-engine/gui-engine.cpp'
--- checkbox-gui/gui-engine/gui-engine.cpp 2014-03-18 15:54:05 +0000
+++ checkbox-gui/gui-engine/gui-engine.cpp 2014-03-18 16:22:23 +0000
@@ -490,7 +490,7 @@
490490
491 // First time round, fill in our whitelist member491 // First time round, fill in our whitelist member
492 if (!initialised) {492 if (!initialised) {
493 whitelist.insert(child->object_path,true);493 whitelist.insert(child->object_path, false);
494 }494 }
495 }495 }
496496
@@ -507,22 +507,6 @@
507 whitelist.insert(opath,check);507 whitelist.insert(opath,check);
508}508}
509509
510// temporary helper
511void GuiEngine::dump_whitelist_selection(void)
512{
513 // loop around all the children
514 QMap<QDBusObjectPath,bool>::const_iterator iter = whitelist.begin();
515
516 while(iter != whitelist.end() ) {
517
518 bool yes = iter.value();
519
520 qDebug() << iter.key().path() << (yes ? "Yes" : "No");
521
522 iter++;
523 }
524}
525
526void GuiEngine::Pause(void)510void GuiEngine::Pause(void)
527{511{
528 // Very simple512 // Very simple
529513
=== modified file 'checkbox-gui/gui-engine/gui-engine.h'
--- checkbox-gui/gui-engine/gui-engine.h 2014-03-18 15:54:05 +0000
+++ checkbox-gui/gui-engine/gui-engine.h 2014-03-18 16:22:23 +0000
@@ -131,9 +131,6 @@
131 /* Helper functions for logging and testing131 /* Helper functions for logging and testing
132 */132 */
133133
134 // Logging function
135 void dump_whitelist_selection(void);
136
137 // Used by the test program test-gui-engine134 // Used by the test program test-gui-engine
138 void AcknowledgeJobsDone(void);135 void AcknowledgeJobsDone(void);
139 void AcknowledgeLocalJobsDone(void);136 void AcknowledgeLocalJobsDone(void);

Subscribers

People subscribed via source and target branches