Stellarium 0.15.0
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 #ifdef ENABLE_SCRIPT_CONSOLE
46 class ScriptConsole;
47 #endif
48 
52 class StelGui : public QObject, public StelGuiBase
53 {
54  Q_OBJECT
55  Q_PROPERTY(bool visible READ getVisible WRITE setVisible)
56  Q_PROPERTY(bool autoHideHorizontalButtonBar READ getAutoHideHorizontalButtonBar WRITE setAutoHideHorizontalButtonBar)
57  Q_PROPERTY(bool autoHideVerticalButtonBar READ getAutoHideVerticalButtonBar WRITE setAutoHideVerticalButtonBar)
58 
59 public:
60  friend class ViewDialog;
61 
62  StelGui();
63  virtual ~StelGui();
64 
66  // Methods defined in the StelModule class
68  virtual void init(QGraphicsWidget* topLevelGraphicsWidget);
69  void update();
70 
71  StelStyle getStelStyle() const {return currentStelStyle;}
72 
74  // Methods specific to the StelGui class
76  void loadStyle(const QString& fileName);
77 
79  BottomStelBar* getButtonBar() const;
80 
82  class LeftStelBar* getWindowsButtonBar() const;
83 
86  class SkyGui* getSkyGui() const;
87 
89  bool getFlagShowFlipButtons() const;
90 
93 
95  bool initComplete(void) const;
96 
97 #ifdef ENABLE_SCRIPT_CONSOLE
98  ScriptConsole* getScriptConsole() {return scriptConsole;}
99 #endif
100 
102  virtual void forceRefreshGui();
103 
104  virtual void setVisible(bool b);
105 
106  virtual bool getVisible() const;
107 
108  virtual bool isCurrentlyUsed() const;
109 
110  virtual void setInfoTextFilters(const StelObject::InfoStringGroup& aflags);
111  virtual const StelObject::InfoStringGroup& getInfoTextFilters() const;
112 
113 public slots:
115  void setFlagShowFlipButtons(bool b);
116 
119 
120  void setFlagShowDecimalDegrees(bool b);
121 
123  bool getAutoHideHorizontalButtonBar() const;
129  void setAutoHideHorizontalButtonBar(bool b);
130 
132  bool getAutoHideVerticalButtonBar() const;
138  void setAutoHideVerticalButtonBar(bool b);
139 
140 #ifndef DISABLE_SCRIPTING
141  void setScriptKeys(bool b);
143  void increaseScriptSpeed();
144  void decreaseScriptSpeed();
145  void setRealScriptSpeed();
146  void stopScript();
147  void pauseScript();
148  void resumeScript();
149 #endif
150 
152  void setGuiVisible(bool);
153 
154 private slots:
155  void reloadStyle();
156 #ifndef DISABLE_SCRIPTING
157  void scriptStarted();
158  void scriptStopped();
159 #endif
160  void setStelStyle(const QString& section);
162  void quit();
163  void updateI18n();
164  void copySelectedObjectInfo(void);
165 
166 private:
168  StelAction* getAction(const QString& actionName);
169 
170  QGraphicsWidget* topLevelGraphicsWidget;
171 
172  class SkyGui* skyGui;
173 
174  StelButton* buttonTimeRewind;
175  StelButton* buttonTimeRealTimeSpeed;
176  StelButton* buttonTimeCurrent;
177  StelButton* buttonTimeForward;
178 
179  StelButton* buttonGotoSelectedObject;
180 
181  LocationDialog* locationDialog;
182  HelpDialog* helpDialog;
183  DateTimeDialog* dateTimeDialog;
184  SearchDialog* searchDialog;
185  ViewDialog* viewDialog;
186  ShortcutsDialog* shortcutsDialog;
187  ConfigurationDialog* configurationDialog;
188 #ifdef ENABLE_SCRIPT_CONSOLE
189  ScriptConsole* scriptConsole;
190 #endif
191  AstroCalcDialog* astroCalcDialog;
192 
193  bool flagShowFlipButtons;
194  StelButton* flipVert;
195  StelButton* flipHoriz;
196 
197  bool flagShowNebulaBackgroundButton;
198  StelButton* btShowNebulaeBackground;
199 
200  bool initDone;
201 
202  QSizeF savedProgressBarSize;
203 
204  // Currently used StelStyle
205  StelStyle currentStelStyle;
206 };
207 
208 #else // NO_GUI
209 
210 #include "StelGuiBase.hpp"
211 #include <QProgressBar>
212 
213 class StelGui : public StelGuiBase
214 {
215 public:
216  StelGui() {;}
217  ~StelGui() {;}
218  virtual void init(QGraphicsWidget* topLevelGraphicsWidget, class StelAppGraphicsWidget* stelAppGraphicsWidget) {;}
219  virtual void updateI18n() {;}
220  virtual void setStelStyle(const QString& section) {;}
221  virtual void setInfoTextFilters(const StelObject::InfoStringGroup& aflags) {dummyInfoTextFilter=aflags;}
222  virtual const StelObject::InfoStringGroup& getInfoTextFilters() const {return dummyInfoTextFilter;}
223  virtual QProgressBar* addProgressBar() {return new QProgressBar;}
224  virtual QAction* addGuiActions(const QString& actionName, const QString& text, const QString& shortCut, const QString& helpGroup, bool checkable=true, bool autoRepeat=false) {return NULL;}
225  virtual void forceRefreshGui() {;}
226  virtual void setVisible(bool b) {visible=b;}
227  virtual bool getVisible() const {return visible;}
228  virtual bool isCurrentlyUsed() const {return false;}
229 private:
230  StelObject::InfoStringGroup dummyInfoTextFilter;
231  bool visible;
232 };
233 
234 #endif
235 
236 #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.
void setFlagShowNebulaBackgroundButton(bool b)
Define whether the button toggling nebulae background 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.
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.
bool getAutoHideVerticalButtonBar() const
Get the auto-hide status of the vertical toolbar.
The informations about the currently selected object.
Definition: SkyGui.hpp:37
A Button Graphicsitem for use in Stellarium's graphic widgets.
The class managing the layout for button bars, selected object info and loading bars.
Definition: SkyGui.hpp:53
BottomStelBar * getButtonBar() const
Get the button bar at the bottom of the screen.
bool getFlagShowFlipButtons() const
Get whether the buttons toggling image flip are 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.
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:52
The sky object search dialog.
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.