StelMainWindow.cpp   StelMainWindow.cpp 
skipping to change at line 21 skipping to change at line 21
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#include "StelMainWindow.hpp" #include "StelMainWindow.hpp"
#include <stdexcept>
#include "StelApp.hpp"
#include "StelMainGraphicsView.hpp"
#include "StelFileMgr.hpp"
#include "StelModuleMgr.hpp"
#include "StelTranslator.hpp"
#include <QSettings> #include <QSettings>
#include <QResizeEvent> #include <QResizeEvent>
#include <QIcon> #include <QIcon>
#include <QDebug> #include <QDebug>
#include <QFontDatabase>
#include <QCoreApplication> #include <QCoreApplication>
#include <QApplication> #include <QApplication>
#include <QHBoxLayout>
#include <stdexcept> #include <QFontDatabase>
#include "StelApp.hpp" #include <QGLWidget>
#include "StelMainGraphicsView.hpp"
#include "StelFileMgr.hpp"
#include "StelModuleMgr.hpp"
#include "StelGui.hpp"
#include "StelTranslator.hpp"
// Initialize static variables // Initialize static variables
StelMainWindow* StelMainWindow::singleton = NULL; StelMainWindow* StelMainWindow::singleton = NULL;
StelMainWindow::StelMainWindow(QWidget* parent) : QMainWindow(parent), init Complete(false) StelMainWindow::StelMainWindow() : QMainWindow(NULL)
{ {
// Can't create 2 StelMainWindow instances // Can't create 2 StelMainWindow instances
Q_ASSERT(!singleton); Q_ASSERT(!singleton);
singleton = this; singleton = this;
}
// Update the translated title setAttribute(Qt::WA_NoSystemBackground);
void StelMainWindow::initTitleI18n()
{
QString appNameI18n = q_("Stellarium %1").arg(StelApp::getApplicatio
nVersion());
setWindowTitle(appNameI18n);
}
void StelMainWindow::init()
{
setWindowIcon(QIcon(":/mainWindow/icon.bmp")); setWindowIcon(QIcon(":/mainWindow/icon.bmp"));
initTitleI18n(); initTitleI18n();
QString fName; // Add the DejaVu font that we use everywhere in the program
try try
{ {
fName = StelApp::getInstance().getFileMgr().findFile("data/D const QString& fName = StelFileMgr::findFile("data/DejaVuSan
ejaVuSans.ttf"); s.ttf");
if (!fName.isEmpty())
QFontDatabase::addApplicationFont(fName);
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
// Removed this warning practically allowing to package the program without the font file. // Removed this warning practically allowing to package the program without the font file.
// This is useful for distribution having already a package for DejaVu font. // This is useful for distribution having already a package for DejaVu font.
// qWarning() << "ERROR while loading font DejaVuSans : " << e.what(); // qWarning() << "ERROR while loading font DejaVuSans : " << e.what();
} }
if (!fName.isEmpty())
QFontDatabase::addApplicationFont(fName);
// Init the main window. It must be done here because it is not the mainGraphicsView = new StelMainGraphicsView(this);
responsability of StelApp to do that setCentralWidget(mainGraphicsView);
QCoreApplication::processEvents(); }
QSettings* settings = StelApp::getInstance().getSettings(); // Update the translated title
resize(settings->value("video/screen_w", 800).toInt(), settings->val void StelMainWindow::initTitleI18n()
ue("video/screen_h", 600).toInt()); {
QString appNameI18n = q_("Stellarium %1").arg(StelUtils::getApplicat
ionVersion());
setWindowTitle(appNameI18n);
}
if (settings->value("video/fullscreen", true).toBool()) void StelMainWindow::init(QSettings* conf)
{
resize(conf->value("video/screen_w", 800).toInt(), conf->value("vide
o/screen_h", 600).toInt());
if (conf->value("video/fullscreen", true).toBool())
{ {
showFullScreen(); setFullScreen(true);
} }
else else
{ {
show(); setFullScreen(false);
} }
show();
// Process the event to make the window visible and create the openG
L context.
QCoreApplication::processEvents();
mainGraphicsView->init(conf);
}
StelMainGraphicsView::getInstance().init(); void StelMainWindow::deinit()
{
initComplete = true; StelMainGraphicsView::getInstance().deinitGL();
} }
// Alternate fullscreen mode/windowed mode if possible // Alternate fullscreen mode/windowed mode if possible
void StelMainWindow::toggleFullScreen() void StelMainWindow::toggleFullScreen()
{ {
// Toggle full screen // Toggle full screen
if (!isFullScreen()) if (getFullScreen())
{ {
showFullScreen(); setFullScreen(false);
} }
else else
{ {
showNormal(); setFullScreen(true);
} }
} }
// Get whether fullscreen is activated or not // Get whether fullscreen is activated or not
bool StelMainWindow::getFullScreen() const bool StelMainWindow::getFullScreen() const
{ {
return isFullScreen(); return windowState().testFlag(Qt::WindowFullScreen);
} }
// Set whether fullscreen is activated or not // Set whether fullscreen is activated or not.
// Don't use the showFullScreen() and showNormal() methods since they have
an unexpected behaviour.
void StelMainWindow::setFullScreen(bool b) void StelMainWindow::setFullScreen(bool b)
{ {
if (b) if (b)
showFullScreen(); setWindowState(windowState() | Qt::WindowFullScreen);
else else
showNormal(); setWindowState(windowState() & ~Qt::WindowFullScreen);
} }
void StelMainWindow::closeEvent(QCloseEvent* event) void StelMainWindow::closeEvent(QCloseEvent* event)
{ {
event->ignore(); event->ignore();
GETSTELMODULE(StelGui)->quitStellarium(); QCoreApplication::exit();
}
void StelMainWindow::resizeEvent(QResizeEvent* event)
{
QMainWindow::resizeEvent(event);
} }
 End of changes. 25 change blocks. 
52 lines changed or deleted 53 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/