|
|
|
@ -4,6 +4,7 @@
|
|
|
|
|
# === This file is part of Calamares - <http://github.com/calamares> ===
|
|
|
|
|
#
|
|
|
|
|
# Copyright 2016-2017, Teo Mrnjavac <teo@kde.org>
|
|
|
|
|
# Copyright 2017, Alf Gaida <agaida@siduction.org>
|
|
|
|
|
#
|
|
|
|
|
# Calamares is free software: you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
@ -54,10 +55,13 @@ _ = gettext.gettext
|
|
|
|
|
# exposed as a single QWidget, returned by the widget function.
|
|
|
|
|
#
|
|
|
|
|
# For convenience, both C++ and PythonQt ViewSteps are considered to be
|
|
|
|
|
# implementations of ViewStep.h. Additionally, the Calamares PythonQt API allows
|
|
|
|
|
# Python developers to keep their identifiers more Pythonic on the Python side.
|
|
|
|
|
# Thus, all of the following are considered valid method identifiers in a
|
|
|
|
|
# ViewStep implementation: isNextEnabled, isnextenabled, is_next_enabled.
|
|
|
|
|
# implementations of ViewStep.h. Additionally, the Calamares PythonQt API
|
|
|
|
|
# allows Python developers to keep their identifiers more Pythonic on the
|
|
|
|
|
# Python side. Thus, all of the following are considered valid method
|
|
|
|
|
# identifiers in a ViewStep implementation: isNextEnabled, isnextenabled,
|
|
|
|
|
# is_next_enabled.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@calamares_module
|
|
|
|
|
class DummyPythonQtViewStep:
|
|
|
|
|
def __init__(self):
|
|
|
|
@ -80,10 +84,10 @@ class DummyPythonQtViewStep:
|
|
|
|
|
btn.setText(_("Click me!"))
|
|
|
|
|
self.main_widget.layout().addWidget(btn)
|
|
|
|
|
|
|
|
|
|
# The syntax for signal-slot connections is very simple, though slightly
|
|
|
|
|
# different from the C++ equivalent. There are no SIGNAL and SLOT
|
|
|
|
|
# macros, and a signal can be connected to any Python method (without a
|
|
|
|
|
# special "slot" designation).
|
|
|
|
|
# The syntax for signal-slot connections is very simple, though
|
|
|
|
|
# slightly different from the C++ equivalent. There are no SIGNAL and
|
|
|
|
|
# SLOT macros, and a signal can be connected to any Python method
|
|
|
|
|
# (without a special "slot" designation).
|
|
|
|
|
btn.connect("clicked(bool)", self.on_btn_clicked)
|
|
|
|
|
|
|
|
|
|
def on_btn_clicked(self):
|
|
|
|
@ -93,26 +97,27 @@ class DummyPythonQtViewStep:
|
|
|
|
|
return "Dummy PythonQt ViewStep"
|
|
|
|
|
|
|
|
|
|
def isNextEnabled(self):
|
|
|
|
|
return True # The "Next" button should be clickable
|
|
|
|
|
return True # The "Next" button should be clickable
|
|
|
|
|
|
|
|
|
|
def isBackEnabled(self):
|
|
|
|
|
return True # The "Back" button should be clickable
|
|
|
|
|
return True # The "Back" button should be clickable
|
|
|
|
|
|
|
|
|
|
def isAtBeginning(self):
|
|
|
|
|
# True means the currently shown UI page is the first page of this
|
|
|
|
|
# module, thus a "Back" button click will not be handled by this module,
|
|
|
|
|
# and will cause a skip to the previous ViewStep instead (if any).
|
|
|
|
|
# Fals means that the present ViewStep provides other UI pages placed
|
|
|
|
|
# logically "before" the current one, thus a "Back" button click will
|
|
|
|
|
# be handled by this module instead of skipping to another ViewStep.
|
|
|
|
|
# A module (ViewStep) with only one page will always return True here.
|
|
|
|
|
# module, thus a "Back" button click will not be handled by this
|
|
|
|
|
# module and will cause a skip to the previous ViewStep instead
|
|
|
|
|
# (if any). False means that the present ViewStep provides other UI
|
|
|
|
|
# pages placed logically "before" the current one, thus a "Back" button
|
|
|
|
|
# click will be handled by this module instead of skipping to another
|
|
|
|
|
# ViewStep. A module (ViewStep) with only one page will always return
|
|
|
|
|
# True here.
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def isAtEnd(self):
|
|
|
|
|
# True means the currently shown UI page is the last page of this
|
|
|
|
|
# module, thus a "Next" button click will not be handled by this module,
|
|
|
|
|
# and will cause a skip to the next ViewStep instead (if any).
|
|
|
|
|
# Fals means that the present ViewStep provides other UI pages placed
|
|
|
|
|
# module, thus a "Next" button click will not be handled by this
|
|
|
|
|
# module and will cause a skip to the next ViewStep instead (if any).
|
|
|
|
|
# False means that the present ViewStep provides other UI pages placed
|
|
|
|
|
# logically "after" the current one, thus a "Next" button click will
|
|
|
|
|
# be handled by this module instead of skipping to another ViewStep.
|
|
|
|
|
# A module (ViewStep) with only one page will always return True here.
|
|
|
|
@ -139,9 +144,9 @@ class DummyPythonQtViewStep:
|
|
|
|
|
# user-visible strings must be retranslated (by calling tr() in C++ or
|
|
|
|
|
# _() in Python) and reapplied on the relevant widgets.
|
|
|
|
|
# When the user picks a new UI translation language, Qt raises a QEvent
|
|
|
|
|
# of type LanguageChange, which propagates through the QObject hierarchy.
|
|
|
|
|
# By catching and reacting to this event, we can show user-visible
|
|
|
|
|
# strings in the new language at the right time.
|
|
|
|
|
# of type LanguageChange, which propagates through the QObject
|
|
|
|
|
# hierarchy. By catching and reacting to this event, we can show
|
|
|
|
|
# user-visible strings in the new language at the right time.
|
|
|
|
|
# The C++ side of the Calamares PythonQt API catches the LanguageChange
|
|
|
|
|
# event and calls the present method. It is then up to the module
|
|
|
|
|
# developer to add here all the needed code to load the module's
|
|
|
|
@ -168,6 +173,8 @@ class DummyPythonQtViewStep:
|
|
|
|
|
# same rules apply as for ViewStep. No decorators are necessary here, because
|
|
|
|
|
# only the ViewStep implementation is the unique entry point, and a module can
|
|
|
|
|
# have any number of jobs.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DummyPQJob:
|
|
|
|
|
def __init__(self, my_msg):
|
|
|
|
|
self.my_msg = my_msg
|
|
|
|
|