You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
146 lines
4.2 KiB
146 lines
4.2 KiB
15 years ago
|
/*
|
||
|
* This file is part of the KDE libraries
|
||
13 years ago
|
* Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
|
||
15 years ago
|
*
|
||
|
* 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 "kmwbanners.h"
|
||
|
#include "kmwizard.h"
|
||
|
#include "kmprinter.h"
|
||
|
#include "kmfactory.h"
|
||
|
#include "kmmanager.h"
|
||
|
|
||
15 years ago
|
#include <tqcombobox.h>
|
||
|
#include <tqlabel.h>
|
||
|
#include <tqlayout.h>
|
||
|
#include <tqmap.h>
|
||
15 years ago
|
#include <klocale.h>
|
||
|
|
||
15 years ago
|
TQStringList defaultBanners()
|
||
15 years ago
|
{
|
||
14 years ago
|
TQStringList bans;
|
||
15 years ago
|
TQPtrList<KMPrinter> *list = KMFactory::self()->manager()->printerList(false);
|
||
15 years ago
|
if (list && list->count() > 0)
|
||
|
{
|
||
15 years ago
|
TQPtrListIterator<KMPrinter> it(*list);
|
||
15 years ago
|
for (;it.current() && !it.current()->isPrinter(); ++it) ;
|
||
|
if (it.current() && KMFactory::self()->manager()->completePrinter(it.current()))
|
||
|
{
|
||
14 years ago
|
TQString s = list->getFirst()->option("kde-banners-supported");
|
||
15 years ago
|
bans = TQStringList::split(',',s,false);
|
||
15 years ago
|
}
|
||
|
}
|
||
|
if (bans.count() == 0)
|
||
|
bans.append("none");
|
||
|
return bans;
|
||
|
}
|
||
|
|
||
|
static struct
|
||
|
{
|
||
|
const char *banner;
|
||
|
const char *name;
|
||
|
} bannermap[] =
|
||
|
{
|
||
|
{ "none", I18N_NOOP( "No Banner" ) },
|
||
|
{ "classified", I18N_NOOP( "Classified" ) },
|
||
|
{ "confidential", I18N_NOOP( "Confidential" ) },
|
||
|
{ "secret", I18N_NOOP( "Secret" ) },
|
||
|
{ "standard", I18N_NOOP( "Standard" ) },
|
||
|
{ "topsecret", I18N_NOOP( "Top Secret" ) },
|
||
|
{ "unclassified", I18N_NOOP( "Unclassified" ) },
|
||
|
{ 0, 0 }
|
||
|
};
|
||
|
|
||
15 years ago
|
TQString mapBanner( const TQString& ban )
|
||
15 years ago
|
{
|
||
15 years ago
|
static TQMap<TQString,TQString> map;
|
||
15 years ago
|
if ( map.size() == 0 )
|
||
|
for ( int i=0; bannermap[ i ].banner; i++ )
|
||
|
map[ bannermap[ i ].banner ] = bannermap[ i ].name;
|
||
13 years ago
|
TQMap<TQString,TQString>::ConstIterator it = map.find( ban );
|
||
15 years ago
|
if ( it == map.end() )
|
||
|
return ban;
|
||
|
else
|
||
|
return it.data();
|
||
|
}
|
||
|
|
||
|
//**************************************************************************************************************
|
||
|
|
||
15 years ago
|
KMWBanners::KMWBanners(TQWidget *parent, const char *name)
|
||
15 years ago
|
: KMWizardPage(parent,name)
|
||
|
{
|
||
|
m_ID = KMWizard::Banners;
|
||
|
m_title = i18n("Banner Selection");
|
||
|
m_nextpage = KMWizard::Custom+3;
|
||
|
|
||
15 years ago
|
m_start = new TQComboBox(this);
|
||
|
m_end = new TQComboBox(this);
|
||
15 years ago
|
|
||
14 years ago
|
TQLabel *l1 = new TQLabel(i18n("&Starting banner:"),this);
|
||
|
TQLabel *l2 = new TQLabel(i18n("&Ending banner:"),this);
|
||
15 years ago
|
|
||
|
l1->setBuddy(m_start);
|
||
|
l2->setBuddy(m_end);
|
||
|
|
||
14 years ago
|
TQLabel *l0 = new TQLabel(this);
|
||
15 years ago
|
l0->setText(i18n("<p>Select the default banners associated with this printer. These "
|
||
|
"banners will be inserted before and/or after each print job sent "
|
||
|
"to the printer. If you don't want to use banners, select <b>No Banner</b>.</p>"));
|
||
|
|
||
14 years ago
|
TQGridLayout *lay = new TQGridLayout(this, 5, 2, 0, 10);
|
||
15 years ago
|
lay->setColStretch(1,1);
|
||
|
lay->addRowSpacing(1,20);
|
||
|
lay->setRowStretch(4,1);
|
||
|
lay->addMultiCellWidget(l0,0,0,0,1);
|
||
|
lay->addWidget(l1,2,0);
|
||
|
lay->addWidget(l2,3,0);
|
||
|
lay->addWidget(m_start,2,1);
|
||
|
lay->addWidget(m_end,3,1);
|
||
|
}
|
||
|
|
||
|
void KMWBanners::initPrinter(KMPrinter *p)
|
||
|
{
|
||
|
if (p)
|
||
|
{
|
||
|
if (m_start->count() == 0)
|
||
|
{
|
||
15 years ago
|
m_bans = TQStringList::split(',',p->option("kde-banners-supported"),false);
|
||
15 years ago
|
if (m_bans.count() == 0)
|
||
|
m_bans = defaultBanners();
|
||
13 years ago
|
if (m_bans.find("none") == m_bans.end())
|
||
15 years ago
|
m_bans.prepend("none");
|
||
15 years ago
|
for ( TQStringList::Iterator it=m_bans.begin(); it!=m_bans.end(); ++it )
|
||
15 years ago
|
{
|
||
|
m_start->insertItem( i18n( mapBanner(*it).utf8() ) );
|
||
|
m_end->insertItem( i18n( mapBanner(*it).utf8() ) );
|
||
|
}
|
||
|
}
|
||
14 years ago
|
TQStringList l = TQStringList::split(',',p->option("kde-banners"),false);
|
||
15 years ago
|
while (l.count() < 2)
|
||
|
l.append("none");
|
||
13 years ago
|
m_start->setCurrentItem(m_bans.findIndex(l[0]));
|
||
|
m_end->setCurrentItem(m_bans.findIndex(l[1]));
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
void KMWBanners::updatePrinter(KMPrinter *p)
|
||
|
{
|
||
|
if (m_start->count() > 0)
|
||
|
{
|
||
|
p->setOption("kde-banners",m_bans[m_start->currentItem()]+","+m_bans[m_end->currentItem()]);
|
||
|
}
|
||
|
}
|