Fix _calamares_module_basewidget check and improve readability.
This commit is contained in:
parent
0f0a6ab18d
commit
25613d1bef
@ -26,6 +26,7 @@
|
|||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
|
||||||
namespace Calamares
|
namespace Calamares
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -35,18 +36,22 @@ PythonQtViewStep::PythonQtViewStep( PythonQtObjectPtr cxt,
|
|||||||
, m_widget( new QWidget() )
|
, m_widget( new QWidget() )
|
||||||
, m_cxt( cxt )
|
, m_cxt( cxt )
|
||||||
{
|
{
|
||||||
|
PythonQt* pq = PythonQt::self();
|
||||||
|
Q_ASSERT( pq );
|
||||||
|
|
||||||
// The @calamares_module decorator should have filled _calamares_module_typename
|
// The @calamares_module decorator should have filled _calamares_module_typename
|
||||||
// for us.
|
// for us.
|
||||||
QString className = m_cxt.getVariable( "_calamares_module_typename" ).toString();
|
QString className = m_cxt.getVariable( "_calamares_module_typename" ).toString();
|
||||||
|
|
||||||
// Instantiate an object of the class marked with @calamares_module and
|
// Instantiate an object of the class marked with @calamares_module and
|
||||||
// store it as _calamares_module.
|
// store it as _calamares_module.
|
||||||
PythonQt::self()->evalScript( m_cxt, QString( "_calamares_module = %1()" )
|
pq->evalScript( m_cxt, QString( "_calamares_module = %1()" )
|
||||||
.arg( className ) );
|
.arg( className ) );
|
||||||
m_obj = PythonQt::self()->lookupObject( m_cxt, "_calamares_module" );
|
m_obj = pq->lookupObject( m_cxt, "_calamares_module" );
|
||||||
|
|
||||||
Q_ASSERT( !m_obj.isNull() ); // no entry point, no party
|
Q_ASSERT( !m_obj.isNull() ); // no entry point, no party
|
||||||
|
|
||||||
|
// Prepare the base widget for the module's pages
|
||||||
m_widget->setLayout( new QVBoxLayout );
|
m_widget->setLayout( new QVBoxLayout );
|
||||||
CalamaresUtils::unmarginLayout( m_widget->layout() );
|
CalamaresUtils::unmarginLayout( m_widget->layout() );
|
||||||
m_cxt.addObject( "_calamares_module_basewidget", m_widget );
|
m_cxt.addObject( "_calamares_module_basewidget", m_widget );
|
||||||
@ -70,7 +75,7 @@ PythonQtViewStep::widget()
|
|||||||
"This should never happen.";
|
"This should never happen.";
|
||||||
|
|
||||||
bool nothingChanged = m_cxt.evalScript(
|
bool nothingChanged = m_cxt.evalScript(
|
||||||
"_calamares_module_basewidget.contains(_calamares_module.widget())" ).toBool();
|
"_calamares_module.widget() in _calamares_module_basewidget.children()" ).toBool();
|
||||||
if ( nothingChanged )
|
if ( nothingChanged )
|
||||||
return m_widget;
|
return m_widget;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user