ok, now we use qfontdatabase (thanks Dekel). Things seem good

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5664 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2002-11-17 17:16:21 +00:00
parent 1199867058
commit 627de563e1
6 changed files with 163 additions and 180 deletions

View File

@ -1,3 +1,12 @@
2002-11-17 John Levon <levon@movementarian.org>
* ui/QPrefScreenFontsModule.ui:
* QPrefsDialog.h:
* QPrefsDialog.C:
* QPrefs.C: use font families properly
* qfont_loader.C: and obey them
2002-11-17 John Levon <levon@movementarian.org> 2002-11-17 John Levon <levon@movementarian.org>
* QPrefsDialog.C: partial fonts fix * QPrefsDialog.C: partial fonts fix

View File

@ -230,9 +230,9 @@ void QPrefs::apply()
LyXRC const oldrc(rc); LyXRC const oldrc(rc);
rc.roman_font_name = fontmod->screenRomanED->text().latin1(); rc.roman_font_name = fontmod->screenRomanCO->currentText().latin1();
rc.sans_font_name = fontmod->screenSansED->text().latin1(); rc.sans_font_name = fontmod->screenSansCO->currentText().latin1();
rc.typewriter_font_name = fontmod->screenTypewriterED->text().latin1(); rc.typewriter_font_name = fontmod->screenTypewriterCO->currentText().latin1();
rc.zoom = fontmod->screenZoomSB->value(); rc.zoom = fontmod->screenZoomSB->value();
rc.dpi = fontmod->screenDpiSB->value(); rc.dpi = fontmod->screenDpiSB->value();
rc.font_sizes[LyXFont::SIZE_TINY] = strToDbl(fontmod->screenTinyED->text().latin1()); rc.font_sizes[LyXFont::SIZE_TINY] = strToDbl(fontmod->screenTinyED->text().latin1());
@ -428,9 +428,31 @@ void QPrefs::update_contents()
QPrefScreenFontsModule * fontmod(dialog_->screenfontsModule); QPrefScreenFontsModule * fontmod(dialog_->screenfontsModule);
fontmod->screenRomanED->setText(rc.roman_font_name.c_str()); QString roman(rc.roman_font_name.c_str());
fontmod->screenSansED->setText(rc.sans_font_name.c_str()); QString sans(rc.sans_font_name.c_str());
fontmod->screenTypewriterED->setText(rc.typewriter_font_name.c_str()); QString typewriter(rc.typewriter_font_name.c_str());
for (int i = 0; i < fontmod->screenRomanCO->count(); ++i) {
if (fontmod->screenRomanCO->text(i) == roman) {
fontmod->screenRomanCO->setCurrentItem(i);
break;
}
}
for (int i = 0; i < fontmod->screenSansCO->count(); ++i) {
if (fontmod->screenSansCO->text(i) == sans) {
fontmod->screenSansCO->setCurrentItem(i);
break;
}
}
for (int i = 0; i < fontmod->screenTypewriterCO->count(); ++i) {
if (fontmod->screenTypewriterCO->text(i) == typewriter) {
fontmod->screenTypewriterCO->setCurrentItem(i);
break;
}
}
fontmod->screenZoomSB->setValue(rc.zoom); fontmod->screenZoomSB->setValue(rc.zoom);
fontmod->screenDpiSB->setValue(int(rc.dpi)); fontmod->screenDpiSB->setValue(int(rc.dpi));
fontmod->screenTinyED->setText(tostr(rc.font_sizes[LyXFont::SIZE_TINY]).c_str()); fontmod->screenTinyED->setText(tostr(rc.font_sizes[LyXFont::SIZE_TINY]).c_str());

View File

