Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Commit

Permalink
fixed font loading on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico-Duduf committed Mar 7, 2021
1 parent 27e0fd3 commit 651ab8b
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 60 deletions.
6 changes: 0 additions & 6 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ if ffmpeg/ocio not found, reset path in settings, and search again

## au prochain build

- check default ocio path on win & linux

- check reset settings pour voir si les chemins (win, linux) sont bien trouvés

- Check UI win (font size)

- doc: add ociobakelut instruction for macos

- build doc
Expand Down
2 changes: 1 addition & 1 deletion src/Renderer/cachemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ CacheManager *CacheManager::instance()
void CacheManager::init()
{
QSettings settings;
QString defaultCachePath = QDir::tempPath() + "/" + qApp->applicationName() + "/";
QString defaultCachePath = FileUtils::applicationTempPath();
defaultCachePath = QDir::toNativeSeparators(defaultCachePath);

QString currentCachePath = settings.value("cachePath", defaultCachePath).toString();
Expand Down
2 changes: 1 addition & 1 deletion src/UI/Blocks/blockcontentwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ BlockContentWidget::BlockContentWidget(MediaInfo *mediaInfo, QWidget *parent) :
_freezeUI = false;
}

void BlockContentWidget::activate(bool act)
void BlockContentWidget::activate(bool /*act*/)
{

}
Expand Down
10 changes: 6 additions & 4 deletions src/UI/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ MainWindow::MainWindow(QStringList args, QWidget *parent) :
connect(ffmpegSettingsWidget,SIGNAL(presetsPathChanged()),queueWidget,SLOT(presetsPathChanged()));

log("Init - Setting stylesheet", LogUtils::Debug);
// Set style
duqf_setStyle();

//parse arguments if ffmpeg is valid
autoQuit = false;
Expand Down Expand Up @@ -306,6 +304,9 @@ MainWindow::MainWindow(QStringList args, QWidget *parent) :
connect(launchQueueButton, &QToolButton::clicked, this, &MainWindow::go);
connect( goButton, &QToolButton::clicked, this, &MainWindow::go );

// Set style
duqf_setStyle();

log("Ready!");
}

Expand Down Expand Up @@ -431,6 +432,8 @@ void MainWindow::duqf_initUi()
void MainWindow::duqf_setStyle()
{
// ======== STYLE ========
// Font first so it's available in the css
DuUI::setFont(settings.value("appearance/font", "Ubuntu").toString());

//Re-set StyleSheet
QString cssFile = settings.value("appearance/cssFile", ":/styles/default").toString();
Expand All @@ -444,8 +447,7 @@ void MainWindow::duqf_setStyle()
DuUI::updateCSS("");
qApp->setStyle(QStyleFactory::create(style));
}
//and font
DuUI::setFont(settings.value("appearance/font", "Ubuntu").toString());

//and tool buttons
int styleIndex = settings.value("appearance/toolButtonStyle", 2).toInt();
DuUI::setToolButtonStyle(styleIndex);
Expand Down
47 changes: 19 additions & 28 deletions src/duqf-app/app-style.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define APPSTYLE_H

#include "app-version.h"
#include "duqf-utils/utils.h"

#include <QString>
#include <QStringList>
Expand All @@ -15,6 +16,7 @@
#include <QToolButton>
#include <QtDebug>


class DuUI
{
public:
Expand Down Expand Up @@ -116,39 +118,28 @@ class DuUI
return css;
}

static void setFont(QString family = "Ubuntu", int size=0)
static void setFont(QString family = "Ubuntu")
{
if (family == "Ubuntu")
{
//add fonts
QFontDatabase::addApplicationFont(":/fonts/Ubuntu-B");
QFontDatabase::addApplicationFont(":/fonts/Ubuntu-BI");
QFontDatabase::addApplicationFont(":/fonts/Ubuntu-C");
QFontDatabase::addApplicationFont(":/fonts/Ubuntu-L");
QFontDatabase::addApplicationFont(":/fonts/Ubuntu-LI");
QFontDatabase::addApplicationFont(":/fonts/Ubuntu-M");
QFontDatabase::addApplicationFont(":/fonts/Ubuntu-MI");
QFontDatabase::addApplicationFont(":/fonts/Ubuntu-R");
QFontDatabase::addApplicationFont(":/fonts/Ubuntu-RI");
QFontDatabase::addApplicationFont(":/fonts/Ubuntu-Th");
QFontDatabase::addApplicationFont(":/fonts/UbuntuMono-B");
QFontDatabase::addApplicationFont(":/fonts/UbuntuMono-BI");
QFontDatabase::addApplicationFont(":/fonts/UbuntuMono-R");
QFontDatabase::addApplicationFont(":/fonts/UbuntuMono-RI");
//extract fonts
QFontDatabase::addApplicationFont(":/fonts/Ubuntu-B.ttf");
QFontDatabase::addApplicationFont(":/fonts/Ubuntu-BI.ttf");
QFontDatabase::addApplicationFont(":/fonts/Ubuntu-C.ttf");
QFontDatabase::addApplicationFont(":/fonts/Ubuntu-L.ttf");
QFontDatabase::addApplicationFont(":/fonts/Ubuntu-LI.ttf");
QFontDatabase::addApplicationFont(":/fonts/Ubuntu-M.ttf");
QFontDatabase::addApplicationFont(":/fonts/Ubuntu-MI.ttf");
QFontDatabase::addApplicationFont(":/fonts/Ubuntu-R.ttf");
QFontDatabase::addApplicationFont(":/fonts/Ubuntu-RI.ttf");
QFontDatabase::addApplicationFont(":/fonts/Ubuntu-Th.ttf");
QFontDatabase::addApplicationFont(":/fonts/UbuntuMono-B.ttf");
QFontDatabase::addApplicationFont(":/fonts/UbuntuMono-BI.ttf");
QFontDatabase::addApplicationFont(":/fonts/UbuntuMono-R.ttf");
QFontDatabase::addApplicationFont(":/fonts/UbuntuMono-RI.ttf");
}
#ifdef Q_OS_MAC
if (size == 0) size = 12;
#endif
#ifdef Q_OS_LINUX
if (size ==0) size = 10;
#endif

#ifdef Q_OS_WIN
//There are strange issues with setting the font size on Win (at least with Qt 5.9.9)

qApp->setFont(QFont(family));
#else
qApp->setFont(QFont(family,size));
#endif
}

