mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Removed Ui::ConfirmDontWarnBox.
This commit is contained in:
parent
e6da3cf845
commit
df125bac19
13 changed files with 43 additions and 78 deletions
|
@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "lang/lang_keys.h"
|
||||
#include "main/main_session.h"
|
||||
#include "mtproto/mtproto_response.h"
|
||||
#include "boxes/abstract_box.h" // Ui::show().
|
||||
|
||||
namespace Api {
|
||||
namespace {
|
||||
|
|
|
@ -29,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/text/text_options.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/basic_click_handlers.h"
|
||||
#include "boxes/abstract_box.h" // Ui::show().
|
||||
#include "styles/style_layers.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_chat_helpers.h"
|
||||
|
|
|
@ -33,6 +33,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/toast/toast.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "mtproto/mtproto_config.h"
|
||||
#include "boxes/abstract_box.h" // Ui::show().
|
||||
|
||||
#include <tgcalls/VideoCaptureInterface.h>
|
||||
#include <tgcalls/StaticThreads.h>
|
||||
|
|
|
@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_user.h"
|
||||
#include "data/data_session.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "boxes/abstract_box.h" // Ui::hideLayer().
|
||||
#include "facades.h"
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -45,6 +45,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "mainwindow.h"
|
||||
#include "core/application.h"
|
||||
#include "lottie/lottie_animation.h"
|
||||
#include "boxes/abstract_box.h" // Ui::hideLayer().
|
||||
|
||||
#include <QtCore/QBuffer>
|
||||
#include <QtCore/QMimeType>
|
||||
|
|
|
@ -25,7 +25,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "platform/platform_file_utilities.h"
|
||||
#include "ui/chat/chat_theme.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/widgets/checkbox.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "boxes/abstract_box.h" // Ui::show().
|
||||
#include "styles/style_layers.h"
|
||||
|
||||
#include <QtCore/QBuffer>
|
||||
#include <QtCore/QMimeType>
|
||||
|
@ -34,12 +37,38 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
namespace Data {
|
||||
namespace {
|
||||
|
||||
void ConfirmDontWarnBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
rpl::producer<TextWithEntities> &&text,
|
||||
rpl::producer<QString> &&confirm,
|
||||
Fn<void(bool)> callback) {
|
||||
auto checkbox = object_ptr<Ui::Checkbox>(
|
||||
box.get(),
|
||||
tr::lng_launch_exe_dont_ask(),
|
||||
false,
|
||||
st::defaultBoxCheckbox);
|
||||
const auto weak = Ui::MakeWeak(checkbox.data());
|
||||
auto confirmed = crl::guard(weak, [=, callback = std::move(callback)] {
|
||||
const auto checked = weak->checked();
|
||||
box->closeBox();
|
||||
callback(checked);
|
||||
});
|
||||
Ui::ConfirmBox(box, {
|
||||
.text = std::move(text),
|
||||
.confirmed = std::move(confirmed),
|
||||
.confirmText = std::move(confirm),
|
||||
});
|
||||
auto padding = st::boxPadding;
|
||||
padding.setTop(padding.bottom());
|
||||
box->addRow(std::move(checkbox), std::move(padding));
|
||||
}
|
||||
|
||||
void LaunchWithWarning(
|
||||
// not_null<Window::Controller*> controller,
|
||||
const QString &name,
|
||||
HistoryItem *item) {
|
||||
const auto isExecutable = Data::IsExecutableName(name);
|
||||
const auto isIpReveal = Data::IsIpRevealingName(name);
|
||||
const auto isIpReveal = true;
|
||||
auto &app = Core::App();
|
||||
const auto warn = [&] {
|
||||
if (item && item->history()->peer->isVerified()) {
|
||||
|
@ -80,9 +109,9 @@ void LaunchWithWarning(
|
|||
rpl::single(Ui::Text::Bold(extension)),
|
||||
Ui::Text::WithEntities)
|
||||
: tr::lng_launch_svg_warning(Ui::Text::WithEntities);
|
||||
Ui::show(Box<Ui::ConfirmDontWarnBox>(
|
||||
Ui::show(Box(
|
||||
ConfirmDontWarnBox,
|
||||
std::move(text),
|
||||
tr::lng_launch_exe_dont_ask(tr::now),
|
||||
(isExecutable ? tr::lng_launch_exe_sure : tr::lng_continue)(),
|
||||
callback));
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/toast/toast.h"
|
||||
#include "ui/image/image_location_factory.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "boxes/abstract_box.h" // Ui::show().
|
||||
#include "styles/style_chat_helpers.h"
|
||||
|
||||
namespace Data {
|
||||
|
|
|
@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "base/platform/base_platform_info.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "base/qt/qt_common_adapters.h"
|
||||
#include "boxes/abstract_box.h" // Ui::show().
|
||||
#include "styles/style_export.h"
|
||||
#include "styles/style_layers.h"
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/text/text_utilities.h"
|
||||
#include "core/file_utilities.h"
|
||||
#include "core/click_handler_types.h"
|
||||
#include "boxes/abstract_box.h" // Ui::hideLayer().
|
||||
#include "styles/style_layers.h"
|
||||
|
||||
namespace Lang {
|
||||
|
|
|
@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "webrtc/webrtc_create_adm.h" // Webrtc::Backend.
|
||||
#include "tgcalls/VideoCaptureInterface.h"
|
||||
#include "facades.h"
|
||||
#include "boxes/abstract_box.h" // Ui::hideLayer().
|
||||
#include "styles/style_layers.h"
|
||||
|
||||
namespace Settings {
|
||||
|
|
|
@ -32,6 +32,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "api/api_updates.h"
|
||||
#include "base/qt/qt_common_adapters.h"
|
||||
#include "base/custom_app_icon.h"
|
||||
#include "boxes/abstract_box.h" // Ui::show().
|
||||
|
||||
#include "zlib.h"
|
||||
|
||||
|
|
|
@ -8,10 +8,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/boxes/confirm_box.h"
|
||||
|
||||
#include "lang/lang_keys.h"
|
||||
#include "ui/widgets/checkbox.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "styles/style_layers.h"
|
||||
#include "styles/style_boxes.h"
|
||||
|
||||
namespace Ui {
|
||||
|
||||
|
@ -86,51 +84,4 @@ object_ptr<Ui::GenericBox> MakeInformBox(v::text::data text) {
|
|||
});
|
||||
}
|
||||
|
||||
ConfirmDontWarnBox::ConfirmDontWarnBox(
|
||||
QWidget*,
|
||||
rpl::producer<TextWithEntities> text,
|
||||
const QString &checkbox,
|
||||
rpl::producer<QString> confirm,
|
||||
FnMut<void(bool)> callback)
|
||||
: _confirm(std::move(confirm))
|
||||
, _content(setupContent(std::move(text), checkbox, std::move(callback))) {
|
||||
}
|
||||
|
||||
void ConfirmDontWarnBox::prepare() {
|
||||
setDimensionsToContent(st::boxWidth, _content);
|
||||
addButton(std::move(_confirm), [=] { _callback(); });
|
||||
addButton(tr::lng_cancel(), [=] { closeBox(); });
|
||||
}
|
||||
|
||||
not_null<Ui::RpWidget*> ConfirmDontWarnBox::setupContent(
|
||||
rpl::producer<TextWithEntities> text,
|
||||
const QString &checkbox,
|
||||
FnMut<void(bool)> callback) {
|
||||
const auto result = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||
result->add(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
result,
|
||||
std::move(text),
|
||||
st::boxLabel),
|
||||
st::boxPadding);
|
||||
const auto control = result->add(
|
||||
object_ptr<Ui::Checkbox>(
|
||||
result,
|
||||
checkbox,
|
||||
false,
|
||||
st::defaultBoxCheckbox),
|
||||
style::margins(
|
||||
st::boxPadding.left(),
|
||||
st::boxPadding.bottom(),
|
||||
st::boxPadding.right(),
|
||||
st::boxPadding.bottom()));
|
||||
_callback = [=, callback = std::move(callback)]() mutable {
|
||||
const auto checked = control->checked();
|
||||
auto local = std::move(callback);
|
||||
closeBox();
|
||||
local(checked);
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace Ui
|
||||
|
|
|
@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "boxes/abstract_box.h"
|
||||
#include "ui/layers/generic_box.h"
|
||||
#include "ui/text/text_variant.h"
|
||||
|
||||
|
@ -44,28 +43,4 @@ void ConfirmBox(not_null<Ui::GenericBox*> box, ConfirmBoxArgs &&args);
|
|||
ConfirmBoxArgs &&args);
|
||||
[[nodiscard]] object_ptr<Ui::GenericBox> MakeInformBox(v::text::data text);
|
||||
|
||||
class ConfirmDontWarnBox : public Ui::BoxContent {
|
||||
public:
|
||||
ConfirmDontWarnBox(
|
||||
QWidget*,
|
||||
rpl::producer<TextWithEntities> text,
|
||||
const QString &checkbox,
|
||||
rpl::producer<QString> confirm,
|
||||
FnMut<void(bool)> callback);
|
||||
|
||||
protected:
|
||||
void prepare() override;
|
||||
|
||||
private:
|
||||
not_null<Ui::RpWidget*> setupContent(
|
||||
rpl::producer<TextWithEntities> text,
|
||||
const QString &checkbox,
|
||||
FnMut<void(bool)> callback);
|
||||
|
||||
rpl::producer<QString> _confirm;
|
||||
FnMut<void()> _callback;
|
||||
not_null<Ui::RpWidget*> _content;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Ui
|
||||
|
|
Loading…
Add table
Reference in a new issue