Files
allhaileris afb81b8278
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Close stale issues and PRs / stale (push) Successful in 13s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
init
2026-02-16 15:50:16 +03:00

82 lines
2.1 KiB
C++

// This file is part of Desktop App Toolkit,
// a set of libraries for developing nice desktop applications.
//
// For license and copyright information please follow this link:
// https://github.com/desktop-app/legal/blob/master/LEGAL
//
#pragma once
#include "base/weak_ptr.h"
#include "ui/layers/layer_widget.h"
struct TextWithEntities;
namespace anim {
enum class type : uchar;
} // namespace anim
namespace Ui::Toast {
struct Config;
class Instance;
} // namespace Ui::Toast
namespace Ui {
class BoxContent;
class LayerWidget;
inline constexpr auto kZOrderBasic = 0;
class Show {
public:
virtual ~Show() = 0;
virtual void showOrHideBoxOrLayer(
std::variant<
v::null_t,
object_ptr<BoxContent>,
std::unique_ptr<LayerWidget>> &&layer,
LayerOptions options,
anim::type animated) const = 0;
[[nodiscard]] virtual not_null<QWidget*> toastParent() const = 0;
[[nodiscard]] virtual bool valid() const = 0;
virtual operator bool() const = 0;
void showBox(
object_ptr<BoxContent> content,
LayerOptions options = LayerOption::KeepOther,
anim::type animated = anim::type()) const;
void showLayer(
std::unique_ptr<LayerWidget> layer,
LayerOptions options = LayerOption::KeepOther,
anim::type animated = anim::type()) const;
void hideLayer(anim::type animated = anim::type()) const;
base::weak_ptr<Toast::Instance> showToast(Toast::Config &&config) const;
base::weak_ptr<Toast::Instance> showToast(
TextWithEntities &&text,
crl::time duration = 0) const;
base::weak_ptr<Toast::Instance> showToast(
const QString &text,
crl::time duration = 0) const;
template <
typename BoxType,
typename = std::enable_if_t<std::is_base_of_v<BoxContent, BoxType>>>
base::weak_qptr<BoxType> show(
object_ptr<BoxType> content,
LayerOptions options = LayerOption::KeepOther,
anim::type animated = anim::type()) const {
auto result = base::weak_qptr<BoxType>(content.data());
showBox(std::move(content), options, animated);
return result;
}
private:
mutable base::weak_ptr<Toast::Instance> _lastToast;
};
inline Show::~Show() = default;
} // namespace Ui