Added Fonts Tab in Preferences. Can NOT change webviews.

This commit is contained in:
Mark Watkins 2011-10-05 20:44:41 +10:00
parent 76d71e75c0
commit cdb7766d29
10 changed files with 331 additions and 59 deletions

View File

@ -19,15 +19,38 @@ const int mouse_movement_threshold=6;
void InitGraphs()
{
if (!_graph_init) {
defaultfont=new QFont("Sans Serif",10);
if (!PREF.Exists("FontGraph")) {
PREF["FontGraph"]="Sans Serif";
PREF["FontGraphSize"]=10;
PREF["FontGraphBold"]=false;
PREF["FontGraphItalic"]=false;
}
if (!PREF.Exists("FontTitle")) {
PREF["FontTitle"]="Serif";
PREF["FontTitleSize"]=11;
PREF["FontTitleBold"]=true;
PREF["FontTitleItalic"]=false;
}
if (!PREF.Exists("FontBig")) {
PREF["FontBig"]="Serif";
PREF["FontBigSize"]=35;
PREF["FontBigBold"]=false;
PREF["FontBigItalic"]=false;
}
defaultfont=new QFont(PREF["FontGraph"].toString(),PREF["FontGraphSize"].toInt(),PREF["FontGraphBold"].toBool() ? QFont::Bold : QFont::Normal,PREF["FontGraphItalic"].toBool());
mediumfont=new QFont(PREF["FontTitle"].toString(),PREF["FontTitleSize"].toInt(),PREF["FontTitleBold"].toBool() ? QFont::Bold : QFont::Normal,PREF["FontTitleItalic"].toBool());
bigfont=new QFont(PREF["FontBig"].toString(),PREF["FontBigSize"].toInt(),PREF["FontBigBold"].toBool() ? QFont::Bold : QFont::Normal,PREF["FontBigItalic"].toBool());
// defaultfont->setPixelSize(11);
mediumfont=new QFont("Serif",11);
bigfont=new QFont("Serif",35);
//mediumfont=new QFont("Serif",11);
//bigfont=new QFont("Serif",35);
defaultfont->setStyleHint(QFont::SansSerif,QFont::OpenGLCompatible);
mediumfont->setStyleHint(QFont::SansSerif,QFont::OpenGLCompatible);
bigfont->setStyleHint(QFont::Serif ,QFont::OpenGLCompatible);
mediumfont->setBold(true);
//mediumfont->setBold(true);
_graph_init=true;
}
}

View File

@ -203,6 +203,8 @@ Daily::Daily(QWidget *parent,gGraphView * shared, MainWindow *mw)
ui->calendar->setWeekdayTextFormat(Qt::Sunday, format);
ui->tabWidget->setCurrentWidget(ui->details);
ui->webView->settings()->setFontSize(QWebSettings::DefaultFontSize,QApplication::font().pointSize());
}
Daily::~Daily()

View File

@ -89,14 +89,8 @@
<height>0</height>
</size>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="currentIndex">
<number>1</number>
<number>3</number>
</property>
<property name="movable">
<bool>true</bool>
@ -120,12 +114,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>9</pointsize>
</font>
</property>
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
@ -151,12 +139,6 @@
</property>
<item>
<widget class="QTreeWidget" name="treeWidget">
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
@ -254,11 +236,6 @@
</item>
<item>
<widget class="QToolButton" name="JournalNotesItalic">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string> i </string>
</property>
@ -269,11 +246,6 @@
</item>
<item>
<widget class="QToolButton" name="JournalNotesUnderline">
<property name="font">
<font>
<underline>true</underline>
</font>
</property>
<property name="text">
<string>u</string>
</property>
@ -281,12 +253,6 @@
</item>
<item>
<widget class="QToolButton" name="JournalNotesBold">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>B</string>
</property>

View File

@ -1,9 +1,5 @@
<html>
<head>
<style type='text/css'>
<!--h1,p,a,td,body { font-family: 'FreeSans', 'Sans Serif' } --/>
p,a,td,body { font-size: 14px }
</style>
</head>
<body leftmargin=0 topmargin=0 rightmargin=0>
<table width="100%" cellspacing=0 cellpadding=4 border=0 >

View File