@ -47,7 +47,8 @@
#include <qlineedit.h> #include <qlineedit.h>
#include <qcheckbox.h> #include <qcheckbox.h>
#include <qcombobox.h> #include <qcombobox.h>
#include <qfontdialog.h> #include <qfontdatabase.h>
#include <qstringlist.h>
#include <qcolordialog.h> #include <qcolordialog.h>
#include <qcolor.h> #include <qcolor.h>
#include "qcoloritem.h" #include "qcoloritem.h"
@ -179,6 +180,15 @@ QPrefsDialog::QPrefsDialog(QPrefs * form)
colorsModule->lyxObjectsLB->insertItem(ci); colorsModule->lyxObjectsLB->insertItem(ci);
} }
QFontDatabase fontdb;
QStringList families(fontdb.families());
for (QStringList::Iterator it = families.begin(); it != families.end(); ++it) {
screenfontsModule->screenRomanCO->insertItem(*it);
screenfontsModule->screenSansCO->insertItem(*it);
screenfontsModule->screenTypewriterCO->insertItem(*it);
}
connect(uiModule->uiFilePB, SIGNAL(clicked()), this, SLOT(select_ui())); connect(uiModule->uiFilePB, SIGNAL(clicked()), this, SLOT(select_ui()));
connect(uiModule->bindFilePB, SIGNAL(clicked()), this, SLOT(select_bind())); connect(uiModule->bindFilePB, SIGNAL(clicked()), this, SLOT(select_bind()));
@ -193,10 +203,6 @@ QPrefsDialog::QPrefsDialog(QPrefs * form)
connect(pathsModule->workingDirPB, SIGNAL(clicked()), this, SLOT(select_workingdir())); connect(pathsModule->workingDirPB, SIGNAL(clicked()), this, SLOT(select_workingdir()));
connect(pathsModule->lyxserverDirPB, SIGNAL(clicked()), this, SLOT(select_lyxpipe())); connect(pathsModule->lyxserverDirPB, SIGNAL(clicked()), this, SLOT(select_lyxpipe()));
connect(screenfontsModule->screenRomanPB, SIGNAL(clicked()), this, SLOT(change_roman()));
connect(screenfontsModule->screenSansPB, SIGNAL(clicked()), this, SLOT(change_sans()));
connect(screenfontsModule->screenTypewriterPB, SIGNAL(clicked()), this, SLOT(change_typewriter()));
connect(colorsModule->colorChangePB, SIGNAL(clicked()), this, SLOT(change_color())); connect(colorsModule->colorChangePB, SIGNAL(clicked()), this, SLOT(change_color()));
connect(colorsModule->lyxObjectsLB, SIGNAL(selected(int)), this, SLOT(change_color())); connect(colorsModule->lyxObjectsLB, SIGNAL(selected(int)), this, SLOT(change_color()));
@ -279,9 +285,9 @@ QPrefsDialog::QPrefsDialog(QPrefs * form)
connect(printerModule->printerExtraED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); connect(printerModule->printerExtraED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
connect(printerModule->printerSpoolPrefixED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); connect(printerModule->printerSpoolPrefixED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
connect(printerModule->printerPaperSizeED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); connect(printerModule->printerPaperSizeED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
connect(screenfontsModule->screenRomanED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); connect(screenfontsModule->screenRomanCO, SIGNAL(activated(const QString&)), this, SLOT(change_adaptor()));
connect(screenfontsModule->screenSansED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); connect(screenfontsModule->screenSansCO, SIGNAL(activated(const QString&)), this, SLOT(change_adaptor()));
connect(screenfontsModule->screenTypewriterED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); connect(screenfontsModule->screenTypewriterCO, SIGNAL(activated(const QString&)), this, SLOT(change_adaptor()));
connect(screenfontsModule->screenZoomSB, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor())); connect(screenfontsModule->screenZoomSB, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor()));
connect(screenfontsModule->screenDpiSB, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor())); connect(screenfontsModule->screenDpiSB, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor()));
connect(screenfontsModule->screenTinyED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); connect(screenfontsModule->screenTinyED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
@ -566,62 +572,3 @@ void QPrefsDialog::select_lyxpipe()
if (!file.empty()) if (!file.empty())
pathsModule->lyxserverDirED->setText(file.c_str()); pathsModule->lyxserverDirED->setText(file.c_str());
} }
namespace {
QFont fontFromString(QString const & s) {
QFont f;
#if QT_VERSION >= 300
f.fromString(s);
return f;
#else
f.setRawName(s);
return f;
#endif
}
QString const fontToString(QFont const & f) {
#if QT_VERSION >= 300
return f.toString();
#else
return f.rawName();
#endif
}
}
void QPrefsDialog::change_roman()
{
QFont f(fontFromString(screenfontsModule->screenRomanED->text()));
// Qt designers hadn't heard of references
bool ok;
f = QFontDialog::getFont(&ok, f);
if (ok)
screenfontsModule->screenRomanED->setText(fontToString(f));
}
void QPrefsDialog::change_sans()
{
QFont f(fontFromString(screenfontsModule->screenSansED->text()));
// Qt designers hadn't heard of references
bool ok;
f = QFontDialog::getFont(&ok, f);
if (ok)
screenfontsModule->screenSansED->setText(fontToString(f));
}
void QPrefsDialog::change_typewriter()
{
QFont f(fontFromString(screenfontsModule->screenTypewriterED->text()));
// Qt designers hadn't heard of references
bool ok;
f = QFontDialog::getFont(&ok, f);
if (ok)
screenfontsModule->screenTypewriterED->setText(fontToString(f));
}

