20 #include "kmwbanners.h"
22 #include "kmprinter.h"
23 #include "kmfactory.h"
24 #include "kmmanager.h"
26 #include <tqcombobox.h>
30 #include <tdelocale.h>
32 TQStringList defaultBanners()
35 TQPtrList<KMPrinter> *list = KMFactory::self()->manager()->printerList(
false);
36 if (list && list->count() > 0)
38 TQPtrListIterator<KMPrinter> it(*list);
39 for (;it.current() && !it.current()->isPrinter(); ++it) ;
40 if (it.current() && KMFactory::self()->manager()->completePrinter(it.current()))
42 TQString s = list->getFirst()->option(
"kde-banners-supported");
43 bans = TQStringList::split(
',',s,
false);
46 if (bans.count() == 0)
57 {
"none", I18N_NOOP(
"No Banner" ) },
58 {
"classified", I18N_NOOP(
"Classified" ) },
59 {
"confidential", I18N_NOOP(
"Confidential" ) },
60 {
"secret", I18N_NOOP(
"Secret" ) },
61 {
"standard", I18N_NOOP(
"Standard" ) },
62 {
"topsecret", I18N_NOOP(
"Top Secret" ) },
63 {
"unclassified", I18N_NOOP(
"Unclassified" ) },
67 TQString mapBanner(
const TQString& ban )
69 static TQMap<TQString,TQString> map;
70 if ( map.size() == 0 )
71 for (
int i=0; bannermap[ i ].banner; i++ )
72 map[ bannermap[ i ].banner ] = bannermap[ i ].name;
73 TQMap<TQString,TQString>::ConstIterator it = map.find( ban );
74 if ( it == map.end() )
82 KMWBanners::KMWBanners(TQWidget *parent,
const char *name)
83 : KMWizardPage(parent,name)
85 m_ID = KMWizard::Banners;
86 m_title = i18n(
"Banner Selection");
87 m_nextpage = KMWizard::Custom+3;
89 m_start =
new TQComboBox(
this);
90 m_end =
new TQComboBox(
this);
92 TQLabel *l1 =
new TQLabel(i18n(
"&Starting banner:"),
this);
93 TQLabel *l2 =
new TQLabel(i18n(
"&Ending banner:"),
this);
95 l1->setBuddy(m_start);
98 TQLabel *l0 =
new TQLabel(
this);
99 l0->setText(i18n(
"<p>Select the default banners associated with this printer. These "
100 "banners will be inserted before and/or after each print job sent "
101 "to the printer. If you don't want to use banners, select <b>No Banner</b>.</p>"));
103 TQGridLayout *lay =
new TQGridLayout(
this, 5, 2, 0, 10);
104 lay->setColStretch(1,1);
105 lay->addRowSpacing(1,20);
106 lay->setRowStretch(4,1);
107 lay->addMultiCellWidget(l0,0,0,0,1);
108 lay->addWidget(l1,2,0);
109 lay->addWidget(l2,3,0);
110 lay->addWidget(m_start,2,1);
111 lay->addWidget(m_end,3,1);
114 void KMWBanners::initPrinter(KMPrinter *p)
118 if (m_start->count() == 0)
120 m_bans = TQStringList::split(
',',p->option(
"kde-banners-supported"),
false);
121 if (m_bans.count() == 0)
122 m_bans = defaultBanners();
123 if (m_bans.find(
"none") == m_bans.end())
124 m_bans.prepend(
"none");
125 for ( TQStringList::Iterator it=m_bans.begin(); it!=m_bans.end(); ++it )
127 m_start->insertItem( i18n( mapBanner(*it).utf8() ) );
128 m_end->insertItem( i18n( mapBanner(*it).utf8() ) );
131 TQStringList l = TQStringList::split(
',',p->option(
"kde-banners"),
false);
132 while (l.count() < 2)
134 m_start->setCurrentItem(m_bans.findIndex(l[0]));
135 m_end->setCurrentItem(m_bans.findIndex(l[1]));
139 void KMWBanners::updatePrinter(KMPrinter *p)
141 if (m_start->count() > 0)
143 p->setOption(
"kde-banners",m_bans[m_start->currentItem()]+
","+m_bans[m_end->currentItem()]);