Stellarium 0.15.2
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 initComplete(void) const;
103 
104 #ifdef ENABLE_SCRIPT_CONSOLE
105  ScriptConsole* getScriptConsole() {return scriptConsole;}
106 #endif
107 
109  virtual void forceRefreshGui();
110 
111  virtual void setVisible(bool b);
112 
113  virtual bool getVisible() const;
114 
115  virtual bool getAstroCalcVisible();
116 
117  virtual bool isCurrentlyUsed() const;
118 
119  virtual void setInfoTextFilters(const StelObject::InfoStringGroup& aflags);
120  virtual const StelObject::InfoStringGroup& getInfoTextFilters() const;
121 
122 public slots:
124  void setFlagShowFlipButtons(bool b);
125 
128 
130  void setFlagShowToastSurveyButton(bool b);
131 
133  void setFlagShowBookmarksButton(bool b);
134 
135  void setFlagShowDecimalDegrees(bool b);
136 
138  bool getAutoHideHorizontalButtonBar() const;
144  void setAutoHideHorizontalButtonBar(bool b);
145 
147  bool getAutoHideVerticalButtonBar() const;
153  void setAutoHideVerticalButtonBar(bool b);
154 
155 #ifndef DISABLE_SCRIPTING
156  void setScriptKeys(bool b);
158  void increaseScriptSpeed();
159  void decreaseScriptSpeed();
160  void setRealScriptSpeed();
161  void stopScript();
162  void pauseScript();
163  void resumeScript();
164 #endif
165 
167  void setGuiVisible(bool);
168 
169 signals:
170  void visibleChanged(bool b);
171  void autoHideHorizontalButtonBarChanged(bool b);
172  void autoHideVerticalButtonBarChanged(bool b);
173 
174 private slots:
175  void reloadStyle();
176 #ifndef DISABLE_SCRIPTING
177  void scriptStarted();
178  void scriptStopped();
179 #endif
180  void setStelStyle(const QString& section);
182  void quit();
183  void updateI18n();
184  void copySelectedObjectInfo(void);
185 
186 private:
188  StelAction* getAction(const QString& actionName);
189 
190  QGraphicsWidget* topLevelGraphicsWidget;
191 
192  class SkyGui* skyGui;
193 
194  StelButton* buttonTimeRewind;
195  StelButton* buttonTimeRealTimeSpeed;
196  StelButton* buttonTimeCurrent;
197  StelButton* buttonTimeForward;
198 
199  StelButton* buttonGotoSelectedObject;
200 
201  LocationDialog* locationDialog;
202  HelpDialog* helpDialog;
203  DateTimeDialog* dateTimeDialog;
204  SearchDialog* searchDialog;
205  ViewDialog* viewDialog;
206  ShortcutsDialog* shortcutsDialog;
207  ConfigurationDialog* configurationDialog;
208 #ifdef ENABLE_SCRIPT_CONSOLE
209  ScriptConsole* scriptConsole;
210 #endif
211  AstroCalcDialog* astroCalcDialog;
212  BookmarksDialog* bookmarksDialog;
213 
214  bool flagShowFlipButtons;
215  StelButton* flipVert;
216  StelButton* flipHoriz;
217 
218  bool flagShowNebulaBackgroundButton;
219  StelButton* btShowNebulaeBackground;
220 
221  bool flagShowToastSurveyButton;
222  StelButton* btShowToastSurvey;
223 
224  bool flagShowBookmarksButton;
225  StelButton* btShowBookmarks;
226 
227  bool initDone;
228 
229  QSizeF savedProgressBarSize;
230 
231  // Currently used StelStyle
232  StelStyle currentStelStyle;
233 
234 #ifndef DISABLE_SCRIPTING
235  // We use a QStringList to save the user-configured buttons while script is running, and restore them later.
236  QStringList scriptSaveSpeedbuttons;
237 #endif
238 };
239 
240 #else // NO_GUI
241 
242 #include "StelGuiBase.hpp"
243 #include <QProgressBar>
244 
245 class StelGui : public StelGuiBase
246 {
247 public:
248  StelGui() {;}
249  ~StelGui() {;}
250  virtual void init(QGraphicsWidget* topLevelGraphicsWidget, class StelAppGraphicsWidget* stelAppGraphicsWidget) {;}
251  virtual void updateI18n() {;}
252  virtual void setStelStyle(const QString& section) {;}
253  virtual void setInfoTextFilters(const StelObject::InfoStringGroup& aflags) {dummyInfoTextFilter=aflags;}
254  virtual const StelObject::InfoStringGroup& getInfoTextFilters() const {return dummyInfoTextFilter;}
255  virtual QProgressBar* addProgressBar() {return new QProgressBar;}
256  virtual QAction* addGuiActions(const QString& actionName, const QString& text, const QString& shortCut, const QString& helpGroup, bool checkable=true, bool autoRepeat=false) {return NULL;}
257  virtual void forceRefreshGui() {;}
258  virtual void setVisible(bool b) {visible=b;}
259  virtual bool getVisible() const {return visible;}
260  virtual bool isCurrentlyUsed() const {return false;}
261 private:
262  StelObject::InfoStringGroup dummyInfoTextFilter;
263  bool visible;
264 };
265 
266 #endif
267 
268 #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.
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.
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.
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.