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