Esempio n. 1
0
void TvConfig::saveOptions()
{
    int card, tuner, pll, radio = 0;

    KConfig *config = new KConfig("kcmtasmatvrc");
    QFile bttv("/etc/modules.d/bttv");

    card = getCard();
    tuner = getTuner();
    pll = pllGroup->id(pllGroup->selected());

    if (radioCard->isChecked())
	radio = 1;

    if (bttv.open(IO_WriteOnly | IO_Truncate)) {
	QTextStream os(&bttv);

	config->setFileWriteMode(0644);
	config->setGroup("System");
	config->writeEntry("Card", card);
	config->writeEntry("Tuner", tuner);
	config->writeEntry("Pll", pll);
	config->writeEntry("Radio", radio);
	config->sync();

	os << "### This file is automatically generated by tasma." << endl;
	os << "#" << endl;
	os << "# Please do not edit this file directly. All changes" << endl;
	os << "# made in this file will be lost." << endl;
	os << "#" << endl;
	os << endl;
	os << "options bttv card=" << card;

	if (tuner != AUTO_TUNER)
	    os << " " << "tuner=" << tuner;
	if (pll)
	    os << " " << "pll=" << pll;
	if (radio)
	    os << " " << "radio=" << radio;

	os << endl;

	bttv.close();
	system("/sbin/modules-update");
    }

    delete config;
}