mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Implement some power saving options.
This commit is contained in:
@@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "info/profile/info_profile_values.h"
|
||||
#include "boxes/peers/edit_participants_box.h"
|
||||
#include "boxes/peers/edit_peer_info_box.h"
|
||||
#include "settings/settings_power_saving.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "main/main_session.h"
|
||||
@@ -42,6 +43,11 @@ namespace {
|
||||
constexpr auto kSlowmodeValues = 7;
|
||||
constexpr auto kSuggestGigagroupThreshold = 199000;
|
||||
|
||||
[[nodiscard]] auto Dependencies(PowerSaving::Flags)
|
||||
-> std::vector<std::pair<PowerSaving::Flag, PowerSaving::Flag>> {
|
||||
return {};
|
||||
}
|
||||
|
||||
struct NestedRestrictionLabels {
|
||||
std::optional<rpl::producer<QString>> nestedLabel;
|
||||
std::vector<RestrictionLabel> restrictionLabels;
|
||||
@@ -194,7 +200,6 @@ auto Dependencies(ChatRestrictions)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
ChatRestrictions NegateRestrictions(ChatRestrictions value) {
|
||||
using Flag = ChatRestriction;
|
||||
|
||||
@@ -473,13 +478,14 @@ template <
|
||||
ApplyDependencies(state->checkViews, dependencies, view);
|
||||
};
|
||||
|
||||
container->add(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
container,
|
||||
std::move(header),
|
||||
st::rightsHeaderLabel),
|
||||
st::rightsHeaderMargin);
|
||||
|
||||
if (header) {
|
||||
container->add(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
container,
|
||||
std::move(header),
|
||||
st::rightsHeaderLabel),
|
||||
st::rightsHeaderMargin);
|
||||
}
|
||||
const auto addCheckbox = [&](
|
||||
not_null<Ui::VerticalLayout*> verticalLayout,
|
||||
bool isInner,
|
||||
@@ -1131,3 +1137,18 @@ ChatAdminRights AdminRightsForOwnershipTransfer(
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
EditFlagsControl<PowerSaving::Flags, Ui::RpWidget> CreateEditPowerSaving(
|
||||
QWidget *parent,
|
||||
PowerSaving::Flags flags) {
|
||||
auto widget = object_ptr<Ui::VerticalLayout>(parent);
|
||||
auto result = CreateEditFlags(
|
||||
widget.data(),
|
||||
nullptr,
|
||||
flags,
|
||||
std::map<PowerSaving::Flags, QString>{},
|
||||
Settings::PowerSavingLabelsList());
|
||||
result.widget = std::move(widget);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@@ -16,6 +16,11 @@ class RpWidget;
|
||||
class VerticalLayout;
|
||||
} // namespace Ui
|
||||
|
||||
namespace PowerSaving {
|
||||
enum Flag : uint32;
|
||||
using Flags = base::flags<Flag>;
|
||||
} // namespace PowerSaving
|
||||
|
||||
template <typename Object>
|
||||
class object_ptr;
|
||||
|
||||
@@ -82,3 +87,8 @@ struct EditFlagsControl {
|
||||
ChatRestrictions restrictions);
|
||||
[[nodiscard]] ChatAdminRights AdminRightsForOwnershipTransfer(
|
||||
Data::AdminRightsSetOptions options);
|
||||
|
||||
[[nodiscard]] auto CreateEditPowerSaving(
|
||||
QWidget *parent,
|
||||
PowerSaving::Flags flags
|
||||
) -> EditFlagsControl<PowerSaving::Flags, Ui::RpWidget>;
|
||||
|
@@ -32,6 +32,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/effects/path_shift_gradient.h"
|
||||
#include "ui/emoji_config.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/power_saving.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "ui/widgets/popup_menu.h"
|
||||
#include "ui/cached_round_corners.h"
|
||||
@@ -1125,8 +1126,8 @@ void StickerSetBox::Inner::paintEvent(QPaintEvent *e) {
|
||||
_pathGradient->startFrame(0, width(), width() / 2);
|
||||
|
||||
const auto now = crl::now();
|
||||
const auto paused = _controller->isGifPausedAtLeastFor(
|
||||
Window::GifPauseReason::Layer);
|
||||
const auto paused = On(PowerSaving::kStickersPanel)
|
||||
|| _controller->isGifPausedAtLeastFor(Window::GifPauseReason::Layer);
|
||||
for (int32 i = from; i < to; ++i) {
|
||||
for (int32 j = 0; j < _perRow; ++j) {
|
||||
int32 index = i * _perRow + j;
|
||||
|
Reference in New Issue
Block a user