Merge lp:~nataliabidart/ubuntuone-control-panel/center-me into lp:ubuntuone-control-panel

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 262
Merged at revision: 261
Proposed branch: lp:~nataliabidart/ubuntuone-control-panel/center-me
Merge into: lp:ubuntuone-control-panel
Diff against target: 80 lines (+27/-6)
2 files modified
ubuntuone/controlpanel/gui/qt/gui.py (+7/-5)
ubuntuone/controlpanel/gui/qt/tests/test_start.py (+20/-1)
To merge this branch: bzr merge lp:~nataliabidart/ubuntuone-control-panel/center-me
Reviewer Review Type Date Requested Status
Diego Sarmentero (community) Approve
Roberto Alsina (community) Approve
Review via email: mp+93582@code.launchpad.net

Commit message

- Center the main window when openning it (LP: #934173).

To post a comment you must log in.
Revision history for this message
Roberto Alsina (ralsina) wrote :

+1 code review + IRL test

review: Approve
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ubuntuone/controlpanel/gui/qt/gui.py'
--- ubuntuone/controlpanel/gui/qt/gui.py 2012-02-07 13:54:46 +0000
+++ ubuntuone/controlpanel/gui/qt/gui.py 2012-02-17 14:47:20 +0000
@@ -1,8 +1,6 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
2
3# Authors: Alejandro J. Cura <alecu@canonical.com>
4#2#
5# Copyright 2011 Canonical Ltd.3# Copyright 2011-2012 Canonical Ltd.
6#4#
7# This program is free software: you can redistribute it and/or modify it5# This program is free software: you can redistribute it and/or modify it
8# under the terms of the GNU General Public License version 3, as published6# under the terms of the GNU General Public License version 3, as published
@@ -18,8 +16,7 @@
1816
19"""The user interface for the control panel for Ubuntu One."""17"""The user interface for the control panel for Ubuntu One."""
2018
2119from PyQt4 import QtGui, QtCore
22from PyQt4 import QtGui
2320
24from ubuntuone.controlpanel.gui.qt.systray import TrayIcon21from ubuntuone.controlpanel.gui.qt.systray import TrayIcon
25from ubuntuone.controlpanel.gui.qt.ui import mainwindow_ui22from ubuntuone.controlpanel.gui.qt.ui import mainwindow_ui
@@ -60,6 +57,11 @@
60 window = MainWindow()57 window = MainWindow()
61 else:58 else:
62 window = MainWindow(close_callback=close_callback)59 window = MainWindow(close_callback=close_callback)
60 app = QtGui.QApplication.instance()
61 style = QtGui.QStyle.alignedRect(
62 QtCore.Qt.LeftToRight, QtCore.Qt.AlignCenter,
63 window.size(), app.desktop().availableGeometry())
64 window.setGeometry(style)
63 window.show()65 window.show()
64 else:66 else:
65 window = None67 window = None
6668
=== modified file 'ubuntuone/controlpanel/gui/qt/tests/test_start.py'
--- ubuntuone/controlpanel/gui/qt/tests/test_start.py 2012-02-07 13:54:46 +0000
+++ ubuntuone/controlpanel/gui/qt/tests/test_start.py 2012-02-17 14:47:20 +0000
@@ -28,9 +28,12 @@
2828
29 """A fake thing."""29 """A fake thing."""
3030
31 shown = False
32 size = lambda *a: gui.QtCore.QSize(123456, 654321)
33 style = None
34
31 def __init__(self):35 def __init__(self):
32 self.args = []36 self.args = []
33 self.shown = False
3437
35 def __call__(self, *args, **kwargs):38 def __call__(self, *args, **kwargs):
36 self.args.append((args, kwargs))39 self.args.append((args, kwargs))
@@ -40,6 +43,13 @@
40 """Show."""43 """Show."""
41 self.shown = True44 self.shown = True
4245
46 # Invalid name "setGeometry"
47 # pylint: disable=C0103
48
49 def setGeometry(self, style):
50 """Save the new geometry."""
51 self.style = style
52
4353
44class StartTestCase(TestCase):54class StartTestCase(TestCase):
45 """Test the qt control panel."""55 """Test the qt control panel."""
@@ -87,3 +97,12 @@
87 kwargs = {'close_callback': self.close_cb, 'window': None}97 kwargs = {'close_callback': self.close_cb, 'window': None}
88 self.assertEqual(self.tray_icon.args, [((), kwargs)])98 self.assertEqual(self.tray_icon.args, [((), kwargs)])
89 self.assertEqual(self.main_window.args, [])99 self.assertEqual(self.main_window.args, [])
100
101 def test_center_window(self):
102 """The main window should be centered."""
103 gui.start(close_callback=self.close_cb)
104 app = gui.QtGui.QApplication.instance()
105 expected = gui.QtGui.QStyle.alignedRect(gui.QtCore.Qt.LeftToRight,
106 gui.QtCore.Qt.AlignCenter, self.main_window.size(),
107 app.desktop().availableGeometry())
108 self.assertEqual(self.main_window.style, expected)

Subscribers

People subscribed via source and target branches