// Misc values
const int DEFAULT_SCREEN_WIDTH = 800; ///< Default N900 screen width
const int DEFAULT_SCREEN_HEIGHT = 480; ///< Default N900 screen height
+const int SCREEN_HEIGHT_DIFFERENCE = 56; ///< Difference between fullscreen height and non fs
const QColor COLOR_GRAY = QColor(152, 152, 152); ///< Gray color
const QFont NOKIA_FONT_NORMAL = QFont("Nokia Sans", 18, QFont::Normal); ///< Normal font
qDebug() << __PRETTY_FUNCTION__;
changeAutoCenteringSetting(false);
- m_ui->buildInformationBox(tr("Auto centering disabled"));
}
void SituareEngine::enableAutoCentering(bool enabled)
enableGPS(true);
m_ui->buildInformationBox(tr("GPS enabled"));
- m_ui->buildInformationBox(tr("Auto centering enabled"));
} else { // Normal start
changeAutoCenteringSetting(autoCenteringEnabled.toBool());
if (gpsEnabled.toBool())
m_ui->buildInformationBox(tr("GPS enabled"));
-
- if (gpsEnabled.toBool() && autoCenteringEnabled.toBool())
- m_ui->buildInformationBox(tr("Auto centering enabled"));
}
} else {
enableGPS(false);
*
* @param request QNetworkRequest
* @param data QByteArray
- * @param onlineRequestOnly bool
+ * @param onlineRequestsOnly bool
* @return QNetworkReply
*/
QNetworkReply *post(const QNetworkRequest &request, QByteArray &data,
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
*/
+
#include <QDebug>
#include <QPainter>
#include <QSettings>
-#include "indicatorbutton.h"
#include "math.h"
#include "common.h"
#include "panelcommon.h"
+#include "indicatorbutton.h"
+
+enum State {OFF, ON}; ///< Enumerator for led state
-const int ROUNDING_RADIUS = 9; ///< Roundness of the rounded edge
-const qreal OPACITY = 0.13; ///< Opacity of the background in percents
-const int BUTTON_WIDTH = 66; ///< Button width
-const int BUTTON_HEIGHT = 66; ///< Button height
-const int DRAGGABLE_BUTTON_WIDTH = 85;
-const int DRAGGABLE_BUTTON_HEIGHT = 85;
+const qreal OPACITY = 0.50; ///< Opacity of the background in percents
+const int ROUNDING_RADIUS = 9; ///< Roundness of the rounded edge
+const int BUTTON_WIDTH = 66; ///< Button width
+const int BUTTON_HEIGHT = 66; ///< Button height
IndicatorButton::IndicatorButton(QWidget *parent)
: QToolButton(parent),
m_isDraggable(false)
{
- setIcon(QIcon::fromTheme(QLatin1String("general_fullsize")));
+ m_indicatorLeds[OFF].load(":res/images/led_red.png");
+ m_indicatorLeds[ON].load(":res/images/led_red_s.png");
setFixedSize(BUTTON_WIDTH, BUTTON_HEIGHT);
QSettings settings(DIRECTORY_NAME, FILE_NAME);
QPoint(DIRECTION_INDICATOR_POSITION_X,
DIRECTION_INDICATOR_POSITION_Y)).toPoint());
- QPalette pal = palette();
- QColor backgroundColor = pal.color(backgroundRole());
- backgroundColor.setAlpha(floor(OPACITY * 255));
- pal.setColor(backgroundRole(), backgroundColor);
- setPalette(pal);
+ // Normal background
+ m_normalColor = new QColor(Qt::black);
+ m_normalColor->setAlpha(floor(OPACITY * 255));
- setAutoFillBackground(true);
+ // Selected bakcground
+ m_selectedGradient = new QLinearGradient(0, 0, 0, this->height());
+ m_selectedGradient->setColorAt(0.02, QColor(0, 113, 181));
+ m_selectedGradient->setColorAt(0.25, QColor(24, 142, 214));
+ m_selectedGradient->setColorAt(0.5, QColor(41, 162, 239));
+ m_selectedGradient->setColorAt(0.75, QColor(82, 195, 255));
+ m_selectedGradient->setColorAt(0.98, QColor(115, 215, 255));
+
+ // Item shape path
+ m_backgroundPath.addRoundedRect(0, 0, this->rect().width(), this->rect().height(),
+ ROUNDING_RADIUS, ROUNDING_RADIUS);
m_dragStartTimer = new QTimer(this);
m_dragStartTimer->setSingleShot(true);
connect(this, SIGNAL(pressed()),
m_dragStartTimer, SLOT(start()));
+
connect(this, SIGNAL(released()),
m_dragStartTimer, SLOT(stop()));
connect(m_dragStartTimer, SIGNAL(timeout()),
this, SLOT(timerExpired()));
+
connect(m_forceReleaseTimer, SIGNAL(timeout()),
this, SLOT(forceMouseRelease()));
}
m_eventPosition = mapToParent(event->pos());
m_dragStartTimer->start();
-// QToolButton::mousePressEvent(event);
}
void IndicatorButton::mouseMoveEvent(QMouseEvent *event)
if (newLocation.x() < SIDEBAR_WIDTH)
newLocation.rx() = SIDEBAR_WIDTH;
-// else if (newLocation.x() > m_screenSize.width() - width() - SIDEBAR_WIDTH)
-// newLocation.rx() = m_screenSize.width() - width() - SIDEBAR_WIDTH;
+ else if (newLocation.x() > m_screenSize.width() - width() - SIDEBAR_WIDTH)
+ newLocation.rx() = m_screenSize.width() - width() - SIDEBAR_WIDTH;
if (newLocation.y() < 0)
newLocation.ry() = 0;
-// else if (newLocation.y() > m_screenSize.height() - height())
-// newLocation.ry() = m_screenSize.height() - height();
+ else if (newLocation.y() > m_screenSize.height() - height())
+ newLocation.ry() = m_screenSize.height() - height();
move(newLocation);
}
emit autoCenteringTriggered(true);
}
}
+
QToolButton::mouseReleaseEvent(event);
}
m_isDraggable = mode;
if(mode) {
- setFixedSize(DRAGGABLE_BUTTON_WIDTH, DRAGGABLE_BUTTON_HEIGHT);
- setAutoFillBackground(true);
grabMouse();
m_forceReleaseTimer->start();
m_dragPosition = eventPosition;
} else {
- setFixedSize(BUTTON_WIDTH, BUTTON_HEIGHT);
- setAutoFillBackground(true);
releaseMouse();
m_forceReleaseTimer->stop();
}
+
+ update();
+}
+
+void IndicatorButton::screenResized(const QSize &newSize)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_screenSize = newSize;
+
+ QPoint resizedPosition = pos();
+
+ if(newSize.height() < DEFAULT_SCREEN_HEIGHT)
+ resizedPosition.ry() -= SCREEN_HEIGHT_DIFFERENCE;
+ else
+ resizedPosition.ry() += SCREEN_HEIGHT_DIFFERENCE;
+
+ move(resizedPosition);
}
const QPoint& IndicatorButton::eventPosition()
setDraggable(false);
}
+void IndicatorButton::paintEvent(QPaintEvent *event)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ Q_UNUSED(event);
+
+ QPainter painter(this);
+ painter.setRenderHint(QPainter::Antialiasing);
+
+ if(m_isDraggable)
+ painter.fillPath(m_backgroundPath, QBrush(Qt::Dense4Pattern));
+ else if (isDown())
+ painter.fillPath(m_backgroundPath, QBrush(*m_selectedGradient));
+ else
+ painter.fillPath(m_backgroundPath, QBrush(*m_normalColor));
+
+ if(isChecked())
+ painter.drawPixmap((this->width() / 2) - (m_indicatorLeds[ON].width() / 2),
+ (this->height() / 2) - (m_indicatorLeds[ON].height() / 2),
+ m_indicatorLeds[ON]);
+ else
+ painter.drawPixmap((this->width() / 2) - (m_indicatorLeds[OFF].width() / 2),
+ (this->height() / 2) - (m_indicatorLeds[OFF].height() / 2),
+ m_indicatorLeds[OFF]);
+}
+
void IndicatorButton::timerExpired()
{
qDebug() << __PRETTY_FUNCTION__;
setDraggable(true, m_dragPosition);
}
-//void IndicatorButton::paintEvent(QPaintEvent *event)
-//{
-// qDebug() << __PRETTY_FUNCTION__;
-
-// QToolButton::paintEvent(event);
-//}
#include <QToolButton>
#include <QTimer>
#include <QMouseEvent>
-#include <QPaintEvent>
#include "../user/user.h"
/**
* @brief Indicator button class
*
* @class IndicatorButton indicatorbutton.h "ui/indicatorbutton.h"
+* @author Katri Kaikkonen - katri.kaikkonen (at) ixonos.com
*/
class IndicatorButton : public QToolButton
{
Q_OBJECT
public:
+
/**
* @brief Constructor
*
/**
* @brief Move event for the distance indicator button
*
- * @param event Event
+ * @param event Mouse event
*/
void mouseMoveEvent(QMouseEvent *event);
/**
* @brief Press event for the distance indicator button
*
- * @param event Event
+ * @param event Mouse event
*/
void mousePressEvent(QMouseEvent *event);
*/
void mouseReleaseEvent(QMouseEvent *event);
-// void paintEvent(QPaintEvent *event);
-
+ /**
+ * @brief Event handler for paint events
+ *
+ * Paints the button and its icon
+ * @param event Paint event
+ */
+ void paintEvent(QPaintEvent *event);
/*******************************************************************************
* MEMBER FUNCTIONS AND SLOTS
******************************************************************************/
-
public slots:
/**
const QPoint& eventPosition();
/**
+ * @brief Slot to redraw the panel after window resize event
+ *
+ * @param size Size of the new screen
+ */
+ void screenResized(const QSize &size);
+
+ /**
* @brief Toggle distance indicator button draggability
*/
void setDraggable(bool mode, QPoint eventPosition = QPoint(0,0));
private slots:
+
/**
* @brief Safeguard slot to release mouse grab if something goes horribly wrong
*/
* SIGNALS
******************************************************************************/
signals:
+
/**
* @brief Automatic centering setting changed by user
*
* DATA MEMBERS
******************************************************************************/
private:
- bool m_isDraggable; ///< Boolean for tracking the draggability state
- QPoint m_dragPosition; ///< Location from where the widget is grabbed
- QPoint m_eventPosition; ///< Position of mousePressEvent
+ bool m_isDraggable; ///< Boolean for tracking the draggability state
+
+ QPoint m_dragPosition; ///< Location from where the widget is grabbed
+ QPoint m_eventPosition; ///< Position of mousePressEvent
+
+ QSize m_screenSize; ///< Store for the screen size
- QSize m_screenSize; ///< Store for the screen size
+ QTimer *m_dragStartTimer; ///< Timer to init draggability of the distance indicator button
+ QTimer *m_forceReleaseTimer; ///< Timer to run forceMouseRelease;
- QTimer *m_dragStartTimer; ///< Timer to init draggability of the distance indicator button
- QTimer *m_forceReleaseTimer; ///< Timer to run forceMouseRelease;
+ QColor *m_normalColor;
+ QLinearGradient *m_selectedGradient;
+ QPainterPath m_backgroundPath;
+ QPixmap m_indicatorLeds[2];
};
m_ownLocationCrosshair(0),
m_email(),
m_password(),
+ m_webView(0),
m_fullScreenButton(0),
m_indicatorButton(0),
- m_webView(0),
m_mapScale(0),
m_cookieJar(0)
{
connect(m_indicatorButton, SIGNAL(autoCenteringTriggered(bool)),
this, SIGNAL(autoCenteringTriggered(bool)));
+
+ connect(m_mapView, SIGNAL(viewResized(QSize)),
+ m_indicatorButton, SLOT(screenResized(QSize)));
}
void MainWindow::buildInformationBox(const QString &message, bool modal)
connect(m_mapView, SIGNAL(viewResized(QSize)),
m_zoomButtonPanel, SLOT(screenResized(QSize)));
+
}
void MainWindow::clearCookieJar()
void MainWindow::drawMapScale(const QSize &size)
{
+ qDebug() << __PRETTY_FUNCTION__;
+
const int LEFT_SCALE_MARGIN = 10;
const int BOTTOM_SCALE_MARGIN = 2;
qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
if(!m_friendsListPanel->isVisible()) {
m_friendsListPanel->show();
m_friendsListPanelSidebar->show();
- m_indicatorButton->show();
}
if(!m_userPanel->isVisible()) {
Henri Lampela - henri.lampela@ixonos.com
Kaj Wallin - kaj.wallin@ixonos.com
Sami Rämö - sami.ramo@ixonos.com
+ Katri Kaikkonen - katri.kaikkonen@ixonos.com
Situare is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
QString m_email; ///< Placeholder for email
QString m_password; ///< Placeholder for password
- FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
- IndicatorButton * m_indicatorButton; ///< Instance of direction indicator button
-
QWebView *m_webView; ///< Shows facebook login page
FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
+ FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
+ IndicatorButton *m_indicatorButton; ///< Instance of direction indicator button
MapScale *m_mapScale; ///< Instance of the map scale
MapView *m_mapView; ///< Instance of the map view
NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
Copyright (C) 2010 Ixonos Plc. Authors:
Kaj Wallin - kaj.wallin@ixonos.com
+ Katri Kaikkonen - katri.kaikkonen@ixonos.com
Situare is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
const int FRIENDPANEL_HEIGHT = DEFAULT_SCREEN_HEIGHT - PANEL_TOP_PADDING
- PANEL_BOTTOM_PADDING; ///< Height of the friends list panel
+/**
+* @brief Friend list panel inner margin (left)
+*
+* @var FRIENDPANEL_MARGIN_LEFT
+*/
const int FRIENDPANEL_MARGIN_LEFT = SLIDER_BUTTON_OFFSET
- + MAEMO5_SCROLLBAR_WIDTH; ///< Friend list panel inner margin (left)
-const int FRIENDPANEL_MARGIN_RIGHT = SIDEBAR_WIDTH; ///< Friend list panel inner margin (right)
-const int FRIENDPANEL_MARGIN_TOP = 0; ///< Friend list panel inner margin (top)
-const int FRIENDPANEL_MARGIN_BOTTOM = 0; ///< Friend list panel inner margin (bottom)
-
-const int FRIENDPANEL_FILTER_MARGIN_LEFT = FRIENDPANEL_MARGIN_LEFT + 4; ///< Friend list filter bar margin (left)
+ + MAEMO5_SCROLLBAR_WIDTH;
+const int FRIENDPANEL_MARGIN_RIGHT = SIDEBAR_WIDTH; ///< Friend list panel inner margin (right)
+const int FRIENDPANEL_MARGIN_TOP = 0; ///< Friend list panel inner margin (top)
+const int FRIENDPANEL_MARGIN_BOTTOM = 0; ///< Friend list panel inner margin (bottom)
+
+/**
+* @brief Friend list filter bar margin (left)
+*
+* @var FRIENDPANEL_FILTER_MARGIN_LEFT
+*/
+const int FRIENDPANEL_FILTER_MARGIN_LEFT = FRIENDPANEL_MARGIN_LEFT + 4;
+
+/**
+* @brief Friend list filter bar margin (right)
+*
+* @var FRIENDPANEL_FILTER_MARGIN_RIGHT
+*/
const int FRIENDPANEL_FILTER_MARGIN_RIGHT = FRIENDPANEL_MARGIN_RIGHT
- + MAEMO5_SCROLLBAR_WIDTH + 4; ///< Friend list filter bar margin (right)
+ + MAEMO5_SCROLLBAR_WIDTH + 4;
const int SHOW_ALL_BUTTON_RIGHT_MARGIN = SIDEBAR_WIDTH * 2 - 7; ///< Show all button right margin
+/**
+* @brief Horizontal position of a closed friend list panel
+*
+* @var FRIENDPANEL_CLOSED_X
+*/
const int FRIENDPANEL_CLOSED_X = DEFAULT_SCREEN_WIDTH - SLIDER_BUTTON_OFFSET
- - PANEL_PEEK_AMOUNT; ///< Horizontal position of a closed friend list panel
+ - PANEL_PEEK_AMOUNT;
+
+/**
+* @brief Horizontal position of a open friend list panel
+*
+* @var FRIENDPANEL_OPENED_X
+*/
const int FRIENDPANEL_OPENED_X = DEFAULT_SCREEN_WIDTH - SLIDER_BUTTON_OFFSET - SLIDER_BAR_WIDTH
- - FRIENDPANEL_WIDTH; ///< Horizontal position of a open friend list panel
+ - FRIENDPANEL_WIDTH;
// User info panel settings
const int USERPANEL_WIDTH = 298; ///< Width of the user panel
const int USERPANEL_MARGIN_LEFT = SIDEBAR_WIDTH
+ MAEMO5_SCROLLBAR_WIDTH; ///< User info panel inner margin (left)
-const int USERPANEL_MARGIN_RIGHT = SLIDER_BUTTON_OFFSET; ///< User info panel inner margin (right)
-const int USERPANEL_MARGIN_TOP = 0; ///< User info panel inner margin (top)
-const int USERPANEL_MARGIN_BOTTOM = 0; ///< User info panel inner margin (bottom)
-
+const int USERPANEL_MARGIN_RIGHT = SLIDER_BUTTON_OFFSET; ///< User info panel inner margin (right)
+const int USERPANEL_MARGIN_TOP = 0; ///< User info panel inner margin (top)
+const int USERPANEL_MARGIN_BOTTOM = 0; ///< User info panel inner margin (bottom)
+
+/**
+* @brief Horizontal position of a closed user info panel
+*
+* @var USERPANEL_CLOSED_X
+*/
const int USERPANEL_CLOSED_X = - USERPANEL_WIDTH + PANEL_PEEK_AMOUNT
- - SLIDER_BAR_WIDTH; ///< Horizontal position of a closed user info panel
-const int USERPANEL_OPENED_X = 0; ///< Horizontal position of a open user info panel
+ - SLIDER_BAR_WIDTH;
+const int USERPANEL_OPENED_X = 0; ///< Horizontal position of a open user info panel
// Zoom button panel settings
-const int ZOOM_BUTTON_PANEL_POSITION_X = 10 + PANEL_PEEK_AMOUNT; ///< Horizontal position of zoom panel
+const int ZOOM_BUTTON_PANEL_POSITION_X = 10 +
+ PANEL_PEEK_AMOUNT; ///< Horizontal position of zoom panel
const int ZOOM_BUTTON_PANEL_POSITION_Y = 10; ///< Vertical position of zoom panel
const int ZOOM_BUTTON_PANEL_BUTTON_SPACING = 4; ///< Size of a zoom button spacing
const QString ZOOMPANEL_POSITION = "Zoom_Panel_Position";
// Direction indicator button settings
-const int DIRECTION_INDICATOR_POSITION_X = 10 + PANEL_PEEK_AMOUNT; ///< Horizontal position of direction indicator button
-const int DIRECTION_INDICATOR_POSITION_Y = 342; ///< Vertical position of direction indicator button
+/**
+* @brief Horizontal position of direction indicator button
+*
+* @var DIRECTION_INDICATOR_POSITION_X
+*/
+const int DIRECTION_INDICATOR_POSITION_X = 10 + PANEL_PEEK_AMOUNT;
+const int DIRECTION_INDICATOR_POSITION_Y = 315; ///< Vertical position of direction indicator button
const QString DIRECTION_INDICATOR_BUTTON_POSITION = "Direction_Indicator_Position";
void ZoomButtonPanel::screenResized(const QSize &newSize)
{
qDebug() << __PRETTY_FUNCTION__;
-
+
m_screenSize = newSize;
QPoint resizedPosition = pos();