7ecbfa0cdb
* 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).
41 lines
963 B
C++
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
|