Added translucent, rounded background for the fullscreen toggle button
authorKaj Wallin <kaj.wallin@ixonos.com>
Wed, 16 Jun 2010 13:00:50 +0000 (16:00 +0300)
committerKaj Wallin <kaj.wallin@ixonos.com>
Wed, 16 Jun 2010 13:00:50 +0000 (16:00 +0300)
Reviewed by: Pekka Nissinen

debian/changelog
src/src.pro
src/ui/fullscreenbutton.cpp [new file with mode: 0644]
src/ui/fullscreenbutton.h [new file with mode: 0644]
src/ui/mainwindow.cpp
src/ui/mainwindow.h

index 0b971cb..ddb962e 100644 (file)
@@ -1,3 +1,8 @@
+situare (0.7-0) unstable; urgency=low
+  * Situare Beta Release (Intermediate build)
+
+ -- Kaj Wallin <kaj.wallin@ixonos.com>  Mon, 16 Jun 2010 08:20:00 +0300
+
 situare (0.6-2) unstable; urgency=low
   * Situare Beta Release
 
index 32d698b..a16a414 100644 (file)
@@ -50,7 +50,8 @@ SOURCES += main.cpp \
     ui/userinfopanel.cpp \
     ui/zoombutton.cpp \
     ui/zoombuttonpanel.cpp \
-    user/user.cpp
+    user/user.cpp \
+    ui/fullscreenbutton.cpp
 HEADERS += common.h \
     engine/engine.h \
     facebookservice/facebookauthentication.h \
@@ -98,7 +99,8 @@ HEADERS += common.h \
     ui/sidepanelbase.h \
     ui/zoombutton.h \
     ui/zoombuttonpanel.h \
-    user/user.h
+    user/user.h \
+    ui/fullscreenbutton.h
 QT += network \
     webkit
 DEFINES += QT_NO_DEBUG_OUTPUT
diff --git a/src/ui/fullscreenbutton.cpp b/src/ui/fullscreenbutton.cpp
new file mode 100644 (file)
index 0000000..6ea5a54
--- /dev/null
@@ -0,0 +1,50 @@
+ /*
+    Situare - A location system for Facebook
+    Copyright (C) 2010  Ixonos Plc. Authors:
+
+        Kaj Wallin - kaj.wallin@ixonos.com
+
+    Situare is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License
+    version 2 as published by the Free Software Foundation.
+
+    Situare is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with Situare; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+    USA.
+ */
+
+#include "fullscreenbutton.h"
+#include "math.h"
+
+const int ROUNDING_RADIUS = 5;  ///< Roundness of the rounded edge
+const qreal OPACITY = 0.13;     ///< Opacity of the background in percents
+
+FullScreenButton::FullScreenButton(QWidget *parent) :
+    QToolButton(parent)
+{
+    setIcon(QIcon::fromTheme(QLatin1String("general_fullsize")));
+    setFixedSize(sizeHint());
+
+    QPalette pal = palette();
+    QColor backgroundColor = pal.color(backgroundRole());
+    backgroundColor.setAlpha(floor(OPACITY * 255));  //
+    pal.setColor(backgroundRole(), backgroundColor);
+    setPalette(pal);
+
+    setAutoFillBackground(true);
+
+    // Create mask to round the top left corner of the background
+    QRegion maskbase(rect());
+    QRegion cookiecutterbase(QRect(QPoint(0,0),QPoint(ROUNDING_RADIUS, ROUNDING_RADIUS)));
+    QRegion cookiecuttersplice(QRect(0,0,2*ROUNDING_RADIUS, 2*ROUNDING_RADIUS),QRegion::Ellipse);
+    QRegion cookiecutter = cookiecutterbase.subtract(cookiecuttersplice);
+    QRegion mask = maskbase.subtract(cookiecutter);
+
+    setMask(mask);
+}
diff --git a/src/ui/fullscreenbutton.h b/src/ui/fullscreenbutton.h
new file mode 100644 (file)
index 0000000..b0c402f
--- /dev/null
@@ -0,0 +1,47 @@
+ /*
+    Situare - A location system for Facebook
+    Copyright (C) 2010  Ixonos Plc. Authors:
+
+        Kaj Wallin - kaj.wallin@ixonos.com
+
+    Situare is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License
+    version 2 as published by the Free Software Foundation.
+
+    Situare is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with Situare; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+    USA.
+ */
+
+
+#ifndef FULLSCREENBUTTON_H
+#define FULLSCREENBUTTON_H
+
+#include <QToolButton>
+
+/**
+* @brief Fullscreen button class
+*
+* @author Kaj Wallin - kaj.wallin (at) ixonos.com
+*
+* @class FullScreenButton fullscreenbutton.h "ui/fullscreenbutton.h"
+*/
+class FullScreenButton : public QToolButton
+{
+    Q_OBJECT
+public:
+    /**
+     * @brief Constructor
+     *
+     * @param parent Parent widget
+     */
+    FullScreenButton(QWidget *parent = 0);
+};
+
+#endif // FULLSCREENBUTTON_H
index 1bb61cd..5d54ec7 100644 (file)
@@ -32,6 +32,7 @@
 #include "map/mapview.h"
 #include "common.h"
 #include "friendlistpanel.h"
