Stellarium 0.15.0
StelDialog.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 _STELDIALOG_HPP_
21 #define _STELDIALOG_HPP_
22 
23 #include <QObject>
24 
25 class QAbstractButton;
26 class QComboBox;
27 class QSpinBox;
28 class QDoubleSpinBox;
29 class QSlider;
30 class StelAction;
31 
67 class StelDialog : public QObject
68 {
69  Q_OBJECT
70  Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY visibleChanged)
71 public:
72  StelDialog(QObject* parent=NULL);
73  virtual ~StelDialog();
74 
76  bool visible() const;
77 
78 public slots:
89  virtual void retranslate() = 0;
91  void setVisible(bool);
93  void close();
95  void handleMovedTo(QPoint newPos);
96 signals:
97  void visibleChanged(bool);
98 
99 protected:
101  virtual void createDialogContent()=0;
102 
104  static void connectCheckBox(QAbstractButton* checkBox,const QString& actionName);
106  static void connectCheckBox(QAbstractButton *checkBox, StelAction* action);
107 
112  static void connectIntProperty(QSpinBox* spinBox, const QString& propName);
118  static void connectIntProperty(QComboBox* comboBox, const QString& propName);
122  static void connectDoubleProperty(QDoubleSpinBox* spinBox, const QString& propName);
130  static void connectDoubleProperty(QSlider* slider, const QString& propName, double minValue, double maxValue);
134  static void connectBoolProperty(QAbstractButton* checkBox, const QString& propName);
135 
137  QWidget* dialog;
138  class CustomProxy* proxy;
140  QString dialogName;
141 
142 #ifdef Q_OS_WIN
143  void installKineticScrolling(QList<QWidget *> addscroll);
145 #endif
146 
147 private slots:
148  void updateNightModeProperty();
149 
150 };
151 
152 #endif // _STELDIALOG_HPP_
void handleMovedTo(QPoint newPos)
Adds dialog location to config.ini; should be connected in createDialogContent()
void close()
Closes the window (the window widget is not deleted, just not visible).
static void connectBoolProperty(QAbstractButton *checkBox, const QString &propName)
Helper function to connect a checkbox to a bool StelProperty.
static void connectIntProperty(QSpinBox *spinBox, const QString &propName)
Helper function to connect a QSpinBox to an integer StelProperty.
virtual void createDialogContent()=0
Initialize the dialog widgets and connect the signals/slots.
Base class for all the GUI windows in Stellarium.
Definition: StelDialog.hpp:67
static void connectCheckBox(QAbstractButton *checkBox, const QString &actionName)
Helper function to connect a checkbox to the StelAction with the specified name.
void setVisible(bool)
On the first call with "true" populates the window contents.
static void connectDoubleProperty(QDoubleSpinBox *spinBox, const QString &propName)
Helper function to connect a QDoubleSpinBox to an double or float StelProperty.
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.
QString dialogName
The name should be set in derived classes' constructors and can be used to store and retrieve the pan...
Definition: StelDialog.hpp:140
QWidget * dialog
The main dialog.
Definition: StelDialog.hpp:137
virtual void retranslate()=0
Retranslate the content of the dialog.
bool visible() const
Returns true if the dialog contents have been constructed and are currently shown.