plugincombobox.cpp
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
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         
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"
 
This file is part of the documentation for kdeprint Library Version 3.2.0.