kdeprint Library API Documentation

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> This combo box shows (and lets you select) " 00034 " a print subsystem to be used by KDEPrint. (This print" 00035 " subsystem must, of course, be installed inside your" 00036 " Operating System.) KDEPrint usually auto-detects it." 00037 " Most Linux distributions have \"CUPS\", the <em>Common" 00038 " Unix Printing System</em>." 00039 " </qt>" ); 00040 00041 m_combo = new QComboBox(this, "PluginCombo"); 00042 QWhatsThis::add(m_combo, whatsThisCurrentPrintsystem); 00043 QLabel *m_label = new QLabel(i18n("Print s&ystem currently used:"), this); 00044 QWhatsThis::add(m_label, whatsThisCurrentPrintsystem); 00045 m_label->setAlignment(AlignVCenter|AlignRight); 00046 m_label->setBuddy(m_combo); 00047 m_plugininfo = new QLabel("Plugin information", this); 00048 QGridLayout *l0 = new QGridLayout(this, 2, 2, 0, 5); 00049 l0->setColStretch(0, 1); 00050 l0->addWidget(m_label, 0, 0); 00051 l0->addWidget(m_combo, 0, 1); 00052 l0->addWidget(m_plugininfo, 1, 1); 00053 00054 QValueList<KMFactory::PluginInfo> list = KMFactory::self()->pluginList(); 00055 QString currentPlugin = KMFactory::self()->printSystem(); 00056 for (QValueList<KMFactory::PluginInfo>::ConstIterator it=list.begin(); it!=list.end(); ++it) 00057 { 00058 m_combo->insertItem((*it).comment); 00059 if ((*it).name == currentPlugin) 00060 m_combo->setCurrentItem(m_combo->count()-1); 00061 m_pluginlist.append((*it).name); 00062 } 00063 00064 connect(m_combo, SIGNAL(activated(int)), SLOT(slotActivated(int))); 00065 configChanged(); 00066 } 00067 00068 void PluginComboBox::slotActivated(int index) 00069 { 00070 QString plugin = m_pluginlist[index]; 00071 if (!plugin.isEmpty()) 00072 { 00073 // the factory will notify all registered objects of the change 00074 KMFactory::self()->reload(plugin, true); 00075 } 00076 } 00077 00078 void PluginComboBox::reload() 00079 { 00080 QString syst = KMFactory::self()->printSystem(); 00081 int index(-1); 00082 if ((index=m_pluginlist.findIndex(syst)) != -1) 00083 m_combo->setCurrentItem(index); 00084 configChanged(); 00085 } 00086 00087 void PluginComboBox::configChanged() 00088 { 00089 QString whatsThisCurrentConnection = i18n(" <qt> This line shows to which CUPS server your PC" 00090 " currently is connected for printing and retrieving" 00091 " printer info. To switch to a different CUPS server," 00092 " click \"System Options\", then select \"Cups server\"" 00093 " and fill in the required info." 00094 " </qt>" ); 00095 00096 m_plugininfo->setText(KMManager::self()->stateInformation()); 00097 QWhatsThis::add(m_plugininfo, whatsThisCurrentConnection); 00098 00099 } 00100 00101 #include "plugincombobox.moc"
KDE Logo
This file is part of the documentation for kdeprint Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Aug 30 22:55:51 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003