+#include "fullscreenbutton.h"
 #include "logindialog.h"
 #include "mapscale.h"
 #include "settingsdialog.h"
@@ -139,9 +140,7 @@ void MainWindow::buildFullScreenButton()
 {
     qDebug() << __PRETTY_FUNCTION__;
 #ifdef Q_WS_MAEMO_5
-    m_fullScreenButton = new QToolButton(this);
-    m_fullScreenButton->setIcon(QIcon::fromTheme(QLatin1String("general_fullsize")));
-    m_fullScreenButton->setFixedSize(m_fullScreenButton->sizeHint());
+    m_fullScreenButton = new FullScreenButton(this);
     connect(m_fullScreenButton, SIGNAL(clicked()),
             this, SLOT(toggleFullScreen()));
 #endif // Q_WS_MAEMO_5
@@ -472,9 +471,14 @@ void MainWindow::drawFullScreenButton(const QSize &size)
     qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
 
     if(m_fullScreenButton) {
-        m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width()
-                                 - PANEL_PEEK_AMOUNT,
-                                 size.height() - m_fullScreenButton->size().height());
+        if(m_loggedIn) {
+            m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width()
+                                     - PANEL_PEEK_AMOUNT,
+                                     size.height() - m_fullScreenButton->size().height());
+        } else {
+            m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width(),
+                                     size.height() - m_fullScreenButton->size().height());
+        }
     }
 }
 
@@ -797,7 +801,7 @@ void MainWindow::setOwnLocationCrosshairVisibility(bool visibility)
     if (visibility && m_loggedIn) {
         m_ownLocationCrosshair->show();
         m_drawOwnLocationCrosshair = true;
-        drawOwnLocationCrosshair(QSize(m_viewPortWidth, m_viewPortHeight));
+        drawOwnLocationCrosshair(m_viewPortSize);
     } else {
         m_ownLocationCrosshair->hide();
         m_drawOwnLocationCrosshair = false;
@@ -822,8 +826,7 @@ void MainWindow::setViewPortSize(const QSize &size)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_viewPortWidth = size.width();
-    m_viewPortHeight = size.height();
+    m_viewPortSize = size;
 }
 
 void MainWindow::showEnableAutomaticUpdateLocationDialog(const QString &text)
@@ -923,6 +926,7 @@ void MainWindow::updateItemVisibility()
         m_userPanelSidebar->hide();
         setOwnLocationCrosshairVisibility(false);
     }
+    drawFullScreenButton(m_viewPortSize);
 }
 
 const QString MainWindow::username()
index 9079c02..aae2e50 100644 (file)
@@ -36,6 +36,7 @@ class QWebView;
 class QNetworkReply;
 
 class FacebookAuthentication;
+class FullScreenButton;
 class FriendListPanel;
 class MapScale;
 class MapScene;
@@ -590,8 +591,6 @@ private:
     bool m_loggedIn;                        ///< Indicates login state
     bool m_refresh;                         ///< Indicates when webpage is refreshed
 
-    int m_viewPortHeight;                   ///< Height of view port
-    int m_viewPortWidth;                    ///< Width of view port
 
     QAction *m_autoCenteringAct;            ///< Action to auto center map using gps position
     QAction *m_gpsToggleAct;                ///< Action to trigger gps toggle
@@ -608,10 +607,12 @@ private:
 
     QMessageBox *m_automaticUpdateLocationDialog;   ///< Automatic update location dialog
 
+    QSize m_viewPortSize;                 ///< Size of the viewport
+
     QString m_email;                        ///< Placeholder for email
     QString m_password;                     ///< Placeholder for password
 
-    QToolButton *m_fullScreenButton;        ///< Instance of the fullscreen toggle button
+    FullScreenButton *m_fullScreenButton;   ///< Instance of the fullscreen toggle button
 
     QWebView *m_webView;                    ///< Shows facebook login page