Move window_outdated_bar to td_ui subproject.

This commit is contained in:
John Preston 2022-02-22 15:50:19 +03:00
parent 280d79fecc
commit e4a7c01541
5 changed files with 33 additions and 29 deletions

View file

@ -1173,8 +1173,6 @@ PRIVATE
window/window_main_menu.h window/window_main_menu.h
window/window_media_preview.cpp window/window_media_preview.cpp
window/window_media_preview.h window/window_media_preview.h
window/window_outdated_bar.cpp
window/window_outdated_bar.h
window/window_peer_menu.cpp window/window_peer_menu.cpp
window/window_peer_menu.h window/window_peer_menu.h
window/window_section_common.h window/window_section_common.h

View file

@ -5,7 +5,7 @@ the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link: For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#include "window/window_outdated_bar.h" #include "ui/controls/window_outdated_bar.h"
#include "ui/widgets/labels.h" // Ui::FlatLabel #include "ui/widgets/labels.h" // Ui::FlatLabel
#include "ui/widgets/buttons.h" // Ui::IconButton #include "ui/widgets/buttons.h" // Ui::IconButton
@ -15,7 +15,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "styles/style_window.h" #include "styles/style_window.h"
namespace Window { #include <QtCore/QFile>
namespace Ui {
namespace { namespace {
#ifdef DESKTOP_APP_SPECIAL_TARGET #ifdef DESKTOP_APP_SPECIAL_TARGET
@ -23,22 +25,22 @@ constexpr auto kMinimalSkip = 7;
constexpr auto kSoonSkip = 30; constexpr auto kSoonSkip = 30;
constexpr auto kNowSkip = 90; constexpr auto kNowSkip = 90;
class Bar : public Ui::RpWidget { class Bar final : public RpWidget {
public: public:
Bar(not_null<QWidget*> parent, QDate date); Bar(not_null<QWidget*> parent, QDate date);
int resizeGetHeight(int newWidth) override; int resizeGetHeight(int newWidth) override;
rpl::producer<> hideClicks() const; [[nodiscard]] rpl::producer<> hideClicks() const;
protected: protected:
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
private: private:
QDate _date; QDate _date;
object_ptr<Ui::FlatLabel> _title; object_ptr<FlatLabel> _title;
object_ptr<Ui::FlatLabel> _details; object_ptr<FlatLabel> _details;
object_ptr<Ui::IconButton> _close; object_ptr<IconButton> _close;
bool _soon = false; bool _soon = false;
}; };
@ -54,7 +56,7 @@ Bar::Bar(not_null<QWidget*> parent, QDate date)
: _date(date) : _date(date)
, _title( , _title(
this, this,
OutdatedReasonPhrase() | Ui::Text::ToUpper(), OutdatedReasonPhrase() | Text::ToUpper(),
st::windowOutdatedTitle) st::windowOutdatedTitle)
, _details(this, , _details(this,
QString(), QString(),
@ -97,12 +99,12 @@ void Bar::paintEvent(QPaintEvent *e) {
_soon ? st::outdateSoonBg : st::outdatedBg); _soon ? st::outdateSoonBg : st::outdatedBg);
} }
QString LastHiddenPath() { [[nodiscard]] QString LastHiddenPath(const QString &workingDir) {
return cWorkingDir() + qsl("tdata/outdated_hidden"); return workingDir + u"tdata/outdated_hidden"_q;
} }
[[nodiscard]] bool Skip(const QDate &date) { [[nodiscard]] bool Skip(const QDate &date, const QString &workingDir) {
auto file = QFile(LastHiddenPath()); auto file = QFile(LastHiddenPath(workingDir));
if (!file.open(QIODevice::ReadOnly) || file.size() != sizeof(qint32)) { if (!file.open(QIODevice::ReadOnly) || file.size() != sizeof(qint32)) {
return false; return false;
} }
@ -132,8 +134,8 @@ QString LastHiddenPath() {
} }
} }
void Closed() { void Closed(const QString &workingDir) {
auto file = QFile(LastHiddenPath()); auto file = QFile(LastHiddenPath(workingDir));
if (!file.open(QIODevice::WriteOnly)) { if (!file.open(QIODevice::WriteOnly)) {
return; return;
} }
@ -150,16 +152,18 @@ void Closed() {
} // namespace } // namespace
object_ptr<Ui::RpWidget> CreateOutdatedBar(not_null<QWidget*> parent) { object_ptr<RpWidget> CreateOutdatedBar(
not_null<QWidget*> parent,
const QString &workingPath) {
#ifdef DESKTOP_APP_SPECIAL_TARGET #ifdef DESKTOP_APP_SPECIAL_TARGET
const auto date = Platform::WhenSystemBecomesOutdated(); const auto date = Platform::WhenSystemBecomesOutdated();
if (date.isNull()) { if (date.isNull()) {
return { nullptr }; return { nullptr };
} else if (Skip(date)) { } else if (Skip(date, workingPath)) {
return { nullptr }; return { nullptr };
} }
auto result = object_ptr<Ui::SlideWrap<Bar>>( auto result = object_ptr<SlideWrap<Bar>>(
parent.get(), parent.get(),
object_ptr<Bar>(parent.get(), date)); object_ptr<Bar>(parent.get(), date));
const auto wrap = result.data(); const auto wrap = result.data();
@ -167,7 +171,7 @@ object_ptr<Ui::RpWidget> CreateOutdatedBar(not_null<QWidget*> parent) {
wrap->entity()->hideClicks( wrap->entity()->hideClicks(
) | rpl::start_with_next([=] { ) | rpl::start_with_next([=] {
wrap->toggle(false, anim::type::normal); wrap->toggle(false, anim::type::normal);
Closed(); Closed(workingPath);
}, wrap->lifetime()); }, wrap->lifetime());
return result; return result;
@ -176,4 +180,4 @@ object_ptr<Ui::RpWidget> CreateOutdatedBar(not_null<QWidget*> parent) {
#endif // DESKTOP_APP_SPECIAL_TARGET #endif // DESKTOP_APP_SPECIAL_TARGET
} }
} // namespace Window } // namespace Ui

View file

@ -10,11 +10,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/object_ptr.h" #include "base/object_ptr.h"
namespace Ui { namespace Ui {
class RpWidget; class RpWidget;
[[nodiscard]] object_ptr<RpWidget> CreateOutdatedBar(
not_null<QWidget*> parent,
const QString &workingPath);
} // namespace Ui } // namespace Ui
namespace Window {
object_ptr<Ui::RpWidget> CreateOutdatedBar(not_null<QWidget*> parent);
} // namespace Window

View file

@ -15,7 +15,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history.h" #include "history/history.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "window/window_lock_widgets.h" #include "window/window_lock_widgets.h"
#include "window/window_outdated_bar.h"
#include "window/window_controller.h" #include "window/window_controller.h"
#include "main/main_account.h" // Account::sessionValue. #include "main/main_account.h" // Account::sessionValue.
#include "core/application.h" #include "core/application.h"
@ -27,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/crc32hash.h" #include "base/crc32hash.h"
#include "ui/toast/toast.h" #include "ui/toast/toast.h"
#include "ui/widgets/shadow.h" #include "ui/widgets/shadow.h"
#include "ui/controls/window_outdated_bar.h"
#include "ui/ui_utility.h" #include "ui/ui_utility.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "mainwindow.h" #include "mainwindow.h"
@ -307,7 +307,7 @@ QImage WithSmallCounter(QImage image, CounterLayerArgs &&args) {
MainWindow::MainWindow(not_null<Controller*> controller) MainWindow::MainWindow(not_null<Controller*> controller)
: _controller(controller) : _controller(controller)
, _positionUpdatedTimer([=] { savePosition(); }) , _positionUpdatedTimer([=] { savePosition(); })
, _outdated(CreateOutdatedBar(body())) , _outdated(Ui::CreateOutdatedBar(body(), cWorkingDir()))
, _body(body()) { , _body(body()) {
style::PaletteChanged( style::PaletteChanged(
) | rpl::start_with_next([=] { ) | rpl::start_with_next([=] {

View file

@ -204,6 +204,8 @@ PRIVATE
ui/controls/send_button.h ui/controls/send_button.h
ui/controls/who_reacted_context_action.cpp ui/controls/who_reacted_context_action.cpp
ui/controls/who_reacted_context_action.h ui/controls/who_reacted_context_action.h
ui/controls/window_outdated_bar.cpp
ui/controls/window_outdated_bar.h
ui/text/format_song_name.cpp ui/text/format_song_name.cpp
ui/text/format_song_name.h ui/text/format_song_name.h
ui/text/format_values.cpp ui/text/format_values.cpp