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 <QtCore/QDebug>
20 #include <QtGui/QApplication>
21 #include <QtGui/QDesktopWidget>
22 #include "graphicsscreen.h"
23 #include "toolbaritem.h"
24 #include "graphicsscene.h"
29 int const PADDING = 6;
32 GraphicsScreen::GraphicsScreen(QWidget* parent): QGraphicsView(parent),
33 AbstractScreen(), scene_(0), isFlipped_(false)
35 QRect rect = QApplication::desktop()->availableGeometry();
37 scene_ = new GraphicsScene(QRect(QPoint(0, 0), rect.size()));
40 connect(scene_, SIGNAL(clicked()), this, SIGNAL(clicked()));
42 minimizeButton_ = new ToolbarItem(":/resources/minimize.png", ":/resources/minimize_active.png");
43 minimizeButton_->setZValue(9999);
44 scene_->addItem(minimizeButton_);
45 connect(minimizeButton_, SIGNAL(clicked()), this, SIGNAL(minimizePressed()));
47 imageWidth_ = minimizeButton_->pixmap().width();
49 closeButton_ = new ToolbarItem(":/resources/close.png", ":/resources/close_active.png");
50 closeButton_->setZValue(9999);
51 scene_->addItem(closeButton_);
52 connect(closeButton_, SIGNAL(clicked()), this, SIGNAL(closePressed()));
54 settingsButton_ = new ToolbarItem(":/resources/settings.png", ":/resources/settings_active.png");
55 settingsButton_->setZValue(9999);
56 scene_->addItem(settingsButton_);
57 connect(settingsButton_, SIGNAL(clicked()), this, SIGNAL(settingsPressed()));
61 connect(&(Odometer::instance()), SIGNAL(dataUpdated()), this, SLOT(update()));
62 connect(&(Odometer::instance()), SIGNAL(unitChanged()), this, SLOT(update()));
65 GraphicsScreen::~GraphicsScreen()
69 void GraphicsScreen::reArrange()
71 QRect rect = QApplication::desktop()->screenGeometry();
72 scene_->setSceneRect(rect);
73 minimizeButton_->setPos(PADDING, PADDING);
74 closeButton_->setPos(rect.width() - imageWidth_ - PADDING, PADDING);
75 settingsButton_->setPos((rect.width() / 2) - (imageWidth_ / 2), PADDING);
78 void GraphicsScreen::flip()
87 setTransform(QTransform(1, 0, 0, 0, -1, 0, 0, 0, 1));
92 GraphicsScene* GraphicsScreen::getScene() const
97 void GraphicsScreen::forceRepaint()
99 QApplication::processEvents();
101 QApplication::processEvents();