mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-23 10:25:45 -05:00
[libcalamaresui] Debug-tool to dump widget tree
- Adds another tool to the debug window, which dumps (to the debug log) a tree-like view of all the widgets in the application. This can be used when writing stylesheets.
This commit is contained in:
parent
b5625fc14d
commit
877cb0e999
2 changed files with 31 additions and 0 deletions
|
@ -23,6 +23,7 @@
|
|||
#include "Branding.h"
|
||||
#include "utils/Retranslator.h"
|
||||
#include "utils/qjsonmodel.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
#include "JobQueue.h"
|
||||
#include "Job.h"
|
||||
|
@ -51,6 +52,20 @@ crash()
|
|||
*a = 1;
|
||||
}
|
||||
|
||||
/// @brief Print out the widget tree (names) in indented form.
|
||||
static void dumpWidgetTree( QDebug& deb, const QWidget* widget, int depth )
|
||||
{
|
||||
if ( !widget )
|
||||
return;
|
||||
|
||||
deb << Logger::Continuation;
|
||||
for (int i = 0; i < depth; ++i )
|
||||
deb << ' ';
|
||||
deb << widget->objectName();
|
||||
|
||||
for ( const auto* w : widget->findChildren<QWidget*>( QString(), Qt::FindDirectChildrenOnly ) )
|
||||
dumpWidgetTree( deb, w, depth+1 );
|
||||
}
|
||||
|
||||
namespace Calamares {
|
||||
|
||||
|
@ -202,6 +217,15 @@ DebugWindow::DebugWindow()
|
|||
}
|
||||
}
|
||||
});
|
||||
connect( m_ui->widgetTreeButton, &QPushButton::clicked,
|
||||
[]()
|
||||
{
|
||||
for ( auto* w : qApp->topLevelWidgets() )
|
||||
{
|
||||
auto deb = cDebug();
|
||||
dumpWidgetTree( deb, w, 0 );
|
||||
}
|
||||
});
|
||||
|
||||
CALAMARES_RETRANSLATE(
|
||||
m_ui->retranslateUi( this );
|
||||
|
|
|
@ -107,6 +107,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="widgetTreeButton">
|
||||
<property name="text">
|
||||
<string>Widget Tree</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
|
|
Loading…
Add table
Reference in a new issue