# kdeprint Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# kmconfigfonts.cpp

    00001 /*
    00002  *  This file is part of the KDE libraries
    00003  *  Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be>
    00004  *
    00005  *  This library is free software; you can redistribute it and/or
    00006  *  modify it under the terms of the GNU Library General Public
    00007  *  License version 2 as published by the Free Software Foundation.
    00008  *
    00009  *  This library is distributed in the hope that it will be useful,
    00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00012  *  Library General Public License for more details.
    00013  *
    00014  *  You should have received a copy of the GNU Library General Public License
    00015  *  along with this library; see the file COPYING.LIB.  If not, write to
    00016  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00017  *  Boston, MA 02111-1307, USA.
    00018  **/
    00019
    00020 #include "kmconfigfonts.h"
    00021
    00022 #include <qgroupbox.h>
    00023 #include <kpushbutton.h>
    00024 #include <qlayout.h>
    00025 #include <qheader.h>
    00026 #include <qlabel.h>
    00027 #include <qcheckbox.h>
    00028 #include <qsettings.h>
    00029 #include <qwhatsthis.h>
    00030
    00031 #include <klocale.h>
    00032 #include <kconfig.h>
    00033 #include <kiconloader.h>
    00034 #include <kurlrequester.h>
    00035 #include <kfile.h>
    00036 #include <klistview.h>
    00037 #include <kdialog.h>
    00038
    00039 KMConfigFonts::KMConfigFonts(QWidget *parent, const char *name)
    00040 : KMConfigPage(parent, name)
    00041 {
    00042     setPageName(i18n("Fonts"));
    00043     setPageHeader(i18n("Font Settings"));
    00044     setPagePixmap("fonts");
    00045
    00046     QGroupBox   *box = new QGroupBox(0, Qt::Vertical, i18n("Fonts Embedding"), this);
    00047     QGroupBox   *box2 = new QGroupBox(0, Qt::Vertical, i18n("Fonts Path"), this);
    00048
    00049     m_embedfonts = new QCheckBox(i18n("&Embed fonts in PostScript data when printing"), box);
    00050     m_fontpath = new KListView(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"), "up"), box2);
    00058     m_down = new KPushButton(KGuiItem(i18n("&Down"), "down"), box2);
    00059     m_add = new KPushButton(KGuiItem(i18n("&Add"), "add"), box2);
    00060     m_remove = new KPushButton(KGuiItem(i18n("&Remove"), "editdelete"), box2);
    00061     QLabel  *lab0 = new QLabel(i18n("Additional director&y:"), box2);
    00062     lab0->setBuddy(m_addpath);
    00063
    00064     QVBoxLayout *l0 = new QVBoxLayout(box->layout(), KDialog::spacingHint());
    00065     l0->addWidget(m_embedfonts);
    00066     QVBoxLayout *l1 = new QVBoxLayout(box2->layout(), KDialog::spacingHint());
    00067     l1->addWidget(m_fontpath);
    00068     QHBoxLayout *l2 = new QHBoxLayout(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     QHBoxLayout *l3 = new QHBoxLayout(0, 0, KDialog::spacingHint());
    00077     l1->addLayout(l3);
    00078     l3->addStretch(1);
    00079     l3->addWidget(m_add);
    00080     QVBoxLayout *l4 = new QVBoxLayout(this, 0, KDialog::spacingHint());
    00081     l4->addWidget(box);
    00082     l4->addWidget(box2);
    00083
    00084     QWhatsThis::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     QWhatsThis::add(m_fontpath,
    00089             i18n("When using font embedding you can select additional directories where "
    00090                  "KDE 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, SIGNAL(clicked()), SLOT(slotRemove()));
    00095     connect(m_add, SIGNAL(clicked()), SLOT(slotAdd()));
    00096     connect(m_up, SIGNAL(clicked()), SLOT(slotUp()));
    00097     connect(m_down, SIGNAL(clicked()), SLOT(slotDown()));
    00098     connect(m_fontpath, SIGNAL(selectionChanged()), SLOT(slotSelected()));
    00099     connect(m_addpath, SIGNAL(textChanged(const QString&)), SLOT(slotTextChanged(const QString&)));
    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(KConfig *)
    00107 {
    00108     QSettings   settings;
    00109     m_embedfonts->setChecked(settings.readBoolEntry("/qt/embedFonts", true));
    00110     QStringList paths = settings.readListEntry("/qt/fontPath", ':');
    00111     QListViewItem   *item(0);
    00112     for (QStringList::ConstIterator it=paths.begin(); it!=paths.end(); ++it)
    00113         item = new QListViewItem(m_fontpath, item, *it);
    00114 }
    00115
    00116 void KMConfigFonts::saveConfig(KConfig *)
    00117 {
    00118     QSettings   settings;
    00119     settings.writeEntry("/qt/embedFonts", m_embedfonts->isChecked());
    00120     QStringList l;
    00121     QListViewItem   *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     QListViewItem   *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     QListViewItem   *lastItem(m_fontpath->firstChild());
    00143     while (lastItem && lastItem->nextSibling())
    00144         lastItem = lastItem->nextSibling();
    00145     QListViewItem   *item = new QListViewItem(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     QListViewItem   *citem = m_fontpath->selectedItem(), *nitem = 0;
    00160     if (!citem || !citem->itemAbove())
    00161         return;
    00162     nitem = new QListViewItem(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     QListViewItem   *citem = m_fontpath->selectedItem(), *nitem = 0;
    00170     if (!citem || !citem->itemBelow())
    00171         return;
    00172     nitem = new QListViewItem(m_fontpath, citem->itemBelow(), citem->text(0));
    00173     delete citem;
    00174     m_fontpath->setSelected(nitem, true);
    00175 }
    00176
    00177 void KMConfigFonts::slotTextChanged(const QString& t)
    00178 {
    00179     m_add->setEnabled(!t.isEmpty());
    00180 }
    00181
    00182 #include "kmconfigfonts.moc"

This file is part of the documentation for kdeprint Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:31:01 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003