mirror of https://github.com/procxx/kepka.git
Move UnreadBadge to ui/unread_badge.
This commit is contained in:
parent
defec611e3
commit
656e4869e6
|
@ -37,9 +37,9 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
#include "auth_session.h"
|
#include "auth_session.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "ui/special_buttons.h"
|
#include "ui/special_buttons.h"
|
||||||
|
#include "ui/unread_badge.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/dropdown_menu.h"
|
#include "ui/widgets/dropdown_menu.h"
|
||||||
#include "dialogs/dialogs_layout.h"
|
|
||||||
#include "window/window_controller.h"
|
#include "window/window_controller.h"
|
||||||
#include "window/window_peer_menu.h"
|
#include "window/window_peer_menu.h"
|
||||||
#include "calls/calls_instance.h"
|
#include "calls/calls_instance.h"
|
||||||
|
@ -47,44 +47,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
#include "observer_peer.h"
|
#include "observer_peer.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
|
|
||||||
class HistoryTopBarWidget::UnreadBadge : public Ui::RpWidget {
|
|
||||||
public:
|
|
||||||
using RpWidget::RpWidget;
|
|
||||||
|
|
||||||
void setText(const QString &text, bool active) {
|
|
||||||
_text = text;
|
|
||||||
_active = active;
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void paintEvent(QPaintEvent *e) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString _text;
|
|
||||||
bool _active = false;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
void HistoryTopBarWidget::UnreadBadge::paintEvent(QPaintEvent *e) {
|
|
||||||
if (_text.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Painter p(this);
|
|
||||||
|
|
||||||
Dialogs::Layout::UnreadBadgeStyle unreadSt;
|
|
||||||
unreadSt.muted = !_active;
|
|
||||||
auto unreadRight = width();
|
|
||||||
auto unreadTop = 0;
|
|
||||||
Dialogs::Layout::paintUnreadCount(
|
|
||||||
p,
|
|
||||||
_text,
|
|
||||||
unreadRight,
|
|
||||||
unreadTop,
|
|
||||||
unreadSt);
|
|
||||||
}
|
|
||||||
|
|
||||||
HistoryTopBarWidget::HistoryTopBarWidget(
|
HistoryTopBarWidget::HistoryTopBarWidget(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
not_null<Window::Controller*> controller)
|
not_null<Window::Controller*> controller)
|
||||||
|
|
|
@ -28,6 +28,7 @@ class UserpicButton;
|
||||||
class RoundButton;
|
class RoundButton;
|
||||||
class IconButton;
|
class IconButton;
|
||||||
class DropdownMenu;
|
class DropdownMenu;
|
||||||
|
class UnreadBadge;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
|
@ -69,8 +70,6 @@ protected:
|
||||||
bool eventFilter(QObject *obj, QEvent *e) override;
|
bool eventFilter(QObject *obj, QEvent *e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class UnreadBadge;
|
|
||||||
|
|
||||||
void refreshLang();
|
void refreshLang();
|
||||||
void updateControlsGeometry();
|
void updateControlsGeometry();
|
||||||
void selectedShowCallback();
|
void selectedShowCallback();
|
||||||
|
@ -113,7 +112,7 @@ private:
|
||||||
object_ptr<Ui::RoundButton> _forward, _delete;
|
object_ptr<Ui::RoundButton> _forward, _delete;
|
||||||
|
|
||||||
object_ptr<Ui::IconButton> _back;
|
object_ptr<Ui::IconButton> _back;
|
||||||
object_ptr<UnreadBadge> _unreadBadge = { nullptr };
|
object_ptr<Ui::UnreadBadge> _unreadBadge = { nullptr };
|
||||||
object_ptr<Ui::UserpicButton> _info = { nullptr };
|
object_ptr<Ui::UserpicButton> _info = { nullptr };
|
||||||
|
|
||||||
object_ptr<Ui::IconButton> _call;
|
object_ptr<Ui::IconButton> _call;
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
||||||
|
|
||||||
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
It is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
In addition, as a special exception, the copyright holders give permission
|
||||||
|
to link the code of portions of this program with the OpenSSL library.
|
||||||
|
|
||||||
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
||||||
|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
|
*/
|
||||||
|
#include "ui/unread_badge.h"
|
||||||
|
|
||||||
|
#include "dialogs/dialogs_layout.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
|
||||||
|
void UnreadBadge::setText(const QString &text, bool active) {
|
||||||
|
_text = text;
|
||||||
|
_active = active;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UnreadBadge::paintEvent(QPaintEvent *e) {
|
||||||
|
if (_text.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Painter p(this);
|
||||||
|
|
||||||
|
Dialogs::Layout::UnreadBadgeStyle unreadSt;
|
||||||
|
unreadSt.muted = !_active;
|
||||||
|
auto unreadRight = width();
|
||||||
|
auto unreadTop = 0;
|
||||||
|
Dialogs::Layout::paintUnreadCount(
|
||||||
|
p,
|
||||||
|
_text,
|
||||||
|
unreadRight,
|
||||||
|
unreadTop,
|
||||||
|
unreadSt);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Ui
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
||||||
|
|
||||||
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
It is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
In addition, as a special exception, the copyright holders give permission
|
||||||
|
to link the code of portions of this program with the OpenSSL library.
|
||||||
|
|
||||||
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
||||||
|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "ui/rp_widget.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
|
||||||
|
class UnreadBadge : public RpWidget {
|
||||||
|
public:
|
||||||
|
using RpWidget::RpWidget;
|
||||||
|
|
||||||
|
void setText(const QString &text, bool active);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString _text;
|
||||||
|
bool _active = false;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Ui
|
|
@ -622,6 +622,8 @@
|
||||||
<(src_loc)/ui/special_buttons.h
|
<(src_loc)/ui/special_buttons.h
|
||||||
<(src_loc)/ui/twidget.cpp
|
<(src_loc)/ui/twidget.cpp
|
||||||
<(src_loc)/ui/twidget.h
|
<(src_loc)/ui/twidget.h
|
||||||
|
<(src_loc)/ui/unread_badge.cpp
|
||||||
|
<(src_loc)/ui/unread_badge.h
|
||||||
<(src_loc)/window/layer_widget.cpp
|
<(src_loc)/window/layer_widget.cpp
|
||||||
<(src_loc)/window/layer_widget.h
|
<(src_loc)/window/layer_widget.h
|
||||||
<(src_loc)/window/main_window.cpp
|
<(src_loc)/window/main_window.cpp
|
||||||
|
|
Loading…
Reference in New Issue