ui: filter monospace fonts
* relpaced onw construction with QFontComboBox * filter monospace font
This commit is contained in:
@@ -1,14 +1,8 @@
|
||||
#include "qt/element/QtFontPicker.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QFontDialog>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPainter>
|
||||
#include <QPushButton>
|
||||
#include <QStyleOption>
|
||||
#include <QComboBox>
|
||||
#include <QFontDatabase>
|
||||
#include <QFontComboBox>
|
||||
|
||||
#include "qt/element/QtLineEdit.h"
|
||||
|
||||
@@ -23,32 +17,13 @@ QtFontPicker::QtFontPicker(QWidget *parent)
|
||||
layout->setContentsMargins(1, 1, 1, 1);
|
||||
layout->setAlignment(Qt::AlignTop);
|
||||
|
||||
m_box = new QComboBox();
|
||||
QFontDatabase database;
|
||||
m_box->setFont(QFont("Roboto"));
|
||||
for( QString fam : database.families() )
|
||||
{
|
||||
m_box->addItem(fam);
|
||||
}
|
||||
m_box = new QFontComboBox();
|
||||
m_box->setFontFilters( QFontComboBox::MonospacedFonts );
|
||||
m_box->setEditable(false);
|
||||
|
||||
QLabel* sampleLabel = new QLabel("Font preview:");
|
||||
m_sampleLabel = new QLabel("AaBbCcXxYyZz");
|
||||
layout->addWidget(sampleLabel);
|
||||
layout->addWidget(m_sampleLabel);
|
||||
QBoxLayout* layout1 = new QVBoxLayout();
|
||||
layout1->addWidget(m_box);
|
||||
layout1->addLayout(layout);
|
||||
layout->addWidget(m_box);
|
||||
|
||||
connect(m_box, static_cast<void(QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
||||
[=](const QString &family)
|
||||
{
|
||||
if (!family.isEmpty())
|
||||
{
|
||||
m_sampleLabel->setFont(QFont(family));
|
||||
}
|
||||
});
|
||||
|
||||
setLayout(layout1);
|
||||
setLayout(layout);
|
||||
setSizePolicy(sizePolicy().horizontalPolicy(), QSizePolicy::Fixed);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,7 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QPushButton;
|
||||
class QtLineEdit;
|
||||
class QComboBox;
|
||||
class QLabel;
|
||||
class QFontComboBox;
|
||||
|
||||
class QtFontPicker
|
||||
: public QWidget
|
||||
@@ -22,8 +19,7 @@ public:
|
||||
void setText(QString text);
|
||||
|
||||
private:
|
||||
QLabel* m_sampleLabel;
|
||||
QComboBox* m_box;
|
||||
QFontComboBox* m_box;
|
||||
};
|
||||
|
||||
#endif // QT_FONT_PICKER_H
|
||||
|
||||
Reference in New Issue
Block a user