Allow boxes that don't hide by escape / click.

This commit is contained in:
John Preston
2018-06-06 14:51:27 +03:00
parent e47d110f28
commit 16f3ca87f5
5 changed files with 46 additions and 5 deletions
+18 -2
View File
@@ -32,8 +32,8 @@ QPointer<Ui::RoundButton> BoxContent::addLeftButton(
Fn<QString()> textFactory,
Fn<void()> clickCallback) {
return getDelegate()->addLeftButton(
std::move(textFactory),
std::move(clickCallback),
std::move(textFactory),
std::move(clickCallback),
st::defaultBoxButton);
}
@@ -190,6 +190,14 @@ void BoxContent::resizeEvent(QResizeEvent *e) {
}
}
void BoxContent::keyPressEvent(QKeyEvent *e) {
if (e->key() == Qt::Key_Escape && !_closeByEscape) {
e->accept();
} else {
RpWidget::keyPressEvent(e);
}
}
void BoxContent::updateScrollAreaGeometry() {
auto newScrollHeight = height() - _innerTopSkip - _innerBottomSkip;
auto changed = (_scroll->height() != newScrollHeight);
@@ -316,6 +324,14 @@ void AbstractBox::setAdditionalTitle(Fn<QString()> additionalFactory) {
refreshAdditionalTitle();
}
void AbstractBox::setCloseByOutsideClick(bool close) {
_closeByOutsideClick = close;
}
bool AbstractBox::closeByOutsideClick() const {
return _closeByOutsideClick;
}
void AbstractBox::refreshAdditionalTitle() {
_additionalTitle = _additionalTitleFactory ? _additionalTitleFactory() : QString();
update();