Stellarium 0.15.2
List of all members | Public Slots | Signals | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Properties
StelDialog Class Referenceabstract

Base class for all the GUI windows in Stellarium. More...

#include <StelDialog.hpp>

+ Inheritance diagram for StelDialog:
+ Collaboration diagram for StelDialog:

Public Slots

virtual void retranslate ()=0
 Retranslate the content of the dialog. More...
 
void setVisible (bool)
 On the first call with "true" populates the window contents. More...
 
void close ()
 Closes the window (the window widget is not deleted, just not visible). More...
 
void handleMovedTo (QPoint newPos)
 Adds dialog location to config.ini; should be connected in createDialogContent() More...
 
void handleDialogSizeChanged (QSizeF size)
 Stores dialog sizes into config.ini; should be connected from the proxy. More...
 
QString getDialogName ()
 

Signals

void visibleChanged (bool)
 

Public Member Functions

 StelDialog (QString dialogName="Default", QObject *parent=NULL)
 
bool visible () const
 Returns true if the dialog contents have been constructed and are currently shown. More...
 

Protected Member Functions

virtual void createDialogContent ()=0
 Initialize the dialog widgets and connect the signals/slots. More...
 

Static Protected Member Functions

static void connectCheckBox (QAbstractButton *checkBox, const QString &actionName)
 Helper function to connect a checkbox to the StelAction with the specified name. More...
 
static void connectCheckBox (QAbstractButton *checkBox, StelAction *action)
 Helper function to connect a checkbox to the given StelAction. More...
 
static void connectIntProperty (QSpinBox *spinBox, const QString &propName)
 Helper function to connect a QSpinBox to an integer StelProperty. More...
 
static void connectIntProperty (QComboBox *comboBox, const QString &propName)
 Helper function to connect a QComboBox to an integer StelProperty. More...
 
static void connectIntProperty (QSlider *slider, const QString &propName, int minValue, int maxValue)
 Helper function to connect a QSlider to an double or float StelProperty. More...
 
static void connectDoubleProperty (QDoubleSpinBox *spinBox, const QString &propName)
 Helper function to connect a QDoubleSpinBox to an double or float StelProperty. More...
 
static void connectDoubleProperty (QSlider *slider, const QString &propName, double minValue, double maxValue)
 Helper function to connect a QSlider to an double or float StelProperty. More...
 
static void connectBoolProperty (QAbstractButton *checkBox, const QString &propName)
 Helper function to connect a checkbox to a bool StelProperty. More...
 

Protected Attributes

QWidget * dialog
 The main dialog. More...
 
class CustomProxyproxy
 
QString dialogName
 The name should be set in derived classes' constructors and can be used to store and retrieve the panel locations. More...
 

Properties

bool visible
 

Detailed Description

Base class for all the GUI windows in Stellarium.

A local copy of StelDialog, the base class for all the GUI windows in Stellarium, included to allow the plug-in to be loaded dynamically on Windows.

Windows in Stellarium are actually basic QWidgets that have to be wrapped in a QGraphicsProxyWidget (CustomProxy) to be displayed by StelMainView (which is derived from QGraphicsView). See the Qt documentation for details.

The base widget needs to be populated with controls in the implementation 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 for details.

The createDialogContent() function itself is called automatically the first time setVisible() is called with "true".

Moving a window is done by dragging its title bar, defined in the BarFrame class. Every derived window class needs a BarFrame object - it has to be either included in a .ui file, or manually instantiated in 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 constructor), and setting a connect() from the BarFrame's movedTo() signal to handleMovedTo() in createDialogContent(). If the dialog is called and the stored location is off-screen, the dialog 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 instances. These functions are:

Definition at line 72 of file StelDialog.hpp.

Member Function Documentation

void StelDialog::close ( )
slot

Closes the window (the window widget is not deleted, just not visible).

static void StelDialog::connectBoolProperty ( QAbstractButton *  checkBox,
const QString &  propName 
)
staticprotected

Helper function to connect a checkbox to a bool StelProperty.

Warning
If the action with propName is invalid/unregistered, or cannot be converted to the required datatype, the application will crash
static void StelDialog::connectCheckBox ( QAbstractButton *  checkBox,
const QString &  actionName 
)
staticprotected

Helper function to connect a checkbox to the StelAction with the specified name.

static void StelDialog::connectCheckBox ( QAbstractButton *  checkBox,
StelAction action 
)
staticprotected

Helper function to connect a checkbox to the given StelAction.

static void StelDialog::connectDoubleProperty ( QDoubleSpinBox *  spinBox,
const QString &  propName 
)
staticprotected

Helper function to connect a QDoubleSpinBox to an double or float StelProperty.

Warning
If the action with propName is invalid/unregistered, or cannot be converted to the required datatype, the application will crash
static void StelDialog::connectDoubleProperty ( QSlider *  slider,
const QString &  propName,
double  minValue,
double  maxValue 
)
staticprotected

Helper function to connect a QSlider to an double or float StelProperty.

Parameters
sliderThe slider which should be connected
propNameThe id of the StelProperty which should be connected
minValuethe double value associated with the minimal slider position
maxValuethe double value associated with the maximal slider position
Warning
If the action with propName is invalid/unregistered, or cannot be converted to the required datatype, the application will crash
static void StelDialog::connectIntProperty ( QSpinBox *  spinBox,
const QString &  propName 
)
staticprotected

Helper function to connect a QSpinBox to an integer StelProperty.

Note
This method also works with flag/enum types
Warning
If the action with propName is invalid/unregistered, or cannot be converted to the required datatype, the application will crash
static void StelDialog::connectIntProperty ( QComboBox *  comboBox,
const QString &  propName 
)
staticprotected

Helper function to connect a QComboBox to an integer StelProperty.

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 propName is invalid/unregistered, or cannot be converted to the required datatype, the application will crash
static void StelDialog::connectIntProperty ( QSlider *  slider,
const QString &  propName,
int  minValue,
int  maxValue 
)
staticprotected

Helper function to connect a QSlider to an double or float StelProperty.

Parameters
sliderThe slider which should be connected
propNameThe id of the StelProperty which should be connected
minValuethe int value associated with the minimal slider position
maxValuethe int value associated with the maximal slider position
Warning
If the action with propName is invalid/unregistered, or cannot be converted to the required datatype, the application will crash
virtual void StelDialog::createDialogContent ( )
protectedpure virtual
void StelDialog::handleDialogSizeChanged ( QSizeF  size)
slot

Stores dialog sizes into config.ini; should be connected from the proxy.

void StelDialog::handleMovedTo ( QPoint  newPos)
slot

Adds dialog location to config.ini; should be connected in createDialogContent()

virtual void StelDialog::retranslate ( )
pure virtualslot

Retranslate the content of the dialog.

Needs to be connected to StelApp::languageChanged(). At the very least, if the window is based on a Qt Designer file (.ui), the implementation needs to call the generated class' retranslateUi() method, like this:

if (dialog)
ui->retranslateUi(dialog);
void StelDialog::setVisible ( bool  )
slot

On the first call with "true" populates the window contents.

bool StelDialog::visible ( ) const

Returns true if the dialog contents have been constructed and are currently shown.

Member Data Documentation

QWidget* StelDialog::dialog
protected

The main dialog.

Definition at line 153 of file StelDialog.hpp.

QString StelDialog::dialogName
protected

The name should be set in derived classes' constructors and can be used to store and retrieve the panel locations.

Definition at line 156 of file StelDialog.hpp.


The documentation for this class was generated from the following file: