From ebac08df7f74b8b87408ae5e3fbd7c9b5b346999 Mon Sep 17 00:00:00 2001 From: John Levon Date: Mon, 18 Nov 2002 19:52:29 +0000 Subject: [PATCH] Show an example of chosen font git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5665 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt2/Makefile.am | 2 + src/frontends/qt2/QPrefs.C | 5 + src/frontends/qt2/QPrefsDialog.C | 23 +++ src/frontends/qt2/QPrefsDialog.h | 4 + src/frontends/qt2/qfontexample.C | 41 +++++ src/frontends/qt2/qfontexample.h | 30 ++++ .../qt2/ui/QPrefScreenFontsModule.ui | 156 ++++++++++++------ 7 files changed, 215 insertions(+), 46 deletions(-) create mode 100644 src/frontends/qt2/qfontexample.C create mode 100644 src/frontends/qt2/qfontexample.h diff --git a/src/frontends/qt2/Makefile.am b/src/frontends/qt2/Makefile.am index 733f18778d..1a7fef539f 100644 --- a/src/frontends/qt2/Makefile.am +++ b/src/frontends/qt2/Makefile.am @@ -73,6 +73,8 @@ libqt2_la_SOURCES = \ lyx_gui.C \ qcoloritem.h \ qcoloritem.C \ + qfontexample.h \ + qfontexample.C \ qfont_loader.h \ qfont_loader.C \ qfont_metrics.C \ diff --git a/src/frontends/qt2/QPrefs.C b/src/frontends/qt2/QPrefs.C index 81f4e3b2c8..fa59b0a9af 100644 --- a/src/frontends/qt2/QPrefs.C +++ b/src/frontends/qt2/QPrefs.C @@ -453,6 +453,11 @@ void QPrefs::update_contents() } } + // Fucked if I know why we need this. But we do + dialog_->select_roman(roman); + dialog_->select_sans(sans); + dialog_->select_typewriter(typewriter); + fontmod->screenZoomSB->setValue(rc.zoom); fontmod->screenDpiSB->setValue(int(rc.dpi)); fontmod->screenTinyED->setText(tostr(rc.font_sizes[LyXFont::SIZE_TINY]).c_str()); diff --git a/src/frontends/qt2/QPrefsDialog.C b/src/frontends/qt2/QPrefsDialog.C index b239cd9119..c5e271800c 100644 --- a/src/frontends/qt2/QPrefsDialog.C +++ b/src/frontends/qt2/QPrefsDialog.C @@ -52,6 +52,7 @@ #include #include #include "qcoloritem.h" +#include "qfontexample.h" using std::map; using std::endl; @@ -183,6 +184,10 @@ QPrefsDialog::QPrefsDialog(QPrefs * form) QFontDatabase fontdb; QStringList families(fontdb.families()); + connect(screenfontsModule->screenRomanCO, SIGNAL(activated(const QString&)), this, SLOT(select_roman(const QString&))); + connect(screenfontsModule->screenSansCO, SIGNAL(activated(const QString&)), this, SLOT(select_sans(const QString&))); + connect(screenfontsModule->screenTypewriterCO, SIGNAL(activated(const QString&)), this, SLOT(select_typewriter(const QString&))); + for (QStringList::Iterator it = families.begin(); it != families.end(); ++it) { screenfontsModule->screenRomanCO->insertItem(*it); screenfontsModule->screenSansCO->insertItem(*it); @@ -572,3 +577,21 @@ void QPrefsDialog::select_lyxpipe() if (!file.empty()) pathsModule->lyxserverDirED->setText(file.c_str()); } + + +void QPrefsDialog::select_roman(const QString& name) +{ + screenfontsModule->screenRomanFE->set(QFont(name), name); +} + + +void QPrefsDialog::select_sans(const QString& name) +{ + screenfontsModule->screenSansFE->set(QFont(name), name); +} + + +void QPrefsDialog::select_typewriter(const QString& name) +{ + screenfontsModule->screenTypewriterFE->set(QFont(name), name); +} diff --git a/src/frontends/qt2/QPrefsDialog.h b/src/frontends/qt2/QPrefsDialog.h index a144386706..7b3ae38ad5 100644 --- a/src/frontends/qt2/QPrefsDialog.h +++ b/src/frontends/qt2/QPrefsDialog.h @@ -81,6 +81,10 @@ public slots: void select_workingdir(); void select_lyxpipe(); + void select_roman(const QString&); + void select_sans(const QString&); + void select_typewriter(const QString&); + protected: void closeEvent(QCloseEvent * e); diff --git a/src/frontends/qt2/qfontexample.C b/src/frontends/qt2/qfontexample.C new file mode 100644 index 0000000000..c7a9c7081d --- /dev/null +++ b/src/frontends/qt2/qfontexample.C @@ -0,0 +1,41 @@ +/** + * \file qfontexample.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author John Levon + * + * Full author contact details are available in file CREDITS + */ + + +#include "qfontexample.h" + +#include + +void QFontExample::set(QFont const & font, QString const & text) +{ + font_ = font; + text_ = text; + repaint(); +} + + +QSize QFontExample::sizeHint() const +{ + QFontMetrics m(font_); + return QSize(m.width(text_) + 10, m.ascent() + m.descent() + 6); +} + + +void QFontExample::paintEvent(QPaintEvent *) +{ + QPainter p; + QFontMetrics m(font_); + + p.begin(this); + p.setFont(font_); + p.drawRect(0, 0, width() - 1, height() - 1); + p.drawText(5, 3 + m.ascent(), text_); + p.end(); +} diff --git a/src/frontends/qt2/qfontexample.h b/src/frontends/qt2/qfontexample.h new file mode 100644 index 0000000000..726410767f --- /dev/null +++ b/src/frontends/qt2/qfontexample.h @@ -0,0 +1,30 @@ +/** + * \file qfontexample.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author John Levon + * + * Full author contact details are available in file CREDITS + */ + +#include +#include + +class QFontExample : public QWidget { + +public: + QFontExample(QWidget * parent, const char * name) + : QWidget(parent, name) {} + + void set(QFont const & font, QString const & text); + + virtual QSize sizeHint() const; + +protected: + virtual void paintEvent(QPaintEvent * p); + +private: + QFont font_; + QString text_; +}; diff --git a/src/frontends/qt2/ui/QPrefScreenFontsModule.ui b/src/frontends/qt2/ui/QPrefScreenFontsModule.ui index fec575a8e0..0940587b4e 100644 --- a/src/frontends/qt2/ui/QPrefScreenFontsModule.ui +++ b/src/frontends/qt2/ui/QPrefScreenFontsModule.ui @@ -13,8 +13,8 @@ 0 0 - 270 - 358 + 321 + 344 @@ -34,7 +34,7 @@ QLayoutWidget name - Layout4 + Layout6 @@ -49,7 +49,14 @@ QLayoutWidget name - Layout4 + Layout5 + + + minimumSize + + 60 + 0 + @@ -60,18 +67,39 @@ spacing 6 - + QComboBox name - screenRomanCO + screenSansCO duplicatesEnabled false - + + QFontExample + + name + screenSansFE + + + sizePolicy + + 3 + 5 + + + + minimumSize + + 60 + 0 + + + + QLabel name @@ -86,81 +114,95 @@ screenSansCO - - QLabel + + QFontExample name - screenRomanLA + screenRomanFE - text - &Roman : + sizePolicy + + 3 + 5 + - - buddy - screenRomanCO + + minimumSize + + 60 + 0 + - + QComboBox name - screenTypewriterCO + screenRomanCO duplicatesEnabled false - - QComboBox + + QLabel name - screenSansCO + screenTypewriterLA - duplicatesEnabled - false + text + T&ypewriter : + + + buddy + screenTypewriterCO - + QLabel name - screenTypewriterLA + screenRomanLA text - T&ypewriter : + &Roman : buddy + screenRomanCO + + + + QFontExample + + name + screenTypewriterFE + + + sizePolicy + + 3 + 5 + + + + + QComboBox + + name screenTypewriterCO + + duplicatesEnabled + false + - - - name - Spacer3 - - - orientation - Horizontal - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - @@ -534,6 +576,28 @@ + + + QFontExample +
qfontexample.h
+ + -1 + -1 + + 0 + + 5 + 5 + + image0 +
+
+ + + image0 + 789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758 + + screenZoomSB screenDpiSB -- 2.39.2