Allow triggering buttons in boxes from code.
This commit is contained in:
parent
7ed6610511
commit
d68dfd3320
5 changed files with 17 additions and 4 deletions
|
|
@ -51,6 +51,8 @@ public:
|
|||
lifetime());
|
||||
}
|
||||
|
||||
void clicked(Qt::KeyboardModifiers modifiers, Qt::MouseButton button);
|
||||
|
||||
protected:
|
||||
void enterEventHook(QEvent *e) override;
|
||||
void leaveEventHook(QEvent *e) override;
|
||||
|
|
@ -82,8 +84,6 @@ protected:
|
|||
virtual void onStateChanged(State was, StateChangeSource source) {
|
||||
}
|
||||
|
||||
void clicked(Qt::KeyboardModifiers modifiers, Qt::MouseButton button);
|
||||
|
||||
private:
|
||||
void updateCursor();
|
||||
void checkIfOver(QPoint localPos);
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ public:
|
|||
virtual void setNoContentMargin(bool noContentMargin) = 0;
|
||||
virtual bool isBoxShown() const = 0;
|
||||
virtual void closeBox() = 0;
|
||||
virtual void triggerButton(int index) = 0;
|
||||
|
||||
template <typename BoxType>
|
||||
QPointer<BoxType> show(
|
||||
|
|
@ -102,6 +103,9 @@ public:
|
|||
void closeBox() {
|
||||
getDelegate()->closeBox();
|
||||
}
|
||||
void triggerButton(int index) {
|
||||
getDelegate()->triggerButton(index);
|
||||
}
|
||||
|
||||
void setTitle(rpl::producer<QString> title);
|
||||
void setTitle(rpl::producer<TextWithEntities> title) {
|
||||
|
|
@ -158,7 +162,7 @@ public:
|
|||
setFocus();
|
||||
}
|
||||
|
||||
rpl::producer<> boxClosing() const {
|
||||
[[nodiscard]] rpl::producer<> boxClosing() const {
|
||||
return _boxClosingStream.events();
|
||||
}
|
||||
void notifyBoxClosing() {
|
||||
|
|
@ -171,7 +175,7 @@ public:
|
|||
prepare();
|
||||
finishPrepare();
|
||||
}
|
||||
not_null<BoxContentDelegate*> getDelegate() const {
|
||||
[[nodiscard]] not_null<BoxContentDelegate*> getDelegate() const {
|
||||
return _delegate;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -156,6 +156,12 @@ void BoxLayerWidget::setAdditionalTitle(rpl::producer<QString> additional) {
|
|||
_additionalTitle = std::move(additional);
|
||||
}
|
||||
|
||||
void BoxLayerWidget::triggerButton(int index) {
|
||||
if (index < _buttons.size()) {
|
||||
_buttons[index]->clicked(Qt::KeyboardModifiers(), Qt::LeftButton);
|
||||
}
|
||||
}
|
||||
|
||||
void BoxLayerWidget::setCloseByOutsideClick(bool close) {
|
||||
_closeByOutsideClick = close;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ public:
|
|||
void closeBox() override {
|
||||
closeLayer();
|
||||
}
|
||||
void triggerButton(int index) override;
|
||||
|
||||
void setCloseByOutsideClick(bool close) override;
|
||||
bool closeByOutsideClick() const override;
|
||||
|
|
|
|||
|
|
@ -72,6 +72,8 @@ public:
|
|||
void setInnerFocus() override {
|
||||
if (_focus) {
|
||||
_focus();
|
||||
} else {
|
||||
BoxContent::setInnerFocus();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue