Add support for attaching a Python console in DebugWindow.
Also add support for showing module type/interface. Also minor layout improvements.
This commit is contained in:
parent
c618999418
commit
53f687587b
@ -26,6 +26,12 @@
|
|||||||
#include "modulesystem/ModuleManager.h"
|
#include "modulesystem/ModuleManager.h"
|
||||||
#include "modulesystem/Module.h"
|
#include "modulesystem/Module.h"
|
||||||
|
|
||||||
|
#ifdef WITH_PYTHONQT
|
||||||
|
#include <gui/PythonQtScriptingConsole.h>
|
||||||
|
#include "ViewManager.h"
|
||||||
|
#include "viewpages/PythonQtViewStep.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QSplitter>
|
#include <QSplitter>
|
||||||
#include <QStringListModel>
|
#include <QStringListModel>
|
||||||
@ -68,11 +74,6 @@ DebugWindow::DebugWindow()
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
// Modules page
|
// Modules page
|
||||||
QSplitter* splitter = new QSplitter( modulesTab );
|
|
||||||
modulesTab->layout()->addWidget( splitter );
|
|
||||||
splitter->addWidget( modulesListView );
|
|
||||||
splitter->addWidget( moduleConfigView );
|
|
||||||
|
|
||||||
QStringListModel* modulesModel = new QStringListModel( ModuleManager::instance()->loadedInstanceKeys() );
|
QStringListModel* modulesModel = new QStringListModel( ModuleManager::instance()->loadedInstanceKeys() );
|
||||||
modulesListView->setModel( modulesModel );
|
modulesListView->setModel( modulesModel );
|
||||||
modulesListView->setSelectionMode( QAbstractItemView::SingleSelection );
|
modulesListView->setSelectionMode( QAbstractItemView::SingleSelection );
|
||||||
@ -80,8 +81,76 @@ DebugWindow::DebugWindow()
|
|||||||
QJsonModel* moduleConfigModel = new QJsonModel( this );
|
QJsonModel* moduleConfigModel = new QJsonModel( this );
|
||||||
moduleConfigView->setModel( moduleConfigModel );
|
moduleConfigView->setModel( moduleConfigModel );
|
||||||
|
|
||||||
|
#ifdef WITH_PYTHONQT
|
||||||
|
QPushButton* pythonConsoleButton = new QPushButton;
|
||||||
|
pythonConsoleButton->setText( "Attach Python console" );
|
||||||
|
modulesVerticalLayout->insertWidget( 1, pythonConsoleButton );
|
||||||
|
pythonConsoleButton->hide();
|
||||||
|
|
||||||
|
QObject::connect( pythonConsoleButton, &QPushButton::clicked,
|
||||||
|
this, [ this, moduleConfigModel ]
|
||||||
|
{
|
||||||
|
QString moduleName = modulesListView->currentIndex().data().toString();
|
||||||
|
Module* module = ModuleManager::instance()->moduleInstance( moduleName );
|
||||||
|
if ( module->interface() != Module::PythonQtInterface ||
|
||||||
|
module->type() != Module::View )
|
||||||
|
return;
|
||||||
|
|
||||||
|
for ( ViewStep* step : ViewManager::instance()->viewSteps() )
|
||||||
|
{
|
||||||
|
if ( step->moduleInstanceKey() == module->instanceKey() )
|
||||||
|
{
|
||||||
|
PythonQtViewStep* pqvs =
|
||||||
|
qobject_cast< PythonQtViewStep* >( step );
|
||||||
|
if ( pqvs )
|
||||||
|
{
|
||||||
|
QWidget* consoleWindow = new QWidget;
|
||||||
|
|
||||||
|
QWidget* console = pqvs->createScriptingConsole();
|
||||||
|
console->setParent( consoleWindow );
|
||||||
|
|
||||||
|
QVBoxLayout* layout = new QVBoxLayout;
|
||||||
|
consoleWindow->setLayout( layout );
|
||||||
|
layout->addWidget( console );
|
||||||
|
|
||||||
|
QHBoxLayout* bottomLayout = new QHBoxLayout;
|
||||||
|
layout->addLayout( bottomLayout );
|
||||||
|
|
||||||
|
QLabel* bottomLabel = new QLabel( consoleWindow );
|
||||||
|
bottomLayout->addWidget( bottomLabel );
|
||||||
|
QString line =
|
||||||
|
QString( "Module: <font color=\"#008000\"><code>%1</code></font><br/>"
|
||||||
|
"Python class: <font color=\"#008000\"><code>%2</code></font>" )
|
||||||
|
.arg( module->instanceKey() )
|
||||||
|
.arg( console->property( "classname" ).toString() );
|
||||||
|
bottomLabel->setText( line );
|
||||||
|
|
||||||
|
QPushButton* closeButton = new QPushButton( consoleWindow );
|
||||||
|
closeButton->setText( "&Close" );
|
||||||
|
QObject::connect( closeButton, &QPushButton::clicked,
|
||||||
|
[ consoleWindow ]
|
||||||
|
{
|
||||||
|
consoleWindow->close();
|
||||||
|
} );
|
||||||
|
bottomLayout->addWidget( closeButton );
|
||||||
|
bottomLabel->setSizePolicy( QSizePolicy::Expanding,
|
||||||
|
QSizePolicy::Preferred );
|
||||||
|
|
||||||
|
consoleWindow->setParent( this );
|
||||||
|
consoleWindow->setWindowFlags( Qt::Window );
|
||||||
|
consoleWindow->setWindowTitle( "Calamares Python console" );
|
||||||
|
consoleWindow->setAttribute( Qt::WA_DeleteOnClose, true );
|
||||||
|
consoleWindow->showNormal();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
connect( modulesListView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
connect( modulesListView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
||||||
this, [ this, moduleConfigModel ]
|
this, [ this, moduleConfigModel, pythonConsoleButton ]
|
||||||
{
|
{
|
||||||
QString moduleName = modulesListView->currentIndex().data().toString();
|
QString moduleName = modulesListView->currentIndex().data().toString();
|
||||||
Module* module = ModuleManager::instance()->moduleInstance( moduleName );
|
Module* module = ModuleManager::instance()->moduleInstance( moduleName );
|
||||||
@ -89,6 +158,13 @@ DebugWindow::DebugWindow()
|
|||||||
{
|
{
|
||||||
moduleConfigModel->loadJson( QJsonDocument::fromVariant( module->configurationMap() ).toJson() );
|
moduleConfigModel->loadJson( QJsonDocument::fromVariant( module->configurationMap() ).toJson() );
|
||||||
moduleConfigView->expandAll();
|
moduleConfigView->expandAll();
|
||||||
|
moduleTypeLabel->setText( module->typeString() );
|
||||||
|
moduleInterfaceLabel->setText( module->interfaceString() );
|
||||||
|
#ifdef WITH_PYTHONQT
|
||||||
|
pythonConsoleButton->setVisible(
|
||||||
|
module->interface() == Module::PythonQtInterface &&
|
||||||
|
module->type() == Module::View );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>632</width>
|
<width>962</width>
|
||||||
<height>497</height>
|
<height>651</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -17,7 +17,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="globalStorageTab">
|
<widget class="QWidget" name="globalStorageTab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@ -48,7 +48,43 @@
|
|||||||
<widget class="QListView" name="modulesListView"/>
|
<widget class="QListView" name="modulesListView"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTreeView" name="moduleConfigView"/>
|
<layout class="QVBoxLayout" name="modulesVerticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Type:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLabel" name="moduleTypeLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>none</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Interface:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLabel" name="moduleInterfaceLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>none</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QTreeView" name="moduleConfigView"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
Loading…
Reference in New Issue
Block a user