Merge lp:~tiagosh/checkbox/welcome-persist into lp:checkbox

Proposed by Tiago Salem Herrmann
Status: Merged
Merged at revision: 1331
Proposed branch: lp:~tiagosh/checkbox/welcome-persist
Merge into: lp:checkbox
Diff against target: 239 lines (+75/-7)
6 files modified
checkbox/user_interface.py (+1/-0)
checkbox_qt/qt_interface.py (+14/-2)
debian/changelog (+4/-0)
plugins/user_interface.py (+23/-0)
qt/frontend/qtfront.cpp (+27/-4)
qt/frontend/qtfront.h (+6/-1)
To merge this branch: bzr merge lp:~tiagosh/checkbox/welcome-persist
Reviewer Review Type Date Requested Status
Daniel Manrique (community) Approve
Review via email: mp+97729@code.launchpad.net

Description of the change

This MR will make the Qt Ui use the new persistent layer.
Additionally it will make the checkbox present at the bottom of the welcome screen work properly, remembering its value on future runs.

To post a comment you must log in.
lp:~tiagosh/checkbox/welcome-persist updated
1318. By Tiago Salem Herrmann

merge trunk

Revision history for this message
Daniel Manrique (roadmr) wrote :

OK, after some massaging to get this to merge against current trunk, it's now working, so I'll push it to trunk. Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'checkbox/user_interface.py'
2--- checkbox/user_interface.py 2012-03-07 21:24:47 +0000
3+++ checkbox/user_interface.py 2012-03-15 19:42:04 +0000
4@@ -68,6 +68,7 @@
5 self.title = title
6 self.data_path = data_path
7 self.progress = None
8+ self.ui_flags = {}
9
10 self.report_url = None
11 self.direction = NEXT
12
13=== modified file 'checkbox_qt/qt_interface.py'
14--- checkbox_qt/qt_interface.py 2012-03-12 21:27:15 +0000
15+++ checkbox_qt/qt_interface.py 2012-03-15 19:42:04 +0000
16@@ -59,7 +59,10 @@
17 self.onClosedFrontend, "closedFrontend")
18 self.bus.add_signal_receiver(
19 self.onReviewTestsClicked, "reviewTestsClicked")
20+ self.bus.add_signal_receiver(
21+ self.onWelcomeCheckboxToggled, "welcomeCheckboxToggled")
22 self.qtiface.setInitialState()
23+
24 self._set_main_title()
25
26 def onReviewTestsClicked(self):
27@@ -68,8 +71,14 @@
28 def onWelcomeScreenRequested(self):
29 pass
30
31- def onClosedFrontend(self):
32- self.direction = KeyboardInterrupt
33+ def onWelcomeCheckboxToggled(self, checked):
34+ self.ui_flags["show_welcome_message"] = bool(checked)
35+
36+ def onClosedFrontend(self, finished):
37+ if bool(finished):
38+ self.direction = NEXT
39+ else:
40+ self.direction = KeyboardInterrupt
41 self.loop.quit()
42
43 def _set_main_title(self, test_name=None):
44@@ -99,6 +108,9 @@
45 #Reset window title
46 self._set_main_title()
47
48+ if not self.ui_flags == {}:
49+ self.qtiface.setUiFlags(self.ui_flags)
50+
51 self.qtiface.showText(text)
52 self.wait_on_signals(fullTestsClicked=onFullTestsClicked)
53
54
55=== modified file 'debian/changelog'
56--- debian/changelog 2012-03-15 14:05:42 +0000
57+++ debian/changelog 2012-03-15 19:42:04 +0000
58@@ -7,6 +7,10 @@
59 plugins/user_interface.py, qt/frontend/qtfront.cpp, qt/frontend/qtfront.h:
60 Correctly update automated test execution status in the Selection tab
61 (LP: #950105).
62+ * set interface.direction to NEXT if all the tests were executed and the user
63+ either analyzed or submitted the results. (LP: #956329)
64+ * use the ui persistent storage to keep some ui configuration
65+ values. (LP: #937626)
66
67 [Jeff Lane]
68 * Reset default checkbox log level to INFO from DEBUG to make logs less
69
70=== modified file 'plugins/user_interface.py'
71--- plugins/user_interface.py 2012-03-07 21:24:47 +0000
72+++ plugins/user_interface.py 2012-03-15 19:42:04 +0000
73@@ -16,6 +16,7 @@
74 # You should have received a copy of the GNU General Public License
75 # along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
76 #
77+from checkbox.contrib.persist import Persist, MemoryBackend
78 from checkbox.plugin import Plugin
79 from checkbox.properties import Path, String
80 from checkbox.user_interface import PREV
81@@ -44,9 +45,21 @@
82 # Path where data files are stored.
83 data_path = Path(required=False)
84
85+ @property
86+ def persist(self):
87+ if self._persist is None:
88+ self._persist = Persist(backend=MemoryBackend())
89+
90+ return self._persist.root_at("user_interface")
91+
92 def register(self, manager):
93 super(UserInterface, self).register(manager)
94
95+ self._persist = None
96+
97+ self._manager.reactor.call_on("prompt-begin", self.prompt_begin)
98+ self._manager.reactor.call_on("stop", self.save_persist)
99+ self._manager.reactor.call_on("begin-persist", self.begin_persist)
100 self._manager.reactor.call_on("run", self.run)
101 self._manager.reactor.call_on("launchpad-report", self.launchpad_report)
102
103@@ -58,6 +71,16 @@
104 #information about each job that completes
105 interface.update_status(job)
106
107+ def begin_persist(self, persist):
108+ self._persist = persist
109+
110+ def prompt_begin(self, interface):
111+ self._interface.ui_flags = self.persist.get("ui_flags", {})
112+
113+ def save_persist(self, *args):
114+ self.persist.set("ui_flags", self._interface.ui_flags)
115+ self.persist.save()
116+
117 def set_progress(self, progress):
118 self._interface.progress = progress
119
120
121=== modified file 'qt/frontend/qtfront.cpp'
122--- qt/frontend/qtfront.cpp 2012-03-08 17:15:05 +0000
123+++ qt/frontend/qtfront.cpp 2012-03-15 19:42:04 +0000
124@@ -39,7 +39,9 @@
125 m_model(0),
126 m_statusModel(new QStandardItemModel()),
127 m_currentTab(1),
128- m_skipTestMessage(false)
129+ m_skipTestMessage(false),
130+ isFirstTimeWelcome(true),
131+ m_doneTesting(false)
132 {
133 m_mainWindow = (QWidget*)new CustomQWidget();
134 ui->setupUi(m_mainWindow);
135@@ -62,7 +64,8 @@
136 connect(ui->previousTestButton, SIGNAL(clicked()), this, SLOT(onPreviousTestClicked()));
137 connect(ui->buttonSubmitResults, SIGNAL(clicked()), this, SLOT(onSubmitTestsClicked()));
138 connect(ui->buttonViewResults, SIGNAL(clicked()), this, SLOT(onReviewTestsClicked()));
139- connect(m_mainWindow, SIGNAL(closed()), this, SIGNAL(closedFrontend()));
140+ connect(m_mainWindow, SIGNAL(closed()), this, SLOT(onClosedFrontend()));
141+ connect(ui->checkBox, SIGNAL(toggled(bool)), SIGNAL(welcomeCheckboxToggled(bool)));
142 connect(ui->treeView, SIGNAL(collapsed(QModelIndex)), this, SLOT(onJobItemChanged(QModelIndex)));
143 connect(ui->treeView, SIGNAL(expanded(QModelIndex)), this, SLOT(onJobItemChanged(QModelIndex)));
144 connect(ui->treeView->verticalScrollBar(), SIGNAL(valueChanged(int)), ui->statusView->verticalScrollBar(), SLOT(setValue(int)));
145@@ -102,6 +105,18 @@
146
147 }
148
149+void QtFront::setUiFlags(QVariantMap flags)
150+{
151+ // process all ui flags
152+ QVariant checked = flags["show_welcome_message"];
153+ ui->checkBox->setChecked(checked.toBool());
154+}
155+
156+void QtFront::onClosedFrontend()
157+{
158+ emit closedFrontend(m_doneTesting);
159+}
160+
161 void QtFront::onSelectAllContextMenu(const QPoint& pos)
162 {
163 if (currentState != TREE || !m_model)
164@@ -212,19 +227,28 @@
165 {
166 ui->buttonSubmitResults->setEnabled(false);
167 ui->lineEditEmailAddress->setEnabled(false);
168+ m_doneTesting = true;
169 emit submitTestsClicked();
170 }
171
172 void QtFront::onReviewTestsClicked()
173 {
174+ m_doneTesting = true;
175 emit reviewTestsClicked();
176 }
177
178 void QtFront::showText(QString text)
179 {
180 if (currentState == WELCOME) {
181+ if(isFirstTimeWelcome) {
182+ isFirstTimeWelcome = false;
183+ if (ui->checkBox->isChecked()) {
184+ QTimer::singleShot(100, this, SLOT(onFullTestsClicked()));
185+ }
186+ } else {
187+ ui->tabWidget->setCurrentIndex(0);
188+ }
189 m_mainWindow->show();
190- ui->tabWidget->setCurrentIndex(0);
191 ui->welcomeTextBox->setPlainText(text);
192 } else if (currentState == SUBMISSION) {
193 ui->submissionWarningLabel->setText(text);
194@@ -546,6 +570,5 @@
195 qDebug() << "error registering object";
196 return false;
197 }
198-
199 return true;
200 }
201
202=== modified file 'qt/frontend/qtfront.h'
203--- qt/frontend/qtfront.h 2012-03-08 17:15:05 +0000
204+++ qt/frontend/qtfront.h 2012-03-15 19:42:04 +0000
205@@ -51,6 +51,7 @@
206 QString getEmailAddress();
207 void showTest(QString purpose, QString steps, QString verification, QString info, QString testType, QString testName, bool enableTestButton);
208 QString showInfo(QString text, QStringList options, QString defaultoption);
209+ void setUiFlags(QVariantMap flags);
210 void updateAutoTestStatus(QString status, QString testName);
211
212 private slots:
213@@ -69,6 +70,7 @@
214 void updateTestStatus(QStandardItem *item, QString status);
215 void updateTestStatus(QString status = QString());
216 void onSelectAllContextMenu(const QPoint& pos);
217+ void onClosedFrontend();
218
219 signals:
220 void fullTestsClicked();
221@@ -84,7 +86,8 @@
222 void welcomeScreenRequested();
223 // when the user clicks welcome from the tests selection tree
224 void welcomeClicked();
225- void closedFrontend();
226+ void closedFrontend(bool testsFinished);
227+ void welcomeCheckboxToggled(bool toogled);
228
229 private:
230 bool registerService();
231@@ -100,6 +103,8 @@
232 int m_currentTab;
233 bool m_skipTestMessage;
234 QString m_currentTestName;
235+ bool isFirstTimeWelcome;
236+ bool m_doneTesting;
237 };
238
239 #endif // QTFRONT_H

Subscribers

People subscribed via source and target branches