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:
nerix
2023-10-28 21:17:32 +02:00
committed by GitHub
parent 5c0219c245
commit 7ecbfa0cdb
5 changed files with 151 additions and 98 deletions
+16 -5
View File
@@ -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