mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Removed old implementation of Ui::ConfirmBox.
This commit is contained in:
parent
5718789d53
commit
e6da3cf845
2 changed files with 4 additions and 526 deletions
|
@ -14,29 +14,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
namespace {
|
|
||||||
|
|
||||||
TextParseOptions kInformBoxTextOptions = {
|
void ConfirmBox(not_null<Ui::GenericBox*> box, ConfirmBoxArgs &&args) {
|
||||||
(TextParseLinks
|
|
||||||
| TextParseMultiline
|
|
||||||
| TextParseMarkdown), // flags
|
|
||||||
0, // maxw
|
|
||||||
0, // maxh
|
|
||||||
Qt::LayoutDirectionAuto, // dir
|
|
||||||
};
|
|
||||||
|
|
||||||
TextParseOptions kMarkedTextBoxOptions = {
|
|
||||||
(TextParseLinks
|
|
||||||
| TextParseMultiline
|
|
||||||
| TextParseMarkdown
|
|
||||||
| TextParseMentions
|
|
||||||
| TextParseHashtags), // flags
|
|
||||||
0, // maxw
|
|
||||||
0, // maxh
|
|
||||||
Qt::LayoutDirectionAuto, // dir
|
|
||||||
};
|
|
||||||
|
|
||||||
void GenericConfirmBox(not_null<Ui::GenericBox*> box, ConfirmBoxArgs &&args) {
|
|
||||||
const auto weak = Ui::MakeWeak(box);
|
const auto weak = Ui::MakeWeak(box);
|
||||||
const auto lifetime = box->lifetime().make_state<rpl::lifetime>();
|
const auto lifetime = box->lifetime().make_state<rpl::lifetime>();
|
||||||
|
|
||||||
|
@ -96,10 +75,8 @@ void GenericConfirmBox(not_null<Ui::GenericBox*> box, ConfirmBoxArgs &&args) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
object_ptr<Ui::GenericBox> MakeConfirmBox(ConfirmBoxArgs &&args) {
|
object_ptr<Ui::GenericBox> MakeConfirmBox(ConfirmBoxArgs &&args) {
|
||||||
return Box(GenericConfirmBox, std::move(args));
|
return Box(ConfirmBox, std::move(args));
|
||||||
}
|
}
|
||||||
|
|
||||||
object_ptr<Ui::GenericBox> MakeInformBox(v::text::data text) {
|
object_ptr<Ui::GenericBox> MakeInformBox(v::text::data text) {
|
||||||
|
@ -109,365 +86,6 @@ object_ptr<Ui::GenericBox> MakeInformBox(v::text::data text) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfirmBox::ConfirmBox(
|
|
||||||
QWidget*,
|
|
||||||
const QString &text,
|
|
||||||
ConfirmBox::ConfirmedCallback confirmedCallback,
|
|
||||||
FnMut<void()> cancelledCallback)
|
|
||||||
: _confirmText(tr::lng_box_ok(tr::now))
|
|
||||||
, _cancelText(tr::lng_cancel(tr::now))
|
|
||||||
, _confirmStyle(st::defaultBoxButton)
|
|
||||||
, _text(st::boxWidth
|
|
||||||
- st::boxPadding.left()
|
|
||||||
- st::defaultBox.buttonPadding.right())
|
|
||||||
, _confirmedCallback(std::move(confirmedCallback))
|
|
||||||
, _cancelledCallback(std::move(cancelledCallback)) {
|
|
||||||
init(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfirmBox::ConfirmBox(
|
|
||||||
QWidget*,
|
|
||||||
const QString &text,
|
|
||||||
const QString &confirmText,
|
|
||||||
ConfirmBox::ConfirmedCallback confirmedCallback,
|
|
||||||
FnMut<void()> cancelledCallback)
|
|
||||||
: _confirmText(confirmText)
|
|
||||||
, _cancelText(tr::lng_cancel(tr::now))
|
|
||||||
, _confirmStyle(st::defaultBoxButton)
|
|
||||||
, _text(st::boxWidth
|
|
||||||
- st::boxPadding.left()
|
|
||||||
- st::defaultBox.buttonPadding.right())
|
|
||||||
, _confirmedCallback(std::move(confirmedCallback))
|
|
||||||
, _cancelledCallback(std::move(cancelledCallback)) {
|
|
||||||
init(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfirmBox::ConfirmBox(
|
|
||||||
QWidget*,
|
|
||||||
const TextWithEntities &text,
|
|
||||||
const QString &confirmText,
|
|
||||||
ConfirmBox::ConfirmedCallback confirmedCallback,
|
|
||||||
FnMut<void()> cancelledCallback)
|
|
||||||
: _confirmText(confirmText)
|
|
||||||
, _cancelText(tr::lng_cancel(tr::now))
|
|
||||||
, _confirmStyle(st::defaultBoxButton)
|
|
||||||
, _text(st::boxWidth
|
|
||||||
- st::boxPadding.left()
|
|
||||||
- st::defaultBox.buttonPadding.right())
|
|
||||||
, _confirmedCallback(std::move(confirmedCallback))
|
|
||||||
, _cancelledCallback(std::move(cancelledCallback)) {
|
|
||||||
init(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfirmBox::ConfirmBox(
|
|
||||||
QWidget*,
|
|
||||||
const QString &text,
|
|
||||||
const QString &confirmText,
|
|
||||||
const style::RoundButton &confirmStyle,
|
|
||||||
ConfirmBox::ConfirmedCallback confirmedCallback,
|
|
||||||
FnMut<void()> cancelledCallback)
|
|
||||||
: _confirmText(confirmText)
|
|
||||||
, _cancelText(tr::lng_cancel(tr::now))
|
|
||||||
, _confirmStyle(confirmStyle)
|
|
||||||
, _text(st::boxWidth
|
|
||||||
- st::boxPadding.left()
|
|
||||||
- st::defaultBox.buttonPadding.right())
|
|
||||||
, _confirmedCallback(std::move(confirmedCallback))
|
|
||||||
, _cancelledCallback(std::move(cancelledCallback)) {
|
|
||||||
init(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfirmBox::ConfirmBox(
|
|
||||||
QWidget*,
|
|
||||||
const QString &text,
|
|
||||||
const QString &confirmText,
|
|
||||||
const QString &cancelText,
|
|
||||||
ConfirmBox::ConfirmedCallback confirmedCallback,
|
|
||||||
FnMut<void()> cancelledCallback)
|
|
||||||
: _confirmText(confirmText)
|
|
||||||
, _cancelText(cancelText)
|
|
||||||
, _confirmStyle(st::defaultBoxButton)
|
|
||||||
, _text(st::boxWidth
|
|
||||||
- st::boxPadding.left()
|
|
||||||
- st::defaultBox.buttonPadding.right())
|
|
||||||
, _confirmedCallback(std::move(confirmedCallback))
|
|
||||||
, _cancelledCallback(std::move(cancelledCallback)) {
|
|
||||||
init(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfirmBox::ConfirmBox(
|
|
||||||
QWidget*,
|
|
||||||
const QString &text,
|
|
||||||
const QString &confirmText,
|
|
||||||
const style::RoundButton &confirmStyle,
|
|
||||||
const QString &cancelText,
|
|
||||||
ConfirmBox::ConfirmedCallback confirmedCallback,
|
|
||||||
FnMut<void()> cancelledCallback)
|
|
||||||
: _confirmText(confirmText)
|
|
||||||
, _cancelText(cancelText)
|
|
||||||
, _confirmStyle(st::defaultBoxButton)
|
|
||||||
, _text(st::boxWidth
|
|
||||||
- st::boxPadding.left()
|
|
||||||
- st::defaultBox.buttonPadding.right())
|
|
||||||
, _confirmedCallback(std::move(confirmedCallback))
|
|
||||||
, _cancelledCallback(std::move(cancelledCallback)) {
|
|
||||||
init(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfirmBox::ConfirmBox(
|
|
||||||
const InformBoxTag &,
|
|
||||||
const QString &text,
|
|
||||||
const QString &doneText,
|
|
||||||
Fn<void()> closedCallback)
|
|
||||||
: _confirmText(doneText)
|
|
||||||
, _confirmStyle(st::defaultBoxButton)
|
|
||||||
, _informative(true)
|
|
||||||
, _text(st::boxWidth
|
|
||||||
- st::boxPadding.left()
|
|
||||||
- st::defaultBox.buttonPadding.right())
|
|
||||||
, _confirmedCallback(generateInformCallback(closedCallback))
|
|
||||||
, _cancelledCallback(generateInformCallback(closedCallback)) {
|
|
||||||
init(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfirmBox::ConfirmBox(
|
|
||||||
const InformBoxTag &,
|
|
||||||
const TextWithEntities &text,
|
|
||||||
const QString &doneText,
|
|
||||||
Fn<void()> closedCallback)
|
|
||||||
: _confirmText(doneText)
|
|
||||||
, _confirmStyle(st::defaultBoxButton)
|
|
||||||
, _informative(true)
|
|
||||||
, _text(st::boxWidth
|
|
||||||
- st::boxPadding.left()
|
|
||||||
- st::defaultBox.buttonPadding.right())
|
|
||||||
, _confirmedCallback(generateInformCallback(closedCallback))
|
|
||||||
, _cancelledCallback(generateInformCallback(closedCallback)) {
|
|
||||||
init(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
FnMut<void()> ConfirmBox::generateInformCallback(
|
|
||||||
Fn<void()> closedCallback) {
|
|
||||||
return crl::guard(this, [=] {
|
|
||||||
closeBox();
|
|
||||||
if (closedCallback) {
|
|
||||||
closedCallback();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfirmBox::init(const QString &text) {
|
|
||||||
_text.setText(
|
|
||||||
st::boxLabelStyle,
|
|
||||||
text,
|
|
||||||
_informative ? kInformBoxTextOptions : kPlainTextOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfirmBox::init(const TextWithEntities &text) {
|
|
||||||
_text.setMarkedText(st::boxLabelStyle, text, kMarkedTextBoxOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfirmBox::prepare() {
|
|
||||||
addButton(
|
|
||||||
rpl::single(_confirmText),
|
|
||||||
[=] { confirmed(); },
|
|
||||||
_confirmStyle);
|
|
||||||
if (!_informative) {
|
|
||||||
addButton(
|
|
||||||
rpl::single(_cancelText),
|
|
||||||
[=] { _cancelled = true; closeBox(); });
|
|
||||||
}
|
|
||||||
|
|
||||||
boxClosing() | rpl::start_with_next([=] {
|
|
||||||
if (!_confirmed && (!_strictCancel || _cancelled)) {
|
|
||||||
if (auto callback = std::move(_cancelledCallback)) {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, lifetime());
|
|
||||||
|
|
||||||
textUpdated();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfirmBox::setMaxLineCount(int count) {
|
|
||||||
if (_maxLineCount != count) {
|
|
||||||
_maxLineCount = count;
|
|
||||||
textUpdated();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfirmBox::textUpdated() {
|
|
||||||
_textWidth = st::boxWidth
|
|
||||||
- st::boxPadding.left()
|
|
||||||
- st::defaultBox.buttonPadding.right();
|
|
||||||
_textHeight = _text.countHeight(_textWidth);
|
|
||||||
if (_maxLineCount > 0) {
|
|
||||||
accumulate_min(
|
|
||||||
_textHeight,
|
|
||||||
_maxLineCount * st::boxLabelStyle.lineHeight);
|
|
||||||
}
|
|
||||||
setDimensions(
|
|
||||||
st::boxWidth,
|
|
||||||
st::boxPadding.top() + _textHeight + st::boxPadding.bottom());
|
|
||||||
|
|
||||||
setMouseTracking(_text.hasLinks());
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfirmBox::confirmed() {
|
|
||||||
if (!_confirmed) {
|
|
||||||
_confirmed = true;
|
|
||||||
|
|
||||||
const auto confirmed = &_confirmedCallback;
|
|
||||||
if (const auto callbackPtr = std::get_if<1>(confirmed)) {
|
|
||||||
if (auto callback = base::take(*callbackPtr)) {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
} else if (const auto callbackPtr = std::get_if<2>(confirmed)) {
|
|
||||||
if (auto callback = base::take(*callbackPtr)) {
|
|
||||||
const auto weak = Ui::MakeWeak(this);
|
|
||||||
callback(crl::guard(weak, [=] { closeBox(); }));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfirmBox::mouseMoveEvent(QMouseEvent *e) {
|
|
||||||
_lastMousePos = e->globalPos();
|
|
||||||
updateHover();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfirmBox::mousePressEvent(QMouseEvent *e) {
|
|
||||||
_lastMousePos = e->globalPos();
|
|
||||||
updateHover();
|
|
||||||
ClickHandler::pressed();
|
|
||||||
return BoxContent::mousePressEvent(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfirmBox::mouseReleaseEvent(QMouseEvent *e) {
|
|
||||||
_lastMousePos = e->globalPos();
|
|
||||||
updateHover();
|
|
||||||
if (const auto activated = ClickHandler::unpressed()) {
|
|
||||||
ActivateClickHandler(window(), activated, e->button());
|
|
||||||
crl::on_main(this, [=] {
|
|
||||||
closeBox();
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BoxContent::mouseReleaseEvent(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfirmBox::leaveEventHook(QEvent *e) {
|
|
||||||
ClickHandler::clearActive(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfirmBox::clickHandlerActiveChanged(
|
|
||||||
const ClickHandlerPtr &p,
|
|
||||||
bool active) {
|
|
||||||
setCursor(active ? style::cur_pointer : style::cur_default);
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfirmBox::clickHandlerPressedChanged(
|
|
||||||
const ClickHandlerPtr &p,
|
|
||||||
bool pressed) {
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfirmBox::updateLink() {
|
|
||||||
_lastMousePos = QCursor::pos();
|
|
||||||
updateHover();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfirmBox::updateHover() {
|
|
||||||
const auto m = mapFromGlobal(_lastMousePos);
|
|
||||||
const auto state = _text.getStateLeft(
|
|
||||||
m - QPoint(st::boxPadding.left(), st::boxPadding.top()),
|
|
||||||
_textWidth,
|
|
||||||
width());
|
|
||||||
|
|
||||||
ClickHandler::setActive(state.link, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfirmBox::keyPressEvent(QKeyEvent *e) {
|
|
||||||
if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) {
|
|
||||||
confirmed();
|
|
||||||
} else {
|
|
||||||
BoxContent::keyPressEvent(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfirmBox::paintEvent(QPaintEvent *e) {
|
|
||||||
BoxContent::paintEvent(e);
|
|
||||||
|
|
||||||
Painter p(this);
|
|
||||||
|
|
||||||
// draw box title / text
|
|
||||||
p.setPen(st::boxTextFg);
|
|
||||||
if (_maxLineCount > 0) {
|
|
||||||
_text.drawLeftElided(
|
|
||||||
p,
|
|
||||||
st::boxPadding.left(),
|
|
||||||
st::boxPadding.top(),
|
|
||||||
_textWidth,
|
|
||||||
width(),
|
|
||||||
_maxLineCount,
|
|
||||||
style::al_left);
|
|
||||||
} else {
|
|
||||||
_text.drawLeft(
|
|
||||||
p,
|
|
||||||
st::boxPadding.left(),
|
|
||||||
st::boxPadding.top(),
|
|
||||||
_textWidth,
|
|
||||||
width(),
|
|
||||||
style::al_left);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
InformBox::InformBox(
|
|
||||||
QWidget*,
|
|
||||||
const QString &text, Fn<void()> closedCallback)
|
|
||||||
: ConfirmBox(
|
|
||||||
ConfirmBox::InformBoxTag(),
|
|
||||||
text,
|
|
||||||
tr::lng_box_ok(tr::now),
|
|
||||||
std::move(closedCallback)) {
|
|
||||||
}
|
|
||||||
|
|
||||||
InformBox::InformBox(
|
|
||||||
QWidget*,
|
|
||||||
const QString &text,
|
|
||||||
const QString &doneText,
|
|
||||||
Fn<void()> closedCallback)
|
|
||||||
: ConfirmBox(
|
|
||||||
ConfirmBox::InformBoxTag(),
|
|
||||||
text,
|
|
||||||
doneText,
|
|
||||||
std::move(closedCallback)) {
|
|
||||||
}
|
|
||||||
|
|
||||||
InformBox::InformBox(
|
|
||||||
QWidget*,
|
|
||||||
const TextWithEntities &text,
|
|
||||||
Fn<void()> closedCallback)
|
|
||||||
: ConfirmBox(
|
|
||||||
ConfirmBox::InformBoxTag(),
|
|
||||||
text,
|
|
||||||
tr::lng_box_ok(tr::now),
|
|
||||||
std::move(closedCallback)) {
|
|
||||||
}
|
|
||||||
|
|
||||||
InformBox::InformBox(
|
|
||||||
QWidget*,
|
|
||||||
const TextWithEntities &text,
|
|
||||||
const QString &doneText,
|
|
||||||
Fn<void()> closedCallback)
|
|
||||||
: ConfirmBox(
|
|
||||||
ConfirmBox::InformBoxTag(),
|
|
||||||
text,
|
|
||||||
doneText,
|
|
||||||
std::move(closedCallback)) {
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfirmDontWarnBox::ConfirmDontWarnBox(
|
ConfirmDontWarnBox::ConfirmDontWarnBox(
|
||||||
QWidget*,
|
QWidget*,
|
||||||
rpl::producer<TextWithEntities> text,
|
rpl::producer<TextWithEntities> text,
|
||||||
|
|
|
@ -38,152 +38,12 @@ struct ConfirmBoxArgs {
|
||||||
bool strictCancel = false;
|
bool strictCancel = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void ConfirmBox(not_null<Ui::GenericBox*> box, ConfirmBoxArgs &&args);
|
||||||
|
|
||||||
[[nodiscard]] object_ptr<Ui::GenericBox> MakeConfirmBox(
|
[[nodiscard]] object_ptr<Ui::GenericBox> MakeConfirmBox(
|
||||||
ConfirmBoxArgs &&args);
|
ConfirmBoxArgs &&args);
|
||||||
[[nodiscard]] object_ptr<Ui::GenericBox> MakeInformBox(v::text::data text);
|
[[nodiscard]] object_ptr<Ui::GenericBox> MakeInformBox(v::text::data text);
|
||||||
|
|
||||||
class InformBox;
|
|
||||||
class ConfirmBox : public Ui::BoxContent, public ClickHandlerHost {
|
|
||||||
public:
|
|
||||||
|
|
||||||
using ConfirmedCallback = std::variant<
|
|
||||||
v::null_t,
|
|
||||||
FnMut<void()>,
|
|
||||||
FnMut<void(Fn<void()>)>>;
|
|
||||||
|
|
||||||
ConfirmBox(
|
|
||||||
QWidget*,
|
|
||||||
const QString &text,
|
|
||||||
ConfirmedCallback confirmedCallback = FnMut<void()>(),
|
|
||||||
FnMut<void()> cancelledCallback = FnMut<void()>());
|
|
||||||
ConfirmBox(
|
|
||||||
QWidget*,
|
|
||||||
const QString &text,
|
|
||||||
const QString &confirmText,
|
|
||||||
ConfirmedCallback confirmedCallback = FnMut<void()>(),
|
|
||||||
FnMut<void()> cancelledCallback = FnMut<void()>());
|
|
||||||
ConfirmBox(
|
|
||||||
QWidget*,
|
|
||||||
const QString &text,
|
|
||||||
const QString &confirmText,
|
|
||||||
const style::RoundButton &confirmStyle,
|
|
||||||
ConfirmedCallback confirmedCallback = FnMut<void()>(),
|
|
||||||
FnMut<void()> cancelledCallback = FnMut<void()>());
|
|
||||||
ConfirmBox(
|
|
||||||
QWidget*,
|
|
||||||
const QString &text,
|
|
||||||
const QString &confirmText,
|
|
||||||
const QString &cancelText,
|
|
||||||
ConfirmedCallback confirmedCallback = FnMut<void()>(),
|
|
||||||
FnMut<void()> cancelledCallback = FnMut<void()>());
|
|
||||||
ConfirmBox(
|
|
||||||
QWidget*,
|
|
||||||
const QString &text,
|
|
||||||
const QString &confirmText,
|
|
||||||
const style::RoundButton &confirmStyle,
|
|
||||||
const QString &cancelText,
|
|
||||||
ConfirmedCallback confirmedCallback = FnMut<void()>(),
|
|
||||||
FnMut<void()> cancelledCallback = FnMut<void()>());
|
|
||||||
ConfirmBox(
|
|
||||||
QWidget*,
|
|
||||||
const TextWithEntities &text,
|
|
||||||
const QString &confirmText,
|
|
||||||
ConfirmedCallback confirmedCallback = v::null,
|
|
||||||
FnMut<void()> cancelledCallback = nullptr);
|
|
||||||
|
|
||||||
void updateLink();
|
|
||||||
|
|
||||||
// If strict cancel is set the cancelledCallback is only called
|
|
||||||
// if the cancel button was pressed.
|
|
||||||
void setStrictCancel(bool strictCancel) {
|
|
||||||
_strictCancel = strictCancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setMaxLineCount(int count);
|
|
||||||
|
|
||||||
// ClickHandlerHost interface
|
|
||||||
void clickHandlerActiveChanged(
|
|
||||||
const ClickHandlerPtr &p,
|
|
||||||
bool active) override;
|
|
||||||
void clickHandlerPressedChanged(
|
|
||||||
const ClickHandlerPtr &p,
|
|
||||||
bool pressed) override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void prepare() override;
|
|
||||||
|
|
||||||
void keyPressEvent(QKeyEvent *e) override;
|
|
||||||
void paintEvent(QPaintEvent *e) override;
|
|
||||||
void mouseMoveEvent(QMouseEvent *e) override;
|
|
||||||
void mousePressEvent(QMouseEvent *e) override;
|
|
||||||
void mouseReleaseEvent(QMouseEvent *e) override;
|
|
||||||
void leaveEventHook(QEvent *e) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct InformBoxTag {
|
|
||||||
};
|
|
||||||
ConfirmBox(
|
|
||||||
const InformBoxTag &,
|
|
||||||
const QString &text,
|
|
||||||
const QString &doneText,
|
|
||||||
Fn<void()> closedCallback);
|
|
||||||
ConfirmBox(
|
|
||||||
const InformBoxTag &,
|
|
||||||
const TextWithEntities &text,
|
|
||||||
const QString &doneText,
|
|
||||||
Fn<void()> closedCallback);
|
|
||||||
FnMut<void()> generateInformCallback(Fn<void()> closedCallback);
|
|
||||||
friend class InformBox;
|
|
||||||
|
|
||||||
void confirmed();
|
|
||||||
void init(const QString &text);
|
|
||||||
void init(const TextWithEntities &text);
|
|
||||||
void textUpdated();
|
|
||||||
void updateHover();
|
|
||||||
|
|
||||||
QString _confirmText;
|
|
||||||
QString _cancelText;
|
|
||||||
const style::RoundButton &_confirmStyle;
|
|
||||||
bool _informative = false;
|
|
||||||
|
|
||||||
Ui::Text::String _text;
|
|
||||||
int _textWidth = 0;
|
|
||||||
int _textHeight = 0;
|
|
||||||
int _maxLineCount = 16;
|
|
||||||
|
|
||||||
QPoint _lastMousePos;
|
|
||||||
|
|
||||||
bool _confirmed = false;
|
|
||||||
bool _cancelled = false;
|
|
||||||
bool _strictCancel = false;
|
|
||||||
ConfirmBox::ConfirmedCallback _confirmedCallback;
|
|
||||||
FnMut<void()> _cancelledCallback;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class InformBox : public ConfirmBox {
|
|
||||||
public:
|
|
||||||
InformBox(
|
|
||||||
QWidget*,
|
|
||||||
const QString &text,
|
|
||||||
Fn<void()> closedCallback = nullptr);
|
|
||||||
InformBox(
|
|
||||||
QWidget*,
|
|
||||||
const QString &text,
|
|
||||||
const QString &doneText,
|
|
||||||
Fn<void()> closedCallback = nullptr);
|
|
||||||
InformBox(
|
|
||||||
QWidget*,
|
|
||||||
const TextWithEntities &text,
|
|
||||||
Fn<void()> closedCallback = nullptr);
|
|
||||||
InformBox(
|
|
||||||
QWidget*,
|
|
||||||
const TextWithEntities &text,
|
|
||||||
const QString &doneText,
|
|
||||||
Fn<void()> closedCallback = nullptr);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class ConfirmDontWarnBox : public Ui::BoxContent {
|
class ConfirmDontWarnBox : public Ui::BoxContent {
|
||||||
public:
|
public:
|
||||||
ConfirmDontWarnBox(
|
ConfirmDontWarnBox(
|
||||||
|
|
Loading…
Add table
Reference in a new issue