@ -100,13 +100,22 @@ int main(int argc, char *argv[])
//if (!PREF.Exists("Profile")) PREF["Profile"]=getUserName();
/*int id=QFontDatabase::addApplicationFont(":/fonts/FreeSans.ttf");
QStringList ffam=QFontDatabase::applicationFontFamilies(id);
//int id=QFontDatabase::addApplicationFont(":/fonts/FreeSans.ttf");
/* QFontDatabase fdb;
QStringList ffam=fdb.families();
for (QStringList::iterator i=ffam.begin();i!=ffam.end();i++) {
qDebug() << "Loaded Font: " << (*i);
}*/
} */
a.setFont(QFont("Sans Serif",10));
if (!PREF.Exists("FontApplication")) {
PREF["FontApplication"]="Sans Serif";
PREF["FontApplicationSize"]=10;
PREF["FontApplicationBold"]=false;
PREF["FontApplicationItalic"]=false;
}
QApplication::setFont(QFont(PREF["FontApplication"].toString(),PREF["FontApplicationSize"].toInt(),PREF["FontApplicationBold"].toBool() ? QFont::Bold : QFont::Normal,PREF["FontApplicationItalic"].toBool()));
qInstallMsgHandler(MyOutputHandler);

View File

@ -22,12 +22,6 @@
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="windowTitle">
<string>SleepyHead</string>
</property>

View File

@ -10,11 +10,6 @@
<height>393</height>
</rect>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
</font>
</property>
<property name="windowTitle">
<string>Form</string>
</property>

View File

@ -4,6 +4,10 @@
#include "ui_preferencesdialog.h"
#include "SleepLib/machine_common.h"
extern QFont * defaultfont;
extern QFont * mediumfont;
extern QFont * bigfont;
PreferencesDialog::PreferencesDialog(QWidget *parent,Profile * _profile) :
QDialog(parent),
ui(new Ui::PreferencesDialog),
@ -33,6 +37,27 @@ PreferencesDialog::PreferencesDialog(QWidget *parent,Profile * _profile) :
val=(*profile)["IgnoreShorterSessions"].toInt();
ui->IgnoreSlider->setValue(val);
ui->applicationFont->setCurrentFont(QApplication::font());
ui->applicationFontSize->setValue(QApplication::font().pointSize());
ui->applicationFontBold->setChecked(QApplication::font().weight()==QFont::Bold);
ui->applicationFontItalic->setChecked(QApplication::font().italic());
ui->graphFont->setCurrentFont(*defaultfont);
ui->graphFontSize->setValue(defaultfont->pointSize());
ui->graphFontBold->setChecked(defaultfont->weight()==QFont::Bold);
ui->graphFontItalic->setChecked(defaultfont->italic());
ui->titleFont->setCurrentFont(*mediumfont);
ui->titleFontSize->setValue(mediumfont->pointSize());
ui->titleFontBold->setChecked(mediumfont->weight()==QFont::Bold);
ui->titleFontItalic->setChecked(mediumfont->italic());
ui->bigFont->setCurrentFont(*bigfont);
ui->bigFontSize->setValue(bigfont->pointSize());
ui->bigFontBold->setChecked(bigfont->weight()==QFont::Bold);
ui->bigFontItalic->setChecked(bigfont->italic());
if (val>0) {
ui->IgnoreLCD->display(val);
} else ui->IgnoreLCD->display(tr("OFF"));
@ -144,6 +169,45 @@ void PreferencesDialog::Save()
(*profile)["IntentionalLeak"]=ui->intentionalLeakEdit->value();
(*profile)["EnableMultithreading"]=ui->useMultithreading->isChecked();
PREF["FontApplication"]=ui->applicationFont->currentText();
PREF["FontApplicationSize"]=ui->applicationFontSize->value();
PREF["FontApplicationBold"]=ui->applicationFontBold->isChecked();
PREF["FontApplicationItalic"]=ui->applicationFontItalic->isChecked();
PREF["FontGraph"]=ui->graphFont->currentText();
PREF["FontGraphSize"]=ui->graphFontSize->value();
PREF["FontGraphBold"]=ui->graphFontBold->isChecked();
PREF["FontGraphItalic"]=ui->graphFontItalic->isChecked();
PREF["FontTitle"]=ui->titleFont->currentText();
PREF["FontTitleSize"]=ui->titleFontSize->value();
PREF["FontTitleBold"]=ui->titleFontBold->isChecked();
PREF["FontTitleItalic"]=ui->titleFontItalic->isChecked();
PREF["FontBig"]=ui->bigFont->currentText();
PREF["FontBigSize"]=ui->bigFontSize->value();
PREF["FontBigBold"]=ui->bigFontBold->isChecked();
PREF["FontBigItalic"]=ui->bigFontItalic->isChecked();
QFont font=ui->applicationFont->currentFont();
font.setPointSize(ui->applicationFontSize->value());
font.setWeight(ui->applicationFontBold->isChecked()?QFont::Bold : QFont::Normal);
font.setItalic(ui->applicationFontItalic->isChecked());
QApplication::setFont(font);
*defaultfont=ui->graphFont->currentFont();
defaultfont->setWeight(ui->graphFontBold->isChecked()?QFont::Bold : QFont::Normal);
defaultfont->setItalic(ui->graphFontItalic->isChecked());
*mediumfont=ui->titleFont->currentFont();
mediumfont->setWeight(ui->titleFontBold->isChecked()?QFont::Bold : QFont::Normal);
mediumfont->setItalic(ui->titleFontItalic->isChecked());
*bigfont=ui->bigFont->currentFont();
bigfont->setWeight(ui->bigFontBold->isChecked()?QFont::Bold : QFont::Normal);
bigfont->setItalic(ui->bigFontItalic->isChecked());
for (QHash<int,QColor>::iterator i=m_new_colors.begin();i!=m_new_colors.end();i++) {
schema::Channel &chan=schema::channel[i.key()];
if (!chan.isNull()) {
@ -170,3 +234,23 @@ void PreferencesDialog::on_IgnoreSlider_valueChanged(int position)
ui->IgnoreLCD->display(position);
} else ui->IgnoreLCD->display(tr("OFF"));
}
void PreferencesDialog::on_applicationFontSize_valueChanged(int arg1)
{
ui->applicationFont->currentFont().setPointSize(arg1);
}
void PreferencesDialog::on_graphFontSize_valueChanged(int arg1)
{
ui->graphFont->currentFont().setPointSize(arg1);
}
void PreferencesDialog::on_titleFontSize_valueChanged(int arg1)
{
ui->titleFont->currentFont().setPointSize(arg1);
}
void PreferencesDialog::on_bigFontSize_valueChanged(int arg1)
{
ui->bigFont->currentFont().setPointSize(arg1);
}

