1
# -*- coding: utf-8 -*-
3
# Copyright 2012 Canonical Ltd.
5
# This program is free software: you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License version 3, as published
7
# by the Free Software Foundation.
9
# This program is distributed in the hope that it will be useful, but
10
# WITHOUT ANY WARRANTY; without even the implied warranties of
11
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12
# PURPOSE. See the GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License along
15
# with this program. If not, see <http://www.gnu.org/licenses/>.
17
# In addition, as a special exception, the copyright holders give
18
# permission to link the code of portions of this program with the
19
# OpenSSL library under certain conditions as described in each
20
# individual source file, and distribute linked combinations
22
# You must obey the GNU General Public License in all respects
23
# for all of the code used other than OpenSSL. If you modify
24
# file(s) with this exception, you may extend this exception to your
25
# version of the file(s), but you are not obligated to do so. If you
26
# do not wish to do so, delete this exception statement from your
27
# version. If you delete this exception statement from all source
28
# files in the program, then also delete it here.
29
"""Main module to open the QT UI."""
33
from PyQt4 import QtGui, QtCore
35
# Module used to include the resources into this file
36
# Unused import resources_rc, pylint: disable=W0611
37
from ubuntu_sso.qt.ui import resources_rc
38
# pylint: enable=W0611
39
from ubuntu_sso.qt.ubuntu_sso_wizard import UbuntuSSOClientGUI
40
from ubuntu_sso.utils import PLATFORM_QSS
43
# Invalid name "source", pylint: disable=C0103
44
if sys.platform == 'win32':
45
from ubuntu_sso.qt.main import windows
48
from ubuntu_sso.qt.main import linux
50
# pylint: enable=C0103
54
"""Start the QT mainloop and open the main window."""
55
app = QtGui.QApplication(sys.argv)
60
for qss_name in (PLATFORM_QSS, ":/stylesheet.qss"):
61
qss = QtCore.QResource(qss_name)
62
data.append(unicode(qss.data()))
63
app.setStyleSheet('\n'.join(data))
65
# Fix the string that contains unicode chars.
68
if isinstance(value, str):
69
kwargs[key] = value.decode('utf-8')
71
# Unused variable 'ui', pylint: disable=W0612
72
close_callback = lambda: source.main_quit(app)
73
ui = UbuntuSSOClientGUI(close_callback=close_callback, **kwargs)
74
style = QtGui.QStyle.alignedRect(
75
QtCore.Qt.LeftToRight, QtCore.Qt.AlignCenter,
76
ui.size(), app.desktop().availableGeometry())
80
source.main_start(app)