400
400
from PyQt4 import uic
401
from PyQt4.QtCore import Qt
402
from PyQt4.QtGui import QWidget, QPixmap, QLabel, QVBoxLayout
403
from PyQt4.QtGui import QSizePolicy, QLayout
401
from PyQt4.QtGui import QWidget, QPixmap, QIcon
404
402
self.page = uic.loadUi('/usr/share/ubiquity/qt/stepLanguage.ui')
405
403
self.combobox = self.page.language_combobox
406
404
self.combobox.currentIndexChanged[str].connect(
410
408
self.page.oem_id_entry.hide()
412
410
def init_big_button(button, image_name):
414
Hackishly turns an empty button into a big button, with a large
417
I tried to set the padding throught style.qss, but it also
418
applies padding between the image and the text, which looks
419
ugly. This hackish code creates two QLabel inside the button
420
and lay them out vertically. This makes it possible to define
421
proper padding with setContentsMargins().
423
It returns the text label so that its text can be updated when
426
pix = QPixmap("/usr/share/ubiquity/qt/images/" + image_name)
428
img_label.setPixmap(pix)
429
img_label.setAlignment(Qt.AlignCenter)
430
img_label.setMinimumSize(pix.size())
432
text_label = QLabel()
433
text_label.setAlignment(Qt.AlignCenter)
435
layout = QVBoxLayout(button)
436
layout.addWidget(img_label)
437
layout.addWidget(text_label)
438
layout.setContentsMargins(24, 24, 24, 24)
439
layout.setSizeConstraint(QLayout.SetMinimumSize)
411
pix = QPixmap('/usr/share/ubiquity/qt/images/' + image_name)
414
button.setIconSize(pix.size())
444
self.page.try_ubuntu_button.setEnabled(False)
417
self.page.try_ubuntu.setEnabled(False)
445
418
self.controller.go_forward()
447
self.page.install_ubuntu_button.clicked.connect(inst)
448
self.page.try_ubuntu_button.clicked.connect(
449
self.on_try_ubuntu_clicked)
451
self.try_ubuntu_label = init_big_button(
452
self.page.try_ubuntu_button, "try.png")
453
self.install_ubuntu_label = init_big_button(
454
self.page.install_ubuntu_button, "install.png")
456
self.try_ubuntu_label.setObjectName("try_ubuntu")
457
self.install_ubuntu_label.setObjectName("install_ubuntu")
419
self.page.install_ubuntu.clicked.connect(inst)
420
self.page.try_ubuntu.clicked.connect(self.on_try_ubuntu_clicked)
421
init_big_button(self.page.install_ubuntu, 'install.png')
422
init_big_button(self.page.try_ubuntu, 'try.png')
459
424
self.release_notes_url = ''
460
425
self.update_installer = True
478
443
self.page.release_notes_label.hide()
480
445
if not 'UBIQUITY_GREETER' in os.environ:
481
self.page.try_ubuntu_button.hide()
446
self.page.try_ubuntu.hide()
482
447
self.page.try_install_text_label.hide()
483
self.page.install_ubuntu_button.hide()
448
self.page.install_ubuntu.hide()
486
451
self.page.alpha_warning_label.hide()
559
524
self.combobox.setCurrentIndex(index)
561
526
if not self.only and 'UBIQUITY_GREETER' in os.environ:
562
self.page.try_ubuntu_button.setEnabled(True)
563
self.page.install_ubuntu_button.setEnabled(True)
527
self.page.try_ubuntu.setEnabled(True)
528
self.page.install_ubuntu.setEnabled(True)
565
530
def get_language(self):
566
531
lang = self.selected_language()
585
550
install_medium = misc.get_install_medium()
586
551
install_medium = i18n.get_string(install_medium, lang)
587
552
for widget in (self.page.try_install_text_label,
588
self.try_ubuntu_label,
589
self.install_ubuntu_label,
553
self.page.try_ubuntu,
554
self.page.install_ubuntu,
590
555
self.page.alpha_warning_label):
591
556
text = widget.text()
592
557
text = text.replace('${RELEASE}', release.name)