init
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
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
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
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
81
Telegram/lib_ui/ui/widgets/time_input.h
Normal file
81
Telegram/lib_ui/ui/widgets/time_input.h
Normal file
@@ -0,0 +1,81 @@
|
||||
// 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 "ui/rp_widget.h"
|
||||
|
||||
#include "ui/effects/animations.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
|
||||
namespace Ui {
|
||||
|
||||
class TimePart;
|
||||
|
||||
class TimeInput final : public RpWidget {
|
||||
public:
|
||||
TimeInput(
|
||||
QWidget *parent,
|
||||
const QString &value,
|
||||
const style::InputField &stField,
|
||||
const style::InputField &stDateField,
|
||||
const style::FlatLabel &stSeparator,
|
||||
const style::margins &stSeparatorPadding);
|
||||
|
||||
bool setFocusFast();
|
||||
[[nodiscard]] rpl::producer<QString> value() const;
|
||||
[[nodiscard]] rpl::producer<> submitRequests() const;
|
||||
[[nodiscard]] rpl::producer<> focuses() const;
|
||||
[[nodiscard]] QString valueCurrent() const;
|
||||
void showError();
|
||||
|
||||
int resizeGetHeight(int width) override;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void mousePressEvent(QMouseEvent *e) override;
|
||||
void mouseMoveEvent(QMouseEvent *e) override;
|
||||
|
||||
private:
|
||||
void setInnerFocus();
|
||||
void putNext(const object_ptr<TimePart> &field, QChar ch);
|
||||
void erasePrevious(const object_ptr<TimePart> &field);
|
||||
void setFocusQueued(const object_ptr<TimePart> &field);
|
||||
void setErrorShown(bool error);
|
||||
void setFocused(bool focused);
|
||||
void startBorderAnimation();
|
||||
template <typename Widget>
|
||||
bool insideSeparator(QPoint position, const Widget &widget) const;
|
||||
|
||||
[[nodiscard]] std::optional<int> hour() const;
|
||||
[[nodiscard]] std::optional<int> minute() const;
|
||||
|
||||
const style::InputField &_stField;
|
||||
const style::InputField &_stDateField;
|
||||
const style::FlatLabel &_stSeparator;
|
||||
const style::margins &_stSeparatorPadding;
|
||||
|
||||
object_ptr<TimePart> _hour;
|
||||
object_ptr<PaddingWrap<FlatLabel>> _separator1;
|
||||
object_ptr<TimePart> _minute;
|
||||
rpl::variable<QString> _value;
|
||||
rpl::event_stream<> _submitRequests;
|
||||
rpl::event_stream<> _focuses;
|
||||
|
||||
style::cursor _cursor = style::cur_default;
|
||||
Animations::Simple _a_borderShown;
|
||||
int _borderAnimationStart = 0;
|
||||
Animations::Simple _a_borderOpacity;
|
||||
bool _borderVisible = false;
|
||||
|
||||
Animations::Simple _a_error;
|
||||
bool _error = false;
|
||||
Animations::Simple _a_focused;
|
||||
bool _focused = false;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Ui
|
||||
Reference in New Issue
Block a user