• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeprint
 

tdeprint

  • tdeprint
  • management
kmconfigfonts.cpp
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License version 2 as published by the Free Software Foundation.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB. If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  **/
19 
20 #include "kmconfigfonts.h"
21 
22 #include <tqgroupbox.h>
23 #include <kpushbutton.h>
24 #include <tqlayout.h>
25 #include <tqheader.h>
26 #include <tqlabel.h>
27 #include <tqcheckbox.h>
28 #include <tqsettings.h>
29 #include <tqwhatsthis.h>
30 
31 #include <tdelocale.h>
32 #include <tdeconfig.h>
33 #include <kiconloader.h>
34 #include <kurlrequester.h>
35 #include <tdefile.h>
36 #include <tdelistview.h>
37 #include <kdialog.h>
38 
39 KMConfigFonts::KMConfigFonts(TQWidget *parent, const char *name)
40 : KMConfigPage(parent, name)
41 {
42  setPageName(i18n("Fonts"));
43  setPageHeader(i18n("Font Settings"));
44  setPagePixmap("fonts");
45 
46  TQGroupBox *box = new TQGroupBox(0, TQt::Vertical, i18n("Fonts Embedding"), this);
47  TQGroupBox *box2 = new TQGroupBox(0, TQt::Vertical, i18n("Fonts Path"), this);
48 
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);
63 
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());
69  l1->addLayout(l2);
70  l2->addWidget(m_up);
71  l2->addWidget(m_down);
72  l2->addWidget(m_remove);
73  l1->addSpacing(10);
74  l1->addWidget(lab0);
75  l1->addWidget(m_addpath);
76  TQHBoxLayout *l3 = new TQHBoxLayout(0, 0, KDialog::spacingHint());
77  l1->addLayout(l3);
78  l3->addStretch(1);
79  l3->addWidget(m_add);
80  TQVBoxLayout *l4 = new TQVBoxLayout(this, 0, KDialog::spacingHint());
81  l4->addWidget(box);
82  l4->addWidget(box2);
83 
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."));
93 
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);
104 }
105 
106 void KMConfigFonts::loadConfig(TDEConfig *)
107 {
108  TQSettings settings;
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);
114 }
115 
116 void KMConfigFonts::saveConfig(TDEConfig *)
117 {
118  TQSettings settings;
119  settings.writeEntry("/qt/embedFonts", m_embedfonts->isChecked());
120  TQStringList l;
121  TQListViewItem *item = m_fontpath->firstChild();
122  while (item)
123  {
124  l << item->text(0);
125  item = item->nextSibling();
126  }
127  settings.writeEntry("/qt/fontPath", l, ':');
128 }
129 
130 void KMConfigFonts::slotSelected()
131 {
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());
136 }
137 
138 void KMConfigFonts::slotAdd()
139 {
140  if (m_addpath->url().isEmpty())
141  return;
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);
147 }
148 
149 void KMConfigFonts::slotRemove()
150 {
151  delete m_fontpath->selectedItem();
152  if (m_fontpath->currentItem())
153  m_fontpath->setSelected(m_fontpath->currentItem(), true);
154  slotSelected();
155 }
156 
157 void KMConfigFonts::slotUp()
158 {
159  TQListViewItem *citem = m_fontpath->selectedItem(), *nitem = 0;
160  if (!citem || !citem->itemAbove())
161  return;
162  nitem = new TQListViewItem(m_fontpath, citem->itemAbove()->itemAbove(), citem->text(0));
163  delete citem;
164  m_fontpath->setSelected(nitem, true);
165 }
166 
167 void KMConfigFonts::slotDown()
168 {
169  TQListViewItem *citem = m_fontpath->selectedItem(), *nitem = 0;
170  if (!citem || !citem->itemBelow())
171  return;
172  nitem = new TQListViewItem(m_fontpath, citem->itemBelow(), citem->text(0));
173  delete citem;
174  m_fontpath->setSelected(nitem, true);
175 }
176 
177 void KMConfigFonts::slotTextChanged(const TQString& t)
178 {
179  m_add->setEnabled(!t.isEmpty());
180 }
181 
182 #include "kmconfigfonts.moc"

tdeprint

Skip menu "tdeprint"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdeprint

Skip menu "tdeprint"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeprint by doxygen 1.9.1
This website is maintained by Timothy Pearson.