View File

@ -70,10 +70,6 @@ public slots:
void change_color(); void change_color();
void change_roman();
void change_sans();
void change_typewriter();
void select_ui(); void select_ui();
void select_bind(); void select_bind();
void select_keymap1(); void select_keymap1();

View File

@ -176,13 +176,13 @@ qfont_loader::font_info::font_info(LyXFont const & f)
} else } else
switch (f.family()) { switch (f.family()) {
case LyXFont::ROMAN_FAMILY: case LyXFont::ROMAN_FAMILY:
font.setFamily("times"); font.setFamily(lyxrc.roman_font_name.c_str());
break; break;
case LyXFont::SANS_FAMILY: case LyXFont::SANS_FAMILY:
font.setFamily("helvetica"); font.setFamily(lyxrc.sans_font_name.c_str());
break; break;
case LyXFont::TYPEWRITER_FAMILY: case LyXFont::TYPEWRITER_FAMILY:
font.setFamily("courier"); font.setFamily(lyxrc.typewriter_font_name.c_str());
break; break;
default: default:
break; break;
@ -191,8 +191,6 @@ qfont_loader::font_info::font_info(LyXFont const & f)
font.setPointSizeFloat(lyxrc.font_sizes[f.size()] font.setPointSizeFloat(lyxrc.font_sizes[f.size()]
* lyxrc.zoom / 100.0); * lyxrc.zoom / 100.0);
// FIXME: lyxrc, check for failure etc.
switch (f.series()) { switch (f.series()) {
case LyXFont::MEDIUM_SERIES: case LyXFont::MEDIUM_SERIES:
font.setWeight(QFont::Normal); font.setWeight(QFont::Normal);

View File

@ -13,8 +13,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>203</width> <width>270</width>
<height>360</height> <height>358</height>
</rect> </rect>
</property> </property>
<property stdset="1"> <property stdset="1">
@ -34,7 +34,22 @@
<class>QLayoutWidget</class> <class>QLayoutWidget</class>
<property stdset="1"> <property stdset="1">
<name>name</name> <name>name</name>
<cstring>Layout17</cstring> <cstring>Layout4</cstring>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout4</cstring>
</property> </property>
<grid> <grid>
<property stdset="1"> <property stdset="1">
@ -45,80 +60,18 @@
<name>spacing</name> <name>spacing</name>
<number>6</number> <number>6</number>
</property> </property>
<widget row="1" column="2" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>screenSansPB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>C&amp;hoose...</string>
</property>
</widget>
<widget row="2" column="1" >
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>screenTypewriterED</cstring>
</property>
</widget>
<widget row="1" column="1" >
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>screenSansED</cstring>
</property>
</widget>
<widget row="0" column="2" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>screenRomanPB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Ch&amp;oose...</string>
</property>
</widget>
<widget row="0" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>screenRomanLA</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Roman:</string>
</property>
<property>
<name>buddy</name>
<cstring>screenRomanED</cstring>
</property>
</widget>
<widget row="0" column="1" > <widget row="0" column="1" >
<class>QLineEdit</class> <class>QComboBox</class>
<property stdset="1"> <property stdset="1">
<name>name</name> <name>name</name>
<cstring>screenRomanED</cstring> <cstring>screenRomanCO</cstring>
</property>
<property stdset="1">
<name>duplicatesEnabled</name>
<bool>false</bool>
</property> </property>
</widget> </widget>
<widget row="2" column="0" > <widget row="2" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>screenTypewriterLA</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>T&amp;ypewriter:</string>
</property>
<property>
<name>buddy</name>
<cstring>screenTypewriterED</cstring>
</property>
</widget>
<widget row="1" column="0" >
<class>QLabel</class> <class>QLabel</class>
<property stdset="1"> <property stdset="1">
<name>name</name> <name>name</name>
@ -126,26 +79,90 @@
</property> </property>
<property stdset="1"> <property stdset="1">
<name>text</name> <name>text</name>
<string>Sa&amp;ns Serif:</string> <string>Sa&amp;ns Serif :</string>
</property> </property>
<property> <property>
<name>buddy</name> <name>buddy</name>
<cstring>screenSansED</cstring> <cstring>screenSansCO</cstring>
</property> </property>
</widget> </widget>
<widget row="2" column="2" > <widget row="0" column="0" rowspan="2" colspan="1" >
<class>QPushButton</class> <class>QLabel</class>
<property stdset="1"> <property stdset="1">
<name>name</name> <name>name</name>
<cstring>screenTypewriterPB</cstring> <cstring>screenRomanLA</cstring>
</property> </property>
<property stdset="1"> <property stdset="1">
<name>text</name> <name>text</name>
<string>Choos&amp;e...</string> <string>&amp;Roman :</string>
</property>
<property>
<name>buddy</name>
<cstring>screenRomanCO</cstring>
</property>
</widget>
<widget row="3" column="1" >
<class>QComboBox</class>
<property stdset="1">
<name>name</name>
<cstring>screenTypewriterCO</cstring>
</property>
<property stdset="1">
<name>duplicatesEnabled</name>
<bool>false</bool>
</property>
</widget>
<widget row="1" column="1" rowspan="2" colspan="1" >
<class>QComboBox</class>
<property stdset="1">
<name>name</name>
<cstring>screenSansCO</cstring>
</property>
<property stdset="1">
<name>duplicatesEnabled</name>
<bool>false</bool>
</property>
</widget>
<widget row="3" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>screenTypewriterLA</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>T&amp;ypewriter :</string>
</property>
<property>
<name>buddy</name>
<cstring>screenTypewriterCO</cstring>
</property> </property>
</widget> </widget>
</grid> </grid>
</widget> </widget>
<spacer>
<property>
<name>name</name>
<cstring>Spacer3</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Horizontal</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</hbox>
</widget>
<widget> <widget>
<class>QLayoutWidget</class> <class>QLayoutWidget</class>
<property stdset="1"> <property stdset="1">
@ -518,12 +535,6 @@
</vbox> </vbox>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>screenRomanED</tabstop>
<tabstop>screenRomanPB</tabstop>
<tabstop>screenSansED</tabstop>
<tabstop>screenSansPB</tabstop>
<tabstop>screenTypewriterED</tabstop>
<tabstop>screenTypewriterPB</tabstop>
<tabstop>screenZoomSB</tabstop> <tabstop>screenZoomSB</tabstop>
<tabstop>screenDpiSB</tabstop> <tabstop>screenDpiSB</tabstop>
<tabstop>screenTinyED</tabstop> <tabstop>screenTinyED</tabstop>