# kdeprint Library API Documentation

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

# plugincombobox.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 "plugincombobox.h"
    00021 #include "kmfactory.h"
    00022 #include "kmmanager.h"
    00023
    00024 #include <qcombobox.h>
    00025 #include <qlabel.h>
    00026 #include <qlayout.h>
    00027 #include <klocale.h>
    00028 #include <qwhatsthis.h>
    00029
    00030 PluginComboBox::PluginComboBox(QWidget *parent, const char *name)
    00031 :QWidget(parent, name)
    00032 {
    00033         QString whatsThisCurrentPrintsystem = i18n(" <qt><b>Print Subsystem Selection</b>"
    00034                         " <p>This combo box shows (and lets you select)"
    00035                         " a print subsystem to be used by KDEPrint. (This print"
    00036                         " subsystem must, of course, be installed inside your"
    00037                         " Operating System.) KDEPrint usually auto-detects the"
    00038                                                 " correct print subsystem by itself upon first startup."
    00039                         " Most Linux distributions have \"CUPS\", the <em>Common"
    00040                         " UNIX Printing System</em>."
    00041                                                 " </qt>" );
    00042
    00043     m_combo = new QComboBox(this, "PluginCombo");
    00044         QWhatsThis::add(m_combo, whatsThisCurrentPrintsystem);
    00045     QLabel  *m_label = new QLabel(i18n("Print s&ystem currently used:"), this);
    00046         QWhatsThis::add(m_label, whatsThisCurrentPrintsystem);
    00047     m_label->setAlignment(AlignVCenter|AlignRight);
    00048     m_label->setBuddy(m_combo);
    00049     m_plugininfo = new QLabel("Plugin information", this);
    00050     QGridLayout *l0 = new QGridLayout(this, 2, 2, 0, 5);
    00051     l0->setColStretch(0, 1);
    00052     l0->addWidget(m_label, 0, 0);
    00053     l0->addWidget(m_combo, 0, 1);
    00054     l0->addWidget(m_plugininfo, 1, 1);
    00055
    00056     QValueList<KMFactory::PluginInfo>   list = KMFactory::self()->pluginList();
    00057     QString         currentPlugin = KMFactory::self()->printSystem();
    00058     for (QValueList<KMFactory::PluginInfo>::ConstIterator it=list.begin(); it!=list.end(); ++it)
    00059     {
    00060         m_combo->insertItem((*it).comment);
    00061         if ((*it).name == currentPlugin)
    00062             m_combo->setCurrentItem(m_combo->count()-1);
    00063         m_pluginlist.append((*it).name);
    00064     }
    00065
    00066     connect(m_combo, SIGNAL(activated(int)), SLOT(slotActivated(int)));
    00067     configChanged();
    00068 }
    00069
    00070 void PluginComboBox::slotActivated(int index)
    00071 {
    00072     QString plugin = m_pluginlist[index];
    00073     if (!plugin.isEmpty())
    00074     {
    00075         // the factory will notify all registered objects of the change
    00076         KMFactory::self()->reload(plugin, true);
    00077     }
    00078 }
    00079
    00080 void PluginComboBox::reload()
    00081 {
    00082     QString syst = KMFactory::self()->printSystem();
    00083     int index(-1);
    00084     if ((index=m_pluginlist.findIndex(syst)) != -1)
    00085         m_combo->setCurrentItem(index);
    00086     configChanged();
    00087 }
    00088
    00089 void PluginComboBox::configChanged()
    00090 {
    00091         QString whatsThisCurrentConnection = i18n(" <qt><b>Current Connection</b>"
    00092                         " <p>This line shows which CUPS server your PC is"
    00093                         " currently connected to for printing and retrieving"
    00094                         " printer info. To switch to a different CUPS server,"
    00095                         " click \"System Options\", then select \"Cups server\""
    00096                         " and fill in the required info."
    00097                                                 " </qt>" );
    00098
    00099     m_plugininfo->setText(KMManager::self()->stateInformation());
    00100         QWhatsThis::add(m_plugininfo, whatsThisCurrentConnection);
    00101
    00102 }
    00103
    00104 #include "plugincombobox.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:05 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003