Commit 4ce88264 authored by Oliver Bock's avatar Oliver Bock
Browse files

Added fullscreen mode (center widget only)

* Alternative shortcuts are required when menu is hidden
  -> Actions won't be trigged otherwise
  -> Save/restore widget visibility states
  -> Shortcuts pending for actions: run, pause, stop
* Black window background when in fullscreen mode
* Also: finally implemented menu hide feature
* Also: added license info to about dialog
parent afa38600
...@@ -26,9 +26,26 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent) ...@@ -26,9 +26,26 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent)
QAction* animControl = ui.dockAnimControl->toggleViewAction(); QAction* animControl = ui.dockAnimControl->toggleViewAction();
animControl->setStatusTip("Toggle the animation control visibility"); animControl->setStatusTip("Toggle the animation control visibility");
animControl->setShortcut(QKeySequence::fromString("Alt+A")); animControl->setShortcut(QKeySequence(Qt::ALT + Qt::Key_A));
ui.menuView->addAction(animControl); ui.menuView->addAction(animControl);
// inital status (based on GUI)
m_rotationAxesVisible = ui.actionRotationAxes->isChecked();
m_menuBarVisible = ui.actionMenu_bar->isChecked();
m_statusBarVisible = ui.actionStatus_bar->isChecked();
m_animControlVisible = true;
m_animControlFloating = ui.dockAnimControl->isFloating();
// register alternate shortcuts (will be enabled when menu is hidden)
m_rotationAxesShortcut = new QShortcut(QKeySequence(Qt::ALT + Qt::Key_R), this);
m_rotationAxesShortcut->setEnabled(false);
m_menuBarShortcut = new QShortcut(QKeySequence(Qt::ALT + Qt::Key_M), this);
m_menuBarShortcut->setEnabled(false);
m_fullscreenShortcut = new QShortcut(QKeySequence(Qt::ALT + Qt::Key_F), this);
m_fullscreenShortcut->setEnabled(false);
// TODO: register all remaining shortcuts, too (to use them while menu is hidden!)
connect(ui.actionRun, SIGNAL(activated()), connect(ui.actionRun, SIGNAL(activated()),
ui.pulsarGlWidget, SLOT(runAnimation())); ui.pulsarGlWidget, SLOT(runAnimation()));
...@@ -53,6 +70,8 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent) ...@@ -53,6 +70,8 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent)
connect(ui.pulsarGlWidget, SIGNAL(pulseProfileUpdated(const QVector<float>&)), connect(ui.pulsarGlWidget, SIGNAL(pulseProfileUpdated(const QVector<float>&)),
ui.pulseScopeWidget, SLOT(drawCurve(const QVector<float>&))); ui.pulseScopeWidget, SLOT(drawCurve(const QVector<float>&)));
// initialize animation parameters (using GUI settings)
on_sliderPulsarSemiMajorAxis_valueChanged(ui.sliderPulsarSemiMajorAxis->value()); on_sliderPulsarSemiMajorAxis_valueChanged(ui.sliderPulsarSemiMajorAxis->value());
on_radioCompanionNS_toggled(true); on_radioCompanionNS_toggled(true);
...@@ -65,7 +84,20 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent) ...@@ -65,7 +84,20 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent)
PulsatingScience::~PulsatingScience() PulsatingScience::~PulsatingScience()
{ {
if(m_rotationAxesShortcut) {
m_rotationAxesShortcut->disconnect();
delete m_rotationAxesShortcut;
}
if(m_menuBarShortcut) {
m_menuBarShortcut->disconnect();
delete m_menuBarShortcut;
}
if(m_fullscreenShortcut) {
m_fullscreenShortcut->disconnect();
delete m_fullscreenShortcut;
}
} }
void PulsatingScience::on_pushRun_clicked() void PulsatingScience::on_pushRun_clicked()
...@@ -151,14 +183,120 @@ void PulsatingScience::on_sliderPulsarSemiMajorAxis_valueChanged(int value) ...@@ -151,14 +183,120 @@ void PulsatingScience::on_sliderPulsarSemiMajorAxis_valueChanged(int value)
ui.lcdPulsarSemiMajorAxis->setStyleSheet("color: black"); ui.lcdPulsarSemiMajorAxis->setStyleSheet("color: black");
} }
void PulsatingScience::rotationAxesToggled() {
if(m_rotationAxesVisible) {
on_actionRotationAxes_toggled(false);
ui.actionRotationAxes->setChecked(false);
}
else {
on_actionRotationAxes_toggled(true);
ui.actionRotationAxes->setChecked(true);
}
}
void PulsatingScience::on_actionRotationAxes_toggled(bool checked) {
m_rotationAxesVisible = checked;
}
void PulsatingScience::menuBarToggled()
{
if(ui.menuBar->isVisible()) {
on_actionMenu_bar_toggled(false);
ui.actionMenu_bar->setChecked(false);
}
else {
on_actionMenu_bar_toggled(true);
ui.actionMenu_bar->setChecked(true);
}
}
void PulsatingScience::on_actionMenu_bar_toggled(bool checked) void PulsatingScience::on_actionMenu_bar_toggled(bool checked)
{ {
checked ? ui.menuBar->show() : ui.menuBar->hide(); if(checked) {
ui.menuBar->show();
m_menuBarVisible = true;
// deactivate alternate shortcuts
m_rotationAxesShortcut->disconnect();
m_rotationAxesShortcut->setEnabled(false);
m_fullscreenShortcut->disconnect();
m_fullscreenShortcut->setEnabled(false);
m_menuBarShortcut->disconnect();
m_menuBarShortcut->setEnabled(false);
}
else {
ui.menuBar->hide();
m_menuBarVisible = false;
// activate alternate shortcuts
m_rotationAxesShortcut->setEnabled(true);
connect(m_rotationAxesShortcut, SIGNAL(activated()), this, SLOT(rotationAxesToggled()));
m_fullscreenShortcut->setEnabled(true);
connect(m_fullscreenShortcut, SIGNAL(activated()), this, SLOT(fullscreenToggled()));
m_menuBarShortcut->setEnabled(true);
connect(m_menuBarShortcut, SIGNAL(activated()), this, SLOT(menuBarToggled()));
}
}
void PulsatingScience::fullscreenToggled()
{
if((windowState() & Qt::WindowFullScreen) > 0) {
on_actionFullscreen_toggled(false);
ui.actionFullscreen->setChecked(false);
}
else {
on_actionFullscreen_toggled(true);
ui.actionFullscreen->setChecked(true);
}
}
void PulsatingScience::on_actionFullscreen_toggled(bool checked)
{
if(checked) {
window()->setWindowState(windowState() | Qt::WindowFullScreen);
// assuming text being black
setBackgroundRole(QPalette::Text);
if(m_menuBarVisible) {
on_actionMenu_bar_toggled(false);
// keep visibility setting
m_menuBarVisible = true;
}
if(m_statusBarVisible) ui.statusbar->hide();
if(m_animControlVisible && !m_animControlFloating) {
ui.dockAnimControl->hide();
// keep visibility setting
m_animControlVisible = true;
}
}
else {
window()->setWindowState(windowState() & ~Qt::WindowFullScreen);
setBackgroundRole(QPalette::Window);
if(m_menuBarVisible) on_actionMenu_bar_toggled(true);
if(m_statusBarVisible) ui.statusbar->show();
if(m_animControlVisible && !m_animControlFloating) ui.dockAnimControl->show();
}
} }
void PulsatingScience::on_actionStatus_bar_toggled(bool checked) void PulsatingScience::on_actionStatus_bar_toggled(bool checked)
{ {
checked ? ui.statusbar->show() : ui.statusbar->hide(); if(checked) {
ui.statusbar->show();
m_statusBarVisible = true;
}
else {
ui.statusbar->hide();
m_statusBarVisible = false;
}
}
void PulsatingScience::on_dockAnimControl_visibilityChanged(bool visible) {
m_animControlVisible = visible;
}
void PulsatingScience::on_dockAnimControl_topLevelChanged(bool topLevel) {
m_animControlFloating = topLevel;
} }
void PulsatingScience::on_actionAbout_activated() void PulsatingScience::on_actionAbout_activated()
...@@ -168,7 +306,8 @@ void PulsatingScience::on_actionAbout_activated() ...@@ -168,7 +306,8 @@ void PulsatingScience::on_actionAbout_activated()
"International Year of Astronomy 2009<br><br>" "International Year of Astronomy 2009<br><br>"
"Authors: Oliver Bock, Benjamin Knispel<br><br>" "Authors: Oliver Bock, Benjamin Knispel<br><br>"
"Background image: The Carina Nebula<br>" "Background image: The Carina Nebula<br>"
"Courtesy of: ESO/IDA/Danish 1.5 m/R.Gendler, J-E. Ovaldsen, C. Th&ouml;ne and C. Feron<br><br>" "(Courtesy of ESO/IDA/Danish 1.5 m/R.Gendler, J-E. Ovaldsen, C. Th&ouml;ne and C. Feron)<br><br>"
"License: GNU General Public License (Version 3)<br><br>"
"Copyright &copy; 2009 " "Copyright &copy; 2009 "
"<a href=\"http://www.aei.mpg.de\">Max-Planck-Institut f&uuml;r Gravitationsphysik</a>"); "<a href=\"http://www.aei.mpg.de\">Max-Planck-Institut f&uuml;r Gravitationsphysik</a>");
} }
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <QtGui/QMainWindow> #include <QtGui/QMainWindow>
#include <QtGui/QMessageBox> #include <QtGui/QMessageBox>
#include <QtGui/QShortcut>
#include "ui_pulsatingscience.h" #include "ui_pulsatingscience.h"
...@@ -48,14 +49,32 @@ public slots: ...@@ -48,14 +49,32 @@ public slots:
void on_sliderPulsarMagneticAxisInclination_valueChanged(int value); void on_sliderPulsarMagneticAxisInclination_valueChanged(int value);
void on_sliderPulsarSemiMajorAxis_valueChanged(int value); void on_sliderPulsarSemiMajorAxis_valueChanged(int value);
void rotationAxesToggled();
void on_actionRotationAxes_toggled(bool checked);
void fullscreenToggled();
void on_actionFullscreen_toggled(bool checked);
void menuBarToggled();
void on_actionMenu_bar_toggled(bool checked); void on_actionMenu_bar_toggled(bool checked);
void on_actionStatus_bar_toggled(bool checked); void on_actionStatus_bar_toggled(bool checked);
void on_dockAnimControl_visibilityChanged(bool visible);
void on_dockAnimControl_topLevelChanged(bool topLevel);
void on_actionAbout_activated(); void on_actionAbout_activated();
void updatePulsarSemiMajorAxisValue(double value); void updatePulsarSemiMajorAxisValue(double value);
private: private:
Ui::PulsatingScienceClass ui; Ui::PulsatingScienceClass ui;
QShortcut *m_rotationAxesShortcut;
QShortcut *m_menuBarShortcut;
QShortcut *m_fullscreenShortcut;
bool m_rotationAxesVisible;
bool m_menuBarVisible;
bool m_statusBarVisible;
bool m_animControlVisible;
bool m_animControlFloating;
}; };
#endif // PULSATINGSCIENCE_H #endif // PULSATINGSCIENCE_H
...@@ -471,16 +471,18 @@ ...@@ -471,16 +471,18 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>693</width> <width>693</width>
<height>31</height> <height>24</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuView" > <widget class="QMenu" name="menuView" >
<property name="title" > <property name="title" >
<string>&amp;View</string> <string>&amp;View</string>
</property> </property>
<addaction name="actionMenu_bar" />
<addaction name="actionRotationAxes" /> <addaction name="actionRotationAxes" />
<addaction name="separator" /> <addaction name="separator" />
<addaction name="actionFullscreen" />
<addaction name="separator" />
<addaction name="actionMenu_bar" />
<addaction name="actionStatus_bar" /> <addaction name="actionStatus_bar" />
</widget> </widget>
<widget class="QMenu" name="menuHelp" > <widget class="QMenu" name="menuHelp" >
...@@ -630,9 +632,6 @@ ...@@ -630,9 +632,6 @@
<property name="shortcut" > <property name="shortcut" >
<string>Alt+M</string> <string>Alt+M</string>
</property> </property>
<property name="visible" >
<bool>false</bool>
</property>
</action> </action>
<action name="actionStatus_bar" > <action name="actionStatus_bar" >
<property name="checkable" > <property name="checkable" >
...@@ -659,6 +658,17 @@ ...@@ -659,6 +658,17 @@
<string>Alt+R</string> <string>Alt+R</string>
</property> </property>
</action> </action>
<action name="actionFullscreen" >
<property name="checkable" >
<bool>true</bool>
</property>
<property name="text" >
<string>Fullscreen</string>
</property>
<property name="shortcut" >
<string>Alt+F</string>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment