~ralsina/ubuntuone-control-panel/unique_in_ubuntu

« back to all changes in this revision

Viewing changes to ubuntuone/controlpanel/gui/qt/gui.py

  • Committer: Tarmac
  • Author(s): Natalia B. Bidart, Manuel de la Pena
  • Date: 2012-04-05 18:07:56 UTC
  • mfrom: (307.1.6 autoupdate)
  • Revision ID: tarmac-20120405180756-bwh9460pl303hfwi
- Check for updates when the main window is shown. On linux, this is a no
operation. On windows, this will check for new versions of the software and
will prompt the user for confirmation to install updates (LP: #971455).

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
from PyQt4 import QtGui, QtCore
20
20
 
 
21
from twisted.internet import defer
 
22
 
 
23
from ubuntuone.controlpanel import utils
 
24
from ubuntuone.controlpanel.logger import setup_logging
 
25
from ubuntuone.controlpanel.gui import UPDATE_TITLE, UPDATE_SOFTWARE
21
26
from ubuntuone.controlpanel.gui.qt.systray import TrayIcon
22
27
from ubuntuone.controlpanel.gui.qt.ui import mainwindow_ui
23
 
from ubuntuone.controlpanel.utils import add_to_autostart
24
28
 
25
29
# pylint: disable=E0611
26
30
try:
30
34
    USE_LIBUNITY = False
31
35
# pylint: enable=E0611
32
36
 
 
37
logger = setup_logging('qt.gui')
 
38
 
33
39
U1_DOTDESKTOP = "ubuntuone-installer.desktop"
34
40
 
35
41
 
49
55
        self.installer = installer
50
56
        if installer:
51
57
            self.ui.control_panel.start_from_license()
52
 
        add_to_autostart()
 
58
        utils.add_to_autostart()
53
59
        if USE_LIBUNITY:
54
60
            self.entry = Unity.LauncherEntry.get_for_desktop_id(U1_DOTDESKTOP)
55
61
        else:
87
93
 
88
94
    # pylint: enable=C0103
89
95
 
 
96
    @defer.inlineCallbacks
 
97
    def check_updates(self):
 
98
        """Offer the user to update if there are updates available."""
 
99
        logger.debug('Checking for updates.')
 
100
        are_present = yield utils.are_updates_present()
 
101
        logger.info('Updates available? %r', are_present)
 
102
        if are_present:
 
103
            buttons = QtGui.QMessageBox.Yes | QtGui.QMessageBox.No
 
104
            result = QtGui.QMessageBox.question(self, UPDATE_TITLE,
 
105
                                                UPDATE_SOFTWARE,
 
106
                                                buttons, QtGui.QMessageBox.Yes)
 
107
            if result == QtGui.QMessageBox.Yes:
 
108
                logger.info('Performing auto-update.')
 
109
                utils.perform_update()
 
110
            else:
 
111
                logger.info('User do not want to update.')
 
112
 
90
113
 
91
114
def start(close_callback, minimized=False, with_icon=False, installer=False):
92
115
    """Show the UI elements."""
102
125
                    QtCore.Qt.LeftToRight, QtCore.Qt.AlignCenter,
103
126
                    window.size(), app.desktop().availableGeometry())
104
127
        window.setGeometry(style)
 
128
        window.check_updates()
105
129
        window.show()
106
130
    else:
107
131
        window = None