Skip to content

Commit

Permalink
Prevent fonts from loading before main
Browse files Browse the repository at this point in the history
  • Loading branch information
Cubitect committed Nov 13, 2022
1 parent 7419920 commit 996ce9b
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/conditiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ ConditionDialog::ConditionDialog(FormConditions *parent, Config *config, int mcv
QString mcs = tr("MC %1", "Minecraft version").arg(p_mcs ? p_mcs : "?");
ui->labelMC->setText(mcs);

ui->lineSummary->setFont(g_font_mono);
ui->lineSummary->setFont(*gp_font_mono);

// prevent bold font of group box title getting inherited
QFont dfont = font();
Expand Down
2 changes: 1 addition & 1 deletion src/configdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ConfigDialog::ConfigDialog(QWidget *parent, Config *config)
}
#endif

ui->buttonBiomeColor->setFont(g_font_mono);
ui->buttonBiomeColor->setFont(*gp_font_mono);

ui->lineMatching->setValidator(new QIntValidator(1, 99999999, ui->lineMatching));

Expand Down
2 changes: 1 addition & 1 deletion src/formconditions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ FormConditions::FormConditions(QWidget *parent)
qRegisterMetaType< Condition >("Condition");
qRegisterMetaTypeStreamOperators< Condition >("Condition");

ui->listConditionsFull->setFont(g_font_mono);
ui->listConditionsFull->setFont(*gp_font_mono);
}

FormConditions::~FormConditions()
Expand Down
2 changes: 1 addition & 1 deletion src/formgen48.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ FormGen48::FormGen48(MainWindow *parent)
connect(ui->lineSalt, SIGNAL(editingFinished()), SLOT(onChange()));
connect(ui->lineListSalt, SIGNAL(editingFinished()), SLOT(onChange()));

ui->lineList48->setFont(g_font_mono);
ui->lineList48->setFont(*gp_font_mono);

cond.type = 0;
Gen48Settings defaults;
Expand Down
11 changes: 6 additions & 5 deletions src/formsearchcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,17 @@ FormSearchControl::FormSearchControl(MainWindow *parent)
ui->setupUi(this);
protodialog = new ProtoBaseDialog(this);

ui->results->setFont(g_font_mono);
ui->progressBar->setFont(g_font_mono);
ui->labelStatus->setFont(g_font_mono);
QFont mono = *gp_font_mono;
ui->results->setFont(mono);
ui->progressBar->setFont(mono);
ui->labelStatus->setFont(mono);

proxy->setSourceModel(model);
ui->results->setModel(proxy);

ui->results->horizontalHeader()->setFont(g_font_mono);
ui->results->horizontalHeader()->setFont(mono);
ui->results->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);
ui->results->verticalHeader()->setDefaultSectionSize(QFontMetrics(g_font_mono).height());
ui->results->verticalHeader()->setDefaultSectionSize(QFontMetrics(mono).height());
ui->results->setColumnWidth(SeedTableModel::COL_SEED, 200);
ui->results->setColumnWidth(SeedTableModel::COL_TOP16, 60);
ui->results->setColumnWidth(SeedTableModel::COL_HEX48, 120);
Expand Down
17 changes: 10 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ unsigned char g_tempsColors[256][3];

ExtGenSettings g_extgen;

QFont g_font_default;
QFont g_font_mono;
QFont *gp_font_default;
QFont *gp_font_mono;

extern "C"
int getStructureConfig_override(int stype, int mc, StructureConfig *sconf)
Expand Down Expand Up @@ -53,12 +53,15 @@ int main(int argc, char *argv[])
QFontDatabase::addApplicationFont(":/fonts/DejaVuSans-Bold.ttf");
int fontid_mono = QFontDatabase::addApplicationFont(":/fonts/DejaVuSansMono.ttf");

g_font_default = QFontDatabase::applicationFontFamilies(fontid).at(0);
g_font_default.setPointSize(10);
g_font_mono = QFontDatabase::applicationFontFamilies(fontid_mono).at(0);
g_font_mono.setPointSize(9);
static QFont font_default = QFontDatabase::applicationFontFamilies(fontid).at(0);
font_default.setPointSize(10);
static QFont font_mono = QFontDatabase::applicationFontFamilies(fontid_mono).at(0);
font_mono.setPointSize(9);

app.setFont(g_font_default);
app.setFont(font_default);

gp_font_default = &font_default;
gp_font_mono = &font_mono;
}

MainWindow mw;
Expand Down
5 changes: 3 additions & 2 deletions src/mapview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ MapView::MapView(QWidget *parent)
{
memset(sshow, 0, sizeof(sshow));

setFont(g_font_mono);
QFont mono = *gp_font_mono;
setFont(mono);

QPalette pal = palette();
pal.setColor(QPalette::Background, Qt::black);
Expand All @@ -65,7 +66,7 @@ MapView::MapView(QWidget *parent)

overlay = new MapOverlay(this);
overlay->setMouseTracking(true);
overlay->setFont(g_font_mono);
overlay->setFont(mono);

setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
Expand Down
2 changes: 1 addition & 1 deletion src/presetdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ PresetDialog::PresetDialog(QWidget *parent, WorldInfo wi, bool showEamples)
connect(ui->buttonOk, &QPushButton::clicked, this, &QDialog::accept);
connect(ui->buttonCancel, &QPushButton::clicked, this, &QDialog::reject);

ui->listFilters->setFont(g_font_mono);
ui->listFilters->setFont(*gp_font_mono);

if (showEamples)
ui->tabWidget->setCurrentWidget(ui->tabExamples);
Expand Down
4 changes: 2 additions & 2 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ struct ExtGenSettings
extern ExtGenSettings g_extgen;

// global references to the default fonts
extern QFont g_font_default;
extern QFont g_font_mono;
extern QFont *gp_font_default;
extern QFont *gp_font_mono;

struct WorldInfo
{
Expand Down
2 changes: 1 addition & 1 deletion src/tabbiomes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ TabBiomes::TabBiomes(MainWindow *parent)
//QHeaderView *header = ui->table->horizontalHeader();
connect(header, &QHeaderView::sortIndicatorChanged, this, &TabBiomes::onTableSort);

ui->table->setFont(g_font_mono);
ui->table->setFont(*gp_font_mono);
ui->table->setSortingEnabled(true);

ui->treeLocate->setColumnWidth(0, 160);
Expand Down

0 comments on commit 996ce9b

Please sign in to comment.