17
14
# You should have received a copy of the GNU General Public License along
18
15
# with this program. If not, see <http://www.gnu.org/licenses/>.
19
"""Reactor installation for windows."""
21
# pylint: disable=E1101, F0401, W0404
17
"""Main method to be used on windows."""
25
19
from PyQt4 import QtGui, QtCore
26
from twisted.internet import defer
28
# Module used to include the resources into this file
29
# pylint: disable=W0611
30
from ubuntuone_installer.gui.qt.ui import images_rc
31
# pylint: enable=W0611
35
"""End the process."""
36
from twisted.internet import reactor
40
def error_cb(exc, logger):
41
"""Handle credentials errors."""
43
'Error while getting the credentials: %r', exc)
47
@defer.inlineCallbacks
48
def success_cb(creds, gui, installing, logger, start_control_panel,
50
"""Handle credentials success."""
51
logger.debug('Got back from sso.')
52
if creds: # Have credentials already
53
logger.debug('Already got credentials.')
54
logger.info('Starting control panel.')
55
start_control_panel(with_icon=False)
56
logger.info('Checking updates.')
57
yield check_updates(gui, logger)
58
logger.info('Stopping.')
60
else: # No credentials
61
logger.debug('Did got connections.')
62
window = gui.MainWindow(close_callback=stop, installing=installing)
63
# Set Application Style Sheet
64
app = QtGui.QApplication.instance()
65
qss = QtCore.QResource(":/ubuntuone.qss")
66
app.setStyleSheet(QtCore.QString(qss.data()))
67
# Apply font to the entire application
68
QtGui.QFontDatabase.addApplicationFont(':/Ubuntu-R.ttf')
69
QtGui.QFontDatabase.addApplicationFont(':/Ubuntu-B.ttf')
70
# Set Application Icon
71
app.setWindowIcon(QtGui.QIcon(":/ubuntu_one_favicon.png"))
75
def main(installing=False):
76
"""Perform a client request to be logged in."""
77
# pylint: disable=W0612
78
app = QtGui.QApplication(sys.argv)
79
# pylint: enable=W0612
80
import qtreactor.qt4reactor
81
qtreactor.qt4reactor.install()
82
from ubuntuone_installer.gui.qt import gui
83
from twisted.internet import reactor
84
# All this has to be imported here because it installs a reactor
85
from ubuntuone_installer.logger import setup_logging
86
from ubuntuone_installer.gui.qt.utils import check_credentials
88
logger = setup_logging('qt.gui')
89
check_credentials(gui, logger, success_cb,
23
"""Apply style sheet and fonts."""
24
# Apply font to the entire application
25
QtGui.QFontDatabase.addApplicationFont(':/Ubuntu-R.ttf')
26
QtGui.QFontDatabase.addApplicationFont(':/Ubuntu-B.ttf')
28
# Set Application Icon
29
app.setWindowIcon(QtGui.QIcon(":/ubuntu_one_favicon.png"))
31
# Apply Style Sheet -- The windows version may be different
32
qss = QtCore.QResource(":/ubuntuone.qss")
33
app.setStyleSheet(qss.data())