2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Kaj Wallin - kaj.wallin@ixonos.com
6 Pekka Nissinen - pekka.nissinen@ixonos.com
8 Situare is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 version 2 as published by the Free Software Foundation.
12 Situare is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Situare; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
29 #include "fullscreenbutton.h"
31 const int ROUNDING_ARC_START_ANGLE = 90; ///< Start angle of the arc
32 const int ROUNDING_ARC_LENGTH = 90; ///< Length of the arc (degree)
33 const int ROUNDING_ARC_RADIUS = 5; ///< Roundness of the rounded edge
35 const qreal OPACITY = 0.13; ///< Opacity of the background in percents
37 FullScreenButton::FullScreenButton(QWidget *parent) :
40 qDebug() << __PRETTY_FUNCTION__;
42 const int HIDING_DELAY_MS = 5000;
44 setIcon(QIcon::fromTheme(QLatin1String("general_fullsize")));
45 setFixedSize(sizeHint());
48 m_normalColor = new QColor(Qt::black);
49 m_normalColor->setAlpha(floor(OPACITY * 255));
51 // Selected bakcground
52 m_selectedGradient = new QLinearGradient(0, 0, 0, this->height());
53 m_selectedGradient->setColorAt(0.02, QColor(0, 113, 181));
54 m_selectedGradient->setColorAt(0.25, QColor(24, 142, 214));
55 m_selectedGradient->setColorAt(0.5, QColor(41, 162, 239));
56 m_selectedGradient->setColorAt(0.75, QColor(82, 195, 255));
57 m_selectedGradient->setColorAt(0.98, QColor(115, 215, 255));
60 m_backgroundPath.moveTo(this->width(), 0); // Top right corner
61 m_backgroundPath.lineTo(ROUNDING_ARC_RADIUS, 0);
62 m_backgroundPath.arcTo(0, 0, ROUNDING_ARC_RADIUS * 2, ROUNDING_ARC_RADIUS * 2,
63 ROUNDING_ARC_START_ANGLE, ROUNDING_ARC_LENGTH);
64 m_backgroundPath.lineTo(0, this->height()); // Bottom left corner
65 m_backgroundPath.lineTo(this->width(), this->height()); // Bottom right corner
66 m_backgroundPath.closeSubpath(); // Back to the beginning
68 // Timer for hiding the button automatically after a delay
69 m_hidingTimer = new QTimer(this);
71 m_hidingTimer->setSingleShot(true);
72 m_hidingTimer->setInterval(HIDING_DELAY_MS);
74 connect(m_hidingTimer, SIGNAL(timeout()),
79 FullScreenButton::~FullScreenButton()
81 qDebug() << __PRETTY_FUNCTION__;
84 delete m_selectedGradient;
87 void FullScreenButton::invoke()
89 qDebug() << __PRETTY_FUNCTION__;
95 m_hidingTimer->start();
98 void FullScreenButton::paintEvent(QPaintEvent *event)
100 qDebug() << __PRETTY_FUNCTION__;
104 QPainter painter(this);
105 painter.setRenderHint(QPainter::Antialiasing);
108 painter.fillPath(m_backgroundPath, QBrush(*m_selectedGradient));
110 painter.fillPath(m_backgroundPath, QBrush(*m_normalColor));
112 icon().paint(&painter, this->rect());