[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 <QFileInfo>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#ifdef WITH_QML
|
#ifdef WITH_QML
|
||||||
|
#include <QQmlContext>
|
||||||
|
#include <QQmlEngine>
|
||||||
#include <QQuickItem>
|
#include <QQuickItem>
|
||||||
#include <QQuickWidget>
|
#include <QQuickWidget>
|
||||||
#endif
|
#endif
|
||||||
@ -240,7 +242,7 @@ setDimension( QQuickWidget* w, Qt::Orientation o, int desiredWidth )
|
|||||||
|
|
||||||
|
|
||||||
static QWidget*
|
static QWidget*
|
||||||
getQmlSidebar( Calamares::DebugWindowManager*,
|
getQmlSidebar( Calamares::DebugWindowManager* debug,
|
||||||
Calamares::ViewManager*,
|
Calamares::ViewManager*,
|
||||||
QWidget* parent,
|
QWidget* parent,
|
||||||
Qt::Orientation o,
|
Qt::Orientation o,
|
||||||
@ -248,6 +250,11 @@ getQmlSidebar( Calamares::DebugWindowManager*,
|
|||||||
{
|
{
|
||||||
CalamaresUtils::registerQmlModels();
|
CalamaresUtils::registerQmlModels();
|
||||||
QQuickWidget* w = new QQuickWidget( parent );
|
QQuickWidget* w = new QQuickWidget( parent );
|
||||||
|
if ( debug )
|
||||||
|
{
|
||||||
|
w->engine()->rootContext()->setContextProperty( "debug", debug );
|
||||||
|
}
|
||||||
|
|
||||||
w->setSource( QUrl(
|
w->setSource( QUrl(
|
||||||
CalamaresUtils::searchQmlFile( CalamaresUtils::QmlSearch::Both, QStringLiteral( "calamares-sidebar" ) ) ) );
|
CalamaresUtils::searchQmlFile( CalamaresUtils::QmlSearch::Both, QStringLiteral( "calamares-sidebar" ) ) ) );
|
||||||
setDimension( w, o, desiredWidth );
|
setDimension( w, o, desiredWidth );
|
||||||
@ -255,7 +262,7 @@ getQmlSidebar( Calamares::DebugWindowManager*,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static QWidget*
|
static QWidget*
|
||||||
getQmlNavigation( Calamares::DebugWindowManager*,
|
getQmlNavigation( Calamares::DebugWindowManager* debug,
|
||||||
Calamares::ViewManager*,
|
Calamares::ViewManager*,
|
||||||
QWidget* parent,
|
QWidget* parent,
|
||||||
Qt::Orientation o,
|
Qt::Orientation o,
|
||||||
@ -263,6 +270,10 @@ getQmlNavigation( Calamares::DebugWindowManager*,
|
|||||||
{
|
{
|
||||||
CalamaresUtils::registerQmlModels();
|
CalamaresUtils::registerQmlModels();
|
||||||
QQuickWidget* w = new QQuickWidget( parent );
|
QQuickWidget* w = new QQuickWidget( parent );
|
||||||
|
if ( debug )
|
||||||
|
{
|
||||||
|
w->engine()->rootContext()->setContextProperty( "debug", debug );
|
||||||
|
}
|
||||||
w->setSource( QUrl(
|
w->setSource( QUrl(
|
||||||
CalamaresUtils::searchQmlFile( CalamaresUtils::QmlSearch::Both, QStringLiteral( "calamares-navigation" ) ) ) );
|
CalamaresUtils::searchQmlFile( CalamaresUtils::QmlSearch::Both, QStringLiteral( "calamares-navigation" ) ) ) );
|
||||||
setDimension( w, o, desiredWidth );
|
setDimension( w, o, desiredWidth );
|
||||||
|
@ -274,5 +274,11 @@ DebugWindowManager::show( bool visible )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DebugWindowManager::toggle()
|
||||||
|
{
|
||||||
|
show( !m_visible );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Calamares
|
} // namespace Calamares
|
||||||
|
@ -77,6 +77,7 @@ public Q_SLOTS:
|
|||||||
bool enabled() const;
|
bool enabled() const;
|
||||||
bool visible() const { return m_visible; }
|
bool visible() const { return m_visible; }
|
||||||
void show( bool visible );
|
void show( bool visible );
|
||||||
|
void toggle();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void visibleChanged( bool visible );
|
void visibleChanged( bool visible );
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/* Sample of QML progress tree.
|
/* Sample of QML progress tree.
|
||||||
|
|
||||||
SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
|
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
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
|
||||||
@ -59,5 +60,29 @@ Rectangle {
|
|||||||
Item {
|
Item {
|
||||||
Layout.fillHeight: true;
|
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