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 };
75 for (
int j = 0; j < topitem->
childCount(); ++j)
79 for (
int icol = 0; icol < 3; ++icol)
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]);
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();
400void ScriptBuilder::initViewOptions()
407 fields <<
"ShowInfoBoxes" <<
i18n(
"Toggle display of all InfoBoxes") <<
i18n(
"bool");
410 fields <<
"ShowTimeBox" <<
i18n(
"Toggle display of Time InfoBox") <<
i18n(
"bool");
413 fields <<
"ShowGeoBox" <<
i18n(
"Toggle display of Geographic InfoBox") <<
i18n(
"bool");
416 fields <<
"ShowFocusBox" <<
i18n(
"Toggle display of Focus InfoBox") <<
i18n(
"bool");
419 fields <<
"ShadeTimeBox" <<
i18n(
"(un)Shade Time InfoBox") <<
i18n(
"bool");
422 fields <<
"ShadeGeoBox" <<
i18n(
"(un)Shade Geographic InfoBox") <<
i18n(
"bool");
425 fields <<
"ShadeFocusBox" <<
i18n(
"(un)Shade Focus InfoBox") <<
i18n(
"bool");
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");
439 fields <<
"ShowMainToolBar" <<
i18n(
"Toggle display of main toolbar") <<
i18n(
"bool");
442 fields <<
"ShowViewToolBar" <<
i18n(
"Toggle display of view toolbar") <<
i18n(
"bool");
446 argChangeViewOption->OptionName->addItem(
"ShowMainToolBar");
447 argChangeViewOption->OptionName->addItem(
"ShowViewToolBar");
451 fields <<
"ShowStars" <<
i18n(
"Toggle display of Stars") <<
i18n(
"bool");
454 fields <<
"ShowDeepSky" <<
i18n(
"Toggle display of all deep-sky objects") <<
i18n(
"bool");
461 fields <<
"ShowSolarSystem" <<
i18n(
"Toggle display of all solar system bodies") <<
i18n(
"bool");
464 fields <<
"ShowSun" <<
i18n(
"Toggle display of Sun") <<
i18n(
"bool");
467 fields <<
"ShowMoon" <<
i18n(
"Toggle display of Moon") <<
i18n(
"bool");
470 fields <<
"ShowMercury" <<
i18n(
"Toggle display of Mercury") <<
i18n(
"bool");
473 fields <<
"ShowVenus" <<
i18n(
"Toggle display of Venus") <<
i18n(
"bool");
476 fields <<
"ShowMars" <<
i18n(
"Toggle display of Mars") <<
i18n(
"bool");
479 fields <<
"ShowJupiter" <<
i18n(
"Toggle display of Jupiter") <<
i18n(
"bool");
482 fields <<
"ShowSaturn" <<
i18n(
"Toggle display of Saturn") <<
i18n(
"bool");
485 fields <<
"ShowUranus" <<
i18n(
"Toggle display of Uranus") <<
i18n(
"bool");
488 fields <<
"ShowNeptune" <<
i18n(
"Toggle display of Neptune") <<
i18n(
"bool");
494 fields <<
"ShowAsteroids" <<
i18n(
"Toggle display of Asteroids") <<
i18n(
"bool");
497 fields <<
"ShowComets" <<
i18n(
"Toggle display of Comets") <<
i18n(
"bool");
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");
518 fields <<
"ShowCLines" <<
i18n(
"Toggle display of constellation lines") <<
i18n(
"bool");
521 fields <<
"ShowCBounds" <<
i18n(
"Toggle display of constellation boundaries") <<
i18n(
"bool");
524 fields <<
"ShowCNames" <<
i18n(
"Toggle display of constellation names") <<
i18n(
"bool");
527 fields <<
"ShowMilkyWay" <<
i18n(
"Toggle display of Milky Way") <<
i18n(
"bool");
530 fields <<
"ShowGrid" <<
i18n(
"Toggle display of the coordinate grid") <<
i18n(
"bool");
533 fields <<
"ShowEquator" <<
i18n(
"Toggle display of the celestial equator") <<
i18n(
"bool");
536 fields <<
"ShowEcliptic" <<
i18n(
"Toggle display of the ecliptic") <<
i18n(
"bool");
539 fields <<
"ShowHorizon" <<
i18n(
"Toggle display of the horizon line") <<
i18n(
"bool");
542 fields <<
"ShowGround" <<
i18n(
"Toggle display of the opaque ground") <<
i18n(
"bool");
545 fields <<
"ShowStarNames" <<
i18n(
"Toggle display of star name labels") <<
i18n(
"bool");
548 fields <<
"ShowStarMagnitudes" <<
i18n(
"Toggle display of star magnitude labels") <<
i18n(
"bool");
551 fields <<
"ShowAsteroidNames" <<
i18n(
"Toggle display of asteroid name labels") <<
i18n(
"bool");
554 fields <<
"ShowCometNames" <<
i18n(
"Toggle display of comet name labels") <<
i18n(
"bool");
557 fields <<
"ShowPlanetNames" <<
i18n(
"Toggle display of planet name labels") <<
i18n(
"bool");
560 fields <<
"ShowPlanetImages" <<
i18n(
"Toggle display of planet images") <<
i18n(
"bool");
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");
581 fields <<
"UseLatinConstellNames" <<
i18n(
"Show Latin constellation names") <<
i18n(
"bool");
584 fields <<
"UseLocalConstellNames" <<
i18n(
"Show constellation names in local language") <<
i18n(
"bool");
587 fields <<
"UseAbbrevConstellNames" <<
i18n(
"Show IAU-standard constellation abbreviations") <<
i18n(
"bool");
591 argChangeViewOption->OptionName->addItem(
"UseLatinConstellNames");
592 argChangeViewOption->OptionName->addItem(
"UseLocalConstellNames");
593 argChangeViewOption->OptionName->addItem(
"UseAbbrevConstellNames");
596 fields <<
"HideOnSlew" <<
i18n(
"Toggle whether objects hidden while slewing display") <<
i18n(
"bool");
599 fields <<
"SlewTimeScale" <<
i18n(
"Timestep threshold (in seconds) for hiding objects") <<
i18n(
"double");
602 fields <<
"HideStars" <<
i18n(
"Hide faint stars while slewing?") <<
i18n(
"bool");
605 fields <<
"HidePlanets" <<
i18n(
"Hide solar system bodies while slewing?") <<
i18n(
"bool");
608 fields <<
"HideMilkyWay" <<
i18n(
"Hide Milky Way while slewing?") <<
i18n(
"bool");
611 fields <<
"HideCNames" <<
i18n(
"Hide constellation names while slewing?") <<
i18n(
"bool");
614 fields <<
"HideCLines" <<
i18n(
"Hide constellation lines while slewing?") <<
i18n(
"bool");
617 fields <<
"HideCBounds" <<
i18n(
"Hide constellation boundaries while slewing?") <<
i18n(
"bool");
620 fields <<
"HideGrid" <<
i18n(
"Hide coordinate grid while slewing?") <<
i18n(
"bool");
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");
635 fields <<
"UseAltAz" <<
i18n(
"Use Horizontal coordinates? (otherwise, use Equatorial)") <<
i18n(
"bool");
638 fields <<
"ZoomFactor" <<
i18n(
"Set the Zoom Factor") <<
i18n(
"double");
641 fields <<
"FOVName" <<
i18n(
"Select angular size for the FOV symbol (in arcmin)") <<
i18n(
"double");
644 fields <<
"FOVShape" <<
i18n(
"Select shape for the FOV symbol (0=Square, 1=Circle, 2=Crosshairs, 4=Bullseye)")
648 fields <<
"FOVColor" <<
i18n(
"Select color for the FOV symbol") <<
i18n(
"string");
651 fields <<
"UseAnimatedSlewing" <<
i18n(
"Use animated slewing? (otherwise, \"snap\" to new focus)") <<
i18n(
"bool");
654 fields <<
"UseRefraction" <<
i18n(
"Correct for atmospheric refraction?") <<
i18n(
"bool");
657 fields <<
"UseAutoLabel" <<
i18n(
"Automatically attach name label to centered object?") <<
i18n(
"bool");
660 fields <<
"UseHoverLabel" <<
i18n(
"Attach temporary name label when hovering mouse over an object?")
664 fields <<
"UseAutoTrail" <<
i18n(
"Automatically add trail to centered solar system body?") <<
i18n(
"bool");
667 fields <<
"FadePlanetTrails" <<
i18n(
"Planet trails fade to sky color? (otherwise color is constant)")
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");
706 fields <<
"starLabelDensity" <<
i18n(
"magnitude of faintest star labeled on map") <<
i18n(
"double");
709 fields <<
"magLimitHideStar" <<
i18n(
"magnitude of brightest star hidden while slewing") <<
i18n(
"double");
712 fields <<
"magLimitAsteroid" <<
i18n(
"magnitude of faintest asteroid drawn on map") <<
i18n(
"double");
716 fields <<
"asteroidLabelDensity" <<
i18n(
"magnitude of faintest asteroid labeled on map") <<
i18n(
"double");
719 fields <<
"maxRadCometName" <<
i18n(
"comets nearer to the Sun than this (in AU) are labeled on map")
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"));
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);
778 currentFileURL.
clear();
779 currentScriptName.
clear();
783void ScriptBuilder::slotOpen()
795 "*.kstars|" +
i18nc(
"Filter by file type: KStars Scripts.",
"KStars Scripts (*.kstars)"));
802 sb->ScriptListBox->clear();
803 sb->ArgStack->setCurrentWidget(argBlank);
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();
832 KSNotification::sorry(
i18n(
"Invalid URL: %1", currentFileURL.
url()),
i18n(
"Invalid URL"));
833 currentFileURL.
clear();
838void ScriptBuilder::slotSave()
844 if (currentScriptName.
isEmpty())
849 currentScriptName = snd->scriptName();
850 currentAuthor = snd->authorName();
858 bool newFilename =
false;
863 "*.kstars|" +
i18nc(
"Filter by file type: KStars Scripts.",
"KStars Scripts (*.kstars)"));
879 i18n(
"A file named \"%1\" already exists. "
899 QString message =
i18n(
"Could not open file %1.", f.fileName());
900 KSNotification::sorry(message,
i18n(
"Could Not Open File"));
901 currentFileURL.
clear();
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);
930 KSNotification::sorry(message,
i18n(
"Invalid URL"));
931 currentFileURL.
clear();
935void ScriptBuilder::slotSaveAs()
937 currentFileURL.
clear();
938 currentScriptName.
clear();
942void ScriptBuilder::saveWarning()
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();
989 writeScript(ostream);
994 chmod(
QFile::encodeName(f.fileName()), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
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';
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)
1173 fn <<
match.captured(0).remove(
"\"");
1177 for (
auto &sf : KStarsFunctionList)
1179 if (fn_name == sf->name())
1193 for (
int i = 0; i < sf->numArgs(); ++i)
1194 ScriptList.
last()->setArg(i, fn[i]);
1201 if (fn_name == sf->name())
1203 if (fn.
count() != sf->numArgs())
1208 for (
int i = 0; i < sf->numArgs(); ++i)
1209 ScriptList.
last()->setArg(i, fn[i]);
1220void ScriptBuilder::setUnsavedChanges(
bool b)
1222 if (checkForChanges)
1229void ScriptBuilder::slotCopyFunction()
1231 if (!UnsavedChanges)
1232 setUnsavedChanges(
true);
1234 int Pos = sb->ScriptListBox->currentRow() + 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();
1252 sb->ScriptListBox->takeItem(Pos);
1253 if (sb->ScriptListBox->count() == 0)
1255 sb->ArgStack->setCurrentWidget(argBlank);
1264 if (Pos == sb->ScriptListBox->count())
1268 sb->ScriptListBox->setCurrentRow(Pos);
1273void ScriptBuilder::slotAddFunction()
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;
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();
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();
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)
1361 else if (sb->ScriptListBox->count() == 1)
1368 else if (sb->ScriptListBox->currentRow() == 0)
1375 else if (sb->ScriptListBox->currentRow() == ((
int)sb->ScriptListBox->count()) - 1)
1391 if (sb->ScriptListBox->count())
1400 setUnsavedChanges(
false);
1404 if (sb->ScriptListBox->currentRow() > -1 && sb->ScriptListBox->currentRow() < ((
int)sb->ScriptListBox->count()))
1406 unsigned int n = sb->ScriptListBox->currentRow();
1409 checkForChanges =
false;
1411 if (sf->name() ==
"lookTowards")
1413 sb->ArgStack->setCurrentWidget(argLookToward);
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);
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();
1466 argSetAltAz->AltBox->clear();
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()
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)
1665 qWarning() <<
i18n(
"Function index out of bounds.");
1670 sb->FuncDoc->setHtml(found->description());
1674void ScriptBuilder::slotFindCity()
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);
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()));
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);
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);
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();
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();
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())
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);
2090 warningMismatch(
"setGeoLocation");
2094void ScriptBuilder::slotChangeCountry()
2096 ScriptFunction *sf = ScriptList[sb->ScriptListBox->currentRow()];
2098 if (sf->name() ==
"setGeoLocation")
2104 setUnsavedChanges(
true);
2106 sf->setArg(2, country);
2107 if (sf->argVal(0).
length())
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 );
2423 if ( ( ! sf->argVal(1).
isEmpty() ))
2424 sf->setValid(
true );
2426 sf->setValid(
false);
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);
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);
2636 setUnsavedChanges(
true );
2639 if ( ! sf->argVal(1).
isEmpty() )
2640 sf->setValid(
true );
2642 sf->setValid(
false);
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);
2677 setUnsavedChanges(
true );
2680 if ( ! sf->argVal(0).
isEmpty() )
2681 sf->setValid(
true );
2683 sf->setValid(
false);
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()
Dialog for changing the geographic location of the observer.
An angle, stored as degrees, but expressible in many ways.
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)
QString name(GameStandardAction id)
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)
QStringView country(QStringView ifopt)
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)
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
qsizetype count() const const
iterator insert(const_iterator before, parameter_type value)
bool isEmpty() const const
void removeAt(qsizetype i)
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
QString arg(Args &&... args) 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
qsizetype length() const const
QTextStream & dec(QTextStream &stream)
virtual QString fileName() const const override
QString readLine(qint64 maxlen)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
void setRootIsDecorated(bool show)
void setColumnWidth(int column, int width)
QString text(int column) const const
QString fileName(ComponentFormattingOptions options) const const
bool isEmpty() const const
bool isLocalFile() const const
bool isValid() const const
QString toLocalFile() const const
QString url(FormattingOptions options) const const