00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "kmconfigfonts.h"
00021
00022 #include <tqgroupbox.h>
00023 #include <kpushbutton.h>
00024 #include <tqlayout.h>
00025 #include <tqheader.h>
00026 #include <tqlabel.h>
00027 #include <tqcheckbox.h>
00028 #include <tqsettings.h>
00029 #include <tqwhatsthis.h>
00030
00031 #include <tdelocale.h>
00032 #include <tdeconfig.h>
00033 #include <kiconloader.h>
00034 #include <kurlrequester.h>
00035 #include <tdefile.h>
00036 #include <tdelistview.h>
00037 #include <kdialog.h>
00038
00039 KMConfigFonts::KMConfigFonts(TQWidget *parent, const char *name)
00040 : KMConfigPage(parent, name)
00041 {
00042 setPageName(i18n("Fonts"));
00043 setPageHeader(i18n("Font Settings"));
00044 setPagePixmap("fonts");
00045
00046 TQGroupBox *box = new TQGroupBox(0, Qt::Vertical, i18n("Fonts Embedding"), this);
00047 TQGroupBox *box2 = new TQGroupBox(0, Qt::Vertical, i18n("Fonts Path"), this);
00048
00049 m_embedfonts = new TQCheckBox(i18n("&Embed fonts in PostScript data when printing"), box);
00050 m_fontpath = new TDEListView(box2);
00051 m_fontpath->addColumn("");
00052 m_fontpath->header()->setStretchEnabled(true, 0);
00053 m_fontpath->header()->hide();
00054 m_fontpath->setSorting(-1);
00055 m_addpath = new KURLRequester(box2);
00056 m_addpath->setMode(KFile::Directory|KFile::ExistingOnly|KFile::LocalOnly);
00057 m_up = new KPushButton(KGuiItem(i18n("&Up"), "go-up"), box2);
00058 m_down = new KPushButton(KGuiItem(i18n("&Down"), "go-down"), box2);
00059 m_add = new KPushButton(KGuiItem(i18n("&Add"), "add"), box2);
00060 m_remove = new KPushButton(KGuiItem(i18n("&Remove"), "edit-delete"), box2);
00061 TQLabel *lab0 = new TQLabel(i18n("Additional director&y:"), box2);
00062 lab0->setBuddy(m_addpath);
00063
00064 TQVBoxLayout *l0 = new TQVBoxLayout(TQT_TQLAYOUT(box->layout()), KDialog::spacingHint());
00065 l0->addWidget(m_embedfonts);
00066 TQVBoxLayout *l1 = new TQVBoxLayout(TQT_TQLAYOUT(box2->layout()), KDialog::spacingHint());
00067 l1->addWidget(m_fontpath);
00068 TQHBoxLayout *l2 = new TQHBoxLayout(0, 0, KDialog::spacingHint());
00069 l1->addLayout(l2);
00070 l2->addWidget(m_up);
00071 l2->addWidget(m_down);
00072 l2->addWidget(m_remove);
00073 l1->addSpacing(10);
00074 l1->addWidget(lab0);
00075 l1->addWidget(m_addpath);
00076 TQHBoxLayout *l3 = new TQHBoxLayout(0, 0, KDialog::spacingHint());
00077 l1->addLayout(l3);
00078 l3->addStretch(1);
00079 l3->addWidget(m_add);
00080 TQVBoxLayout *l4 = new TQVBoxLayout(this, 0, KDialog::spacingHint());
00081 l4->addWidget(box);
00082 l4->addWidget(box2);
00083
00084 TQWhatsThis::add(m_embedfonts,
00085 i18n("These options will automatically put fonts in the PostScript file "
00086 "which are not present on the printer. Font embedding usually produces better print results "
00087 "(closer to what you see on the screen), but larger print data as well."));
00088 TQWhatsThis::add(m_fontpath,
00089 i18n("When using font embedding you can select additional directories where "
00090 "TDE should search for embeddable font files. By default, the X server "
00091 "font path is used, so adding those directories is not needed. The default "
00092 "search path should be sufficient in most cases."));
00093
00094 connect(m_remove, TQT_SIGNAL(clicked()), TQT_SLOT(slotRemove()));
00095 connect(m_add, TQT_SIGNAL(clicked()), TQT_SLOT(slotAdd()));
00096 connect(m_up, TQT_SIGNAL(clicked()), TQT_SLOT(slotUp()));
00097 connect(m_down, TQT_SIGNAL(clicked()), TQT_SLOT(slotDown()));
00098 connect(m_fontpath, TQT_SIGNAL(selectionChanged()), TQT_SLOT(slotSelected()));
00099 connect(m_addpath, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(slotTextChanged(const TQString&)));
00100 m_add->setEnabled(false);
00101 m_remove->setEnabled(false);
00102 m_up->setEnabled(false);
00103 m_down->setEnabled(false);
00104 }
00105
00106 void KMConfigFonts::loadConfig(TDEConfig *)
00107 {
00108 TQSettings settings;
00109 m_embedfonts->setChecked(settings.readBoolEntry("/qt/embedFonts", true));
00110 TQStringList paths = settings.readListEntry("/qt/fontPath", ':');
00111 TQListViewItem *item(0);
00112 for (TQStringList::ConstIterator it=paths.begin(); it!=paths.end(); ++it)
00113 item = new TQListViewItem(m_fontpath, item, *it);
00114 }
00115
00116 void KMConfigFonts::saveConfig(TDEConfig *)
00117 {
00118 TQSettings settings;
00119 settings.writeEntry("/qt/embedFonts", m_embedfonts->isChecked());
00120 TQStringList l;
00121 TQListViewItem *item = m_fontpath->firstChild();
00122 while (item)
00123 {
00124 l << item->text(0);
00125 item = item->nextSibling();
00126 }
00127 settings.writeEntry("/qt/fontPath", l, ':');
00128 }
00129
00130 void KMConfigFonts::slotSelected()
00131 {
00132 TQListViewItem *item = m_fontpath->selectedItem();
00133 m_remove->setEnabled(item);
00134 m_up->setEnabled(item && item->itemAbove());
00135 m_down->setEnabled(item && item->itemBelow());
00136 }
00137
00138 void KMConfigFonts::slotAdd()
00139 {
00140 if (m_addpath->url().isEmpty())
00141 return;
00142 TQListViewItem *lastItem(m_fontpath->firstChild());
00143 while (lastItem && lastItem->nextSibling())
00144 lastItem = lastItem->nextSibling();
00145 TQListViewItem *item = new TQListViewItem(m_fontpath, lastItem, m_addpath->url());
00146 m_fontpath->setSelected(item, true);
00147 }
00148
00149 void KMConfigFonts::slotRemove()
00150 {
00151 delete m_fontpath->selectedItem();
00152 if (m_fontpath->currentItem())
00153 m_fontpath->setSelected(m_fontpath->currentItem(), true);
00154 slotSelected();
00155 }
00156
00157 void KMConfigFonts::slotUp()
00158 {
00159 TQListViewItem *citem = m_fontpath->selectedItem(), *nitem = 0;
00160 if (!citem || !citem->itemAbove())
00161 return;
00162 nitem = new TQListViewItem(m_fontpath, citem->itemAbove()->itemAbove(), citem->text(0));
00163 delete citem;
00164 m_fontpath->setSelected(nitem, true);
00165 }
00166
00167 void KMConfigFonts::slotDown()
00168 {
00169 TQListViewItem *citem = m_fontpath->selectedItem(), *nitem = 0;
00170 if (!citem || !citem->itemBelow())
00171 return;
00172 nitem = new TQListViewItem(m_fontpath, citem->itemBelow(), citem->text(0));
00173 delete citem;
00174 m_fontpath->setSelected(nitem, true);
00175 }
00176
00177 void KMConfigFonts::slotTextChanged(const TQString& t)
00178 {
00179 m_add->setEnabled(!t.isEmpty());
00180 }
00181
00182 #include "kmconfigfonts.moc"