Stellarium  0.16.1
StelGui.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2008 Fabien Chereau
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18  */
19 
20 #ifndef _STELGUI_HPP_
21 #define _STELGUI_HPP_
22 
23 #ifndef NO_GUI
24 
25 #include "StelModule.hpp"
26 #include "StelObject.hpp"
27 #include "StelGuiBase.hpp"
28 #include "StelStyle.hpp"
29 
30 #include <QGraphicsTextItem>
31 
32 class QGraphicsSceneMouseEvent;
33 class QTimeLine;
34 class StelButton;
35 class BottomStelBar;
36 class InfoPanel;
38 class DateTimeDialog;
39 class HelpDialog;
40 class LocationDialog;
41 class SearchDialog;
42 class ViewDialog;
43 class ShortcutsDialog;
44 class AstroCalcDialog;
45 class BookmarksDialog;
46 #ifdef ENABLE_SCRIPT_CONSOLE
47 class ScriptConsole;
48 #endif
49 
53 class StelGui : public QObject, public StelGuiBase
54 {
55  Q_OBJECT
56  Q_PROPERTY(bool visible READ getVisible WRITE setVisible NOTIFY visibleChanged)
57  Q_PROPERTY(bool autoHideHorizontalButtonBar READ getAutoHideHorizontalButtonBar WRITE setAutoHideHorizontalButtonBar NOTIFY autoHideHorizontalButtonBarChanged)
58  Q_PROPERTY(bool autoHideVerticalButtonBar READ getAutoHideVerticalButtonBar WRITE setAutoHideVerticalButtonBar NOTIFY autoHideVerticalButtonBarChanged)
59 
60 public:
61  friend class ViewDialog;
62 
63  StelGui();
64  virtual ~StelGui();
65 
67  // Methods defined in the StelModule class
69  virtual void init(QGraphicsWidget* topLevelGraphicsWidget);
70  void update();
71 
72  StelStyle getStelStyle() const {return currentStelStyle;}
73 
75  // Methods specific to the StelGui class
77  void loadStyle(const QString& fileName);
78 
80  BottomStelBar* getButtonBar() const;
81 
83  class LeftStelBar* getWindowsButtonBar() const;
84 
87  class SkyGui* getSkyGui() const;
88 
90  bool getFlagShowFlipButtons() const;
91 
94 
96  bool getFlagShowToastSurveyButton() const;
97 
99  bool getFlagShowBookmarksButton() const;
100 
102  bool getFlagShowICRSGridButton() const;
103 
105  bool getFlagShowGalacticGridButton() const;
106 
108  bool getFlagShowEclipticGridButton() const;
109 
112 
114  bool initComplete(void) const;
115 
116 #ifdef ENABLE_SCRIPT_CONSOLE
117  ScriptConsole* getScriptConsole() {return scriptConsole;}
118 #endif
119 
121  virtual void forceRefreshGui();
122 
123  virtual void setVisible(bool b);
124 
125  virtual bool getVisible() const;
126 
127  virtual bool getAstroCalcVisible();
128 
129  virtual bool isCurrentlyUsed() const;
130 
131  virtual void setInfoTextFilters(const StelObject::InfoStringGroup& aflags);
132  virtual const StelObject::InfoStringGroup& getInfoTextFilters() const;
133 
134 public slots:
136  void setFlagShowFlipButtons(bool b);
137 
140 
142  void setFlagShowToastSurveyButton(bool b);
143 
145  void setFlagShowBookmarksButton(bool b);
146 
148  void setFlagShowICRSGridButton(bool b);
149 
151  void setFlagShowGalacticGridButton(bool b);
152 
154  void setFlagShowEclipticGridButton(bool b);
155 
158 
159  void setFlagShowDecimalDegrees(bool b);
160 
162  bool getAutoHideHorizontalButtonBar() const;
168  void setAutoHideHorizontalButtonBar(bool b);
169 
171  bool getAutoHideVerticalButtonBar() const;
177  void setAutoHideVerticalButtonBar(bool b);
178 
179 #ifndef DISABLE_SCRIPTING
180  void setScriptKeys(bool b);
182  void increaseScriptSpeed();
183  void decreaseScriptSpeed();
184  void setRealScriptSpeed();
185  void stopScript();
186  void pauseScript();
187  void resumeScript();
188 #endif
189 
191  void setGuiVisible(bool);
192 
193 signals:
194  void visibleChanged(bool b);
195  void autoHideHorizontalButtonBarChanged(bool b);
196  void autoHideVerticalButtonBarChanged(bool b);
197 
198 private slots:
199  void reloadStyle();
200 #ifndef DISABLE_SCRIPTING
201  void scriptStarted();
202  void scriptStopped();
203 #endif
204  void setStelStyle(const QString& section);
206  void quit();
207  void updateI18n();
208  void copySelectedObjectInfo(void);
209 
210 private:
212  StelAction* getAction(const QString& actionName);
213 
214  QGraphicsWidget* topLevelGraphicsWidget;
215 
216  class SkyGui* skyGui;
217 
218  StelButton* buttonTimeRewind;
219  StelButton* buttonTimeRealTimeSpeed;
220  StelButton* buttonTimeCurrent;
221  StelButton* buttonTimeForward;
222 
223  StelButton* buttonGotoSelectedObject;
224 
225  LocationDialog* locationDialog;
226  HelpDialog* helpDialog;
227  DateTimeDialog* dateTimeDialog;
228  SearchDialog* searchDialog;
229  ViewDialog* viewDialog;
230  ShortcutsDialog* shortcutsDialog;
231  ConfigurationDialog* configurationDialog;
232 #ifdef ENABLE_SCRIPT_CONSOLE
233  ScriptConsole* scriptConsole;
234 #endif
235  AstroCalcDialog* astroCalcDialog;
236  BookmarksDialog* bookmarksDialog;
237 
238  bool flagShowFlipButtons;
239  StelButton* flipVert;
240  StelButton* flipHoriz;
241 
242  bool flagShowNebulaBackgroundButton;
243  StelButton* btShowNebulaeBackground;
244 
245  bool flagShowToastSurveyButton;
246  StelButton* btShowToastSurvey;
247 
248  bool flagShowBookmarksButton;
249  StelButton* btShowBookmarks;
250 
251  bool flagShowICRSGridButton;
252  StelButton* btShowICRSGrid;
253 
254  bool flagShowGalacticGridButton;
255  StelButton* btShowGalacticGrid;
256 
257  bool flagShowEclipticGridButton;
258  StelButton* btShowEclipticGrid;
259 
260  bool flagShowConstellationBoundariesButton;
261  StelButton* btShowConstellationBoundaries;
262 
263  bool initDone;
264 
265  QSizeF savedProgressBarSize;
266 
267  // Currently used StelStyle
268  StelStyle currentStelStyle;
269 
270 #ifndef DISABLE_SCRIPTING
271  // We use a QStringList to save the user-configured buttons while script is running, and restore them later.
272  QStringList scriptSaveSpeedbuttons;
273 #endif
274 };
275 
276 #else // NO_GUI
277 
278 #include "StelGuiBase.hpp"
279 #include <QProgressBar>
280 
281 class StelGui : public StelGuiBase
282 {
283 public:
284  StelGui() {;}
285  ~StelGui() {;}
286  virtual void init(QGraphicsWidget* topLevelGraphicsWidget, class StelAppGraphicsWidget* stelAppGraphicsWidget) {;}
287  virtual void updateI18n() {;}
288  virtual void setStelStyle(const QString& section) {;}
289  virtual void setInfoTextFilters(const StelObject::InfoStringGroup& aflags) {dummyInfoTextFilter=aflags;}
290  virtual const StelObject::InfoStringGroup& getInfoTextFilters() const {return dummyInfoTextFilter;}
291  virtual QProgressBar* addProgressBar() {return new QProgressBar;}
292  virtual QAction* addGuiActions(const QString& actionName, const QString& text, const QString& shortCut, const QString& helpGroup, bool checkable=true, bool autoRepeat=false) {return Q_NULLPTR;}
293  virtual void forceRefreshGui() {;}
294  virtual void setVisible(bool b) {visible=b;}
295  virtual bool getVisible() const {return visible;}
296  virtual bool isCurrentlyUsed() const {return false;}
297 private:
298  StelObject::InfoStringGroup dummyInfoTextFilter;
299  bool visible;
300 };
301 
302 #endif
303 
304 #endif // _STELGUI_HPP_
void setFlagShowFlipButtons(bool b)
Define whether the buttons toggling image flip should be visible.
void setGuiVisible(bool)
Hide or show the GUI. Public so it can be called from scripts.
virtual void setInfoTextFilters(const StelObject::InfoStringGroup &aflags)
Get a pointer on the info panel used to display selected object info.
virtual bool isCurrentlyUsed() const
Show wether the Gui is currently used.
bool getFlagShowGalacticGridButton() const
Get whether the button toggling galactic grid is visible.
void setFlagShowNebulaBackgroundButton(bool b)
Define whether the button toggling nebulae background should be visible.
bool getFlagShowConstellationBoundariesButton() const
Get whether the button toggling constellation boundaries is visible.
void setFlagShowGalacticGridButton(bool b)
Define whether the button toggling galactic grid should be visible.
bool getFlagShowNebulaBackgroundButton() const
Get whether the button toggling nebulae background is visible.
bool getAutoHideHorizontalButtonBar() const
Get the auto-hide status of the horizontal toolbar.
void setAutoHideHorizontalButtonBar(bool b)
Set the auto-hide status of the horizontal toolbar.
void setFlagShowToastSurveyButton(bool b)
Define whether the button toggling TOAST survey should be visible.
class SkyGui * getSkyGui() const
Get the SkyGui instance (useful for adding other interface elements).
virtual void setVisible(bool b)
Show whether the GUI is visible.
virtual void forceRefreshGui()
Used to force a refreshing of the GUI elements such as the button bars.
void setScriptKeys(bool b)
change keys when a script is running / not running
Abstract class defining the base interface for all GUIs.
Definition: StelGuiBase.hpp:30
virtual bool getVisible() const
Get the current visible status of the GUI.
Wrapper around an argumentless QObject slot or a bool Q_PROPERTY with WRITE method, allowing the slot to be called/property to be toggled using this action object.
bool getAutoHideVerticalButtonBar() const
Get the auto-hide status of the vertical toolbar.
The informations about the currently selected object.
Definition: SkyGui.hpp:38
A Button Graphicsitem for use in Stellarium&#39;s graphic widgets.
The class managing the layout for button bars, selected object info and loading bars.
Definition: SkyGui.hpp:56
BottomStelBar * getButtonBar() const
Get the button bar at the bottom of the screen.
bool getFlagShowBookmarksButton() const
Get whether the button toggling bookmarks is visible.
bool getFlagShowFlipButtons() const
Get whether the buttons toggling image flip are visible.
void setFlagShowConstellationBoundariesButton(bool b)
Define whether the button toggling constellation boundaries should be visible.
bool getFlagShowICRSGridButton() const
Get whether the button toggling ICRS grid is visible.
bool initComplete(void) const
returns true if the gui has completed init process.
void setAutoHideVerticalButtonBar(bool b)
Set the auto-hide status of the vertical toolbar.
virtual void init(QGraphicsWidget *topLevelGraphicsWidget)
Initialize the StelGui object.
void setFlagShowBookmarksButton(bool b)
Define whether the button toggling bookmarks should be visible.
Holds the information related to a color style for GUI and modules of Stellarium. ...
Definition: StelStyle.hpp:28
Main class for the GUI based on QGraphicView.
Definition: StelGui.hpp:53
The sky object search dialog.
bool getFlagShowEclipticGridButton() const
Get whether the button toggling ecliptic grid is visible.
void setFlagShowEclipticGridButton(bool b)
Define whether the button toggling ecliptic grid should be visible.
void loadStyle(const QString &fileName)
Load a Qt style sheet to define the widgets style.
class LeftStelBar * getWindowsButtonBar() const
Get the button bar of the left of the screen.
bool getFlagShowToastSurveyButton() const
Get whether the button toggling TOAST survey is visible.
void setFlagShowICRSGridButton(bool b)
Define whether the button toggling ICRS grid should be visible.