[calamares] Apply current coding style
This commit is contained in:
parent
ea0acf1606
commit
f5af4818fb
@ -22,11 +22,11 @@
|
|||||||
#include "CalamaresWindow.h"
|
#include "CalamaresWindow.h"
|
||||||
|
|
||||||
#include "Branding.h"
|
#include "Branding.h"
|
||||||
|
#include "DebugWindow.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "ViewManager.h"
|
#include "ViewManager.h"
|
||||||
#include "progresstree/ProgressTreeView.h"
|
#include "progresstree/ProgressTreeView.h"
|
||||||
#include "utils/CalamaresUtilsGui.h"
|
#include "utils/CalamaresUtilsGui.h"
|
||||||
#include "DebugWindow.h"
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/Retranslator.h"
|
#include "utils/Retranslator.h"
|
||||||
|
|
||||||
|
@ -55,21 +55,29 @@ crash()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Print out the widget tree (names) in indented form.
|
/// @brief Print out the widget tree (names) in indented form.
|
||||||
static void dumpWidgetTree( QDebug& deb, const QWidget* widget, int depth )
|
static void
|
||||||
|
dumpWidgetTree( QDebug& deb, const QWidget* widget, int depth )
|
||||||
{
|
{
|
||||||
if ( !widget )
|
if ( !widget )
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
deb << Logger::Continuation;
|
deb << Logger::Continuation;
|
||||||
for (int i = 0; i < depth; ++i )
|
for ( int i = 0; i < depth; ++i )
|
||||||
|
{
|
||||||
deb << ' ';
|
deb << ' ';
|
||||||
|
}
|
||||||
deb << widget->objectName();
|
deb << widget->objectName();
|
||||||
|
|
||||||
for ( const auto* w : widget->findChildren<QWidget*>( QString(), Qt::FindDirectChildrenOnly ) )
|
for ( const auto* w : widget->findChildren< QWidget* >( QString(), Qt::FindDirectChildrenOnly ) )
|
||||||
dumpWidgetTree( deb, w, depth+1 );
|
{
|
||||||
|
dumpWidgetTree( deb, w, depth + 1 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Calamares {
|
namespace Calamares
|
||||||
|
{
|
||||||
|
|
||||||
DebugWindow::DebugWindow()
|
DebugWindow::DebugWindow()
|
||||||
: QWidget( nullptr )
|
: QWidget( nullptr )
|
||||||
@ -86,9 +94,7 @@ DebugWindow::DebugWindow()
|
|||||||
m_ui->globalStorageView->expandAll();
|
m_ui->globalStorageView->expandAll();
|
||||||
|
|
||||||
// Do above when the GS changes, too
|
// Do above when the GS changes, too
|
||||||
connect( gs, &GlobalStorage::changed,
|
connect( gs, &GlobalStorage::changed, this, [=] {
|
||||||
this, [ = ]
|
|
||||||
{
|
|
||||||
m_globals = JobQueue::instance()->globalStorage()->data();
|
m_globals = JobQueue::instance()->globalStorage()->data();
|
||||||
m_globals_model->reload();
|
m_globals_model->reload();
|
||||||
m_ui->globalStorageView->expandAll();
|
m_ui->globalStorageView->expandAll();
|
||||||
@ -96,11 +102,9 @@ DebugWindow::DebugWindow()
|
|||||||
|
|
||||||
// JobQueue page
|
// JobQueue page
|
||||||
m_ui->jobQueueText->setReadOnly( true );
|
m_ui->jobQueueText->setReadOnly( true );
|
||||||
connect( JobQueue::instance(), &JobQueue::queueChanged,
|
connect( JobQueue::instance(), &JobQueue::queueChanged, this, [this]( const JobList& jobs ) {
|
||||||
this, [ this ]( const JobList& jobs )
|
|
||||||
{
|
|
||||||
QStringList text;
|
QStringList text;
|
||||||
for ( const auto &job : jobs )
|
for ( const auto& job : jobs )
|
||||||
{
|
{
|
||||||
text.append( job->prettyName() );
|
text.append( job->prettyName() );
|
||||||
}
|
}
|
||||||
@ -121,21 +125,17 @@ DebugWindow::DebugWindow()
|
|||||||
m_ui->modulesVerticalLayout->insertWidget( 1, pythonConsoleButton );
|
m_ui->modulesVerticalLayout->insertWidget( 1, pythonConsoleButton );
|
||||||
pythonConsoleButton->hide();
|
pythonConsoleButton->hide();
|
||||||
|
|
||||||
QObject::connect( pythonConsoleButton, &QPushButton::clicked,
|
QObject::connect( pythonConsoleButton, &QPushButton::clicked, this, [this, moduleConfigModel] {
|
||||||
this, [ this, moduleConfigModel ]
|
|
||||||
{
|
|
||||||
QString moduleName = m_ui->modulesListView->currentIndex().data().toString();
|
QString moduleName = m_ui->modulesListView->currentIndex().data().toString();
|
||||||
Module* module = ModuleManager::instance()->moduleInstance( moduleName );
|
Module* module = ModuleManager::instance()->moduleInstance( moduleName );
|
||||||
if ( module->interface() != Module::Interface::PythonQt ||
|
if ( module->interface() != Module::Interface::PythonQt || module->type() != Module::Type::View )
|
||||||
module->type() != Module::Type::View )
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for ( ViewStep* step : ViewManager::instance()->viewSteps() )
|
for ( ViewStep* step : ViewManager::instance()->viewSteps() )
|
||||||
{
|
{
|
||||||
if ( step->moduleInstanceKey() == module->instanceKey() )
|
if ( step->moduleInstanceKey() == module->instanceKey() )
|
||||||
{
|
{
|
||||||
PythonQtViewStep* pqvs =
|
PythonQtViewStep* pqvs = qobject_cast< PythonQtViewStep* >( step );
|
||||||
qobject_cast< PythonQtViewStep* >( step );
|
|
||||||
if ( pqvs )
|
if ( pqvs )
|
||||||
{
|
{
|
||||||
QWidget* consoleWindow = new QWidget;
|
QWidget* consoleWindow = new QWidget;
|
||||||
@ -152,23 +152,17 @@ DebugWindow::DebugWindow()
|
|||||||
|
|
||||||
QLabel* bottomLabel = new QLabel( consoleWindow );
|
QLabel* bottomLabel = new QLabel( consoleWindow );
|
||||||
bottomLayout->addWidget( bottomLabel );
|
bottomLayout->addWidget( bottomLabel );
|
||||||
QString line =
|
QString line = QString( "Module: <font color=\"#008000\"><code>%1</code></font><br/>"
|
||||||
QString( "Module: <font color=\"#008000\"><code>%1</code></font><br/>"
|
"Python class: <font color=\"#008000\"><code>%2</code></font>" )
|
||||||
"Python class: <font color=\"#008000\"><code>%2</code></font>" )
|
.arg( module->instanceKey() )
|
||||||
.arg( module->instanceKey() )
|
.arg( console->property( "classname" ).toString() );
|
||||||
.arg( console->property( "classname" ).toString() );
|
|
||||||
bottomLabel->setText( line );
|
bottomLabel->setText( line );
|
||||||
|
|
||||||
QPushButton* closeButton = new QPushButton( consoleWindow );
|
QPushButton* closeButton = new QPushButton( consoleWindow );
|
||||||
closeButton->setText( "&Close" );
|
closeButton->setText( "&Close" );
|
||||||
QObject::connect( closeButton, &QPushButton::clicked,
|
QObject::connect( closeButton, &QPushButton::clicked, [consoleWindow] { consoleWindow->close(); } );
|
||||||
[ consoleWindow ]
|
|
||||||
{
|
|
||||||
consoleWindow->close();
|
|
||||||
} );
|
|
||||||
bottomLayout->addWidget( closeButton );
|
bottomLayout->addWidget( closeButton );
|
||||||
bottomLabel->setSizePolicy( QSizePolicy::Expanding,
|
bottomLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
|
||||||
QSizePolicy::Preferred );
|
|
||||||
|
|
||||||
consoleWindow->setParent( this );
|
consoleWindow->setParent( this );
|
||||||
consoleWindow->setWindowFlags( Qt::Window );
|
consoleWindow->setWindowFlags( Qt::Window );
|
||||||
@ -183,58 +177,52 @@ DebugWindow::DebugWindow()
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
connect( m_ui->modulesListView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
connect( m_ui->modulesListView->selectionModel(),
|
||||||
this, [ this
|
&QItemSelectionModel::selectionChanged,
|
||||||
|
this,
|
||||||
|
[this
|
||||||
#ifdef WITH_PYTHONQT
|
#ifdef WITH_PYTHONQT
|
||||||
, pythonConsoleButton
|
,
|
||||||
|
pythonConsoleButton
|
||||||
#endif
|
#endif
|
||||||
]
|
] {
|
||||||
{
|
QString moduleName = m_ui->modulesListView->currentIndex().data().toString();
|
||||||
QString moduleName = m_ui->modulesListView->currentIndex().data().toString();
|
Module* module = ModuleManager::instance()->moduleInstance( moduleName );
|
||||||
Module* module = ModuleManager::instance()->moduleInstance( moduleName );
|
if ( module )
|
||||||
if ( module )
|
{
|
||||||
{
|
m_module = module->configurationMap();
|
||||||
m_module = module->configurationMap();
|
m_module_model->reload();
|
||||||
m_module_model->reload();
|
m_ui->moduleConfigView->expandAll();
|
||||||
m_ui->moduleConfigView->expandAll();
|
m_ui->moduleTypeLabel->setText( module->typeString() );
|
||||||
m_ui->moduleTypeLabel->setText( module->typeString() );
|
m_ui->moduleInterfaceLabel->setText( module->interfaceString() );
|
||||||
m_ui->moduleInterfaceLabel->setText( module->interfaceString() );
|
|
||||||
#ifdef WITH_PYTHONQT
|
#ifdef WITH_PYTHONQT
|
||||||
pythonConsoleButton->setVisible(
|
pythonConsoleButton->setVisible( module->interface() == Module::Interface::PythonQt
|
||||||
module->interface() == Module::Interface::PythonQt &&
|
&& module->type() == Module::Type::View );
|
||||||
module->type() == Module::Type::View );
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// Tools page
|
// Tools page
|
||||||
connect( m_ui->crashButton, &QPushButton::clicked, this, [] { ::crash(); } );
|
connect( m_ui->crashButton, &QPushButton::clicked, this, [] { ::crash(); } );
|
||||||
connect( m_ui->reloadStylesheetButton, &QPushButton::clicked,
|
connect( m_ui->reloadStylesheetButton, &QPushButton::clicked, []() {
|
||||||
[]()
|
for ( auto* w : qApp->topLevelWidgets() )
|
||||||
{
|
{
|
||||||
for ( auto* w : qApp->topLevelWidgets() )
|
// Needs to match what's set in CalamaresWindow
|
||||||
{
|
if ( w->objectName() == QStringLiteral( "mainApp" ) )
|
||||||
// Needs to match what's set in CalamaresWindow
|
{
|
||||||
if ( w->objectName() == QStringLiteral( "mainApp" ) )
|
w->setStyleSheet( Calamares::Branding::instance()->stylesheet() );
|
||||||
{
|
}
|
||||||
w->setStyleSheet( Calamares::Branding::instance()->stylesheet() );
|
}
|
||||||
}
|
} );
|
||||||
}
|
connect( m_ui->widgetTreeButton, &QPushButton::clicked, []() {
|
||||||
});
|
for ( auto* w : qApp->topLevelWidgets() )
|
||||||
connect( m_ui->widgetTreeButton, &QPushButton::clicked,
|
{
|
||||||
[]()
|
Logger::CDebug deb;
|
||||||
{
|
dumpWidgetTree( deb, w, 0 );
|
||||||
for ( auto* w : qApp->topLevelWidgets() )
|
}
|
||||||
{
|
} );
|
||||||
Logger::CDebug deb;
|
|
||||||
dumpWidgetTree( deb, w, 0 );
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
CALAMARES_RETRANSLATE(
|
CALAMARES_RETRANSLATE( m_ui->retranslateUi( this ); setWindowTitle( tr( "Debug information" ) ); )
|
||||||
m_ui->retranslateUi( this );
|
|
||||||
setWindowTitle( tr( "Debug information" ) );
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -245,4 +233,4 @@ DebugWindow::closeEvent( QCloseEvent* e )
|
|||||||
emit closed();
|
emit closed();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Calamares
|
} // namespace Calamares
|
||||||
|
@ -27,12 +27,13 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace Calamares {
|
namespace Calamares
|
||||||
|
{
|
||||||
|
|
||||||
// From the .ui file
|
// From the .ui file
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
class DebugWindow;
|
class DebugWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
class DebugWindow : public QWidget
|
class DebugWindow : public QWidget
|
||||||
@ -49,13 +50,13 @@ protected:
|
|||||||
void closeEvent( QCloseEvent* e ) override;
|
void closeEvent( QCloseEvent* e ) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::DebugWindow *m_ui;
|
Ui::DebugWindow* m_ui;
|
||||||
QVariant m_globals;
|
QVariant m_globals;
|
||||||
QVariant m_module;
|
QVariant m_module;
|
||||||
std::unique_ptr< VariantModel> m_globals_model;
|
std::unique_ptr< VariantModel > m_globals_model;
|
||||||
std::unique_ptr< VariantModel> m_module_model;
|
std::unique_ptr< VariantModel > m_module_model;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace Calamares
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user