ui: Delay font face laoding until combobox clicked to speed up preferences display time
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include "qt/utility/utilityQt.h"
|
#include "qt/utility/utilityQt.h"
|
||||||
#include "settings/ApplicationSettings.h"
|
#include "settings/ApplicationSettings.h"
|
||||||
@@ -45,11 +46,30 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row)
|
|||||||
addTitle("USER INTERFACE", layout, row);
|
addTitle("USER INTERFACE", layout, row);
|
||||||
|
|
||||||
// font face
|
// font face
|
||||||
m_fontFace = new QFontComboBox(this);
|
m_fontFacePlaceHolder = new QtComboBoxPlaceHolder();
|
||||||
m_fontFace->setFontFilters(QFontComboBox::MonospacedFonts);
|
m_fontFace = new QFontComboBox();
|
||||||
m_fontFace->setWritingSystem(QFontDatabase::Latin);
|
|
||||||
m_fontFace->setEditable(false);
|
m_fontFace->setEditable(false);
|
||||||
addLabelAndWidget("Font Face", m_fontFace, layout, row);
|
addLabelAndWidget("Font Face", m_fontFacePlaceHolder, layout, row);
|
||||||
|
|
||||||
|
int rowNum = row;
|
||||||
|
connect(m_fontFacePlaceHolder, &QtComboBoxPlaceHolder::opened,
|
||||||
|
[this, rowNum, layout]()
|
||||||
|
{
|
||||||
|
m_fontFacePlaceHolder->hide();
|
||||||
|
|
||||||
|
QString name = m_fontFace->currentText();
|
||||||
|
m_fontFace->setFontFilters(QFontComboBox::MonospacedFonts);
|
||||||
|
m_fontFace->setWritingSystem(QFontDatabase::Latin);
|
||||||
|
m_fontFace->setCurrentText(name);
|
||||||
|
|
||||||
|
addWidget(m_fontFace, layout, rowNum);
|
||||||
|
|
||||||
|
QTimer::singleShot(10, [this]()
|
||||||
|
{
|
||||||
|
m_fontFace->showPopup();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
row++;
|
row++;
|
||||||
|
|
||||||
// font size
|
// font size
|
||||||
@@ -359,7 +379,10 @@ void QtProjectWizzardContentPreferences::load()
|
|||||||
{
|
{
|
||||||
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
|
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
|
||||||
|
|
||||||
m_fontFace->setCurrentText(QString::fromStdString(appSettings->getFontName()));
|
QString fontName = QString::fromStdString(appSettings->getFontName());
|
||||||
|
m_fontFace->setCurrentText(fontName);
|
||||||
|
m_fontFacePlaceHolder->addItem(fontName);
|
||||||
|
m_fontFacePlaceHolder->setCurrentText(fontName);
|
||||||
|
|
||||||
m_fontSize->setCurrentIndex(appSettings->getFontSize() - appSettings->getFontSizeMin());
|
m_fontSize->setCurrentIndex(appSettings->getFontSize() - appSettings->getFontSizeMin());
|
||||||
m_tabWidth->setCurrentIndex(appSettings->getCodeTabWidth() - 1);
|
m_tabWidth->setCurrentIndex(appSettings->getCodeTabWidth() - 1);
|
||||||
@@ -695,13 +718,24 @@ void QtProjectWizzardContentPreferences::addTitle(QString title, QGridLayout* la
|
|||||||
layout->addWidget(createFormTitle(title), row++, QtProjectWizzardWindow::FRONT_COL, Qt::AlignLeft);
|
layout->addWidget(createFormTitle(title), row++, QtProjectWizzardWindow::FRONT_COL, Qt::AlignLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtProjectWizzardContentPreferences::addLabelAndWidget(
|
void QtProjectWizzardContentPreferences::addLabel(QString label, QGridLayout* layout, int row)
|
||||||
QString label, QWidget* widget, QGridLayout* layout, int& row, Qt::Alignment widgetAlignment)
|
|
||||||
{
|
{
|
||||||
layout->addWidget(createFormLabel(label), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
|
layout->addWidget(createFormLabel(label), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtProjectWizzardContentPreferences::addWidget(
|
||||||
|
QWidget* widget, QGridLayout* layout, int row, Qt::Alignment widgetAlignment)
|
||||||
|
{
|
||||||
layout->addWidget(widget, row, QtProjectWizzardWindow::BACK_COL, widgetAlignment);
|
layout->addWidget(widget, row, QtProjectWizzardWindow::BACK_COL, widgetAlignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtProjectWizzardContentPreferences::addLabelAndWidget(
|
||||||
|
QString label, QWidget* widget, QGridLayout* layout, int row, Qt::Alignment widgetAlignment)
|
||||||
|
{
|
||||||
|
addLabel(label, layout, row);
|
||||||
|
addWidget(widget, layout, row, widgetAlignment);
|
||||||
|
}
|
||||||
|
|
||||||
void QtProjectWizzardContentPreferences::addGap(QGridLayout* layout, int& row)
|
void QtProjectWizzardContentPreferences::addGap(QGridLayout* layout, int& row)
|
||||||
{
|
{
|
||||||
layout->setRowMinimumHeight(row++, 20);
|
layout->setRowMinimumHeight(row++, 20);
|
||||||
|
|||||||
@@ -1,18 +1,35 @@
|
|||||||
#ifndef QT_PROJECT_WIZZARD_CONTENT_PREFERENCES_H
|
#ifndef QT_PROJECT_WIZZARD_CONTENT_PREFERENCES_H
|
||||||
#define QT_PROJECT_WIZZARD_CONTENT_PREFERENCES_H
|
#define QT_PROJECT_WIZZARD_CONTENT_PREFERENCES_H
|
||||||
|
|
||||||
|
#include <QComboBox>
|
||||||
|
|
||||||
#include "qt/element/QtLocationPicker.h"
|
#include "qt/element/QtLocationPicker.h"
|
||||||
#include "qt/element/QtDirectoryListBox.h"
|
#include "qt/element/QtDirectoryListBox.h"
|
||||||
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
|
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
|
||||||
#include "utility/path_detector/CombinedPathDetector.h"
|
#include "utility/path_detector/CombinedPathDetector.h"
|
||||||
|
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
class QComboBox;
|
|
||||||
class QFontComboBox;
|
class QFontComboBox;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
|
|
||||||
|
|
||||||
|
class QtComboBoxPlaceHolder
|
||||||
|
: public QComboBox
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void opened();
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual void showPopup()
|
||||||
|
{
|
||||||
|
emit opened();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class QtProjectWizzardContentPreferences
|
class QtProjectWizzardContentPreferences
|
||||||
: public QtProjectWizzardContent
|
: public QtProjectWizzardContent
|
||||||
{
|
{
|
||||||
@@ -45,8 +62,10 @@ private:
|
|||||||
void addMavenPathDetection(QGridLayout* layout, int& row);
|
void addMavenPathDetection(QGridLayout* layout, int& row);
|
||||||
|
|
||||||
void addTitle(QString title, QGridLayout* layout, int& row);
|
void addTitle(QString title, QGridLayout* layout, int& row);
|
||||||
|
void addLabel(QString label, QGridLayout* layout, int row);
|
||||||
|
void addWidget(QWidget* widget, QGridLayout* layout, int row, Qt::Alignment widgetAlignment = Qt::Alignment());
|
||||||
void addLabelAndWidget(
|
void addLabelAndWidget(
|
||||||
QString label, QWidget* widget, QGridLayout* layout, int& row, Qt::Alignment widgetAlignment = Qt::Alignment());
|
QString label, QWidget* widget, QGridLayout* layout, int row, Qt::Alignment widgetAlignment = Qt::Alignment());
|
||||||
void addGap(QGridLayout* layout, int& row);
|
void addGap(QGridLayout* layout, int& row);
|
||||||
|
|
||||||
QCheckBox* addCheckBox(QString label, QString text, QString helpText, QGridLayout* layout, int& row);
|
QCheckBox* addCheckBox(QString label, QString text, QString helpText, QGridLayout* layout, int& row);
|
||||||
@@ -59,6 +78,8 @@ private:
|
|||||||
QLineEdit* addLineEdit(QString label, QString helpText, QGridLayout* layout, int& row);
|
QLineEdit* addLineEdit(QString label, QString helpText, QGridLayout* layout, int& row);
|
||||||
|
|
||||||
QFontComboBox* m_fontFace;
|
QFontComboBox* m_fontFace;
|
||||||
|
QtComboBoxPlaceHolder* m_fontFacePlaceHolder;
|
||||||
|
|
||||||
QComboBox* m_fontSize;
|
QComboBox* m_fontSize;
|
||||||
QComboBox* m_tabWidth;
|
QComboBox* m_tabWidth;
|
||||||
QComboBox* m_textEncoding;
|
QComboBox* m_textEncoding;
|
||||||
|
|||||||
Reference in New Issue
Block a user