Added new font and set icons to frontlight controls

This commit is contained in:
Nicolas Mailloux 2021-03-29 21:46:53 -04:00
parent d07080ec84
commit 640991db98
4 changed files with 38 additions and 6 deletions

View file

@ -31,5 +31,11 @@
<file>resources/alert.png</file> <file>resources/alert.png</file>
<file>resources/eink_dark.qss</file> <file>resources/eink_dark.qss</file>
<file>resources/frontlight.png</file> <file>resources/frontlight.png</file>
<file>resources/fonts/CrimsonPro-Bold.ttf</file>
<file>resources/fonts/CrimsonPro-Italic.ttf</file>
<file>resources/fonts/CrimsonPro-Regular.ttf</file>
<file>resources/check.png</file>
<file>resources/minus.png</file>
<file>resources/plus.png</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -54,7 +54,10 @@ reader::reader(QWidget *parent) :
ui->previousDefinitionBtn->setIcon(QIcon(":/resources/chevron-left.png")); ui->previousDefinitionBtn->setIcon(QIcon(":/resources/chevron-left.png"));
ui->nextDefinitionBtn->setText(""); ui->nextDefinitionBtn->setText("");
ui->nextDefinitionBtn->setIcon(QIcon(":/resources/chevron-right.png")); ui->nextDefinitionBtn->setIcon(QIcon(":/resources/chevron-right.png"));
ui->brightnessDecBtn->setText("");
ui->brightnessDecBtn->setIcon(QIcon(":/resources/minus.png"));
ui->brightnessIncBtn->setText("");
ui->brightnessIncBtn->setIcon(QIcon(":/resources/plus.png"));
// Making text selectable // Making text selectable
ui->text->setTextInteractionFlags(Qt::TextSelectableByMouse); ui->text->setTextInteractionFlags(Qt::TextSelectableByMouse);
@ -65,11 +68,20 @@ reader::reader(QWidget *parent) :
if(checkconfig_str_val == "") { if(checkconfig_str_val == "") {
; ;
} }
else {
if(checkconfig_str_val == "Crimson Pro") {
int id = QFontDatabase::addApplicationFont(":/resources/fonts/CrimsonPro-Regular.ttf");
QString family = QFontDatabase::applicationFontFamilies(id).at(0);
QFont crimson(family);
ui->text->setFont(crimson);
ui->fontChooser->setCurrentText(checkconfig_str_val);
}
else { else {
QFont config_font(checkconfig_str_val); QFont config_font(checkconfig_str_val);
ui->text->setFont(config_font); ui->text->setFont(config_font);
ui->fontChooser->setCurrentText(checkconfig_str_val); ui->fontChooser->setCurrentText(checkconfig_str_val);
} }
}
// Alignment // Alignment
string_checkconfig(".config/04-book/alignment"); string_checkconfig(".config/04-book/alignment");
@ -476,6 +488,13 @@ void reader::on_fontChooser_currentIndexChanged(const QString &arg1)
ui->text->setFont(libertinus); ui->text->setFont(libertinus);
string_writeconfig(".config/04-book/font", "Libertinus Serif"); string_writeconfig(".config/04-book/font", "Libertinus Serif");
} }
if(arg1 == "Crimson Pro") {
int id = QFontDatabase::addApplicationFont(":/resources/fonts/CrimsonPro-Regular.ttf");
QString family = QFontDatabase::applicationFontFamilies(id).at(0);
QFont crimson(family);
ui->text->setFont(crimson);
string_writeconfig(".config/04-book/font", "Crimson Pro");
}
} }
void reader::on_alignLeftBtn_clicked() void reader::on_alignLeftBtn_clicked()

View file

@ -12,6 +12,8 @@
#include <fstream> #include <fstream>
#include <QMessageBox> #include <QMessageBox>
#include <regex> #include <regex>
#include <QFont>
#include <QFontDatabase>
using namespace std; using namespace std;

View file

@ -196,14 +196,14 @@
<item row="1" column="0"> <item row="1" column="0">
<widget class="QPushButton" name="brightnessDecBtn"> <widget class="QPushButton" name="brightnessDecBtn">
<property name="text"> <property name="text">
<string>―</string> <string/>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="2"> <item row="1" column="2">
<widget class="QPushButton" name="brightnessIncBtn"> <widget class="QPushButton" name="brightnessIncBtn">
<property name="text"> <property name="text">
<string> + </string> <string/>
</property> </property>
</widget> </widget>
</item> </item>
@ -333,6 +333,11 @@
<string>Inter</string> <string>Inter</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>Crimson Pro</string>
</property>
</item>
<item> <item>
<property name="text"> <property name="text">
<string>Source Serif Pro</string> <string>Source Serif Pro</string>