2 * This file is part of jSpeed.
4 * jSpeed is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * jSpeed is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with jSpeed. If not, see <http://www.gnu.org/licenses/>.
19 #include <QtGui/QApplication>
20 #include <QtGui/QDesktopWidget>
21 #include "graphicsscreen.h"
22 #include "toolbaritem.h"
23 #include "graphicsscene.h"
28 int const PADDING = 8;
31 GraphicsScreen::GraphicsScreen(QWidget* parent): QGraphicsView(parent),
32 AbstractScreen(), scene_(0), isFlipped_(false)
34 QRect rect = QApplication::desktop()->availableGeometry();
36 scene_ = new GraphicsScene(QRect(QPoint(0, 0), rect.size()));
39 connect(scene_, SIGNAL(clicked()), this, SIGNAL(clicked()));
41 minimizeButton_ = new ToolbarItem(":/resources/minimize.png", ":/resources/minimize_active.png");
42 minimizeButton_->setZValue(9999);
43 scene_->addItem(minimizeButton_);
44 connect(minimizeButton_, SIGNAL(clicked()), this, SIGNAL(minimizePressed()));
46 imageWidth_ = minimizeButton_->pixmap().width();
48 closeButton_ = new ToolbarItem(":/resources/close.png", ":/resources/close_active.png");
49 closeButton_->setZValue(9999);
50 scene_->addItem(closeButton_);
51 connect(closeButton_, SIGNAL(clicked()), this, SIGNAL(closePressed()));
53 settingsButton_ = new ToolbarItem(":/resources/settings.png", ":/resources/settings_active.png");
54 settingsButton_->setZValue(9999);
55 scene_->addItem(settingsButton_);
56 connect(settingsButton_, SIGNAL(clicked()), this, SIGNAL(settingsPressed()));
60 connect(&(Odometer::instance()), SIGNAL(dataUpdated()), this, SLOT(update()));
61 connect(&(Odometer::instance()), SIGNAL(unitChanged()), this, SLOT(update()));
64 GraphicsScreen::~GraphicsScreen()
68 void GraphicsScreen::reArrange()
70 QRect rect = QApplication::desktop()->screenGeometry();
71 scene_->setSceneRect(rect);
72 minimizeButton_->setPos(PADDING, PADDING);
73 closeButton_->setPos(rect.width() - imageWidth_ - PADDING, PADDING);
74 settingsButton_->setPos((rect.width() / 2) - (imageWidth_ / 2), PADDING);
77 void GraphicsScreen::flip()
86 setTransform(QTransform(1, 0, 0, 0, -1, 0, 0, 0, 1));
91 GraphicsScene* GraphicsScreen::getScene() const