📄 kfontdialog.cpp
字号:
/* $Id: kfontdialog.cpp,v 1.1 2003/09/08 19:42:09 jasonk Exp $ Requires the Qt widget libraries, available at no cost at http://www.troll.no Copyright (C) 1996 Bernd Johannes Wuebben wuebben@math.cornell.edu This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. $Log: kfontdialog.cpp,v $ Revision 1.1 2003/09/08 19:42:09 jasonk Addition of packages directory and associated files. Revision 1.1.1.1 2003/08/07 21:18:32 jasonk Initial import of PIXIL into new cvs repository. Revision 1.1.1.1 2003/06/23 22:04:23 jasonk Revision 1.1.1.1 2000/07/07 16:10:59 jasonk Initial import of ViewML Revision 1.29 1999/01/18 10:56:41 kulow .moc files are back in kdelibs. Built fine here using automake 1.3 Revision 1.28 1999/01/15 09:31:00 kulow it's official - kdelibs builds with srcdir != builddir. For this I automocifized it, the generated rules are easier to maintain than selfwritten rules. I have to fight with some bugs of this tool, but generally it's better than keeping them updated by hand. Revision 1.27 1998/11/30 19:31:32 lavikka Now kfontdialog uses QLayout instead of hardcoded widget coordinates. Command buttons are aligned correctly as well. Looks good and behaves well. Revision 1.26 1998/09/14 20:44:04 kulow I know, Ok is ok too, but OK is more OK some GUI guides say :) Revision 1.25 1998/09/01 20:21:53 kulow I renamed all old qt header files to the new versions. I think, this looks nicer (and gives the change in configure a sense :) Revision 1.24 1998/08/31 12:43:26 esken GPL -> LGPL Revision 1.23 1998/06/15 12:49:33 kulow applied patch to replace .kde with localkdedir() Revision 1.22 1998/06/10 18:23:37 schreter New klocale code had a little bug - it tried to find if there is "charsets" file in a locale dir instead of "charset" file, but then opened "charset" file. So I've fixed it. I've also fixed font dialog label sizes. Revision 1.21 1998/06/01 09:13:34 kalle Added static getFontAndText() Revision 1.20 1998/06/01 08:42:41 kalle KFontDialog: - you can now enter your own example string - new static method getXLFD() that converts a QFont() to a X Logical Font Description KIntegerLine: - new signal valueChanged( int ) Revision 1.19 1998/05/27 20:38:48 schreter Fixed font dialog charset display problem - combo wouldn't load charsets for current font on invocation of the dialog. Revision 1.18 1998/04/12 08:56:13 jacek Small fix in setting charset combo Revision 1.17 1998/03/08 22:08:49 wuebben Bernd: adjusted the size of kfontdialog for localization Revision 1.16 1998/01/21 15:06:57 jacek Added real KCharsets support Revision 1.14 1997/11/20 22:36:48 kalle - Removed some more hardcoded colors - A patch from Bernd regarding KProgress Revision 1.13 1997/11/09 22:56:11 wuebben Bernd: colorscheme related changes Revision 1.12 1997/11/09 05:18:57 wuebben Bernd: fix Revision 1.11 1997/11/09 04:41:44 wuebben Bernd: fixed the broken kfontdialog ... Revision 1.10 1997/11/09 03:45:55 wuebben *** empty log message *** Revision 1.9 1997/10/21 20:45:00 kulow removed all NULLs and replaced it with 0L or "". There are some left in mediatool, but this is not C++ Revision 1.8 1997/10/16 11:15:21 torben Kalle: Copyright headers kdoctoolbar removed Revision 1.7 1997/08/31 19:18:37 kdecvs Kalle: new usage of KLocale default string for KConfig::readEntry to const char* Revision 1.6 1997/08/24 20:40:40 kulow Coolo: translated the dialogs and others. I hope, noone minds. Revision 1.5 1997/07/24 21:06:04 kalle Kalle: KToolBar upgraded to newtoolbar 0.6 KTreeList has rubberbanding now Patches for SGI Revision 1.4 1997/05/03 19:37:02 kulow Coolo: Again a little bug in acinclude included the moc file in kfontdialog Revision 1.3 1997/05/02 16:46:39 kalle Kalle: You may now override how KApplication reacts to external changes KButton uses the widget default palette new kfontdialog version 0,5 new kpanner by Paul Kendall new: KIconLoader Revision 1.4 1997/04/29 02:44:24 wuebben *** empty log message *** Revision 1.3 1997/04/27 01:50:49 wuebben added ~/.kde/config/kdefonts support Revision 1.2 1997/04/20 14:59:44 wuebben fixed a minor bug which caused the last font in the font list to not be displayed Revision 1.1 1997/04/20 00:18:15 wuebben Initial revision Revision 1.1 1997/01/04 17:36:44 wuebben Initial revision*/#ifdef HAVE_CONFIG_H#include <config.h>#endif#include "kfontdialog.h"#include "stdio.h"#include "stdlib.h"#include "qfile.h"#include <qstrlist.h> #include <qfile.h>#include <qtextstream.h> #include <qapplication.h>#include <X11/Xlib.h>#include <klocale.h>#include <kcharsets.h>#include <kapp.h>#define MINSIZE(x) x->setMinimumSize(x->sizeHint());KFontDialog::KFontDialog( QWidget *parent, const char *name, bool modal, const QStrList* fontlist) : QDialog( parent, name, modal ){ QPushButton *button; setCaption( klocale->translate("Select Font") ); layout = new QVBoxLayout(this, 10); box1 = new QGroupBox(klocale->translate("Requested Font"), this); box2 = new QGroupBox(klocale->translate("Actual Font"), this); box1layout = new QGridLayout(box1, 5, 7, 7); box1layout->addColSpacing(0, 3); box1layout->addColSpacing(6, 3); box1layout->addRowSpacing(0, 13); box1layout->addRowSpacing(4, 3); box1layout->addColSpacing(3, 10); box1layout->setColStretch(2, 1); box1layout->setColStretch(5, 1); box2layout = new QGridLayout(box2, 7, 5, 7); box2layout->addColSpacing(0, 3); box2layout->addColSpacing(4, 3); box2layout->addRowSpacing(0, 13); box2layout->addRowSpacing(6, 3); box2layout->setColStretch(2, 1); box2layout->setColStretch(3, 2); family_label = new QLabel(box1,"family"); family_label->setText( klocale->translate("Family:") ); MINSIZE(family_label); box1layout->addWidget(family_label, 1, 1); actual_family_label = new QLabel(box2,"afamily"); actual_family_label->setText(klocale->translate("Family:")); MINSIZE(actual_family_label); actual_family_label_data = new QLabel(box2,"afamilyd"); box2layout->addWidget(actual_family_label, 2, 1); box2layout->addWidget(actual_family_label_data, 2, 2); charset_label = new QLabel(box1,"charset"); charset_label->setText(klocale->translate("Charset:")); MINSIZE(charset_label); box1layout->addWidget(charset_label, 3, 1); actual_charset_label = new QLabel(box2,"acharset"); actual_charset_label->setText(klocale->translate("Charset:")); MINSIZE(actual_charset_label); actual_charset_label_data = new QLabel(box2,"acharsetd"); box2layout->addWidget(actual_charset_label, 1, 1); box2layout->addWidget(actual_charset_label_data, 1, 2); size_label = new QLabel(box1,"size"); size_label->setText(klocale->translate("Size:")); MINSIZE(size_label); box1layout->addWidget(size_label, 1, 4); actual_size_label = new QLabel(box2,"asize"); actual_size_label->setText(klocale->translate("Size:")); MINSIZE(actual_size_label); actual_size_label_data = new QLabel(box2,"asized"); box2layout->addWidget(actual_size_label, 3, 1); box2layout->addWidget(actual_size_label_data, 3, 2); weight_label = new QLabel(box1,"weight"); weight_label->setText(klocale->translate("Weight:")); MINSIZE(weight_label); box1layout->addWidget(weight_label, 2, 1); actual_weight_label = new QLabel(box2,"aweight"); actual_weight_label->setText(klocale->translate("Weight:")); MINSIZE(actual_weight_label); actual_weight_label_data = new QLabel(box2,"aweightd"); box2layout->addWidget(actual_weight_label, 4, 1); box2layout->addWidget(actual_weight_label_data, 4, 2); style_label = new QLabel(box1,"style"); style_label->setText(klocale->translate("Style:")); MINSIZE(style_label); box1layout->addWidget(style_label, 2, 4); actual_style_label = new QLabel(box2,"astyle"); actual_style_label->setText(klocale->translate("Style:")); MINSIZE(actual_style_label); actual_style_label_data = new QLabel(box2,"astyled"); box2layout->addWidget(actual_style_label, 5, 1); box2layout->addWidget(actual_style_label_data, 5, 2); family_combo = new QComboBox(true, box1, "Family" ); box1layout->addWidget(family_combo, 1, 2); family_combo->setInsertionPolicy(QComboBox::NoInsertion); connect( family_combo, SIGNAL(activated(const char *)), SLOT(family_chosen_slot(const char *)) ); if (fontlist != 0L){ if(fontlist->count() !=0){ family_combo->insertStrList(fontlist, -1); // this is a dirty fix due to a bug in Qt 1.2 family_combo->setCurrentItem(1); family_combo->setCurrentItem(0); } } else{ fill_family_combo(); } MINSIZE(family_combo); size_combo = new QComboBox( true, box1, klocale->translate("Size") ); box1layout->addWidget(size_combo, 1, 5); size_combo->insertItem( "4" ); size_combo->insertItem( "5" ); size_combo->insertItem( "6" ); size_combo->insertItem( "7" ); size_combo->insertItem( "8" ); size_combo->insertItem( "9" ); size_combo->insertItem( "10" ); size_combo->insertItem( "11" ); size_combo->insertItem( "12" ); size_combo->insertItem( "13" ); size_combo->insertItem( "14" ); size_combo->insertItem( "15" ); size_combo->insertItem( "16" ); size_combo->insertItem( "17" ); size_combo->insertItem( "18" ); size_combo->insertItem( "19" ); size_combo->insertItem( "20" ); size_combo->insertItem( "22" ); size_combo->insertItem( "24" ); size_combo->insertItem( "26" ); size_combo->insertItem( "28" ); size_combo->insertItem( "32" ); size_combo->insertItem( "48" ); size_combo->insertItem( "64" ); // we may want to allow the user to choose another size, since I // can really not presume to have listed all useful sizes. // size_combo->setInsertionPolicy(QComboBox::NoInsertion); connect( size_combo, SIGNAL(activated(const char *)), SLOT(size_chosen_slot(const char *)) ); MINSIZE(size_combo); weight_combo = new QComboBox( TRUE, box1, klocale->translate("Weight") ); box1layout->addWidget(weight_combo, 2, 2); weight_combo->insertItem( klocale->translate("normal") ); weight_combo->insertItem( klocale->translate("bold") ); weight_combo->setInsertionPolicy(QComboBox::NoInsertion); connect( weight_combo, SIGNAL(activated(const char *)), SLOT(weight_chosen_slot(const char *)) ); // QToolTip::add( weight_combo, "Select Font Weight" ); MINSIZE(weight_combo); style_combo = new QComboBox( TRUE, box1, klocale->translate("Style") ); box1layout->addWidget(style_combo, 2, 5); style_combo->insertItem( klocale->translate("roman") ); style_combo->insertItem( klocale->translate("italic") ); style_combo->setInsertionPolicy(QComboBox::NoInsertion); connect( style_combo, SIGNAL(activated(const char *)), SLOT(style_chosen_slot(const char *)) ); MINSIZE(style_combo); charset_combo = new QComboBox( TRUE, box1, klocale->translate("Charset") ); box1layout->addWidget(charset_combo, 3, 2); charset_combo->setInsertionPolicy(QComboBox::NoInsertion); connect( charset_combo, SIGNAL(activated(const char *)), SLOT(charset_chosen_slot(const char *)) ); MINSIZE(charset_combo); example_edit = new QLineEdit(box2, "examples"); box2layout->addMultiCellWidget(example_edit, 1, 5, 3, 3); example_edit->setFont(selFont); // example_edit->setAlignment(AlignCenter); // example_edit->setBackgroundColor(white); // example_edit->setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); // example_edit->setLineWidth( 1 ); example_edit->setText(klocale->translate("Dolor Ipse")); // example_edit->setAutoResize(true); connect(this,SIGNAL(fontSelected( const QFont& )), this,SLOT(display_example( const QFont&))); MINSIZE(example_edit); // lets initialize the display if possible if(family_combo->count() != 0){ this->setFont(QFont(family_combo->text(0),12,QFont::Normal)); } // Create displayable charsets list KCharsets *charsets=KApplication::getKApplication()->getCharsets(); QStrList lst=charsets->displayable(selFont.family()); for(const char * chset=lst.first();chset;chset=lst.next()) charset_combo->insertItem( chset ); charset_combo->insertItem( "any" ); setColors(); connect(KApplication::getKApplication(),SIGNAL(kdisplayPaletteChanged()), this,SLOT(setColors())); box1layout->activate(); box2layout->activate(); layout->addWidget(box1, 1); layout->addWidget(box2, 1); KButtonBox *bbox = new KButtonBox(this); bbox->addStretch(1); button = bbox->addButton(klocale->translate("OK")); connect( button, SIGNAL( clicked() ), SLOT( accept() ) ); button = bbox->addButton(klocale->translate("Cancel")); connect( button, SIGNAL( clicked() ), SLOT( reject() ) ); bbox->layout(); bbox->setMinimumSize(bbox->sizeHint()); layout->addWidget(bbox, 0); layout->activate();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -