mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-25 04:38:23 +00:00
Add call debug window on Ctrl+Click Show Info.
It is available only when debug logs are enabled.
This commit is contained in:
parent
96a0fcb28f
commit
0a6e012e90
@ -184,3 +184,7 @@ callRatingComment: InputField(defaultInputField) {
|
||||
heightMax: 135px;
|
||||
}
|
||||
callRatingCommentTop: 2px;
|
||||
|
||||
callDebugLabel: FlatLabel(defaultFlatLabel) {
|
||||
margin: margins(24px, 0px, 24px, 0px);
|
||||
}
|
||||
|
@ -225,6 +225,15 @@ void Call::redial() {
|
||||
_delegate->callRedial(this);
|
||||
}
|
||||
|
||||
QString Call::getDebugLog() const {
|
||||
constexpr auto kDebugLimit = 4096;
|
||||
auto bytes = base::byte_vector(kDebugLimit, gsl::byte {});
|
||||
_controller->GetDebugString(reinterpret_cast<char*>(bytes.data()), bytes.size());
|
||||
auto end = std::find(bytes.begin(), bytes.end(), gsl::byte {});
|
||||
auto size = (end - bytes.begin());
|
||||
return QString::fromUtf8(reinterpret_cast<const char*>(bytes.data()), size);
|
||||
}
|
||||
|
||||
void Call::startWaitingTrack() {
|
||||
_waitingTrack = Media::Audio::Current().createTrack();
|
||||
auto trackFileName = (_type == Type::Outgoing) ? qsl(":/sounds/call_outgoing.mp3") : qsl(":/sounds/call_incoming.mp3");
|
||||
|
@ -119,6 +119,8 @@ public:
|
||||
bool isKeyShaForFingerprintReady() const;
|
||||
std::array<gsl::byte, kSha256Size> getKeyShaForFingerprint() const;
|
||||
|
||||
QString getDebugLog() const;
|
||||
|
||||
~Call();
|
||||
|
||||
private:
|
||||
|
@ -26,8 +26,52 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||
#include "lang.h"
|
||||
#include "calls/calls_call.h"
|
||||
#include "calls/calls_instance.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "boxes/abstract_box.h"
|
||||
#include "base/timer.h"
|
||||
|
||||
namespace Calls {
|
||||
namespace {
|
||||
|
||||
constexpr auto kUpdateDebugTimeoutMs = TimeMs(500);
|
||||
|
||||
class DebugInfoBox : public BoxContent {
|
||||
public:
|
||||
DebugInfoBox(QWidget*, base::weak_unique_ptr<Call> call);
|
||||
|
||||
protected:
|
||||
void prepare() override;
|
||||
|
||||
private:
|
||||
void updateText();
|
||||
|
||||
base::weak_unique_ptr<Call> _call;
|
||||
QPointer<Ui::FlatLabel> _text;
|
||||
base::Timer _updateTextTimer;
|
||||
|
||||
};
|
||||
|
||||
DebugInfoBox::DebugInfoBox(QWidget*, base::weak_unique_ptr<Call> call) : _call(call) {
|
||||
}
|
||||
|
||||
void DebugInfoBox::prepare() {
|
||||
setTitle("Call Debug");
|
||||
addButton(lang(lng_close), [this] { closeBox(); });
|
||||
_text = setInnerWidget(object_ptr<Ui::FlatLabel>(this, st::callDebugLabel));
|
||||
_text->setSelectable(true);
|
||||
updateText();
|
||||
_updateTextTimer.setCallback([this] { updateText(); });
|
||||
_updateTextTimer.callEach(kUpdateDebugTimeoutMs);
|
||||
setDimensions(st::boxWideWidth, st::boxMaxListHeight);
|
||||
}
|
||||
|
||||
void DebugInfoBox::updateText() {
|
||||
if (auto call = _call.get()) {
|
||||
_text->setText(call->getDebugLog());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TopBar::TopBar(QWidget *parent, const base::weak_unique_ptr<Call> &call) : TWidget(parent)
|
||||
, _call(call)
|
||||
@ -52,7 +96,11 @@ void TopBar::initControls() {
|
||||
});
|
||||
_info->setClickedCallback([this] {
|
||||
if (auto call = _call.get()) {
|
||||
Current().showInfoPanel(call);
|
||||
if (cDebug() && (_info->clickModifiers() & Qt::ControlModifier)) {
|
||||
Ui::show(Box<DebugInfoBox>(_call));
|
||||
} else {
|
||||
Current().showInfoPanel(call);
|
||||
}
|
||||
}
|
||||
});
|
||||
_hangup->setClickedCallback([this] {
|
||||
|
Loading…
Reference in New Issue
Block a user