StelDialog.cpp   StelDialog.cpp 
skipping to change at line 24 skipping to change at line 24
* *
* 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.
*/ */
#include "StelDialog.hpp" #include "StelDialog.hpp"
#include "StelDialog_p.hpp" #include "StelDialog_p.hpp"
#include "StelMainView.hpp" #include "StelMainView.hpp"
#include "StelGui.hpp" #include "StelGui.hpp"
#include "StelApp.hpp"
#include "StelActionMgr.hpp" #include "StelActionMgr.hpp"
#include "StelPropertyMgr.hpp" #include "StelPropertyMgr.hpp"
#include <QDebug> #include <QDebug>
#include <QAbstractButton> #include <QAbstractButton>
#include <QComboBox> #include <QComboBox>
#include <QDialog> #include <QDialog>
#include <QGraphicsProxyWidget>
#include <QMetaProperty> #include <QMetaProperty>
#include <QStyleOptionGraphicsItem> #include <QStyleOptionGraphicsItem>
#include <QSettings>
#include <QSlider> #include <QSlider>
#include <QSpinBox> #include <QSpinBox>
#include <QDoubleSpinBox> #include <QDoubleSpinBox>
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#include <QScroller> #include <QScroller>
#endif #endif
class CustomProxy : public QGraphicsProxyWidget
{
public:
CustomProxy(QGraphicsItem *parent = 0, Qt::WindowFlags wFlag
s = 0) : QGraphicsProxyWidget(parent, wFlags)
{
setFocusPolicy(Qt::StrongFocus);
}
//! Reimplement this method to add windows decorations. Curr
ently there are invisible 2 px decorations
void paintWindowFrame(QPainter*, const QStyleOptionGraphicsI
tem*, QWidget*)
{
/* QStyleOptionTitleBar bar;
initStyleOption(&bar);
bar.subControls = QStyle::SC_TitleBarCloseButton;
qWarning() << style()->subControlRect(QStyle::CC_Tit
leBar, &bar, QStyle::SC_TitleBarCloseButton);
QGraphicsProxyWidget::paintWindowFrame(painter, opti
on, widget);*/
}
protected:
virtual bool event(QEvent* event)
{
if (StelApp::getInstance().getSettings()->value("gui
/flag_use_window_transparency", true).toBool())
{
switch (event->type())
{
case QEvent::WindowDeactivate:
widget()->setWindowOpacity(0
.4);
break;
case QEvent::WindowActivate:
case QEvent::GrabMouse:
widget()->setWindowOpacity(0
.9);
break;
default:
break;
}
}
return QGraphicsProxyWidget::event(event);
}
};
StelDialog::StelDialog(QObject* parent) StelDialog::StelDialog(QObject* parent)
: QObject(parent) : QObject(parent)
, dialog(NULL) , dialog(NULL)
, proxy(NULL) , proxy(NULL)
{ {
if (parent == NULL) if (parent == NULL)
setParent(StelMainView::getInstance().getGuiWidget()); setParent(StelMainView::getInstance().getGuiWidget());
} }
StelDialog::~StelDialog() StelDialog::~StelDialog()
skipping to change at line 147 skipping to change at line 105
dialog->setStyleSheet(gui->getStelStyle().qtStyleShe et); dialog->setStyleSheet(gui->getStelStyle().qtStyleShe et);
// Ensure that tooltip get rendered in red in night mode. // Ensure that tooltip get rendered in red in night mode.
connect(&StelApp::getInstance(), SIGNAL(visionNightM odeChanged(bool)), this, SLOT(updateNightModeProperty())); connect(&StelApp::getInstance(), SIGNAL(visionNightM odeChanged(bool)), this, SLOT(updateNightModeProperty()));
updateNightModeProperty(); updateNightModeProperty();
proxy = new CustomProxy(parent, Qt::Tool); proxy = new CustomProxy(parent, Qt::Tool);
proxy->setWidget(dialog); proxy->setWidget(dialog);
QSizeF size = proxy->size(); QSizeF size = proxy->size();
connect(proxy, SIGNAL(sizeChanged(QSizeF)), this, SL
OT(handleDialogSizeChanged(QSizeF)));
int newX, newY; int newX, newY;
// Retrieve panel locations from config.ini, but shi ft if required to a visible position. // Retrieve panel locations from config.ini, but shi ft if required to a visible position.
// else centre dialog according to current window si ze. // else centre dialog according to current window si ze.
QSettings *conf=StelApp::getInstance().getSettings() ; QSettings *conf=StelApp::getInstance().getSettings() ;
Q_ASSERT(conf); Q_ASSERT(conf);
QString confNamePt="DialogPositions/" + dialogName; QString confNamePt="DialogPositions/" + dialogName;
QString storedPosString=conf->value(confNamePt, QString storedPosString=conf->value(confNamePt,
QString("%1,%2") QString("%1,%2")
.arg((int)((scre enSize.width() - size.width() )/2)) .arg((int)((scre enSize.width() - size.width() )/2))
skipping to change at line 183 skipping to change at line 143
if (newY>=screenSize.height()) if (newY>=screenSize.height())
newY= (screenSize.height() - dialog->size(). height()); newY= (screenSize.height() - dialog->size(). height());
// Make sure that the window's title bar is accessib le // Make sure that the window's title bar is accessib le
if (newY <-0) if (newY <-0)
newY = 0; newY = 0;
proxy->setPos(newX, newY); proxy->setPos(newX, newY);
proxy->setWindowFrameMargins(2,0,2,2); proxy->setWindowFrameMargins(2,0,2,2);
// (this also changes the bounding rectangle size) // (this also changes the bounding rectangle size)
// The caching is buggy on all plateforms with Qt 4. // Retrieve stored panel sizes, scale panel up if it
5.2 was stored larger than default.
QString confNameSize="DialogSizes/" + dialogName;
QString storedSizeString=conf->value(confNameSize, Q
String("0,0")).toString();
QStringList sizeList=storedSizeString.split(",");
if (sizeList.length()==2)
{
newX=sizeList.at(0).toInt();
newY=sizeList.at(1).toInt();
}
else // in case there is an invalid string?
{
newX=0;
newY=0;
}
// resize only if number was valid and larger than d
efault loaded size.
if ( (newX>=proxy->size().width()) || (newY>=proxy->
size().height()) )
{
//qDebug() << confNameSize << ": resize to "
<< storedSizeString;
proxy->resize(qMax((qreal)newX, proxy->size(
).width()), qMax((qreal)newY, proxy->size().height()));
}
// The caching is buggy on all platforms with Qt 4.5
.2
proxy->setCacheMode(QGraphicsItem::ItemCoordinateCac he); proxy->setCacheMode(QGraphicsItem::ItemCoordinateCac he);
proxy->setZValue(100); proxy->setZValue(100);
StelMainView::getInstance().scene()->setActiveWindow (proxy); StelMainView::getInstance().scene()->setActiveWindow (proxy);
} }
proxy->setFocus(); proxy->setFocus();
} }
else else
{ {
dialog->hide(); dialog->hide();
skipping to change at line 220 skipping to change at line 201
connect(action, SIGNAL(toggled(bool)), checkBox, SLOT(setChecked(boo l))); connect(action, SIGNAL(toggled(bool)), checkBox, SLOT(setChecked(boo l)));
connect(checkBox, SIGNAL(toggled(bool)), action, SLOT(setChecked(boo l))); connect(checkBox, SIGNAL(toggled(bool)), action, SLOT(setChecked(boo l)));
} }
void StelDialog::connectIntProperty(QSpinBox *spinBox, const QString &propN ame) void StelDialog::connectIntProperty(QSpinBox *spinBox, const QString &propN ame)
{ {
StelProperty* prop = StelApp::getInstance().getStelPropertyManager() ->getProperty(propName); StelProperty* prop = StelApp::getInstance().getStelPropertyManager() ->getProperty(propName);
Q_ASSERT_X(prop,"StelDialog", "StelProperty does not exist"); Q_ASSERT_X(prop,"StelDialog", "StelProperty does not exist");
//use a proxy for the connection //use a proxy for the connection
new QSpinBoxStelPropertyConnectionHelper(prop,spinBox); new QSpinBoxStelPropertyConnectionHelper(prop,spinBox);
} }
void StelDialog::connectIntProperty(QComboBox *comboBox, const QString &pro pName) void StelDialog::connectIntProperty(QComboBox *comboBox, const QString &pro pName)
{ {
StelProperty* prop = StelApp::getInstance().getStelPropertyManager() ->getProperty(propName); StelProperty* prop = StelApp::getInstance().getStelPropertyManager() ->getProperty(propName);
Q_ASSERT_X(prop,"StelDialog", "StelProperty does not exist"); Q_ASSERT_X(prop,"StelDialog", "StelProperty does not exist");
//use a proxy for the connection //use a proxy for the connection
new QComboBoxStelPropertyConnectionHelper(prop,comboBox); new QComboBoxStelPropertyConnectionHelper(prop,comboBox);
} }
void StelDialog::connectDoubleProperty(QDoubleSpinBox *spinBox, const QStri ng &propName) void StelDialog::connectDoubleProperty(QDoubleSpinBox *spinBox, const QStri ng &propName)
{ {
StelProperty* prop = StelApp::getInstance().getStelPropertyManager() ->getProperty(propName); StelProperty* prop = StelApp::getInstance().getStelPropertyManager() ->getProperty(propName);
Q_ASSERT_X(prop,"StelDialog", "StelProperty does not exist"); Q_ASSERT_X(prop,"StelDialog", "StelProperty does not exist");
//use a proxy for the connection //use a proxy for the connection
new QDoubleSpinBoxStelPropertyConnectionHelper(prop,spinBox); new QDoubleSpinBoxStelPropertyConnectionHelper(prop,spinBox);
} }
void StelDialog::connectDoubleProperty(QSlider *slider, const QString &prop Name,double minValue, double maxValue) void StelDialog::connectDoubleProperty(QSlider *slider, const QString &prop Name,double minValue, double maxValue)
{ {
StelProperty* prop = StelApp::getInstance().getStelPropertyManager() ->getProperty(propName); StelProperty* prop = StelApp::getInstance().getStelPropertyManager() ->getProperty(propName);
Q_ASSERT_X(prop,"StelDialog", "StelProperty does not exist"); Q_ASSERT_X(prop,"StelDialog", "StelProperty does not exist");
//The connection is handled by a helper class. It is automatically d estroyed when the slider is destroyed. //The connection is handled by a helper class. It is automatically d estroyed when the slider is destroyed.
new QSliderStelPropertyConnectionHelper(prop,minValue,maxValue,slide r); new QSliderStelPropertyConnectionHelper(prop,minValue,maxValue,slide r);
} }
skipping to change at line 286 skipping to change at line 267
dialog->setProperty("nightMode", StelApp::getInstance().getVisionMod eNight()); dialog->setProperty("nightMode", StelApp::getInstance().getVisionMod eNight());
} }
void StelDialog::handleMovedTo(QPoint newPos) void StelDialog::handleMovedTo(QPoint newPos)
{ {
QSettings *conf=StelApp::getInstance().getSettings(); QSettings *conf=StelApp::getInstance().getSettings();
Q_ASSERT(conf); Q_ASSERT(conf);
conf->setValue("DialogPositions/" + dialogName, QString("%1,%2").arg (newPos.x()).arg(newPos.y())); conf->setValue("DialogPositions/" + dialogName, QString("%1,%2").arg (newPos.x()).arg(newPos.y()));
} }
void StelDialog::handleDialogSizeChanged(QSizeF size)
{
QSettings *conf=StelApp::getInstance().getSettings();
Q_ASSERT(conf);
conf->setValue("DialogSizes/" + dialogName, QString("%1,%2").arg((in
t)size.width()).arg((int)size.height()));
}
//// --- Implementation of StelDialog_p.hpp classes follow --- //// --- Implementation of StelDialog_p.hpp classes follow ---
QAbstractButtonStelPropertyConnectionHelper::QAbstractButtonStelPropertyCon nectionHelper(StelProperty *prop, QAbstractButton *button) QAbstractButtonStelPropertyConnectionHelper::QAbstractButtonStelPropertyCon nectionHelper(StelProperty *prop, QAbstractButton *button)
:StelPropertyProxy(prop,button), button(button) :StelPropertyProxy(prop,button), button(button)
{ {
QVariant val = prop->getValue(); QVariant val = prop->getValue();
bool ok = val.canConvert<bool>(); bool ok = val.canConvert<bool>();
Q_ASSERT_X(ok,"QAbstractButtonStelPropertyConnectionHelper","Can not convert to bool datatype"); Q_ASSERT_X(ok,"QAbstractButtonStelPropertyConnectionHelper","Can not convert to bool datatype");
Q_UNUSED(ok); Q_UNUSED(ok);
onPropertyChanged(val); onPropertyChanged(val);
 End of changes. 9 change blocks. 
54 lines changed or deleted 42 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/