#include "qt_helpers.h"
#include "support/debug.h"
-#include "support/foreach.h"
#include <QCheckBox>
#include <QPushButton>
typedef QList<CheckedLineEdit> CheckedWidgetList;
Private()
- : okay_(0), apply_(0), cancel_(0), restore_(0), auto_apply_(0),
+ : okay_(0), apply_(0), cancel_(0), restore_(0), auto_apply_(0), default_(0),
policy_(ButtonPolicy::IgnorantPolicy)
{}
bool checkWidgets() const
{
bool valid = true;
- foreach (const CheckedLineEdit & w, checked_widgets_)
+ for (const CheckedLineEdit & w : checked_widgets_)
valid &= w.check();
return valid;
}
QPushButton * cancel_;
QPushButton * restore_;
QCheckBox * auto_apply_;
+ QPushButton * default_;
typedef QList<QWidget *> Widgets;
Widgets read_only_;
// refreshReadOnly(); This will enable all widgets in dialogs, no matter if
// they allowed to be enabled, so when you plan to
// reenable this call, read this before:
- // http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg128222.html
+ // http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg128222.html
refresh();
return ro;
}
bool const enabled = policy().buttonStatus(ButtonPolicy::AUTOAPPLY);
d->auto_apply_->setEnabled(enabled);
}
-
+ if (d->default_)
+ // Somewhere in the chain this can lose default status (#11417)
+ d->default_->setDefault(true);
}
{
if (d->read_only_.empty())
return;
-
bool const enable = !policy().isReadOnly();
-
- foreach (QWidget * w, d->read_only_)
+ for(QWidget * w : d->read_only_)
setWidgetEnabled(w, enable);
}
}
-void ButtonController::setOK(QPushButton * obj)
+void ButtonController::setOK(QPushButton * obj, bool const default_button)
{
d->okay_ = obj;
+ if (default_button)
+ d->default_ = obj;
}
-void ButtonController::setApply(QPushButton * obj)
+void ButtonController::setApply(QPushButton * obj, bool const default_button)
{
d->apply_ = obj;
+ if (default_button)
+ d->default_ = obj;
}
}
-void ButtonController::setCancel(QPushButton * obj)
+void ButtonController::setCancel(QPushButton * obj, bool const default_button)
{
d->cancel_ = obj;
+ if (default_button)
+ d->default_ = obj;
}
-void ButtonController::setRestore(QPushButton * obj)
+void ButtonController::setRestore(QPushButton * obj, bool const default_button)
{
d->restore_ = obj;
+ if (default_button)
+ d->default_ = obj;
}