Skip to content

Commit

Permalink
Move initializeFonts out of MixxxMainWindow.
Browse files Browse the repository at this point in the history
  • Loading branch information
rryan committed Jan 9, 2016
1 parent 6824abd commit 07024ee
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 27 deletions.
26 changes: 1 addition & 25 deletions src/mixxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void MixxxMainWindow::initialize(QApplication* pApp, const CmdlineArgs& args) {
mixxx::Translations::initializeTranslations(
pConfig.data(), pApp, args.getLocale());

initializeFonts(); // takes a long time
FontUtils::initializeFonts(resourcePath); // takes a long time

launchProgress(2);

Expand Down Expand Up @@ -704,30 +704,6 @@ void MixxxMainWindow::initializeWindow() {
slotUpdateWindowTitle(TrackPointer());
}

void MixxxMainWindow::initializeFonts() {
UserSettingsPointer pConfig = m_pSettingsManager->settings();
QDir fontsDir(pConfig->getResourcePath());
if (!fontsDir.cd("fonts")) {
qWarning("MixxxMainWindow::initializeFonts: cd fonts failed");
return;
}

QList<QFileInfo> files = fontsDir.entryInfoList(
QDir::NoDotAndDotDot | QDir::Files | QDir::Readable);
foreach (const QFileInfo& file, files) {
const QString& path = file.filePath();

// Skip text files (e.g. license files). For all others we let Qt tell
// us whether the font format is supported since there is no way to
// check other than adding.
if (path.endsWith(".txt", Qt::CaseInsensitive)) {
continue;
}

FontUtils::addFont(path);
}
}

void MixxxMainWindow::initializeKeyboard() {
UserSettingsPointer pConfig = m_pSettingsManager->settings();
QString resourcePath = pConfig->getResourcePath();
Expand Down
1 change: 0 additions & 1 deletion src/mixxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ class MixxxMainWindow : public QMainWindow {
private:
void initializeWindow();
void initializeKeyboard();
void initializeFonts();
void checkDirectRendering();
bool confirmExit();
void linkSkinWidget(ControlObjectSlave** pCOS,
Expand Down
2 changes: 1 addition & 1 deletion src/preferences/settingsmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SettingsManager : public QObject {
}

void save() {
m_pSettings->Save();
m_pSettings->save();
}

bool shouldRescanLibrary() {
Expand Down
24 changes: 24 additions & 0 deletions src/util/font.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,35 @@
#include <QFontDatabase>
#include <QString>
#include <QtDebug>
#include <QDir>

#include "util/cmdlineargs.h"

class FontUtils {
public:
static void initializeFonts(const QString& resourcePath) {
QDir fontsDir(resourcePath);
if (!fontsDir.cd("fonts")) {
qWarning("MixxxMainWindow::initializeFonts: cd fonts failed");
return;
}

QList<QFileInfo> files = fontsDir.entryInfoList(
QDir::NoDotAndDotDot | QDir::Files | QDir::Readable);
foreach (const QFileInfo& file, files) {
const QString& path = file.filePath();

// Skip text files (e.g. license files). For all others we let Qt tell
// us whether the font format is supported since there is no way to
// check other than adding.
if (path.endsWith(".txt", Qt::CaseInsensitive)) {
continue;
}

addFont(path);
}
}

static bool addFont(const QString& path) {
int result = QFontDatabase::addApplicationFont(path);
if (result == -1) {
Expand Down

0 comments on commit 07024ee

Please sign in to comment.