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_media_preview.cpp
window/window_media_preview.h
window/window_outdated_bar.cpp
window/window_outdated_bar.h
window/window_peer_menu.cpp
window/window_peer_menu.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:
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/buttons.h" // Ui::IconButton
@ -15,7 +15,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h"
#include "styles/style_window.h"
namespace Window {
#include <QtCore/QFile>
namespace Ui {
namespace {
#ifdef DESKTOP_APP_SPECIAL_TARGET
@ -23,22 +25,22 @@ constexpr auto kMinimalSkip = 7;
constexpr auto kSoonSkip = 30;
constexpr auto kNowSkip = 90;
class Bar : public Ui::RpWidget {
class Bar final : public RpWidget {
public:
Bar(not_null<QWidget*> parent, QDate date);
int resizeGetHeight(int newWidth) override;
rpl::producer<> hideClicks() const;
[[nodiscard]] rpl::producer<> hideClicks() const;
protected:
void paintEvent(QPaintEvent *e) override;
private:
QDate _date;
object_ptr<Ui::FlatLabel> _title;
object_ptr<Ui::FlatLabel> _details;
object_ptr<Ui::IconButton> _close;
object_ptr<FlatLabel> _title;
object_ptr<FlatLabel> _details;
object_ptr<IconButton> _close;
bool _soon = false;
};
@ -54,7 +56,7 @@ Bar::Bar(not_null<QWidget*> parent, QDate date)
: _date(date)
, _title(
this,
OutdatedReasonPhrase() | Ui::Text::ToUpper(),
OutdatedReasonPhrase() | Text::ToUpper(),
st::windowOutdatedTitle)
, _details(this,
QString(),
@ -97,12 +99,12 @@ void Bar::paintEvent(QPaintEvent *e) {
_soon ? st::outdateSoonBg : st::outdatedBg);
}
QString LastHiddenPath() {
return cWorkingDir() + qsl("tdata/outdated_hidden");
[[nodiscard]] QString LastHiddenPath(const QString &workingDir) {
return workingDir + u"tdata/outdated_hidden"_q;
}
[[nodiscard]] bool Skip(const QDate &date) {
auto file = QFile(LastHiddenPath());
[[nodiscard]] bool Skip(const QDate &date, const QString &workingDir) {
auto file = QFile(LastHiddenPath(workingDir));
if (!file.open(QIODevice::ReadOnly) || file.size() != sizeof(qint32)) {
return false;
}
@ -132,8 +134,8 @@ QString LastHiddenPath() {
}
}
void Closed() {
auto file = QFile(LastHiddenPath());
void Closed(const QString &workingDir) {
auto file = QFile(LastHiddenPath(workingDir));
if (!file.open(QIODevice::WriteOnly)) {
return;
}
@ -150,16 +152,18 @@ void Closed() {
} // 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
const auto date = Platform::WhenSystemBecomesOutdated();
if (date.isNull()) {
return { nullptr };
} else if (Skip(date)) {
} else if (Skip(date, workingPath)) {
return { nullptr };
}
auto result = object_ptr<Ui::SlideWrap<Bar>>(
auto result = object_ptr<SlideWrap<Bar>>(
parent.get(),
object_ptr<Bar>(parent.get(), date));
const auto wrap = result.data();
@ -167,7 +171,7 @@ object_ptr<Ui::RpWidget> CreateOutdatedBar(not_null<QWidget*> parent) {
wrap->entity()->hideClicks(
) | rpl::start_with_next([=] {
wrap->toggle(false, anim::type::normal);
Closed();
Closed(workingPath);
}, wrap->lifetime());
return result;
@ -176,4 +180,4 @@ object_ptr<Ui::RpWidget> CreateOutdatedBar(not_null<QWidget*> parent) {
#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"
namespace Ui {
class RpWidget;
[[nodiscard]] object_ptr<RpWidget> CreateOutdatedBar(
not_null<QWidget*> parent,
const QString &workingPath);
} // 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 "window/window_session_controller.h"
#include "window/window_lock_widgets.h"
#include "window/window_outdated_bar.h"
#include "window/window_controller.h"
#include "main/main_account.h" // Account::sessionValue.
#include "core/application.h"
@ -27,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/crc32hash.h"
#include "ui/toast/toast.h"
#include "ui/widgets/shadow.h"
#include "ui/controls/window_outdated_bar.h"
#include "ui/ui_utility.h"
#include "apiwrap.h"
#include "mainwindow.h"
@ -307,7 +307,7 @@ QImage WithSmallCounter(QImage image, CounterLayerArgs &&args) {
MainWindow::MainWindow(not_null<Controller*> controller)
: _controller(controller)
, _positionUpdatedTimer([=] { savePosition(); })
, _outdated(CreateOutdatedBar(body()))
, _outdated(Ui::CreateOutdatedBar(body(), cWorkingDir()))
, _body(body()) {
style::PaletteChanged(
) | rpl::start_with_next([=] {

View File

@ -204,6 +204,8 @@ PRIVATE
ui/controls/send_button.h
ui/controls/who_reacted_context_action.cpp
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.h
ui/text/format_values.cpp