[calamares] Decouple debug-window button
- Provide slots and signals for managing the debug-window, so it can be used from QML as well.
This commit is contained in:
parent
473576991d
commit
ab7f6abf02
@ -103,24 +103,8 @@ CalamaresWindow::getWidgetSidebar( QWidget* parent, int desiredWidth )
|
|||||||
sideLayout->addWidget( debugWindowBtn );
|
sideLayout->addWidget( debugWindowBtn );
|
||||||
debugWindowBtn->setFlat( true );
|
debugWindowBtn->setFlat( true );
|
||||||
debugWindowBtn->setCheckable( true );
|
debugWindowBtn->setCheckable( true );
|
||||||
connect( debugWindowBtn, &QPushButton::clicked, this, [=]( bool checked ) {
|
connect( debugWindowBtn, &QPushButton::clicked, this, &CalamaresWindow::showDebugWindow );
|
||||||
if ( checked )
|
connect( this, &CalamaresWindow::debugWindowShown, debugWindowBtn, &QPushButton::setChecked );
|
||||||
{
|
|
||||||
m_debugWindow = new Calamares::DebugWindow();
|
|
||||||
m_debugWindow->show();
|
|
||||||
connect( m_debugWindow.data(), &Calamares::DebugWindow::closed, this, [=]() {
|
|
||||||
m_debugWindow->deleteLater();
|
|
||||||
debugWindowBtn->setChecked( false );
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( m_debugWindow )
|
|
||||||
{
|
|
||||||
m_debugWindow->deleteLater();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CalamaresUtils::unmarginLayout( sideLayout );
|
CalamaresUtils::unmarginLayout( sideLayout );
|
||||||
@ -430,6 +414,29 @@ CalamaresWindow::ensureSize( QSize size )
|
|||||||
resize( w, h );
|
resize( w, h );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CalamaresWindow::showDebugWindow( bool show )
|
||||||
|
{
|
||||||
|
if ( show )
|
||||||
|
{
|
||||||
|
m_debugWindow = new Calamares::DebugWindow();
|
||||||
|
m_debugWindow->show();
|
||||||
|
connect( m_debugWindow.data(), &Calamares::DebugWindow::closed, this, [=]() {
|
||||||
|
m_debugWindow->deleteLater();
|
||||||
|
emit debugWindowShown( false );
|
||||||
|
} );
|
||||||
|
emit debugWindowShown( true );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( m_debugWindow )
|
||||||
|
{
|
||||||
|
m_debugWindow->deleteLater();
|
||||||
|
}
|
||||||
|
emit debugWindowShown( false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CalamaresWindow::closeEvent( QCloseEvent* event )
|
CalamaresWindow::closeEvent( QCloseEvent* event )
|
||||||
{
|
{
|
||||||
|
@ -30,7 +30,7 @@ public:
|
|||||||
CalamaresWindow( QWidget* parent = nullptr );
|
CalamaresWindow( QWidget* parent = nullptr );
|
||||||
~CalamaresWindow() override {}
|
~CalamaresWindow() override {}
|
||||||
|
|
||||||
public slots:
|
public Q_SLOTS:
|
||||||
/**
|
/**
|
||||||
* This asks the main window to grow to accomodate @p size pixels, to accomodate
|
* This asks the main window to grow to accomodate @p size pixels, to accomodate
|
||||||
* larger-than-expected window contents. The enlargement may be silently
|
* larger-than-expected window contents. The enlargement may be silently
|
||||||
@ -38,6 +38,17 @@ public slots:
|
|||||||
*/
|
*/
|
||||||
void ensureSize( QSize size );
|
void ensureSize( QSize size );
|
||||||
|
|
||||||
|
/** @brief Set visibility of debug window
|
||||||
|
*
|
||||||
|
* Shows or hides the debug window, depending on @p show.
|
||||||
|
* If Calamares is not in debug mode, nothing happens and the debug
|
||||||
|
* window remains hidden.
|
||||||
|
*/
|
||||||
|
void showDebugWindow( bool show );
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void debugWindowShown( bool show );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void closeEvent( QCloseEvent* e ) override;
|
virtual void closeEvent( QCloseEvent* e ) override;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user