[libcalamaresui] Remove *quit* button from ViewManager
- Mostly like the other buttons - Also show/hide the button and set tooltip
This commit is contained in:
parent
0c71c7c23f
commit
91d0ba1007
@ -197,6 +197,13 @@ CalamaresWindow::getWidgetNavigation()
|
||||
auto* quit = new QPushButton( getButtonIcon( QStringLiteral( "dialog-cancel" ) ), tr( "&Cancel" ), navigation );
|
||||
quit->setObjectName( "view-button-cancel" );
|
||||
connect( quit, &QPushButton::clicked, m_viewManager, &Calamares::ViewManager::quit );
|
||||
connect( m_viewManager, &Calamares::ViewManager::quitEnabledChanged, quit, &QPushButton::setEnabled );
|
||||
connect( m_viewManager, &Calamares::ViewManager::quitLabelChanged, quit, &QPushButton::setText );
|
||||
connect( m_viewManager, &Calamares::ViewManager::quitIconChanged, this, [=]( QString n ) {
|
||||
setButtonIcon( quit, n );
|
||||
} );
|
||||
connect( m_viewManager, &Calamares::ViewManager::quitTooltipChanged, quit, &QPushButton::setToolTip );
|
||||
connect( m_viewManager, &Calamares::ViewManager::quitVisibleChanged, quit, &QPushButton::setVisible );
|
||||
bottomLayout->addWidget( quit );
|
||||
}
|
||||
|
||||
|
@ -94,26 +94,12 @@ ViewManager::ViewManager( QObject* parent )
|
||||
m_stack->setContentsMargins( 0, 0, 0, 0 );
|
||||
mainLayout->addWidget( m_stack );
|
||||
|
||||
// Create buttons and sets an initial icon; the icons may change
|
||||
m_quit = new QPushButton( getButtonIcon( QStringLiteral( "dialog-cancel" ) ), tr( "&Cancel" ), m_widget );
|
||||
m_quit->setObjectName( "view-button-cancel" );
|
||||
|
||||
CALAMARES_RETRANSLATE_SLOT( &ViewManager::updateButtonLabels )
|
||||
|
||||
QBoxLayout* bottomLayout = new QHBoxLayout;
|
||||
mainLayout->addLayout( bottomLayout );
|
||||
bottomLayout->addStretch();
|
||||
bottomLayout->addWidget( m_quit );
|
||||
|
||||
connect( m_quit, &QPushButton::clicked, this, &ViewManager::quit );
|
||||
|
||||
connect( JobQueue::instance(), &JobQueue::failed, this, &ViewManager::onInstallationFailed );
|
||||
connect( JobQueue::instance(), &JobQueue::finished, this, &ViewManager::next );
|
||||
|
||||
if ( Calamares::Settings::instance()->disableCancel() )
|
||||
{
|
||||
m_quit->setVisible( false );
|
||||
}
|
||||
UPDATE_BUTTON_PROPERTY( quitVisible, !Calamares::Settings::instance()->disableCancel() )
|
||||
}
|
||||
|
||||
|
||||
@ -413,28 +399,31 @@ ViewManager::updateButtonLabels()
|
||||
// Cancel button changes label at the end
|
||||
if ( isAtVeryEnd( m_steps, m_currentStep ) )
|
||||
{
|
||||
m_quit->setText( tr( "&Done" ) );
|
||||
m_quit->setToolTip( quitOnCompleteTooltip );
|
||||
m_quit->setVisible( true ); // At end, always visible and enabled.
|
||||
setButtonIcon( m_quit, "dialog-ok-apply" );
|
||||
UPDATE_BUTTON_PROPERTY( quitLabel, tr( "&Done" ) )
|
||||
UPDATE_BUTTON_PROPERTY( quitTooltip, quitOnCompleteTooltip )
|
||||
UPDATE_BUTTON_PROPERTY( quitVisible, true )
|
||||
UPDATE_BUTTON_PROPERTY( quitIcon, "dialog-ok-apply" )
|
||||
updateCancelEnabled( true );
|
||||
// FIXME
|
||||
#if 0
|
||||
if ( settings->quitAtEnd() )
|
||||
{
|
||||
m_quit->click();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( settings->disableCancel() )
|
||||
{
|
||||
m_quit->setVisible( false ); // In case we went back from final
|
||||
UPDATE_BUTTON_PROPERTY( quitVisible, false )
|
||||
}
|
||||
updateCancelEnabled( !settings->disableCancel()
|
||||
&& !( stepIsExecute( m_steps, m_currentStep ) && settings->disableCancelDuringExec() ) );
|
||||
|
||||
m_quit->setText( tr( "&Cancel" ) );
|
||||
m_quit->setToolTip( cancelBeforeInstallationTooltip );
|
||||
setButtonIcon( m_quit, "dialog-cancel" );
|
||||
UPDATE_BUTTON_PROPERTY( quitLabel, tr( "&Cancel" ) )
|
||||
UPDATE_BUTTON_PROPERTY( quitTooltip, cancelBeforeInstallationTooltip )
|
||||
UPDATE_BUTTON_PROPERTY( quitIcon, "dialog-cancel" )
|
||||
}
|
||||
}
|
||||
|
||||
@ -516,7 +505,7 @@ ViewManager::confirmCancelInstallation()
|
||||
void
|
||||
ViewManager::updateCancelEnabled( bool enabled )
|
||||
{
|
||||
m_quit->setEnabled( enabled );
|
||||
UPDATE_BUTTON_PROPERTY( quitEnabled, enabled )
|
||||
emit cancelEnabled( enabled );
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,13 @@ class UIDLLEXPORT ViewManager : public QAbstractListModel
|
||||
Q_PROPERTY( QString backLabel READ backLabel NOTIFY backLabelChanged FINAL )
|
||||
Q_PROPERTY( QString backIcon READ backIcon NOTIFY backIconChanged FINAL )
|
||||
|
||||
Q_PROPERTY( bool quitEnabled READ quitEnabled NOTIFY quitEnabledChanged FINAL )
|
||||
Q_PROPERTY( QString quitLabel READ quitLabel NOTIFY quitLabelChanged FINAL )
|
||||
Q_PROPERTY( QString quitIcon READ quitIcon NOTIFY quitIconChanged FINAL )
|
||||
Q_PROPERTY( QString quitTooltip READ quitTooltip NOTIFY quitTooltipChanged FINAL )
|
||||
|
||||
Q_PROPERTY( bool quitVisible READ quitVisible NOTIFY quitVisibleChanged FINAL )
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief instance access to the ViewManager singleton.
|
||||
@ -145,6 +152,23 @@ public Q_SLOTS:
|
||||
* Asks for confirmation if necessary. Terminates the application.
|
||||
*/
|
||||
void quit();
|
||||
bool quitEnabled() const
|
||||
{
|
||||
return m_quitEnabled; ///< Is the quit-button to be enabled
|
||||
}
|
||||
QString quitLabel() const
|
||||
{
|
||||
return m_quitLabel; ///< What should be displayed on the quit-button
|
||||
}
|
||||
QString quitIcon() const
|
||||
{
|
||||
return m_quitIcon; ///< Name of the icon to show
|
||||
}
|
||||
bool quitVisible() const
|
||||
{
|
||||
return m_quitVisible; ///< Should the quit-button be visible
|
||||
}
|
||||
QString quitTooltip() const { return m_quitTooltip; }
|
||||
|
||||
/**
|
||||
* @brief onInstallationFailed displays an error message when a fatal failure
|
||||
@ -173,6 +197,12 @@ signals:
|
||||
void backLabelChanged( QString ) const;
|
||||
void backIconChanged( QString ) const;
|
||||
|
||||
void quitEnabledChanged( bool ) const;
|
||||
void quitLabelChanged( QString ) const;
|
||||
void quitIconChanged( QString ) const;
|
||||
void quitVisibleChanged( bool ) const;
|
||||
void quitTooltipChanged( QString ) const;
|
||||
|
||||
private:
|
||||
explicit ViewManager( QObject* parent = nullptr );
|
||||
virtual ~ViewManager() override;
|
||||
@ -188,7 +218,6 @@ private:
|
||||
|
||||
QWidget* m_widget;
|
||||
QStackedWidget* m_stack;
|
||||
QPushButton* m_quit;
|
||||
|
||||
bool m_nextEnabled = false;
|
||||
QString m_nextLabel;
|
||||
@ -198,6 +227,12 @@ private:
|
||||
QString m_backLabel;
|
||||
QString m_backIcon;
|
||||
|
||||
bool m_quitEnabled = false;
|
||||
QString m_quitLabel;
|
||||
QString m_quitIcon;
|
||||
QString m_quitTooltip;
|
||||
bool m_quitVisible = true;
|
||||
|
||||
public:
|
||||
/** @section Model
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user