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).
This commit is contained in:
@@ -1,29 +1,40 @@
|
||||
#include "DebugPopup.hpp"
|
||||
#include "widgets/helper/DebugPopup.hpp"
|
||||
|
||||
#include "common/Literals.hpp"
|
||||
#include "util/Clipboard.hpp"
|
||||
#include "util/DebugCount.hpp"
|
||||
|
||||
#include <QFontDatabase>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QTimer>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
using namespace literals;
|
||||
|
||||
DebugPopup::DebugPopup()
|
||||
{
|
||||
auto *layout = new QHBoxLayout(this);
|
||||
auto *layout = new QVBoxLayout(this);
|
||||
auto *text = new QLabel(this);
|
||||
auto *timer = new QTimer(this);
|
||||
auto *copyButton = new QPushButton(u"&Copy"_s);
|
||||
|
||||
timer->setInterval(300);
|
||||
QObject::connect(timer, &QTimer::timeout, [text] {
|
||||
text->setText(DebugCount::getDebugText());
|
||||
});
|
||||
timer->start();
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user