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