mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 13:47:05 +02:00
Don't show Downloads if it's empty in search.
This commit is contained in:
parent
44bfdbdc83
commit
c3e15de759
4 changed files with 37 additions and 12 deletions
|
@ -124,6 +124,15 @@ DownloadManager::DownloadManager()
|
|||
|
||||
DownloadManager::~DownloadManager() = default;
|
||||
|
||||
bool DownloadManager::empty() const {
|
||||
for (const auto &[session, data] : _sessions) {
|
||||
if (!data.downloading.empty() || !data.downloaded.empty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void DownloadManager::trackSession(not_null<Main::Session*> session) {
|
||||
auto &data = _sessions.emplace(session, SessionData()).first->second;
|
||||
data.downloaded = deserialize(session);
|
||||
|
|
|
@ -80,6 +80,8 @@ public:
|
|||
DownloadManager();
|
||||
~DownloadManager();
|
||||
|
||||
[[nodiscard]] bool empty() const;
|
||||
|
||||
void trackSession(not_null<Main::Session*> session);
|
||||
void itemVisibilitiesUpdated(not_null<Main::Session*> session);
|
||||
|
||||
|
|
|
@ -12,11 +12,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "base/unixtime.h"
|
||||
#include "base/qt/qt_key_modifiers.h"
|
||||
#include "boxes/peer_list_box.h"
|
||||
#include "core/application.h"
|
||||
#include "data/components/recent_peers.h"
|
||||
#include "data/components/top_peers.h"
|
||||
#include "data/data_changes.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_download_manager.h"
|
||||
#include "data/data_folder.h"
|
||||
#include "data/data_peer_values.h"
|
||||
#include "data/data_session.h"
|
||||
|
@ -1305,18 +1307,7 @@ Suggestions::Suggestions(
|
|||
, _tabs(
|
||||
_tabsScroll->setOwnedWidget(
|
||||
object_ptr<Ui::SettingsSlider>(this, st::dialogsSearchTabs)))
|
||||
, _tabKeys{
|
||||
{ Tab::Chats },
|
||||
{ Tab::Channels },
|
||||
{ Tab::Apps },
|
||||
{ Tab::Media, MediaType::Photo },
|
||||
{ Tab::Media, MediaType::Video },
|
||||
{ Tab::Downloads },
|
||||
{ Tab::Media, MediaType::Link },
|
||||
{ Tab::Media, MediaType::File },
|
||||
{ Tab::Media, MediaType::MusicFile },
|
||||
{ Tab::Media, MediaType::RoundVoiceFile },
|
||||
}
|
||||
, _tabKeys(TabKeysFor(controller))
|
||||
, _chatsScroll(std::make_unique<Ui::ElasticScroll>(this))
|
||||
, _chatsContent(
|
||||
_chatsScroll->setOwnedWidget(object_ptr<Ui::VerticalLayout>(this)))
|
||||
|
@ -1987,6 +1978,26 @@ float64 Suggestions::shownOpacity() const {
|
|||
return _shownAnimation.value(_hidden ? 0. : 1.);
|
||||
}
|
||||
|
||||
std::vector<Suggestions::Key> Suggestions::TabKeysFor(
|
||||
not_null<Window::SessionController*> controller) {
|
||||
auto result = std::vector<Key>{
|
||||
{ Tab::Chats },
|
||||
{ Tab::Channels },
|
||||
{ Tab::Apps },
|
||||
{ Tab::Media, MediaType::Photo },
|
||||
{ Tab::Media, MediaType::Video },
|
||||
{ Tab::Downloads },
|
||||
{ Tab::Media, MediaType::Link },
|
||||
{ Tab::Media, MediaType::File },
|
||||
{ Tab::Media, MediaType::MusicFile },
|
||||
{ Tab::Media, MediaType::RoundVoiceFile },
|
||||
};
|
||||
if (Core::App().downloadManager().empty()) {
|
||||
result.erase(ranges::find(result, Key{ Tab::Downloads }));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void Suggestions::paintEvent(QPaintEvent *e) {
|
||||
const auto opacity = shownOpacity();
|
||||
auto color = st::windowBg->c;
|
||||
|
|
|
@ -147,6 +147,9 @@ private:
|
|||
rpl::variable<int> count;
|
||||
};
|
||||
|
||||
[[nodiscard]] static std::vector<Key> TabKeysFor(
|
||||
not_null<Window::SessionController*> controller);
|
||||
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue