Пример #1
0
bool KMSpecialManager::loadDesktopFile(const QString& filename)
{
	KSimpleConfig	conf(filename);
	conf.setGroup("General");
	int	n = conf.readNumEntry("Number",0);
	for (int i=0;i<n;i++)
	{
		QString	grpname = QString::fromLatin1("Printer %1").arg(i);
		if (!conf.hasGroup(grpname)) continue;
		conf.setGroup(grpname);
		KMPrinter	*printer = new KMPrinter;
		printer->setName(conf.readEntry("Name"));
		printer->setPrinterName(printer->name());
		printer->setDescription(conf.readEntry("Description"));
		printer->setLocation(conf.readEntry("Comment"));
		printer->setOption("kde-special-command",conf.readPathEntry("Command"));
		printer->setOption("kde-special-file",conf.readPathEntry("File"));
		printer->setOption("kde-special-extension",conf.readEntry("Extension"));
		printer->setOption("kde-special-mimetype",conf.readEntry("Mimetype"));
		printer->setOption("kde-special-require",conf.readEntry("Require"));
		printer->setPixmap(conf.readEntry("Icon","unknown"));
		printer->setType(KMPrinter::Special);
		if ( !KdeprintChecker::check( &conf ) ||
				!KXmlCommandManager::self()->checkCommand( printer->option( "kde-special-command" ),
					KXmlCommandManager::None, KXmlCommandManager::None, 0 ) )
			printer->addType(KMPrinter::Invalid);
		printer->setState(KMPrinter::Idle);
		printer->setAcceptJobs(true);
		m_mgr->addPrinter(printer);
	}

	return true;
}
Пример #2
0
KMPrinter* KMSpecialPrinterDlg::printer()
{
	KMPrinter	*printer = new KMPrinter();
	printer->setName(m_name->text());
	printer->setPrinterName(m_name->text());
	printer->setPixmap(m_icon->icon());
	printer->setDescription(m_description->text());
	printer->setLocation(m_location->text());
	printer->setOption("kde-special-command",m_command->command());
	printer->setOption("kde-special-file",(m_usefile->isChecked() ? "1" : "0"));
	if (m_usefile->isChecked ())
	{
		if (m_mimetype->currentText() != "all/all")
			printer->setOption("kde-special-mimetype", m_mimetype->currentText());
		printer->setOption("kde-special-extension",m_extension->text());
	}
	printer->setType(KMPrinter::Special);
	printer->setState(KMPrinter::Idle);
	return printer;
}
Пример #3
0
KMPrinter *KMFoomaticManager::createPrinterFromElement(QDomElement *elem)
{
    QDomElement e = elem->namedItem("name").toElement();
    if(!e.isNull())
    {
        KMPrinter *printer = new KMPrinter;
        printer->setType(KMPrinter::Printer);
        printer->setName(e.text());
        printer->setPrinterName(e.text());
        printer->setState(KMPrinter::Idle);
        /*if (printer->name().find('/') != -1)
        {
            QString	s(printer->name());
            int	p = s.find('/');
            printer->setPrinterName(s.left(p));
            printer->setInstanceName(s.mid(p+1));
            printer->addType(KMPrinter::Virtual);
        }*/

        if(!(e = elem->namedItem("description").toElement()).isNull())
            printer->setDescription(e.text());
        if(!(e = elem->namedItem("location").toElement()).isNull())
            printer->setLocation(e.text());
        if(!(e = elem->namedItem("connect").toElement()).isNull())
            printer->setDevice(e.text());

        printer->setOption("foomatic", elem->attribute("foomatic"));
        printer->setOption("spooler", elem->attribute("spooler"));
        if(elem->attribute("foomatic") == "1")
        {
            if(!(e = elem->namedItem("printer").toElement()).isNull())
                printer->setOption("printer", e.text());
            if(!(e = elem->namedItem("driver").toElement()).isNull())
                printer->setOption("driver", e.text());
        }

        return printer;
    }
    return NULL;
}