View File

@ -29,6 +29,14 @@ private slots:
void on_IgnoreSlider_valueChanged(int value);
void on_applicationFontSize_valueChanged(int arg1);
void on_graphFontSize_valueChanged(int arg1);
void on_titleFontSize_valueChanged(int arg1);
void on_bigFontSize_valueChanged(int arg1);
private:
Ui::PreferencesDialog *ui;
Profile * profile;

View File

@ -29,7 +29,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>3</number>
<number>4</number>
</property>
<widget class="QWidget" name="visualTab">
<attribute name="title">
@ -507,6 +507,201 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</widget>
<widget class="QWidget" name="fontsTab">
<attribute name="title">
<string>Fonts</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Application Fonts</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label_10">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Application</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QFontComboBox" name="applicationFont"/>
</item>
<item row="0" column="2">
<widget class="QSpinBox" name="applicationFontSize">
<property name="minimum">
<number>6</number>
</property>
<property name="maximum">
<number>30</number>
</property>
<property name="value">
<number>10</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_11">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Graph Text</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QFontComboBox" name="graphFont"/>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="graphFontSize">
<property name="minimum">
<number>6</number>
</property>
<property name="maximum">
<number>40</number>
</property>
<property name="value">
<number>11</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_12">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Graph Titles</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QFontComboBox" name="titleFont"/>
</item>
<item row="2" column="2">
<widget class="QSpinBox" name="titleFontSize">
<property name="minimum">
<number>6</number>
</property>
<property name="maximum">
<number>40</number>
</property>
<property name="value">
<number>14</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Big Text</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QFontComboBox" name="bigFont"/>
</item>
<item row="3" column="2">
<widget class="QSpinBox" name="bigFontSize">
<property name="minimum">
<number>6</number>
</property>
<property name="maximum">
<number>72</number>
</property>
<property name="value">
<number>18</number>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QCheckBox" name="applicationFontItalic">
<property name="text">
<string>Italic</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QCheckBox" name="applicationFontBold">
<property name="text">
<string>Bold</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QCheckBox" name="graphFontBold">
<property name="text">
<string>Bold</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QCheckBox" name="graphFontItalic">
<property name="text">
<string>Italic</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QCheckBox" name="titleFontBold">
<property name="text">
<string>Bold</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QCheckBox" name="titleFontItalic">
<property name="text">
<string>Italic</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QCheckBox" name="bigFontBold">
<property name="text">
<string>Bold</string>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QCheckBox" name="bigFontItalic">
<property name="text">
<string>Italic</string>
</property>
</widget>
</item>
<item row="4" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>