[calamares] Make debug-window available to QML
- Add a toggle() to the debug-window manager, for convenience - Make the manager available to QML - Use the debug-window manager (code imported from KaOS)
This commit is contained in:
parent
c00a382aea
commit
0b8ef49e7e
@ -32,6 +32,8 @@
|
||||
#include <QFileInfo>
|
||||
#include <QLabel>
|
||||
#ifdef WITH_QML
|
||||
#include <QQmlContext>
|
||||
#include <QQmlEngine>
|
||||
#include <QQuickItem>
|
||||
#include <QQuickWidget>
|
||||
#endif
|
||||
@ -240,7 +242,7 @@ setDimension( QQuickWidget* w, Qt::Orientation o, int desiredWidth )
|
||||
|
||||
|
||||
static QWidget*
|
||||
getQmlSidebar( Calamares::DebugWindowManager*,
|
||||
getQmlSidebar( Calamares::DebugWindowManager* debug,
|
||||
Calamares::ViewManager*,
|
||||
QWidget* parent,
|
||||
Qt::Orientation o,
|
||||
@ -248,6 +250,11 @@ getQmlSidebar( Calamares::DebugWindowManager*,
|
||||
{
|
||||
CalamaresUtils::registerQmlModels();
|
||||
QQuickWidget* w = new QQuickWidget( parent );
|
||||
if ( debug )
|
||||
{
|
||||
w->engine()->rootContext()->setContextProperty( "debug", debug );
|
||||
}
|
||||
|
||||
w->setSource( QUrl(
|
||||
CalamaresUtils::searchQmlFile( CalamaresUtils::QmlSearch::Both, QStringLiteral( "calamares-sidebar" ) ) ) );
|
||||
setDimension( w, o, desiredWidth );
|
||||
@ -255,7 +262,7 @@ getQmlSidebar( Calamares::DebugWindowManager*,
|
||||
}
|
||||
|
||||
static QWidget*
|
||||
getQmlNavigation( Calamares::DebugWindowManager*,
|
||||
getQmlNavigation( Calamares::DebugWindowManager* debug,
|
||||
Calamares::ViewManager*,
|
||||
QWidget* parent,
|
||||
Qt::Orientation o,
|
||||
@ -263,6 +270,10 @@ getQmlNavigation( Calamares::DebugWindowManager*,
|
||||
{
|
||||
CalamaresUtils::registerQmlModels();
|
||||
QQuickWidget* w = new QQuickWidget( parent );
|
||||
if ( debug )
|
||||
{
|
||||
w->engine()->rootContext()->setContextProperty( "debug", debug );
|
||||
}
|
||||
w->setSource( QUrl(
|
||||
CalamaresUtils::searchQmlFile( CalamaresUtils::QmlSearch::Both, QStringLiteral( "calamares-navigation" ) ) ) );
|
||||
setDimension( w, o, desiredWidth );
|
||||
|
@ -274,5 +274,11 @@ DebugWindowManager::show( bool visible )
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DebugWindowManager::toggle()
|
||||
{
|
||||
show( !m_visible );
|
||||
}
|
||||
|
||||
|
||||
} // namespace Calamares
|
||||
|
@ -77,6 +77,7 @@ public Q_SLOTS:
|
||||
bool enabled() const;
|
||||
bool visible() const { return m_visible; }
|
||||
void show( bool visible );
|
||||
void toggle();
|
||||
|
||||
signals:
|
||||
void visibleChanged( bool visible );
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* Sample of QML progress tree.
|
||||
|
||||
SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
|
||||
SPDX-FileCopyrightText: 2021 Anke Boersma <demm@kaosx.us>
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
|
||||
@ -59,5 +60,29 @@ Rectangle {
|
||||
Item {
|
||||
Layout.fillHeight: true;
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
Layout.fillWidth: true;
|
||||
height: 35
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
|
||||
color: Branding.styleString( mouseArea.containsMouse ? Branding.SidebarTextHighlight : Branding.SidebarBackground);
|
||||
visible: debug.enabled
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
anchors.fill: parent;
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
hoverEnabled: true
|
||||
Text {
|
||||
anchors.verticalCenter: parent.verticalCenter;
|
||||
x: parent.x + 4;
|
||||
text: qsTr("Show debug information")
|
||||
color: Branding.styleString( mouseArea.containsMouse ? Branding.SidebarTextSelect : Branding.SidebarBackground );
|
||||
font.pointSize : 9
|
||||
}
|
||||
|
||||
onClicked: debug.toggle()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user