Merge lp://staging/~caioromao/apport/kde_question_userpass into lp://staging/~apport-hackers/apport/trunk

Proposed by Caio Romão
Status: Merged
Merged at revision: not available
Proposed branch: lp://staging/~caioromao/apport/kde_question_userpass
Merge into: lp://staging/~apport-hackers/apport/trunk
Diff against target: None lines
To merge this branch: bzr merge lp://staging/~caioromao/apport/kde_question_userpass
Reviewer Review Type Date Requested Status
Apport upstream developers Pending
Review via email: mp+9664@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Caio Romão (caioromao) wrote :

Hi Martin,

This time I've implemented the ui_question_userpass method on apport_kde. I wrote a basic one for my tests and decided to make it work correctly, that's why I haven't implemented it in apport_gtk nor in apport_cli.

The first commit in this branch simply fixes some identation issues: mixed use of whitespace and tabs.

Revision history for this message
Martin Pitt (pitti) wrote :

Hello Caio,

Caio Romão [2009-08-04 20:40 -0000]:
> This time I've implemented the ui_question_userpass method on
> apport_kde. I wrote a basic one for my tests and decided to make it
> work correctly, that's why I haven't implemented it in apport_gtk
> nor in apport_cli.

Nice, thanks! I merged this into trunk.

