libcalamaresui: deal with QMessageBox::question
This commit is contained in:
parent
159eccbda0
commit
8ea7c578b3
@ -287,6 +287,37 @@ isAtVeryEnd( const ViewStepList& steps, int index )
|
||||
return ( index >= steps.count() ) || ( index == steps.count() - 1 && steps.last()->isAtEnd() );
|
||||
}
|
||||
|
||||
static int
|
||||
questionBox( QWidget* parent,
|
||||
const QString& title,
|
||||
const QString& question,
|
||||
const QString& button0,
|
||||
const QString& button1 )
|
||||
{
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
|
||||
QMessageBox mb( QMessageBox::Question, title, question, QMessageBox::StandardButton::NoButton, parent );
|
||||
const auto* const okButton = mb.addButton( button0, QMessageBox::AcceptRole );
|
||||
mb.addButton( button1, QMessageBox::RejectRole );
|
||||
mb.exec();
|
||||
if ( mb.clickedButton() == okButton )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 1; // Cancel
|
||||
#else
|
||||
return QMessageBox::question( parent,
|
||||
title,
|
||||
question,
|
||||
button0,
|
||||
button1,
|
||||
QString(),
|
||||
0 /* default first button, i.e. confirm */,
|
||||
1 /* escape is second button, i.e. cancel */ );
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
ViewManager::next()
|
||||
{
|
||||
@ -318,15 +349,11 @@ ViewManager::next()
|
||||
QString confirm = settings->isSetupMode() ? tr( "&Set up now" ) : tr( "&Install now" );
|
||||
|
||||
const auto* branding = Calamares::Branding::instance();
|
||||
int reply
|
||||
= QMessageBox::question( m_widget,
|
||||
int reply = questionBox( m_widget,
|
||||
title,
|
||||
question.arg( branding->shortProductName(), branding->shortVersionedName() ),
|
||||
confirm,
|
||||
tr( "Go &back" ),
|
||||
QString(),
|
||||
0 /* default first button, i.e. confirm */,
|
||||
1 /* escape is second button, i.e. cancel */ );
|
||||
tr( "Go &back" ) );
|
||||
if ( reply == 1 )
|
||||
{
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user