20 #include "kmconfigfonts.h"
22 #include <tqgroupbox.h>
23 #include <kpushbutton.h>
27 #include <tqcheckbox.h>
28 #include <tqsettings.h>
29 #include <tqwhatsthis.h>
31 #include <tdelocale.h>
32 #include <tdeconfig.h>
33 #include <kiconloader.h>
34 #include <kurlrequester.h>
36 #include <tdelistview.h>
39 KMConfigFonts::KMConfigFonts(TQWidget *parent,
const char *name)
40 : KMConfigPage(parent, name)
42 setPageName(i18n(
"Fonts"));
43 setPageHeader(i18n(
"Font Settings"));
44 setPagePixmap(
"fonts");
46 TQGroupBox *box =
new TQGroupBox(0, TQt::Vertical, i18n(
"Fonts Embedding"),
this);
47 TQGroupBox *box2 =
new TQGroupBox(0, TQt::Vertical, i18n(
"Fonts Path"),
this);
49 m_embedfonts =
new TQCheckBox(i18n(
"&Embed fonts in PostScript data when printing"), box);
50 m_fontpath =
new TDEListView(box2);
51 m_fontpath->addColumn(
"");
52 m_fontpath->header()->setStretchEnabled(
true, 0);
53 m_fontpath->header()->hide();
54 m_fontpath->setSorting(-1);
55 m_addpath =
new KURLRequester(box2);
56 m_addpath->setMode(KFile::Directory|KFile::ExistingOnly|KFile::LocalOnly);
57 m_up =
new KPushButton(KGuiItem(i18n(
"&Up"),
"go-up"), box2);
58 m_down =
new KPushButton(KGuiItem(i18n(
"&Down"),
"go-down"), box2);
59 m_add =
new KPushButton(KGuiItem(i18n(
"&Add"),
"add"), box2);
60 m_remove =
new KPushButton(KGuiItem(i18n(
"&Remove"),
"edit-delete"), box2);
61 TQLabel *lab0 =
new TQLabel(i18n(
"Additional director&y:"), box2);
62 lab0->setBuddy(m_addpath);
64 TQVBoxLayout *l0 =
new TQVBoxLayout(box->layout(), KDialog::spacingHint());
65 l0->addWidget(m_embedfonts);
66 TQVBoxLayout *l1 =
new TQVBoxLayout(box2->layout(), KDialog::spacingHint());
67 l1->addWidget(m_fontpath);
68 TQHBoxLayout *l2 =
new TQHBoxLayout(0, 0, KDialog::spacingHint());
71 l2->addWidget(m_down);
72 l2->addWidget(m_remove);
75 l1->addWidget(m_addpath);
76 TQHBoxLayout *l3 =
new TQHBoxLayout(0, 0, KDialog::spacingHint());
80 TQVBoxLayout *l4 =
new TQVBoxLayout(
this, 0, KDialog::spacingHint());
84 TQWhatsThis::add(m_embedfonts,
85 i18n(
"These options will automatically put fonts in the PostScript file "
86 "which are not present on the printer. Font embedding usually produces better print results "
87 "(closer to what you see on the screen), but larger print data as well."));
88 TQWhatsThis::add(m_fontpath,
89 i18n(
"When using font embedding you can select additional directories where "
90 "TDE should search for embeddable font files. By default, the X server "
91 "font path is used, so adding those directories is not needed. The default "
92 "search path should be sufficient in most cases."));
94 connect(m_remove, TQ_SIGNAL(clicked()), TQ_SLOT(slotRemove()));
95 connect(m_add, TQ_SIGNAL(clicked()), TQ_SLOT(slotAdd()));
96 connect(m_up, TQ_SIGNAL(clicked()), TQ_SLOT(slotUp()));
97 connect(m_down, TQ_SIGNAL(clicked()), TQ_SLOT(slotDown()));
98 connect(m_fontpath, TQ_SIGNAL(selectionChanged()), TQ_SLOT(slotSelected()));
99 connect(m_addpath, TQ_SIGNAL(textChanged(
const TQString&)), TQ_SLOT(slotTextChanged(
const TQString&)));
100 m_add->setEnabled(
false);
101 m_remove->setEnabled(
false);
102 m_up->setEnabled(
false);
103 m_down->setEnabled(
false);
106 void KMConfigFonts::loadConfig(TDEConfig *)
109 m_embedfonts->setChecked(settings.readBoolEntry(
"/qt/embedFonts",
true));
110 TQStringList paths = settings.readListEntry(
"/qt/fontPath",
':');
111 TQListViewItem *item(0);
112 for (TQStringList::ConstIterator it=paths.begin(); it!=paths.end(); ++it)
113 item =
new TQListViewItem(m_fontpath, item, *it);
116 void KMConfigFonts::saveConfig(TDEConfig *)
119 settings.writeEntry(
"/qt/embedFonts", m_embedfonts->isChecked());
121 TQListViewItem *item = m_fontpath->firstChild();
125 item = item->nextSibling();
127 settings.writeEntry(
"/qt/fontPath", l,
':');
130 void KMConfigFonts::slotSelected()
132 TQListViewItem *item = m_fontpath->selectedItem();
133 m_remove->setEnabled(item);
134 m_up->setEnabled(item && item->itemAbove());
135 m_down->setEnabled(item && item->itemBelow());
138 void KMConfigFonts::slotAdd()
140 if (m_addpath->url().isEmpty())
142 TQListViewItem *lastItem(m_fontpath->firstChild());
143 while (lastItem && lastItem->nextSibling())
144 lastItem = lastItem->nextSibling();
145 TQListViewItem *item =
new TQListViewItem(m_fontpath, lastItem, m_addpath->url());
146 m_fontpath->setSelected(item,
true);
149 void KMConfigFonts::slotRemove()
151 delete m_fontpath->selectedItem();
152 if (m_fontpath->currentItem())
153 m_fontpath->setSelected(m_fontpath->currentItem(),
true);
157 void KMConfigFonts::slotUp()
159 TQListViewItem *citem = m_fontpath->selectedItem(), *nitem = 0;
160 if (!citem || !citem->itemAbove())
162 nitem =
new TQListViewItem(m_fontpath, citem->itemAbove()->itemAbove(), citem->text(0));
164 m_fontpath->setSelected(nitem,
true);
167 void KMConfigFonts::slotDown()
169 TQListViewItem *citem = m_fontpath->selectedItem(), *nitem = 0;
170 if (!citem || !citem->itemBelow())
172 nitem =
new TQListViewItem(m_fontpath, citem->itemBelow(), citem->text(0));
174 m_fontpath->setSelected(nitem,
true);
177 void KMConfigFonts::slotTextChanged(
const TQString& t)
179 m_add->setEnabled(!t.isEmpty());
182 #include "kmconfigfonts.moc"