kmpropertypage.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., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 **/ 00019 00020 #include "kmpropertypage.h" 00021 #include "kmpropwidget.h" 00022 #include "kmpropcontainer.h" 00023 #include "kmprinter.h" 00024 #include "kmfactory.h" 00025 #include "kmuimanager.h" 00026 00027 #include "kmpropgeneral.h" 00028 00029 #include <tqvbox.h> 00030 #include <kiconloader.h> 00031 00032 KMPropertyPage::KMPropertyPage(TQWidget *parent, const char *name) 00033 : CJanusWidget(parent,name) 00034 { 00035 m_widgets.setAutoDelete(false); 00036 00037 initialize(); 00038 } 00039 00040 KMPropertyPage::~KMPropertyPage() 00041 { 00042 } 00043 00044 void KMPropertyPage::setPrinter(KMPrinter *p) 00045 { 00046 TQPtrListIterator<KMPropWidget> it(m_widgets); 00047 for (;it.current();++it) 00048 it.current()->setPrinterBase(p); 00049 } 00050 00051 void KMPropertyPage::addPropPage(KMPropWidget *w) 00052 { 00053 if (w) 00054 { 00055 m_widgets.append(w); 00056 KMPropContainer *ctn = new KMPropContainer(this,"Container"); 00057 ctn->setWidget(w); 00058 connect(ctn,TQT_SIGNAL(enable(bool)),TQT_SLOT(slotEnable(bool))); 00059 00060 TQPixmap icon = KGlobal::instance()->iconLoader()->loadIcon( 00061 w->pixmap(), 00062 KIcon::NoGroup, 00063 KIcon::SizeMedium 00064 ); 00065 addPage(ctn,w->title(),w->header(),icon); 00066 } 00067 } 00068 00069 void KMPropertyPage::slotEnable(bool on) 00070 { 00071 TQWidget *w = (TQWidget*)(sender()); 00072 if (on) 00073 enablePage(w); 00074 else 00075 disablePage(w); 00076 } 00077 00078 void KMPropertyPage::initialize() 00079 { 00080 // add General page 00081 addPropPage(new KMPropGeneral(this, "General")); 00082 // add plugin specific pages 00083 KMFactory::self()->uiManager()->setupPropertyPages(this); 00084 } 00085 00086 void KMPropertyPage::reload() 00087 { 00088 clearPages(); 00089 m_widgets.clear(); 00090 initialize(); 00091 setPrinter(0); 00092 } 00093 00094 #include "kmpropertypage.moc"