7#include "scriptbuilder.h"
10#include "scriptfunction.h"
12#include "kstarsdata.h"
14#include "ksnotification.h"
15#include "kstarsdatetime.h"
16#include "dialogs/finddialog.h"
17#include "dialogs/locationdialog.h"
18#include "widgets/dmsbox.h"
19#include "widgets/timespinbox.h"
20#include "widgets/timestepbox.h"
22#include <KLocalizedString>
24#include <KIO/StoredTransferJob>
28#include <QApplication>
29#include <QFontMetrics>
33#include <QStandardPaths>
34#include <QTemporaryFile>
40OptionsTreeViewWidget::OptionsTreeViewWidget(
QWidget *p) :
QFrame(p)
47 otvw.reset(
new OptionsTreeViewWidget(
this));
52 setLayout(mainLayout);
54 setWindowTitle(
i18nc(
"@title:window",
"Options"));
58 connect(buttonBox, SIGNAL(accepted()),
this, SLOT(accept()));
59 connect(buttonBox, SIGNAL(rejected()),
this, SLOT(reject()));
64void OptionsTreeView::resizeColumns()
67 int maxwidth[3] = { 0, 0, 0 };
68 QFontMetrics qfm = optionsList()->fontMetrics();
70 for (
int i = 0; i < optionsList()->topLevelItemCount(); ++i)
72 QTreeWidgetItem *topitem = optionsList()->topLevelItem(i);
75 for (
int j = 0; j < topitem->
childCount(); ++j)
77 QTreeWidgetItem *child = topitem->
child(j);
79 for (
int icol = 0; icol < 3; ++icol)
87 w += 2 * optionsList()->indentation();
90 if (w > maxwidth[icol])
98 for (
int icol = 0; icol < 3; ++icol)
101 qDebug() << Q_FUNC_INFO << QString(
"max width of column %1: %2").arg(icol).arg(maxwidth[icol]);
103 optionsList()->setColumnWidth(icol, maxwidth[icol]);
117 snw =
new ScriptNameWidget(
this);
122 setLayout(mainLayout);
124 setWindowTitle(
i18nc(
"@title:window",
"Script Data"));
128 connect(buttonBox, SIGNAL(accepted()),
this, SLOT(accept()));
129 connect(buttonBox, SIGNAL(rejected()),
this, SLOT(reject()));
133 connect(snw->ScriptName, SIGNAL(textChanged(
QString)),
this, SLOT(slotEnableOkButton()));
136ScriptNameDialog::~ScriptNameDialog()
141void ScriptNameDialog::slotEnableOkButton()
143 okB->setEnabled(!snw->ScriptName->text().isEmpty());
151ScriptBuilder::ScriptBuilder(
QWidget *parent)
152 :
QDialog(parent), UnsavedChanges(false), checkForChanges(true), currentFileURL(), currentDir(
QDir::homePath()),
153 currentScriptName(), currentAuthor()
158 sb =
new ScriptBuilderUI(
this);
163 setLayout(mainLayout);
165 setWindowTitle(
i18nc(
"@title:window",
"Script Builder"));
169 connect(buttonBox, SIGNAL(rejected()),
this, SLOT(slotClose()));
175 i18n(
"Point the display at the specified location. %1 can be the name "
176 "of an object, a cardinal point on the compass, or 'zenith'.",
178 false,
"QString",
"dir"));
180 "addLabel",
i18n(
"Add a name label to the object named %1.",
QString(
"name")),
false,
"QString",
"name"));
181 KStarsFunctionList.append(
183 false,
"QString",
"name"));
185 "addTrail",
i18n(
"Add a trail to the solar system body named %1.",
QString(
"name")),
false,
"QString",
"name"));
187 "removeTrail",
i18n(
"Remove the trail from the solar system body named %1.",
QString(
"name")),
false,
"QString",
190 i18n(
"Point the display at the specified RA/Dec coordinates. RA is "
191 "expressed in Hours; Dec is expressed in Degrees."),
192 false,
"double",
"ra",
"double",
"dec"));
195 i18n(
"Point the display at the specified Alt/Az coordinates. Alt and Az are expressed in Degrees."),
false,
196 "double",
"alt",
"double",
"az"));
197 KStarsFunctionList.append(
new ScriptFunction(
"zoomIn",
i18n(
"Increase the display Zoom Level."),
false));
198 KStarsFunctionList.append(
new ScriptFunction(
"zoomOut",
i18n(
"Decrease the display Zoom Level."),
false));
199 KStarsFunctionList.append(
200 new ScriptFunction(
"defaultZoom",
i18n(
"Set the display Zoom Level to its default value."),
false));
201 KStarsFunctionList.append(
202 new ScriptFunction(
"zoom",
i18n(
"Set the display Zoom Level manually."),
false,
"double",
"z"));
203 KStarsFunctionList.append(
204 new ScriptFunction(
"setLocalTime",
i18n(
"Set the system clock to the specified Local Time."),
false,
"int",
205 "year",
"int",
"month",
"int",
"day",
"int",
"hour",
"int",
"minute",
"int",
"second"));
207 "waitFor",
i18n(
"Pause script execution for specified number of seconds."),
false,
"double",
"sec"));
209 i18n(
"Halt script execution until the specified key is pressed. Only "
210 "single-key strokes are possible; use 'space' for the spacebar."),
211 false,
"QString",
"key"));
213 "setTracking",
i18n(
"Set whether the display is tracking the current location."),
false,
"bool",
"track"));
215 "changeViewOption",
i18n(
"Change view option named %1 to value %2.",
QString(
"opName"),
QString(
"opValue")),
216 false,
"QString",
"opName",
"QString",
"opValue"));
218 "setGeoLocation",
i18n(
"Set the geographic location to the city specified by city, province and country."),
219 false,
"QString",
"cityName",
"QString",
"provinceName",
"QString",
"countryName"));
221 "setColor",
i18n(
"Set the color named %1 to the value %2.",
QString(
"colorName"),
QString(
"value")),
false,
222 "QString",
"colorName",
"QString",
"value"));
223 KStarsFunctionList.append(
new ScriptFunction(
"loadColorScheme",
i18n(
"Load the color scheme specified by name."),
224 false,
"QString",
"name"));
225 KStarsFunctionList.append(
226 new ScriptFunction(
"exportImage",
i18n(
"Export the sky image to the file, with specified width and height."),
227 false,
"QString",
"fileName",
"int",
"width",
"int",
"height"));
228 KStarsFunctionList.append(
230 i18n(
"Print the sky image to a printer or file. If %1 is true, it will show the print "
231 "dialog. If %2 is true, it will use the Star Chart color scheme for printing.",
233 false,
"bool",
"usePrintDialog",
"bool",
"useChartColors"));
234 SimClockFunctionList.append(
new ScriptFunction(
"stop",
i18n(
"Halt the simulation clock."),
true));
235 SimClockFunctionList.append(
new ScriptFunction(
"start",
i18n(
"Start the simulation clock."),
true));
237 i18n(
"Set the timescale of the simulation clock to specified scale. "
238 " 1.0 means real-time; 2.0 means twice real-time; etc."),
239 true,
"double",
"scale"));
245 for (
auto &item : KStarsFunctionList)
248 for (
auto &item : SimClockFunctionList)
254 sb->FunctionTree->setColumnCount(1);
256 sb->FunctionTree->setSortingEnabled(
false);
262 sb->SaveAsButton->setIcon(
284 argLookToward =
new ArgLookToward(sb->ArgStack);
285 argFindObject =
new ArgFindObject(sb->ArgStack);
286 argSetRaDec =
new ArgSetRaDec(sb->ArgStack);
287 argSetAltAz =
new ArgSetAltAz(sb->ArgStack);
288 argSetLocalTime =
new ArgSetLocalTime(sb->ArgStack);
289 argWaitFor =
new ArgWaitFor(sb->ArgStack);
290 argWaitForKey =
new ArgWaitForKey(sb->ArgStack);
291 argSetTracking =
new ArgSetTrack(sb->ArgStack);
292 argChangeViewOption =
new ArgChangeViewOption(sb->ArgStack);
293 argSetGeoLocation =
new ArgSetGeoLocation(sb->ArgStack);
294 argTimeScale =
new ArgTimeScale(sb->ArgStack);
295 argZoom =
new ArgZoom(sb->ArgStack);
296 argExportImage =
new ArgExportImage(sb->ArgStack);
297 argPrintImage =
new ArgPrintImage(sb->ArgStack);
298 argSetColor =
new ArgSetColor(sb->ArgStack);
299 argLoadColorScheme =
new ArgLoadColorScheme(sb->ArgStack);
301 sb->ArgStack->addWidget(argBlank);
302 sb->ArgStack->addWidget(argLookToward);
303 sb->ArgStack->addWidget(argFindObject);
304 sb->ArgStack->addWidget(argSetRaDec);
305 sb->ArgStack->addWidget(argSetAltAz);
306 sb->ArgStack->addWidget(argSetLocalTime);
307 sb->ArgStack->addWidget(argWaitFor);
308 sb->ArgStack->addWidget(argWaitForKey);
309 sb->ArgStack->addWidget(argSetTracking);
310 sb->ArgStack->addWidget(argChangeViewOption);
311 sb->ArgStack->addWidget(argSetGeoLocation);
312 sb->ArgStack->addWidget(argTimeScale);
313 sb->ArgStack->addWidget(argZoom);
314 sb->ArgStack->addWidget(argExportImage);
315 sb->ArgStack->addWidget(argPrintImage);
316 sb->ArgStack->addWidget(argSetColor);
317 sb->ArgStack->addWidget(argLoadColorScheme);
319 sb->ArgStack->setCurrentIndex(0);
324 otv->resize(sb->width(), 0.5 * sb->height());
327 otv->resizeColumns();
330 connect(sb->FunctionTree, SIGNAL(itemDoubleClicked(
QTreeWidgetItem*,
int)),
this, SLOT(slotAddFunction()));
332 connect(sb->UpButton, SIGNAL(clicked()),
this, SLOT(slotMoveFunctionUp()));
334 connect(sb->DownButton, SIGNAL(clicked()),
this, SLOT(slotMoveFunctionDown()));
335 connect(sb->CopyButton, SIGNAL(clicked()),
this, SLOT(slotCopyFunction()));
336 connect(sb->RemoveButton, SIGNAL(clicked()),
this, SLOT(slotRemoveFunction()));
337 connect(sb->NewButton, SIGNAL(clicked()),
this, SLOT(slotNew()));
338 connect(sb->OpenButton, SIGNAL(clicked()),
this, SLOT(slotOpen()));
339 connect(sb->SaveButton, SIGNAL(clicked()),
this, SLOT(slotSave()));
340 connect(sb->SaveAsButton, SIGNAL(clicked()),
this, SLOT(slotSaveAs()));
341 connect(sb->AddButton, SIGNAL(clicked()),
this, SLOT(slotAddFunction()));
342 connect(sb->RunButton, SIGNAL(clicked()),
this, SLOT(slotRunScript()));
345 connect(argSetGeoLocation->FindCityButton, SIGNAL(clicked()),
this, SLOT(slotFindCity()));
346 connect(argLookToward->FindButton, SIGNAL(clicked()),
this, SLOT(slotFindObject()));
347 connect(argChangeViewOption->TreeButton, SIGNAL(clicked()),
this, SLOT(slotShowOptions()));
348 connect(argFindObject->FindButton, SIGNAL(clicked()),
this, SLOT(slotFindObject()));
350 connect(argLookToward->FocusEdit, SIGNAL(editTextChanged(
QString)),
this, SLOT(slotLookToward()));
351 connect(argFindObject->NameEdit, SIGNAL(textChanged(
QString)),
this, SLOT(slotArgFindObject()));
352 connect(argSetRaDec->RABox, SIGNAL(textChanged(
QString)),
this, SLOT(slotRa()));
353 connect(argSetRaDec->DecBox, SIGNAL(textChanged(
QString)),
this, SLOT(slotDec()));
354 connect(argSetAltAz->AltBox, SIGNAL(textChanged(
QString)),
this, SLOT(slotAlt()));
355 connect(argSetAltAz->AzBox, SIGNAL(textChanged(
QString)),
this, SLOT(slotAz()));
356 connect(argSetLocalTime->DateWidget, SIGNAL(dateChanged(
QDate)),
this, SLOT(slotChangeDate()));
357 connect(argSetLocalTime->TimeBox, SIGNAL(timeChanged(
QTime)),
this, SLOT(slotChangeTime()));
358 connect(argWaitFor->DelayBox, SIGNAL(valueChanged(
int)),
this, SLOT(slotWaitFor()));
359 connect(argWaitForKey->WaitKeyEdit, SIGNAL(textChanged(
QString)),
this, SLOT(slotWaitForKey()));
360 connect(argSetTracking->CheckTrack, SIGNAL(stateChanged(
int)),
this, SLOT(slotTracking()));
361 connect(argChangeViewOption->OptionName, SIGNAL(activated(
QString)),
this, SLOT(slotViewOption()));
362 connect(argChangeViewOption->OptionValue, SIGNAL(textChanged(
QString)),
this, SLOT(slotViewOption()));
363 connect(argSetGeoLocation->CityName, SIGNAL(textChanged(
QString)),
this, SLOT(slotChangeCity()));
364 connect(argSetGeoLocation->ProvinceName, SIGNAL(textChanged(
QString)),
this, SLOT(slotChangeProvince()));
365 connect(argSetGeoLocation->CountryName, SIGNAL(textChanged(
QString)),
this, SLOT(slotChangeCountry()));
366 connect(argTimeScale->TimeScale, SIGNAL(scaleChanged(
float)),
this, SLOT(slotTimeScale()));
367 connect(argZoom->ZoomBox, SIGNAL(textChanged(
QString)),
this, SLOT(slotZoom()));
368 connect(argExportImage->ExportFileName, SIGNAL(textChanged(
QString)),
this, SLOT(slotExportImage()));
369 connect(argExportImage->ExportWidth, SIGNAL(valueChanged(
int)),
this, SLOT(slotExportImage()));
370 connect(argExportImage->ExportHeight, SIGNAL(valueChanged(
int)),
this, SLOT(slotExportImage()));
371 connect(argPrintImage->UsePrintDialog, SIGNAL(toggled(
bool)),
this, SLOT(slotPrintImage()));
372 connect(argPrintImage->UseChartColors, SIGNAL(toggled(
bool)),
this, SLOT(slotPrintImage()));
373 connect(argSetColor->ColorName, SIGNAL(activated(
QString)),
this, SLOT(slotChangeColorName()));
374 connect(argSetColor->ColorValue, SIGNAL(changed(
QColor)),
this, SLOT(slotChangeColor()));
375 connect(argLoadColorScheme->SchemeList, SIGNAL(itemClicked(
QListWidgetItem*)),
this, SLOT(slotLoadColorScheme()));
378 sb->CopyButton->setEnabled(
false);
379 sb->AddButton->setEnabled(
false);
380 sb->RemoveButton->setEnabled(
false);
381 sb->UpButton->setEnabled(
false);
382 sb->DownButton->setEnabled(
false);
383 sb->SaveButton->setEnabled(
false);
384 sb->SaveAsButton->setEnabled(
false);
385 sb->RunButton->setEnabled(
false);
388ScriptBuilder::~ScriptBuilder()
390 while (!KStarsFunctionList.isEmpty())
391 delete KStarsFunctionList.takeFirst();
393 while (!SimClockFunctionList.isEmpty())
394 delete SimClockFunctionList.takeFirst();
396 while (!ScriptList.isEmpty())
397 delete ScriptList.takeFirst();
400void ScriptBuilder::initViewOptions()
402 otv->optionsList()->setRootIsDecorated(
true);
406 opsGUI =
new QTreeWidgetItem(otv->optionsList(), QStringList(
i18n(
"InfoBoxes")));
407 fields <<
"ShowInfoBoxes" <<
i18n(
"Toggle display of all InfoBoxes") <<
i18n(
"bool");
408 new QTreeWidgetItem(opsGUI, fields);
410 fields <<
"ShowTimeBox" <<
i18n(
"Toggle display of Time InfoBox") <<
i18n(
"bool");
411 new QTreeWidgetItem(opsGUI, fields);
413 fields <<
"ShowGeoBox" <<
i18n(
"Toggle display of Geographic InfoBox") <<
i18n(
"bool");
414 new QTreeWidgetItem(opsGUI, fields);
416 fields <<
"ShowFocusBox" <<
i18n(
"Toggle display of Focus InfoBox") <<
i18n(
"bool");
417 new QTreeWidgetItem(opsGUI, fields);
419 fields <<
"ShadeTimeBox" <<
i18n(
"(un)Shade Time InfoBox") <<
i18n(
"bool");
420 new QTreeWidgetItem(opsGUI, fields);
422 fields <<
"ShadeGeoBox" <<
i18n(
"(un)Shade Geographic InfoBox") <<
i18n(
"bool");
423 new QTreeWidgetItem(opsGUI, fields);
425 fields <<
"ShadeFocusBox" <<
i18n(
"(un)Shade Focus InfoBox") <<
i18n(
"bool");
426 new QTreeWidgetItem(opsGUI, fields);
429 argChangeViewOption->OptionName->addItem(
"ShowInfoBoxes");
430 argChangeViewOption->OptionName->addItem(
"ShowTimeBox");
431 argChangeViewOption->OptionName->addItem(
"ShowGeoBox");
432 argChangeViewOption->OptionName->addItem(
"ShowFocusBox");
433 argChangeViewOption->OptionName->addItem(
"ShadeTimeBox");
434 argChangeViewOption->OptionName->addItem(
"ShadeGeoBox");
435 argChangeViewOption->OptionName->addItem(
"ShadeFocusBox");
438 opsToolbar =
new QTreeWidgetItem(otv->optionsList(), QStringList(
i18n(
"Toolbars")));
439 fields <<
"ShowMainToolBar" <<
i18n(
"Toggle display of main toolbar") <<
i18n(
"bool");
440 new QTreeWidgetItem(opsToolbar, fields);
442 fields <<
"ShowViewToolBar" <<
i18n(
"Toggle display of view toolbar") <<
i18n(
"bool");
443 new QTreeWidgetItem(opsToolbar, fields);
446 argChangeViewOption->OptionName->addItem(
"ShowMainToolBar");
447 argChangeViewOption->OptionName->addItem(
"ShowViewToolBar");
450 opsShowObj =
new QTreeWidgetItem(otv->optionsList(), QStringList(
i18n(
"Show Objects")));
451 fields <<
"ShowStars" <<
i18n(
"Toggle display of Stars") <<
i18n(
"bool");
452 new QTreeWidgetItem(opsShowObj, fields);
454 fields <<
"ShowDeepSky" <<
i18n(
"Toggle display of all deep-sky objects") <<
i18n(
"bool");
455 new QTreeWidgetItem(opsShowObj, fields);
457 new QTreeWidgetItem(opsShowObj, fields);
459 new QTreeWidgetItem(opsShowObj, fields);
461 fields <<
"ShowSolarSystem" <<
i18n(
"Toggle display of all solar system bodies") <<
i18n(
"bool");
462 new QTreeWidgetItem(opsShowObj, fields);
464 fields <<
"ShowSun" <<
i18n(
"Toggle display of Sun") <<
i18n(
"bool");
465 new QTreeWidgetItem(opsShowObj, fields);
467 fields <<
"ShowMoon" <<
i18n(
"Toggle display of Moon") <<
i18n(
"bool");
468 new QTreeWidgetItem(opsShowObj, fields);
470 fields <<
"ShowMercury" <<
i18n(
"Toggle display of Mercury") <<
i18n(
"bool");
471 new QTreeWidgetItem(opsShowObj, fields);
473 fields <<
"ShowVenus" <<
i18n(
"Toggle display of Venus") <<
i18n(
"bool");
474 new QTreeWidgetItem(opsShowObj, fields);
476 fields <<
"ShowMars" <<
i18n(
"Toggle display of Mars") <<
i18n(
"bool");
477 new QTreeWidgetItem(opsShowObj, fields);
479 fields <<
"ShowJupiter" <<
i18n(
"Toggle display of Jupiter") <<
i18n(
"bool");
480 new QTreeWidgetItem(opsShowObj, fields);
482 fields <<
"ShowSaturn" <<
i18n(
"Toggle display of Saturn") <<
i18n(
"bool");
483 new QTreeWidgetItem(opsShowObj, fields);
485 fields <<
"ShowUranus" <<
i18n(
"Toggle display of Uranus") <<
i18n(
"bool");
486 new QTreeWidgetItem(opsShowObj, fields);
488 fields <<
"ShowNeptune" <<
i18n(
"Toggle display of Neptune") <<
i18n(
"bool");
489 new QTreeWidgetItem(opsShowObj, fields);
494 fields <<
"ShowAsteroids" <<
i18n(
"Toggle display of Asteroids") <<
i18n(
"bool");
495 new QTreeWidgetItem(opsShowObj, fields);
497 fields <<
"ShowComets" <<
i18n(
"Toggle display of Comets") <<
i18n(
"bool");
498 new QTreeWidgetItem(opsShowObj, fields);
501 argChangeViewOption->OptionName->addItem(
"ShowStars");
502 argChangeViewOption->OptionName->addItem(
"ShowDeepSky");
503 argChangeViewOption->OptionName->addItem(
"ShowSolarSystem");
504 argChangeViewOption->OptionName->addItem(
"ShowSun");
505 argChangeViewOption->OptionName->addItem(
"ShowMoon");
506 argChangeViewOption->OptionName->addItem(
"ShowMercury");
507 argChangeViewOption->OptionName->addItem(
"ShowVenus");
508 argChangeViewOption->OptionName->addItem(
"ShowMars");
509 argChangeViewOption->OptionName->addItem(
"ShowJupiter");
510 argChangeViewOption->OptionName->addItem(
"ShowSaturn");
511 argChangeViewOption->OptionName->addItem(
"ShowUranus");
512 argChangeViewOption->OptionName->addItem(
"ShowNeptune");
514 argChangeViewOption->OptionName->addItem(
"ShowAsteroids");
515 argChangeViewOption->OptionName->addItem(
"ShowComets");
517 opsShowOther =
new QTreeWidgetItem(otv->optionsList(), QStringList(
i18n(
"Show Other")));
518 fields <<
"ShowCLines" <<
i18n(
"Toggle display of constellation lines") <<
i18n(
"bool");
519 new QTreeWidgetItem(opsShowOther, fields);
521 fields <<
"ShowCBounds" <<
i18n(
"Toggle display of constellation boundaries") <<
i18n(
"bool");
522 new QTreeWidgetItem(opsShowOther, fields);
524 fields <<
"ShowCNames" <<
i18n(
"Toggle display of constellation names") <<
i18n(
"bool");
525 new QTreeWidgetItem(opsShowOther, fields);
527 fields <<
"ShowMilkyWay" <<
i18n(
"Toggle display of Milky Way") <<
i18n(
"bool");
528 new QTreeWidgetItem(opsShowOther, fields);
530 fields <<
"ShowGrid" <<
i18n(
"Toggle display of the coordinate grid") <<
i18n(
"bool");
531 new QTreeWidgetItem(opsShowOther, fields);
533 fields <<
"ShowEquator" <<
i18n(
"Toggle display of the celestial equator") <<
i18n(
"bool");
534 new QTreeWidgetItem(opsShowOther, fields);
536 fields <<
"ShowEcliptic" <<
i18n(
"Toggle display of the ecliptic") <<
i18n(
"bool");
537 new QTreeWidgetItem(opsShowOther, fields);
539 fields <<
"ShowHorizon" <<
i18n(
"Toggle display of the horizon line") <<
i18n(
"bool");
540 new QTreeWidgetItem(opsShowOther, fields);
542 fields <<
"ShowGround" <<
i18n(
"Toggle display of the opaque ground") <<
i18n(
"bool");
543 new QTreeWidgetItem(opsShowOther, fields);
545 fields <<
"ShowStarNames" <<
i18n(
"Toggle display of star name labels") <<
i18n(
"bool");
546 new QTreeWidgetItem(opsShowOther, fields);
548 fields <<
"ShowStarMagnitudes" <<
i18n(
"Toggle display of star magnitude labels") <<
i18n(
"bool");
549 new QTreeWidgetItem(opsShowOther, fields);
551 fields <<
"ShowAsteroidNames" <<
i18n(
"Toggle display of asteroid name labels") <<
i18n(
"bool");
552 new QTreeWidgetItem(opsShowOther, fields);
554 fields <<
"ShowCometNames" <<
i18n(
"Toggle display of comet name labels") <<
i18n(
"bool");
555 new QTreeWidgetItem(opsShowOther, fields);
557 fields <<
"ShowPlanetNames" <<
i18n(
"Toggle display of planet name labels") <<
i18n(
"bool");
558 new QTreeWidgetItem(opsShowOther, fields);
560 fields <<
"ShowPlanetImages" <<
i18n(
"Toggle display of planet images") <<
i18n(
"bool");
561 new QTreeWidgetItem(opsShowOther, fields);
564 argChangeViewOption->OptionName->addItem(
"ShowCLines");
565 argChangeViewOption->OptionName->addItem(
"ShowCBounds");
566 argChangeViewOption->OptionName->addItem(
"ShowCNames");
567 argChangeViewOption->OptionName->addItem(
"ShowMilkyWay");
568 argChangeViewOption->OptionName->addItem(
"ShowGrid");
569 argChangeViewOption->OptionName->addItem(
"ShowEquator");
570 argChangeViewOption->OptionName->addItem(
"ShowEcliptic");
571 argChangeViewOption->OptionName->addItem(
"ShowHorizon");
572 argChangeViewOption->OptionName->addItem(
"ShowGround");
573 argChangeViewOption->OptionName->addItem(
"ShowStarNames");
574 argChangeViewOption->OptionName->addItem(
"ShowStarMagnitudes");
575 argChangeViewOption->OptionName->addItem(
"ShowAsteroidNames");
576 argChangeViewOption->OptionName->addItem(
"ShowCometNames");
577 argChangeViewOption->OptionName->addItem(
"ShowPlanetNames");
578 argChangeViewOption->OptionName->addItem(
"ShowPlanetImages");
580 opsCName =
new QTreeWidgetItem(otv->optionsList(), QStringList(
i18n(
"Constellation Names")));
581 fields <<
"UseLatinConstellNames" <<
i18n(
"Show Latin constellation names") <<
i18n(
"bool");
582 new QTreeWidgetItem(opsCName, fields);
584 fields <<
"UseLocalConstellNames" <<
i18n(
"Show constellation names in local language") <<
i18n(
"bool");
585 new QTreeWidgetItem(opsCName, fields);
587 fields <<
"UseAbbrevConstellNames" <<
i18n(
"Show IAU-standard constellation abbreviations") <<
i18n(
"bool");
588 new QTreeWidgetItem(opsCName, fields);
591 argChangeViewOption->OptionName->addItem(
"UseLatinConstellNames");
592 argChangeViewOption->OptionName->addItem(
"UseLocalConstellNames");
593 argChangeViewOption->OptionName->addItem(
"UseAbbrevConstellNames");
595 opsHide =
new QTreeWidgetItem(otv->optionsList(), QStringList(
i18n(
"Hide Items")));
596 fields <<
"HideOnSlew" <<
i18n(
"Toggle whether objects hidden while slewing display") <<
i18n(
"bool");
597 new QTreeWidgetItem(opsHide, fields);
599 fields <<
"SlewTimeScale" <<
i18n(
"Timestep threshold (in seconds) for hiding objects") <<
i18n(
"double");
600 new QTreeWidgetItem(opsHide, fields);
602 fields <<
"HideStars" <<
i18n(
"Hide faint stars while slewing?") <<
i18n(
"bool");
603 new QTreeWidgetItem(opsHide, fields);
605 fields <<
"HidePlanets" <<
i18n(
"Hide solar system bodies while slewing?") <<
i18n(
"bool");
606 new QTreeWidgetItem(opsHide, fields);
608 fields <<
"HideMilkyWay" <<
i18n(
"Hide Milky Way while slewing?") <<
i18n(
"bool");
609 new QTreeWidgetItem(opsHide, fields);
611 fields <<
"HideCNames" <<
i18n(
"Hide constellation names while slewing?") <<
i18n(
"bool");
612 new QTreeWidgetItem(opsHide, fields);
614 fields <<
"HideCLines" <<
i18n(
"Hide constellation lines while slewing?") <<
i18n(
"bool");
615 new QTreeWidgetItem(opsHide, fields);
617 fields <<
"HideCBounds" <<
i18n(
"Hide constellation boundaries while slewing?") <<
i18n(
"bool");
618 new QTreeWidgetItem(opsHide, fields);
620 fields <<
"HideGrid" <<
i18n(
"Hide coordinate grid while slewing?") <<
i18n(
"bool");
621 new QTreeWidgetItem(opsHide, fields);
624 argChangeViewOption->OptionName->addItem(
"HideOnSlew");
625 argChangeViewOption->OptionName->addItem(
"SlewTimeScale");
626 argChangeViewOption->OptionName->addItem(
"HideStars");
627 argChangeViewOption->OptionName->addItem(
"HidePlanets");
628 argChangeViewOption->OptionName->addItem(
"HideMilkyWay");
629 argChangeViewOption->OptionName->addItem(
"HideCNames");
630 argChangeViewOption->OptionName->addItem(
"HideCLines");
631 argChangeViewOption->OptionName->addItem(
"HideCBounds");
632 argChangeViewOption->OptionName->addItem(
"HideGrid");
634 opsSkymap =
new QTreeWidgetItem(otv->optionsList(), QStringList(
i18n(
"Skymap Options")));
635 fields <<
"UseAltAz" <<
i18n(
"Use Horizontal coordinates? (otherwise, use Equatorial)") <<
i18n(
"bool");
636 new QTreeWidgetItem(opsSkymap, fields);
638 fields <<
"ZoomFactor" <<
i18n(
"Set the Zoom Factor") <<
i18n(
"double");
639 new QTreeWidgetItem(opsSkymap, fields);
641 fields <<
"FOVName" <<
i18n(
"Select angular size for the FOV symbol (in arcmin)") <<
i18n(
"double");
642 new QTreeWidgetItem(opsSkymap, fields);
644 fields <<
"FOVShape" <<
i18n(
"Select shape for the FOV symbol (0=Square, 1=Circle, 2=Crosshairs, 4=Bullseye)")
646 new QTreeWidgetItem(opsSkymap, fields);
648 fields <<
"FOVColor" <<
i18n(
"Select color for the FOV symbol") <<
i18n(
"string");
649 new QTreeWidgetItem(opsSkymap, fields);
651 fields <<
"UseAnimatedSlewing" <<
i18n(
"Use animated slewing? (otherwise, \"snap\" to new focus)") <<
i18n(
"bool");
652 new QTreeWidgetItem(opsSkymap, fields);
654 fields <<
"UseRefraction" <<
i18n(
"Correct for atmospheric refraction?") <<
i18n(
"bool");
655 new QTreeWidgetItem(opsSkymap, fields);
657 fields <<
"UseAutoLabel" <<
i18n(
"Automatically attach name label to centered object?") <<
i18n(
"bool");
658 new QTreeWidgetItem(opsSkymap, fields);
660 fields <<
"UseHoverLabel" <<
i18n(
"Attach temporary name label when hovering mouse over an object?")
662 new QTreeWidgetItem(opsSkymap, fields);
664 fields <<
"UseAutoTrail" <<
i18n(
"Automatically add trail to centered solar system body?") <<
i18n(
"bool");
665 new QTreeWidgetItem(opsSkymap, fields);
667 fields <<
"FadePlanetTrails" <<
i18n(
"Planet trails fade to sky color? (otherwise color is constant)")
669 new QTreeWidgetItem(opsSkymap, fields);
672 argChangeViewOption->OptionName->addItem(
"UseAltAz");
673 argChangeViewOption->OptionName->addItem(
"ZoomFactor");
674 argChangeViewOption->OptionName->addItem(
"FOVName");
675 argChangeViewOption->OptionName->addItem(
"FOVSize");
676 argChangeViewOption->OptionName->addItem(
"FOVShape");
677 argChangeViewOption->OptionName->addItem(
"FOVColor");
678 argChangeViewOption->OptionName->addItem(
"UseRefraction");
679 argChangeViewOption->OptionName->addItem(
"UseAutoLabel");
680 argChangeViewOption->OptionName->addItem(
"UseHoverLabel");
681 argChangeViewOption->OptionName->addItem(
"UseAutoTrail");
682 argChangeViewOption->OptionName->addItem(
"AnimateSlewing");
683 argChangeViewOption->OptionName->addItem(
"FadePlanetTrails");
685 opsLimit =
new QTreeWidgetItem(otv->optionsList(), QStringList(
i18n(
"Limits")));
706 fields <<
"starLabelDensity" <<
i18n(
"magnitude of faintest star labeled on map") <<
i18n(
"double");
707 new QTreeWidgetItem(opsLimit, fields);
709 fields <<
"magLimitHideStar" <<
i18n(
"magnitude of brightest star hidden while slewing") <<
i18n(
"double");
710 new QTreeWidgetItem(opsLimit, fields);
712 fields <<
"magLimitAsteroid" <<
i18n(
"magnitude of faintest asteroid drawn on map") <<
i18n(
"double");
713 new QTreeWidgetItem(opsLimit, fields);
716 fields <<
"asteroidLabelDensity" <<
i18n(
"magnitude of faintest asteroid labeled on map") <<
i18n(
"double");
717 new QTreeWidgetItem(opsLimit, fields);
719 fields <<
"maxRadCometName" <<
i18n(
"comets nearer to the Sun than this (in AU) are labeled on map")
721 new QTreeWidgetItem(opsLimit, fields);
726 argChangeViewOption->OptionName->addItem(
"magLimitDrawDeepSky");
727 argChangeViewOption->OptionName->addItem(
"magLimitDrawDeepSkyZoomOut");
728 argChangeViewOption->OptionName->addItem(
"starLabelDensity");
729 argChangeViewOption->OptionName->addItem(
"magLimitHideStar");
730 argChangeViewOption->OptionName->addItem(
"magLimitAsteroid");
731 argChangeViewOption->OptionName->addItem(
"asteroidLabelDensity");
732 argChangeViewOption->OptionName->addItem(
"maxRadCometName");
737 argSetColor->ColorName->addItem(KStarsData::Instance()->colorScheme()->nameAt(i));
741 argLoadColorScheme->SchemeList->addItem(
i18nc(
"use default color scheme",
"Default Colors"));
742 argLoadColorScheme->SchemeList->addItem(
i18nc(
"use 'star chart' color scheme",
"Star Chart"));
743 argLoadColorScheme->SchemeList->addItem(
i18nc(
"use 'night vision' color scheme",
"Night Vision"));
744 argLoadColorScheme->SchemeList->addItem(
i18nc(
"use 'moonless night' color scheme",
"Moonless Night"));
752 QTextStream stream(&file);
754 while (!stream.atEnd())
756 line = stream.readLine();
757 argLoadColorScheme->SchemeList->addItem(line.
left(line.
indexOf(
':')));
764void ScriptBuilder::slotNew()
770 sb->ScriptListBox->clear();
771 sb->ArgStack->setCurrentWidget(argBlank);
773 sb->CopyButton->setEnabled(
false);
774 sb->RemoveButton->setEnabled(
false);
775 sb->RunButton->setEnabled(
false);
776 sb->SaveAsButton->setEnabled(
false);
778 currentFileURL.clear();
779 currentScriptName.clear();
783void ScriptBuilder::slotOpen()
788 QTemporaryFile tmpfile;
795 "*.kstars|" +
i18nc(
"Filter by file type: KStars Scripts.",
"KStars Scripts (*.kstars)"));
797 if (currentFileURL.isValid())
799 currentDir = currentFileURL.toLocalFile();
802 sb->ScriptListBox->clear();
803 sb->ArgStack->setCurrentWidget(argBlank);
805 if (currentFileURL.isLocalFile())
807 fname = currentFileURL.toLocalFile();
814 KSNotification::sorry(
i18n(
"Could not download remote file."),
i18n(
"Download Error"));
820 KSNotification::sorry(
i18n(
"Could not open file %1.", f.fileName()),
i18n(
"Could Not Open File"));
821 currentFileURL.clear();
825 QTextStream istream(&f);
830 else if (!currentFileURL.url().isEmpty())
832 KSNotification::sorry(
i18n(
"Invalid URL: %1", currentFileURL.url()),
i18n(
"Invalid URL"));
833 currentFileURL.clear();
838void ScriptBuilder::slotSave()
841 QTemporaryFile tmpfile;
844 if (currentScriptName.isEmpty())
849 currentScriptName = snd->scriptName();
850 currentAuthor = snd->authorName();
858 bool newFilename =
false;
859 if (currentFileURL.isEmpty())
863 "*.kstars|" +
i18nc(
"Filter by file type: KStars Scripts.",
"KStars Scripts (*.kstars)"));
867 if (currentFileURL.isValid())
869 currentDir = currentFileURL.toLocalFile();
871 if (currentFileURL.isLocalFile())
873 fname = currentFileURL.toLocalFile();
876 if (newFilename ==
true &&
QFile::exists(currentFileURL.toLocalFile()))
879 i18n(
"A file named \"%1\" already exists. "
881 currentFileURL.fileName()),
899 QString message =
i18n(
"Could not open file %1.", f.fileName());
900 KSNotification::sorry(message,
i18n(
"Could Not Open File"));
901 currentFileURL.clear();
905 QTextStream ostream(&f);
906 writeScript(ostream);
911 chmod(fname.
toLatin1(), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
920 QString message =
i18n(
"Could not upload image to remote location: %1", currentFileURL.url());
921 KSNotification::sorry(message,
i18n(
"Could not upload file"));
925 setUnsavedChanges(
false);
929 QString message =
i18n(
"Invalid URL: %1", currentFileURL.url());
930 KSNotification::sorry(message,
i18n(
"Invalid URL"));
931 currentFileURL.clear();
935void ScriptBuilder::slotSaveAs()
937 currentFileURL.clear();
938 currentScriptName.clear();
942void ScriptBuilder::saveWarning()
946 QString caption =
i18n(
"Save Changes to Script?");
947 QString message =
i18n(
"The current script has unsaved changes. Would you like to save before closing it?");
953 setUnsavedChanges(
false);
957 setUnsavedChanges(
false);
964void ScriptBuilder::slotRunScript()
982 QString message =
i18n(
"Could not open file %1.", f.fileName());
983 KSNotification::sorry(message,
i18n(
"Could Not Open File"));
984 currentFileURL.clear();
988 QTextStream ostream(&f);
989 writeScript(ostream);
994 chmod(
QFile::encodeName(f.fileName()), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
1004 QStringList arguments;
1005 p.
start(f.fileName(), arguments);
1008 qDebug() << Q_FUNC_INFO <<
"Process did not start.";
1012 qApp->processEvents();
1027void ScriptBuilder::writeScript(
QTextStream &ostream)
1030 QString dbus_call =
"dbus-send --dest=org.kde.kstars --print-reply ";
1031 QString main_method =
"/KStars org.kde.kstars.";
1032 QString clock_method =
"/KStars/SimClock org.kde.kstars.SimClock.";
1035 ostream <<
"#!/bin/bash\n";
1036 ostream <<
"#KStars DBus script: " << currentScriptName <<
'\n';
1037 ostream <<
"#by " << currentAuthor <<
'\n';
1041 foreach (ScriptFunction *sf, ScriptList)
1046 if (sf->isClockFunction())
1048 ostream << dbus_call << clock_method << sf->scriptLine() <<
'\n';
1052 ostream << dbus_call << main_method << sf->scriptLine() <<
'\n';
1061void ScriptBuilder::readScript(
QTextStream &istream)
1064 QString service_name =
"org.kde.kstars.";
1067 while (!istream.
atEnd())
1072 if (line.
contains(
"#KStars DBus script: "))
1080 if (line.
left(4) ==
"dbus")
1085 service_name +=
"SimClock.";
1102 if (parseFunction(fn_name, line))
1104 sb->ScriptListBox->addItem(ScriptList.last()->name());
1106 ScriptList.last()->setValid(
true);
1109 qWarning() <<
i18n(
"Could not parse script. Line was: %1", line);
1115 if (sb->ScriptListBox->count())
1117 sb->ScriptListBox->setCurrentItem(
nullptr);
1122bool ScriptBuilder::parseFunction(
const QString &fn_name,
const QString &fn_args)
1167 QRegularExpression re(
"(?<=:)[^:\\s]*");
1168 QRegularExpressionMatchIterator i = re.globalMatch(fn_args);
1172 QRegularExpressionMatch
match = i.
next();
1173 fn <<
match.captured(0).remove(
"\"");
1177 for (
auto &sf : KStarsFunctionList)
1179 if (fn_name == sf->name())
1191 ScriptList.append(
new ScriptFunction(sf));
1193 for (
int i = 0; i < sf->numArgs(); ++i)
1194 ScriptList.last()->setArg(i, fn[i]);
1199 foreach (ScriptFunction *sf, SimClockFunctionList)
1201 if (fn_name == sf->name())
1203 if (fn.
count() != sf->numArgs())
1206 ScriptList.append(
new ScriptFunction(sf));
1208 for (
int i = 0; i < sf->numArgs(); ++i)
1209 ScriptList.last()->setArg(i, fn[i]);
1220void ScriptBuilder::setUnsavedChanges(
bool b)
1222 if (checkForChanges)
1225 sb->SaveButton->setEnabled(b);
1229void ScriptBuilder::slotCopyFunction()
1231 if (!UnsavedChanges)
1232 setUnsavedChanges(
true);
1234 int Pos = sb->ScriptListBox->currentRow() + 1;
1235 ScriptList.insert(Pos,
new ScriptFunction(ScriptList[Pos - 1]));
1237 for (
int i = 0; i < ScriptList[Pos - 1]->numArgs(); ++i)
1238 ScriptList[Pos]->setArg(i, ScriptList[Pos - 1]->argVal(i));
1240 sb->ScriptListBox->insertItem(Pos, ScriptList[Pos]->
name());
1242 sb->ScriptListBox->setCurrentRow(Pos);
1246void ScriptBuilder::slotRemoveFunction()
1248 setUnsavedChanges(
true);
1250 int Pos = sb->ScriptListBox->currentRow();
1251 ScriptList.removeAt(Pos);
1252 sb->ScriptListBox->takeItem(Pos);
1253 if (sb->ScriptListBox->count() == 0)
1255 sb->ArgStack->setCurrentWidget(argBlank);
1256 sb->CopyButton->setEnabled(
false);
1257 sb->RemoveButton->setEnabled(
false);
1258 sb->RunButton->setEnabled(
false);
1259 sb->SaveAsButton->setEnabled(
false);
1264 if (Pos == sb->ScriptListBox->count())
1268 sb->ScriptListBox->setCurrentRow(Pos);
1273void ScriptBuilder::slotAddFunction()
1275 ScriptFunction *found =
nullptr;
1276 QTreeWidgetItem *currentItem = sb->FunctionTree->currentItem();
1278 if (currentItem ==
nullptr || currentItem->
parent() ==
nullptr)
1281 for (
auto &sc : KStarsFunctionList)
1283 if (sc->prototype() == currentItem->
text(0))
1290 for (
auto &sc : SimClockFunctionList)
1292 if (sc->prototype() == currentItem->
text(0))
1299 if (found ==
nullptr)
1302 setUnsavedChanges(
true);
1304 int Pos = sb->ScriptListBox->currentRow() + 1;
1306 ScriptList.insert(Pos,
new ScriptFunction(found));
1307 sb->ScriptListBox->insertItem(Pos, ScriptList[Pos]->
name());
1308 sb->ScriptListBox->setCurrentRow(Pos);
1312void ScriptBuilder::slotMoveFunctionUp()
1314 if (sb->ScriptListBox->currentRow() > 0)
1316 setUnsavedChanges(
true);
1319 QString t = sb->ScriptListBox->currentItem()->text();
1320 unsigned int n = sb->ScriptListBox->currentRow();
1322 ScriptFunction *tmp = ScriptList.takeAt(n);
1323 ScriptList.insert(n - 1, tmp);
1325 sb->ScriptListBox->takeItem(n);
1326 sb->ScriptListBox->insertItem(n - 1, t);
1327 sb->ScriptListBox->setCurrentRow(n - 1);
1332void ScriptBuilder::slotMoveFunctionDown()
1334 if (sb->ScriptListBox->currentRow() > -1 && sb->ScriptListBox->currentRow() < ((
int)sb->ScriptListBox->count()) - 1)
1336 setUnsavedChanges(
true);
1338 QString t = sb->ScriptListBox->currentItem()->text();
1339 unsigned int n = sb->ScriptListBox->currentRow();
1341 ScriptFunction *tmp = ScriptList.takeAt(n);
1342 ScriptList.insert(n + 1, tmp);
1344 sb->ScriptListBox->takeItem(n);
1345 sb->ScriptListBox->insertItem(n + 1, t);
1346 sb->ScriptListBox->setCurrentRow(n + 1);
1351void ScriptBuilder::slotArgWidget()
1354 if (sb->ScriptListBox->currentRow() == -1)
1356 sb->CopyButton->setEnabled(
false);
1357 sb->RemoveButton->setEnabled(
false);
1358 sb->UpButton->setEnabled(
false);
1359 sb->DownButton->setEnabled(
false);
1361 else if (sb->ScriptListBox->count() == 1)
1363 sb->CopyButton->setEnabled(
true);
1364 sb->RemoveButton->setEnabled(
true);
1365 sb->UpButton->setEnabled(
false);
1366 sb->DownButton->setEnabled(
false);
1368 else if (sb->ScriptListBox->currentRow() == 0)
1370 sb->CopyButton->setEnabled(
true);
1371 sb->RemoveButton->setEnabled(
true);
1372 sb->UpButton->setEnabled(
false);
1373 sb->DownButton->setEnabled(
true);
1375 else if (sb->ScriptListBox->currentRow() == ((
int)sb->ScriptListBox->count()) - 1)
1377 sb->CopyButton->setEnabled(
true);
1378 sb->RemoveButton->setEnabled(
true);
1379 sb->UpButton->setEnabled(
true);
1380 sb->DownButton->setEnabled(
false);
1384 sb->CopyButton->setEnabled(
true);
1385 sb->RemoveButton->setEnabled(
true);
1386 sb->UpButton->setEnabled(
true);
1387 sb->DownButton->setEnabled(
true);
1391 if (sb->ScriptListBox->count())
1393 sb->RunButton->setEnabled(
true);
1394 sb->SaveAsButton->setEnabled(
true);
1398 sb->RunButton->setEnabled(
false);
1399 sb->SaveAsButton->setEnabled(
false);
1400 setUnsavedChanges(
false);
1404 if (sb->ScriptListBox->currentRow() > -1 && sb->ScriptListBox->currentRow() < ((
int)sb->ScriptListBox->count()))
1406 unsigned int n = sb->ScriptListBox->currentRow();
1407 ScriptFunction *sf = ScriptList.at(n);
1409 checkForChanges =
false;
1411 if (sf->name() ==
"lookTowards")
1413 sb->ArgStack->setCurrentWidget(argLookToward);
1414 QString s = sf->argVal(0);
1415 argLookToward->FocusEdit->setEditText(s);
1417 else if (sf->name() ==
"addLabel" || sf->name() ==
"removeLabel" || sf->name() ==
"addTrail" ||
1418 sf->name() ==
"removeTrail")
1420 sb->ArgStack->setCurrentWidget(argFindObject);
1421 QString s = sf->argVal(0);
1422 argFindObject->NameEdit->setText(s);
1424 else if (sf->name() ==
"setRaDec")
1427 double r(0.0), d(0.0);
1430 sb->ArgStack->setCurrentWidget(argSetRaDec);
1436 argSetRaDec->RABox->clear();
1440 argSetRaDec->RABox->show(ra);
1447 argSetRaDec->DecBox->clear();
1449 argSetRaDec->DecBox->show(dms(d));
1451 else if (sf->name() ==
"setAltAz")
1454 double x(0.0),
y(0.0);
1456 sb->ArgStack->setCurrentWidget(argSetAltAz);
1462 argSetAltAz->AzBox->clear();
1464 argSetAltAz->AltBox->show(dms(
y));
1466 argSetAltAz->AltBox->clear();
1471 argSetAltAz->AzBox->show(dms(
x));
1473 else if (sf->name() ==
"zoomIn")
1475 sb->ArgStack->setCurrentWidget(argBlank);
1478 else if (sf->name() ==
"zoomOut")
1480 sb->ArgStack->setCurrentWidget(argBlank);
1483 else if (sf->name() ==
"defaultZoom")
1485 sb->ArgStack->setCurrentWidget(argBlank);
1488 else if (sf->name() ==
"zoom")
1490 sb->ArgStack->setCurrentWidget(argZoom);
1494 argZoom->ZoomBox->setText(sf->argVal(0));
1496 argZoom->ZoomBox->setText(
"2000.");
1498 else if (sf->name() ==
"exportImage")
1500 sb->ArgStack->setCurrentWidget(argExportImage);
1504 w = sf->argVal(1).
toInt(&ok);
1506 h = sf->argVal(2).
toInt(&ok);
1509 argExportImage->ExportWidth->setValue(w);
1510 argExportImage->ExportHeight->setValue(h);
1514 argExportImage->ExportWidth->setValue(SkyMap::Instance()->
width());
1515 argExportImage->ExportHeight->setValue(SkyMap::Instance()->
height());
1518 else if (sf->name() ==
"printImage")
1520 if (sf->argVal(0) ==
i18n(
"true"))
1521 argPrintImage->UsePrintDialog->setChecked(
true);
1523 argPrintImage->UsePrintDialog->setChecked(
false);
1524 if (sf->argVal(1) ==
i18n(
"true"))
1525 argPrintImage->UseChartColors->setChecked(
true);
1527 argPrintImage->UseChartColors->setChecked(
false);
1529 else if (sf->name() ==
"setLocalTime")
1531 sb->ArgStack->setCurrentWidget(argSetLocalTime);
1533 int year = 0, month = 0, day = 0, hour = 0, min = 0, sec = 0;
1535 year = sf->argVal(0).
toInt(&ok);
1537 month = sf->argVal(1).
toInt(&ok);
1539 day = sf->argVal(2).
toInt(&ok);
1541 argSetLocalTime->DateWidget->setDate(QDate(year, month, day));
1545 hour = sf->argVal(3).
toInt(&ok);
1549 min = sf->argVal(4).
toInt(&ok);
1551 sec = sf->argVal(5).
toInt(&ok);
1553 argSetLocalTime->TimeBox->setTime(QTime(hour, min, sec));
1557 else if (sf->name() ==
"waitFor")
1559 sb->ArgStack->setCurrentWidget(argWaitFor);
1561 int sec = sf->argVal(0).
toInt(&ok);
1563 argWaitFor->DelayBox->setValue(sec);
1565 argWaitFor->DelayBox->setValue(0);
1567 else if (sf->name() ==
"waitForKey")
1569 sb->ArgStack->setCurrentWidget(argWaitForKey);
1570 if (sf->argVal(0).
length() == 1 || sf->argVal(0).
toLower() ==
"space")
1571 argWaitForKey->WaitKeyEdit->setText(sf->argVal(0));
1573 argWaitForKey->WaitKeyEdit->setText(QString());
1575 else if (sf->name() ==
"setTracking")
1577 sb->ArgStack->setCurrentWidget(argSetTracking);
1578 if (sf->argVal(0) ==
i18n(
"true"))
1579 argSetTracking->CheckTrack->setChecked(
true);
1581 argSetTracking->CheckTrack->setChecked(
false);
1583 else if (sf->name() ==
"changeViewOption")
1585 sb->ArgStack->setCurrentWidget(argChangeViewOption);
1586 argChangeViewOption->OptionName->setCurrentIndex(argChangeViewOption->OptionName->findText(sf->argVal(0)));
1587 argChangeViewOption->OptionValue->setText(sf->argVal(1));
1589 else if (sf->name() ==
"setGeoLocation")
1591 sb->ArgStack->setCurrentWidget(argSetGeoLocation);
1592 argSetGeoLocation->CityName->setText(sf->argVal(0));
1593 argSetGeoLocation->ProvinceName->setText(sf->argVal(1));
1594 argSetGeoLocation->CountryName->setText(sf->argVal(2));
1596 else if (sf->name() ==
"setColor")
1598 sb->ArgStack->setCurrentWidget(argSetColor);
1600 sf->setArg(0,
"SkyColor");
1601 argSetColor->ColorName->setCurrentIndex(
1602 argSetColor->ColorName->findText(KStarsData::Instance()->colorScheme()->nameFromKey(sf->argVal(0))));
1603 argSetColor->ColorValue->setColor(QColor(sf->argVal(1).
remove(
'\\')));
1605 else if (sf->name() ==
"loadColorScheme")
1607 sb->ArgStack->setCurrentWidget(argLoadColorScheme);
1608 argLoadColorScheme->SchemeList->setCurrentItem(
1611 else if (sf->name() ==
"stop")
1613 sb->ArgStack->setCurrentWidget(argBlank);
1616 else if (sf->name() ==
"start")
1618 sb->ArgStack->setCurrentWidget(argBlank);
1621 else if (sf->name() ==
"setClockScale")
1623 sb->ArgStack->setCurrentWidget(argTimeScale);
1625 double ts = sf->argVal(0).
toDouble(&ok);
1627 argTimeScale->TimeScale->tsbox()->changeScale(
float(ts));
1629 argTimeScale->TimeScale->tsbox()->changeScale(0.0);
1632 checkForChanges =
true;
1636void ScriptBuilder::slotShowDoc()
1638 ScriptFunction *found =
nullptr;
1639 QTreeWidgetItem *currentItem = sb->FunctionTree->currentItem();
1641 if (currentItem ==
nullptr || currentItem->
parent() ==
nullptr)
1644 for (
auto &sc : KStarsFunctionList)
1646 if (sc->prototype() == currentItem->
text(0))
1653 for (
auto &sc : SimClockFunctionList)
1655 if (sc->prototype() == currentItem->
text(0))
1662 if (found ==
nullptr)
1664 sb->AddButton->setEnabled(
false);
1665 qWarning() <<
i18n(
"Function index out of bounds.");
1669 sb->AddButton->setEnabled(
true);
1670 sb->FuncDoc->setHtml(found->description());
1674void ScriptBuilder::slotFindCity()
1676 QPointer<LocationDialog> ld =
new LocationDialog(
this);
1680 if (ld->selectedCity())
1683 argSetGeoLocation->CityName->setText(ld->selectedCityName());
1684 if (!ld->selectedProvinceName().isEmpty())
1686 argSetGeoLocation->ProvinceName->setText(ld->selectedProvinceName());
1690 argSetGeoLocation->ProvinceName->clear();
1692 argSetGeoLocation->CountryName->setText(ld->selectedCountryName());
1694 ScriptFunction *sf = ScriptList[sb->ScriptListBox->currentRow()];
1695 if (sf->name() ==
"setGeoLocation")
1697 setUnsavedChanges(
true);
1699 sf->setArg(0, ld->selectedCityName());
1700 sf->setArg(1, ld->selectedProvinceName());
1701 sf->setArg(2, ld->selectedCountryName());
1705 warningMismatch(
"setGeoLocation");
1712void ScriptBuilder::slotFindObject()
1716 setUnsavedChanges(
true);
1718 if (
sender() == argLookToward->FindButton)
1719 argLookToward->FocusEdit->setEditText(FindDialog::Instance()->targetObject()->
name());
1721 argFindObject->NameEdit->setText(FindDialog::Instance()->targetObject()->
name());
1725void ScriptBuilder::slotShowOptions()
1730 argChangeViewOption->OptionName->setCurrentIndex(
1731 argChangeViewOption->OptionName->findText(otv->optionsList()->currentItem()->text(0)));
1735void ScriptBuilder::slotLookToward()
1737 ScriptFunction *sf = ScriptList[sb->ScriptListBox->currentRow()];
1739 if (sf->name() ==
"lookTowards")
1741 setUnsavedChanges(
true);
1743 sf->setArg(0, argLookToward->FocusEdit->currentText());
1748 warningMismatch(
"lookTowards");
1752void ScriptBuilder::slotArgFindObject()
1754 ScriptFunction *sf = ScriptList[sb->ScriptListBox->currentRow()];
1756 if (sf->name() ==
"addLabel" || sf->name() ==
"removeLabel" || sf->name() ==
"addTrail" ||
1757 sf->name() ==
"removeTrail")
1759 setUnsavedChanges(
true);
1761 sf->setArg(0, argFindObject->NameEdit->text());
1766 warningMismatch(sf->name());
1770void ScriptBuilder::slotRa()
1772 ScriptFunction *sf = ScriptList[sb->ScriptListBox->currentRow()];
1774 if (sf->name() ==
"setRaDec")
1777 if (argSetRaDec->RABox->text().isEmpty())
1781 dms ra = argSetRaDec->RABox->createDms(&ok);
1784 setUnsavedChanges(
true);
1786 sf->setArg(0, QString(
"%1").arg(ra.
Hours()));
1792 sf->setArg(0, QString());
1793 sf->setValid(
false);
1798 warningMismatch(
"setRaDec");
1802void ScriptBuilder::slotDec()
1804 ScriptFunction *sf = ScriptList[sb->ScriptListBox->currentRow()];
1806 if (sf->name() ==
"setRaDec")
1809 if (argSetRaDec->DecBox->text().isEmpty())
1813 dms
dec = argSetRaDec->DecBox->createDms(&ok);
1816 setUnsavedChanges(
true);
1818 sf->setArg(1, QString(
"%1").arg(
dec.Degrees()));
1824 sf->setArg(1, QString());
1825 sf->setValid(
false);
1830 warningMismatch(
"setRaDec");
1834void ScriptBuilder::slotAz()
1836 ScriptFunction *sf = ScriptList[sb->ScriptListBox->currentRow()];
1838 if (sf->name() ==
"setAltAz")
1841 if (argSetAltAz->AzBox->text().isEmpty())
1845 dms az = argSetAltAz->AzBox->createDms(&ok);
1848 setUnsavedChanges(
true);
1849 sf->setArg(1, QString(
"%1").arg(az.
Degrees()));
1855 sf->setArg(1, QString());
1856 sf->setValid(
false);
1861 warningMismatch(
"setAltAz");
1865void ScriptBuilder::slotAlt()
1867 ScriptFunction *sf = ScriptList[sb->ScriptListBox->currentRow()];
1869 if (sf->name() ==
"setAltAz")
1872 if (argSetAltAz->AltBox->text().isEmpty())
1876 dms alt = argSetAltAz->AltBox->createDms(&ok);
1879 setUnsavedChanges(
true);
1881 sf->setArg(0, QString(
"%1").arg(alt.
Degrees()));
1887 sf->setArg(0, QString());
1888 sf->setValid(
false);
1893 warningMismatch(
"setAltAz");
1897void ScriptBuilder::slotChangeDate()
1899 ScriptFunction *sf = ScriptList[sb->ScriptListBox->currentRow()];
1901 if (sf->name() ==
"setLocalTime")
1903 setUnsavedChanges(
true);
1905 QDate date = argSetLocalTime->DateWidget->date();
1907 sf->setArg(0, QString(
"%1").arg(date.
year()));
1908 sf->setArg(1, QString(
"%1").arg(date.
month()));
1909 sf->setArg(2, QString(
"%1").arg(date.
day()));
1915 warningMismatch(
"setLocalTime");
1919void ScriptBuilder::slotChangeTime()
1921 ScriptFunction *sf = ScriptList[sb->ScriptListBox->currentRow()];
1923 if (sf->name() ==
"setLocalTime")
1925 setUnsavedChanges(
true);
1927 QTime time = argSetLocalTime->TimeBox->time();
1929 sf->setArg(3, QString(
"%1").arg(time.
hour()));
1930 sf->setArg(4, QString(
"%1").arg(time.
minute()));
1931 sf->setArg(5, QString(
"%1").arg(time.
second()));
1937 warningMismatch(
"setLocalTime");
1941void ScriptBuilder::slotWaitFor()
1943 ScriptFunction *sf = ScriptList[sb->ScriptListBox->currentRow()];
1945 if (sf->name() ==
"waitFor")
1948 int delay = argWaitFor->DelayBox->text().toInt(&ok);
1952 setUnsavedChanges(
true);
1954 sf->setArg(0, QString(
"%1").arg(delay));
1959 sf->setValid(
false);
1964 warningMismatch(
"waitFor");
1968void ScriptBuilder::slotWaitForKey()
1970 ScriptFunction *sf = ScriptList[sb->ScriptListBox->currentRow()];
1972 if (sf->name() ==
"waitForKey")
1974 QString sKey = argWaitForKey->WaitKeyEdit->text().trimmed();
1978 if (sKey.
length() == 1 || sKey ==
"space")
1980 setUnsavedChanges(
true);
1982 sf->setArg(0, sKey);
1987 sf->setValid(
false);
1992 warningMismatch(
"waitForKey");
1996void ScriptBuilder::slotTracking()
1998 ScriptFunction *sf = ScriptList[sb->ScriptListBox->currentRow()];
2000 if (sf->name() ==
"setTracking")
2002 setUnsavedChanges(
true);
2004 sf->setArg(0, (argSetTracking->CheckTrack->isChecked() ?
i18n(
"true") :
i18n(
"false")));
2009 warningMismatch(
"setTracking");
2013void ScriptBuilder::slotViewOption()
2015 ScriptFunction *sf = ScriptList[sb->ScriptListBox->currentRow()];
2017 if (sf->name() ==
"changeViewOption")
2019 if (argChangeViewOption->OptionName->currentIndex() >= 0 && argChangeViewOption->OptionValue->text().length())
2021 setUnsavedChanges(
true);
2023 sf->setArg(0, argChangeViewOption->OptionName->currentText());
2024 sf->setArg(1, argChangeViewOption->OptionValue->text());
2029 sf->setValid(
false);
2034 warningMismatch(
"changeViewOption");
2038void ScriptBuilder::slotChangeCity()
2040 ScriptFunction *sf = ScriptList[sb->ScriptListBox->currentRow()];
2042 if (sf->name() ==
"setGeoLocation")
2044 QString city = argSetGeoLocation->CityName->text();
2048 setUnsavedChanges(
true);
2050 sf->setArg(0, city);
2051 if (sf->argVal(2).
length())
2056 sf->setArg(0, QString());
2057 sf->setValid(
false);
2062 warningMismatch(
"setGeoLocation");
2066void ScriptBuilder::slotChangeProvince()
2068 ScriptFunction *sf = ScriptList[sb->ScriptListBox->currentRow()];
2070 if (sf->name() ==
"setGeoLocation")
2072 QString province = argSetGeoLocation->ProvinceName->text();
2076 setUnsavedChanges(
true);
2078 sf->setArg(1, province);
2084 sf->setArg(1, QString());
2090 warningMismatch(
"setGeoLocation");
2094void ScriptBuilder::slotChangeCountry()
2096 ScriptFunction *sf = ScriptList[sb->ScriptListBox->currentRow()];
2098 if (sf->name() ==
"setGeoLocation")
2100 QString
country = argSetGeoLocation->CountryName->text();
2104 setUnsavedChanges(
true);
2106 sf->setArg(2, country);
2107 if (sf->argVal(0).
length())
2112 sf->setArg(2, QString());
2113 sf->setValid(
false);
2118 warningMismatch(
"setGeoLocation");
2122void ScriptBuilder::slotTimeScale()
2124 ScriptFunction *sf = ScriptList[sb->ScriptListBox->currentRow()];
2126 if (sf->name() ==
"setClockScale")
2128 setUnsavedChanges(
true);
2130 sf->setArg(0, QString(
"%1").arg(argTimeScale->TimeScale->tsbox()->timeScale()));
2135 warningMismatch(
"setClockScale");
2139void ScriptBuilder::slotZoom()
2141 ScriptFunction *sf = ScriptList[sb->ScriptListBox->currentRow()];
2143 if (sf->name() ==
"zoom")
2145 setUnsavedChanges(
true);
2148 argZoom->ZoomBox->text().toDouble(&ok);
2151 sf->setArg(0, argZoom->ZoomBox->text());
2157 warningMismatch(
"zoom");
2161void ScriptBuilder::slotExportImage()
2163 ScriptFunction *sf = ScriptList[sb->ScriptListBox->currentRow()];
2165 if (sf->name() ==
"exportImage")
2167 setUnsavedChanges(
true);
2169 sf->setArg(0, argExportImage->ExportFileName->url().url());
2170 sf->setArg(1, QString(
"%1").arg(argExportImage->ExportWidth->value()));
2171 sf->setArg(2, QString(
"%1").arg(argExportImage->ExportHeight->value()));
2176 warningMismatch(
"exportImage");
2180void ScriptBuilder::slotPrintImage()
2182 ScriptFunction *sf = ScriptList[sb->ScriptListBox->currentRow()];
2184 if (sf->name() ==
"printImage")
2186 setUnsavedChanges(
true);
2188 sf->setArg(0, (argPrintImage->UsePrintDialog->isChecked() ?
i18n(
"true") :
i18n(
"false")));
2189 sf->setArg(1, (argPrintImage->UseChartColors->isChecked() ?
i18n(
"true") :
i18n(
"false")));
2194 warningMismatch(
"exportImage");
2198void ScriptBuilder::slotChangeColorName()
2200 ScriptFunction *sf = ScriptList[sb->ScriptListBox->currentRow()];
2202 if (sf->name() ==
"setColor")
2204 setUnsavedChanges(
true);
2206 argSetColor->ColorValue->setColor(KStarsData::Instance()->colorScheme()->colorAt(argSetColor->ColorName->currentIndex()));
2207 sf->setArg(0, KStarsData::Instance()->colorScheme()->keyAt(argSetColor->ColorName->currentIndex()));
2208 QString cname(argSetColor->ColorValue->color().name());
2210 sf->setArg(1, cname);
2215 warningMismatch(
"setColor");
2219void ScriptBuilder::slotChangeColor()
2221 ScriptFunction *sf = ScriptList[sb->ScriptListBox->currentRow()];
2223 if (sf->name() ==
"setColor")
2225 setUnsavedChanges(
true);
2227 sf->setArg(0, KStarsData::Instance()->colorScheme()->keyAt(argSetColor->ColorName->currentIndex()));
2228 QString cname(argSetColor->ColorValue->color().name());
2230 sf->setArg(1, cname);
2235 warningMismatch(
"setColor");
2239void ScriptBuilder::slotLoadColorScheme()
2241 ScriptFunction *sf = ScriptList[sb->ScriptListBox->currentRow()];
2243 if (sf->name() ==
"loadColorScheme")
2245 setUnsavedChanges(
true);
2247 sf->setArg(0,
'\"' + argLoadColorScheme->SchemeList->currentItem()->text() +
'\"');
2252 warningMismatch(
"loadColorScheme");
2256void ScriptBuilder::slotClose()
2260 if (!UnsavedChanges)
2263 sb->ScriptListBox->clear();
2264 sb->ArgStack->setCurrentWidget(argBlank);
2272void ScriptBuilder::slotINDIStartDeviceName()
2274 ScriptFunction * sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2276 if ( sf->name() ==
"startINDI" )
2278 setUnsavedChanges(
true );
2280 sf->setArg(0, argStartINDI->deviceName->text());
2281 sf->setArg(1, argStartINDI->LocalButton->isChecked() ?
"true" :
"false");
2286 warningMismatch(
"startINDI" );
2291void ScriptBuilder::slotINDIStartDeviceMode()
2294 ScriptFunction * sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2296 if ( sf->name() ==
"startINDI" )
2298 setUnsavedChanges(
true );
2300 sf->setArg(1, argStartINDI->LocalButton->isChecked() ?
"true" :
"false");
2305 warningMismatch(
"startINDI" );
2310void ScriptBuilder::slotINDISetDevice()
2313 ScriptFunction * sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2315 if ( sf->name() ==
"setINDIDevice" )
2317 setUnsavedChanges(
true );
2319 sf->setArg(0, argSetDeviceINDI->deviceName->text());
2324 warningMismatch(
"startINDI" );
2328void ScriptBuilder::slotINDIShutdown()
2331 ScriptFunction * sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2333 if ( sf->name() ==
"shutdownINDI" )
2335 if (argShutdownINDI->deviceName->text().isEmpty())
2337 sf->setValid(
false);
2341 if (sf->argVal(0) != argShutdownINDI->deviceName->text())
2342 setUnsavedChanges(
true );
2344 sf->setArg(0, argShutdownINDI->deviceName->text());
2349 warningMismatch(
"shutdownINDI" );
2354void ScriptBuilder::slotINDISwitchDeviceConnection()
2357 ScriptFunction * sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2359 if ( sf->name() ==
"switchINDI" )
2362 if (sf->argVal(0) != (argSwitchINDI->OnButton->isChecked() ?
"true" :
"false"))
2363 setUnsavedChanges(
true );
2365 sf->setArg(0, argSwitchINDI->OnButton->isChecked() ?
"true" :
"false");
2370 warningMismatch(
"switchINDI" );
2375void ScriptBuilder::slotINDISetPortDevicePort()
2377 ScriptFunction * sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2379 if ( sf->name() ==
"setINDIPort" )
2382 if (argSetPortINDI->devicePort->text().isEmpty())
2384 sf->setValid(
false);
2388 if (sf->argVal(0) != argSetPortINDI->devicePort->text())
2389 setUnsavedChanges(
true );
2391 sf->setArg(0, argSetPortINDI->devicePort->text());
2396 warningMismatch(
"setINDIPort" );
2401void ScriptBuilder::slotINDISetTargetCoordDeviceRA()
2403 ScriptFunction * sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2405 if ( sf->name() ==
"setINDITargetCoord" )
2408 if ( argSetTargetCoordINDI->RABox->text().isEmpty() )
2410 sf->setValid(
false);
2415 dms ra = argSetTargetCoordINDI->RABox->createDms(&ok);
2419 if (sf->argVal(0) != QString(
"%1" ).arg( ra.
Hours() ))
2420 setUnsavedChanges(
true );
2422 sf->setArg( 0, QString(
"%1" ).arg( ra.
Hours() ) );
2423 if ( ( ! sf->argVal(1).
isEmpty() ))
2424 sf->setValid(
true );
2426 sf->setValid(
false);
2431 sf->setArg( 0, QString() );
2432 sf->setValid(
false );
2437 warningMismatch(
"setINDITargetCoord" );
2442void ScriptBuilder::slotINDISetTargetCoordDeviceDEC()
2444 ScriptFunction * sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2446 if ( sf->name() ==
"setINDITargetCoord" )
2449 if ( argSetTargetCoordINDI->DecBox->text().isEmpty() )
2451 sf->setValid(
false);
2456 dms
dec = argSetTargetCoordINDI->DecBox->createDms(&ok);
2460 if (sf->argVal(1) != QString(
"%1" ).arg(
dec.Degrees() ))
2461 setUnsavedChanges(
true );
2463 sf->setArg( 1, QString(
"%1" ).arg(
dec.Degrees() ) );
2464 if ( ( ! sf->argVal(0).
isEmpty() ))
2465 sf->setValid(
true );
2467 sf->setValid(
false);
2472 sf->setArg( 1, QString() );
2473 sf->setValid(
false );
2478 warningMismatch(
"setINDITargetCoord" );
2483void ScriptBuilder::slotINDIsetCoreProperty(SequenceJob::SJ_TargetName,TargetName()
2486 ScriptFunction * sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2488 if ( sf->name() ==
"setINDITargetName" )
2490 if (argsetCoreProperty(SequenceJob::SJ_TargetName,INDI->targetName->text().isEmpty())
2492 sf->setValid(false);
2496 if (sf->argVal(0) != argsetCoreProperty(SequenceJob::SJ_TargetName,INDI->targetName->text())
2497 setUnsavedChanges(
true );
2499 sf->setArg(0, argsetCoreProperty(SequenceJob::SJ_TargetName,INDI->targetName->text());
2504 warningMismatch(
"setINDITargetName" );
2509void ScriptBuilder::slotINDISetActionName()
2511 ScriptFunction * sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2513 if ( sf->name() ==
"setINDIAction" )
2515 if (argSetActionINDI->actionName->text().isEmpty())
2517 sf->setValid(
false);
2521 if (sf->argVal(0) != argSetActionINDI->actionName->text())
2522 setUnsavedChanges(
true );
2524 sf->setArg(0, argSetActionINDI->actionName->text());
2529 warningMismatch(
"setINDIAction" );
2534void ScriptBuilder::slotINDIWaitForActionName()
2536 ScriptFunction * sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2538 if ( sf->name() ==
"waitForINDIAction" )
2540 if (argWaitForActionINDI->actionName->text().isEmpty())
2542 sf->setValid(
false);
2546 if (sf->argVal(0) != argWaitForActionINDI->actionName->text())
2547 setUnsavedChanges(
true );
2549 sf->setArg(0, argWaitForActionINDI->actionName->text());
2554 warningMismatch(
"waitForINDIAction" );
2559void ScriptBuilder::slotINDISetFocusSpeed()
2561 ScriptFunction * sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2563 if ( sf->name() ==
"setINDIFocusSpeed" )
2566 if (sf->argVal(0).
toInt() != argSetFocusSpeedINDI->speedIN->value())
2567 setUnsavedChanges(
true );
2569 sf->setArg(0, QString(
"%1").arg(argSetFocusSpeedINDI->speedIN->value()));
2574 warningMismatch(
"setINDIFocusSpeed" );
2579void ScriptBuilder::slotINDIStartFocusDirection()
2581 ScriptFunction * sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2583 if ( sf->name() ==
"startINDIFocus" )
2585 if (sf->argVal(0) != argStartFocusINDI->directionCombo->currentText())
2586 setUnsavedChanges(
true );
2588 sf->setArg(0, argStartFocusINDI->directionCombo->currentText());
2593 warningMismatch(
"startINDIFocus" );
2598void ScriptBuilder::slotINDISetFocusTimeout()
2600 ScriptFunction * sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2602 if ( sf->name() ==
"setINDIFocusTimeout" )
2604 if (sf->argVal(0).
toInt() != argSetFocusTimeoutINDI->timeOut->value())
2605 setUnsavedChanges(
true );
2607 sf->setArg(0, QString(
"%1").arg(argSetFocusTimeoutINDI->timeOut->value()));
2612 warningMismatch(
"setINDIFocusTimeout" );
2617void ScriptBuilder::slotINDISetGeoLocationDeviceLong()
2619 ScriptFunction * sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2621 if ( sf->name() ==
"setINDIGeoLocation" )
2624 if ( argSetGeoLocationINDI->longBox->text().isEmpty())
2626 sf->setValid(
false);
2631 dms longitude = argSetGeoLocationINDI->longBox->createDms(&ok);
2635 if (sf->argVal(0) != QString(
"%1" ).arg( longitude.
Degrees()))
2636 setUnsavedChanges(
true );
2638 sf->setArg( 0, QString(
"%1" ).arg( longitude.
Degrees() ) );
2639 if ( ! sf->argVal(1).
isEmpty() )
2640 sf->setValid(
true );
2642 sf->setValid(
false);
2647 sf->setArg( 0, QString() );
2648 sf->setValid(
false );
2653 warningMismatch(
"setINDIGeoLocation" );
2658void ScriptBuilder::slotINDISetGeoLocationDeviceLat()
2660 ScriptFunction * sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2662 if ( sf->name() ==
"setINDIGeoLocation" )
2665 if ( argSetGeoLocationINDI->latBox->text().isEmpty() )
2667 sf->setValid(
false);
2672 dms latitude = argSetGeoLocationINDI->latBox->createDms(&ok);
2676 if (sf->argVal(1) != QString(
"%1" ).arg( latitude.
Degrees()))
2677 setUnsavedChanges(
true );
2679 sf->setArg( 1, QString(
"%1" ).arg( latitude.
Degrees() ) );
2680 if ( ! sf->argVal(0).
isEmpty() )
2681 sf->setValid(
true );
2683 sf->setValid(
false);
2688 sf->setArg( 1, QString() );
2689 sf->setValid(
false );
2694 warningMismatch(
"setINDIGeoLocation" );
2699void ScriptBuilder::slotINDIStartExposureTimeout()
2701 ScriptFunction * sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2703 if ( sf->name() ==
"startINDIExposure" )
2706 if (sf->argVal(0).
toInt() != argStartExposureINDI->timeOut->value())
2707 setUnsavedChanges(
true );
2709 sf->setArg(0, QString(
"%1").arg(argStartExposureINDI->timeOut->value()));
2714 warningMismatch(
"startINDIExposure" );
2719void ScriptBuilder::slotINDISetUTC()
2721 ScriptFunction * sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2723 if ( sf->name() ==
"setINDIUTC" )
2726 if (argSetUTCINDI->UTC->text().isEmpty())
2728 sf->setValid(
false);
2732 if (sf->argVal(0) != argSetUTCINDI->UTC->text())
2733 setUnsavedChanges(
true );
2735 sf->setArg(0, argSetUTCINDI->UTC->text());
2740 warningMismatch(
"setINDIUTC" );
2745void ScriptBuilder::slotINDISetScopeAction()
2747 ScriptFunction * sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2749 if ( sf->name() ==
"setINDIScopeAction" )
2752 if (sf->argVal(0) != argSetScopeActionINDI->actionCombo->currentText())
2753 setUnsavedChanges(
true );
2755 sf->setArg(0, argSetScopeActionINDI->actionCombo->currentText());
2756 sf->setINDIProperty(
"CHECK");
2761 warningMismatch(
"setINDIScopeAction" );
2766void ScriptBuilder::slotINDISetFrameType()
2768 ScriptFunction * sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2770 if ( sf->name() ==
"setINDIFrameType" )
2773 if (sf->argVal(0) != argSetFrameTypeINDI->typeCombo->currentText())
2774 setUnsavedChanges(
true );
2776 sf->setArg(0, argSetFrameTypeINDI->typeCombo->currentText());
2781 warningMismatch(
"setINDIFrameType" );
2786void ScriptBuilder::slotINDISetCCDTemp()
2788 ScriptFunction * sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2790 if ( sf->name() ==
"setINDICCDTemp" )
2793 if (sf->argVal(0).
toInt() != argSetCCDTempINDI->temp->value())
2794 setUnsavedChanges(
true );
2796 sf->setArg(0, QString(
"%1").arg(argSetCCDTempINDI->temp->value()));
2801 warningMismatch(
"setINDICCDTemp" );
2806void ScriptBuilder::slotINDISetFilterNum()
2809 ScriptFunction * sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2811 if ( sf->name() ==
"setINDIFilterNum" )
2814 if (sf->argVal(0).
toInt() != argSetFilterNumINDI->filter_num->value())
2815 setUnsavedChanges(
true );
2817 sf->setArg(0, QString(
"%1").arg(argSetFilterNumINDI->filter_num->value()));
2822 warningMismatch(
"setINDIFilterNum" );
2829void ScriptBuilder::warningMismatch(
const QString &expected)
const
2831 qWarning() <<
i18n(
"Mismatch between function and Arg widget (expected %1.)", QString(expected));
unsigned int numberOfColors() const
ColorScheme * colorScheme()
static KStarsDateTime currentDateTime()
static KStars * Instance()
const double & Degrees() const
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
KCOREADDONS_EXPORT Result match(QStringView pattern, QStringView str)
KIOCORE_EXPORT ChmodJob * chmod(const KFileItemList &lstItems, int permissions, int mask, const QString &newOwner, const QString &newGroup, bool recursive, JobFlags flags=DefaultFlags)
KIOCORE_EXPORT StoredTransferJob * storedHttpPost(const QByteArray &arr, const QUrl &url, JobFlags flags=DefaultFlags)
KIOCORE_EXPORT CopyJob * copy(const QList< QUrl > &src, const QUrl &dest, JobFlags flags=DefaultFlags)
QString path(const QString &relativePath)
ButtonCode warningContinueCancel(QWidget *parent, const QString &text, const QString &title=QString(), const KGuiItem &buttonContinue=KStandardGuiItem::cont(), const KGuiItem &buttonCancel=KStandardGuiItem::cancel(), const QString &dontAskAgainName=QString(), Options options=Notify)
QString name(StandardAction id)
KI18NLOCALEDATA_EXPORT KCountry country(const char *ianaId)
QString applicationDirPath()
QString toString(QStringView format, QCalendar cal) const const
QByteArray encodeName(const QString &fileName)
bool exists() const const
bool open(FILE *fh, OpenMode mode, FileHandleFlags handleFlags)
void setFileName(const QString &name)
virtual void close() override
QUrl getOpenFileUrl(QWidget *parent, const QString &caption, const QUrl &dir, const QString &filter, QString *selectedFilter, Options options, const QStringList &supportedSchemes)
QUrl getSaveFileUrl(QWidget *parent, const QString &caption, const QUrl &dir, const QString &filter, QString *selectedFilter, Options options, const QStringList &supportedSchemes)
int horizontalAdvance(QChar ch) const const
QIcon fromTheme(const QString &name)
qsizetype count() const const
QObject * parent() const const
QObject * sender() const const
void setProcessEnvironment(const QProcessEnvironment &environment)
void start(OpenMode mode)
QProcess::ProcessState state() const const
bool waitForFinished(int msecs)
bool waitForStarted(int msecs)
void insert(const QProcessEnvironment &e)
QProcessEnvironment systemEnvironment()
QString value(const QString &name, const QString &defaultValue) const const
bool hasNext() const const
QRegularExpressionMatch next()
qsizetype count() const const
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
qsizetype indexOf(QChar ch, qsizetype from, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
qsizetype lastIndexOf(QChar ch, Qt::CaseSensitivity cs) const const
QString left(qsizetype n) const const
qsizetype length() const const
QString mid(qsizetype position, qsizetype n) const const
QString & remove(QChar ch, Qt::CaseSensitivity cs)
QString right(qsizetype n) const const
double toDouble(bool *ok) const const
int toInt(bool *ok, int base) const const
QByteArray toLatin1() const const
QString toLower() const const
QString trimmed() const const
QTextStream & dec(QTextStream &stream)
virtual QString fileName() const const override
QString readLine(qint64 maxlen)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QString text(int column) const const