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 <QtGui/QGraphicsScene>
22 #include <QtGui/QApplication>
23 #include "graphicsscreen.h"
24 #include "imageitem.h"
25 #include "graphicsscene.h"
30 int const PADDING = 8;
33 GraphicsScreen::GraphicsScreen(QWidget* parent): QGraphicsView(parent),
34 AbstractScreen(), scene_(0)
36 QRect rect = QApplication::desktop()->availableGeometry();
38 scene_ = new GraphicsScene(QRect(QPoint(0, 0), rect.size()));
41 connect(scene_, SIGNAL(clicked()), this, SIGNAL(clicked()));
43 minimizeButton_ = new ImageItem(":/resources/minimize.png");
44 minimizeButton_->setZValue(9999);
45 scene_->addItem(minimizeButton_);
46 connect(minimizeButton_, SIGNAL(clicked()), this, SIGNAL(minimizePressed()));
48 imageWidth_ = minimizeButton_->pixmap().width();
50 closeButton_ = new ImageItem(":/resources/close.png");
51 closeButton_->setZValue(9999);
52 scene_->addItem(closeButton_);
53 connect(closeButton_, SIGNAL(clicked()), this, SIGNAL(closePressed()));
55 settingsButton_ = new ImageItem(":/resources/settings.png");
56 settingsButton_->setZValue(9999);
57 scene_->addItem(settingsButton_);
58 connect(settingsButton_, SIGNAL(clicked()), this, SIGNAL(settingsPressed()));
62 connect(&(Odometer::instance()), SIGNAL(dataUpdated()), this, SLOT(update()));
63 connect(&(Odometer::instance()), SIGNAL(unitChanged()), this, SLOT(update()));
66 GraphicsScreen::~GraphicsScreen()
70 void GraphicsScreen::reArrange()
72 QRect rect = QApplication::desktop()->screenGeometry();
73 scene_->setSceneRect(rect);
74 minimizeButton_->setPos(PADDING, PADDING);
75 closeButton_->setPos(rect.width() - imageWidth_ - PADDING, PADDING);
76 settingsButton_->setPos((rect.width() / 2) - (imageWidth_ / 2) - (PADDING / 2), PADDING);
79 void GraphicsScreen::flip()
87 setTransform(QTransform(1, 0, 0, 0, -1, 0, 0, 0, 1));
90 GraphicsScene* GraphicsScreen::getScene() const