diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 68c9bd4e5..dc7c1ee02 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -570,6 +570,8 @@ set(SOURCE_FILES widgets/dialogs/EditHotkeyDialog.hpp widgets/dialogs/EmotePopup.cpp widgets/dialogs/EmotePopup.hpp + widgets/dialogs/FontPicker.cpp + widgets/dialogs/FontPicker.hpp widgets/dialogs/LastRunCrashDialog.cpp widgets/dialogs/LastRunCrashDialog.hpp widgets/dialogs/LoginDialog.cpp diff --git a/src/controllers/commands/builtin/chatterino/Debugging.cpp b/src/controllers/commands/builtin/chatterino/Debugging.cpp index 2984aa9e9..c4316068e 100644 --- a/src/controllers/commands/builtin/chatterino/Debugging.cpp +++ b/src/controllers/commands/builtin/chatterino/Debugging.cpp @@ -9,6 +9,7 @@ #include "messages/MessageElement.hpp" #include "singletons/Theme.hpp" #include "util/PostToThread.hpp" +#include "widgets/dialogs/FontPicker.hpp" #include #include @@ -141,6 +142,10 @@ QString debugTest(const CommandContext &ctx) ctx.channel->addSystemMessage("debug-test called"); + FontPicker *fontPicker = new FontPicker; + + fontPicker->show(); + return ""; } diff --git a/src/widgets/dialogs/FontPicker.cpp b/src/widgets/dialogs/FontPicker.cpp new file mode 100644 index 000000000..46824e9c3 --- /dev/null +++ b/src/widgets/dialogs/FontPicker.cpp @@ -0,0 +1,61 @@ +#include "widgets/dialogs/FontPicker.hpp" + +#include +#include +#include +#include +#include +#include + +namespace { + +constexpr auto SAMPLE_POINT_SIZE = 12; + +} // namespace + +namespace chatterino { + +FontPicker::FontPicker() +{ + auto *layout = new QVBoxLayout(this); + + auto *fontList = new QListView(this); + layout->addWidget(fontList); + + auto *model = new QStringListModel(this); + auto *selectionModel = new QItemSelectionModel(model); + qInfo() << "font families:" + << QFontDatabase::families(QFontDatabase::WritingSystem::Latin); + QStringList fonts; + for (const auto &font : + QFontDatabase::families(QFontDatabase::WritingSystem::Latin)) + { + if (QFontDatabase::isPrivateFamily(font)) + { + continue; + } + + fonts << font; + } + model->setStringList(fonts); + + fontList->setModel(model); + fontList->setEditTriggers(QAbstractItemView::NoEditTriggers); + fontList->setSelectionModel(selectionModel); + + auto *sample = new QLabel(this); + sample->setText("forsen: This is some sample text xD"); + layout->addWidget(sample); + + QObject::connect( + selectionModel, &QItemSelectionModel::currentChanged, + [sample](const QModelIndex &selected, const QModelIndex &deselected) { + (void)deselected; + sample->setFont(QFontDatabase::font(selected.data().toString(), + "Normal", SAMPLE_POINT_SIZE)); + qInfo() << "clicked font xd" << selected.data(); + // selcetion changed? xd + }); +} + +} // namespace chatterino diff --git a/src/widgets/dialogs/FontPicker.hpp b/src/widgets/dialogs/FontPicker.hpp new file mode 100644 index 000000000..3d2d1cc6d --- /dev/null +++ b/src/widgets/dialogs/FontPicker.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include + +namespace chatterino { + +class FontPicker : public QDialog +{ +public: + FontPicker(); +}; + +} // namespace chatterino