Martin
--
Martin Pitt | http://www.piware.de
Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'kde/apport-kde'
2--- kde/apport-kde 2009-07-10 10:34:13 +0000
3+++ kde/apport-kde 2009-08-04 20:22:41 +0000
4@@ -19,15 +19,15 @@
5 try:
6 from PyQt4.QtCore import *
7 from PyQt4.QtGui import (QDialog, QLabel, QCheckBox, QRadioButton,
8- QTreeWidget, QTreeWidgetItem, QMessageBox,
9- QVBoxLayout, QFileDialog, QDialogButtonBox,
10- QProgressBar, QGroupBox)
11+ QTreeWidget, QTreeWidgetItem, QMessageBox,
12+ QVBoxLayout, QFileDialog, QDialogButtonBox,
13+ QProgressBar, QGroupBox, QLineEdit)
14 from PyQt4 import uic
15 from gettext import gettext
16 from PyKDE4.kdecore import (ki18n, KAboutData, KCmdLineArgs,
17- KLocalizedString)
18+ KLocalizedString)
19 from PyKDE4.kdeui import (KApplication, KNotification, KMessageBox, KIcon,
20- KStandardGuiItem)
21+ KStandardGuiItem)
22 import apport.ui
23 except ImportError, e:
24 # this can happen while upgrading python packages
25@@ -41,12 +41,12 @@
26 def translate(self, prop):
27 ''' Reimplement method from uic to change it to use gettext '''
28 if prop.get("notr", None) == "true":
29- return self._cstring(prop)
30+ return self._cstring(prop)
31 else:
32- if prop.text is None:
33- return ""
34- text = prop.text.encode("UTF-8")
35- return _(text)
36+ if prop.text is None:
37+ return ""
38+ text = prop.text.encode("UTF-8")
39+ return _(text)
40
41 uic.properties.Properties._string = translate
42
43@@ -54,345 +54,380 @@
44 ''' Main dialog wrapper '''
45
46 def __init__(self, ui, title, heading, text):
47- QDialog.__init__(self, None, Qt.Window)
48-
49- uic.loadUi(os.path.join(os.path.dirname(sys.argv[0]), ui), self)
50-
51- self.setWindowTitle(title)
52- if self.findChild(QLabel, 'heading'):
53- self.findChild(QLabel, 'heading').setText('<h2>%s</h2>' % heading)
54- self.findChild(QLabel, 'text').setText(text)
55+ QDialog.__init__(self, None, Qt.Window)
56+
57+ uic.loadUi(os.path.join(os.path.dirname(sys.argv[0]), ui), self)
58+
59+ self.setWindowTitle(title)
60+ if self.findChild(QLabel, 'heading'):
61+ self.findChild(QLabel, 'heading').setText('<h2>%s</h2>' % heading)
62+ self.findChild(QLabel, 'text').setText(text)
63
64 def on_buttons_clicked(self, button):
65- self.actionbutton = button
66- if self.sender().buttonRole(button) == QDialogButtonBox.ActionRole:
67- button.window().done(2)
68-
69+ self.actionbutton = button
70+ if self.sender().buttonRole(button) == QDialogButtonBox.ActionRole:
71+ button.window().done(2)
72+
73 def addbutton(self, button):
74- return self.findChild(QDialogButtonBox, 'buttons').addButton(button,
75- QDialogButtonBox.ActionRole)
76+ return self.findChild(QDialogButtonBox, 'buttons').addButton(button,
77+ QDialogButtonBox.ActionRole)
78
79 class ErrorDialog(Dialog):
80 ''' Error dialog wrapper '''
81
82 def __init__(self, title, heading, text, checker=None):
83- Dialog.__init__(self, 'error.ui', title, heading, text)
84-
85- self.setMaximumSize(1, 1)
86- self.findChild(QLabel, 'icon').setPixmap(
87- QMessageBox.standardIcon(QMessageBox.Critical))
88-
89- self.checker = self.findChild(QCheckBox, 'checker')
90- if checker:
91- self.checker.setText(checker)
92- else:
93- self.checker.hide()
94-
95+ Dialog.__init__(self, 'error.ui', title, heading, text)
96+
97+ self.setMaximumSize(1, 1)
98+ self.findChild(QLabel, 'icon').setPixmap(
99+ QMessageBox.standardIcon(QMessageBox.Critical))
100+
101+ self.checker = self.findChild(QCheckBox, 'checker')
102+ if checker:
103+ self.checker.setText(checker)
104+ else:
105+ self.checker.hide()
106+
107 def checked(self):
108- return self.checker.isChecked()
109+ return self.checker.isChecked()
110
111 class ChoicesDialog(Dialog):
112 ''' Choices dialog wrapper '''
113
114 def __init__(self, title, text):
115- Dialog.__init__(self, 'choices.ui', title, None, text)
116+ Dialog.__init__(self, 'choices.ui', title, None, text)
117
118- self.setMaximumSize(1, 1)
119+ self.setMaximumSize(1, 1)
120
121 def on_buttons_clicked(self, button):
122- Dialog.on_buttons_clicked(self, button)
123- if self.sender().buttonRole(button) == QDialogButtonBox.RejectRole:
124- sys.exit(0)
125+ Dialog.on_buttons_clicked(self, button)
126+ if self.sender().buttonRole(button) == QDialogButtonBox.RejectRole:
127+ sys.exit(0)
128
129 class ProgressDialog(Dialog):
130 ''' Progress dialog wrapper '''
131
132 def __init__(self, title, heading, text):
133- Dialog.__init__(self, 'progress.ui', title, heading, text)
134+ Dialog.__init__(self, 'progress.ui', title, heading, text)
135
136- self.setMaximumSize(1, 1)
137+ self.setMaximumSize(1, 1)
138
139 def on_buttons_clicked(self, button):
140- Dialog.on_buttons_clicked(self, button)
141- if self.sender().buttonRole(button) == QDialogButtonBox.RejectRole:
142- sys.exit(0)
143-
144+ Dialog.on_buttons_clicked(self, button)
145+ if self.sender().buttonRole(button) == QDialogButtonBox.RejectRole:
146+ sys.exit(0)
147+
148 def set(self, value=None):
149- progress = self.findChild(QProgressBar, 'progress')
150- if not value:
151- progress.setRange(0, 0)
152- progress.setValue(0)
153- else:
154- progress.setRange(0, 1000)
155- progress.setValue(value * 1000)
156+ progress = self.findChild(QProgressBar, 'progress')
157+ if not value:
158+ progress.setRange(0, 0)
159+ progress.setValue(0)
160+ else:
161+ progress.setRange(0, 1000)
162+ progress.setValue(value * 1000)
163
164 class ReportDialog(Dialog):
165 ''' Report dialog wrapper '''
166
167 def __init__(self, title, heading, text):
168- Dialog.__init__(self, 'bugreport.ui', title, heading, text)
169-
170- self.details = self.addbutton(_("&Details..."))
171- self.details.setCheckable(True)
172-
173- self.treeview = self.findChild(QTreeWidget, 'details')
174- self.showtree(False)
175+ Dialog.__init__(self, 'bugreport.ui', title, heading, text)
176+
177+ self.details = self.addbutton(_("&Details..."))
178+ self.details.setCheckable(True)
179+
180+ self.treeview = self.findChild(QTreeWidget, 'details')
181+ self.showtree(False)
182
183 def on_buttons_clicked(self, button):
184- if self.details == button:
185- self.showtree(button.isChecked())
186- else:
187- Dialog.on_buttons_clicked(self, button)
188- if self.sender().buttonRole(button) == QDialogButtonBox.RejectRole:
189- sys.exit(0)
190-
191+ if self.details == button:
192+ self.showtree(button.isChecked())
193+ else:
194+ Dialog.on_buttons_clicked(self, button)
195+ if self.sender().buttonRole(button) == QDialogButtonBox.RejectRole:
196+ sys.exit(0)
197+
198 def showtree(self, visible):
199- self.treeview.setVisible(visible)
200- if visible:
201- self.setMaximumSize(16777215, 16777215)
202- else:
203- self.setMaximumSize(1, 1)
204+ self.treeview.setVisible(visible)
205+ if visible:
206+ self.setMaximumSize(16777215, 16777215)
207+ else:
208+ self.setMaximumSize(1, 1)
209+
210+
211+class UserPassDialog(Dialog):
212+ ''' Username/Password dialog wrapper '''
213+
214+ def __init__(self, title, text):
215+ Dialog.__init__(self, 'userpass.ui', title, None, text)
216+ self.findChild(QLabel, 'l_username').setText(_('Username:'))
217+ self.findChild(QLabel, 'l_password').setText(_('Password:'))
218+
219+ def on_buttons_clicked(self, button):
220+ Dialog.on_buttons_clicked(self, button)
221+ if self.sender().buttonRole(button) == QDialogButtonBox.RejectRole:
222+ sys.exit(0)
223+
224
225 class MainUserInterface(apport.ui.UserInterface):
226 ''' The main user interface presented to the user '''
227
228 def __init__(self):
229- apport.ui.UserInterface.__init__(self)
230+ apport.ui.UserInterface.__init__(self)
231
232- self.run_argv()
233+ self.run_argv()
234
235 #
236 # ui_* implementation of abstract UserInterface classes
237 #
238
239 def ui_present_crash(self, desktop_entry):
240- # adapt dialog heading and label appropriately
241- if desktop_entry:
242- name = desktop_entry.getName()
243- heading = _('Sorry, %s closed unexpectedly') % name
244- elif self.report.has_key('ExecutablePath'):
245- name = os.path.basename(self.report['ExecutablePath'])
246- heading = _('Sorry, the program "%s" closed unexpectedly.') % name
247- else:
248- name = self.cur_package
249- heading = _('Sorry, %s closed unexpectedly.') % name
250-
251- dialog = ErrorDialog(name, heading,
252- _('If you were not doing anything confidential (entering '
253- 'passwords or other private information), you can help '
254- 'to improve the application by reporting the problem.'),
255- _('&Ignore future crashes of this program version'))
256-
257- reportbutton = dialog.addbutton(_('&Report Problem...'))
258-
259- if desktop_entry and self.report.has_key('ExecutablePath') and \
260- os.path.dirname(self.report['ExecutablePath']) in \
261- os.environ['PATH'].split(':') and subprocess.call(['pgrep',
262- '-x', os.path.basename(self.report['ExecutablePath']),
263- '-u', str(os.getuid())], stdout=subprocess.PIPE) != 0:
264- restartbutton = dialog.addbutton(_('Restart &Program'))
265-
266- # show crash notification dialog
267- response = dialog.exec_()
268- blacklist = dialog.checked()
269-
270- if response == QDialog.Rejected:
271- return {'action': 'cancel', 'blacklist': blacklist}
272- if dialog.actionbutton == reportbutton:
273- return {'action': 'report', 'blacklist': blacklist}
274- if dialog.actionbutton == restartbutton:
275- return {'action': 'restart', 'blacklist': blacklist}
276- # Fallback
277- return {'action': 'cancel', 'blacklist': blacklist}
278+ # adapt dialog heading and label appropriately
279+ if desktop_entry:
280+ name = desktop_entry.getName()
281+ heading = _('Sorry, %s closed unexpectedly') % name
282+ elif self.report.has_key('ExecutablePath'):
283+ name = os.path.basename(self.report['ExecutablePath'])
284+ heading = _('Sorry, the program "%s" closed unexpectedly.') % name
285+ else:
286+ name = self.cur_package
287+ heading = _('Sorry, %s closed unexpectedly.') % name
288+
289+ dialog = ErrorDialog(name, heading,
290+ _('If you were not doing anything confidential (entering '
291+ 'passwords or other private information), you can help '
292+ 'to improve the application by reporting the problem.'),
293+ _('&Ignore future crashes of this program version'))
294+
295+ reportbutton = dialog.addbutton(_('&Report Problem...'))
296+
297+ if desktop_entry and self.report.has_key('ExecutablePath') and \
298+ os.path.dirname(self.report['ExecutablePath']) in \
299+ os.environ['PATH'].split(':') and subprocess.call(['pgrep',
300+ '-x', os.path.basename(self.report['ExecutablePath']),
301+ '-u', str(os.getuid())], stdout=subprocess.PIPE) != 0:
302+ restartbutton = dialog.addbutton(_('Restart &Program'))
303+
304+ # show crash notification dialog
305+ response = dialog.exec_()
306+ blacklist = dialog.checked()
307+
308+ if response == QDialog.Rejected:
309+ return {'action': 'cancel', 'blacklist': blacklist}
310+ if dialog.actionbutton == reportbutton:
311+ return {'action': 'report', 'blacklist': blacklist}
312+ if dialog.actionbutton == restartbutton:
313+ return {'action': 'restart', 'blacklist': blacklist}
314+ # Fallback
315+ return {'action': 'cancel', 'blacklist': blacklist}
316
317 def ui_present_package_error(self):
318- name = self.report['Package']
319- dialog = ErrorDialog(name,
320- _('Sorry, the package "%s" failed to install or upgrade.') %
321- name,
322- _('You can help the developers to fix the package by '
323- 'reporting the problem.'))
324-
325- reportbutton = dialog.addbutton(_('&Report Problem...'))
326-
327- response = dialog.exec_()
328-
329- if response == QDialog.Rejected:
330- return 'cancel'
331- if dialog.actionbutton == reportbutton:
332- return 'report'
333- # Fallback
334- return 'cancel'
335+ name = self.report['Package']
336+ dialog = ErrorDialog(name,
337+ _('Sorry, the package "%s" failed to install or upgrade.') %
338+ name,
339+ _('You can help the developers to fix the package by '
340+ 'reporting the problem.'))
341+
342+ reportbutton = dialog.addbutton(_('&Report Problem...'))
343+
344+ response = dialog.exec_()
345+
346+ if response == QDialog.Rejected:
347+ return 'cancel'
348+ if dialog.actionbutton == reportbutton:
349+ return 'report'
350+ # Fallback
351+ return 'cancel'
352
353 def ui_present_kernel_error(self):
354- message = _('Your system encountered a serious kernel problem.')
355- annotate = ''
356- if self.report.has_key('Annotation'):
357- annotate = self.report['Annotation'] + '\n\n'
358- annotate += _('You can help the developers to fix the problem by '
359- 'reporting it.')
360-
361- dialog = ErrorDialog(_('Kernel problem'), message, annotate)
362-
363- reportbutton = dialog.addbutton(_('&Report Problem...'))
364-
365- response = dialog.exec_()
366-
367- if response == QDialog.Rejected:
368- return 'cancel'
369- if dialog.actionbutton == reportbutton:
370- return 'report'
371- # Fallback
372- return 'cancel'
373+ message = _('Your system encountered a serious kernel problem.')
374+ annotate = ''
375+ if self.report.has_key('Annotation'):
376+ annotate = self.report['Annotation'] + '\n\n'
377+ annotate += _('You can help the developers to fix the problem by '
378+ 'reporting it.')
379+
380+ dialog = ErrorDialog(_('Kernel problem'), message, annotate)
381+
382+ reportbutton = dialog.addbutton(_('&Report Problem...'))
383+
384+ response = dialog.exec_()
385+
386+ if response == QDialog.Rejected:
387+ return 'cancel'
388+ if dialog.actionbutton == reportbutton:
389+ return 'report'
390+ # Fallback
391+ return 'cancel'
392
393 def ui_present_report_details(self):
394- dialog = ReportDialog(self.report.get('Package',
395- _('Generic error')).split()[0],
396- _('Send problem report to the developers?'),
397- _('After the problem report has been sent, please fill out '
398- 'the form in the automatically opened web browser.'))
399-
400- sendbutton = dialog.addbutton(_('&Send'))
401- sendbutton.setDefault(True)
402-
403- # report contents
404- details = dialog.findChild(QTreeWidget, 'details')
405- for key in self.report:
406- keyitem = QTreeWidgetItem([key])
407- details.addTopLevelItem(keyitem)
408-
409- # string value
410- if not hasattr(self.report[key], 'gzipvalue') and \
411- hasattr(self.report[key], 'isspace') and \
412- not self.report._is_binary(self.report[key]):
413- lines = self.report[key].splitlines()
414- for line in lines:
415- QTreeWidgetItem(keyitem, [line])
416- if len(lines) < 4:
417- keyitem.setExpanded(True)
418- else:
419- QTreeWidgetItem(keyitem, [_('(binary data)')])
420-
421- details.header().hide()
422-
423- # complete/reduce radio buttons
424- if self.report.has_key('CoreDump') and \
425- self.report.has_useful_stacktrace():
426- dialog.findChild(QRadioButton, 'complete').setText(
427- _('Complete report (recommended; %s)') %
428- self.format_filesize(self.get_complete_size()))
429- dialog.findChild(QRadioButton, 'reduced').setText(
430- _('Reduced report (slow Internet connection; %s)') %
431- self.format_filesize(self.get_reduced_size()))
432- else:
433- dialog.findChild(QGroupBox, 'options').hide()
434-
435- response = dialog.exec_()
436-
437- if response == QDialog.Rejected:
438- return 'cancel'
439- # Fallback
440- if dialog.actionbutton != sendbutton:
441- return 'cancel'
442- if dialog.findChild(QRadioButton, 'reduced').isChecked():
443- return 'reduced'
444- if dialog.findChild(QRadioButton, 'complete').isChecked():
445- return 'full'
446- # Fallback
447- return 'cancel'
448+ dialog = ReportDialog(self.report.get('Package',
449+ _('Generic error')).split()[0],
450+ _('Send problem report to the developers?'),
451+ _('After the problem report has been sent, please fill out '
452+ 'the form in the automatically opened web browser.'))
453+
454+ sendbutton = dialog.addbutton(_('&Send'))
455+ sendbutton.setDefault(True)
456+
457+ # report contents
458+ details = dialog.findChild(QTreeWidget, 'details')
459+ for key in self.report:
460+ keyitem = QTreeWidgetItem([key])
461+ details.addTopLevelItem(keyitem)
462+
463+ # string value
464+ if not hasattr(self.report[key], 'gzipvalue') and \
465+ hasattr(self.report[key], 'isspace') and \
466+ not self.report._is_binary(self.report[key]):
467+ lines = self.report[key].splitlines()
468+ for line in lines:
469+ QTreeWidgetItem(keyitem, [line])
470+ if len(lines) < 4:
471+ keyitem.setExpanded(True)
472+ else:
473+ QTreeWidgetItem(keyitem, [_('(binary data)')])
474+
475+ details.header().hide()
476+
477+ # complete/reduce radio buttons
478+ if self.report.has_key('CoreDump') and \
479+ self.report.has_useful_stacktrace():
480+ dialog.findChild(QRadioButton, 'complete').setText(
481+ _('Complete report (recommended; %s)') %
482+ self.format_filesize(self.get_complete_size()))
483+ dialog.findChild(QRadioButton, 'reduced').setText(
484+ _('Reduced report (slow Internet connection; %s)') %
485+ self.format_filesize(self.get_reduced_size()))
486+ else:
487+ dialog.findChild(QGroupBox, 'options').hide()
488+
489+ response = dialog.exec_()
490+
491+ if response == QDialog.Rejected:
492+ return 'cancel'
493+ # Fallback
494+ if dialog.actionbutton != sendbutton:
495+ return 'cancel'
496+ if dialog.findChild(QRadioButton, 'reduced').isChecked():
497+ return 'reduced'
498+ if dialog.findChild(QRadioButton, 'complete').isChecked():
499+ return 'full'
500+ # Fallback
501+ return 'cancel'
502
503 def ui_info_message(self, title, text):
504- KMessageBox.information(None, _(text), _(title))
505+ KMessageBox.information(None, _(text), _(title))
506
507 def ui_error_message(self, title, text):
508- KMessageBox.information(None, _(text), _(title))
509+ KMessageBox.information(None, _(text), _(title))
510
511 def ui_start_info_collection_progress(self):
512- self.progress = ProgressDialog(
513- _('Collecting Problem Information'),
514- _('Collecting problem information'),
515- _('The collected information can be sent to the developers '
516- 'to improve the application. This might take a few '
517- 'minutes.'))
518- self.progress.set()
519- self.progress.show()
520+ self.progress = ProgressDialog(
521+ _('Collecting Problem Information'),
522+ _('Collecting problem information'),
523+ _('The collected information can be sent to the developers '
524+ 'to improve the application. This might take a few '
525+ 'minutes.'))
526+ self.progress.set()
527+ self.progress.show()
528
529 def ui_pulse_info_collection_progress(self):
530- self.progress.set()
531- KApplication.processEvents()
532+ self.progress.set()
533+ KApplication.processEvents()
534
535 def ui_stop_info_collection_progress(self):
536- self.progress.hide()
537+ self.progress.hide()
538
539 def ui_start_upload_progress(self):
540- self.progress = ProgressDialog(
541- _('Uploading Problem Information'),
542- _('Uploading problem information'),
543- _('The collected information is being sent to the bug '
544- 'tracking system. This might take a few minutes.'))
545- self.progress.show()
546+ self.progress = ProgressDialog(
547+ _('Uploading Problem Information'),
548+ _('Uploading problem information'),
549+ _('The collected information is being sent to the bug '
550+ 'tracking system. This might take a few minutes.'))
551+ self.progress.show()
552
553 def ui_set_upload_progress(self, progress):
554- if progress:
555- self.progress.set(progress)
556- else:
557- self.progress.set()
558- KApplication.processEvents()
559+ if progress:
560+ self.progress.set(progress)
561+ else:
562+ self.progress.set()
563+ KApplication.processEvents()
564
565 def ui_stop_upload_progress(self):
566- self.progress.hide()
567+ self.progress.hide()
568
569 def ui_question_yesno(self, text):
570- response = KMessageBox.questionYesNoCancel(None, _(text), QString(),
571- KStandardGuiItem.yes(), KStandardGuiItem.no(),
572- KStandardGuiItem.cancel())
573- if response == KMessageBox.Yes:
574- return True
575- if response == KMessageBox.No:
576- return False
577- return None
578+ response = KMessageBox.questionYesNoCancel(None, _(text), QString(),
579+ KStandardGuiItem.yes(), KStandardGuiItem.no(),
580+ KStandardGuiItem.cancel())
581+ if response == KMessageBox.Yes:
582+ return True
583+ if response == KMessageBox.No:
584+ return False
585+ return None
586
587 def ui_question_choice(self, text, options, multiple):
588- ''' Show a question with predefined choices.
589-
590- @options is a list of strings to present.
591- @multiple - if True, choices should be QCheckBoxes, if False then
592- should be QRadioButtons.
593-
594- Return list of selected option indexes, or None if the user cancelled.
595- If multiple is False, the list will always have one element.
596- '''
597-
598- dialog = ChoicesDialog(_("Apport"), text)
599-
600- b = None
601- for option in options:
602- if multiple:
603- b = QCheckBox(option)
604- else:
605- b = QRadioButton(option)
606- dialog.vbox_choices.insertWidget(0, b)
607-
608- response = dialog.exec_()
609-
610- if response == QDialog.Rejected:
611- return 'cancel'
612-
613- response = [c for c in range(0, dialog.vbox_choices.count()) if \
614- dialog.vbox_choices.itemAt(c).widget().isChecked()]
615-
616- return response
617+ ''' Show a question with predefined choices.
618+
619+ @options is a list of strings to present.
620+ @multiple - if True, choices should be QCheckBoxes, if False then
621+ should be QRadioButtons.
622+
623+ Return list of selected option indexes, or None if the user cancelled.
624+ If multiple is False, the list will always have one element.
625+ '''
626+
627+ dialog = ChoicesDialog(_("Apport"), text)
628+
629+ b = None
630+ for option in options:
631+ if multiple:
632+ b = QCheckBox(option)
633+ else:
634+ b = QRadioButton(option)
635+ dialog.vbox_choices.insertWidget(0, b)
636+
637+ response = dialog.exec_()
638+
639+ if response == QDialog.Rejected:
640+ return 'cancel'
641+
642+ response = [c for c in range(0, dialog.vbox_choices.count()) if \
643+ dialog.vbox_choices.itemAt(c).widget().isChecked()]
644+
645+ return response
646
647 def ui_question_file(self, text):
648- ''' Show a file selector dialog.
649-
650- Return path if the user selected a file, or None if cancelled.
651- '''
652-
653- response = QFileDialog.getOpenFileName(None, unicode(text, 'UTF-8'))
654- if response.length() == 0:
655- return None
656- return str(response)
657+ ''' Show a file selector dialog.
658+
659+ Return path if the user selected a file, or None if cancelled.
660+ '''
661+
662+ response = QFileDialog.getOpenFileName(None, unicode(text, 'UTF-8'))
663+ if response.length() == 0:
664+ return None
665+ return str(response)
666+
667+
668+ def ui_question_userpass(self, text):
669+ '''Show a Username/Password dialog.
670+
671+ Return a tuple (user, pass) or None if cancelled.'''
672+
673+ dialog = UserPassDialog(_('Apport'), text)
674+ response = dialog.exec_()
675+
676+ if response == QDialog.Rejected:
677+ return None
678+
679+ username = str(dialog.findChild(QLineEdit, 'e_username').text())
680+ password = str(dialog.findChild(QLineEdit, 'e_password').text())
681+
682+ if len(username) == 0 or len(password) == 0:
683+ return None
684+ return (username, password)
685+
686
687 if __name__ == '__main__':
688 appName = "apport-kde"
689@@ -407,7 +442,7 @@
690 bugEmail = "kubuntu-devel@lists.ubuntu.com"
691
692 aboutData = KAboutData(appName, catalog, programName, version, description,
693- license, copyright, text, homePage, bugEmail)
694+ license, copyright, text, homePage, bugEmail)
695
696 aboutData.addAuthor(ki18n("Richard A. Johnson"), ki18n("Author"))
697 aboutData.addAuthor(ki18n("Michael Hofmann"), ki18n("Original Qt4 Author"))
698
699=== added file 'kde/userpass.ui'
700--- kde/userpass.ui 1970-01-01 00:00:00 +0000
701+++ kde/userpass.ui 2009-08-04 20:22:41 +0000
702@@ -0,0 +1,127 @@
703+<?xml version="1.0" encoding="UTF-8"?>
704+<ui version="4.0">
705+ <class>Dialog</class>
706+ <widget class="QDialog" name="Dialog">
707+ <property name="geometry">
708+ <rect>
709+ <x>0</x>
710+ <y>0</y>
711+ <width>398</width>
712+ <height>159</height>
713+ </rect>
714+ </property>
715+ <property name="windowTitle">
716+ <string>Dialog</string>
717+ </property>
718+ <widget class="QWidget" name="verticalLayoutWidget">
719+ <property name="geometry">
720+ <rect>
721+ <x>10</x>
722+ <y>10</y>
723+ <width>381</width>
724+ <height>139</height>
725+ </rect>
726+ </property>
727+ <layout class="QVBoxLayout" name="verticalLayout">
728+ <item>
729+ <widget class="QLabel" name="text">
730+ <property name="sizePolicy">
731+ <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
732+ <horstretch>0</horstretch>
733+ <verstretch>0</verstretch>
734+ </sizepolicy>
735+ </property>
736+ <property name="text">
737+ <string>text</string>
738+ </property>
739+ <property name="alignment">
740+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
741+ </property>
742+ <property name="wordWrap">
743+ <bool>true</bool>
744+ </property>
745+ <property name="indent">
746+ <number>1</number>
747+ </property>
748+ </widget>
749+ </item>
750+ <item>
751+ <layout class="QFormLayout" name="formLayout">
752+ <property name="fieldGrowthPolicy">
753+ <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
754+ </property>
755+ <item row="1" column="1">
756+ <widget class="QLineEdit" name="e_username"/>
757+ </item>
758+ <item row="1" column="0">
759+ <widget class="QLabel" name="l_username">
760+ <property name="text">
761+ <string>user</string>
762+ </property>
763+ </widget>
764+ </item>
765+ <item row="2" column="0">
766+ <widget class="QLabel" name="l_password">
767+ <property name="text">
768+ <string>pass</string>
769+ </property>
770+ </widget>
771+ </item>
772+ <item row="2" column="1">
773+ <widget class="QLineEdit" name="e_password">
774+ <property name="echoMode">
775+ <enum>QLineEdit::Password</enum>
776+ </property>
777+ </widget>
778+ </item>
779+ </layout>
780+ </item>
781+ <item>
782+ <widget class="QDialogButtonBox" name="buttonBox">
783+ <property name="orientation">
784+ <enum>Qt::Horizontal</enum>
785+ </property>
786+ <property name="standardButtons">
787+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
788+ </property>
789+ </widget>
790+ </item>
791+ </layout>
792+ </widget>
793+ </widget>
794+ <resources/>
795+ <connections>
796+ <connection>
797+ <sender>buttonBox</sender>
798+ <signal>accepted()</signal>
799+ <receiver>Dialog</receiver>
800+ <slot>accept()</slot>
801+ <hints>
802+ <hint type="sourcelabel">
803+ <x>248</x>
804+ <y>254</y>
805+ </hint>
806+ <hint type="destinationlabel">
807+ <x>157</x>
808+ <y>274</y>
809+ </hint>
810+ </hints>
811+ </connection>
812+ <connection>
813+ <sender>buttonBox</sender>
814+ <signal>rejected()</signal>
815+ <receiver>Dialog</receiver>
816+ <slot>reject()</slot>
817+ <hints>
818+ <hint type="sourcelabel">
819+ <x>316</x>
820+ <y>260</y>
821+ </hint>
822+ <hint type="destinationlabel">
823+ <x>286</x>
824+ <y>274</y>
825+ </hint>
826+ </hints>
827+ </connection>
828+ </connections>
829+</ui>

Subscribers

People subscribed via source and target branches