static void setToolButtonStyle(int styleIndex)
Expand Down
5 changes: 5 additions & 0 deletions src/duqf-utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,8 @@ void ProcessUtils::runProcess(QProcess *p, QString binary, QStringList arguments

p->start(QIODevice::ReadWrite);
}

QString FileUtils::applicationTempPath()
{
return QDir::tempPath() + "/" + qApp->applicationName() + "/";
}
2 changes: 2 additions & 0 deletions src/duqf-utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
#include <QTime>
#include <QDir>
#include <QProcess>
#include <QApplication>

namespace FileUtils
{
QString applicationTempPath();
void setReadWrite(QFile *file);
void setReadWrite(QString path);
void move(QString from, QString to);
Expand Down
28 changes: 14 additions & 14 deletions src/duqf_resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@
<file alias="default-values">duqf_resources/styles/style-values.rui</file>
</qresource>
<qresource prefix="/fonts">
<file alias="Ubuntu-B">duqf_resources/fonts/Ubuntu-B.ttf</file>
<file alias="Ubuntu-BI">duqf_resources/fonts/Ubuntu-BI.ttf</file>
<file alias="Ubuntu-C">duqf_resources/fonts/Ubuntu-C.ttf</file>
<file alias="Ubuntu-L">duqf_resources/fonts/Ubuntu-L.ttf</file>
<file alias="Ubuntu-LI">duqf_resources/fonts/Ubuntu-LI.ttf</file>
<file alias="Ubuntu-M">duqf_resources/fonts/Ubuntu-M.ttf</file>
<file alias="Ubuntu-MI">duqf_resources/fonts/Ubuntu-MI.ttf</file>
<file alias="UbuntuMono-B">duqf_resources/fonts/UbuntuMono-B.ttf</file>
<file alias="UbuntuMono-BI">duqf_resources/fonts/UbuntuMono-BI.ttf</file>
<file alias="UbuntuMono-R">duqf_resources/fonts/UbuntuMono-R.ttf</file>
<file alias="UbuntuMono-RI">duqf_resources/fonts/UbuntuMono-RI.ttf</file>
<file alias="Ubuntu-R">duqf_resources/fonts/Ubuntu-R.ttf</file>
<file alias="Ubuntu-RI">duqf_resources/fonts/Ubuntu-RI.ttf</file>
<file alias="Ubuntu-Th">duqf_resources/fonts/Ubuntu-Th.ttf</file>
<file alias="Ubuntu-B.ttf">duqf_resources/fonts/Ubuntu-B.ttf</file>
<file alias="Ubuntu-BI.ttf">duqf_resources/fonts/Ubuntu-BI.ttf</file>
<file alias="Ubuntu-C.ttf">duqf_resources/fonts/Ubuntu-C.ttf</file>
<file alias="Ubuntu-L.ttf">duqf_resources/fonts/Ubuntu-L.ttf</file>
<file alias="Ubuntu-LI.ttf">duqf_resources/fonts/Ubuntu-LI.ttf</file>
<file alias="Ubuntu-M.ttf">duqf_resources/fonts/Ubuntu-M.ttf</file>
<file alias="Ubuntu-MI.ttf">duqf_resources/fonts/Ubuntu-MI.ttf</file>
<file alias="UbuntuMono-B.ttf">duqf_resources/fonts/UbuntuMono-B.ttf</file>
<file alias="UbuntuMono-BI.ttf">duqf_resources/fonts/UbuntuMono-BI.ttf</file>
<file alias="UbuntuMono-R.ttf">duqf_resources/fonts/UbuntuMono-R.ttf</file>
<file alias="UbuntuMono-RI.ttf">duqf_resources/fonts/UbuntuMono-RI.ttf</file>
<file alias="Ubuntu-R.ttf">duqf_resources/fonts/Ubuntu-R.ttf</file>
<file alias="Ubuntu-RI.ttf">duqf_resources/fonts/Ubuntu-RI.ttf</file>
<file alias="Ubuntu-Th.ttf">duqf_resources/fonts/Ubuntu-Th.ttf</file>
</qresource>
</RCC>
4 changes: 4 additions & 0 deletions src/duqf_resources/styles/style-values.rui
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
@color-yellow = #ecd718
@color-light-red = #f96969

@font-size-small = 9px
@font-size-medium = 12px
@font-size-large = 15px;

@margin = 3px
@padding-small = 5px
@padding-medium = 7px
Expand Down
9 changes: 3 additions & 6 deletions src/duqf_resources/styles/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
outline: none;
}

MainWindow, QDialog {
background-color: @color-dark-grey;
}

QWidget {
/*font-weight:400;*/
MainWindow, QDialog, QWidget {
font-familiy = @font-family;
font-size: @font-size-medium;
background-color: @color-dark-grey;
}

Expand Down

0 comments on commit 651ab8b

Please sign in to comment.