From 00a9a6add98fd1ef4674bb79f5a67323d04aa4a6 Mon Sep 17 00:00:00 2001 From: Pekka Nissinen Date: Tue, 10 Aug 2010 15:50:04 +0300 Subject: [PATCH] The first "kind of" working version of the new panels --- src/ui/mainwindow.cpp | 134 ++++++++++++-------------- src/ui/mainwindow.h | 9 +- src/ui/userinfo.cpp | 22 ++--- src/ui/userinfo.h | 241 +++++++++++++++++++++++----------------------- src/ui/userinfopanel.cpp | 7 +- src/ui/userinfopanel.h | 3 +- 6 files changed, 199 insertions(+), 217 deletions(-) diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index d93ae1a..6bd5c0d 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -37,6 +37,8 @@ #include "indicatorbutton.h" #include "logindialog.h" #include "mapscale.h" +#include "panelcommon.h" +#include "tabbedpanel.h" #include "searchdialog.h" #include "settingsdialog.h" #include "userinfopanel.h" @@ -54,18 +56,18 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), - m_errorShown(false), - m_loggedIn(false), - m_refresh(false), - m_progressIndicatorCount(0), - m_ownLocationCrosshair(0), - m_email(), - m_password(), - m_webView(0), - m_fullScreenButton(0), - m_indicatorButton(0), - m_mapScale(0), - m_cookieJar(0) + m_errorShown(false), + m_loggedIn(false), + m_refresh(false), + m_progressIndicatorCount(0), + m_ownLocationCrosshair(0), + m_email(), + m_password(), + m_webView(0), + m_fullScreenButton(0), + m_indicatorButton(0), + m_mapScale(0), + m_cookieJar(0) { qDebug() << __PRETTY_FUNCTION__; @@ -80,14 +82,15 @@ MainWindow::MainWindow(QWidget *parent) setCentralWidget(new QWidget()); centralWidget()->setLayout(layout); - buildFriendListPanel(); +// buildFriendListPanel(); buildUserInfoPanel(); createMenus(); setWindowTitle(tr("Situare")); // set stacking order of widgets - m_zoomButtonPanel->stackUnder(m_userPanel); +// m_zoomButtonPanel->stackUnder(m_userInfoPanel); + m_zoomButtonPanel->stackUnder(m_tabbedPanel); if(m_fullScreenButton) { m_fullScreenButton->stackUnder(m_zoomButtonPanel); m_osmLicense->stackUnder(m_fullScreenButton); @@ -155,10 +158,6 @@ void MainWindow::buildFriendListPanel() m_friendsListPanel = new FriendListPanel(this); - m_friendsListPanelSidebar = new PanelSideBar(this, RIGHT); - - m_friendsListPanel->stackUnder(m_friendsListPanelSidebar); - connect(this, SIGNAL(friendsLocationsReady(QList&)), m_friendsListPanel, SLOT(friendInfoReceived(QList&))); @@ -168,9 +167,6 @@ void MainWindow::buildFriendListPanel() connect(m_mapView, SIGNAL(viewResized(QSize)), m_friendsListPanel, SLOT(resizePanel(QSize))); - connect(m_mapView, SIGNAL(viewResized(QSize)), - m_friendsListPanelSidebar, SLOT(resizeSideBar(QSize))); - connect(m_friendsListPanel, SIGNAL(findFriend(GeoCoordinate)), this, SIGNAL(findFriend(GeoCoordinate))); @@ -309,42 +305,43 @@ void MainWindow::buildUserInfoPanel() { qDebug() << __PRETTY_FUNCTION__; - m_userPanel = new UserInfoPanel(this); - - m_userPanelSidebar = new PanelSideBar(this, LEFT); - - m_userPanelSidebar->stackUnder(m_friendsListPanel); - m_userPanel->stackUnder(m_userPanelSidebar); + m_userInfoPanel = new UserInfoPanel(this); connect(this, SIGNAL(userLocationReady(User*)), - m_userPanel, SLOT(userDataReceived(User*))); + m_userInfoPanel, SLOT(userDataReceived(User*))); connect(this, SIGNAL(reverseGeoReady(QString)), - m_userPanel, SIGNAL(reverseGeoReady(QString))); + m_userInfoPanel, SIGNAL(reverseGeoReady(QString))); connect(this, SIGNAL(clearUpdateLocationDialogData()), - m_userPanel, SIGNAL(clearUpdateLocationDialogData())); + m_userInfoPanel, SIGNAL(clearUpdateLocationDialogData())); - connect(m_mapView, SIGNAL(viewResized(QSize)), - m_userPanel, SLOT(resizePanel(QSize))); - - connect(m_mapView, SIGNAL(viewResized(QSize)), - m_userPanelSidebar, SLOT(resizeSideBar(QSize))); - - connect(m_userPanel, SIGNAL(findUser(GeoCoordinate)), + connect(m_userInfoPanel, SIGNAL(findUser(GeoCoordinate)), this, SIGNAL(findUser(GeoCoordinate))); - connect(m_userPanel, SIGNAL(requestReverseGeo()), + connect(m_userInfoPanel, SIGNAL(requestReverseGeo()), this, SIGNAL(requestReverseGeo())); - connect(m_userPanel, SIGNAL(statusUpdate(QString,bool)), + connect(m_userInfoPanel, SIGNAL(statusUpdate(QString,bool)), this, SIGNAL(statusUpdate(QString,bool))); - connect(m_userPanel, SIGNAL(refreshUserData()), + connect(m_userInfoPanel, SIGNAL(refreshUserData()), this, SIGNAL(refreshUserData())); - connect(m_userPanel, SIGNAL(notificateUpdateFailing(QString, bool)), + connect(m_userInfoPanel, SIGNAL(notificateUpdateFailing(QString, bool)), this, SLOT(buildInformationBox(QString, bool))); + + m_tabbedPanel = new TabbedPanel(this); + m_tabbedPanel->addTab(m_userInfoPanel, QIcon(":/res/images/user_info.png")); + + // This is just testing + m_tabbedPanel->addTab(new QPushButton("Friend List"), QIcon(":/res/images/friend_list.png")); + + // Another test + m_tabbedPanel->addTab(new QPushButton("Routing"), QIcon(":/res/images/routing.png")); + + connect(m_mapView, SIGNAL(viewResized(QSize)), + m_tabbedPanel, SLOT(resizePanel(QSize))); } void MainWindow::buildWebView() @@ -500,16 +497,9 @@ void MainWindow::drawFullScreenButton(const QSize &size) { qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height(); - if(m_fullScreenButton) { - 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()); - } - } + if(m_fullScreenButton) + m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width(), + size.height() - m_fullScreenButton->size().height()); } void MainWindow::drawMapScale(const QSize &size) @@ -518,9 +508,9 @@ void MainWindow::drawMapScale(const QSize &size) const int LEFT_SCALE_MARGIN = 10; const int BOTTOM_SCALE_MARGIN = 2; - qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height(); +// qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height(); - m_mapScale->move(PANEL_PEEK_AMOUNT + LEFT_SCALE_MARGIN, + m_mapScale->move(LEFT_SCALE_MARGIN, size.height() - m_mapScale->size().height() - BOTTOM_SCALE_MARGIN); } @@ -529,7 +519,7 @@ void MainWindow::drawOsmLicense(const QSize &size) qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height(); m_osmLicense->move(size.width() - m_osmLicense->fontMetrics().width(OSM_LICENSE) - - PANEL_PEEK_AMOUNT, + - PANEL_BAR_WIDTH, size.height() - m_osmLicense->fontMetrics().height()); } @@ -909,17 +899,17 @@ void MainWindow::showPanels() drawFullScreenButton(m_viewPortSize); - if(m_loggedIn) { - if(!m_friendsListPanel->isVisible()) { - m_friendsListPanel->show(); - m_friendsListPanelSidebar->show(); - } +// if(m_loggedIn) { +// if(!m_friendsListPanel->isVisible()) { +// m_friendsListPanel->show(); +// m_friendsListPanelSidebar->show(); +// } - if(!m_userPanel->isVisible()) { - m_userPanel->show(); - m_userPanelSidebar->show(); - } - } +// if(!m_userPanel->isVisible()) { +// m_userPanel->show(); +// m_userPanelSidebar->show(); +// } +// } } void MainWindow::startLocationSearch() @@ -970,14 +960,14 @@ void MainWindow::updateItemVisibility() { qDebug() << __PRETTY_FUNCTION__; - if(!m_loggedIn) { - m_friendsListPanel->closePanel(); - m_friendsListPanel->hide(); - m_friendsListPanelSidebar->hide(); - m_userPanel->closePanel(); - m_userPanel->hide(); - m_userPanelSidebar->hide(); - } +// if(!m_loggedIn) { +// m_friendsListPanel->closePanel(); +// m_friendsListPanel->hide(); +// m_friendsListPanelSidebar->hide(); +// m_userPanel->closePanel(); +// m_userPanel->hide(); +// m_userPanelSidebar->hide(); +// } } const QString MainWindow::username() diff --git a/src/ui/mainwindow.h b/src/ui/mainwindow.h index 2189709..52b1404 100644 --- a/src/ui/mainwindow.h +++ b/src/ui/mainwindow.h @@ -29,7 +29,6 @@ #include #include "network/networkcookiejar.h" -#include "panelsidebar.h" class QGraphicsScene; class QLabel; @@ -46,6 +45,7 @@ class GeoCoordinate; class MapScale; class MapScene; class MapView; +class TabbedPanel; class SettingsDialog; class SceneCoordinate; class SituareService; @@ -53,7 +53,6 @@ class User; class UserInfoPanel; class ZoomButtonPanel; - /** * @brief Main Window Class */ @@ -151,7 +150,6 @@ public: const QString username(); public slots: - /** * @brief Build direction indicator button and connect slots */ @@ -647,9 +645,8 @@ private: MapScale *m_mapScale; ///< Instance of the map scale MapView *m_mapView; ///< Instance of the map view NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies - PanelSideBar *m_userPanelSidebar; ///< User panel side bar - PanelSideBar *m_friendsListPanelSidebar;///< Friends panel side bar - UserInfoPanel *m_userPanel; ///< Instance of the user information panel + TabbedPanel *m_tabbedPanel; ///< Widget for tabbed panels + UserInfoPanel *m_userInfoPanel; ///< Instance of the user information panel ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel }; diff --git a/src/ui/userinfo.cpp b/src/ui/userinfo.cpp index c6f11ae..7ee573f 100644 --- a/src/ui/userinfo.cpp +++ b/src/ui/userinfo.cpp @@ -23,18 +23,19 @@ USA. */ +#include "userinfo.h" + +#include "../user/user.h" #include "common.h" #include "imagebutton.h" -#include "../user/user.h" -#include "userinfo.h" -const int BACKGROUND_WIDTH = 240; ///< Width for item -const int BACKGROUND_TOP_HEIGHT = 16; ///< Height for item top +const int BACKGROUND_WIDTH = 368; ///< Width for item +const int BACKGROUND_TOP_HEIGHT = 20; ///< Height for item top const int BACKGROUND_BOTTOM_HEIGHT = 15; ///< Height for item bottom const int ICON_HEIGHT = 24; ///< Icon height const int ICON_WIDTH = 24; ///< Icon width const int MARGIN = 5; ///< Icon margin -const int LINE_LENGTH = 17; ///< Line length +const int LINE_LENGTH = 27; ///< Line length const int MOUSE_PRESS_AREA_WIDTH = 20; ///< Area width for item height toggling const int MOUSE_PRESS_AREA_HEIGHT = 20; ///< Area height for item height toggling @@ -127,9 +128,9 @@ UserInfo::UserInfo(QWidget *parent) namePalette.setColor(QPalette::Foreground, Qt::white); m_nameLabel->setPalette(namePalette); - m_backgroundTopImage.load(":/res/images/user_info_item_top.png"); - m_backgroundMiddleImage.load(":/res/images/user_info_item_middle.png"); - m_backgroundBottomImage.load(":/res/images/user_info_item_bottom.png"); + m_backgroundTopImage.load(":/res/images/list_item_top.png"); + m_backgroundMiddleImage.load(":/res/images/list_item_middle.png"); + m_backgroundBottomImage.load(":/res/images/list_item_bottom.png"); restoreUnsendMessage(); } @@ -301,7 +302,7 @@ void UserInfo::paintEvent(QPaintEvent *aPaintEvent) QRect topRect = QRect(0, MARGIN, BACKGROUND_WIDTH, BACKGROUND_TOP_HEIGHT); QRect middleRect = QRect(0, topRect.bottom(), BACKGROUND_WIDTH, - height() - BACKGROUND_TOP_HEIGHT - BACKGROUND_BOTTOM_HEIGHT); + this->height() - BACKGROUND_TOP_HEIGHT - BACKGROUND_BOTTOM_HEIGHT); QRect bottomRect = QRect(topRect.left(), middleRect.bottom(), BACKGROUND_WIDTH, BACKGROUND_BOTTOM_HEIGHT); @@ -333,7 +334,7 @@ QString UserInfo::shortenText(const QLabel *label, const QString &text, int text textParam.truncate(index); textParam.append("..."); } - if (textWidth > 150) + if (textWidth > 250) textParam.insert(LINE_LENGTH, QString("\n")); return labelMetrics.elidedText(textParam, Qt::ElideRight, textMaxWidth); @@ -361,5 +362,4 @@ void UserInfo::updateLocationDialogFinished(int reason) m_updateLocation->deleteLater(); m_updateLocation = 0; } - } diff --git a/src/ui/userinfo.h b/src/ui/userinfo.h index 23f436b..f3514c8 100644 --- a/src/ui/userinfo.h +++ b/src/ui/userinfo.h @@ -34,26 +34,27 @@ class ImageButton; /** -* @brief UserInfo shows user's data in expandable item. -* -* @class UserInfo userinfo.h "ui/userinfo.h" -*/ + * @brief UserInfo shows user's data in expandable item. + * + * @class UserInfo userinfo.h "ui/userinfo.h" + */ class UserInfo : public QWidget { Q_OBJECT + public: /** - * @brief Constructor - * - * @param parent Parent - */ + * @brief Constructor + * + * @param parent Parent + */ UserInfo(QWidget *parent=0); /** - * @brief Desctructor - * saves unsend user message to settings - * - */ + * @brief Desctructor + * saves unsend user message to settings + * + */ ~UserInfo(); /******************************************************************************* @@ -61,25 +62,25 @@ public: *******************************************************************************/ protected: /** - * @brief Set current mouse position to mouse event position. - * - * @param event QMouseEvent mouse press event - */ + * @brief Set current mouse position to mouse event position. + * + * @param event QMouseEvent mouse press event + */ void mousePressEvent(QMouseEvent *event); /** - * @brief Call toggleHeight if mouse position is unchanged. - * - * Check if current mouse position is same as mouse release position. - * @param event QMouseEvent mouse release event - */ + * @brief Call toggleHeight if mouse position is unchanged. + * + * Check if current mouse position is same as mouse release position. + * @param event QMouseEvent mouse release event + */ void mouseReleaseEvent(QMouseEvent *event); /** - * @brief This function is called when the widget is drawn - * - * @param aPaintEvent Pointer to paint event - */ + * @brief This function is called when the widget is drawn + * + * @param aPaintEvent Pointer to paint event + */ void paintEvent(QPaintEvent *aPaintEvent); /****************************************************************************** @@ -87,101 +88,98 @@ protected: ******************************************************************************/ public: /** - * @brief Sets the users current address - * - * @param address Reference to users current address - */ + * @brief Sets the users current address + * + * @param address Reference to users current address + */ void setAddress(const QString &address); /** - * @brief Sets the users current coordinates - * - * @param coordinates Reference to users current coordinates - */ + * @brief Sets the users current coordinates + * + * @param coordinates Reference to users current coordinates + */ void setCoordinates(const GeoCoordinate &coordinates); /** - * @brief Sets the user picture - * - * @param image Reference to user picture - */ + * @brief Sets the user picture + * + * @param image Reference to user picture + */ void setProfileImage(const QPixmap &image); /** - * @brief Sets the time of updated message - * - * @param time Reference to time when message was sent. - */ + * @brief Sets the time of updated message + * + * @param time Reference to time when message was sent. + */ void setTime(const QString &time); - /** - * @brief Sets the user name - * - * @param name Reference to user name - */ + /** + * @brief Sets the user name + * + * @param name Reference to user name + */ void setUserName(const QString &name); public slots: /** - * @brief Clears backups of message and publish on Facebook setting - */ + * @brief Clears backups of message and publish on Facebook setting + */ void clearUpdateLocationDialogData(); /** - * @brief Saves status message and Facebook publish setting - * - * @param status message that user sends. Message is stored to m_backupMessage data member - * @param publish setting that determines whether the user status message is published on - * Facebook. This value is stored to m_backupFacebookPublishPolicity data member. - */ + * @brief Saves status message and Facebook publish setting + * + * @param status message that user sends. Message is stored to m_backupMessage data member + * @param publish setting that determines whether the user status message is published on + * Facebook. This value is stored to m_backupFacebookPublishPolicity data member. + */ void backupUpdateLocationDialogData(const QString &status, bool publish); /** - * @brief Sets the message text - * - * @param text Reference to user message - */ + * @brief Sets the message text + * + * @param text Reference to user message + */ void setMessageText(const QString &text); private: /** - * @brief reads Unsend message from settings at startup - * - */ + * @brief reads Unsend message from settings at startup + */ void restoreUnsendMessage(); /** - * @brief Set shortened or full-length text to labels. - * - * @param expanded true if full-length text is set, false otherwise - */ + * @brief Set shortened or full-length text to labels. + * + * @param expanded true if full-length text is set, false otherwise + */ void setText(bool expanded); /** - * @brief Set shortened texts from User data. - * - * Text length is defined by MAXIMUM_CHARS. - */ + * @brief Set shortened texts from User data. + * + * Text length is defined by MAXIMUM_CHARS. + */ QString shortenText(const QLabel *label, const QString &text, int textMaxWidth); private slots: /** - * @brief Slot for find button click - */ + * @brief Slot for find button click + */ void findButtonClicked(); /** - * @brief Slot function to forward messageUpdate launch signal - * - */ + * @brief Slot function to forward messageUpdate launch signal + */ void messageUpdate(); /** - * @brief Slot function to get indication when dialog is finished - * - */ + * @brief Slot function to get indication when dialog is finished + */ void updateLocationDialogFinished(int reason); /****************************************************************************** @@ -189,70 +187,73 @@ private slots: ******************************************************************************/ signals: /** - * @brief Signal for finding user. - * - * @param coordinates user geo coordinates - */ + * @brief Signal for finding user. + * + * @param coordinates user geo coordinates + */ void findUser(const GeoCoordinate &coordinates); /** - * @brief Signal that used to inform user that his message/location update tp Situare server - * was failed. - * This signal is originally sended from UserInfo - * @param message message for notification - * @param modal true if modal notification otherwice false - */ + * @brief Signal that used to inform user that his message/location update tp Situare server + * was failed. + * This signal is originally sended from UserInfo + * @param message message for notification + * @param modal true if modal notification otherwice false + */ void notificateUpdateFailing(const QString &message, bool modal); /** - * @brief Signal for refreshing user data. - * - */ + * @brief Signal for refreshing user data. + */ void refreshUserData(); /** - * @brief Signal for requesting reverseGeo from SituareEngine - * - */ + * @brief Signal for requesting reverseGeo from SituareEngine + */ void requestReverseGeo(); /** - * @brief Signals, when address data is ready - * - * @param address Street address - */ + * @brief Signals, when address data is ready + * + * @param address Street address + */ void reverseGeoReady(const QString &address); /** - * @brief Signal for requestLocationUpdate from SituareEngine via MainWindow class - * - * @param status Status message - * @param publish Publish on Facebook - */ + * @brief Signal for requestLocationUpdate from SituareEngine via MainWindow class + * + * @param status Status message + * @param publish Publish on Facebook + */ void statusUpdate(const QString &status, const bool &publish); /****************************************************************************** * DATA MEMBERS ******************************************************************************/ private: - bool m_backupFacebookPublishPolicity; ///< Backup of publish on Facebook checkbox value - bool m_expanded; ///< Item expanded state - QLabel *m_locationLabel; ///< Location label - QLabel *m_nameLabel; ///< Name label - QLabel *m_statusTextLabel; ///< Status text label - QLabel *m_updatedLabel; ///< Updated label - QPixmap m_backgroundBottomImage; ///< Bottom background image - QPixmap m_backgroundMiddleImage; ///< Middle background image - QPixmap m_backgroundTopImage; ///< Top background image - QPoint m_mousePosition; ///< Current mouse press position - GeoCoordinate m_coordinates; ///< User current coordinates - QString m_address; ///< Address from where the new message was sent - QString m_backupMessage; ///< Backup of users message - QString m_expandedMessageText; ///< Expanded message text - QString m_messageText; ///< User's message - QString m_time; ///< Time when the new message was sent - QString m_userName; ///< User's name - ImageButton *m_findButton; ///< User find button + bool m_backupFacebookPublishPolicity; ///< Backup of publish on Facebook checkbox value + bool m_expanded; ///< Item expanded state + + QLabel *m_locationLabel; ///< Location label + QLabel *m_nameLabel; ///< Name label + QLabel *m_statusTextLabel; ///< Status text label + QLabel *m_updatedLabel; ///< Updated label + + QPixmap m_backgroundBottomImage; ///< Bottom background image + QPixmap m_backgroundMiddleImage; ///< Middle background image + QPixmap m_backgroundTopImage; ///< Top background image + + QPoint m_mousePosition; ///< Current mouse press position + + QString m_address; ///< Address from where the new message was sent + QString m_backupMessage; ///< Backup of users message + QString m_expandedMessageText; ///< Expanded message text + QString m_messageText; ///< User's message + QString m_time; ///< Time when the new message was sent + QString m_userName; ///< User's name + + GeoCoordinate m_coordinates; ///< User current coordinates + ImageButton *m_findButton; ///< User find button UpdateLocationDialog *m_updateLocation; ///< Update location dialog }; diff --git a/src/ui/userinfopanel.cpp b/src/ui/userinfopanel.cpp index ff41cef..f6cbb24 100644 --- a/src/ui/userinfopanel.cpp +++ b/src/ui/userinfopanel.cpp @@ -25,12 +25,10 @@ #include "panelcommon.h" UserInfoPanel::UserInfoPanel(QWidget *parent) - : SidePanel(parent) + : QWidget(parent) { qDebug() << __PRETTY_FUNCTION__; - setType(SidePanel::UserPanel); - m_userInfo = new UserInfo(this); QWidget *userInfoView = new QWidget(this); @@ -48,9 +46,6 @@ UserInfoPanel::UserInfoPanel(QWidget *parent) userInfoScroll->viewport()->setAutoFillBackground(false); userInfoScroll->widget()->setAutoFillBackground(false); - m_panelVBox->addWidget(userInfoScroll); - m_panelVBox->setContentsMargins(USERPANEL_MARGIN_LEFT, 0, USERPANEL_MARGIN_RIGHT, 0); - connect(m_userInfo, SIGNAL(findUser(GeoCoordinate)), this, SIGNAL(findUser(GeoCoordinate))); diff --git a/src/ui/userinfopanel.h b/src/ui/userinfopanel.h index cd9f1c3..84f7440 100644 --- a/src/ui/userinfopanel.h +++ b/src/ui/userinfopanel.h @@ -26,7 +26,6 @@ #include #include "../user/user.h" -#include "sidepanel.h" class UserInfo; @@ -36,7 +35,7 @@ class UserInfo; * @author Kaj Wallin - kaj.wallin (at) ixonos.com * @class UserInfoPanel */ -class UserInfoPanel : public SidePanel +class UserInfoPanel : public QWidget { Q_OBJECT -- 1.7.9.5