summaryrefslogtreecommitdiffstats
path: root/kdeprint/management/kmpropertypage.cpp
blob: e0526ad5a61ff531c19ec5d07a9fbcedb95de8c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
 *  This file is part of the KDE libraries
 *  Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Library General Public
 *  License version 2 as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Library General Public License for more details.
 *
 *  You should have received a copy of the GNU Library General Public License
 *  along with this library; see the file COPYING.LIB.  If not, write to
 *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 *  Boston, MA 02110-1301, USA.
 **/

#include "kmpropertypage.h"
#include "kmpropwidget.h"
#include "kmpropcontainer.h"
#include "kmprinter.h"
#include "kmfactory.h"
#include "kmuimanager.h"

#include "kmpropgeneral.h"

#include <tqvbox.h>
#include <kiconloader.h>

KMPropertyPage::KMPropertyPage(TQWidget *parent, const char *name)
: CJanusWidget(parent,name)
{
	m_widgets.setAutoDelete(false);

	initialize();
}

KMPropertyPage::~KMPropertyPage()
{
}

void KMPropertyPage::setPrinter(KMPrinter *p)
{
	TQPtrListIterator<KMPropWidget>	it(m_widgets);
	for (;it.current();++it)
		it.current()->setPrinterBase(p);
}

void KMPropertyPage::addPropPage(KMPropWidget *w)
{
	if (w)
	{
		m_widgets.append(w);
		KMPropContainer	*ctn = new KMPropContainer(this,"Container");
		ctn->setWidget(w);
		connect(ctn,TQT_SIGNAL(enable(bool)),TQT_SLOT(slotEnable(bool)));

		TQPixmap icon = KGlobal::instance()->iconLoader()->loadIcon(
		                                                           w->pixmap(),
		                                                           KIcon::NoGroup,
		                                                           KIcon::SizeMedium
 		                                                          );
		addPage(ctn,w->title(),w->header(),icon);
	}
}

void KMPropertyPage::slotEnable(bool on)
{
	TQWidget	*w = (TQWidget*)(sender());
	if (on)
		enablePage(w);
	else
		disablePage(w);
}

void KMPropertyPage::initialize()
{
	// add General page
	addPropPage(new KMPropGeneral(this, "General"));
	// add plugin specific pages
	KMFactory::self()->uiManager()->setupPropertyPages(this);
}

void KMPropertyPage::reload()
{
	clearPages();
	m_widgets.clear();
	initialize();
	setPrinter(0);
}

#include "kmpropertypage.moc"