mirror of
https://github.com/uowuo/abaddon.git
synced 2024-11-10 06:00:10 +00:00
hide progress bar when not actually mid-upload
This commit is contained in:
parent
4bca973a21
commit
8324172a90
@ -5,7 +5,7 @@
|
||||
#include "chatlist.hpp"
|
||||
#include "constants.hpp"
|
||||
#ifdef WITH_LIBHANDY
|
||||
#include "channeltabswitcherhandy.hpp"
|
||||
#include "channeltabswitcherhandy.hpp"
|
||||
#endif
|
||||
|
||||
ChatWindow::ChatWindow() {
|
||||
@ -109,7 +109,13 @@ ChatWindow::ChatWindow() {
|
||||
m_main->add(*m_meta);
|
||||
m_main->add(m_progress);
|
||||
|
||||
m_progress.show();
|
||||
m_progress.signal_start().connect([this]() {
|
||||
m_progress.show();
|
||||
});
|
||||
|
||||
m_progress.signal_stop().connect([this]() {
|
||||
m_progress.hide();
|
||||
});
|
||||
|
||||
m_main->show();
|
||||
}
|
||||
|
@ -5,12 +5,19 @@ MessageUploadProgressBar::MessageUploadProgressBar() {
|
||||
auto &discord = Abaddon::Get().GetDiscordClient();
|
||||
discord.signal_message_progress().connect([this](const std::string &nonce, float percent) {
|
||||
if (nonce == m_last_nonce) {
|
||||
if (!m_active) {
|
||||
m_active = true;
|
||||
m_signal_start.emit();
|
||||
}
|
||||
set_fraction(percent);
|
||||
}
|
||||
});
|
||||
discord.signal_message_send_fail().connect([this](const std::string &nonce, float) {
|
||||
if (nonce == m_last_nonce)
|
||||
if (nonce == m_last_nonce) {
|
||||
set_fraction(0.0);
|
||||
m_active = false;
|
||||
m_signal_stop.emit();
|
||||
}
|
||||
});
|
||||
discord.signal_message_create().connect([this](const Message &msg) {
|
||||
if (msg.IsPending) {
|
||||
@ -18,6 +25,16 @@ MessageUploadProgressBar::MessageUploadProgressBar() {
|
||||
} else if (msg.Nonce.has_value() && (*msg.Nonce == m_last_nonce)) {
|
||||
m_last_nonce = "";
|
||||
set_fraction(0.0);
|
||||
m_active = false;
|
||||
m_signal_stop.emit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
MessageUploadProgressBar::type_signal_start MessageUploadProgressBar::signal_start() {
|
||||
return m_signal_start;
|
||||
}
|
||||
|
||||
MessageUploadProgressBar::type_signal_stop MessageUploadProgressBar::signal_stop() {
|
||||
return m_signal_stop;
|
||||
}
|
||||
|
@ -6,5 +6,16 @@ public:
|
||||
MessageUploadProgressBar();
|
||||
|
||||
private:
|
||||
bool m_active = false;
|
||||
std::string m_last_nonce;
|
||||
|
||||
using type_signal_start = sigc::signal<void()>;
|
||||
using type_signal_stop = sigc::signal<void()>;
|
||||
|
||||
type_signal_start m_signal_start;
|
||||
type_signal_stop m_signal_stop;
|
||||
|
||||
public:
|
||||
type_signal_start signal_start();
|
||||
type_signal_stop signal_stop();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user