Merge lp:~stefan-schwarzburg/qreator/fix-bug-1017674 into lp:~dpm/qreator/trunk

Proposed by Schwarzburg
Status: Merged
Merged at revision: 118
Proposed branch: lp:~stefan-schwarzburg/qreator/fix-bug-1017674
Merge into: lp:~dpm/qreator/trunk
Diff against target: 25 lines (+13/-0)
1 file modified
qreator/qrcodes/QRCodeURLGtk.py (+13/-0)
To merge this branch: bzr merge lp:~stefan-schwarzburg/qreator/fix-bug-1017674
Reviewer Review Type Date Requested Status
David Planella Approve
Review via email: mp+117884@code.launchpad.net

Description of the change

This implements the more complicated but preferred version:

- check if the entry starts with a supported protocol (support is taken from the combobox entries)
- if so, remove that protocol and
- select the appropriate protocol of the combobox

It is actually not that complicated, so we should stick with that...

To post a comment you must log in.
117. By Schwarzburg

removed GObject import

118. By Schwarzburg

merge with trunk

Revision history for this message
David Planella (dpm) wrote :

Looks great and works great, as discussed in the implementation e-mail a while ago. Merged, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qreator/qrcodes/QRCodeURLGtk.py'
2--- qreator/qrcodes/QRCodeURLGtk.py 2012-05-30 10:19:57 +0000
3+++ qreator/qrcodes/QRCodeURLGtk.py 2012-08-05 14:34:19 +0000
4@@ -58,8 +58,21 @@
5 def on_entryURL_icon_press(self, widget, icon, mouse_button):
6 clear_text_entry(widget, icon)
7
8+ def check_and_remove_protocol(self, widget):
9+ """
10+ Creates a list of protocols (as given by the combobox).
11+ Checks if beginning of the text entry is in that list. If so, remove the protocol
12+ and select the appropriate protocol in the combobox.
13+ """
14+ for n, protocol in enumerate([mr[0] for mr in self.combobox.get_model()]):
15+ if widget.get_text().strip().startswith(protocol):
16+ widget.set_text(widget.get_text().strip().strip(protocol))
17+ self.combobox.set_active(n)
18+ return
19+
20 def on_entryURL_changed(self, widget, data=None):
21 show_clear_icon(widget)
22+ self.check_and_remove_protocol(widget)
23 self.update_url_qr_code(www=widget.get_text())
24
25 def on_comboboxtextProtocol_changed(self, widget, data=None):

Subscribers

People subscribed via source and target branches

to all changes: