Merge lp:~ralsina/ubuntuone-control-panel/go-native into lp:ubuntuone-control-panel

Proposed by Roberto Alsina
Status: Merged
Approved by: Roberto Alsina
Approved revision: 286
Merged at revision: 280
Proposed branch: lp:~ralsina/ubuntuone-control-panel/go-native
Merge into: lp:ubuntuone-control-panel
Diff against target: 70 lines (+14/-4)
3 files modified
ubuntuone/controlpanel/gui/qt/addfolder.py (+12/-1)
ubuntuone/controlpanel/gui/qt/tests/test_addfolder.py (+1/-1)
ubuntuone/controlpanel/utils/windows.py (+1/-2)
To merge this branch: bzr merge lp:~ralsina/ubuntuone-control-panel/go-native
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Manuel de la Peña (community) Approve
Review via email: mp+96123@code.launchpad.net

Commit message

 - Switched to the native file chooser on Linux (Fixes LP: #947711).

Description of the change

Only use the non-native file chooser on Windows

To post a comment you must log in.
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

When opening the file choose from the Folders tab, I'm getting:

  File "/home/nessita/canonical/controlpanel/review_go-native/ubuntuone/controlpanel/gui/qt/__init__.py", line 94, in inner
    res = yield f(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1039, in _inlineCallbacks
    result = g.send(result)
  File "/home/nessita/canonical/controlpanel/review_go-native/ubuntuone/controlpanel/gui/qt/addfolder.py", line 61, in on_clicked
    options=FILE_CHOOSER_OPTIONS)
TypeError: QFileDialog.getExistingDirectory(QWidget parent=None, QString caption=QString(), QString directory=QString(), QFileDialog.Options options=QFileDialog.ShowDirsOnly): argument 'options' has unexpected type 'int'

review: Needs Fixing
279. By Roberto Alsina

No, 0 is not a good option

Revision history for this message
Roberto Alsina (ralsina) wrote :

> When opening the file choose from the Folders tab, I'm getting:
>
> File "/home/nessita/canonical/controlpanel/review_go-
> native/ubuntuone/controlpanel/gui/qt/__init__.py", line 94, in inner
> res = yield f(*args, **kwargs)
> File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line
> 1039, in _inlineCallbacks
> result = g.send(result)
> File "/home/nessita/canonical/controlpanel/review_go-
> native/ubuntuone/controlpanel/gui/qt/addfolder.py", line 61, in on_clicked
> options=FILE_CHOOSER_OPTIONS)
> TypeError: QFileDialog.getExistingDirectory(QWidget parent=None, QString
> caption=QString(), QString directory=QString(), QFileDialog.Options
> options=QFileDialog.ShowDirsOnly): argument 'options' has unexpected type
> 'int'

I forgot to IRL test the last revno. So, I added the right constant now, but I amhaving two concerns about this branch:

1) It's importing PyQt outside qt/
2) I created a linux.py just for a constant

Revision history for this message
Natalia Bidart (nataliabidart) wrote :

> I forgot to IRL test the last revno. So, I added the right constant now, but I
> amhaving two concerns about this branch:
>
> 1) It's importing PyQt outside qt/
> 2) I created a linux.py just for a constant

What about if you just do the following in ubuntuone/controlpanel/utils/__init__.py?

if windows:
    FILE_CHOOSER_OPTIONS = QtGui.QFileDialog.DontUseNativeDialog | QtGui.QFileDialog.ShowDirsOnly
else:
    FILE_CHOOSER_OPTIONS = QtGui.QFileDialog.ShowDirsOnly

280. By Roberto Alsina

simplify a bit

Revision history for this message
Roberto Alsina (ralsina) wrote :

> What about if you just do the following in
> ubuntuone/controlpanel/utils/__init__.py?
>
> if windows:
> FILE_CHOOSER_OPTIONS = QtGui.QFileDialog.DontUseNativeDialog |
> QtGui.QFileDialog.ShowDirsOnly
> else:
> FILE_CHOOSER_OPTIONS = QtGui.QFileDialog.ShowDirsOnly

Sure, done in revno 280 (no need for the | ShowDirsOnly). It would still be importing QtGui outside qt/ though

Revision history for this message
Manuel de la Peña (mandel) wrote :

Did an IRL and got the native dialog.

review: Approve
281. By Roberto Alsina

moved constants into folders.py

282. By Roberto Alsina

move things around

283. By Roberto Alsina

merged trunk

284. By Roberto Alsina

stupid me

285. By Roberto Alsina

engage brain before coding

Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Looks great!

review: Approve
286. By Roberto Alsina

typo

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ubuntuone/controlpanel/gui/qt/addfolder.py'
--- ubuntuone/controlpanel/gui/qt/addfolder.py 2012-01-18 19:52:25 +0000
+++ ubuntuone/controlpanel/gui/qt/addfolder.py 2012-03-09 14:19:21 +0000
@@ -19,6 +19,7 @@
19"""The user interface for the control panel for Ubuntu One."""19"""The user interface for the control panel for Ubuntu One."""
2020
21from __future__ import division21from __future__ import division
22import sys
2223
23from PyQt4 import QtGui, QtCore24from PyQt4 import QtGui, QtCore
24from twisted.internet import defer25from twisted.internet import defer
@@ -32,6 +33,16 @@
32logger = setup_logging('qt.addfolder')33logger = setup_logging('qt.addfolder')
3334
34CLOSE = QtGui.QMessageBox.Close35CLOSE = QtGui.QMessageBox.Close
36# NOTE: this is temporary because of a Qt bug that will be fixed
37# on Qt 4.9. You cannot, in general, use sys.platform in these
38# modules. Do not do this. Please. This is an exception, one
39# time only, pinky-swear, cross my heart and hope to die if
40# I lie.
41FILE_CHOOSER_OPTIONS = QtGui.QFileDialog.ShowDirsOnly
42if sys.platform == 'win32':
43 FILE_CHOOSER_OPTIONS |= QtGui.QFileDialog.DontUseNativeDialog
44# Yes, that is true. If you do that again, you will be hunted
45# down and taught a lesson. You will be sorry.
3546
3647
37class AddFolderButton(cache.Cache, QtGui.QPushButton):48class AddFolderButton(cache.Cache, QtGui.QPushButton):
@@ -57,7 +68,7 @@
57 home_dir = yield self.backend.get_home_dir()68 home_dir = yield self.backend.get_home_dir()
58 folder = QtGui.QFileDialog.getExistingDirectory(69 folder = QtGui.QFileDialog.getExistingDirectory(
59 parent=self, directory=home_dir,70 parent=self, directory=home_dir,
60 options=QtGui.QFileDialog.DontUseNativeDialog)71 options=FILE_CHOOSER_OPTIONS)
61 folder = unicode(QtCore.QDir.toNativeSeparators(folder))72 folder = unicode(QtCore.QDir.toNativeSeparators(folder))
62 logger.debug('on_add_folder_button_clicked: user requested folder '73 logger.debug('on_add_folder_button_clicked: user requested folder '
63 'creation for path %r', folder)74 'creation for path %r', folder)
6475
=== modified file 'ubuntuone/controlpanel/gui/qt/tests/test_addfolder.py'
--- ubuntuone/controlpanel/gui/qt/tests/test_addfolder.py 2012-03-02 17:13:04 +0000
+++ ubuntuone/controlpanel/gui/qt/tests/test_addfolder.py 2012-03-09 14:19:21 +0000
@@ -81,7 +81,7 @@
81 home_dir = yield self.ui.backend.get_home_dir()81 home_dir = yield self.ui.backend.get_home_dir()
82 self.assertEqual(FakedFileDialog.args, ())82 self.assertEqual(FakedFileDialog.args, ())
83 self.assertEqual(FakedFileDialog.kwargs, {83 self.assertEqual(FakedFileDialog.kwargs, {
84 'options': gui.QtGui.QFileDialog.DontUseNativeDialog,84 'options': gui.FILE_CHOOSER_OPTIONS,
85 'directory': home_dir,85 'directory': home_dir,
86 'parent': self.ui,86 'parent': self.ui,
87 })87 })
8888
=== modified file 'ubuntuone/controlpanel/utils/windows.py'
--- ubuntuone/controlpanel/utils/windows.py 2011-11-15 12:36:15 +0000
+++ ubuntuone/controlpanel/utils/windows.py 2012-03-09 14:19:21 +0000
@@ -15,7 +15,7 @@
15# You should have received a copy of the GNU General Public License along15# You should have received a copy of the GNU General Public License along
16# with this program. If not, see <http://www.gnu.org/licenses/>.16# with this program. If not, see <http://www.gnu.org/licenses/>.
1717
18"""Autoupdate functions for windows."""18"""Miscelaneous functions and constants for windows."""
1919
20import os20import os
21import sys21import sys
@@ -24,7 +24,6 @@
24# pylint: disable=F040124# pylint: disable=F0401
25import win32api25import win32api
26# pylint: enable=F040126# pylint: enable=F0401
27
28from twisted.internet import defer27from twisted.internet import defer
29from twisted.internet.utils import getProcessValue28from twisted.internet.utils import getProcessValue
3029

Subscribers

People subscribed via source and target branches