options.cpp
Go to the documentation of this file.00001 /***************************************************************************/ 00014 #include <kapp.h> 00015 #include <klocale.h> 00016 #include <kfiledialog.h> 00017 #include <kaudioplayer.h> 00018 #include <kiconloader.h> 00019 00020 #include <qpushbutton.h> 00021 #include <qgroupbox.h> 00022 #include <qbuttongroup.h> 00023 #include <qslider.h> 00024 #include <qcheckbox.h> 00025 #include <qradiobutton.h> 00026 #include <qlineedit.h> 00027 00028 #include "ksetiwatch.h" 00029 #include "options.h" 00030 #include "setiloc.h" 00031 00032 /*------------------------------------------------------------------------ */ 00033 Options::Options(QWidget *parent, const char *name ) 00034 : OptionsTmpl(parent,name) 00035 { 00036 slotSetRefreshInterval(globalopts->RefreshInterval); 00037 RefreshIntSlider->setValue(globalopts->RefreshInterval); 00038 00039 MinToPanelChkBox->setChecked(globalopts->MinimizeToPanel); 00040 DrawGridChkBox->setChecked(globalopts->DrawGrid); 00041 00042 HMSRadioBtn->setChecked(globalopts->hms); 00043 DHMSRadioBtn->setChecked(!globalopts->hms); 00044 00045 SpikeChkBox->setChecked(globalopts->ReportSpike); 00046 GaussianChkBox->setChecked(globalopts->ReportGaussian); 00047 PulseChkBox->setChecked(globalopts->ReportPulse); 00048 TripletChkBox->setChecked(globalopts->ReportTriplet); 00049 ShowRecordChkBox->setChecked(globalopts->ShowRecords); 00050 00051 PlayBtn->setPixmap(SmallIcon("1rightarrow")); 00052 SoundBtn->setPixmap(SmallIcon("fileopen")); 00053 SoundChkBox->setChecked(globalopts->PlaySound); 00054 SoundLineEdit->setText(globalopts->HighSignalSound); 00055 } 00056 00057 /*------------------------------------------------------------------------ */ 00058 Options::~Options() 00059 { 00060 } 00061 00062 /*------------------------------------------------------------------------ */ 00063 void Options::slotSetTimeFormat(int id) 00064 { 00065 if(id == 1) 00066 globalopts->hms = true; 00067 else 00068 globalopts->hms = false; 00069 } 00070 00071 /*------------------------------------------------------------------------ */ 00072 void Options::slotSetReportSignals(int id) 00073 { 00074 switch(id) 00075 { 00076 case 0: globalopts->ReportSpike = SpikeChkBox->isChecked(); 00077 break; 00078 case 1: globalopts->ReportGaussian = GaussianChkBox->isChecked(); 00079 break; 00080 case 2: globalopts->ReportPulse = PulseChkBox->isChecked(); 00081 break; 00082 case 3: globalopts->ReportTriplet = TripletChkBox->isChecked(); 00083 break; 00084 case 4: globalopts->ShowRecords = ShowRecordChkBox->isChecked(); 00085 break; 00086 default: 00087 break; 00088 } 00089 } 00090 00091 /*------------------------------------------------------------------------ */ 00092 void Options::slotSetMinToPanel() 00093 { 00094 globalopts->MinimizeToPanel = MinToPanelChkBox->isChecked(); 00095 emit dockStatusChanged(); 00096 } 00097 00098 /*------------------------------------------------------------------------ */ 00099 void Options::slotSetDrawGrid() 00100 { 00101 globalopts->DrawGrid = DrawGridChkBox->isChecked(); 00102 } 00103 00104 /*------------------------------------------------------------------------ */ 00105 void Options::slotSetSoundOption() 00106 { 00107 globalopts->PlaySound = SoundChkBox->isChecked(); 00108 } 00109 00110 /*------------------------------------------------------------------------ */ 00111 void Options::slotSelectSound() 00112 { 00113 QString f = KFileDialog::getOpenFileName(); 00114 if(!f.isEmpty()) 00115 { 00116 setSound(f); 00117 SoundLineEdit->setText(f); 00118 } 00119 } 00120 00121 /*------------------------------------------------------------------------ */ 00122 void Options::slotPlaySound() 00123 { 00124 if(!globalopts->HighSignalSound.isEmpty()) 00125 KAudioPlayer::play(globalopts->HighSignalSound); 00126 } 00127 00128 /*------------------------------------------------------------------------ */ 00129 void Options::slotSetSound() 00130 { 00131 setSound(SoundLineEdit->text()); 00132 } 00133 00134 /*------------------------------------------------------------------------ */ 00135 void Options::setSound(const QString& s) 00136 { 00137 globalopts->HighSignalSound = s; 00138 if(globalopts->HighSignalSound.isEmpty()) 00139 PlayBtn->setEnabled(false); 00140 else 00141 PlayBtn->setEnabled(true); 00142 } 00143 00144 /*------------------------------------------------------------------------ */ 00145 void Options::slotSetRefreshInterval(int ri) 00146 { 00147 QString title, buf; 00148 int m, s; 00149 00150 if(ri != globalopts->RefreshInterval) 00151 { 00152 for(SetiLoc* loc=Ksetiwatch::locationList().first(); loc != 0; 00153 loc=Ksetiwatch::locationList().next()) 00154 { 00155 loc->setRefreshInterval(ri); 00156 } 00157 } 00158 globalopts->RefreshInterval = ri; 00159 title = i18n("Refresh Interval: "); 00160 m = (int)(ri/60); 00161 s = ri % 60; 00162 if(m) 00163 { 00164 buf.sprintf("%d min ", m); 00165 title += buf; 00166 } 00167 if(s) 00168 { 00169 if(m) 00170 buf.sprintf("%02d s", s); 00171 else 00172 buf.sprintf("%d s", s); 00173 title += buf; 00174 } 00175 RefreshIntSliderBox->setTitle(title); 00176 } 00177 00178 /*------------------------------------------------------------------------ */ 00179 void Options::slotEnableRecordCheckbox(bool) 00180 { 00181 if(SpikeChkBox->isChecked() || GaussianChkBox->isChecked() || 00182 PulseChkBox->isChecked() || TripletChkBox->isChecked()) 00183 { 00184 ShowRecordChkBox->setEnabled(true); 00185 } 00186 else 00187 { 00188 ShowRecordChkBox->setEnabled(false); 00189 } 00190 } 00191 00192 #include "options.moc" 00193

