/*************************************************************************** * Copyright (C) 2004 by Johan Maes - ON4QZ * * on4qz@telenet.be * * http://users.telenet.be/on4qz * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program 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 General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "configdialog.h" #include "configform.h" #include "qsstvglobal.h" #include #include #include #include "configform.h" #include "sstvparam.h" #include "utils.h" #include /** \class configDialog More detailed discription of the configdialog class */ QString docPath; //!< path to the documentation (default /usr/local/share) QString audioPath; //!< directory path to the audio files QString txImagePath; QString rxImagePath; QString templatePath; int samplingrate; QString defaultImageFormat; bool useUTC; double rxClock; double txClock; QString audioDevice; QString serialPort; QString callsign; QString lastname; QString locator; QString firstname; QString qth; QString qsstv_version=QString("QSSTV ") + VERSION; QString cwText; int cwTone; int cwWPM; bool enableFTP; int ftpPort; QString ftpRemoteHost; QString ftpRemoteDirectory; QString ftpLogin; QString ftpPassword; QString ftpFilename; QString ftpDefaultImageFormat; int repeaterImageInterval; bool repeaterEnable; sstvMode repeaterTxMode; QString repeaterImage1; QString repeaterImage2; QString repeaterImage3; QString repeaterImage4; QString repeaterAcknowledge; QString repeaterTemplate; QString toCall; // placed here for convenience (from tx window) QString toOperator; // placed here for convenience (from tx window) QString rst; // placed here for convenience (from tx window) #define NUMBEROFIMAGEFORMATS 5 const char *imageFormatStr[NUMBEROFIMAGEFORMATS]= { "png", "bmp", "xbm", "xpm", "jpeg" }; /** constructor for configDialog */ configDialog::configDialog(QWidget *, const char *) { readSettings(); } /** destructor for configDialog */ configDialog::~configDialog() { } //! read variables from config file /** Read the config file and initializes the variables. If not found, default values will be used. \sa writeSettings */ void configDialog::readSettings() { QSettings qSettings(QSettings::Ini); docPath =qSettings.readEntry(APP_KEY + "docPath",QString("/usr/share/doc/packages/qsstv/")); audioPath=qSettings.readEntry(APP_KEY + "audioPath",QString(getenv("HOME"))+"/"); rxImagePath=qSettings.readEntry(APP_KEY + "rxImagePath",QString(getenv("HOME"))+"/"); templatePath=qSettings.readEntry(APP_KEY + "templatePath",QString(getenv("HOME"))+"/"); txImagePath=qSettings.readEntry(APP_KEY + "txImagePath",QString(getenv("HOME"))+"/"); defaultImageFormat=qSettings.readEntry(APP_KEY + "defaultImageFormat","png"); samplingrate=qSettings.readNumEntry(APP_KEY + "samplingrate",11025); useUTC=qSettings.readBoolEntry(APP_KEY + "useUTC",TRUE); rxClock=qSettings.readDoubleEntry(APP_KEY + "rxClock",11025); txClock=qSettings.readDoubleEntry(APP_KEY + "txClock",11025); audioDevice=qSettings.readEntry(APP_KEY + "audioDevice","/dev/dsp"); serialPort=qSettings.readEntry(APP_KEY + "serialPort","/dev/ttyS0"); callsign=qSettings.readEntry(APP_KEY + "callsign","NOCALL"); qth=qSettings.readEntry(APP_KEY + "qth","NOWHERE"); lastname=qSettings.readEntry(APP_KEY + "lastname","NONAME"); firstname=qSettings.readEntry(APP_KEY + "firstname","NOFIRSTNAME"); locator=qSettings.readEntry(APP_KEY + "locator","NOLOCATOR"); cwText=qSettings.readEntry(APP_KEY + "cwtext",""); cwTone=qSettings.readNumEntry(APP_KEY + "cwtone",800); cwWPM=qSettings.readNumEntry(APP_KEY + "cwWPM",12); enableFTP=qSettings.readBoolEntry(APP_KEY + "enableFTP",FALSE); ftpPort=qSettings.readNumEntry(APP_KEY + "ftpPort",21); ftpRemoteHost=qSettings.readEntry(APP_KEY + "ftpRemoteHost",""); ftpRemoteDirectory=qSettings.readEntry(APP_KEY + "ftpRemoteDirectory","/"); ftpLogin=qSettings.readEntry(APP_KEY + "ftpLogin",""); ftpPassword=qSettings.readEntry(APP_KEY + "ftpPassword",""); ftpFilename=qSettings.readEntry(APP_KEY + "ftpFilename",""); ftpDefaultImageFormat=qSettings.readEntry(APP_KEY + "ftpDefaultImageFormat","png"); repeaterImageInterval=qSettings.readNumEntry(APP_KEY + "repeaterImageInterval",10); repeaterEnable=qSettings.readBoolEntry(APP_KEY + "repeaterEnable",FALSE); repeaterTxMode=((sstvMode)qSettings.readNumEntry(APP_KEY +"repeaterTxMode",0)); repeaterImage1=qSettings.readEntry(APP_KEY + "repeaterImage1",""); repeaterImage2=qSettings.readEntry(APP_KEY + "repeaterImage2",""); repeaterImage3=qSettings.readEntry(APP_KEY + "repeaterImage3",""); repeaterImage4=qSettings.readEntry(APP_KEY + "repeaterImage4",""); repeaterAcknowledge=qSettings.readEntry(APP_KEY + "repeaterAcknowledge",""); repeaterTemplate=qSettings.readEntry(APP_KEY + "repeaterTemplate",""); } //! write variables to config file /** Writes the variables to the config file. \sa readSettings */ void configDialog::writeSettings() { QSettings qSettings(QSettings::Ini); qSettings.writeEntry( APP_KEY + "docPath",docPath); qSettings.writeEntry( APP_KEY + "audioPath",audioPath); qSettings.writeEntry( APP_KEY + "rxImagePath",rxImagePath); qSettings.writeEntry( APP_KEY + "txImagePath",txImagePath); qSettings.writeEntry( APP_KEY + "templatePath",templatePath); qSettings.writeEntry( APP_KEY + "defaultImageFormat",defaultImageFormat); qSettings.writeEntry( APP_KEY + "samplingrate",samplingrate); qSettings.writeEntry( APP_KEY + "useUTC", useUTC); qSettings.writeEntry( APP_KEY + "rxClock",rxClock); qSettings.writeEntry( APP_KEY + "txClock",txClock); qSettings.writeEntry( APP_KEY + "audioDevice",audioDevice); qSettings.writeEntry( APP_KEY + "serialPort",serialPort); qSettings.writeEntry( APP_KEY + "callsign",callsign); qSettings.writeEntry( APP_KEY + "qth",qth); qSettings.writeEntry( APP_KEY + "locator",locator); qSettings.writeEntry( APP_KEY + "lastname",lastname); qSettings.writeEntry( APP_KEY + "firstname",firstname); qSettings.writeEntry( APP_KEY + "cwtext",cwText); qSettings.writeEntry( APP_KEY + "cwtone",cwTone); qSettings.writeEntry( APP_KEY + "cwWPM",cwWPM); qSettings.writeEntry( APP_KEY + "enableFTP",enableFTP); qSettings.writeEntry( APP_KEY + "ftpPort",ftpPort); qSettings.writeEntry( APP_KEY + "ftpRemoteHost",ftpRemoteHost); qSettings.writeEntry( APP_KEY + "ftpRemoteDirectory",ftpRemoteDirectory); qSettings.writeEntry( APP_KEY + "ftpLogin",ftpLogin); qSettings.writeEntry( APP_KEY + "ftpPassword",ftpPassword); qSettings.writeEntry( APP_KEY + "ftpFilename",ftpFilename); qSettings.writeEntry( APP_KEY + "ftpDefaultImageFormat",ftpDefaultImageFormat); qSettings.writeEntry(APP_KEY + "repeaterImageInterval",repeaterImageInterval); qSettings.writeEntry(APP_KEY + "repeaterEnable",repeaterEnable); qSettings.writeEntry(APP_KEY + "repeaterTxMode",repeaterTxMode); qSettings.writeEntry(APP_KEY + "repeaterImage1",repeaterImage1); qSettings.writeEntry(APP_KEY + "repeaterImage2",repeaterImage2); qSettings.writeEntry(APP_KEY + "repeaterImage3",repeaterImage3); qSettings.writeEntry(APP_KEY + "repeaterImage4",repeaterImage4); qSettings.writeEntry(APP_KEY + "repeaterAcknowledge",repeaterAcknowledge); qSettings.writeEntry(APP_KEY + "repeaterTemplate",repeaterTemplate); } void configDialog::exec() { int i; conf=new configForm(0); conf->setModal(FALSE); QStringList str=QImage::outputFormatList(); conf->defaultImageFormatComboBox->insertStringList(str); conf->ftpDefaultImageFormatComboBox->insertStringList(str); for(i=0;i<(NUMMODES-1);i++) // exclude Calibrate { conf->repeaterTxModeComboBox->insertItem(getMode(i)); } connect(conf->audioBrowseButton,SIGNAL(clicked()),SLOT(slotBrowseAudioPath())); connect(conf->docPathBrowseButton,SIGNAL(clicked()),SLOT(slotBrowseDocPath())); connect(conf->rxImageBrowseButton,SIGNAL(clicked()),SLOT(slotBrowseRxImagePath())); connect(conf->txImageBrowseButton,SIGNAL(clicked()),SLOT(slotBrowseTxImagePath())); connect(conf->templateBrowseButton,SIGNAL(clicked()),SLOT(slotBrowseTemplatePath())); connect(conf->rp1BrowseButton,SIGNAL(clicked()),SLOT(slotBrowseRp1())); connect(conf->rp2BrowseButton,SIGNAL(clicked()),SLOT(slotBrowseRp2())); connect(conf->rp3BrowseButton,SIGNAL(clicked()),SLOT(slotBrowseRp3())); connect(conf->rp4BrowseButton,SIGNAL(clicked()),SLOT(slotBrowseRp4())); connect(conf->rpTemplateBrowseButton,SIGNAL(clicked()),SLOT(slotBrowseRpTemplate())); setParams(); if(conf->exec()) { getParams(); writeSettings(); } delete conf; } void configDialog::setParams() { setValue(audioPath, conf->audioPathLineEdit); setValue(docPath,conf->docPathLineEdit); setValue(rxImagePath, conf->rxImagePathLineEdit); setValue(txImagePath, conf->txImagePathLineEdit); setValue(templatePath, conf->templatePathLineEdit); setValue(defaultImageFormat, conf->defaultImageFormatComboBox); setValue(useUTC,conf->utcCheckBox); setValue(rxClock,conf->rxClockLineEdit); setValue(txClock,conf->txClockLineEdit); setValue(audioDevice,conf->audioDeviceLineEdit); setValue(serialPort,conf->serialPortLineEdit); setValue(callsign,conf->callsignLineEdit); setValue(lastname,conf->lastnameLineEdit); setValue(firstname,conf->firstnameLineEdit); setValue(qth,conf->qthLineEdit); setValue(locator,conf->locatorLineEdit); setValue(cwText,conf->cwTextLineEdit); setValue(cwTone,conf->cwToneSpinBox); setValue(cwWPM,conf->cwWPMSpinBox); setValue(enableFTP,conf->enableFTPCheckBox); setValue(ftpPort,conf->ftpPortSpinBox); setValue(ftpRemoteHost,conf->remoteHostLineEdit); setValue(ftpRemoteDirectory,conf->remoteDirectoryLineEdit); setValue(ftpLogin,conf->ftpLoginLineEdit); setValue(ftpPassword,conf->ftpPasswordLineEdit); setValue(ftpFilename,conf->ftpFilenameLineEdit); setValue(ftpDefaultImageFormat,conf->ftpDefaultImageFormatComboBox); setValue(repeaterEnable,conf->repeaterEnableCheckBox); setValue(repeaterTxMode,conf->repeaterTxModeComboBox); setValue(repeaterImage1,conf->repeaterImage1LineEdit); setValue(repeaterImage2,conf->repeaterImage2LineEdit); setValue(repeaterImage3,conf->repeaterImage3LineEdit); setValue(repeaterImage4,conf->repeaterImage4LineEdit); setValue(repeaterAcknowledge,conf->repeaterAcknowledgeLineEdit); setValue(repeaterTemplate,conf->repeaterTemplateLineEdit); } void configDialog::getParams() { getValue(audioPath, conf->audioPathLineEdit); getValue(docPath,conf->docPathLineEdit); getValue(rxImagePath, conf->rxImagePathLineEdit); getValue(txImagePath, conf->txImagePathLineEdit); getValue(templatePath, conf->templatePathLineEdit); getValue(defaultImageFormat, conf->defaultImageFormatComboBox); defaultImageFormat=defaultImageFormat.lower(); getValue(useUTC,conf->utcCheckBox); getValue(rxClock,conf->rxClockLineEdit); getValue(txClock,conf->txClockLineEdit); getValue(audioDevice,conf->audioDeviceLineEdit); getValue(serialPort,conf->serialPortLineEdit); getValue(callsign,conf->callsignLineEdit); getValue(lastname,conf->lastnameLineEdit); getValue(firstname,conf->firstnameLineEdit); getValue(qth,conf->qthLineEdit); getValue(locator,conf->locatorLineEdit); getValue(cwText,conf->cwTextLineEdit); getValue(cwTone,conf->cwToneSpinBox); getValue(cwWPM,conf->cwWPMSpinBox); getValue(enableFTP,conf->enableFTPCheckBox); getValue(ftpPort,conf->ftpPortSpinBox); getValue(ftpRemoteHost,conf->remoteHostLineEdit); getValue(ftpRemoteDirectory,conf->remoteDirectoryLineEdit); getValue(ftpLogin,conf->ftpLoginLineEdit); getValue(ftpPassword,conf->ftpPasswordLineEdit); getValue(ftpFilename,conf->ftpFilenameLineEdit); getValue(ftpDefaultImageFormat,conf->ftpDefaultImageFormatComboBox); ftpDefaultImageFormat=ftpDefaultImageFormat.lower(); getValue(repeaterEnable,conf->repeaterEnableCheckBox); int t; getValue(t,conf->repeaterTxModeComboBox); repeaterTxMode=(sstvMode)t; getValue(repeaterImage1,conf->repeaterImage1LineEdit); getValue(repeaterImage2,conf->repeaterImage2LineEdit); getValue(repeaterImage3,conf->repeaterImage3LineEdit); getValue(repeaterImage4,conf->repeaterImage4LineEdit); getValue(repeaterAcknowledge,conf->repeaterAcknowledgeLineEdit); getValue(repeaterTemplate,conf->repeaterTemplateLineEdit); } void configDialog::slotBrowseAudioPath() { browseDir(conf->audioPathLineEdit,audioPath); } void configDialog::slotBrowseDocPath() { browseDir(conf->docPathLineEdit,docPath); } void configDialog::slotBrowseRxImagePath() { browseDir(conf->rxImagePathLineEdit,rxImagePath); } void configDialog::slotBrowseTxImagePath() { browseDir(conf->txImagePathLineEdit,txImagePath); } void configDialog::slotBrowseTemplatePath() { browseDir(conf->templatePathLineEdit,templatePath); } void configDialog::slotBrowseRp1() { browseGetFile(conf->repeaterImage1LineEdit,repeaterImage1); } void configDialog::slotBrowseRp2() { browseGetFile(conf->repeaterImage2LineEdit,repeaterImage2); } void configDialog::slotBrowseRp3() { browseGetFile(conf->repeaterImage3LineEdit,repeaterImage3); } void configDialog::slotBrowseRp4() { browseGetFile(conf->repeaterImage4LineEdit,repeaterImage4); } void configDialog::slotBrowseRpTemplate() { browseGetFile(conf->repeaterTemplateLineEdit,repeaterTemplate,"*.templ"); }