23 #include <QApplication>
24 #include <QFontMetrics>
25 #include <QTreeWidget>
26 #include <QTextStream>
30 #include <kio/netaccess.h>
32 #include <kstandardguiitem.h>
33 #include <kstandarddirs.h>
35 #include <kiconloader.h>
36 #include <ktemporaryfile.h>
37 #include <kmessagebox.h>
38 #include <kfiledialog.h>
58 setMainWidget( otvw );
59 setCaption( i18n(
"Options" ) );
60 setButtons( KDialog::Ok|KDialog::Cancel );
70 int maxwidth[ 3 ] = { 0, 0, 0 };
71 QFontMetrics qfm = optionsList()->fontMetrics();
73 for (
int i=0; i < optionsList()->topLevelItemCount(); ++i ) {
74 QTreeWidgetItem *topitem = optionsList()->topLevelItem( i );
75 topitem->setExpanded(
true );
77 for (
int j=0; j < topitem->childCount(); ++j ) {
78 QTreeWidgetItem *child = topitem->child( j );
80 for (
int icol=0; icol<3; ++icol ) {
81 child->setExpanded(
true );
83 int w = qfm.width( child->text( icol ) ) + 4;
85 w += 2*optionsList()->indentation();
88 if ( w > maxwidth[icol] ) {
95 for (
int icol=0; icol < 3; ++icol ) {
97 kDebug() << QString(
"max width of column %1: %2").arg(icol).arg(maxwidth[icol]) << endl;
99 optionsList()->setColumnWidth( icol, maxwidth[icol] );
111 setMainWidget( snw );
112 setCaption( i18n(
"Script Data" ) );
113 setButtons( KDialog::Ok|KDialog::Cancel );
115 connect( snw->ScriptName, SIGNAL( textChanged(
const QString &) ),
this, SLOT( slotEnableOkButton() ) );
122 void ScriptNameDialog::slotEnableOkButton() {
123 enableButtonOk( ! snw->ScriptName->text().isEmpty() );
131 :
KDialog( parent ), UnsavedChanges(false), checkForChanges(true),
132 currentFileURL(), currentDir( QDir::homePath() ),
133 currentScriptName(), currentAuthor()
138 setCaption( i18n(
"Script Builder" ) );
139 setButtons( KDialog::User1 );
140 setButtonGuiItem( KDialog::User1, KGuiItem( i18n(
"&Close"),
"dialog-close", i18n(
"Close the dialog") ) );
142 sb->FuncDoc->setTextInteractionFlags( Qt::NoTextInteraction );
145 KStarsFunctionList.append(
new ScriptFunction(
"lookTowards", i18n(
"Point the display at the specified location. %1 can be the name of an object, a cardinal point on the compass, or 'zenith'.", QString(
"dir" ) ),
false,
"QString",
"dir" ) );
146 KStarsFunctionList.append(
new ScriptFunction(
"addLabel", i18n(
"Add a name label to the object named %1.", QString(
"name" ) ),
false,
"QString",
"name" ) );
147 KStarsFunctionList.append(
new ScriptFunction(
"removeLabel", i18n(
"Remove the name label from the object named %1.", QString(
"name" ) ),
false,
"QString",
"name" ) );
148 KStarsFunctionList.append(
new ScriptFunction(
"addTrail", i18n(
"Add a trail to the solar system body named %1.", QString(
"name" ) ),
false,
"QString",
"name" ) );
149 KStarsFunctionList.append(
new ScriptFunction(
"removeTrail", i18n(
"Remove the trail from the solar system body named %1.", QString(
"name" ) ),
false,
"QString",
"name" ) );
150 KStarsFunctionList.append(
new ScriptFunction(
"setRaDec", i18n(
"Point the display at the specified RA/Dec coordinates. RA is expressed in Hours; Dec is expressed in Degrees." ),
151 false,
"double",
"ra",
"double",
"dec" ) );
152 KStarsFunctionList.append(
new ScriptFunction(
"setAltAz", i18n(
"Point the display at the specified Alt/Az coordinates. Alt and Az are expressed in Degrees." ),
153 false,
"double",
"alt",
"double",
"az" ) );
154 KStarsFunctionList.append(
new ScriptFunction(
"zoomIn", i18n(
"Increase the display Zoom Level." ),
false ) );
155 KStarsFunctionList.append(
new ScriptFunction(
"zoomOut", i18n(
"Decrease the display Zoom Level." ),
false ) );
156 KStarsFunctionList.append(
new ScriptFunction(
"defaultZoom", i18n(
"Set the display Zoom Level to its default value." ),
false ) );
157 KStarsFunctionList.append(
new ScriptFunction(
"zoom", i18n(
"Set the display Zoom Level manually." ),
false,
"double",
"z" ) );
158 KStarsFunctionList.append(
new ScriptFunction(
"setLocalTime", i18n(
"Set the system clock to the specified Local Time." ),
159 false,
"int",
"year",
"int",
"month",
"int",
"day",
"int",
"hour",
"int",
"minute",
"int",
"second" ) );
160 KStarsFunctionList.append(
new ScriptFunction(
"waitFor", i18n(
"Pause script execution for specified number of seconds." ),
false,
"double",
"sec" ) );
161 KStarsFunctionList.append(
new ScriptFunction(
"waitForKey", i18n(
"Halt script execution until the specified key is pressed. Only single-key strokes are possible; use 'space' for the spacebar." ),
162 false,
"QString",
"key" ) );
163 KStarsFunctionList.append(
new ScriptFunction(
"setTracking", i18n(
"Set whether the display is tracking the current location." ),
false,
"bool",
"track" ) );
164 KStarsFunctionList.append(
new ScriptFunction(
"changeViewOption", i18n(
"Change view option named %1 to value %2.", QString(
"opName" ), QString(
"opValue" ) ),
false,
"QString",
"opName",
"QString",
"opValue" ) );
165 KStarsFunctionList.append(
new ScriptFunction(
"setGeoLocation", i18n(
"Set the geographic location to the city specified by city, province and country." ),
166 false,
"QString",
"cityName",
"QString",
"provinceName",
"QString",
"countryName" ) );
167 KStarsFunctionList.append(
new ScriptFunction(
"setColor", i18n(
"Set the color named %1 to the value %2.", QString(
"colorName"), QString(
"value") ),
false,
"QString",
"colorName",
"QString",
"value" ) );
168 KStarsFunctionList.append(
new ScriptFunction(
"loadColorScheme", i18n(
"Load the color scheme specified by name." ),
false,
"QString",
"name" ) );
169 KStarsFunctionList.append(
new ScriptFunction(
"exportImage", i18n(
"Export the sky image to the file, with specified width and height."),
false,
"QString",
"fileName",
"int",
"width",
"int",
"height" ) );
170 KStarsFunctionList.append(
new ScriptFunction(
"printImage", i18n(
"Print the sky image to a printer or file. If %1 is true, it will show the print dialog. If %2 is true, it will use the Star Chart color scheme for printing.", QString(
"usePrintDialog" ), QString(
"useChartColors" ) ),
false,
"bool",
"usePrintDialog",
"bool",
"useChartColors" ) );
171 SimClockFunctionList.append(
new ScriptFunction(
"stop", i18n(
"Halt the simulation clock." ),
true ) );
172 SimClockFunctionList.append(
new ScriptFunction(
"start", i18n(
"Start the simulation clock." ),
true ) );
173 SimClockFunctionList.append(
new ScriptFunction(
"setClockScale", i18n(
"Set the timescale of the simulation clock to specified scale. 1.0 means real-time; 2.0 means twice real-time; etc." ),
true,
"double",
"scale" ) );
178 ScriptFunction *startINDIFunc(NULL), *shutdownINDIFunc(NULL), *switchINDIFunc(NULL), *setINDIPortFunc(NULL), *setINDIScopeActionFunc(NULL), *setINDITargetCoordFunc(NULL), *setINDITargetNameFunc(NULL), *setINDIGeoLocationFunc(NULL), *setINDIUTCFunc(NULL), *setINDIActionFunc(NULL), *waitForINDIActionFunc(NULL), *setINDIFocusSpeedFunc(NULL), *startINDIFocusFunc(NULL), *setINDIFocusTimeoutFunc(NULL), *setINDICCDTempFunc(NULL), *setINDIFilterNumFunc(NULL), *setINDIFrameTypeFunc(NULL), *startINDIExposureFunc(NULL), *setINDIDeviceFunc(NULL);
180 startINDIFunc =
new ScriptFunction(
"startINDI", i18n(
"Establish an INDI device either in local mode or server mode."),
false,
"QString",
"deviceName",
"bool",
"useLocal");
181 INDIFunctionList.append ( startINDIFunc );
183 setINDIDeviceFunc =
new ScriptFunction(
"setINDIDevice", i18n(
"Change current active device. All subsequent function calls will communicate with this device until changed"),
false,
"QString",
"deviceName");
184 INDIFunctionList.append(setINDIDeviceFunc);
186 shutdownINDIFunc =
new ScriptFunction(
"shutdownINDI", i18n(
"Shutdown an INDI device."),
false,
"QString",
"deviceName");
187 INDIFunctionList.append ( shutdownINDIFunc);
189 switchINDIFunc =
new ScriptFunction(
"switchINDI", i18n(
"Connect or Disconnect an INDI device."),
false,
"bool",
"turnOn");
190 switchINDIFunc->setINDIProperty(
"CONNECTION");
191 switchINDIFunc->setArg(0,
"true");
192 INDIFunctionList.append ( switchINDIFunc);
194 setINDIPortFunc =
new ScriptFunction(
"setINDIPort", i18n(
"Set INDI's device connection port."),
false,
"QString",
"port");
195 setINDIPortFunc->setINDIProperty(
"DEVICE_PORT");
196 INDIFunctionList.append ( setINDIPortFunc);
198 setINDIScopeActionFunc =
new ScriptFunction(
"setINDIScopeAction", i18n(
"Set the telescope action. Available actions are SLEW, TRACK, SYNC, PARK, and ABORT."),
false,
"QString",
"action");
199 setINDIScopeActionFunc->setINDIProperty(
"CHECK");
200 setINDIScopeActionFunc->setArg(0,
"SLEW");
201 INDIFunctionList.append( setINDIScopeActionFunc);
203 setINDITargetCoordFunc =
new ScriptFunction (
"setINDITargetCoord", i18n(
"Set the telescope target coordinates to the RA/Dec coordinates. RA is expressed in Hours; DEC is expressed in Degrees." ),
false,
"double",
"RA",
"double",
"DEC" );
204 setINDITargetCoordFunc->setINDIProperty(
"EQUATORIAL_EOD_COORD");
205 INDIFunctionList.append ( setINDITargetCoordFunc );
207 setINDITargetNameFunc =
new ScriptFunction(
"setINDITargetName", i18n(
"Set the telescope target coordinates to the RA/Dec coordinates of the selected object."),
false,
"QString",
"targetName");
208 setINDITargetNameFunc->setINDIProperty(
"EQUATORIAL_EOD_COORD");
209 INDIFunctionList.append( setINDITargetNameFunc);
211 setINDIGeoLocationFunc =
new ScriptFunction (
"setINDIGeoLocation", i18n(
"Set the telescope longitude and latitude. The longitude is measured east from Greenwich, UK."),
false,
"double",
"long",
"double",
"lat");
212 setINDIGeoLocationFunc->setINDIProperty(
"GEOGRAPHIC_COORD");
213 INDIFunctionList.append( setINDIGeoLocationFunc);
215 setINDIUTCFunc =
new ScriptFunction (
"setINDIUTC", i18n(
"Set the device UTC time in ISO 8601 format YYYY/MM/DDTHH:MM:SS."),
false,
"QString",
"UTCDateTime");
216 setINDIUTCFunc->setINDIProperty(
"TIME_UTC");
217 INDIFunctionList.append( setINDIUTCFunc);
219 setINDIActionFunc =
new ScriptFunction(
"setINDIAction", i18n(
"Activate an INDI action. The action is the name of any INDI switch property element supported by the device."),
false,
"QString",
"actionName");
220 INDIFunctionList.append( setINDIActionFunc);
222 waitForINDIActionFunc =
new ScriptFunction (
"waitForINDIAction", i18n(
"Pause script execution until action returns with OK status. The action can be the name of any INDI property supported by the device."),
false,
"QString",
"actionName");
223 INDIFunctionList.append( waitForINDIActionFunc );
225 setINDIFocusSpeedFunc =
new ScriptFunction (
"setINDIFocusSpeed", i18n(
"Set the telescope focuser speed. Set speed to 0 to halt the focuser. 1-3 correspond to slow, medium, and fast speeds respectively."),
false,
"unsigned int",
"speed");
226 setINDIFocusSpeedFunc->setINDIProperty(
"FOCUS_SPEED");
227 INDIFunctionList.append( setINDIFocusSpeedFunc );
229 startINDIFocusFunc =
new ScriptFunction (
"startINDIFocus", i18n(
"Start moving the focuser in the direction Dir, and for the duration specified by setINDIFocusTimeout."),
false,
"QString",
"Dir");
230 startINDIFocusFunc->setINDIProperty(
"FOCUS_MOTION");
231 startINDIFocusFunc->setArg(0,
"IN");
232 INDIFunctionList.append( startINDIFocusFunc);
234 setINDIFocusTimeoutFunc =
new ScriptFunction (
"setINDIFocusTimeout", i18n(
"Set the telescope focuser timer in seconds. This is the duration of any focusing procedure performed by calling startINDIFocus."),
false,
"int",
"timeout");
235 setINDIFocusTimeoutFunc->setINDIProperty(
"FOCUS_TIMER");
236 INDIFunctionList.append( setINDIFocusTimeoutFunc);
238 setINDICCDTempFunc =
new ScriptFunction(
"setINDICCDTemp", i18n(
"Set the target CCD chip temperature."),
false,
"int",
"temp");
239 setINDICCDTempFunc->setINDIProperty(
"CCD_TEMPERATURE");
240 INDIFunctionList.append( setINDICCDTempFunc);
242 setINDIFilterNumFunc =
new ScriptFunction(
"setINDIFilterNum", i18n(
"Set the target filter position."),
false,
"int",
"filter_num");
243 setINDIFilterNumFunc->setINDIProperty(
"FILTER_SLOT");
244 INDIFunctionList.append ( setINDIFilterNumFunc);
246 setINDIFrameTypeFunc =
new ScriptFunction(
"setINDIFrameType", i18n(
"Set the CCD camera frame type. Available options are FRAME_LIGHT, FRAME_BIAS, FRAME_DARK, and FRAME_FLAT."),
false,
"QString",
"type");
247 setINDIFrameTypeFunc->setINDIProperty(
"FRAME_TYPE");
248 setINDIFrameTypeFunc->setArg(0,
"FRAME_LIGHT");
249 INDIFunctionList.append( setINDIFrameTypeFunc);
251 startINDIExposureFunc =
new ScriptFunction (
"startINDIExposure", i18n(
"Start Camera/CCD exposure. The duration is in seconds."),
false,
"int",
"timeout");
252 startINDIExposureFunc->setINDIProperty(
"CCD_EXPOSE_DURATION");
253 INDIFunctionList.append( startINDIExposureFunc);
257 QTreeWidgetItem *kstars_tree =
new QTreeWidgetItem( sb->FunctionTree, QStringList(
"KStars"));
258 QTreeWidgetItem *simclock_tree =
new QTreeWidgetItem( sb->FunctionTree, QStringList(
"SimClock"));
260 for (
int i=0; i < KStarsFunctionList.size(); ++i )
261 new QTreeWidgetItem (kstars_tree, QStringList( KStarsFunctionList[i]->prototype()) );
263 for (
int i=0; i < SimClockFunctionList.size(); ++i )
264 new QTreeWidgetItem (simclock_tree, QStringList( SimClockFunctionList[i]->prototype()) );
266 kstars_tree->sortChildren( 0, Qt::AscendingOrder );
267 simclock_tree->sortChildren( 0, Qt::AscendingOrder );
269 sb->FunctionTree->setColumnCount(1);
270 sb->FunctionTree->setHeaderLabels( QStringList(i18n(
"Functions")) );
271 sb->FunctionTree->setSortingEnabled(
false );
274 QTreeWidgetItem *INDI_tree =
new QTreeWidgetItem( sb->FunctionTree, QStringList(
"INDI"));
275 QTreeWidgetItem *INDI_general =
new QTreeWidgetItem( INDI_tree, QStringList(
"General"));
276 QTreeWidgetItem *INDI_telescope =
new QTreeWidgetItem( INDI_tree, QStringList(
"Telescope"));
277 QTreeWidgetItem *INDI_ccd =
new QTreeWidgetItem( INDI_tree, QStringList(
"Camera/CCD"));
278 QTreeWidgetItem *INDI_focuser =
new QTreeWidgetItem( INDI_tree, QStringList(
"Focuser"));
279 QTreeWidgetItem *INDI_filter =
new QTreeWidgetItem( INDI_tree, QStringList(
"Filter"));
282 new QTreeWidgetItem(INDI_general, QStringList(startINDIFunc->prototype()));
283 new QTreeWidgetItem(INDI_general, QStringList(shutdownINDIFunc->prototype()));
284 new QTreeWidgetItem(INDI_general, QStringList(setINDIDeviceFunc->
prototype()));
285 new QTreeWidgetItem(INDI_general, QStringList(switchINDIFunc->prototype()));
286 new QTreeWidgetItem(INDI_general, QStringList(setINDIPortFunc->prototype()));
287 new QTreeWidgetItem(INDI_general, QStringList(setINDIActionFunc->prototype()));
288 new QTreeWidgetItem(INDI_general, QStringList(waitForINDIActionFunc->prototype()));
291 new QTreeWidgetItem(INDI_telescope, QStringList(setINDIScopeActionFunc->prototype()));
292 new QTreeWidgetItem(INDI_telescope, QStringList(setINDITargetCoordFunc->prototype()));
293 new QTreeWidgetItem(INDI_telescope, QStringList(setINDITargetNameFunc->prototype()));
294 new QTreeWidgetItem(INDI_telescope, QStringList(setINDIGeoLocationFunc->prototype()));
295 new QTreeWidgetItem(INDI_telescope, QStringList(setINDIUTCFunc->prototype()));
298 new QTreeWidgetItem(INDI_ccd, QStringList(setINDICCDTempFunc->prototype()));
299 new QTreeWidgetItem(INDI_ccd, QStringList(setINDIFrameTypeFunc->prototype()));
300 new QTreeWidgetItem(INDI_ccd, QStringList(startINDIExposureFunc->prototype()));
303 new QTreeWidgetItem(INDI_focuser, QStringList(setINDIFocusSpeedFunc->prototype()));
304 new QTreeWidgetItem(INDI_focuser, QStringList(setINDIFocusTimeoutFunc->prototype()));
305 new QTreeWidgetItem(INDI_focuser, QStringList(startINDIFocusFunc->prototype()));
308 new QTreeWidgetItem(INDI_filter, QStringList(setINDIFilterNumFunc->prototype()));
312 sb->NewButton->setIcon( KIcon(
"document-new" ) );
313 sb->OpenButton->setIcon( KIcon(
"document-open" ) );
314 sb->SaveButton->setIcon( KIcon(
"document-save" ) );
315 sb->SaveAsButton->setIcon( KIcon(
"document-save-as" ) );
316 sb->RunButton->setIcon( KIcon(
"system-run" ) );
317 sb->CopyButton->setIcon( KIcon(
"view-refresh" ) );
318 sb->AddButton->setIcon( KIcon(
"go-previous" ) );
319 sb->RemoveButton->setIcon( KIcon(
"go-next" ) );
320 sb->UpButton->setIcon( KIcon(
"go-up" ) );
321 sb->DownButton->setIcon( KIcon(
"go-down" ) );
325 argLookToward =
new ArgLookToward( sb->ArgStack );
326 argFindObject =
new ArgFindObject( sb->ArgStack );
327 argSetRaDec =
new ArgSetRaDec( sb->ArgStack );
328 argSetAltAz =
new ArgSetAltAz( sb->ArgStack );
329 argSetLocalTime =
new ArgSetLocalTime( sb->ArgStack );
330 argWaitFor =
new ArgWaitFor( sb->ArgStack );
331 argWaitForKey =
new ArgWaitForKey( sb->ArgStack );
332 argSetTracking =
new ArgSetTrack( sb->ArgStack );
333 argChangeViewOption =
new ArgChangeViewOption( sb->ArgStack );
334 argSetGeoLocation =
new ArgSetGeoLocation( sb->ArgStack );
335 argTimeScale =
new ArgTimeScale( sb->ArgStack );
336 argZoom =
new ArgZoom( sb->ArgStack );
337 argExportImage =
new ArgExportImage( sb->ArgStack );
338 argPrintImage =
new ArgPrintImage( sb->ArgStack );
339 argSetColor =
new ArgSetColor( sb->ArgStack );
340 argLoadColorScheme =
new ArgLoadColorScheme( sb->ArgStack );
343 argStartINDI =
new ArgStartINDI ( sb->ArgStack );
344 argSetDeviceINDI =
new ArgSetDeviceINDI (sb->ArgStack);
345 argShutdownINDI =
new ArgShutdownINDI ( sb->ArgStack );
346 argSwitchINDI =
new ArgSwitchINDI ( sb->ArgStack );
347 argSetPortINDI =
new ArgSetPortINDI ( sb->ArgStack );
348 argSetTargetCoordINDI =
new ArgSetTargetCoordINDI ( sb->ArgStack );
349 argSetTargetNameINDI =
new ArgSetTargetNameINDI ( sb->ArgStack );
350 argSetActionINDI =
new ArgSetActionINDI ( sb->ArgStack );
351 argWaitForActionINDI =
new ArgSetActionINDI ( sb->ArgStack );
352 argSetFocusSpeedINDI =
new ArgSetFocusSpeedINDI ( sb->ArgStack );
353 argStartFocusINDI =
new ArgStartFocusINDI( sb->ArgStack );
354 argSetFocusTimeoutINDI =
new ArgSetFocusTimeoutINDI( sb->ArgStack );
355 argSetGeoLocationINDI =
new ArgSetGeoLocationINDI( sb->ArgStack );
356 argStartExposureINDI =
new ArgStartExposureINDI( sb->ArgStack );
357 argSetUTCINDI =
new ArgSetUTCINDI( sb->ArgStack );
358 argSetScopeActionINDI =
new ArgSetScopeActionINDI( sb->ArgStack );
359 argSetFrameTypeINDI =
new ArgSetFrameTypeINDI ( sb->ArgStack );
360 argSetCCDTempINDI =
new ArgSetCCDTempINDI( sb->ArgStack );
361 argSetFilterNumINDI =
new ArgSetFilterNumINDI( sb->ArgStack );
363 argStartFocusINDI->directionCombo->addItem(
"IN");
364 argStartFocusINDI->directionCombo->addItem(
"OUT");
366 argSetScopeActionINDI->actionCombo->addItem(
"SLEW");
367 argSetScopeActionINDI->actionCombo->addItem(
"TRACK");
368 argSetScopeActionINDI->actionCombo->addItem(
"SYNC");
369 argSetScopeActionINDI->actionCombo->addItem(
"PARK");
370 argSetScopeActionINDI->actionCombo->addItem(
"ABORT");
372 argSetFrameTypeINDI->typeCombo->addItem(
"FRAME_LIGHT");
373 argSetFrameTypeINDI->typeCombo->addItem(
"FRAME_BIAS");
374 argSetFrameTypeINDI->typeCombo->addItem(
"FRAME_DARK");
375 argSetFrameTypeINDI->typeCombo->addItem(
"FRAME_FLAT");
378 sb->ArgStack->addWidget( argBlank );
379 sb->ArgStack->addWidget( argLookToward );
380 sb->ArgStack->addWidget( argFindObject );
381 sb->ArgStack->addWidget( argSetRaDec );
382 sb->ArgStack->addWidget( argSetAltAz );
383 sb->ArgStack->addWidget( argSetLocalTime );
384 sb->ArgStack->addWidget( argWaitFor );
385 sb->ArgStack->addWidget( argWaitForKey );
386 sb->ArgStack->addWidget( argSetTracking );
387 sb->ArgStack->addWidget( argChangeViewOption );
388 sb->ArgStack->addWidget( argSetGeoLocation );
389 sb->ArgStack->addWidget( argTimeScale );
390 sb->ArgStack->addWidget( argZoom );
391 sb->ArgStack->addWidget( argExportImage );
392 sb->ArgStack->addWidget( argPrintImage );
393 sb->ArgStack->addWidget( argSetColor );
394 sb->ArgStack->addWidget( argLoadColorScheme );
397 sb->ArgStack->addWidget( argStartINDI);
398 sb->ArgStack->addWidget( argSetDeviceINDI);
399 sb->ArgStack->addWidget( argShutdownINDI);
400 sb->ArgStack->addWidget( argSwitchINDI);
401 sb->ArgStack->addWidget( argSetPortINDI);
402 sb->ArgStack->addWidget( argSetTargetCoordINDI);
403 sb->ArgStack->addWidget( argSetTargetNameINDI);
404 sb->ArgStack->addWidget( argSetActionINDI);
405 sb->ArgStack->addWidget( argWaitForActionINDI );
406 sb->ArgStack->addWidget( argSetFocusSpeedINDI );
407 sb->ArgStack->addWidget( argStartFocusINDI);
408 sb->ArgStack->addWidget( argSetFocusTimeoutINDI);
409 sb->ArgStack->addWidget( argSetGeoLocationINDI);
410 sb->ArgStack->addWidget( argStartExposureINDI);
411 sb->ArgStack->addWidget( argSetUTCINDI);
412 sb->ArgStack->addWidget( argSetScopeActionINDI);
413 sb->ArgStack->addWidget( argSetFrameTypeINDI);
414 sb->ArgStack->addWidget( argSetCCDTempINDI);
415 sb->ArgStack->addWidget( argSetFilterNumINDI);
418 sb->ArgStack->setCurrentIndex( 0 );
420 snd =
new ScriptNameDialog( ks );
421 otv =
new OptionsTreeView( ks );
423 otv->resize( sb->width(), 0.5*sb->height() );
426 otv->resizeColumns();
429 connect(
this, SIGNAL(user1Clicked()),
this, SLOT(
slotClose()));
430 connect( sb->FunctionTree, SIGNAL( itemDoubleClicked(QTreeWidgetItem *,
int )),
this, SLOT(
slotAddFunction() ) );
431 connect( sb->FunctionTree, SIGNAL( itemClicked(QTreeWidgetItem*,
int) ),
this, SLOT(
slotShowDoc() ) );
433 connect( sb->ScriptListBox, SIGNAL( itemClicked(QListWidgetItem *) ),
this, SLOT(
slotArgWidget() ) );
435 connect( sb->CopyButton, SIGNAL( clicked() ),
this, SLOT(
slotCopyFunction() ) );
437 connect( sb->NewButton, SIGNAL( clicked() ),
this, SLOT(
slotNew() ) );
438 connect( sb->OpenButton, SIGNAL( clicked() ),
this, SLOT(
slotOpen() ) );
439 connect( sb->SaveButton, SIGNAL( clicked() ),
this, SLOT(
slotSave() ) );
440 connect( sb->SaveAsButton, SIGNAL( clicked() ),
this, SLOT(
slotSaveAs() ) );
441 connect( sb->AddButton, SIGNAL( clicked() ),
this, SLOT(
slotAddFunction() ) );
442 connect( sb->RunButton, SIGNAL( clicked() ),
this, SLOT(
slotRunScript() ) );
445 connect( argSetGeoLocation->FindCityButton, SIGNAL( clicked() ),
this, SLOT(
slotFindCity() ) );
446 connect( argLookToward->FindButton, SIGNAL( clicked() ),
this, SLOT(
slotFindObject() ) );
447 connect( argChangeViewOption->TreeButton, SIGNAL( clicked() ),
this, SLOT(
slotShowOptions() ) );
449 connect( argLookToward->FocusEdit, SIGNAL( textChanged(
const QString &) ),
this, SLOT(
slotLookToward() ) );
450 connect( argFindObject->NameEdit, SIGNAL( textChanged(
const QString &) ),
this, SLOT(
slotArgFindObject() ) );
451 connect( argSetRaDec->RABox, SIGNAL( textChanged(
const QString &) ),
this, SLOT(
slotRa() ) );
452 connect( argSetRaDec->DecBox, SIGNAL( textChanged(
const QString &) ),
this, SLOT(
slotDec() ) );
453 connect( argSetAltAz->AltBox, SIGNAL( textChanged(
const QString &) ),
this, SLOT(
slotAlt() ) );
454 connect( argSetAltAz->AzBox, SIGNAL( textChanged(
const QString &) ),
this, SLOT(
slotAz() ) );
455 connect( argSetLocalTime->DateWidget, SIGNAL( changed(
const QDate&) ),
this, SLOT(
slotChangeDate() ) );
456 connect( argSetLocalTime->TimeBox, SIGNAL( timeChanged(
const QTime&) ),
this, SLOT(
slotChangeTime() ) );
457 connect( argWaitFor->DelayBox, SIGNAL( valueChanged(
int) ),
this, SLOT(
slotWaitFor() ) );
458 connect( argWaitForKey->WaitKeyEdit, SIGNAL( textChanged(
const QString &) ),
this, SLOT(
slotWaitForKey() ) );
459 connect( argSetTracking->CheckTrack, SIGNAL( stateChanged(
int) ),
this, SLOT(
slotTracking() ) );
460 connect( argChangeViewOption->OptionName, SIGNAL( activated(
const QString &) ),
this, SLOT(
slotViewOption() ) );
461 connect( argChangeViewOption->OptionValue, SIGNAL( textChanged(
const QString &) ),
this, SLOT(
slotViewOption() ) );
462 connect( argSetGeoLocation->CityName, SIGNAL( textChanged(
const QString &) ),
this, SLOT(
slotChangeCity() ) );
463 connect( argSetGeoLocation->ProvinceName, SIGNAL( textChanged(
const QString &) ),
this, SLOT(
slotChangeProvince() ) );
464 connect( argSetGeoLocation->CountryName, SIGNAL( textChanged(
const QString &) ),
this, SLOT(
slotChangeCountry() ) );
465 connect( argTimeScale->TimeScale, SIGNAL( scaleChanged(
float) ),
this, SLOT(
slotTimeScale() ) );
466 connect( argZoom->ZoomBox, SIGNAL( textChanged(
const QString &) ),
this, SLOT(
slotZoom() ) );
467 connect( argExportImage->ExportFileName, SIGNAL( textChanged(
const QString &) ),
this, SLOT(
slotExportImage() ) );
468 connect( argExportImage->ExportWidth, SIGNAL( valueChanged(
int) ),
this, SLOT(
slotExportImage() ) );
469 connect( argExportImage->ExportHeight, SIGNAL( valueChanged(
int) ),
this, SLOT(
slotExportImage() ) );
470 connect( argPrintImage->UsePrintDialog, SIGNAL( toggled(
bool) ),
this, SLOT(
slotPrintImage() ) );
471 connect( argPrintImage->UseChartColors, SIGNAL( toggled(
bool) ),
this, SLOT(
slotPrintImage() ) );
472 connect( argSetColor->ColorName, SIGNAL( activated(
const QString &) ),
this, SLOT(
slotChangeColorName() ) );
473 connect( argSetColor->ColorValue, SIGNAL( changed(
const QColor &) ),
this, SLOT(
slotChangeColor() ) );
474 connect( argLoadColorScheme->SchemeList, SIGNAL( itemClicked ( QListWidgetItem * )),
this, SLOT(
slotLoadColorScheme() ) );
482 connect (argStartINDI->deviceName, SIGNAL( textChanged(
const QString &) ),
this, SLOT(slotINDIStartDeviceName()));
483 connect (argStartINDI->LocalButton, SIGNAL ( toggled(
bool)),
this, SLOT (slotINDIStartDeviceMode()));
486 connect (argSetDeviceINDI->deviceName, SIGNAL( textChanged(
const QString &) ),
this, SLOT(slotINDISetDevice()));
489 connect (argShutdownINDI->deviceName, SIGNAL( textChanged(
const QString &) ),
this, SLOT(slotINDIShutdown()));
492 connect (argSwitchINDI->OnButton, SIGNAL ( toggled(
bool)),
this, SLOT (slotINDISwitchDeviceConnection()));
495 connect (argSetPortINDI->devicePort, SIGNAL( textChanged(
const QString &) ),
this, SLOT(slotINDISetPortDevicePort()));
498 connect( argSetTargetCoordINDI->RABox, SIGNAL( textChanged(
const QString &) ),
this, SLOT( slotINDISetTargetCoordDeviceRA() ) );
499 connect( argSetTargetCoordINDI->DecBox, SIGNAL( textChanged(
const QString &) ),
this, SLOT( slotINDISetTargetCoordDeviceDEC() ) );
502 connect (argSetTargetNameINDI->targetName, SIGNAL( textChanged(
const QString &) ),
this, SLOT(slotINDISetTargetNameTargetName()));
505 connect (argSetActionINDI->actionName, SIGNAL( textChanged(
const QString &) ),
this, SLOT(slotINDISetActionName()));
508 connect (argWaitForActionINDI->actionName, SIGNAL( textChanged(
const QString &) ),
this, SLOT(slotINDIWaitForActionName()));
511 connect (argSetFocusSpeedINDI->speedIN, SIGNAL( valueChanged(
int) ),
this, SLOT(slotINDISetFocusSpeed()));
514 connect (argStartFocusINDI->directionCombo, SIGNAL( activated(
const QString &) ),
this, SLOT(slotINDIStartFocusDirection()));
517 connect (argSetFocusTimeoutINDI->timeOut, SIGNAL( valueChanged(
int) ),
this, SLOT(slotINDISetFocusTimeout()));
520 connect( argSetGeoLocationINDI->longBox, SIGNAL( textChanged(
const QString &) ),
this, SLOT( slotINDISetGeoLocationDeviceLong() ) );
521 connect( argSetGeoLocationINDI->latBox, SIGNAL( textChanged(
const QString &) ),
this, SLOT( slotINDISetGeoLocationDeviceLat() ) );
524 connect (argStartExposureINDI->timeOut, SIGNAL( valueChanged(
int) ),
this, SLOT(slotINDIStartExposureTimeout()));
527 connect (argSetUTCINDI->UTC, SIGNAL( textChanged(
const QString &) ),
this, SLOT(slotINDISetUTC()));
530 connect (argSetScopeActionINDI->actionCombo, SIGNAL( activated(
const QString &) ),
this, SLOT(slotINDISetScopeAction()));
533 connect (argSetFrameTypeINDI->typeCombo, SIGNAL( activated(
const QString &) ),
this, SLOT(slotINDISetFrameType()));
536 connect (argSetCCDTempINDI->temp, SIGNAL( valueChanged(
int) ),
this, SLOT(slotINDISetCCDTemp()));
539 connect (argSetFilterNumINDI->filter_num, SIGNAL( valueChanged(
int) ),
this, SLOT(slotINDISetFilterNum()));
544 sb->CopyButton->setEnabled(
false );
545 sb->AddButton->setEnabled(
false );
546 sb->RemoveButton->setEnabled(
false );
547 sb->UpButton->setEnabled(
false );
548 sb->DownButton->setEnabled(
false );
549 sb->SaveButton->setEnabled(
false );
550 sb->SaveAsButton->setEnabled(
false );
551 sb->RunButton->setEnabled(
false );
556 while ( ! KStarsFunctionList.isEmpty() )
557 delete KStarsFunctionList.takeFirst();
562 while( !SimClockFunctionList.isEmpty() )
563 delete SimClockFunctionList.takeFirst();
565 while ( ! ScriptList.isEmpty() )
566 delete ScriptList.takeFirst();
569 void ScriptBuilder::initViewOptions() {
570 otv->optionsList()->setRootIsDecorated(
true );
574 opsGUI =
new QTreeWidgetItem( otv->optionsList(), QStringList(i18n(
"InfoBoxes" )) );
575 fields <<
"ShowInfoBoxes" << i18n(
"Toggle display of all InfoBoxes" ) << i18n(
"bool" );
576 new QTreeWidgetItem( opsGUI, fields );
578 fields <<
"ShowTimeBox" << i18n(
"Toggle display of Time InfoBox" ) << i18n(
"bool" );
579 new QTreeWidgetItem( opsGUI, fields );
581 fields <<
"ShowGeoBox" << i18n(
"Toggle display of Geographic InfoBox" ) << i18n(
"bool" );
582 new QTreeWidgetItem( opsGUI, fields );
584 fields <<
"ShowFocusBox" << i18n(
"Toggle display of Focus InfoBox" ) << i18n(
"bool" );
585 new QTreeWidgetItem( opsGUI, fields );
587 fields <<
"ShadeTimeBox" << i18n(
"(un)Shade Time InfoBox" ) << i18n(
"bool" );
588 new QTreeWidgetItem( opsGUI, fields );
590 fields <<
"ShadeGeoBox" << i18n(
"(un)Shade Geographic InfoBox" ) << i18n(
"bool" );
591 new QTreeWidgetItem( opsGUI, fields );
593 fields <<
"ShadeFocusBox" << i18n(
"(un)Shade Focus InfoBox" ) << i18n(
"bool" );
594 new QTreeWidgetItem( opsGUI, fields );
597 argChangeViewOption->OptionName->addItem(
"ShowInfoBoxes" );
598 argChangeViewOption->OptionName->addItem(
"ShowTimeBox" );
599 argChangeViewOption->OptionName->addItem(
"ShowGeoBox" );
600 argChangeViewOption->OptionName->addItem(
"ShowFocusBox" );
601 argChangeViewOption->OptionName->addItem(
"ShadeTimeBox" );
602 argChangeViewOption->OptionName->addItem(
"ShadeGeoBox" );
603 argChangeViewOption->OptionName->addItem(
"ShadeFocusBox" );
606 opsToolbar =
new QTreeWidgetItem( otv->optionsList(), QStringList(i18n(
"Toolbars" )) );
607 fields <<
"ShowMainToolBar" << i18n(
"Toggle display of main toolbar" ) << i18n(
"bool" );
608 new QTreeWidgetItem( opsToolbar, fields );
610 fields <<
"ShowViewToolBar" << i18n(
"Toggle display of view toolbar" ) << i18n(
"bool" );
611 new QTreeWidgetItem( opsToolbar, fields );
614 argChangeViewOption->OptionName->addItem(
"ShowMainToolBar" );
615 argChangeViewOption->OptionName->addItem(
"ShowViewToolBar" );
618 opsShowObj =
new QTreeWidgetItem( otv->optionsList(), QStringList(i18n(
"Show Objects" )) );
619 fields <<
"ShowStars" << i18n(
"Toggle display of Stars" ) << i18n(
"bool" );
620 new QTreeWidgetItem( opsShowObj, fields );
622 fields <<
"ShowDeepSky" << i18n(
"Toggle display of all deep-sky objects" ) << i18n(
"bool" );
623 new QTreeWidgetItem( opsShowObj, fields );
625 fields <<
"ShowMessier" << i18n(
"Toggle display of Messier object symbols" ) << i18n(
"bool" );
626 new QTreeWidgetItem( opsShowObj, fields );
628 fields <<
"ShowMessierImages" << i18n(
"Toggle display of Messier object images" ) << i18n(
"bool" );
629 new QTreeWidgetItem( opsShowObj, fields );
631 fields <<
"ShowNGC" << i18n(
"Toggle display of NGC objects" ) << i18n(
"bool" );
632 new QTreeWidgetItem( opsShowObj, fields );
634 fields <<
"ShowIC" << i18n(
"Toggle display of IC objects" ) << i18n(
"bool" );
635 new QTreeWidgetItem( opsShowObj, fields );
637 fields <<
"ShowSolarSystem" << i18n(
"Toggle display of all solar system bodies" ) << i18n(
"bool" );
638 new QTreeWidgetItem( opsShowObj, fields );
640 fields <<
"ShowSun" << i18n(
"Toggle display of Sun" ) << i18n(
"bool" );
641 new QTreeWidgetItem( opsShowObj, fields );
643 fields <<
"ShowMoon" << i18n(
"Toggle display of Moon" ) << i18n(
"bool" );
644 new QTreeWidgetItem( opsShowObj, fields );
646 fields <<
"ShowMercury" << i18n(
"Toggle display of Mercury" ) << i18n(
"bool" );
647 new QTreeWidgetItem( opsShowObj, fields );
649 fields <<
"ShowVenus" << i18n(
"Toggle display of Venus" ) << i18n(
"bool" );
650 new QTreeWidgetItem( opsShowObj, fields );
652 fields <<
"ShowMars" << i18n(
"Toggle display of Mars" ) << i18n(
"bool" );
653 new QTreeWidgetItem( opsShowObj, fields );
655 fields <<
"ShowJupiter" << i18n(
"Toggle display of Jupiter" ) << i18n(
"bool" );
656 new QTreeWidgetItem( opsShowObj, fields );
658 fields <<
"ShowSaturn" << i18n(
"Toggle display of Saturn" ) << i18n(
"bool" );
659 new QTreeWidgetItem( opsShowObj, fields );
661 fields <<
"ShowUranus" << i18n(
"Toggle display of Uranus" ) << i18n(
"bool" );
662 new QTreeWidgetItem( opsShowObj, fields );
664 fields <<
"ShowNeptune" << i18n(
"Toggle display of Neptune" ) << i18n(
"bool" );
665 new QTreeWidgetItem( opsShowObj, fields );
667 fields <<
"ShowPluto" << i18n(
"Toggle display of Pluto" ) << i18n(
"bool" );
668 new QTreeWidgetItem( opsShowObj, fields );
670 fields <<
"ShowAsteroids" << i18n(
"Toggle display of Asteroids" ) << i18n(
"bool" );
671 new QTreeWidgetItem( opsShowObj, fields );
673 fields <<
"ShowComets" << i18n(
"Toggle display of Comets" ) << i18n(
"bool" );
674 new QTreeWidgetItem( opsShowObj, fields );
677 argChangeViewOption->OptionName->addItem(
"ShowStars" );
678 argChangeViewOption->OptionName->addItem(
"ShowDeepSky" );
679 argChangeViewOption->OptionName->addItem(
"ShowMessier" );
680 argChangeViewOption->OptionName->addItem(
"ShowMessierImages" );
681 argChangeViewOption->OptionName->addItem(
"ShowNGC" );
682 argChangeViewOption->OptionName->addItem(
"ShowIC" );
683 argChangeViewOption->OptionName->addItem(
"ShowSolarSystem" );
684 argChangeViewOption->OptionName->addItem(
"ShowSun" );
685 argChangeViewOption->OptionName->addItem(
"ShowMoon" );
686 argChangeViewOption->OptionName->addItem(
"ShowMercury" );
687 argChangeViewOption->OptionName->addItem(
"ShowVenus" );
688 argChangeViewOption->OptionName->addItem(
"ShowMars" );
689 argChangeViewOption->OptionName->addItem(
"ShowJupiter" );
690 argChangeViewOption->OptionName->addItem(
"ShowSaturn" );
691 argChangeViewOption->OptionName->addItem(
"ShowUranus" );
692 argChangeViewOption->OptionName->addItem(
"ShowNeptune" );
693 argChangeViewOption->OptionName->addItem(
"ShowPluto" );
694 argChangeViewOption->OptionName->addItem(
"ShowAsteroids" );
695 argChangeViewOption->OptionName->addItem(
"ShowComets" );
697 opsShowOther =
new QTreeWidgetItem( otv->optionsList(), QStringList(i18n(
"Show Other" )) );
698 fields <<
"ShowCLines" << i18n(
"Toggle display of constellation lines" ) << i18n(
"bool" );
699 new QTreeWidgetItem( opsShowOther, fields );
701 fields <<
"ShowCBounds" << i18n(
"Toggle display of constellation boundaries" ) << i18n(
"bool" );
702 new QTreeWidgetItem( opsShowOther, fields );
704 fields <<
"ShowCNames" << i18n(
"Toggle display of constellation names" ) << i18n(
"bool" );
705 new QTreeWidgetItem( opsShowOther, fields );
707 fields <<
"ShowMilkyWay" << i18n(
"Toggle display of Milky Way" ) << i18n(
"bool" );
708 new QTreeWidgetItem( opsShowOther, fields );
710 fields <<
"ShowGrid" << i18n(
"Toggle display of the coordinate grid" ) << i18n(
"bool" );
711 new QTreeWidgetItem( opsShowOther, fields );
713 fields <<
"ShowEquator" << i18n(
"Toggle display of the celestial equator" ) << i18n(
"bool" );
714 new QTreeWidgetItem( opsShowOther, fields );
716 fields <<
"ShowEcliptic" << i18n(
"Toggle display of the ecliptic" ) << i18n(
"bool" );
717 new QTreeWidgetItem( opsShowOther, fields );
719 fields <<
"ShowHorizon" << i18n(
"Toggle display of the horizon line" ) << i18n(
"bool" );
720 new QTreeWidgetItem( opsShowOther, fields );
722 fields <<
"ShowGround" << i18n(
"Toggle display of the opaque ground" ) << i18n(
"bool" );
723 new QTreeWidgetItem( opsShowOther, fields );
725 fields <<
"ShowStarNames" << i18n(
"Toggle display of star name labels" ) << i18n(
"bool" );
726 new QTreeWidgetItem( opsShowOther, fields );
728 fields <<
"ShowStarMagnitudes" << i18n(
"Toggle display of star magnitude labels" ) << i18n(
"bool" );
729 new QTreeWidgetItem( opsShowOther, fields );
731 fields <<
"ShowAsteroidNames" << i18n(
"Toggle display of asteroid name labels" ) << i18n(
"bool" );
732 new QTreeWidgetItem( opsShowOther, fields );
734 fields <<
"ShowCometNames" << i18n(
"Toggle display of comet name labels" ) << i18n(
"bool" );
735 new QTreeWidgetItem( opsShowOther, fields );
737 fields <<
"ShowPlanetNames" << i18n(
"Toggle display of planet name labels" ) << i18n(
"bool" );
738 new QTreeWidgetItem( opsShowOther, fields );
740 fields <<
"ShowPlanetImages" << i18n(
"Toggle display of planet images" ) << i18n(
"bool" );
741 new QTreeWidgetItem( opsShowOther, fields );
744 argChangeViewOption->OptionName->addItem(
"ShowCLines" );
745 argChangeViewOption->OptionName->addItem(
"ShowCBounds" );
746 argChangeViewOption->OptionName->addItem(
"ShowCNames" );
747 argChangeViewOption->OptionName->addItem(
"ShowMilkyWay" );
748 argChangeViewOption->OptionName->addItem(
"ShowGrid" );
749 argChangeViewOption->OptionName->addItem(
"ShowEquator" );
750 argChangeViewOption->OptionName->addItem(
"ShowEcliptic" );
751 argChangeViewOption->OptionName->addItem(
"ShowHorizon" );
752 argChangeViewOption->OptionName->addItem(
"ShowGround" );
753 argChangeViewOption->OptionName->addItem(
"ShowStarNames" );
754 argChangeViewOption->OptionName->addItem(
"ShowStarMagnitudes" );
755 argChangeViewOption->OptionName->addItem(
"ShowAsteroidNames" );
756 argChangeViewOption->OptionName->addItem(
"ShowCometNames" );
757 argChangeViewOption->OptionName->addItem(
"ShowPlanetNames" );
758 argChangeViewOption->OptionName->addItem(
"ShowPlanetImages" );
760 opsCName =
new QTreeWidgetItem( otv->optionsList(), QStringList(i18n(
"Constellation Names" )) );
761 fields <<
"UseLatinConstellNames" << i18n(
"Show Latin constellation names" ) << i18n(
"bool" );
762 new QTreeWidgetItem( opsCName, fields );
764 fields <<
"UseLocalConstellNames" <<i18n(
"Show constellation names in local language" ) << i18n(
"bool" );
765 new QTreeWidgetItem( opsCName, fields );
767 fields <<
"UseAbbrevConstellNames" <<i18n(
"Show IAU-standard constellation abbreviations" ) << i18n(
"bool" );
768 new QTreeWidgetItem( opsCName, fields );
771 argChangeViewOption->OptionName->addItem(
"UseLatinConstellNames" );
772 argChangeViewOption->OptionName->addItem(
"UseLocalConstellNames" );
773 argChangeViewOption->OptionName->addItem(
"UseAbbrevConstellNames" );
775 opsHide =
new QTreeWidgetItem( otv->optionsList(), QStringList(i18n(
"Hide Items" )) );
776 fields <<
"HideOnSlew" << i18n(
"Toggle whether objects hidden while slewing display" ) << i18n(
"bool" );
777 new QTreeWidgetItem( opsHide, fields );
779 fields <<
"SlewTimeScale" << i18n(
"Timestep threshold (in seconds) for hiding objects") << i18n(
"double" );
780 new QTreeWidgetItem( opsHide, fields );
782 fields <<
"HideStars" << i18n(
"Hide faint stars while slewing?" ) << i18n(
"bool" );
783 new QTreeWidgetItem( opsHide, fields );
785 fields <<
"HidePlanets" << i18n(
"Hide solar system bodies while slewing?" ) << i18n(
"bool" );
786 new QTreeWidgetItem( opsHide, fields );
788 fields <<
"HideMessier" << i18n(
"Hide Messier objects while slewing?" ) << i18n(
"bool" );
789 new QTreeWidgetItem( opsHide, fields );
791 fields <<
"HideNGC" << i18n(
"Hide NGC objects while slewing?" ) << i18n(
"bool" );
792 new QTreeWidgetItem( opsHide, fields );
794 fields <<
"HideIC" << i18n(
"Hide IC objects while slewing?" ) << i18n(
"bool" );
795 new QTreeWidgetItem( opsHide, fields );
797 fields <<
"HideMilkyWay" << i18n(
"Hide Milky Way while slewing?" ) << i18n(
"bool" );
798 new QTreeWidgetItem( opsHide, fields );
800 fields <<
"HideCNames" << i18n(
"Hide constellation names while slewing?" ) << i18n(
"bool" );
801 new QTreeWidgetItem( opsHide, fields );
803 fields <<
"HideCLines" << i18n(
"Hide constellation lines while slewing?" ) << i18n(
"bool" );
804 new QTreeWidgetItem( opsHide, fields );
806 fields <<
"HideCBounds" << i18n(
"Hide constellation boundaries while slewing?" ) << i18n(
"bool" );
807 new QTreeWidgetItem( opsHide, fields );
809 fields <<
"HideGrid" << i18n(
"Hide coordinate grid while slewing?" ) << i18n(
"bool" );
810 new QTreeWidgetItem( opsHide, fields );
813 argChangeViewOption->OptionName->addItem(
"HideOnSlew" );
814 argChangeViewOption->OptionName->addItem(
"SlewTimeScale" );
815 argChangeViewOption->OptionName->addItem(
"HideStars" );
816 argChangeViewOption->OptionName->addItem(
"HidePlanets" );
817 argChangeViewOption->OptionName->addItem(
"HideMessier" );
818 argChangeViewOption->OptionName->addItem(
"HideNGC" );
819 argChangeViewOption->OptionName->addItem(
"HideIC" );
820 argChangeViewOption->OptionName->addItem(
"HideMilkyWay" );
821 argChangeViewOption->OptionName->addItem(
"HideCNames" );
822 argChangeViewOption->OptionName->addItem(
"HideCLines" );
823 argChangeViewOption->OptionName->addItem(
"HideCBounds" );
824 argChangeViewOption->OptionName->addItem(
"HideGrid" );
826 opsSkymap =
new QTreeWidgetItem( otv->optionsList(), QStringList(i18n(
"Skymap Options" )) );
827 fields <<
"UseAltAz" << i18n(
"Use Horizontal coordinates? (otherwise, use Equatorial)") << i18n(
"bool" );
828 new QTreeWidgetItem( opsSkymap, fields );
830 fields <<
"ZoomFactor" << i18n(
"Set the Zoom Factor" ) << i18n(
"double" );
831 new QTreeWidgetItem( opsSkymap, fields );
833 fields <<
"FOVName" << i18n(
"Select angular size for the FOV symbol (in arcmin)") << i18n(
"double" );
834 new QTreeWidgetItem( opsSkymap, fields );
836 fields <<
"FOVShape" << i18n(
"Select shape for the FOV symbol (0=Square, 1=Circle, 2=Crosshairs, 4=Bullseye)" ) << i18n(
"int" );
837 new QTreeWidgetItem( opsSkymap, fields );
839 fields <<
"FOVColor" << i18n(
"Select color for the FOV symbol" ) << i18n(
"string" );
840 new QTreeWidgetItem( opsSkymap, fields );
842 fields <<
"UseAnimatedSlewing" << i18n(
"Use animated slewing? (otherwise, \"snap\" to new focus)" ) << i18n(
"bool" );
843 new QTreeWidgetItem( opsSkymap, fields );
845 fields <<
"UseRefraction" << i18n(
"Correct for atmospheric refraction?" ) << i18n(
"bool" );
846 new QTreeWidgetItem( opsSkymap, fields );
848 fields <<
"UseAutoLabel" << i18n(
"Automatically attach name label to centered object?" ) << i18n(
"bool" );
849 new QTreeWidgetItem( opsSkymap, fields );
851 fields <<
"UseHoverLabel" << i18n(
"Attach temporary name label when hovering mouse over an object?" ) << i18n(
"bool" );
852 new QTreeWidgetItem( opsSkymap, fields );
854 fields <<
"UseAutoTrail" << i18n(
"Automatically add trail to centered solar system body?" ) << i18n(
"bool" );
855 new QTreeWidgetItem( opsSkymap, fields );
857 fields <<
"FadePlanetTrails" << i18n(
"Planet trails fade to sky color? (otherwise color is constant)" ) << i18n(
"bool" );
858 new QTreeWidgetItem( opsSkymap, fields );
861 argChangeViewOption->OptionName->addItem(
"UseAltAz" );
862 argChangeViewOption->OptionName->addItem(
"ZoomFactor" );
863 argChangeViewOption->OptionName->addItem(
"FOVName" );
864 argChangeViewOption->OptionName->addItem(
"FOVSize" );
865 argChangeViewOption->OptionName->addItem(
"FOVShape" );
866 argChangeViewOption->OptionName->addItem(
"FOVColor" );
867 argChangeViewOption->OptionName->addItem(
"UseRefraction" );
868 argChangeViewOption->OptionName->addItem(
"UseAutoLabel" );
869 argChangeViewOption->OptionName->addItem(
"UseHoverLabel" );
870 argChangeViewOption->OptionName->addItem(
"UseAutoTrail" );
871 argChangeViewOption->OptionName->addItem(
"AnimateSlewing" );
872 argChangeViewOption->OptionName->addItem(
"FadePlanetTrails" );
875 opsLimit =
new QTreeWidgetItem( otv->optionsList(), QStringList(i18n(
"Limits" )) );
896 fields <<
"starLabelDensity" << i18n(
"magnitude of faintest star labeled on map" ) << i18n(
"double" );
897 new QTreeWidgetItem( opsLimit, fields );
899 fields <<
"magLimitHideStar" << i18n(
"magnitude of brightest star hidden while slewing" ) << i18n(
"double" );
900 new QTreeWidgetItem( opsLimit, fields );
902 fields <<
"magLimitAsteroid" << i18n(
"magnitude of faintest asteroid drawn on map" ) << i18n(
"double" );
903 new QTreeWidgetItem( opsLimit, fields );
906 fields <<
"asteroidLabelDensity" << i18n(
"magnitude of faintest asteroid labeled on map" ) << i18n(
"double" );
907 new QTreeWidgetItem( opsLimit, fields );
909 fields <<
"maxRadCometName" << i18n(
"comets nearer to the Sun than this (in AU) are labeled on map" ) << i18n(
"double" );
910 new QTreeWidgetItem( opsLimit, fields );
915 argChangeViewOption->OptionName->addItem(
"magLimitDrawDeepSky" );
916 argChangeViewOption->OptionName->addItem(
"magLimitDrawDeepSkyZoomOut" );
917 argChangeViewOption->OptionName->addItem(
"starLabelDensity" );
918 argChangeViewOption->OptionName->addItem(
"magLimitHideStar" );
919 argChangeViewOption->OptionName->addItem(
"magLimitAsteroid" );
920 argChangeViewOption->OptionName->addItem(
"asteroidLabelDensity" );
921 argChangeViewOption->OptionName->addItem(
"maxRadCometName" );
924 for (
unsigned int i=0; i < ks->data()->colorScheme()->numberOfColors(); ++i ) {
925 argSetColor->ColorName->addItem( ks->data()->colorScheme()->nameAt(i) );
929 argLoadColorScheme->SchemeList->addItem(
i18nc(
"use default color scheme",
"Default Colors" ) );
930 argLoadColorScheme->SchemeList->addItem(
i18nc(
"use 'star chart' color scheme",
"Star Chart" ) );
931 argLoadColorScheme->SchemeList->addItem(
i18nc(
"use 'night vision' color scheme",
"Night Vision" ) );
932 argLoadColorScheme->SchemeList->addItem(
i18nc(
"use 'moonless night' color scheme",
"Moonless Night" ) );
936 file.setFileName( KStandardDirs::locate(
"appdata",
"colors.dat" ) );
937 if ( file.open( QIODevice::ReadOnly ) ) {
940 while ( !stream.atEnd() ) {
941 line = stream.readLine();
942 argLoadColorScheme->SchemeList->addItem( line.left( line.indexOf(
':' ) ) );
951 if ( !UnsavedChanges ) {
953 sb->ScriptListBox->clear();
954 sb->ArgStack->setCurrentWidget( argBlank );
956 sb->CopyButton->setEnabled(
false );
957 sb->RemoveButton->setEnabled(
false );
958 sb->RunButton->setEnabled(
false );
959 sb->SaveAsButton->setEnabled(
false );
961 currentFileURL.clear();
962 currentScriptName.clear();
970 KTemporaryFile tmpfile;
973 if ( !UnsavedChanges ) {
974 currentFileURL = KFileDialog::getOpenUrl( currentDir,
"*.kstars|" +
i18nc(
"Filter by file type: KStars Scripts.",
"KStars Scripts (*.kstars)") );
976 if ( currentFileURL.isValid() ) {
977 currentDir = currentFileURL.directory();
980 sb->ScriptListBox->clear();
981 sb->ArgStack->setCurrentWidget( argBlank );
983 if ( currentFileURL.isLocalFile() ) {
984 fname = currentFileURL.toLocalFile();
986 fname = tmpfile.fileName();
987 if ( ! KIO::NetAccess::download( currentFileURL, fname, (
QWidget*) 0 ) )
988 KMessageBox::sorry( 0, i18n(
"Could not download remote file." ), i18n(
"Download Error" ) );
992 if ( !f.open( QIODevice::ReadOnly) ) {
993 QString message = i18n(
"Could not open file %1.", f.fileName() );
994 KMessageBox::sorry( 0, message, i18n(
"Could Not Open File" ) );
995 currentFileURL.clear();
1000 readScript( istream );
1003 }
else if ( ! currentFileURL.url().isEmpty() ) {
1004 QString message = i18n(
"Invalid URL: %1", currentFileURL.url() );
1005 KMessageBox::sorry( 0, message, i18n(
"Invalid URL" ) );
1006 currentFileURL.clear();
1014 KTemporaryFile tmpfile;
1017 if ( currentScriptName.isEmpty() ) {
1019 if ( snd->exec() == QDialog::Accepted ) {
1020 currentScriptName = snd->scriptName();
1021 currentAuthor = snd->authorName();
1027 bool newFilename =
false;
1028 if ( currentFileURL.isEmpty() ) {
1029 currentFileURL = KFileDialog::getSaveUrl( currentDir,
"*.kstars|" +
i18nc(
"Filter by file type: KStars Scripts.",
"KStars Scripts (*.kstars)") );
1033 if ( currentFileURL.isValid() ) {
1034 currentDir = currentFileURL.directory();
1036 if ( currentFileURL.isLocalFile() ) {
1037 fname = currentFileURL.toLocalFile();
1040 if (newFilename ==
true && QFile::exists(currentFileURL.path())) {
1041 int r=KMessageBox::warningContinueCancel(static_cast<QWidget *>(parent()),
1042 i18n(
"A file named \"%1\" already exists. "
1043 "Overwrite it?" , currentFileURL.fileName()),
1044 i18n(
"Overwrite File?" ),
1045 KStandardGuiItem::overwrite() );
1047 if(r==KMessageBox::Cancel)
return;
1050 fname = tmpfile.fileName();
1053 if ( fname.right( 7 ).toLower() !=
".kstars" ) fname +=
".kstars";
1056 if ( !f.open( QIODevice::WriteOnly) ) {
1057 QString message = i18n(
"Could not open file %1.", f.fileName() );
1058 KMessageBox::sorry( 0, message, i18n(
"Could Not Open File" ) );
1059 currentFileURL.clear();
1064 writeScript( ostream );
1068 chmod( fname.toAscii(), S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH );
1070 if ( tmpfile.fileName() == fname ) {
1071 if ( ! KIO::NetAccess::upload( tmpfile.fileName(), currentFileURL, (
QWidget*) 0 ) ) {
1072 QString message = i18n(
"Could not upload image to remote location: %1", currentFileURL.prettyUrl() );
1073 KMessageBox::sorry( 0, message, i18n(
"Could not upload file" ) );
1077 setUnsavedChanges(
false );
1080 QString message = i18n(
"Invalid URL: %1", currentFileURL.url() );
1081 KMessageBox::sorry( 0, message, i18n(
"Invalid URL" ) );
1082 currentFileURL.clear();
1087 currentFileURL.clear();
1088 currentScriptName.clear();
1093 if ( UnsavedChanges ) {
1094 QString caption = i18n(
"Save Changes to Script?" );
1095 QString message = i18n(
"The current script has unsaved changes. Would you like to save before closing it?" );
1096 int ans = KMessageBox::warningYesNoCancel( 0, message, caption, KStandardGuiItem::save(), KStandardGuiItem::discard() );
1097 if ( ans == KMessageBox::Yes ) {
1099 setUnsavedChanges(
false );
1100 }
else if ( ans == KMessageBox::No ) {
1101 setUnsavedChanges(
false );
1118 QString fname = KStandardDirs::locateLocal(
"tmp",
"kstars-tempscript" );
1121 if ( f.exists() ) f.remove();
1122 if ( !f.open( QIODevice::WriteOnly) ) {
1123 QString message = i18n(
"Could not open file %1.", f.fileName() );
1124 KMessageBox::sorry( 0, message, i18n(
"Could Not Open File" ) );
1125 currentFileURL.clear();
1130 writeScript( ostream );
1134 chmod( QFile::encodeName( f.fileName() ), S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH );
1140 if( !p.waitForStarted() )
1141 kDebug() <<
"Process did not start.";
1143 while ( !p.waitForFinished(10) ) {
1144 qApp->processEvents();
1145 if( p.state() != QProcess::Running )
1149 if ( f.exists() ) f.remove();
1161 QString dbus_call =
"dbus-send --dest=org.kde.kstars --print-reply ";
1162 QString main_method =
"/KStars org.kde.kstars.";
1163 QString clock_method =
"/KStars/SimClock org.kde.kstars.SimClock.";
1166 ostream <<
"#!/bin/bash" << endl;
1167 ostream <<
"#KStars DBus script: " << currentScriptName << endl;
1168 ostream <<
"#by " << currentAuthor << endl;
1170 ostream <<
"#" << endl;
1174 if (!sf->
valid())
continue;
1178 ostream << dbus_call << clock_method << sf->
scriptLine() << endl;
1181 ostream << dbus_call << main_method << sf->
scriptLine() << endl;
1186 if (sb->AppendINDIWait->isChecked() && !sf->
INDIProperty().isEmpty())
1193 else if (sf->
argVal(1) ==
"ABORT")
1199 if ( sf->
argVal(0).contains(
" "))
1200 ostream << mainpre <<
"waitForINDIAction " <<
"\"" << sf->
argVal(0) <<
"\" " << sf->
INDIProperty() << endl;
1202 ostream << mainpre <<
"waitForINDIAction " << sf->
argVal(0) <<
" " << sf->
INDIProperty() << endl;
1209 ostream <<
"##" << endl;
1215 QString service_name =
"org.kde.kstars.";
1218 while ( ! istream.atEnd() ) {
1219 line = istream.readLine();
1222 if ( line.contains(
"#KStars DBus script: " ) )
1223 currentScriptName = line.mid( 21 ).trimmed();
1226 if ( line.contains(
"#by " ) )
1227 currentAuthor = line.mid( 4 ).trimmed();
1230 if ( line.left(4) ==
"dbus" ) {
1233 if ( line.contains(
"SimClock" ) ) {
1234 service_name +=
"SimClock.";
1238 line = line.mid( line.lastIndexOf(service_name) + service_name.count() );
1241 fn_name = line.left(line.indexOf(
" "));
1243 line = line.mid(line.indexOf(
" ") + 1);
1249 if (fn_name != line)
1250 fn = line.split(
' ');
1252 if ( parseFunction( fn_name, fn ) )
1254 sb->ScriptListBox->addItem( ScriptList.last()->name() );
1256 ScriptList.last()->setValid(
true);
1258 else kWarning() << i18n(
"Could not parse script. Line was: %1", line ) ;
1264 if ( sb->ScriptListBox->count() ) {
1265 sb->ScriptListBox->setCurrentItem( 0 );
1275 bool foundQuote(
false), quoteProcessed(
false);
1277 QStringList::iterator it;
1279 for (it = fn.begin(); it != fn.end(); ++it)
1283 cur = cur.mid(cur.indexOf(
":") + 1).
remove(
'\'');
1287 if ( cur.startsWith(
'\"'))
1289 arg += cur.right(cur.length() - 1);
1292 quoteProcessed =
true;
1294 else if (cur.endsWith(
'\"'))
1296 arg += cur.left(cur.length() -1);
1300 else if (foundQuote)
1313 fn = arg.split(
'\'', QString::SkipEmptyParts );
1318 if ( fn_name == sf->
name() )
1321 if ( fn_name ==
"setGeoLocation" )
1323 QString city( fn[0] ), prov, cntry( fn[1] );
1325 if ( fn.count() == 4 ) { prov = fn[1]; cntry = fn[2]; }
1326 if ( fn.count() == 3 || fn.count() == 4 )
1329 ScriptList.last()->setArg( 0, city );
1330 ScriptList.last()->setArg( 1, prov );
1331 ScriptList.last()->setArg( 2, cntry );
1332 }
else return false;
1334 }
else if ( fn.count() != sf->
numArgs())
return false;
1338 for (
int i=0; i<sf->
numArgs(); ++i )
1339 ScriptList.last()->setArg( i, fn[i] );
1346 if ( fn_name == sf->
name() )
1349 if ( fn.count() != sf->
numArgs())
return false;
1353 for (
int i=0; i<sf->
numArgs(); ++i )
1354 ScriptList.last()->setArg( i, fn[i] );
1364 if ( fn[0] == sf->
name() )
1367 if ( fn.count() != sf->
numArgs() + 1 )
return false;
1371 for (
int i=0; i<sf->
numArgs(); ++i )
1372 ScriptList.last()->setArg( i, fn[i+1] );
1385 if ( checkForChanges ) {
1387 sb->SaveButton->setEnabled( b );
1392 if ( ! UnsavedChanges ) setUnsavedChanges(
true );
1394 int Pos = sb->ScriptListBox->currentRow() + 1;
1395 ScriptList.insert( Pos,
new ScriptFunction( ScriptList[ Pos-1 ] ) );
1397 for (
int i=0; i < ScriptList[ Pos-1 ]->numArgs(); ++i )
1398 ScriptList[Pos]->setArg(i, ScriptList[ Pos-1 ]->argVal(i) );
1400 sb->ScriptListBox->insertItem( Pos, ScriptList[Pos]->name());
1402 sb->ScriptListBox->setCurrentRow(Pos);
1407 setUnsavedChanges(
true );
1409 int Pos = sb->ScriptListBox->currentRow();
1410 ScriptList.removeAt( Pos );
1411 sb->ScriptListBox->takeItem( Pos );
1412 if ( sb->ScriptListBox->count() == 0 ) {
1413 sb->ArgStack->setCurrentWidget( argBlank );
1414 sb->CopyButton->setEnabled(
false );
1415 sb->RemoveButton->setEnabled(
false );
1416 sb->RunButton->setEnabled(
false );
1417 sb->SaveAsButton->setEnabled(
false );
1420 if ( Pos == sb->ScriptListBox->count() ) {
1423 sb->ScriptListBox->setCurrentRow(Pos);
1431 QTreeWidgetItem *currentItem = sb->FunctionTree->currentItem();
1433 if ( currentItem == NULL || currentItem->parent() == 0)
1436 foreach ( sc, KStarsFunctionList )
1437 if (sc->
prototype() == currentItem->text(0))
1443 foreach ( sc, SimClockFunctionList )
1444 if (sc->
prototype() == currentItem->text(0))
1453 foreach ( sc, INDIFunctionList )
1454 if (sc->
prototype() == currentItem->text(0))
1462 if (found == NULL)
return;
1464 setUnsavedChanges(
true );
1466 int Pos = sb->ScriptListBox->currentRow() + 1;
1469 sb->ScriptListBox->insertItem(Pos, ScriptList[Pos]->name());
1470 sb->ScriptListBox->setCurrentRow(Pos);
1475 if ( sb->ScriptListBox->currentRow() > 0 ) {
1476 setUnsavedChanges(
true );
1479 QString t = sb->ScriptListBox->currentItem()->text();
1480 unsigned int n = sb->ScriptListBox->currentRow();
1483 ScriptList.insert( n-1, tmp );
1485 sb->ScriptListBox->takeItem( n );
1486 sb->ScriptListBox->insertItem( n-1, t);
1487 sb->ScriptListBox->setCurrentRow(n-1);
1493 if ( sb->ScriptListBox->currentRow() > -1 &&
1494 sb->ScriptListBox->currentRow() < ((int) sb->ScriptListBox->count())-1 ) {
1495 setUnsavedChanges(
true );
1497 QString t = sb->ScriptListBox->currentItem()->text();
1498 unsigned int n = sb->ScriptListBox->currentRow();
1501 ScriptList.insert( n+1, tmp );
1503 sb->ScriptListBox->takeItem( n );
1504 sb->ScriptListBox->insertItem( n+1 , t);
1505 sb->ScriptListBox->setCurrentRow( n+1);
1512 if ( sb->ScriptListBox->currentRow() == -1 ) {
1513 sb->CopyButton->setEnabled(
false );
1514 sb->RemoveButton->setEnabled(
false );
1515 sb->UpButton->setEnabled(
false );
1516 sb->DownButton->setEnabled(
false );
1517 }
else if ( sb->ScriptListBox->count() == 1 ) {
1518 sb->CopyButton->setEnabled(
true );
1519 sb->RemoveButton->setEnabled(
true );
1520 sb->UpButton->setEnabled(
false );
1521 sb->DownButton->setEnabled(
false );
1522 }
else if ( sb->ScriptListBox->currentRow() == 0 ) {
1523 sb->CopyButton->setEnabled(
true );
1524 sb->RemoveButton->setEnabled(
true );
1525 sb->UpButton->setEnabled(
false );
1526 sb->DownButton->setEnabled(
true );
1527 }
else if ( sb->ScriptListBox->currentRow() == ((int) sb->ScriptListBox->count())-1 ) {
1528 sb->CopyButton->setEnabled(
true );
1529 sb->RemoveButton->setEnabled(
true );
1530 sb->UpButton->setEnabled(
true );
1531 sb->DownButton->setEnabled(
false );
1533 sb->CopyButton->setEnabled(
true );
1534 sb->RemoveButton->setEnabled(
true );
1535 sb->UpButton->setEnabled(
true );
1536 sb->DownButton->setEnabled(
true );
1540 if ( sb->ScriptListBox->count() ) {
1541 sb->RunButton->setEnabled(
true );
1542 sb->SaveAsButton->setEnabled(
true );
1544 sb->RunButton->setEnabled(
false );
1545 sb->SaveAsButton->setEnabled(
false );
1546 setUnsavedChanges(
false );
1550 if ( sb->ScriptListBox->currentRow() > -1 &&
1551 sb->ScriptListBox->currentRow() < ((int) sb->ScriptListBox->count()) ) {
1552 QString t = sb->ScriptListBox->currentItem()->text();
1553 unsigned int n = sb->ScriptListBox->currentRow();
1556 checkForChanges =
false;
1558 if ( sf->
name() ==
"lookTowards" ) {
1559 sb->ArgStack->setCurrentWidget( argLookToward );
1560 QString s = sf->
argVal(0);
1561 argLookToward->FocusEdit->setEditText( s );
1563 }
else if ( sf->
name() ==
"addLabel" || sf->
name() ==
"removeLabel" || sf->
name() ==
"addTrail" || sf->
name() ==
"removeTrail" ) {
1564 sb->ArgStack->setCurrentWidget( argFindObject );
1565 QString s = sf->
argVal(0);
1566 argFindObject->NameEdit->setText( s );
1568 }
else if ( sf->
name() ==
"setRaDec" ) {
1570 double r(0.0),
d(0.0);
1573 sb->ArgStack->setCurrentWidget( argSetRaDec );
1575 ok = !sf->
argVal(0).isEmpty();
1576 if (ok) r = sf->
argVal(0).toDouble(&ok);
1577 else argSetRaDec->RABox->clear();
1578 if (ok) { ra.setH(r); argSetRaDec->RABox->showInHours( ra ); }
1580 ok = !sf->
argVal(1).isEmpty();
1581 if (ok) d = sf->
argVal(1).toDouble(&ok);
1582 else argSetRaDec->DecBox->clear();
1583 if (ok) argSetRaDec->DecBox->showInDegrees(
dms(d) );
1585 }
else if ( sf->
name() ==
"setAltAz" ) {
1587 double x(0.0),y(0.0);
1589 sb->ArgStack->setCurrentWidget( argSetAltAz );
1591 ok = !sf->
argVal(0).isEmpty();
1592 if (ok) y = sf->
argVal(0).toDouble(&ok);
1593 else argSetAltAz->AzBox->clear();
1594 if (ok) argSetAltAz->AltBox->showInDegrees(
dms(y) );
1595 else argSetAltAz->AltBox->clear();
1597 ok = !sf->
argVal(1).isEmpty();
1598 x = sf->
argVal(1).toDouble(&ok);
1599 if (ok) argSetAltAz->AzBox->showInDegrees(
dms(x) );
1601 }
else if ( sf->
name() ==
"zoomIn" ) {
1602 sb->ArgStack->setCurrentWidget( argBlank );
1605 }
else if ( sf->
name() ==
"zoomOut" ) {
1606 sb->ArgStack->setCurrentWidget( argBlank );
1609 }
else if ( sf->
name() ==
"defaultZoom" ) {
1610 sb->ArgStack->setCurrentWidget( argBlank );
1613 }
else if ( sf->
name() ==
"zoom" ) {
1614 sb->ArgStack->setCurrentWidget( argZoom );
1616 sf->
argVal(0).toDouble(&ok);
1617 if (ok) argZoom->ZoomBox->setText( sf->
argVal(0) );
1618 else argZoom->ZoomBox->setText(
"2000." );
1620 }
else if ( sf->
name() ==
"exportImage" ) {
1621 sb->ArgStack->setCurrentWidget( argExportImage );
1622 argExportImage->ExportFileName->setUrl( sf->
argVal(0) );
1625 w = sf->
argVal(1).toInt( &ok );
1626 if (ok) h = sf->
argVal(2).toInt( &ok );
1628 argExportImage->ExportWidth->setValue( w );
1629 argExportImage->ExportHeight->setValue( h );
1631 argExportImage->ExportWidth->setValue( ks->map()->width() );
1632 argExportImage->ExportHeight->setValue( ks->map()->height() );
1635 }
else if ( sf->
name() ==
"printImage" ) {
1636 if ( sf->
argVal(0) == i18n(
"true" ) ) argPrintImage->UsePrintDialog->setChecked(
true );
1637 else argPrintImage->UsePrintDialog->setChecked(
false );
1638 if ( sf->
argVal(1) == i18n(
"true" ) ) argPrintImage->UseChartColors->setChecked(
true );
1639 else argPrintImage->UseChartColors->setChecked(
false );
1641 }
else if ( sf->
name() ==
"setLocalTime" ) {
1642 sb->ArgStack->setCurrentWidget( argSetLocalTime );
1644 int year=0, month=0, day=0, hour=0, min=0, sec=0;
1646 year = sf->
argVal(0).toInt(&ok);
1647 if (ok) month = sf->
argVal(1).toInt(&ok);
1648 if (ok) day = sf->
argVal(2).toInt(&ok);
1649 if (ok) argSetLocalTime->DateWidget->setDate( QDate( year, month, day ) );
1650 else argSetLocalTime->DateWidget->setDate( QDate::currentDate() );
1652 hour = sf->
argVal(3).toInt(&ok);
1653 if ( sf->
argVal(3).isEmpty() ) ok =
false;
1654 if (ok) min = sf->
argVal(4).toInt(&ok);
1655 if (ok) sec = sf->
argVal(5).toInt(&ok);
1656 if (ok) argSetLocalTime->TimeBox->setTime( QTime( hour, min, sec ) );
1657 else argSetLocalTime->TimeBox->setTime( QTime( QTime::currentTime() ) );
1659 }
else if ( sf->
name() ==
"waitFor" ) {
1660 sb->ArgStack->setCurrentWidget( argWaitFor );
1662 int sec = sf->
argVal(0).toInt(&ok);
1663 if (ok) argWaitFor->DelayBox->setValue( sec );
1664 else argWaitFor->DelayBox->setValue( 0 );
1666 }
else if ( sf->
name() ==
"waitForKey" ) {
1667 sb->ArgStack->setCurrentWidget( argWaitForKey );
1668 if ( sf->
argVal(0).length()==1 || sf->
argVal(0).toLower() ==
"space" )
1669 argWaitForKey->WaitKeyEdit->setText( sf->
argVal(0) );
1670 else argWaitForKey->WaitKeyEdit->setText( QString() );
1672 }
else if ( sf->
name() ==
"setTracking" ) {
1673 sb->ArgStack->setCurrentWidget( argSetTracking );
1674 if ( sf->
argVal(0) == i18n(
"true" ) ) argSetTracking->CheckTrack->setChecked(
true );
1675 else argSetTracking->CheckTrack->setChecked(
false );
1677 }
else if ( sf->
name() ==
"changeViewOption" ) {
1678 sb->ArgStack->setCurrentWidget( argChangeViewOption );
1679 argChangeViewOption->OptionName->setCurrentIndex(
1680 argChangeViewOption->OptionName->findText( sf->
argVal(0) ) );
1681 argChangeViewOption->OptionValue->setText( sf->
argVal(1) );
1683 }
else if ( sf->
name() ==
"setGeoLocation" ) {
1684 sb->ArgStack->setCurrentWidget( argSetGeoLocation );
1685 argSetGeoLocation->CityName->setText( sf->
argVal(0) );
1686 argSetGeoLocation->ProvinceName->setText( sf->
argVal(1) );
1687 argSetGeoLocation->CountryName->setText( sf->
argVal(2) );
1689 }
else if ( sf->
name() ==
"setColor" ) {
1690 sb->ArgStack->setCurrentWidget( argSetColor );
1691 if ( sf->
argVal(0).isEmpty() ) sf->
setArg( 0,
"SkyColor" );
1692 argSetColor->ColorName->setCurrentIndex(
1693 argSetColor->ColorName->findText(
1694 ks->data()->colorScheme()->nameFromKey( sf->
argVal(0) ) )
1696 argSetColor->ColorValue->setColor( QColor( sf->
argVal(1).remove(
'\\') ) );
1698 }
else if ( sf->
name() ==
"loadColorScheme" ) {
1699 sb->ArgStack->setCurrentWidget( argLoadColorScheme );
1700 argLoadColorScheme->SchemeList->setCurrentItem( argLoadColorScheme->SchemeList->findItems( sf->
argVal(0).remove(
'\"'), Qt::MatchExactly ).at(0) );
1702 }
else if ( sf->
name() ==
"stop" ) {
1703 sb->ArgStack->setCurrentWidget( argBlank );
1706 }
else if ( sf->
name() ==
"start" ) {
1707 sb->ArgStack->setCurrentWidget( argBlank );
1710 }
else if ( sf->
name() ==
"setClockScale" ) {
1711 sb->ArgStack->setCurrentWidget( argTimeScale );
1713 double ts = sf->
argVal(0).toDouble(&ok);
1714 if (ok) argTimeScale->TimeScale->tsbox()->changeScale(
float(ts) );
1715 else argTimeScale->TimeScale->tsbox()->changeScale( 0.0 );
1721 else if (sf->
name() ==
"startINDI") {
1722 sb->ArgStack->setCurrentWidget( argStartINDI);
1724 argStartINDI->deviceName->setText(sf->
argVal(0));
1725 if (sf->
argVal(1) ==
"true")
1726 argStartINDI->LocalButton->setChecked(
true);
1727 else if (! sf->
argVal(1).isEmpty())
1728 argStartINDI->LocalButton->setChecked(
false);
1730 else if (sf->
name() ==
"setINDIDevice")
1732 sb->ArgStack->setCurrentWidget( argSetDeviceINDI);
1733 argSetDeviceINDI->deviceName->setText(sf->
argVal(0));
1735 else if (sf->
name() ==
"shutdownINDI") {
1736 sb->ArgStack->setCurrentWidget( argShutdownINDI);
1738 else if (sf->
name() ==
"switchINDI") {
1739 sb->ArgStack->setCurrentWidget( argSwitchINDI);
1741 if (sf->
argVal(0) ==
"true" || sf->
argVal(0).isEmpty())
1742 argSwitchINDI->OnButton->setChecked(
true);
1744 argSwitchINDI->OffButton->setChecked(
true);
1746 else if (sf->
name() ==
"setINDIPort") {
1747 sb->ArgStack->setCurrentWidget( argSetPortINDI);
1749 argSetPortINDI->devicePort->setText(sf->
argVal(0));
1753 else if (sf->
name() ==
"setINDITargetCoord") {
1755 double r(0.0),
d(0.0);
1758 sb->ArgStack->setCurrentWidget( argSetTargetCoordINDI);
1760 ok = !sf->
argVal(0).isEmpty();
1761 if (ok) r = sf->
argVal(0).toDouble(&ok);
1762 else argSetTargetCoordINDI->RABox->clear();
1763 if (ok) { ra.setH(r); argSetTargetCoordINDI->RABox->showInHours( ra ); }
1765 ok = !sf->
argVal(1).isEmpty();
1766 if (ok) d = sf->
argVal(1).toDouble(&ok);
1767 else argSetTargetCoordINDI->DecBox->clear();
1768 if (ok) argSetTargetCoordINDI->DecBox->showInDegrees(
dms(d) );
1772 else if (sf->
name() ==
"setINDITargetName") {
1773 sb->ArgStack->setCurrentWidget( argSetTargetNameINDI);
1775 argSetTargetNameINDI->targetName->setText(sf->
argVal(0));
1779 else if (sf->
name() ==
"setINDIAction") {
1780 sb->ArgStack->setCurrentWidget( argSetActionINDI);
1782 argSetActionINDI->actionName->setText(sf->
argVal(0));
1786 else if (sf->
name() ==
"waitForINDIAction") {
1787 sb->ArgStack->setCurrentWidget( argWaitForActionINDI);
1789 argWaitForActionINDI->actionName->setText(sf->
argVal(0));
1793 else if (sf->
name() ==
"setINDIFocusSpeed") {
1797 sb->ArgStack->setCurrentWidget( argSetFocusSpeedINDI);
1799 t = sf->
argVal(0).toInt(&ok);
1800 if (ok) argSetFocusSpeedINDI->speedIN->setValue(t);
1801 else argSetFocusSpeedINDI->speedIN->setValue(0);
1805 else if (sf->
name() ==
"startINDIFocus") {
1806 sb->ArgStack->setCurrentWidget( argStartFocusINDI);
1807 bool itemSet(
false);
1809 for (
int i=0; i < argStartFocusINDI->directionCombo->count(); i++)
1811 if (argStartFocusINDI->directionCombo->itemText(i) == sf->
argVal(0))
1813 argStartFocusINDI->directionCombo->setCurrentIndex(i);
1819 if (!itemSet) argStartFocusINDI->directionCombo->setCurrentIndex(0);
1823 else if (sf->
name() ==
"setINDIFocusTimeout") {
1827 sb->ArgStack->setCurrentWidget( argSetFocusTimeoutINDI);
1829 t = sf->
argVal(0).toInt(&ok);
1830 if (ok) argSetFocusTimeoutINDI->timeOut->setValue(t);
1831 else argSetFocusTimeoutINDI->timeOut->setValue(0);
1835 else if (sf->
name() ==
"setINDIGeoLocation") {
1837 double lo(0.0),la(0.0);
1839 sb->ArgStack->setCurrentWidget( argSetGeoLocationINDI);
1841 ok = !sf->
argVal(0).isEmpty();
1842 if (ok) lo = sf->
argVal(0).toDouble(&ok);
1843 else argSetGeoLocationINDI->longBox->clear();
1844 if (ok) { argSetGeoLocationINDI->longBox->showInDegrees(
dms(lo) ); }
1846 ok = !sf->
argVal(1).isEmpty();
1847 if (ok) la = sf->
argVal(1).toDouble(&ok);
1848 else argSetGeoLocationINDI->latBox->clear();
1849 if (ok) argSetGeoLocationINDI->latBox->showInDegrees(
dms(la) );
1852 else if (sf->
name() ==
"startINDIExposure") {
1856 sb->ArgStack->setCurrentWidget( argStartExposureINDI);
1858 t = sf->
argVal(0).toInt(&ok);
1859 if (ok) argStartExposureINDI->timeOut->setValue(t);
1860 else argStartExposureINDI->timeOut->setValue(0);
1863 else if (sf->
name() ==
"setINDIUTC") {
1864 sb->ArgStack->setCurrentWidget( argSetUTCINDI);
1866 argSetUTCINDI->UTC->setText(sf->
argVal(0));
1869 else if (sf->
name() ==
"setINDIScopeAction") {
1870 sb->ArgStack->setCurrentWidget( argSetScopeActionINDI);
1871 bool itemSet(
false);
1873 for (
int i=0; i < argSetScopeActionINDI->actionCombo->count(); i++)
1875 if (argSetScopeActionINDI->actionCombo->itemText(i) == sf->
argVal(0))
1877 argSetScopeActionINDI->actionCombo->setCurrentIndex(i);
1883 if (!itemSet) argSetScopeActionINDI->actionCombo->setCurrentIndex(0);
1886 else if (sf->
name() ==
"setINDIFrameType") {
1887 sb->ArgStack->setCurrentWidget( argSetFrameTypeINDI);
1888 bool itemSet(
false);
1890 for (
int i=0; i < argSetFrameTypeINDI->typeCombo->count(); i++)
1892 if (argSetFrameTypeINDI->typeCombo->itemText(i) == sf->
argVal(0))
1894 argSetFrameTypeINDI->typeCombo->setCurrentIndex(i);
1900 if (!itemSet) argSetFrameTypeINDI->typeCombo->setCurrentIndex(0);
1903 else if (sf->
name() ==
"setINDICCDTemp") {
1907 sb->ArgStack->setCurrentWidget( argSetCCDTempINDI);
1909 t = sf->
argVal(0).toInt(&ok);
1910 if (ok) argSetCCDTempINDI->temp->setValue(t);
1911 else argSetCCDTempINDI->temp->setValue(0);
1914 else if (sf->
name() ==
"setINDIFilterNum") {
1918 sb->ArgStack->setCurrentWidget( argSetFilterNumINDI);
1920 t = sf->
argVal(0).toInt(&ok);
1921 if (ok) argSetFilterNumINDI->filter_num->setValue(t);
1922 else argSetFilterNumINDI->filter_num->setValue(0);
1927 checkForChanges =
true;
1933 QTreeWidgetItem *currentItem = sb->FunctionTree->currentItem();
1935 if ( currentItem == NULL || currentItem->parent() == 0)
1938 foreach ( sc, KStarsFunctionList )
1939 if (sc->
prototype() == currentItem->text(0))
1945 foreach ( sc, SimClockFunctionList )
1946 if (sc->
prototype() == currentItem->text(0))
1955 foreach (sc, INDIFunctionList )
1956 if (sc->
prototype() == currentItem->text(0))
1966 sb->AddButton->setEnabled(
false );
1967 kWarning() << i18n(
"Function index out of bounds." ) ;
1971 sb->AddButton->setEnabled(
true );
1972 sb->FuncDoc->setHtml( found->description() );
1979 if ( ld->exec() == QDialog::Accepted ) {
1980 if ( ld->selectedCity() ) {
1982 argSetGeoLocation->CityName->setText( ld->selectedCityName() );
1983 if ( ! ld->selectedProvinceName().isEmpty() ) {
1984 argSetGeoLocation->ProvinceName->setText( ld->selectedProvinceName() );
1986 argSetGeoLocation->ProvinceName->clear();
1988 argSetGeoLocation->CountryName->setText( ld->selectedCountryName() );
1990 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
1991 if ( sf->
name() ==
"setGeoLocation" ) {
1992 setUnsavedChanges(
true );
1994 sf->
setArg( 0, ld->selectedCityName() );
1995 sf->
setArg( 1, ld->selectedProvinceName() );
1996 sf->
setArg( 2, ld->selectedCountryName() );
1998 warningMismatch(
"setGeoLocation" );
2006 QPointer<FindDialog> fd =
new FindDialog( ks );
2008 if ( fd->exec() == QDialog::Accepted && fd->selectedObject() ) {
2009 setUnsavedChanges(
true );
2011 argLookToward->FocusEdit->setEditText( fd->selectedObject()->name() );
2019 void ScriptBuilder::slotINDIFindObject() {
2020 FindDialog fd( ks );
2022 if ( fd.exec() == QDialog::Accepted && fd.selectedObject() ) {
2023 setUnsavedChanges(
true );
2025 argSetTargetNameINDI->targetName->setText( fd.selectedObject()->name() );
2029 void ScriptBuilder::slotINDIWaitCheck(
bool )
2032 setUnsavedChanges(
true);
2039 if ( otv->exec() == QDialog::Accepted ) {
2040 argChangeViewOption->OptionName->setCurrentIndex(
2041 argChangeViewOption->OptionName->findText(
2042 otv->optionsList()->currentItem()->text(0) )
2048 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2050 if ( sf->
name() ==
"lookTowards" ) {
2051 setUnsavedChanges(
true );
2053 sf->
setArg( 0, argLookToward->FocusEdit->currentText() );
2056 warningMismatch(
"lookTowards" );
2061 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2063 if ( sf->
name() ==
"addLabel" || sf->
name() ==
"removeLabel" || sf->
name() ==
"addTrail" || sf->
name() ==
"removeTrail" ) {
2064 setUnsavedChanges(
true );
2066 sf->
setArg( 0, argFindObject->NameEdit->text() );
2069 warningMismatch( sf->
name() );
2074 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2076 if ( sf->
name() ==
"setRaDec" ) {
2078 if ( argSetRaDec->RABox->text().isEmpty() )
return;
2081 dms ra = argSetRaDec->RABox->createDms(
false, &ok);
2083 setUnsavedChanges(
true );
2085 sf->
setArg( 0, QString(
"%1" ).arg( ra.
Hours() ) );
2089 sf->
setArg( 0, QString() );
2093 warningMismatch(
"setRaDec" );
2098 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2100 if ( sf->
name() ==
"setRaDec" ) {
2102 if ( argSetRaDec->DecBox->text().isEmpty() )
return;
2105 dms dec = argSetRaDec->DecBox->createDms(
true, &ok);
2107 setUnsavedChanges(
true );
2113 sf->
setArg( 1, QString() );
2117 warningMismatch(
"setRaDec" );
2122 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2124 if ( sf->
name() ==
"setAltAz" ) {
2126 if ( argSetAltAz->AzBox->text().isEmpty() )
return;
2129 dms az = argSetAltAz->AzBox->createDms(
true, &ok);
2131 setUnsavedChanges(
true );
2135 sf->
setArg( 1, QString() );
2139 warningMismatch(
"setAltAz" );
2144 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2146 if ( sf->
name() ==
"setAltAz" ) {
2148 if ( argSetAltAz->AltBox->text().isEmpty() )
return;
2151 dms alt = argSetAltAz->AltBox->createDms(
true, &ok);
2153 setUnsavedChanges(
true );
2158 sf->
setArg( 0, QString() );
2162 warningMismatch(
"setAltAz" );
2167 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2169 if ( sf->
name() ==
"setLocalTime" ) {
2170 setUnsavedChanges(
true );
2172 QDate date = argSetLocalTime->DateWidget->date();
2174 sf->
setArg( 0, QString(
"%1" ).arg( date.year() ) );
2175 sf->
setArg( 1, QString(
"%1" ).arg( date.month() ) );
2176 sf->
setArg( 2, QString(
"%1" ).arg( date.day() ) );
2179 warningMismatch(
"setLocalTime" );
2184 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2186 if ( sf->
name() ==
"setLocalTime" ) {
2187 setUnsavedChanges(
true );
2189 QTime time = argSetLocalTime->TimeBox->time();
2191 sf->
setArg( 3, QString(
"%1" ).arg( time.hour() ) );
2192 sf->
setArg( 4, QString(
"%1" ).arg( time.minute() ) );
2193 sf->
setArg( 5, QString(
"%1" ).arg( time.second() ) );
2196 warningMismatch(
"setLocalTime" );
2201 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2203 if ( sf->
name() ==
"waitFor" ) {
2205 int delay = argWaitFor->DelayBox->text().toInt( &ok );
2208 setUnsavedChanges(
true );
2210 sf->
setArg( 0, QString(
"%1" ).arg( delay ) );
2216 warningMismatch(
"waitFor" );
2221 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2223 if ( sf->
name() ==
"waitForKey" ) {
2224 QString sKey = argWaitForKey->WaitKeyEdit->text().trimmed();
2228 if ( sKey.length() == 1 || sKey ==
"space" ) {
2229 setUnsavedChanges(
true );
2237 warningMismatch(
"waitForKey" );
2242 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2244 if ( sf->
name() ==
"setTracking" ) {
2245 setUnsavedChanges(
true );
2247 sf->
setArg( 0, ( argSetTracking->CheckTrack->isChecked() ? i18n(
"true" ) : i18n(
"false" ) ) );
2250 warningMismatch(
"setTracking" );
2255 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2257 if ( sf->
name() ==
"changeViewOption" ) {
2258 if ( argChangeViewOption->OptionName->currentIndex() >= 0
2259 && argChangeViewOption->OptionValue->text().length() ) {
2260 setUnsavedChanges(
true );
2262 sf->
setArg( 0, argChangeViewOption->OptionName->currentText() );
2263 sf->
setArg( 1, argChangeViewOption->OptionValue->text() );
2269 warningMismatch(
"changeViewOption" );
2274 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2276 if ( sf->
name() ==
"setGeoLocation" ) {
2277 QString city = argSetGeoLocation->CityName->text();
2279 if ( city.length() ) {
2280 setUnsavedChanges(
true );
2285 sf->
setArg( 0, QString() );
2289 warningMismatch(
"setGeoLocation" );
2294 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2296 if ( sf->
name() ==
"setGeoLocation" ) {
2297 QString province = argSetGeoLocation->ProvinceName->text();
2299 if ( province.length() ) {
2300 setUnsavedChanges(
true );
2302 sf->
setArg( 1, province );
2305 sf->
setArg( 1, QString() );
2309 warningMismatch(
"setGeoLocation" );
2314 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2316 if ( sf->
name() ==
"setGeoLocation" ) {
2317 QString country = argSetGeoLocation->CountryName->text();
2319 if ( country.length() ) {
2320 setUnsavedChanges(
true );
2322 sf->
setArg( 2, country );
2325 sf->
setArg( 2, QString() );
2329 warningMismatch(
"setGeoLocation" );
2334 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2336 if ( sf->
name() ==
"setClockScale" ) {
2337 setUnsavedChanges(
true );
2339 sf->
setArg( 0, QString(
"%1" ).arg( argTimeScale->TimeScale->tsbox()->timeScale() ) );
2342 warningMismatch(
"setClockScale" );
2347 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2349 if ( sf->
name() ==
"zoom" ) {
2350 setUnsavedChanges(
true );
2353 argZoom->ZoomBox->text().toDouble(&ok);
2355 sf->
setArg( 0, argZoom->ZoomBox->text() );
2359 warningMismatch(
"zoom" );
2364 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2366 if ( sf->
name() ==
"exportImage" ) {
2367 setUnsavedChanges(
true );
2369 sf->
setArg( 0, argExportImage->ExportFileName->url().url() );
2370 sf->
setArg( 1, QString(
"%1").arg( argExportImage->ExportWidth->value() ) );
2371 sf->
setArg( 2, QString(
"%1").arg( argExportImage->ExportHeight->value() ) );
2374 warningMismatch(
"exportImage" );
2379 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2381 if ( sf->
name() ==
"printImage" ) {
2382 setUnsavedChanges(
true );
2384 sf->
setArg( 0, ( argPrintImage->UsePrintDialog->isChecked() ? i18n(
"true" ) : i18n(
"false" ) ) );
2385 sf->
setArg( 1, ( argPrintImage->UseChartColors->isChecked() ? i18n(
"true" ) : i18n(
"false" ) ) );
2388 warningMismatch(
"exportImage" );
2393 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2395 if ( sf->
name() ==
"setColor" ) {
2396 setUnsavedChanges(
true );
2398 argSetColor->ColorValue->setColor( ks->data()->colorScheme()->colorAt( argSetColor->ColorName->currentIndex() ) );
2399 sf->
setArg( 0, ks->data()->colorScheme()->keyAt( argSetColor->ColorName->currentIndex() ) );
2400 QString cname( argSetColor->ColorValue->color().name() );
2405 warningMismatch(
"setColor" );
2410 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2412 if ( sf->
name() ==
"setColor" ) {
2413 setUnsavedChanges(
true );
2415 sf->
setArg( 0, ks->data()->colorScheme()->keyAt( argSetColor->ColorName->currentIndex() ) );
2416 QString cname( argSetColor->ColorValue->color().name() );
2421 warningMismatch(
"setColor" );
2426 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2428 if ( sf->
name() ==
"loadColorScheme" ) {
2429 setUnsavedChanges(
true );
2431 sf->
setArg( 0,
'\"' + argLoadColorScheme->SchemeList->currentItem()->text() +
'\"' );
2434 warningMismatch(
"loadColorScheme" );
2442 if ( !UnsavedChanges ) {
2444 sb->ScriptListBox->clear();
2445 sb->ArgStack->setCurrentWidget( argBlank );
2453 void ScriptBuilder::slotINDIStartDeviceName()
2455 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2457 if ( sf->
name() ==
"startINDI" )
2459 setUnsavedChanges(
true );
2461 sf->
setArg(0, argStartINDI->deviceName->text());
2462 sf->
setArg(1, argStartINDI->LocalButton->isChecked() ?
"true" :
"false");
2467 warningMismatch(
"startINDI" );
2472 void ScriptBuilder::slotINDIStartDeviceMode()
2475 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2477 if ( sf->
name() ==
"startINDI" )
2479 setUnsavedChanges(
true );
2481 sf->
setArg(1, argStartINDI->LocalButton->isChecked() ?
"true" :
"false");
2486 warningMismatch(
"startINDI" );
2491 void ScriptBuilder::slotINDISetDevice()
2494 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2496 if ( sf->
name() ==
"setINDIDevice" )
2498 setUnsavedChanges(
true );
2500 sf->
setArg(0, argSetDeviceINDI->deviceName->text());
2505 warningMismatch(
"startINDI" );
2509 void ScriptBuilder::slotINDIShutdown()
2512 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2514 if ( sf->
name() ==
"shutdownINDI" )
2516 if (argShutdownINDI->deviceName->text().isEmpty())
2522 if (sf->
argVal(0) != argShutdownINDI->deviceName->text())
2523 setUnsavedChanges(
true );
2525 sf->
setArg(0, argShutdownINDI->deviceName->text());
2530 warningMismatch(
"shutdownINDI" );
2535 void ScriptBuilder::slotINDISwitchDeviceConnection()
2538 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2540 if ( sf->
name() ==
"switchINDI" )
2543 if (sf->
argVal(0) != (argSwitchINDI->OnButton->isChecked() ?
"true" :
"false"))
2544 setUnsavedChanges(
true );
2546 sf->
setArg(0, argSwitchINDI->OnButton->isChecked() ?
"true" :
"false");
2551 warningMismatch(
"switchINDI" );
2556 void ScriptBuilder::slotINDISetPortDevicePort()
2558 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2560 if ( sf->
name() ==
"setINDIPort" )
2563 if (argSetPortINDI->devicePort->text().isEmpty())
2569 if (sf->
argVal(0) != argSetPortINDI->devicePort->text())
2570 setUnsavedChanges(
true );
2572 sf->
setArg(0, argSetPortINDI->devicePort->text());
2577 warningMismatch(
"setINDIPort" );
2582 void ScriptBuilder::slotINDISetTargetCoordDeviceRA()
2584 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2586 if ( sf->
name() ==
"setINDITargetCoord" ) {
2588 if ( argSetTargetCoordINDI->RABox->text().isEmpty() )
2595 dms ra = argSetTargetCoordINDI->RABox->createDms(
false, &ok);
2599 if (sf->
argVal(0) != QString(
"%1" ).arg( ra.
Hours() ))
2600 setUnsavedChanges(
true );
2602 sf->
setArg( 0, QString(
"%1" ).arg( ra.
Hours() ) );
2603 if ( ( ! sf->
argVal(1).isEmpty() ))
2610 sf->
setArg( 0, QString() );
2614 warningMismatch(
"setINDITargetCoord" );
2619 void ScriptBuilder::slotINDISetTargetCoordDeviceDEC()
2621 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2623 if ( sf->
name() ==
"setINDITargetCoord" ) {
2625 if ( argSetTargetCoordINDI->DecBox->text().isEmpty() )
2632 dms dec = argSetTargetCoordINDI->DecBox->createDms(
true, &ok);
2637 setUnsavedChanges(
true );
2640 if ( ( ! sf->
argVal(0).isEmpty() ))
2647 sf->
setArg( 1, QString() );
2651 warningMismatch(
"setINDITargetCoord" );
2656 void ScriptBuilder::slotINDISetTargetNameTargetName()
2659 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2661 if ( sf->
name() ==
"setINDITargetName" )
2663 if (argSetTargetNameINDI->targetName->text().isEmpty())
2669 if (sf->
argVal(0) != argSetTargetNameINDI->targetName->text())
2670 setUnsavedChanges(
true );
2672 sf->
setArg(0, argSetTargetNameINDI->targetName->text());
2677 warningMismatch(
"setINDITargetName" );
2682 void ScriptBuilder::slotINDISetActionName()
2684 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2686 if ( sf->
name() ==
"setINDIAction" )
2688 if (argSetActionINDI->actionName->text().isEmpty())
2694 if (sf->
argVal(0) != argSetActionINDI->actionName->text())
2695 setUnsavedChanges(
true );
2697 sf->
setArg(0, argSetActionINDI->actionName->text());
2702 warningMismatch(
"setINDIAction" );
2707 void ScriptBuilder::slotINDIWaitForActionName()
2709 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2711 if ( sf->
name() ==
"waitForINDIAction" )
2713 if (argWaitForActionINDI->actionName->text().isEmpty())
2719 if (sf->
argVal(0) != argWaitForActionINDI->actionName->text())
2720 setUnsavedChanges(
true );
2722 sf->
setArg(0, argWaitForActionINDI->actionName->text());
2727 warningMismatch(
"waitForINDIAction" );
2732 void ScriptBuilder::slotINDISetFocusSpeed()
2734 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2736 if ( sf->
name() ==
"setINDIFocusSpeed" )
2739 if (sf->
argVal(0).toInt() != argSetFocusSpeedINDI->speedIN->value())
2740 setUnsavedChanges(
true );
2742 sf->
setArg(0, QString(
"%1").arg(argSetFocusSpeedINDI->speedIN->value()));
2747 warningMismatch(
"setINDIFocusSpeed" );
2752 void ScriptBuilder::slotINDIStartFocusDirection()
2754 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2756 if ( sf->
name() ==
"startINDIFocus" )
2758 if (sf->
argVal(0) != argStartFocusINDI->directionCombo->currentText())
2759 setUnsavedChanges(
true );
2761 sf->
setArg(0, argStartFocusINDI->directionCombo->currentText());
2766 warningMismatch(
"startINDIFocus" );
2771 void ScriptBuilder::slotINDISetFocusTimeout()
2773 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2775 if ( sf->
name() ==
"setINDIFocusTimeout" )
2777 if (sf->
argVal(0).toInt() != argSetFocusTimeoutINDI->timeOut->value())
2778 setUnsavedChanges(
true );
2780 sf->
setArg(0, QString(
"%1").arg(argSetFocusTimeoutINDI->timeOut->value()));
2785 warningMismatch(
"setINDIFocusTimeout" );
2790 void ScriptBuilder::slotINDISetGeoLocationDeviceLong()
2792 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2794 if ( sf->
name() ==
"setINDIGeoLocation" ) {
2796 if ( argSetGeoLocationINDI->longBox->text().isEmpty())
2803 dms longitude = argSetGeoLocationINDI->longBox->createDms(
true, &ok);
2806 if (sf->
argVal(0) != QString(
"%1" ).arg( longitude.
Degrees()))
2807 setUnsavedChanges(
true );
2809 sf->
setArg( 0, QString(
"%1" ).arg( longitude.
Degrees() ) );
2810 if ( ! sf->
argVal(1).isEmpty() )
2817 sf->
setArg( 0, QString() );
2821 warningMismatch(
"setINDIGeoLocation" );
2826 void ScriptBuilder::slotINDISetGeoLocationDeviceLat()
2828 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2830 if ( sf->
name() ==
"setINDIGeoLocation" ) {
2832 if ( argSetGeoLocationINDI->latBox->text().isEmpty() )
2839 dms latitude = argSetGeoLocationINDI->latBox->createDms(
true, &ok);
2842 if (sf->
argVal(1) != QString(
"%1" ).arg( latitude.
Degrees()))
2843 setUnsavedChanges(
true );
2846 if ( ! sf->
argVal(0).isEmpty() )
2853 sf->
setArg( 1, QString() );
2857 warningMismatch(
"setINDIGeoLocation" );
2862 void ScriptBuilder::slotINDIStartExposureTimeout()
2864 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2866 if ( sf->
name() ==
"startINDIExposure" )
2869 if (sf->
argVal(0).toInt() != argStartExposureINDI->timeOut->value())
2870 setUnsavedChanges(
true );
2872 sf->
setArg(0, QString(
"%1").arg(argStartExposureINDI->timeOut->value()));
2877 warningMismatch(
"startINDIExposure" );
2882 void ScriptBuilder::slotINDISetUTC()
2884 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2886 if ( sf->
name() ==
"setINDIUTC" )
2889 if (argSetUTCINDI->UTC->text().isEmpty())
2895 if (sf->
argVal(0) != argSetUTCINDI->UTC->text())
2896 setUnsavedChanges(
true );
2898 sf->
setArg(0, argSetUTCINDI->UTC->text());
2903 warningMismatch(
"setINDIUTC" );
2908 void ScriptBuilder::slotINDISetScopeAction()
2910 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2912 if ( sf->
name() ==
"setINDIScopeAction" )
2915 if (sf->
argVal(0) != argSetScopeActionINDI->actionCombo->currentText())
2916 setUnsavedChanges(
true );
2918 sf->
setArg(0, argSetScopeActionINDI->actionCombo->currentText());
2924 warningMismatch(
"setINDIScopeAction" );
2929 void ScriptBuilder::slotINDISetFrameType()
2931 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2933 if ( sf->
name() ==
"setINDIFrameType" )
2936 if (sf->
argVal(0) != argSetFrameTypeINDI->typeCombo->currentText())
2937 setUnsavedChanges(
true );
2939 sf->
setArg(0, argSetFrameTypeINDI->typeCombo->currentText());
2944 warningMismatch(
"setINDIFrameType" );
2949 void ScriptBuilder::slotINDISetCCDTemp()
2951 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2953 if ( sf->
name() ==
"setINDICCDTemp" )
2956 if (sf->
argVal(0).toInt() != argSetCCDTempINDI->temp->value())
2957 setUnsavedChanges(
true );
2959 sf->
setArg(0, QString(
"%1").arg(argSetCCDTempINDI->temp->value()));
2964 warningMismatch(
"setINDICCDTemp" );
2969 void ScriptBuilder::slotINDISetFilterNum()
2972 ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2974 if ( sf->
name() ==
"setINDIFilterNum" )
2977 if (sf->
argVal(0).toInt() != argSetFilterNumINDI->filter_num->value())
2978 setUnsavedChanges(
true );
2980 sf->
setArg(0, QString(
"%1").arg(argSetFilterNumINDI->filter_num->value()));
2985 warningMismatch(
"setINDIFilterNum" );
2992 void ScriptBuilder::warningMismatch (
const QString &expected)
const {
2993 kWarning() << i18n(
"Mismatch between function and Arg widget (expected %1.)", QString(expected) ) ;
2996 #include "scriptbuilder.moc"
QString argVal(unsigned int n) const
Dialog for changing the geographic location of the observer.
ScriptBuilder(QWidget *parent)
bool isClockFunction() const
const double & Degrees() const
void slotMoveFunctionDown()
bool parseFunction(QString fn_name, QStringList &fn)
This is the main window for KStars.
void setArg(unsigned int n, QString newVal)
static KStarsDateTime currentDateTime(KDateTime::Spec ts=KDateTime::Spec::ClockTime())
i18nc("string from libindi, used in the config dialog","100x")
QString prototype() const
void slotRemoveFunction()
An angle, stored as degrees, but expressible in many ways.
void writeScript(QTextStream &ostream)
QString INDIProperty() const
void setINDIProperty(QString prop)
void slotMoveFunctionUp()
QString scriptLine() const
void setUnsavedChanges(bool b=true)
ScriptBuilderUI(QWidget *p)
void slotLoadColorScheme()
void slotChangeProvince()
void readScript(QTextStream &istream)
OptionsTreeView(QWidget *p)
void slotChangeColorName()