OcularsGuiPanel.cpp   OcularsGuiPanel.cpp 
skipping to change at line 20 skipping to change at line 20
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
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, US A. Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, US A.
*/ */
#include "config.h"
#include "Oculars.hpp" #include "Oculars.hpp"
#include "OcularsGuiPanel.hpp" #include "OcularsGuiPanel.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelGui.hpp" #include "StelGui.hpp"
#include "StelGuiItems.hpp" #include "StelGuiItems.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelActionMgr.hpp"
#include <QAction>
#include <QGridLayout> #include <QGridLayout>
#include <QGraphicsLinearLayout> #include <QGraphicsLinearLayout>
#include <QGraphicsPathItem> #include <QGraphicsPathItem>
#include <QGraphicsProxyWidget> #include <QGraphicsProxyWidget>
#include <QLabel> #include <QLabel>
#include <QPainter> #include <QPainter>
#include <QPen> #include <QPen>
#include <QPushButton> #include <QPushButton>
#include <QSignalMapper> #include <QSignalMapper>
#include <QWidget> #include <QWidget>
OcularsGuiPanel::OcularsGuiPanel(Oculars* plugin, OcularsGuiPanel::OcularsGuiPanel(Oculars* plugin,
QGraphicsWidget *parent, QGraphicsWidget *parent,
Qt::WindowFlags wFlags): Qt::WindowFlags wFlags):
QGraphicsWidget(parent, wFlags), QGraphicsWidget(parent, wFlags),
ocularsPlugin(plugin), ocularsPlugin(plugin),
parentWidget(parent), parentWidget(parent),
borderPath(0) borderPath(0)
{ {
//setVisible(false);
//setMinimumSize(0, 0);
setMaximumSize(300, 400); setMaximumSize(300, 400);
//setPreferredSize(230, 100);
setContentsMargins(0, 0, 0, 0); setContentsMargins(0, 0, 0, 0);
//TODO: set font? //TODO: set font?
//First create the layout and populate it, then set it? //First create the layout and populate it, then set it?
mainLayout = new QGraphicsLinearLayout(Qt::Vertical); mainLayout = new QGraphicsLinearLayout(Qt::Vertical);
//layout->setContentsMargins(0, 0, 0, 0);
//layout->setSpacing(0);
//Button bar //Button bar
buttonBar = new QGraphicsWidget(); buttonBar = new QGraphicsWidget();
mainLayout->addItem(buttonBar); mainLayout->addItem(buttonBar);
//QPixmap leftBackground(":/graphicGui/btbg-left.png");
//QPixmap middleBackground(":/graphicGui/btbg-middle.png");
//QPixmap rightBackground(":/graphicGui/btbg-right.png");
StelApp& stelApp = StelApp::getInstance(); StelApp& stelApp = StelApp::getInstance();
Q_ASSERT(ocularsPlugin->actionShowOcular); Q_ASSERT(ocularsPlugin->actionShowOcular);
buttonOcular = new StelButton(buttonBar, buttonOcular = new StelButton(buttonBar,
QPixmap(":/ocular/bt_ocular_on.png"), QPixmap(":/ocular/bt_ocular_on.png"),
QPixmap(":/ocular/bt_ocular_off.png"), QPixmap(":/ocular/bt_ocular_off.png"),
QPixmap(), QPixmap(),
ocularsPlugin->actionShowOcular, ocularsPlugin->actionShowOcular,
true); //No background true); //No background
buttonOcular->setToolTip(ocularsPlugin->actionShowOcular->text()); buttonOcular->setToolTip(ocularsPlugin->actionShowOcular->getText())
//buttonOcular->setBackgroundPixmap(leftBackground); ;
buttonOcular->setParentItem(buttonBar); buttonOcular->setParentItem(buttonBar);
//Hack to avoid buttonOcular being left "checked" if it has been tog gled //Hack to avoid buttonOcular being left "checked" if it has been tog gled
//without any object selected. //without any object selected.
disconnect(ocularsPlugin->actionShowOcular, SIGNAL(toggled(bool)), disconnect(ocularsPlugin->actionShowOcular, SIGNAL(toggled(bool)),
ocularsPlugin, SLOT(enableOcular(bool))); ocularsPlugin, SLOT(enableOcular(bool)));
connect(ocularsPlugin->actionShowOcular, SIGNAL(toggled(bool)), connect(ocularsPlugin->actionShowOcular, SIGNAL(toggled(bool)),
ocularsPlugin, SLOT(enableOcular(bool))); ocularsPlugin, SLOT(enableOcular(bool)));
Q_ASSERT(ocularsPlugin->actionShowCrosshairs); Q_ASSERT(ocularsPlugin->actionShowCrosshairs);
buttonCrosshairs = new StelButton(buttonBar, buttonCrosshairs = new StelButton(buttonBar,
QPixmap(":/ocular/bt_crosshairs_on .png"), QPixmap(":/ocular/bt_crosshairs_on .png"),
QPixmap(":/ocular/bt_crosshairs_of f.png"), QPixmap(":/ocular/bt_crosshairs_of f.png"),
QPixmap(), QPixmap(),
ocularsPlugin->actionShowCrosshair s, ocularsPlugin->actionShowCrosshair s,
true); true);
buttonCrosshairs->setToolTip(ocularsPlugin->actionShowCrosshairs->te xt()); buttonCrosshairs->setToolTip(ocularsPlugin->actionShowCrosshairs->ge tText());
buttonCrosshairs->setVisible(false); buttonCrosshairs->setVisible(false);
Q_ASSERT(ocularsPlugin->actionShowSensor); Q_ASSERT(ocularsPlugin->actionShowSensor);
buttonCcd = new StelButton(buttonBar, buttonCcd = new StelButton(buttonBar,
QPixmap(":/ocular/bt_sensor_on.png"), QPixmap(":/ocular/bt_sensor_on.png"),
QPixmap(":/ocular/bt_sensor_off.png"), QPixmap(":/ocular/bt_sensor_off.png"),
QPixmap(), QPixmap(),
ocularsPlugin->actionShowSensor, ocularsPlugin->actionShowSensor,
true); true);
buttonCcd->setToolTip(ocularsPlugin->actionShowSensor->text()); buttonCcd->setToolTip(ocularsPlugin->actionShowSensor->getText());
Q_ASSERT(ocularsPlugin->actionShowTelrad); Q_ASSERT(ocularsPlugin->actionShowTelrad);
buttonTelrad = new StelButton(buttonBar, buttonTelrad = new StelButton(buttonBar,
QPixmap(":/ocular/bt_telrad_on.png"), QPixmap(":/ocular/bt_telrad_on.png"),
QPixmap(":/ocular/bt_telrad_off.png"), QPixmap(":/ocular/bt_telrad_off.png"),
QPixmap(), QPixmap(),
ocularsPlugin->actionShowTelrad, ocularsPlugin->actionShowTelrad,
true); true);
buttonTelrad->setToolTip(ocularsPlugin->actionShowTelrad->text()); buttonTelrad->setToolTip(ocularsPlugin->actionShowTelrad->getText()) ;
Q_ASSERT(ocularsPlugin->actionConfiguration); Q_ASSERT(ocularsPlugin->actionConfiguration);
buttonConfiguration = new StelButton(buttonBar, buttonConfiguration = new StelButton(buttonBar,
QPixmap(":/ocular/bt_settings_o n.png"), QPixmap(":/ocular/bt_settings_o n.png"),
QPixmap(":/ocular/bt_settings_o ff.png"), QPixmap(":/ocular/bt_settings_o ff.png"),
QPixmap(), QPixmap(),
ocularsPlugin->actionConfigurat ion, ocularsPlugin->actionConfigurat ion,
true); true);
buttonConfiguration->setToolTip(ocularsPlugin->actionConfiguration-> text()); buttonConfiguration->setToolTip(ocularsPlugin->actionConfiguration-> getText());
qreal buttonHeight = buttonOcular->boundingRect().height(); qreal buttonHeight = buttonOcular->boundingRect().height();
buttonBar->setMinimumHeight(buttonHeight); buttonBar->setMinimumHeight(buttonHeight);
buttonBar->setMaximumHeight(buttonHeight); buttonBar->setMaximumHeight(buttonHeight);
setLayout(mainLayout); setLayout(mainLayout);
//Widgets with control and information fields //Widgets with control and information fields
ocularControls = new QGraphicsWidget(this); ocularControls = new QGraphicsWidget(this);
ocularControls->setParentItem(this); ocularControls->setParentItem(this);
skipping to change at line 188 skipping to change at line 179
QPixmap pa(":/graphicGui/btTimeRewind-on.png"); QPixmap pa(":/graphicGui/btTimeRewind-on.png");
QPixmap prevArrow = pa.scaledToHeight(lineHeight, Qt::SmoothTransfor mation); QPixmap prevArrow = pa.scaledToHeight(lineHeight, Qt::SmoothTransfor mation);
QPixmap paOff(":/graphicGui/btTimeRewind-off.png"); QPixmap paOff(":/graphicGui/btTimeRewind-off.png");
QPixmap prevArrowOff = paOff.scaledToHeight(lineHeight, Qt::SmoothTr ansformation); QPixmap prevArrowOff = paOff.scaledToHeight(lineHeight, Qt::SmoothTr ansformation);
QPixmap na(":/graphicGui/btTimeForward-on.png"); QPixmap na(":/graphicGui/btTimeForward-on.png");
QPixmap nextArrow = na.scaledToHeight(lineHeight, Qt::SmoothTransfor mation); QPixmap nextArrow = na.scaledToHeight(lineHeight, Qt::SmoothTransfor mation);
QPixmap naOff(":/graphicGui/btTimeForward-off.png"); QPixmap naOff(":/graphicGui/btTimeForward-off.png");
QPixmap nextArrowOff = naOff.scaledToHeight(lineHeight, Qt::SmoothTr ansformation); QPixmap nextArrowOff = naOff.scaledToHeight(lineHeight, Qt::SmoothTr ansformation);
QAction* defaultAction = new QAction(this); StelAction* defaultAction = new StelAction(this);
defaultAction->setCheckable(false); defaultAction->setCheckable(false);
prevOcularButton = new StelButton(ocularControls, prevOcularButton = new StelButton(ocularControls,
prevArrow, prevArrow,
prevArrowOff, prevArrowOff,
QPixmap(), QPixmap(),
defaultAction); defaultAction);
prevOcularButton->setToolTip(q_("Previous ocular")); prevOcularButton->setToolTip(q_("Previous ocular"));
nextOcularButton = new StelButton(ocularControls, nextOcularButton = new StelButton(ocularControls,
nextArrow, nextArrow,
nextArrowOff, nextArrowOff,
skipping to change at line 426 skipping to change at line 417
this, SLOT(updateOcularControls())); this, SLOT(updateOcularControls()));
connect(ocularsPlugin, SIGNAL(selectedCCDChanged()), connect(ocularsPlugin, SIGNAL(selectedCCDChanged()),
this, SLOT(updateCcdControls())); this, SLOT(updateCcdControls()));
connect(ocularsPlugin, SIGNAL(selectedTelescopeChanged()), connect(ocularsPlugin, SIGNAL(selectedTelescopeChanged()),
this, SLOT(updateTelescopeControls())); this, SLOT(updateTelescopeControls()));
connect(ocularsPlugin, SIGNAL(selectedLensChanged()), connect(ocularsPlugin, SIGNAL(selectedLensChanged()),
this, SLOT(updateTelescopeControls())); this, SLOT(updateTelescopeControls()));
//Night mode //Night mode
connect(&stelApp, SIGNAL(colorSchemeChanged(const QString&)), connect(&stelApp, SIGNAL(colorSchemeChanged(const QString&)),
this, SLOT(setColorScheme(const QString&))); this, SLOT(setColorScheme(const QString&)));
setColorScheme(stelApp.getCurrentStelStyle()); setColorScheme(stelApp.getCurrentStelStyle());
} }
OcularsGuiPanel::~OcularsGuiPanel() OcularsGuiPanel::~OcularsGuiPanel()
{ {
if (borderPath) if (borderPath)
delete borderPath; delete borderPath;
} }
void OcularsGuiPanel::showOcularGui() void OcularsGuiPanel::showOcularGui()
skipping to change at line 577 skipping to change at line 568
ocularControls->setMinimumSize(widgetWidth, widgetHeight); ocularControls->setMinimumSize(widgetWidth, widgetHeight);
ocularControls->resize(widgetWidth, widgetHeight); ocularControls->resize(widgetWidth, widgetHeight);
setOcularControlsVisible(true); setOcularControlsVisible(true);
updateTelescopeControls();//Contains a call to updatePosition() updateTelescopeControls();//Contains a call to updatePosition()
} }
void OcularsGuiPanel::updateLensControls() void OcularsGuiPanel::updateLensControls()
{ {
int index = ocularsPlugin->selectedOcularIndex;
//Ocular* ocular = ocularsPlugin->oculars[index];
Lens* lens = ocularsPlugin->selectedLens(); Lens* lens = ocularsPlugin->selectedLens();
index = ocularsPlugin->selectedLensIndex; int index = ocularsPlugin->selectedLensIndex;
QString fullName; QString fullName;
QString multiplerString; QString multiplerString;
if (lens != NULL) if (lens != NULL)
{ {
QString name = lens->name(); QString name = lens->name();
if (name.isEmpty()) if (name.isEmpty())
{ {
fullName = QString(q_("Lens #%1")).arg(index); fullName = QString(q_("Lens #%1")).arg(index);
} }
skipping to change at line 869 skipping to change at line 857
updatePosition(); updatePosition();
} }
void OcularsGuiPanel::setLensControlsVisible(bool show) void OcularsGuiPanel::setLensControlsVisible(bool show)
{ {
if (show) if (show)
{ {
if (!lensControls->isVisible()) if (!lensControls->isVisible())
{ {
lensControls->setVisible(true); lensControls->setVisible(true);
mainLayout->insertItem(2, lensControls); mainLayout->insertItem(3, lensControls);
} }
} }
else else
{ {
if (lensControls->isVisible()) if (lensControls->isVisible())
{ {
mainLayout->removeItem(lensControls); mainLayout->removeItem(lensControls);
lensControls->setVisible(false); lensControls->setVisible(false);
} }
} }
skipping to change at line 893 skipping to change at line 881
mainLayout->geometry().height()); mainLayout->geometry().height());
} }
void OcularsGuiPanel::setOcularControlsVisible(bool show) void OcularsGuiPanel::setOcularControlsVisible(bool show)
{ {
if (show) if (show)
{ {
if (!ocularControls->isVisible()) if (!ocularControls->isVisible())
{ {
ocularControls->setVisible(true); ocularControls->setVisible(true);
mainLayout->insertItem(0, ocularControls); mainLayout->insertItem(1, ocularControls);
} }
} }
else else
{ {
if (ocularControls->isVisible()) if (ocularControls->isVisible())
{ {
mainLayout->removeItem(ocularControls); mainLayout->removeItem(ocularControls);
ocularControls->setVisible(false); ocularControls->setVisible(false);
} }
} }
skipping to change at line 915 skipping to change at line 903
updateMainButtonsPositions(); updateMainButtonsPositions();
} }
void OcularsGuiPanel::setCcdControlsVisible(bool show) void OcularsGuiPanel::setCcdControlsVisible(bool show)
{ {
if (show) if (show)
{ {
if (!ccdControls->isVisible()) if (!ccdControls->isVisible())
{ {
ccdControls->setVisible(true); ccdControls->setVisible(true);
mainLayout->insertItem(0, ccdControls); mainLayout->insertItem(1, ccdControls);
} }
} }
else else
{ {
if (ccdControls->isVisible()) if (ccdControls->isVisible())
{ {
mainLayout->removeItem(ccdControls); mainLayout->removeItem(ccdControls);
ccdControls->setVisible(false); ccdControls->setVisible(false);
} }
} }
} }
void OcularsGuiPanel::setTelescopeControlsVisible(bool show) void OcularsGuiPanel::setTelescopeControlsVisible(bool show)
{ {
if (show) if (show)
{ {
if (!telescopeControls->isVisible()) if (!telescopeControls->isVisible())
{ {
telescopeControls->setVisible(true); telescopeControls->setVisible(true);
mainLayout->insertItem(1, telescopeControls); mainLayout->insertItem(2, telescopeControls);
} }
} }
else else
{ {
if (telescopeControls->isVisible()) if (telescopeControls->isVisible())
{ {
mainLayout->removeItem(telescopeControls); mainLayout->removeItem(telescopeControls);
telescopeControls->setVisible(false); telescopeControls->setVisible(false);
} }
} }
skipping to change at line 976 skipping to change at line 964
qreal spacing = 0.; qreal spacing = 0.;
if (prevTelescopeButton) if (prevTelescopeButton)
{ {
width += 2 * prevTelescopeButton->getButtonPixmapWidth(); width += 2 * prevTelescopeButton->getButtonPixmapWidth();
posX = prevTelescopeButton->getButtonPixmapWidth(); posX = prevTelescopeButton->getButtonPixmapWidth();
} }
if (buttonOcular->parentItem()) if (buttonOcular->parentItem())
{ {
qreal parentWidth = buttonOcular->parentItem()->boundingRect ().width(); qreal parentWidth = buttonOcular->parentItem()->boundingRect ().width();
int nGaps = n - 1;//n buttons have n-1 gaps int nGaps = n - 1;//n buttons have n-1 gaps
//posX = round((parentWidth-width)/2.0);//Centering, depreca ted
spacing = round((parentWidth-width)/nGaps); spacing = round((parentWidth-width)/nGaps);
} }
buttonOcular->setPos(posX, posY); buttonOcular->setPos(posX, posY);
posX += buttonOcular->getButtonPixmapWidth() + spacing; posX += buttonOcular->getButtonPixmapWidth() + spacing;
if (buttonCrosshairs->isVisible()) if (buttonCrosshairs->isVisible())
{ {
buttonCrosshairs->setPos(posX, posY); buttonCrosshairs->setPos(posX, posY);
posX += buttonCrosshairs->getButtonPixmapWidth() + spacing; posX += buttonCrosshairs->getButtonPixmapWidth() + spacing;
} }
buttonCcd->setPos(posX, posY); buttonCcd->setPos(posX, posY);
skipping to change at line 1047 skipping to change at line 1034
fieldCcdName->setFont(font); fieldCcdName->setFont(font);
fieldCcdDimensions->setFont(font); fieldCcdDimensions->setFont(font);
fieldCcdRotation->setFont(font); fieldCcdRotation->setFont(font);
fieldTelescopeName->setFont(font); fieldTelescopeName->setFont(font);
fieldMagnification->setFont(font); fieldMagnification->setFont(font);
fieldFov->setFont(font); fieldFov->setFont(font);
fieldLensName->setFont(font); fieldLensName->setFont(font);
fieldLensMultipler->setFont(font); fieldLensMultipler->setFont(font);
} }
void OcularsGuiPanel::setButtonsNightMode(bool nightMode)
{
//Reused from SkyGui, with modifications
foreach (QGraphicsItem *child, QGraphicsItem::children())
{
foreach (QGraphicsItem *grandchild, child->children())
{
StelButton* button = qgraphicsitem_cast<StelButton*>
(grandchild);
if (button)
button->setRedMode(nightMode);
}
}
}
void OcularsGuiPanel::setColorScheme(const QString &schemeName) void OcularsGuiPanel::setColorScheme(const QString &schemeName)
{ {
if (schemeName == "night_color") Q_UNUSED(schemeName);
{ borderPath->setPen(QColor::fromRgbF(0.7,0.7,0.7,0.5));
borderPath->setPen(QColor::fromRgbF(0.7,0.2,0.2,0.5)); borderPath->setBrush(QColor::fromRgbF(0.15, 0.16, 0.19, 0.2));
borderPath->setBrush(QColor::fromRgbF(0.23, 0.13, 0.03, 0.2) setControlsColor(QColor::fromRgbF(0.9, 0.91, 0.95, 0.9));
);
setControlsColor(QColor::fromRgbF(0.9, 0.33, 0.33, 0.9));
setButtonsNightMode(true);
}
else
{
borderPath->setPen(QColor::fromRgbF(0.7,0.7,0.7,0.5));
borderPath->setBrush(QColor::fromRgbF(0.15, 0.16, 0.19, 0.2)
);
setControlsColor(QColor::fromRgbF(0.9, 0.91, 0.95, 0.9));
setButtonsNightMode(false);
}
} }
QPixmap OcularsGuiPanel::createPixmapFromText(const QString& text, QPixmap OcularsGuiPanel::createPixmapFromText(const QString& text,
int width, int width,
int height, int height,
const QFont& font, const QFont& font,
const QColor& textColor, const QColor& textColor,
const QColor& backgroundColor ) const QColor& backgroundColor )
{ {
if (width <= 0 || height <=0) if (width <= 0 || height <=0) {
return QPixmap(); return QPixmap();
}
QPixmap pixmap(width, height); QPixmap pixmap(width, height);
pixmap.fill(backgroundColor); pixmap.fill(backgroundColor);
if (text.isEmpty()) if (text.isEmpty()) {
return pixmap; return pixmap;
}
QPainter painter(&pixmap); QPainter painter(&pixmap);
painter.setFont(font); painter.setFont(font);
painter.setPen(QPen(textColor)); painter.setPen(QPen(textColor));
painter.drawText(0, 0, width, height, painter.drawText(0, 0, width, height,
Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextSingl eLine, Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextSingl eLine,
text); text);
return pixmap; return pixmap;
} }
 End of changes. 27 change blocks. 
60 lines changed or deleted 23 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/