StelDialog.hpp   StelDialog.hpp 
skipping to change at line 25 skipping to change at line 25
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#ifndef _STELDIALOG_HPP_ #ifndef _STELDIALOG_HPP_
#define _STELDIALOG_HPP_ #define _STELDIALOG_HPP_
#include <QObject> #include <QObject>
//! @class StelDialog class QAbstractButton;
class QComboBox;
class QSpinBox;
class QDoubleSpinBox;
class QSlider;
class StelAction;
//! Base class for all the GUI windows in Stellarium. //! Base class for all the GUI windows in Stellarium.
//! //!
//! Windows in Stellarium are actually basic QWidgets that have to be wrapp ed in //! Windows in Stellarium are actually basic QWidgets that have to be wrapp ed in
//! a QGraphicsProxyWidget (CustomProxy) to be displayed by StelMainView //! a QGraphicsProxyWidget (CustomProxy) to be displayed by StelMainView
//! (which is derived from QGraphicsView). See the Qt documentation for det ails. //! (which is derived from QGraphicsView). See the %Qt documentation for de tails.
//! //!
//! The base widget needs to be populated with controls in the implementati on //! The base widget needs to be populated with controls in the implementati on
//! of the createDialogContent() function. This can be done either manually , or //! of the createDialogContent() function. This can be done either manually , or
//! by using a .ui file. See the Qt documentation on using Qt Designer .ui files //! by using a .ui file. See the %Qt documentation on using %Qt Designer .u i files
//! for details. //! for details.
//! //!
//! The createDialogContent() function itself is called automatically the f irst //! The createDialogContent() function itself is called automatically the f irst
//! time setVisible() is called with "true". //! time setVisible() is called with "true".
//! //!
//! Moving a window is done by dragging its title bar, defined in the BarFr ame //! Moving a window is done by dragging its title bar, defined in the BarFr ame
//! class. Every derived window class needs a BarFrame object - it //! class. Every derived window class needs a BarFrame object - it
//! has to be either included in a .ui file, or manually instantiated in //! has to be either included in a .ui file, or manually instantiated in
//! createDialogContent(). //! createDialogContent().
//!
//! The screen location of the StelDialog can be stored in config.ini. This
requires
//! setting dialogName (must be a unique name, should be set in the constru
ctor),
//! and setting a connect() from the BarFrame's movedTo() signal to handleM
ovedTo()
//! in createDialogContent().
//! If the dialog is called and the stored location is off-screen, the dial
og is
//! shifted to become visible.
//!
//! ## StelProperty and StelAction
//! The StelDialog base class provides multiple helper functions that allow
easy
//! two-way binding of widgets to specific StelAction or StelProperty insta
nces. These functions are:
//! - \ref connectCheckBox to connect a StelAction to a QAbstractButton (in
cludes QCheckBox)
//! - \ref connectIntProperty to connect a StelProperty to a QSpinBox or QC
omboBox
//! - \ref connectDoubleProperty to connect a StelProperty to a QDoubleSpin
Box or QSlider
//! - \ref connectBoolProperty to connect a StelProperty to a QAbstractButt
on (includes QCheckBox)
//! Take care that a valid property name is used and it represents a proper
ty that can be converted to
//! the required data type, or the program will crash at runtime when the f
unction is called
class StelDialog : public QObject class StelDialog : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY visible Changed) Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY visible Changed)
public: public:
StelDialog(QObject* parent=NULL); StelDialog(QObject* parent=NULL);
virtual ~StelDialog(); virtual ~StelDialog();
//! Returns true if the dialog contents have been constructed and ar e currently shown
bool visible() const; bool visible() const;
public slots: public slots:
//! Retranslate the content of the dialog. //! Retranslate the content of the dialog.
//! Needs to be connected to StelApp::languageChanged(). //! Needs to be connected to StelApp::languageChanged().
//! At the very least, if the window is //! At the very least, if the window is
//! <a href="http://doc.qt.nokia.com/stable/designer-using-a-ui-file .html"> //! <a href="http://doc.qt.nokia.com/stable/designer-using-a-ui-file .html">
//! based on a Qt Designer file (.ui)</a>, the implementation needs to call //! based on a Qt Designer file (.ui)</a>, the implementation needs to call
//! the generated class' retranslateUi() method, like this: //! the generated class' retranslateUi() method, like this:
//! \code //! \code
//! if (dialog) //! if (dialog)
//! ui->retranslateUi(dialog); //! ui->retranslateUi(dialog);
//! \endcode //! \endcode
virtual void retranslate() = 0; virtual void retranslate() = 0;
//! On the first call with "true" populates the window contents. //! On the first call with "true" populates the window contents.
void setVisible(bool); void setVisible(bool);
//! Closes the window (the window widget is not deleted, just not vi sible). //! Closes the window (the window widget is not deleted, just not vi sible).
void close(); void close();
//! Adds dialog location to config.ini; should be connected in creat
eDialogContent()
void handleMovedTo(QPoint newPos);
signals: signals:
void visibleChanged(bool); void visibleChanged(bool);
private slots:
void updateNightModeProperty();
protected: protected:
//! Initialize the dialog widgets and connect the signals/slots. //! Initialize the dialog widgets and connect the signals/slots.
virtual void createDialogContent()=0; virtual void createDialogContent()=0;
//! Helper function to connect a checkbox to the StelAction with the
specified name
static void connectCheckBox(QAbstractButton* checkBox,const QString&
actionName);
//! Helper function to connect a checkbox to the given StelAction
static void connectCheckBox(QAbstractButton *checkBox, StelAction* a
ction);
//! Helper function to connect a QSpinBox to an integer StelProperty
.
//! @note This method also works with flag/enum types
//! @warning If the action with \c propName is invalid/unregistered,
or cannot be converted
//! to the required datatype, the application will crash
static void connectIntProperty(QSpinBox* spinBox, const QString& pro
pName);
//! Helper function to connect a QComboBox to an integer StelPropert
y.
//! The property is mapped to the selected index of the combobox.
//! @note This method also works with flag/enum types
//! @warning If the action with \c propName is invalid/unregistered,
or cannot be converted
//! to the required datatype, the application will crash
static void connectIntProperty(QComboBox* comboBox, const QString& p
ropName);
//! Helper function to connect a QDoubleSpinBox to an double or floa
t StelProperty
//! @warning If the action with \c propName is invalid/unregistered,
or cannot be converted
//! to the required datatype, the application will crash
static void connectDoubleProperty(QDoubleSpinBox* spinBox, const QSt
ring& propName);
//! Helper function to connect a QSlider to an double or float StelP
roperty
//! @param slider The slider which should be connected
//! @param propName The id of the StelProperty which should be conne
cted
//! @param minValue the double value associated with the minimal sli
der position
//! @param maxValue the double value associated with the maximal sli
der position
//! @warning If the action with \c propName is invalid/unregistered,
or cannot be converted
//! to the required datatype, the application will crash
static void connectDoubleProperty(QSlider* slider, const QString& pr
opName, double minValue, double maxValue);
//! Helper function to connect a checkbox to a bool StelProperty
//! @warning If the action with \c propName is invalid/unregistered,
or cannot be converted
//! to the required datatype, the application will crash
static void connectBoolProperty(QAbstractButton* checkBox, const QSt
ring& propName);
//! The main dialog //! The main dialog
QWidget* dialog; QWidget* dialog;
class CustomProxy* proxy; class CustomProxy* proxy;
//! The name should be set in derived classes' constructors and can
be used to store and retrieve the panel locations.
QString dialogName;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
//! Kinetic scrolling for lists. //! Kinetic scrolling for lists.
void installKineticScrolling(QList<QWidget *> addscroll); void installKineticScrolling(QList<QWidget *> addscroll);
#endif #endif
private slots:
void updateNightModeProperty();
}; };
#endif // _STELDIALOG_HPP_ #endif // _STELDIALOG_HPP_
 End of changes. 10 change blocks. 
5 lines changed or deleted 102 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/