1 /***************************************************************************
2 kstarsinit.cpp - K Desktop Planetarium
4 begin : Mon Feb 25 2002
5 copyright : (C) 2002 by Jason Harris
6 email : jharris@30doradus.org
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
21 #include <dcopclient.h>
22 #include <kshortcut.h>
23 #include <kiconloader.h>
24 #include <kpopupmenu.h>
25 #include <kstatusbar.h>
27 #include <kmessagebox.h>
28 #include <kstandarddirs.h>
29 #include <kdeversion.h>
33 #include "kstarsdata.h"
34 #include "kstarssplash.h"
36 #include "skyobject.h"
37 #include "ksplanetbase.h"
39 #include "ksnumbers.h"
40 #include "infoboxes.h"
41 #include "toggleaction.h"
44 #include "timestepbox.h"
46 //This file contains functions that kstars calls at startup (except constructors).
47 //These functions are declared in kstars.h
49 void KStars::initActions() {
51 new KAction(i18n("&New Window"), "window_new", KShortcut( "Ctrl+N" ),
52 this, SLOT( newWindow() ), actionCollection(), "new_window");
53 new KAction(i18n("&Close Window"), "fileclose", KShortcut( "Ctrl+W" ),
54 this, SLOT( closeWindow() ), actionCollection(), "close_window");
55 new KAction( i18n( "&Download Data..." ), "knewstuff", KShortcut( "Ctrl+D" ),
56 this, SLOT( slotDownload() ), actionCollection(), "get_data" );
57 new KAction( i18n( "Open FITS..."), "fileopen", KShortcut( "Ctrl+O"), this, SLOT( slotOpenFITS()), actionCollection(), "open_file");
58 new KAction( i18n( "&Save Sky Image..." ), "fileexport", KShortcut( "Ctrl+I" ),
59 this, SLOT( slotExportImage() ), actionCollection(), "export_image" );
60 new KAction( i18n( "&Run Script..." ), "launch", KShortcut( "Ctrl+R" ),
61 this, SLOT( slotRunScript() ), actionCollection(), "run_script" );
62 KStdAction::print(this, SLOT( slotPrint() ), actionCollection(), "print" );
63 KStdAction::quit(this, SLOT( close() ), actionCollection(), "quit" );
66 new KAction( i18n( "Set Time to &Now" ), KShortcut( "Ctrl+E" ),
67 this, SLOT( slotSetTimeToNow() ), actionCollection(), "time_to_now" );
68 new KAction( i18n( "set Clock to New Time", "&Set Time..." ), "clock", KShortcut( "Ctrl+S" ),
69 this, SLOT( slotSetTime() ), actionCollection(), "time_dialog" );
70 ToggleAction
*actTimeRun
= new ToggleAction( i18n( "Stop &Clock" ), BarIcon("player_pause"),
71 i18n("Start &Clock"), BarIcon("1rightarrow"),
72 0, this, SLOT( slotToggleTimer() ), actionCollection(), "timer_control" );
73 actTimeRun
->setOffToolTip( i18n( "Start Clock" ) );
74 actTimeRun
->setOnToolTip( i18n( "Stop Clock" ) );
75 QObject::connect(data()->clock(), SIGNAL(clockStarted()), actTimeRun
, SLOT(turnOn()) );
76 QObject::connect(data()->clock(), SIGNAL(clockStopped()), actTimeRun
, SLOT(turnOff()) );
77 //UpdateTime() if clock is stopped (so hidden objects get drawn)
78 QObject::connect(data()->clock(), SIGNAL(clockStopped()), this, SLOT(updateTime()) );
81 new KAction(i18n( "&Zenith" ), KShortcut( "Z" ),
82 this, SLOT( slotPointFocus() ), actionCollection(), "zenith");
83 new KAction(i18n( "&North" ), KShortcut( "N" ),
84 this, SLOT( slotPointFocus() ), actionCollection(), "north");
85 new KAction(i18n( "&East" ), KShortcut( "E" ),
86 this, SLOT( slotPointFocus() ), actionCollection(), "east");
87 new KAction(i18n( "&South" ), KShortcut( "S" ),
88 this, SLOT( slotPointFocus() ), actionCollection(), "south");
89 new KAction(i18n( "&West" ), KShortcut( "W" ),
90 this, SLOT( slotPointFocus() ), actionCollection(), "west");
91 KAction
*tmpAction
= KStdAction::find( this, SLOT( slotFind() ),
92 actionCollection(), "find_object" );
93 tmpAction
->setText( i18n( "&Find Object..." ) );
94 tmpAction
->setToolTip( i18n( "Find object" ) );
96 new KAction( i18n( "Engage &Tracking" ), "decrypted", KShortcut( "Ctrl+T" ),
97 this, SLOT( slotTrack() ), actionCollection(), "track_object" );
98 if ( Options::isTracking() ) {
99 actionCollection()->action("track_object")->setText( i18n( "Stop &Tracking" ) );
100 actionCollection()->action("track_object")->setIconSet( BarIcon( "encrypted" ) );
103 new KAction( i18n( "Set Focus &Manually..." ), KShortcut( "Ctrl+M" ),
104 this, SLOT( slotManualFocus() ), actionCollection(), "manual_focus" );
107 KStdAction::zoomIn(this, SLOT( slotZoomIn() ), actionCollection(), "zoom_in" );
108 KStdAction::zoomOut(this, SLOT( slotZoomOut() ), actionCollection(), "zoom_out" );
109 new KAction( i18n( "&Default Zoom" ), "viewmagfit.png", KShortcut( "Ctrl+Z" ),
110 this, SLOT( slotDefaultZoom() ), actionCollection(), "zoom_default" );
111 new KAction( i18n( "&Zoom to Angular Size..." ), "viewmag.png", KShortcut( "Ctrl+Shift+Z" ),
112 this, SLOT( slotSetZoom() ), actionCollection(), "zoom_set" );
113 actCoordSys
= new ToggleAction( i18n("Horizontal &Coordinates"), i18n( "Equatorial &Coordinates" ),
114 Key_Space
, this, SLOT( slotCoordSys() ), actionCollection(), "coordsys" );
115 if ( Options::useAltAz() ) actCoordSys
->turnOff();
116 KStdAction::fullScreen( this, SLOT( slotFullScreen() ), actionCollection(), 0 );
122 // Setting the slot in the KToggleAction constructor, connects the slot to
123 // the activated signal instead of the toggled signal. This seems like a bug
126 //Info Boxes option actions
127 KToggleAction
*a
= new KToggleAction(i18n( "Show the information boxes", "Show &Info Boxes"),
128 0, 0, 0, actionCollection(), "show_boxes");
129 #if KDE_IS_VERSION( 3, 2, 90 )
130 // a->setCheckedState(i18n("Hide &Info Boxes"));
132 a
->setChecked( Options::showInfoBoxes() );
133 QObject::connect(a
, SIGNAL( toggled(bool) ), infoBoxes(), SLOT(setVisible(bool)));
134 QObject::connect(a
, SIGNAL( toggled(bool) ), this, SLOT(slotShowGUIItem(bool)));
135 infoBoxes()->setVisible( Options::showInfoBoxes() );
137 a
= new KToggleAction(i18n( "Show time-related info box", "Show &Time Box"),
138 0, 0, 0, actionCollection(), "show_time_box");
139 #if KDE_IS_VERSION( 3, 2, 90 )
140 //a->setCheckedState(i18n("Hide &Time Box"));
142 a
->setChecked( Options::showTimeBox() );
143 QObject::connect(a
, SIGNAL( toggled(bool) ), infoBoxes(), SLOT(showTimeBox(bool)));
144 QObject::connect(a
, SIGNAL( toggled(bool) ), this, SLOT(slotShowGUIItem(bool)));
146 a
= new KToggleAction(i18n( "Show focus-related info box", "Show &Focus Box"),
147 0, 0, 0, actionCollection(), "show_focus_box");
148 #if KDE_IS_VERSION( 3, 2, 90 )
149 //a->setCheckedState(i18n("Hide &Focus Box"));
151 a
->setChecked( Options::showFocusBox() );
152 QObject::connect(a
, SIGNAL( toggled(bool) ), infoBoxes(), SLOT(showFocusBox(bool)));
153 QObject::connect(a
, SIGNAL( toggled(bool) ), this, SLOT(slotShowGUIItem(bool)));
155 a
= new KToggleAction(i18n( "Show location-related info box", "Show &Location Box"),
156 0, 0, 0, actionCollection(), "show_location_box");
157 #if KDE_IS_VERSION( 3, 2, 90 )
158 //a->setCheckedState(i18n("Hide &Location Box"));
160 a
->setChecked( Options::showGeoBox() );
161 QObject::connect(a
, SIGNAL( toggled(bool) ), infoBoxes(), SLOT(showGeoBox(bool)));
162 QObject::connect(a
, SIGNAL( toggled(bool) ), this, SLOT(slotShowGUIItem(bool)));
164 //Toolbar view options
165 a
= new KToggleAction(i18n( "Show Main Toolbar" ),
166 0, 0, 0, actionCollection(), "show_mainToolBar");
167 #if KDE_IS_VERSION( 3, 2, 90 )
168 //a->setCheckedState(i18n("Hide Main Toolbar"));
170 a
->setChecked( Options::showMainToolBar() );
171 QObject::connect(a
, SIGNAL( toggled(bool) ), this, SLOT(slotShowGUIItem(bool)));
173 a
= new KToggleAction(i18n( "Show View Toolbar" ),
174 0, 0, 0, actionCollection(), "show_viewToolBar");
175 #if KDE_IS_VERSION( 3, 2, 90 )
176 //a->setCheckedState(i18n("Hide View Toolbar"));
178 a
->setChecked( Options::showViewToolBar() );
179 QObject::connect(a
, SIGNAL( toggled(bool) ), this, SLOT(slotShowGUIItem(bool)));
181 //Statusbar view options
182 a
= new KToggleAction(i18n( "Show Statusbar" ),
183 0, 0, 0, actionCollection(), "show_statusBar");
184 #if KDE_IS_VERSION( 3, 2, 90 )
185 //a->setCheckedState(i18n("Hide Statusbar"));
187 QObject::connect(a
, SIGNAL( toggled(bool) ), this, SLOT(slotShowGUIItem(bool)));
188 a
->setChecked( Options::showStatusBar() );
189 a
= new KToggleAction(i18n( "Show Az/Alt Field" ),
190 0, 0, 0, actionCollection(), "show_sbAzAlt");
191 #if KDE_IS_VERSION( 3, 2, 90 )
192 //a->setCheckedState(i18n("Hide Az/Alt Field"));
194 a
->setChecked( Options::showAltAzField() );
195 QObject::connect(a
, SIGNAL( toggled(bool) ), this, SLOT(slotShowGUIItem(bool)));
196 a
= new KToggleAction(i18n( "Show RA/Dec Field" ),
197 0, 0, 0, actionCollection(), "show_sbRADec");
198 #if KDE_IS_VERSION( 3, 2, 90 )
199 //a->setCheckedState(i18n("Hide RA/Dec Field"));
201 a
->setChecked( Options::showRADecField() );
202 QObject::connect(a
, SIGNAL( toggled(bool) ), this, SLOT(slotShowGUIItem(bool)));
204 //Color scheme actions. These are added to the "colorschemes" KActionMenu.
205 colorActionMenu
= new KActionMenu( i18n( "C&olor Schemes" ), actionCollection(), "colorschemes" );
206 addColorMenuItem( i18n( "&Default" ), "cs_default" );
207 addColorMenuItem( i18n( "&Star Chart" ), "cs_chart" );
208 addColorMenuItem( i18n( "&Night Vision" ), "cs_night" );
209 addColorMenuItem( i18n( "&Moonless Night" ), "cs_moonless-night" );
211 // colorActionMenu->insert( new KAction( i18n( "&Default" ), 0, this, SLOT( slotColorScheme() ), actionCollection(), "cs_default" ) );
212 // colorActionMenu->insert( new KAction( i18n( "&Star Chart" ), 0, this, SLOT( slotColorScheme() ), actionCollection(), "cs_chart" ) );
213 // colorActionMenu->insert( new KAction( i18n( "&Night Vision" ), 0, this, SLOT( slotColorScheme() ), actionCollection(), "cs_night" ) );
215 //Add any user-defined color schemes:
217 QString line
, schemeName
, filename
;
218 file
.setName( locate( "appdata", "colors.dat" ) ); //determine filename in local user KDE directory tree.
219 if ( file
.exists() && file
.open( IO_ReadOnly
) ) {
220 QTextStream
stream( &file
);
222 while ( !stream
.eof() ) {
223 line
= stream
.readLine();
224 schemeName
= line
.left( line
.find( ':' ) );
225 //I call it filename here, but it's used as the name of the action!
226 filename
= "cs_" + line
.mid( line
.find( ':' ) +1, line
.find( '.' ) - line
.find( ':' ) - 1 );
227 addColorMenuItem( i18n( schemeName
.local8Bit() ), filename
.local8Bit() );
229 // colorActionMenu->insert( new KAction( i18n( schemeName.local8Bit() ), 0,
230 // this, SLOT( slotColorScheme() ), actionCollection(), filename.local8Bit() ) );
235 //Add FOV Symbol actions
236 fovActionMenu
= new KActionMenu( i18n( "&FOV Symbols" ), actionCollection(), "fovsymbols" );
239 new KAction( i18n( "Location on Earth", "&Geographic..." ),
240 "kstars_geo", KShortcut( "Ctrl+G" ), this,
241 SLOT( slotGeoLocator() ), actionCollection(), "geolocation" );
243 KStdAction::preferences( this, SLOT( slotViewOps() ), actionCollection(), "configure" );
245 new KAction(i18n( "Startup Wizard..." ), "wizard", KShortcut(),
246 this, SLOT( slotWizard() ), actionCollection(), "startwizard" );
249 new KAction(i18n( "Calculator..."), KShortcut( "Ctrl+C"),
250 this, SLOT( slotCalculator() ), actionCollection(), "astrocalculator");
252 new KAction(i18n( "Observing List..."), KShortcut( "Ctrl+L"),
253 this, SLOT( slotObsList() ), actionCollection(), "obslist");
255 // enable action only if file was loaded and processed successfully.
256 if (!data()->VariableStarsList
.isEmpty())
257 new KAction(i18n( "AAVSO Light Curves..."), KShortcut( "Ctrl+V"),
258 this, SLOT( slotLCGenerator() ), actionCollection(), "lightcurvegenerator");
260 new KAction(i18n( "Altitude vs. Time..."), KShortcut( "Ctrl+A"),
261 this, SLOT( slotAVT() ), actionCollection(), "altitude_vs_time");
262 new KAction(i18n( "What's up Tonight..."), KShortcut("Ctrl+U"),
263 this, SLOT(slotWUT()), actionCollection(), "whats_up_tonight");
264 new KAction(i18n( "Script Builder..."), KShortcut("Ctrl+B"),
265 this, SLOT(slotScriptBuilder()), actionCollection(), "scriptbuilder");
266 new KAction(i18n( "Solar System..."), KShortcut("Ctrl+Y"),
267 this, SLOT(slotSolarSystem()), actionCollection(), "solarsystem");
268 new KAction(i18n( "Jupiter's Moons..."), KShortcut("Ctrl+J"),
269 this, SLOT(slotJMoonTool()), actionCollection(), "jmoontool");
272 new KAction(i18n("Telescope Wizard..."), 0, this, SLOT(slotTelescopeWizard()), actionCollection(), "telescope_wizard");
273 new KAction(i18n("Device Manager..."), 0, this, SLOT(slotINDIDriver()), actionCollection(), "device_manager");
275 tmpAction
= new KAction(i18n("Capture Image Sequence..."), 0, this, SLOT(slotImageSequence()), actionCollection(), "capture_sequence");
276 tmpAction
->setEnabled(false);
278 tmpAction
= new KAction(i18n("INDI Control Panel..."), 0, this, SLOT(slotINDIPanel()), actionCollection(), "indi_control_panel");
279 tmpAction
->setEnabled(false);
281 new KAction(i18n("Configure INDI..."), 0, this, SLOT(slotINDIConf()), actionCollection(), "configure_indi");
286 new KAction( i18n( "Tip of the Day" ), "idea", 0,
287 this, SLOT( slotTipOfDay() ), actionCollection(), "help_tipofday" );
289 //Handbook toolBar item:
290 new KAction( i18n( "&Handbook" ), "contents", KShortcut( "F1" ),
291 this, SLOT( appHelpActivated() ), actionCollection(), "handbook" );
294 //viewToolBar actions:
298 a
= new KToggleAction( i18n( "Toggle Stars" ), "kstars_stars",
299 0, this, SLOT( slotViewToolBar() ), actionCollection(), "show_stars" );
300 a
->setChecked( Options::showStars() );
303 a
= new KToggleAction( i18n( "Toggle Deep Sky Objects" ), "kstars_deepsky",
304 0, this, SLOT( slotViewToolBar() ), actionCollection(), "show_deepsky" );
305 a
->setChecked( Options::showDeepSky() );
308 a
= new KToggleAction( i18n( "Toggle Solar System" ), "kstars_planets",
309 0, this, SLOT( slotViewToolBar() ), actionCollection(), "show_planets" );
310 a
->setChecked( Options::showPlanets() );
313 a
= new KToggleAction( i18n( "Toggle Constellation Lines" ), "kstars_clines",
314 0, this, SLOT( slotViewToolBar() ), actionCollection(), "show_clines" );
315 a
->setChecked( Options::showCLines() );
318 a
= new KToggleAction( i18n( "Toggle Constellation Names" ), "kstars_cnames",
319 0, this, SLOT( slotViewToolBar() ), actionCollection(), "show_cnames" );
320 a
->setChecked( Options::showCNames() );
323 a
= new KToggleAction( i18n( "Toggle Constellation Boundaries" ), "kstars_cbound",
324 0, this, SLOT( slotViewToolBar() ), actionCollection(), "show_cbounds" );
325 a
->setChecked( Options::showCBounds() );
328 a
= new KToggleAction( i18n( "Toggle Milky Way" ), "kstars_mw",
329 0, this, SLOT( slotViewToolBar() ), actionCollection(), "show_mw" );
330 a
->setChecked( Options::showMilkyWay() );
333 a
= new KToggleAction( i18n( "Toggle Coordinate Grid" ), "kstars_grid",
334 0, this, SLOT( slotViewToolBar() ), actionCollection(), "show_grid" );
335 a
->setChecked( Options::showGrid() );
338 a
= new KToggleAction( i18n( "Toggle Ground" ), "kstars_horizon",
339 0, this, SLOT( slotViewToolBar() ), actionCollection(), "show_horizon" );
340 a
->setChecked( Options::showGround() );
342 if (Options::fitsSaveDirectory().isEmpty())
343 Options::setFitsSaveDirectory(QDir:: homeDirPath());
346 void KStars::initFOV() {
347 //Read in the user's fov.dat and populate the FOV menu with its symbols. If no fov.dat exists, populate
348 //create a default version.
353 f
.setName( locateLocal( "appdata", "fov.dat" ) );
355 //if file s empty, let's start over
356 if ( (uint
)f
.size() == 0 ) f
.remove();
358 if ( ! f
.exists() ) {
359 if ( ! f
.open( IO_WriteOnly
) ) {
360 kdDebug() << i18n( "Could not open fov.dat." ) << endl
;
362 QTextStream
ostream(&f
);
363 ostream
<< i18n( "Do not use a field-of-view indicator", "No FOV" ) << ":0.0:0:#AAAAAA" << endl
;
364 ostream
<< i18n( "use field-of-view for binoculars", "7x35 Binoculars" ) << ":558:1:#AAAAAA" << endl
;
365 ostream
<< i18n( "use 1-degree field-of-view indicator", "One Degree" ) << ":60:2:#AAAAAA" << endl
;
366 ostream
<< i18n( "use HST field-of-view indicator", "HST WFPC2" ) << ":2.4:0:#AAAAAA" << endl
;
367 ostream
<< i18n( "use Radiotelescope HPBW", "30m at 1.3cm" ) << ":1.79:1:#AAAAAA" << endl
;
372 //just populate the FOV menu with items, don't need to fully parse the lines
373 if ( f
.open( IO_ReadOnly
) ) {
374 QTextStream
stream( &f
);
375 while ( !stream
.eof() ) {
376 QString line
= stream
.readLine();
377 fields
= QStringList::split( ":", line
);
379 if ( fields
.count() == 4 ) {
380 nm
= fields
[0].stripWhiteSpace();
381 KToggleAction
*kta
= new KToggleAction( nm
, 0, this, SLOT( slotTargetSymbol() ),
382 actionCollection(), nm
.utf8() );
383 kta
->setExclusiveGroup( "fovsymbol" );
384 if ( nm
== Options::fOVName() ) kta
->setChecked( true );
385 fovActionMenu
->insert( kta
);
389 kdDebug() << i18n( "Could not open file: %1" ).arg( f
.name() ) << endl
;
392 fovActionMenu
->popupMenu()->insertSeparator();
393 fovActionMenu
->insert( new KAction( i18n( "Edit FOV Symbols..." ), 0, this, SLOT( slotFOVEdit() ), actionCollection(), "edit_fov" ) );
396 void KStars::initStatusBar() {
397 statusBar()->insertItem( i18n( " Welcome to KStars " ), 0, 1, true );
398 statusBar()->setItemAlignment( 0, AlignLeft
| AlignVCenter
);
400 QString s
= "000d 00m 00s, +00d 00\' 00\""; //only need this to set the width
402 if ( Options::showAltAzField() ) {
403 statusBar()->insertFixedItem( s
, 1, true );
404 statusBar()->setItemAlignment( 1, AlignRight
| AlignVCenter
);
405 statusBar()->changeItem( "", 1 );
408 if ( Options::showRADecField() ) {
409 statusBar()->insertFixedItem( s
, 2, true );
410 statusBar()->setItemAlignment( 2, AlignRight
| AlignVCenter
);
411 statusBar()->changeItem( "", 2 );
414 if ( ! Options::showStatusBar() ) statusBar()->hide();
417 void KStars::datainitFinished(bool worked
) {
429 data()->setFullTimeUpdate();
432 //Do not start the clock if the user specified "--paused" on the cmd line
433 if ( StartClockRunning
)
434 data()->clock()->start();
436 //Initialize FOV symbol from options
437 data()->fovSymbol
.setName( Options::fOVName() );
438 data()->fovSymbol
.setSize( Options::fOVSize() );
439 data()->fovSymbol
.setShape( Options::fOVShape() );
440 data()->fovSymbol
.setColor( Options::fOVColor().name() );
444 //If this is the first startup, show the wizard
445 if ( Options::runStartupWizard() ) {
447 //reset the clock to the system CPU
451 //Check whether initial position is below the horizon.
452 //We used to just call slotCenter() in buildGUI() which performs this check.
453 //However, on some systems, if the messagebox is shown before show() is called,
454 //the program exits. It does not crash (at least there are no error messages),
455 //it simply exits. Very strange.
456 if ( Options::useAltAz() && Options::showGround() &&
457 map()->focus()->alt()->Degrees() < -1.0 ) {
458 QString caption
= i18n( "Initial Position is Below Horizon" );
459 QString message
= i18n( "The initial position is below the horizon.\nWould you like to reset to the default position?" );
460 if ( KMessageBox::warningYesNo( this, message
, caption
,
461 KStdGuiItem::yes(), KStdGuiItem::no(), "dag_start_below_horiz" ) == KMessageBox::Yes
) {
462 map()->setClickedObject( NULL
);
463 map()->setFocusObject( NULL
);
464 Options::setIsTracking( false );
466 data()->setSnapNextFocus(true);
468 SkyPoint DefaultFocus
;
469 DefaultFocus
.setAz( 180.0 );
470 DefaultFocus
.setAlt( 45.0 );
471 DefaultFocus
.HorizontalToEquatorial( LST(), geo()->lat() );
472 map()->setDestination( &DefaultFocus
);
476 //If there is a focusObject() and it is a SS body, add a temporary Trail to it.
477 if ( map()->focusObject() && map()->focusObject()->isSolarSystem()
478 && Options::useAutoTrail() ) {
479 ((KSPlanetBase
*)map()->focusObject())->addToTrail();
480 data()->temporaryTrail
= true;
483 // just show dialog if option is set (don't force it)
484 KTipDialog::showTip( "kstars/tips" );
487 void KStars::privatedata::buildGUI() {
489 ks
->centralWidget
= new QWidget( ks
);
490 ks
->setCentralWidget( ks
->centralWidget
);
492 //set AAVSO modaless dialog pointer to 0
495 //INDI menu started without GUI
496 ks
->indimenu
= new INDIMenu(ks
);
498 //INDI driver set to null
501 //INDI img sequence, set to null
504 ks
->skymap
= new SkyMap( ks
->data(), ks
->centralWidget
);
505 // update skymap if KStarsData send update signal
506 QObject::connect(kstarsData
, SIGNAL( update() ), ks
->skymap
, SLOT( forceUpdateNow() ) );
508 // get focus of keyboard and mouse actions (for example zoom in with +)
509 ks
->map()->QWidget::setFocus();
514 // create the layout of the central widget
515 ks
->topLayout
= new QVBoxLayout( ks
->centralWidget
);
516 ks
->topLayout
->addWidget( ks
->skymap
);
518 // 2nd parameter must be false, or plugActionList won't work!
519 ks
->createGUI("kstarsui.rc", false);
521 //Do not show text on the view toolbar buttons
522 //FIXME: after strings freeze, remove this and make the
523 //text of each button shorter
524 ks
->toolBar( "viewToolBar" )->setIconText( KToolBar::IconOnly
);
526 //Initialize show/hide state of toolbars.
527 //These were in initActions, but they must appear after createGUI...
528 if ( !Options::showMainToolBar() ) ks
->toolBar( "mainToolBar" )->hide();
529 if ( !Options::showViewToolBar() ) ks
->toolBar( "viewToolBar" )->hide();
531 ks
->TimeStep
= new TimeStepBox( ks
->toolBar() );
532 ks
->toolBar()->insertWidget( 0, 6, ks
->TimeStep
, 15 );
534 //Changing the timestep needs to propagate to the clock, check if slew mode should be
535 //(dis)engaged, and return input focus to the skymap.
536 connect( ks
->TimeStep
, SIGNAL( scaleChanged( float ) ), ks
->data(), SLOT( setTimeDirection( float ) ) );
537 connect( ks
->TimeStep
, SIGNAL( scaleChanged( float ) ), ks
->data()->clock(), SLOT( setScale( float )) );
538 // connect( ks->TimeStep, SIGNAL( scaleChanged( float ) ), ks->skymap, SLOT( slotClockSlewing() ) );
539 connect( ks
->data()->clock(), SIGNAL( scaleChanged( float ) ), ks
->map(), SLOT( slotClockSlewing() ) );
540 connect( ks
->TimeStep
, SIGNAL( scaleChanged( float ) ), ks
, SLOT( mapGetsFocus() ) );
542 ks
->resize( Options::windowWidth(), Options::windowHeight() );
544 // initialize clock with current time/date or the date/time specified on the command line
545 KStarsDateTime startDate
= KStarsDateTime::fromString( ks
->StartDateString
);
546 if ( startDate
.isValid() )
547 ks
->data()->changeDateTime( ks
->geo()->LTtoUT( startDate
) );
549 ks
->slotSetTimeToNow();
551 //Define the celestial equator, horizon and ecliptic
552 KSNumbers
tempnum(ks
->data()->ut().djd());
553 ks
->data()->initGuides(&tempnum
);
556 QObject::connect( ks
->data()->clock(), SIGNAL( timeAdvanced() ), ks
, SLOT( updateTime() ) );
557 QObject::connect( ks
->data()->clock(), SIGNAL( timeChanged() ), ks
, SLOT( updateTime() ) );
559 // Connect cache function
560 QObject::connect( kstarsData
, SIGNAL( clearCache() ), ks
, SLOT( clearCachedFindDialog() ) );
563 if ( ks
->data()->useDefaultOptions
) {
564 newPoint
.setAz( Options::focusRA() );
565 newPoint
.setAlt( Options::focusDec() + 0.0001 );
566 newPoint
.HorizontalToEquatorial( ks
->LST(), ks
->geo()->lat() );
568 newPoint
.set( Options::focusRA(), Options::focusDec() );
571 //need to set focusObject before updateTime, otherwise tracking is set to false
572 if ( (Options::focusObject() != i18n( "star" ) ) &&
573 (Options::focusObject() != i18n( "nothing" ) ) )
574 ks
->map()->setFocusObject( ks
->data()->objectNamed( Options::focusObject() ) );
578 //Set focus of Skymap to value stored in config.
579 //Set default position in case stored focus is below horizon
580 // SkyPoint DefaultFocus;
581 // DefaultFocus.setAz( 180.0 );
582 // DefaultFocus.setAlt( 45.0 );
583 // DefaultFocus.HorizontalToEquatorial( ks->LST(), ks->geo()->lat() );
584 // ks->map()->setDestination( &DefaultFocus );
586 //if user was tracking last time, track on same object now.
587 if ( Options::isTracking() ) {
588 if ( (Options::focusObject() == i18n( "star" ) ) ||
589 (Options::focusObject() == i18n( "nothing" ) ) ) {
590 ks
->map()->setFocusPoint( &newPoint
);
592 ks
->map()->setClickedObject( ks
->data()->objectNamed( Options::focusObject() ) );
593 if ( ks
->map()->clickedObject() ) {
594 ks
->map()->setFocusPoint( ks
->map()->clickedObject() );
595 ks
->map()->setFocusObject( ks
->map()->clickedObject() );
597 ks
->map()->setFocusPoint( &newPoint
);
600 // ks->map()->slotCenter();
602 ks
->map()->setFocusPoint( &newPoint
);
603 // ks->map()->slotCenter();
606 // if ( Options::focusObject() == i18n( "star" ) ) Options::setFocusObject( i18n( "nothing" ) );
608 ks
->map()->setDestination( ks
->map()->focusPoint() );
609 ks
->map()->destination()->EquatorialToHorizontal( ks
->LST(), ks
->geo()->lat() );
610 ks
->map()->setFocus( ks
->map()->destination() );
611 ks
->map()->focus()->EquatorialToHorizontal( ks
->LST(), ks
->geo()->lat() );
613 // ks->infoBoxes()->focusObjChanged( Options::focusObject() );
614 // ks->infoBoxes()->focusCoordChanged( ks->map()->focus() );
615 ks
->map()->showFocusCoords();
617 ks
->data()->setHourAngle( ks
->LST()->Hours() - ks
->map()->focus()->ra()->Hours() );
619 ks
->map()->setOldFocus( ks
->map()->focus() );
620 ks
->map()->oldfocus()->setAz( ks
->map()->focus()->az()->Degrees() );
621 ks
->map()->oldfocus()->setAlt( ks
->map()->focus()->alt()->Degrees() );
623 // check zoom in/out buttons
624 if ( Options::zoomFactor() >= MAXZOOM
) ks
->actionCollection()->action("zoom_in")->setEnabled( false );
625 if ( Options::zoomFactor() <= MINZOOM
) ks
->actionCollection()->action("zoom_out")->setEnabled( false );
627 kapp
->dcopClient()->resume();