Files
chatterino2/src/widgets/helper/DebugPopup.cpp
nerix 7ecbfa0cdb refactor: debug count and popup (#4921)
* Moved implementation of the methods to the `cpp` file.
* Added `DebugCount::Flag(s)` and `DebugCount::configure(name, flags)`.
* Moved from `QMap` to `std::map` (order is important here).
* Used `QStringBuilder` for concatenations.
* Used `QLocale` for formatting (adds separators).
* Added `DebugCount::Flag::DataSize` for data sizes in bytes (and fixed language to English).
* Used `DataSize` for image sizes (maybe this should be moved somewhere else?).
* Added copy button to popup.
* Fixed Image usage reporting being eight times too large (could be another PR, but honestly it's four characters).
2023-10-28 21:17:32 +02:00

41 lines
963 B
C++

#include "widgets/helper/DebugPopup.hpp"
#include "common/Literals.hpp"
#include "util/Clipboard.hpp"
#include "util/DebugCount.hpp"
#include <QFontDatabase>
#include <QLabel>
#include <QPushButton>
#include <QTimer>
#include <QVBoxLayout>
namespace chatterino {
using namespace literals;
DebugPopup::DebugPopup()
{
auto *layout = new QVBoxLayout(this);
auto *text = new QLabel(this);
auto *timer = new QTimer(this);
auto *copyButton = new QPushButton(u"&Copy"_s);
QObject::connect(timer, &QTimer::timeout, [text] {
text->setText(DebugCount::getDebugText());
});
timer->start(300);
text->setText(DebugCount::getDebugText());
text->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
layout->addWidget(text);
layout->addWidget(copyButton, 1);
QObject::connect(copyButton, &QPushButton::clicked, this, [text] {
crossPlatformCopy(text->text());
});
}
} // namespace chatterino