Beispiel #1
0
void KMInstancePage::slotTest()
{
    KMTimer::self()->hold();

    QString src = m_view->currentText();
    if(!src.isEmpty())
    {
        if(src == i18n("(Default)"))
            src = QString::null;
        KMPrinter *mpr = KMFactory::self()->virtualManager()->findInstance(m_printer, src);
        if(!mpr)
            KMessageBox::error(this, i18n("Internal error: printer not found."));
        else if(KMessageBox::warningContinueCancel(this,
                                                   i18n("You are about to print a test page on %1. Do you want to continue?").arg(mpr->printerName()),
                                                   QString::null, i18n("Print Test Page"), "printTestPage")
                == KMessageBox::Continue)
        {
            if(!KMFactory::self()->virtualManager()->testInstance(mpr))
                KMessageBox::error(this, i18n("Unable to send test page to %1.").arg(mpr->printerName()));
            else
                KMessageBox::information(this, i18n("Test page successfully sent to printer %1.").arg(mpr->printerName()));
        }
    }

    KMTimer::self()->release(false);
}
Beispiel #2
0
void KMJobViewer::slotMove(int prID)
{
    if (prID >= 0 && prID < (int)(m_printers.count()))
    {
        KMPrinter	*p = m_printers.at(prID);
        send(KMJob::Move,i18n("Move to %1").arg(p->printerName()),p->printerName());
    }
}
Beispiel #3
0
KMPrinter* LprHandler::createPrinter(PrintcapEntry *entry)
{
	KMPrinter	*prt = new KMPrinter;
	prt->setPrinterName(entry->name);
	prt->setName(entry->name);
	prt->setType(KMPrinter::Printer);
	return prt;
}
Beispiel #4
0
// create basic printer from entry
KMPrinter* createPrinter(const QMap<QString,QString>& entry)
{
	KMPrinter	*printer = new KMPrinter();
	printer->setName(entry["printer-name"]);
	printer->setPrinterName(entry["printer-name"]);
	printer->setType(KMPrinter::Printer);
	printer->setState(KMPrinter::Idle);
	return printer;
}
Beispiel #5
0
void KPrintAction::slotActivated(int ID)
{
	KPrinter	printer(false);
	KMPrinter	*mprt = KMManager::self()->findPrinter(d->printers[ID]);
	if (mprt && mprt->autoConfigure(&printer, d->parentWidget))
	{
		// emit the signal
		emit print(&printer);
	}
}
Beispiel #6
0
bool KMCupsJobManager::listJobs(const QString& prname, KMJobManager::JobType type, int limit)
{
	IppRequest	req;
	QStringList	keys;
	CupsInfos	*infos = CupsInfos::self();

	// wanted attributes
	keys.append("job-id");
	keys.append("job-uri");
	keys.append("job-name");
	keys.append("job-state");
	keys.append("job-printer-uri");
	keys.append("job-k-octets");
	keys.append("job-originating-user-name");
	keys.append("job-k-octets-completed");
	keys.append("job-media-sheets");
	keys.append("job-media-sheets-completed");
	keys.append("job-priority");
	keys.append("job-billing");

	req.setOperation(IPP_GET_JOBS);

	// add printer-uri
	KMPrinter *mp = KMManager::self()->findPrinter(prname);
	if (!mp)
		return false;

	if (!mp->uri().isEmpty())
	{
		req.addURI(IPP_TAG_OPERATION, "printer-uri", mp->uri().prettyURL());
		/*
		req.setHost(mp->uri().host());
		req.setPort(mp->uri().port());
		*/
	}
	else
		req.addURI(IPP_TAG_OPERATION, "printer-uri", QString("ipp://%1/%2/%3").arg(infos->hostaddr(),
                            (mp&&mp->isClass())?"classes":"printers", prname));

	// other attributes
	req.addKeyword(IPP_TAG_OPERATION, "requested-attributes", keys);
	if (type == KMJobManager::CompletedJobs)
		req.addKeyword(IPP_TAG_OPERATION,"which-jobs",QString::fromLatin1("completed"));
	if (limit > 0)
		req.addInteger(IPP_TAG_OPERATION,"limit",limit);

	// send request
	if (req.doRequest("/"))
		parseListAnswer(req, mp);
	else
		return false;

	return true;
}
Beispiel #7
0
void KMJobViewer::addToManager()
{
    if (m_prname == i18n("All Printers"))
    {
        loadPrinters();
        QPtrListIterator<KMPrinter>	it(m_printers);
        for (; it.current(); ++it)
            m_manager->addPrinter(it.current()->printerName(), (KMJobManager::JobType)m_type, it.current()->isSpecial());
    }
    else if (!m_prname.isEmpty())
    {
        KMPrinter *prt = KMManager::self()->findPrinter( m_prname );
        bool isSpecial = ( prt ? prt->isSpecial() : false );
        m_manager->addPrinter(m_prname, (KMJobManager::JobType)m_type, isSpecial);
    }
}
Beispiel #8
0
// "/etc/printcap" file parsing (Linux/LPR)
void KMLpdUnixManager::parseEtcPrintcap()
{
	QFile	f(getPrintcapFileName());
	if (f.exists() && f.open(IO_ReadOnly))
	{
		KTextBuffer	t(&f);
		QMap<QString,QString>	entry;

		while (!t.eof())
		{
			entry = readEntry(t);
			if (entry.isEmpty() || !entry.contains("printer-name") || entry.contains("server"))
				continue;
			if (entry["printer-name"] == "all")
			{
				if (entry.contains("all"))
				{
					// find separator
					int	p = entry["all"].find(QRegExp("[^a-zA-Z0-9_\\s-]"));
					if (p != -1)
					{
						QChar	c = entry["all"][p];
						QStringList	prs = QStringList::split(c,entry["all"],false);
						for (QStringList::ConstIterator it=prs.begin(); it!=prs.end(); ++it)
						{
							KMPrinter	*printer = ::createPrinter(*it);
							printer->setDescription(i18n("Description unavailable"));
							addPrinter(printer);
						}
					}
				}
			}
			else
			{
				KMPrinter	*printer = ::createPrinter(entry);
				if (entry.contains("rm"))
					printer->setDescription(i18n("Remote printer queue on %1").arg(entry["rm"]));
				else
					printer->setDescription(i18n("Local printer"));
				addPrinter(printer);
			}
		}
	}
}
Beispiel #9
0
void PrintMenu::initialize()
{
    if (initialized()) clear();
    setInitialized(true);

    int ID = PRINTER_LIST_ID;
    // just to be sure the plugin is loaded -> icons are available
    KMManager::self();

    if ((KMManager::self()->printerOperationMask() & KMManager::PrinterCreation) && KMManager::self()->hasManagement())
        insertItem(KIcon("wizard"), i18n("Add Printer..."), ADD_PRINTER_ID);
    insertItem(KIcon("kdeprint-configmgr"), i18n("KDE Print Settings"), KDEPRINT_SETTINGS_ID);
    if (KMManager::self()->serverOperationMask() & KMManager::ServerConfigure)
        insertItem(KIcon("kdeprint-configsrv"), i18n("Configure Server"), CONFIG_SERVER_ID);
    addSeparator();
    insertItem(KIcon("kcontrol"), i18n("Print Manager"), PRINT_MANAGER_ID);
    insertItem(KIcon("konqueror"), i18n("Print Browser (Konqueror)"), PRINT_BROWSER_ID);
    addSeparator();
    insertItem(KIcon("document-print"), i18n("Print File..."), KPRINTER_ID);

    // printer list
    QList<KMPrinter*>    l = KMManager::self()->printerList();
    if (!l.isEmpty())
    {
        bool separatorInserted = false;
		QListIterator<KMPrinter*>       it(l);
		while (it.hasNext())
        {
			KMPrinter *itprt = it.next();
            // no special, implicit or pure instances
            if (itprt->isSpecial() || itprt->isVirtual())
                continue;
            if (!separatorInserted)
            {
                // we insert a separator only when we find the first
                // printer
                addSeparator();
                separatorInserted = true;
            }
            insertItem(KIcon(itprt->pixmap()),
                       itprt->printerName(), ID++);
        }
    }
}
Beispiel #10
0
void KMJobViewer::updateCaption()
{
    if (!m_standalone)
        return;

    QString	pixname("fileprint");
    if (!m_prname.isEmpty())
    {
        setCaption(i18n("Print Jobs for %1").arg(m_prname));
        KMPrinter	*prt = KMManager::self()->findPrinter(m_prname);
        if (prt)
            pixname = prt->pixmap();
    }
    else
    {
        setCaption(i18n("No Printer"));
    }
    KWin::setIcons(winId(), DesktopIcon(pixname), SmallIcon(pixname));
}
Beispiel #11
0
void KMMainView::slotConfigure()
{
    if(m_current)
    {
        KMTimer::self()->hold();
        bool needRefresh(false);
        if(m_current->isSpecial())
        {
            KMSpecialPrinterDlg dlg(this);
            dlg.setPrinter(m_current);
            if(dlg.exec())
            {
                KMPrinter *prt = dlg.printer();
                if(prt->name() != m_current->name())
                    m_manager->removeSpecialPrinter(m_current);
                m_manager->createSpecialPrinter(prt);
                needRefresh = true;
            }
        }
        else
        {
            DrMain *driver = m_manager->loadPrinterDriver(m_current, true);
            if(driver)
            {
                KMDriverDialog dlg(this);
                dlg.setCaption(i18n("Configure %1").arg(m_current->printerName()));
                dlg.setDriver(driver);
                // disable OK button for remote printer (read-only dialog)
                if(m_current->isRemote())
                    dlg.enableButtonOK(false);
                if(dlg.exec())
                    if(!m_manager->savePrinterDriver(m_current, driver))
                        showErrorMsg(i18n("Unable to modify settings of printer %1.").arg(m_current->printerName()));
                delete driver;
            }
            else
                showErrorMsg(i18n("Unable to load a valid driver for printer %1.").arg(m_current->printerName()));
        }
        KMTimer::self()->release(needRefresh);
    }
}
Beispiel #12
0
// "/etc/printers.conf" file parsing (Solaris 2.6)
void KMLpdUnixManager::parseEtcPrintersConf()
{
	QFile	f(getEtcPrintersConfName());
	if (f.exists() && f.open(IO_ReadOnly))
	{
		KTextBuffer	t(&f);
		QMap<QString,QString>	entry;
		QString		default_printer;

		while (!t.eof())
		{
			entry = readEntry(t);
			if (entry.isEmpty() || !entry.contains("printer-name"))
				continue;
			QString	prname = entry["printer-name"];
			if (prname == "_default")
			{
				if (entry.contains("use"))
					default_printer = entry["use"];
			}
			else if (prname != "_all")
			{
				KMPrinter	*printer = ::createPrinter(entry);
				if (entry.contains("bsdaddr"))
				{
					QStringList	l = QStringList::split(',',entry["bsdaddr"],false);
					printer->setDescription(i18n("Remote printer queue on %1").arg(l[0]));
				}
				else
					printer->setDescription(i18n("Local printer"));
				addPrinter(printer);
			}
		}

		if (!default_printer.isEmpty())
			setSoftDefault(findPrinter(default_printer));
	}
}
Beispiel #13
0
bool KRlprPrinterImpl::setupCommand(TQString& cmd, KPrinter *printer)
{
	// retrieve the KMPrinter object, to get host and queue name
	KMPrinter	*rpr = KMFactory::self()->manager()->findPrinter(printer->printerName());
	if (!rpr)
		return false;

	QString	host(rpr->option("host")), queue(rpr->option("queue"));
	if (!host.isEmpty() && !queue.isEmpty())
	{
		QString		exestr = TDEStandardDirs::findExe("rlpr");
		if (exestr.isEmpty())
		{
			printer->setErrorMessage(i18n("The <b>%1</b> executable could not be found in your path. Check your installation.").arg("rlpr"));
			return false;
		}

		cmd = TQString::fromLatin1("%1 -H %2 -P %3 -\\#%4").arg(exestr).arg(quote(host)).arg(quote(queue)).arg(printer->numCopies());

		// proxy settings
		TDEConfig	*conf = KMFactory::self()->printConfig();
		conf->setGroup("RLPR");
		QString	host = conf->readEntry("ProxyHost",TQString::null), port = conf->readEntry("ProxyPort",TQString::null);
		if (!host.isEmpty())
		{
			cmd.append(" -X ").append(quote(host));
			if (!port.isEmpty()) cmd.append(" --port=").append(port);
		}

		return true;
	}
	else
	{
		printer->setErrorMessage(i18n("The printer is incompletely defined. Try to reinstall it."));
		return false;
	}
}
Beispiel #14
0
void KMMainView::slotPrinterSelected(const TQString& prname)
{
	KMPrinter	*p = KMManager::self()->findPrinter(prname);
	m_current = p;
	if (p && !p->isSpecial())
		KMFactory::self()->manager()->completePrinter(p);
	m_printerpages->setPrinter(p);

	// update actions state (only if toolbar enabled, workaround for toolbar
	// problem).
	//if (m_toolbar->isEnabled())
	//{
		int 	mask = (m_manager->hasManagement() ? m_manager->printerOperationMask() : 0);
		bool	sp = !(p && p->isSpecial());
//		m_actions->action("printer_remove")->setEnabled(!sp || ((mask & KMManager::PrinterRemoval) && p && p->isLocal() && !p->isImplicit()));
		m_actions->action("printer_remove")->setEnabled(!sp || ((mask & KMManager::PrinterRemoval) && p && !p->isImplicit()));
		m_actions->action("printer_configure")->setEnabled(!sp || ((mask & KMManager::PrinterConfigure) && p && !p->isClass(true) /*&& p->isLocal()*/));
		m_actions->action("printer_hard_default")->setEnabled((sp && (mask & KMManager::PrinterDefault) && p && !p->isClass(true) && !p->isHardDefault() && p->isLocal()));
		m_actions->action("printer_soft_default")->setEnabled((p && !p->isSoftDefault()));
		m_actions->action("printer_test")->setEnabled((sp && (mask & KMManager::PrinterTesting) && p && !p->isClass(true)));
		bool	stmask = (sp && (mask & KMManager::PrinterEnabling) && p);
		m_actions->action("printer_state_change")->setEnabled(stmask && p->isLocal());
		m_actions->action("printer_spool_change")->setEnabled(stmask);
		m_actions->action("printer_start")->setEnabled((stmask && p->state() == KMPrinter::Stopped));
		m_actions->action("printer_stop")->setEnabled((stmask && p->state() != KMPrinter::Stopped));
		m_actions->action("printer_enable")->setEnabled((stmask && !p->acceptJobs()));
		m_actions->action("printer_disable")->setEnabled((stmask && p->acceptJobs()));

		m_actions->action("printer_add")->setEnabled((mask & KMManager::PrinterCreation));
		mask = m_manager->serverOperationMask();
		m_actions->action("server_restart")->setEnabled((mask & KMManager::ServerRestarting));
		m_actions->action("server_configure")->setEnabled((mask & KMManager::ServerConfigure));

		KMFactory::self()->manager()->validatePluginActions(m_actions, p);
	//}
	m_actions->action("printer_tool")->setEnabled(p && !p->isClass(true) && !p->isRemote() && !p->isSpecial());
}
Beispiel #15
0
KMPrinter *PrintcapEntry::createPrinter()
{
    KMPrinter *printer = new KMPrinter();
    printer->setName(m_name);
    printer->setPrinterName(m_name);
    printer->setInstanceName(QString::null);
    printer->setState(KMPrinter::Idle);
    printer->setType(KMPrinter::Printer);
    return printer;
}
Beispiel #16
0
// "/etc/lp/printers/" directory parsing (Solaris non-2.6)
void KMLpdUnixManager::parseEtcLpPrinters()
{
	QDir	d("/etc/lp/printers");
	const QFileInfoList	*prlist = d.entryInfoList(QDir::Dirs);
	if (!prlist)
		return;

	QFileInfoListIterator	it(*prlist);
	for (;it.current();++it)
	{
		if (it.current()->fileName() == "." || it.current()->fileName() == "..")
			continue;
		QFile	f(it.current()->absFilePath() + "/configuration");
		if (f.exists() && f.open(IO_ReadOnly))
		{
			KTextBuffer	t(&f);
			QString		line, remote;
			while (!t.eof())
			{
				line = readLine(t);
				if (line.isEmpty()) continue;
				if (line.startsWith("Remote:"))
				{
					QStringList	l = QStringList::split(':',line,false);
					if (l.count() > 1) remote = l[1];
				}
			}
			KMPrinter	*printer = new KMPrinter;
			printer->setName(it.current()->fileName());
			printer->setPrinterName(it.current()->fileName());
			printer->setType(KMPrinter::Printer);
			printer->setState(KMPrinter::Idle);
			if (!remote.isEmpty())
				printer->setDescription(i18n("Remote printer queue on %1").arg(remote));
			else
				printer->setDescription(i18n("Local printer"));
			addPrinter(printer);
		}
	}
}
Beispiel #17
0
// "/usr/spool/lp/interfaces/" directory parsing (IRIX 6.x)
void KMLpdUnixManager::parseSpoolInterface()
{
	QDir	d("/usr/spool/interfaces/lp");
	const QFileInfoList	*prlist = d.entryInfoList(QDir::Files);
	if (!prlist)
		return;

	QFileInfoListIterator	it(*prlist);
	for (;it.current();++it)
	{
		QFile	f(it.current()->absFilePath());
		if (f.exists() && f.open(IO_ReadOnly))
		{
			KTextBuffer	t(&f);
			QString		line, remote;

			while (!t.eof())
			{
				line = t.readLine().stripWhiteSpace();
				if (line.startsWith("HOSTNAME"))
				{
					QStringList	l = QStringList::split('=',line,false);
					if (l.count() > 1) remote = l[1];
				}
			}

			KMPrinter	*printer = new KMPrinter;
			printer->setName(it.current()->fileName());
			printer->setPrinterName(it.current()->fileName());
			printer->setType(KMPrinter::Printer);
			printer->setState(KMPrinter::Idle);
			if (!remote.isEmpty())
				printer->setDescription(i18n("Remote printer queue on %1").arg(remote));
			else
				printer->setDescription(i18n("Local printer"));
			addPrinter(printer);
		}
	}
}
Beispiel #18
0
// "/etc/lp/member/" directory parsing (HP-UX)
void KMLpdUnixManager::parseEtcLpMember()
{
	QDir	d("/etc/lp/member");
	const QFileInfoList	*prlist = d.entryInfoList(QDir::Files);
	if (!prlist)
		return;

	QFileInfoListIterator	it(*prlist);
	for (;it.current();++it)
	{
		KMPrinter	*printer = new KMPrinter;
		printer->setName(it.current()->fileName());
		printer->setPrinterName(it.current()->fileName());
		printer->setType(KMPrinter::Printer);
		printer->setState(KMPrinter::Idle);
		printer->setDescription(i18n("Local printer"));
		addPrinter(printer);
	}
}
Beispiel #19
0
void KMInstancePage::slotSettings()
{
    KMTimer::self()->hold();

    QString src = m_view->currentText();
    if(!src.isEmpty())
    {
        if(src == i18n("(Default)"))
            src = QString::null;
        KMPrinter *pr = KMFactory::self()->virtualManager()->findInstance(m_printer, src);
        if(!pr)
            KMessageBox::error(this, i18n("Unable to find instance %1.").arg(m_view->currentText()));
        else if(!pr->isSpecial() && !KMFactory::self()->manager()->completePrinterShort(pr))
            KMessageBox::error(
                this,
                i18n("Unable to retrieve printer information. Message from printing system: %1.").arg(KMFactory::self()->manager()->errorMsg()));
        else
        {
            int oldAppType = KMFactory::self()->settings()->application;
            KMFactory::self()->settings()->application = -1;
            KPrinterPropertyDialog::setupPrinter(pr, this);
            KMFactory::self()->settings()->application = oldAppType;
            if(pr->isEdited())
            { // printer edited, need to save changes
                pr->setDefaultOptions(pr->editedOptions());
                pr->setEditedOptions(QMap< QString, QString >());
                pr->setEdited(false);
                KMFactory::self()->virtualManager()->triggerSave();
            }
        }
    }
    else
        KMessageBox::error(this, i18n("The instance name is empty. Please select an instance."));

    KMTimer::self()->release();
}
Beispiel #20
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;
}
Beispiel #21
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;
}
Beispiel #22
0
void KMMainView::slotRightButtonClicked(const QString &prname, const QPoint &p)
{
    KMPrinter *printer = KMManager::self()->findPrinter(prname);
    // construct popup menu
    m_pop->clear();
    if(printer)
    {
        m_current = printer;
        if(!printer->isSpecial())
        {
            if(printer->isLocal())
                m_actions->action((printer->state() == KMPrinter::Stopped ? "printer_start" : "printer_stop"))->plug(m_pop);
            m_actions->action((printer->acceptJobs() ? "printer_disable" : "printer_enable"))->plug(m_pop);
            m_pop->insertSeparator();
        }
        if(!printer->isSoftDefault())
            m_actions->action("printer_soft_default")->plug(m_pop);
        if(printer->isLocal() && !printer->isImplicit())
        {
            if(!printer->isHardDefault())
                m_actions->action("printer_hard_default")->plug(m_pop);
            m_actions->action("printer_remove")->plug(m_pop);
            m_pop->insertSeparator();
            if(!printer->isClass(true))
            {
                m_actions->action("printer_configure")->plug(m_pop);
                m_actions->action("printer_test")->plug(m_pop);
                m_actions->action("printer_tool")->plug(m_pop);
                m_pop->insertSeparator();
            }
        }
        else
        {
            if(!printer->isClass(true))
            {
                m_actions->action("printer_configure")->plug(m_pop);
                m_actions->action("printer_test")->plug(m_pop);
            }
            m_pop->insertSeparator();
        }
        if(!printer->isSpecial())
        {
            QValueList< KAction * > pactions = m_actions->actions("plugin");
            for(QValueList< KAction * >::Iterator it = pactions.begin(); it != pactions.end(); ++it)
                (*it)->plug(m_pop);
            if(pactions.count() > 0)
                m_pop->insertSeparator();
        }
    }
    else
    {
        m_actions->action("printer_add")->plug(m_pop);
        m_actions->action("printer_add_special")->plug(m_pop);
        m_pop->insertSeparator();
        m_actions->action("server_restart")->plug(m_pop);
        m_actions->action("server_configure")->plug(m_pop);
        m_pop->insertSeparator();
        m_actions->action("manager_configure")->plug(m_pop);
        m_actions->action("view_refresh")->plug(m_pop);
        m_pop->insertSeparator();
    }
    m_actions->action("view_printerinfos")->plug(m_pop);
    m_actions->action("view_change")->plug(m_pop);
    m_actions->action("orientation_change")->plug(m_pop);
    m_actions->action("view_toolbar")->plug(m_pop);
    m_actions->action("view_menubar")->plug(m_pop);
    m_pop->insertSeparator();
    m_actions->action("view_pfilter")->plug(m_pop);

    // pop the menu
    m_pop->popup(p);
}
Beispiel #23
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;
}