代码拉取完成,页面将自动刷新
同步操作将从 zhangheyang/LVGLBuilder 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "LVGLFontDialog.h"
#include "ui_LVGLFontDialog.h"
#include <QSettings>
#include <QFile>
#include <QFileDialog>
LVGLFontDialog::LVGLFontDialog(QWidget *parent)
: QDialog(parent)
, m_ui(new Ui::LVGLFontDialog)
{
m_ui->setupUi(this);
// from https://www.qtcentre.org/threads/26924-Retrieve-the-filename-of-a-QFont
QSettings settings("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts", QSettings::NativeFormat);
QStringList list = settings.allKeys();
QString winPath = QString::fromUtf8(qgetenv("windir"));
for (int i = 0; i < list.size(); ++i) {
QString key = list.at(i);
QString text = settings.value(key).toString();
if (!text.endsWith(".ttf", Qt::CaseInsensitive))
continue;
QString fileName = winPath + "\\Fonts\\" + text;
if (!QFile(fileName).exists())
continue;
QStringList keys = key.split(" & ");
QString last = keys.last();
keys[keys.size()-1] = last.left(last.indexOf(" ("));
for(int j = 0; j < keys.size(); ++j) {
m_index.insert(keys[j], j);
m_name.insert(keys[j], fileName);
m_ui->list_font->addItem(keys[j]);
}
}
}
LVGLFontDialog::~LVGLFontDialog()
{
delete m_ui;
}
QString LVGLFontDialog::selectedFontPath() const
{
return m_ui->preview->text();
}
uint8_t LVGLFontDialog::selectedFontSize() const
{
return m_ui->spin_size->value() & 0xff;
}
uint8_t LVGLFontDialog::selectedBPP() const
{
if (m_ui->comboBox->currentIndex() == 0)
return 4;
else if (m_ui->comboBox->currentIndex() == 1)
return 2;
else
return 1;
}
void LVGLFontDialog::on_button_select_clicked()
{
QString fileName = QFileDialog::getOpenFileName(this, "Select font", "", "TTF Font (*.ttf)");
if (fileName.isEmpty())
return;
m_ui->preview->setText(fileName);
}
void LVGLFontDialog::on_list_font_currentTextChanged(const QString ¤tText)
{
m_ui->preview->setText(m_name[currentText]);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。